Class: Bundler::LockfileParser
- Inherits:
-
Object
- Object
- Bundler::LockfileParser
- Defined in:
- lib/bundler/lockfile_parser.rb
Constant Summary collapse
- DEPENDENCIES =
"DEPENDENCIES"
- PLATFORMS =
"PLATFORMS"
- GIT =
"GIT"
- GEM =
"GEM"
- PATH =
"PATH"
- SPECS =
" specs:"
- OPTIONS =
/^ ([a-z]+): (.*)$/i
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#platforms ⇒ Object
readonly
Returns the value of attribute platforms.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
Instance Method Summary collapse
-
#initialize(lockfile) ⇒ LockfileParser
constructor
A new instance of LockfileParser.
Constructor Details
#initialize(lockfile) ⇒ LockfileParser
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 48 49 50 51 52 53 54 |
# 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 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 |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
15 16 17 |
# File 'lib/bundler/lockfile_parser.rb', line 15 def dependencies @dependencies end |
#platforms ⇒ Object (readonly)
Returns the value of attribute platforms.
15 16 17 |
# File 'lib/bundler/lockfile_parser.rb', line 15 def platforms @platforms end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
15 16 17 |
# File 'lib/bundler/lockfile_parser.rb', line 15 def sources @sources end |
#specs ⇒ Object (readonly)
Returns the value of attribute specs.
15 16 17 |
# File 'lib/bundler/lockfile_parser.rb', line 15 def specs @specs end |