class RBS::Collection::Config::LockfileGenerator
Constants
- ALUMNI_STDLIBS
-
Name of stdlibs that was rbs-bundled stdlib but is now a gem.
Attributes
config
[R]
Config
gem_entries
[R]
Hash[String, gem_entry?]
A hash table to look up a gem entry in collection config from the name of the gem
A hash table to look up a spec from name of the gem
Public Class Methods
(config: Config, definition: Bundler::Definition, ?with_lockfile: boolish) → Lockfile
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/collection/config/lockfile_generator.rb, line 42 def self.generate(config:, definition:, with_lockfile: true) generator = new(config: config, definition: definition, with_lockfile: with_lockfile) generator.generate generator.lockfile end
(config: Config, definition: Bundler::Definition, with_lockfile: boolish) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/collection/config/lockfile_generator.rb, line 48 def initialize(config:, definition:, with_lockfile:) @config = config @gem_entries = config.gems.each.with_object({}) do |entry, hash| #$ Hash[String, gem_entry?] name = entry["name"] hash[name] = entry end lockfile_path = Config.to_lockfile_path(config.config_path) lockfile_dir = lockfile_path.parent @lockfile = Lockfile.new( lockfile_path: lockfile_path, path: config.repo_path_data, gemfile_lock_path: definition.lockfile.relative_path_from(lockfile_dir) ) if with_lockfile && lockfile_path.file? @existing_lockfile = Lockfile.from_lockfile(lockfile_path: lockfile_path, data: YAML.load_file(lockfile_path.to_s)) validate_gemfile_lock_path!(lock: @existing_lockfile, gemfile_lock_path: definition.lockfile) end @definition = definition @gem_hash = definition.locked_gems.specs.each.with_object({}) do |spec, hash| #$ Hash[String, Bundler::LazySpecification] hash[spec.name] = spec end end
Public Instance Methods
() → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/collection/config/lockfile_generator.rb, line 76 def generate config.gems.each do |gem| case when gem.dig("source", "type") == "stdlib" unless gem.fetch("ignore", false) assign_stdlib(name: gem["name"]) end else assign_gem(name: gem["name"], version: gem["version"]) end end definition.dependencies.each do |dep| if dep.autorequire && dep.autorequire.empty? next end if spec = gem_hash[dep.name] assign_gem(name: dep.name, version: spec.version, skip: dep.source.is_a?(Bundler::Source::Gemspec)) end end lockfile.lockfile_path.write(YAML.dump(lockfile.to_lockfile)) end