class RBS::CLI::LibraryOptions

Attributes

core_root[RW]
dirs[R]
libs[R]
repos[R]

Public Class Methods

new() click to toggle source
# File rbs-1.4.0/lib/rbs/cli.rb, line 13
def initialize()
  @core_root = EnvironmentLoader::DEFAULT_CORE_ROOT
  @repos = []

  @libs = []
  @dirs = []
end

Public Instance Methods

loader() click to toggle source
# File rbs-1.4.0/lib/rbs/cli.rb, line 21
def loader
  repository = Repository.new(no_stdlib: core_root.nil?)
  repos.each do |repo|
    repository.add(Pathname(repo))
  end

  loader = EnvironmentLoader.new(core_root: core_root, repository: repository)

  dirs.each do |dir|
    loader.add(path: Pathname(dir))
  end

  libs.each do |lib|
    name, version = lib.split(/:/, 2)
    next unless name
    loader.add(library: name, version: version)
  end

  loader
end
setup_library_options(opts) click to toggle source
# File rbs-1.4.0/lib/rbs/cli.rb, line 42
def setup_library_options(opts)
  opts.on("-r LIBRARY", "Load RBS files of the library") do |lib|
    libs << lib
  end

  opts.on("-I DIR", "Load RBS files from the directory") do |dir|
    dirs << dir
  end

  opts.on("--no-stdlib", "Skip loading standard library signatures") do
    self.core_root = nil
  end

  opts.on("--repo DIR", "Add RBS repository") do |dir|
    repos << dir
  end

  opts
end