In Files

  • rbs-2.1.0/lib/rbs/collection/config/lockfile_generator.rb

Parent

Class/Module Index [+]

Quicksearch

RBS::Collection::Config::LockfileGenerator

Attributes

config[R]
gemfile_lock[R]
lock[R]
lock_path[R]

Public Class Methods

generate(config_path:, gemfile_lock_path:, with_lockfile: true) click to toggle source
 
               # File rbs-2.1.0/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
            
new(config_path:, gemfile_lock_path:, with_lockfile:) click to toggle source
 
               # File rbs-2.1.0/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)
  @gem_queue = []
end
            

Public Instance Methods

generate() click to toggle source
 
               # File rbs-2.1.0/lib/rbs/collection/config/lockfile_generator.rb, line 21
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