class Bundler::LockfileParser

Constants

DEPENDENCIES
GEM
GIT
NAME_VERSION
NAME_VERSION_2
NAME_VERSION_4
NAME_VERSION_6
OPTIONS
PATH
PLATFORMS
SPECS
TYPES

Attributes

dependencies[R]
platforms[R]
sources[R]
specs[R]

Public Class Methods

new(lockfile) click to toggle source
# File lib/bundler/lockfile_parser.rb, line 25
def initialize(lockfile)
  @platforms    = []
  @sources      = []
  @dependencies = []
  @state        = :source
  @specs        = {}

  @rubygems_aggregate = Source::Rubygems.new

  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
  @sources << @rubygems_aggregate
  @specs = @specs.values
end