In Files

  • rbs-2.1.0/lib/rbs/collection/sources/git.rb

Class/Module Index [+]

Quicksearch

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.1.0/lib/rbs/collection/sources/git.rb, line 15
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.1.0/lib/rbs/collection/sources/git.rb, line 23
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.1.0/lib/rbs/collection/sources/git.rb, line 33
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.1.0/lib/rbs/collection/sources/git.rb, line 53
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
            
versions(config_entry) click to toggle source
 
               # File rbs-2.1.0/lib/rbs/collection/sources/git.rb, line 28
def versions(config_entry)
  gem_name = config_entry['name']
  gem_repo_dir.join(gem_name).glob('*/').map { |path| path.basename.to_s }
end