Class: Bundler::LockfileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/lockfile_parser.rb

Constant Summary

DEPENDENCIES =
"DEPENDENCIES"
PLATFORMS =
"PLATFORMS"
GIT =
"GIT"
GEM =
"GEM"
PATH =
"PATH"
SPECS =
"  specs:"
OPTIONS =
/^  ([a-z]+): (.*)$/i

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (LockfileParser) initialize(lockfile)

Returns a new instance of LockfileParser



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bundler/lockfile_parser.rb', line 25

def initialize(lockfile)
  @platforms    = []
  @sources      = []
  @dependencies = []
  @state        = :source
  @specs        = {}

  if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
    raise LockfileError, "Your Gemfile.lock contains merge conflicts.\n" \
      "Run `git checkout HEAD -- Gemfile.lock` first to get a clean lock."
  end

  lockfile.split(/(?:\r?\n)+/).each do |line|
    if line == DEPENDENCIES
      @state = :dependency
    elsif line == PLATFORMS
      @state = :platform
    else
      send("parse_#{@state}", line)
    end
  end
  @specs = @specs.values
end

Instance Attribute Details

- (Object) dependencies (readonly)

Returns the value of attribute dependencies



15
16
17
# File 'lib/bundler/lockfile_parser.rb', line 15

def dependencies
  @dependencies
end

- (Object) platforms (readonly)

Returns the value of attribute platforms



15
16
17
# File 'lib/bundler/lockfile_parser.rb', line 15

def platforms
  @platforms
end

- (Object) sources (readonly)

Returns the value of attribute sources



15
16
17
# File 'lib/bundler/lockfile_parser.rb', line 15

def sources
  @sources
end

- (Object) specs (readonly)

Returns the value of attribute specs



15
16
17
# File 'lib/bundler/lockfile_parser.rb', line 15

def specs
  @specs
end