class Bundler::LockfileParser
Constants
- BUNDLED
- DEPENDENCIES
- GEM
- GIT
- NAME_VERSION
- NAME_VERSION_2
- NAME_VERSION_4
- NAME_VERSION_6
- OPTIONS
- PATH
- PLATFORMS
- SOURCE
- SPECS
- TYPES
Attributes
bundler_version[R]
dependencies[R]
platforms[R]
sources[R]
specs[R]
Public Class Methods
new(lockfile)
click to toggle source
# File lib/bundler/lockfile_parser.rb, line 27 def initialize(lockfile) @platforms = [] @sources = [] @dependencies = [] @state = nil @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 SOURCE.include?(line) @state = :source parse_source(line) elsif line == DEPENDENCIES @state = :dependency elsif line == PLATFORMS @state = :platform elsif line == BUNDLED @state = :bundled_with elsif line =~ /^[^\s]/ @state = nil elsif @state send("parse_#{@state}", line) end end @sources << @rubygems_aggregate @specs = @specs.values warn_for_outdated_bundler_version rescue ArgumentError => e Bundler.ui.debug(e) raise LockfileError, "Your lockfile is unreadable. Run `rm Gemfile.lock` " "and then `bundle install` to generate a new lockfile." end
Public Instance Methods
warn_for_outdated_bundler_version()
click to toggle source
# File lib/bundler/lockfile_parser.rb, line 66 def warn_for_outdated_bundler_version return unless bundler_version prerelease_text = bundler_version.prerelease? ? " --pre" : "" current_version = Gem::Version.create(Bundler::VERSION) case current_version.segments.first <=> bundler_version.segments.first when -1 raise LockfileError, "You must use Bundler #{bundler_version.segments.first} or greater with this lockfile." when 0 if current_version < bundler_version Bundler.ui.warn "Warning: the running version of Bundler is older " "than the version that created the lockfile. We suggest you " "upgrade to the latest version of Bundler by running `gem " "install bundler#{prerelease_text}`.\n" end end end