class RBS::Collection::Sources::Git

Constants

METADATA_FILENAME

Attributes

name[R]
remote[R]
repo_dir[R]

Public Class Methods

new(name:, revision:, remote:, repo_dir:) click to toggle source
# File rbs-2.7.0/lib/rbs/collection/sources/git.rb, line 18
def initialize(name:, revision:, remote:, repo_dir:)
  @name = name
  @remote = remote
  @repo_dir = repo_dir || 'gems'

  setup!(revision: revision)
end

Public Instance Methods

has?(config_entry) click to toggle source
# File rbs-2.7.0/lib/rbs/collection/sources/git.rb, line 26
def has?(config_entry)
  gem_name = config_entry['name']
  gem_repo_dir.join(gem_name).directory?
end
install(dest:, config_entry:, stdout:) click to toggle source
# File rbs-2.7.0/lib/rbs/collection/sources/git.rb, line 36
def install(dest:, config_entry:, stdout:)
  gem_name = config_entry['name']
  version = config_entry['version'] or raise
  gem_dir = dest.join(gem_name, version)

  if gem_dir.directory?
    if (prev = YAML.load_file(gem_dir.join(METADATA_FILENAME))) == config_entry
      stdout.puts "Using #{format_config_entry(config_entry)}"
    else
      # @type var prev: RBS::Collection::Config::gem_entry
      stdout.puts "Updating to #{format_config_entry(config_entry)} from #{format_config_entry(prev)}"
      FileUtils.remove_entry_secure(gem_dir.to_s)
      _install(dest: dest, config_entry: config_entry)
    end
  else
    stdout.puts "Installing #{format_config_entry(config_entry)}"
    _install(dest: dest, config_entry: config_entry)
  end
end
manifest_of(config_entry) click to toggle source
# File rbs-2.7.0/lib/rbs/collection/sources/git.rb, line 56
def manifest_of(config_entry)
  gem_name = config_entry['name']
  version = config_entry['version'] or raise
  gem_dir = gem_repo_dir.join(gem_name, version)

  manifest_path = gem_dir.join('manifest.yaml')
  YAML.safe_load(manifest_path.read) if manifest_path.exist?
end
to_lockfile() click to toggle source
# File rbs-2.7.0/lib/rbs/collection/sources/git.rb, line 90
def to_lockfile
  {
    'type' => 'git',
    'name' => name,
    'revision' => resolved_revision,
    'remote' => remote,
    'repo_dir' => repo_dir,
  }
end
versions(config_entry) click to toggle source
# File rbs-2.7.0/lib/rbs/collection/sources/git.rb, line 31
def versions(config_entry)
  gem_name = config_entry['name']
  gem_repo_dir.join(gem_name).glob('*/').map { |path| path.basename.to_s }
end