class RBS::Collection::Config
This class represent the configuration file.
def self.find_config_path
def self.find_config_path current = Pathname.pwd loop do config_path = current.join(PATH) return config_path if config_path.exist? current = current.join('..') return nil if current.root? end end
def self.from_path(path)
def self.from_path(path) new(YAML.load(path.read), config_path: path) end
def self.generate_lockfile(config_path:, definition:, with_lockfile: true)
Generate a rbs lockfile from Gemfile.lock to `config_path`.
def self.generate_lockfile(config_path:, definition:, with_lockfile: true) config = from_path(config_path) lockfile = LockfileGenerator.generate(config: config, definition: definition, with_lockfile: with_lockfile) [config, lockfile] end
def self.to_lockfile_path(config_path)
def self.to_lockfile_path(config_path) config_path.sub_ext('.lock' + config_path.extname) end
def gem(gem_name)
def gem(gem_name) gems.find { |gem| gem['name'] == gem_name } end
def gems
def gems @data['gems'] ||= ( [] #: Array[gem_entry] ) end
def initialize(data, config_path:)
def initialize(data, config_path:) @data = data @config_path = config_path end
def repo_path
def repo_path @config_path.dirname.join repo_path_data end
def repo_path_data
def repo_path_data Pathname(@data["path"]) end
def sources
def sources @sources ||= [ Sources::Rubygems.instance, *@data['sources'].map { |c| Sources.from_config_entry(c, base_directory: @config_path.dirname) }, Sources::Stdlib.instance ] end