Class: RBS::Collection::Config::LockfileGenerator
- Inherits:
-
Object
- Object
- RBS::Collection::Config::LockfileGenerator
- Defined in:
- lib/rbs/collection/config/lockfile_generator.rb
Defined Under Namespace
Classes: GemfileLockMismatchError
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#gemfile_lock ⇒ Object
readonly
Returns the value of attribute gemfile_lock.
-
#lock ⇒ Object
readonly
Returns the value of attribute lock.
-
#lock_path ⇒ Object
readonly
Returns the value of attribute lock_path.
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(config_path:, gemfile_lock_path:, with_lockfile:) ⇒ LockfileGenerator
constructor
A new instance of LockfileGenerator.
Constructor Details
#initialize(config_path:, gemfile_lock_path:, with_lockfile:) ⇒ LockfileGenerator
Returns a new instance of LockfileGenerator.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 29 def initialize(config_path:, gemfile_lock_path:, with_lockfile:) @config = Config.from_path config_path @lock_path = Config.to_lockfile_path(config_path) @lock = Config.from_path(lock_path) if lock_path.exist? && with_lockfile @gemfile_lock = Bundler::LockfileParser.new(gemfile_lock_path.read) @gem_queue = [] validate_gemfile_lock_path!(lock: lock, gemfile_lock_path: gemfile_lock_path) config.gemfile_lock_path = gemfile_lock_path end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
23 24 25 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 23 def config @config end |
#gemfile_lock ⇒ Object (readonly)
Returns the value of attribute gemfile_lock.
23 24 25 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 23 def gemfile_lock @gemfile_lock end |
#lock ⇒ Object (readonly)
Returns the value of attribute lock.
23 24 25 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 23 def lock @lock end |
#lock_path ⇒ Object (readonly)
Returns the value of attribute lock_path.
23 24 25 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 23 def lock_path @lock_path end |
Class Method Details
.generate(config_path:, gemfile_lock_path:, with_lockfile: true) ⇒ Object
25 26 27 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 25 def self.generate(config_path:, gemfile_lock_path:, with_lockfile: true) new(config_path: config_path, gemfile_lock_path: gemfile_lock_path, with_lockfile: with_lockfile).generate end |
Instance Method Details
#generate ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 41 def generate config.gems.each do |gem| @gem_queue.push({ name: gem['name'], version: gem['version'] }) end gemfile_lock_gems do |spec| @gem_queue.push({ name: spec.name, version: spec.version }) end while gem = @gem_queue.shift assign_gem(**gem) end remove_ignored_gems! config.dump_to(lock_path) config end |