Class: RBS::Collection::Config::LockfileGenerator
- Inherits:
-
Object
- Object
- RBS::Collection::Config::LockfileGenerator
- Defined in:
- lib/rbs/collection/config/lockfile_generator.rb
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.
13 14 15 16 17 18 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 13 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) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 7 def config @config end |
#gemfile_lock ⇒ Object (readonly)
Returns the value of attribute gemfile_lock.
7 8 9 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 7 def gemfile_lock @gemfile_lock end |
#lock ⇒ Object (readonly)
Returns the value of attribute lock.
7 8 9 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 7 def lock @lock end |
#lock_path ⇒ Object (readonly)
Returns the value of attribute lock_path.
7 8 9 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 7 def lock_path @lock_path end |
Class Method Details
.generate(config_path:, gemfile_lock_path:, with_lockfile: true) ⇒ Object
9 10 11 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 9 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
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbs/collection/config/lockfile_generator.rb', line 20 def generate config.gems.each do |gem| assign_gem(gem_name: gem['name'], version: gem['version']) end gemfile_lock_gems do |spec| assign_gem(gem_name: spec.name, version: spec.version) end remove_ignored_gems! config.dump_to(lock_path) config end |