Object
# File lib/bundler/lockfile_parser.rb, line 7
7: def initialize(lockfile)
8: @platforms = []
9: @sources = []
10: @dependencies = []
11: @specs = []
12: @state = :source
13:
14: lockfile.split(/(\r?\n)+/).each do |line|
15: if line == "DEPENDENCIES"
16: @state = :dependency
17: elsif line == "PLATFORMS"
18: @state = :platform
19: else
20: send("parse_#{@state}", line)
21: end
22: end
23: end
# File lib/bundler/lockfile_parser.rb, line 61
61: def parse_dependency(line)
62: if line =~ %{^ {2}#{NAME_VERSION}(!)?$}
63: name, version, pinned = $1, $2, $4
64: version = version.split(",").map { |d| d.strip } if version
65:
66: dep = Bundler::Dependency.new(name, version)
67:
68: if pinned && dep.name != 'bundler'
69: spec = @specs.find { |s| s.name == dep.name }
70: dep.source = spec.source if spec
71:
72: # Path sources need to know what the default name / version
73: # to use in the case that there are no gemspecs present. A fake
74: # gemspec is created based on the version set on the dependency
75: # TODO: Use the version from the spec instead of from the dependency
76: if version && version.size == 1 && version.first =~ /^\s*= (.+)\s*$/ && dep.source.is_a?(Bundler::Source::Path)
77: dep.source.name = name
78: dep.source.version = $1
79: end
80: end
81:
82: @dependencies << dep
83: end
84: end
# File lib/bundler/lockfile_parser.rb, line 101
101: def parse_platform(line)
102: if line =~ /^ (.*)$/
103: @platforms << Gem::Platform.new($1)
104: end
105: end
# File lib/bundler/lockfile_parser.rb, line 33
33: def parse_source(line)
34: case line
35: when "GIT", "GEM", "PATH"
36: @current_source = nil
37: @opts, @type = {}, line
38: when " specs:"
39: @current_source = TYPES[@type].from_lock(@opts)
40: @sources << @current_source
41: when /^ ([a-z]+): (.*)$/
42: value = $2
43: value = true if value == "true"
44: value = false if value == "false"
45:
46: key = $1
47:
48: if @opts[key]
49: @opts[key] = Array(@opts[key])
50: @opts[key] << value
51: else
52: @opts[key] = value
53: end
54: else
55: parse_spec(line)
56: end
57: end
# File lib/bundler/lockfile_parser.rb, line 86
86: def parse_spec(line)
87: if line =~ %{^ {4}#{NAME_VERSION}$}
88: name, version = $1, Gem::Version.new($2)
89: platform = $3 ? Gem::Platform.new($3) : Gem::Platform::RUBY
90: @current_spec = LazySpecification.new(name, version, platform)
91: @current_spec.source = @current_source
92: @specs << @current_spec
93: elsif line =~ %{^ {6}#{NAME_VERSION}$}
94: name, version = $1, $2
95: version = version.split(',').map { |d| d.strip } if version
96: dep = Gem::Dependency.new(name, version)
97: @current_spec.dependencies << dep
98: end
99: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.