Class: Bundler::InstallDashDocs::Lockfile
- Inherits:
-
Object
- Object
- Bundler::InstallDashDocs::Lockfile
- Defined in:
- lib/bundler/install_dash_docs/lockfile.rb
Overview
Reads & parses a Gemfile.lock Lockfile, to extract the gems listed in it
Note that some gems may be listed multiple times, with different versions
Instance Attribute Summary collapse
-
#all_gems ⇒ Object
readonly
Array of [gem_name, version] pairs that includes all gems from the Lockfile.
-
#dependencies ⇒ Object
readonly
Array of [gem_name, version] pairs that are listed in the Dependencies section.
Instance Method Summary collapse
-
#initialize(lockfile_contents = nil) ⇒ Lockfile
constructor
Constructor that parses gem names and versions from the Lockfile.
Constructor Details
#initialize(lockfile_contents = nil) ⇒ Lockfile
Constructor that parses gem names and versions from the Lockfile
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bundler/install_dash_docs/lockfile.rb', line 22 def initialize(lockfile_contents = nil) lockfile_contents ||= Bundler.default_lockfile.read @parser = Bundler::LockfileParser.new(lockfile_contents) # dictionary of gem name to array of Bundler::LazySpecification @specs = @parser.specs.group_by(&:name) # create arrays of [name, version] pairs for all specs, # and only for dependencies from Gemfile @all_gems, @dependencies = [ @specs, @parser.dependencies ].map { |hash| hash.keys .sort .flat_map { |name| versions_for_name(name).map { |version| [name, version] } } } end |
Instance Attribute Details
#all_gems ⇒ Object (readonly)
Array of [gem_name, version] pairs that includes all gems from the Lockfile
16 17 18 |
# File 'lib/bundler/install_dash_docs/lockfile.rb', line 16 def all_gems @all_gems end |
#dependencies ⇒ Object (readonly)
Array of [gem_name, version] pairs that are listed in the Dependencies section. Most likely ones that’re specifically requested by the Gemfile
13 14 15 |
# File 'lib/bundler/install_dash_docs/lockfile.rb', line 13 def dependencies @dependencies end |