Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding unknown state to lockfile parser. Adding support for metadata #3

Open
wants to merge 1 commit into from

2 participants

@garru
Collaborator

for the gemfile below "version: 1.0.6" was added as a dependency. this patch fixes it so that new gemfile types will not mess up parsing, by adding a new state "unknown"

GEM
specs:
activesupport (2.3.9)
fauna-mysql (2.8.1.3)
kgio (2.0.0)
memcached (0.17.4)
tbird-client (0.1.0)
thrift (0.2.0)
thrift_client (0.4.0)
thrift

PLATFORMS
ruby

DEPENDENCIES
activesupport (< 3.1)
fauna-mysql (= 2.8.1.3)
kgio (= 2.0.0)
memcached (= 0.17.4)
tbird-client (= 0.1.0)
thrift (= 0.2.0)
thrift_client (= 0.4.0)

METADATA
version: 1.0.6

@freels
Collaborator

Apparently bundler 1.0.6 was pulled because this metadata block was completely broken. Older versions of bundler tried to install the gem "version" or something. 1.0.7 fixed this. I'm not sure if bundler will use the same metadata section in later versions. (Though we should pull this in if that's the case, or modified if not.)

@garru
Collaborator

i don't really care about the metadata. do you want me to repatch with just the unknown state fix?

@freels
Collaborator

Yeah, that sounds reasonable, though perhaps we should bail if we don't know what a section means?

@garru
Collaborator

all spitball cares about are dependencies right? if they decide to add back the metadata section or maybe an even more innocuous hypothetical comments section do you want spitball to just raise something like "unknown Gemfile.lock format?"

i ran into this problem when trying to use spitball with a gemfile generated with bundler 1.0.6 and i got a "run bundle install" error. so i just want to help the next person.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 20, 2010
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 3 deletions.
  1. +23 −3 lib/ext/bundler_lockfile_parser.rb
View
26 lib/ext/bundler_lockfile_parser.rb
@@ -2,7 +2,7 @@
module Bundler
class FakeLockfileParser
- attr_reader :sources, :dependencies, :specs, :platforms
+ attr_reader :sources, :dependencies, :specs, :platforms, :metadata
def initialize(lockfile)
@platforms = []
@@ -10,14 +10,18 @@ def initialize(lockfile)
@dependencies = []
@specs = []
@state = :source
-
+ @metadata = {}
lockfile.split(/(\r?\n)+/).each do |line|
if line == "DEPENDENCIES"
@state = :dependency
elsif line == "PLATFORMS"
@state = :platform
+ elsif line == "METADATA"
+ @state = :metadata
+ elsif line =~ /^[A-Z]/
+ @state = :unknown
else
- send("parse_#{@state}", line)
+ send("parse_#{@state}", line) unless @state == :unknown
end
end
end
@@ -105,5 +109,21 @@ def parse_platform(line)
end
end
+ def parse_metadata(line)
+ if line =~ /^ ([a-z]+): (.*)$/i
+ value = $2
+ value = true if value == "true"
+ value = false if value == "false"
+
+ key = $1
+
+ if @metadata[key]
+ @metadata[key] = Array(@metadata[key])
+ @metadata[key] << value
+ else
+ @metadata[key] = value
+ end
+ end
+ end
end
end
Something went wrong with that request. Please try again.