Class: RBS::CLI::LibraryOptions
- Inherits:
-
Object
- Object
- RBS::CLI::LibraryOptions
- Defined in:
- lib/rbs/cli.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#core_root ⇒ Object
Returns the value of attribute core_root.
-
#dirs ⇒ Object
readonly
Returns the value of attribute dirs.
-
#libs ⇒ Object
readonly
Returns the value of attribute libs.
-
#repos ⇒ Object
readonly
Returns the value of attribute repos.
Instance Method Summary collapse
-
#initialize ⇒ LibraryOptions
constructor
A new instance of LibraryOptions.
- #loader ⇒ Object
- #setup_library_options(opts) ⇒ Object
Constructor Details
#initialize ⇒ LibraryOptions
Returns a new instance of LibraryOptions.
16 17 18 19 20 21 22 23 |
# File 'lib/rbs/cli.rb', line 16 def initialize() @core_root = EnvironmentLoader::DEFAULT_CORE_ROOT @repos = [] @libs = [] @dirs = [] @config_path = Collection::Config.find_config_path || Collection::Config::PATH end |
Instance Attribute Details
#config_path ⇒ Object
Returns the value of attribute config_path.
11 12 13 |
# File 'lib/rbs/cli.rb', line 11 def config_path @config_path end |
#core_root ⇒ Object
Returns the value of attribute core_root.
10 11 12 |
# File 'lib/rbs/cli.rb', line 10 def core_root @core_root end |
#dirs ⇒ Object (readonly)
Returns the value of attribute dirs.
14 15 16 |
# File 'lib/rbs/cli.rb', line 14 def dirs @dirs end |
#libs ⇒ Object (readonly)
Returns the value of attribute libs.
13 14 15 |
# File 'lib/rbs/cli.rb', line 13 def libs @libs end |
#repos ⇒ Object (readonly)
Returns the value of attribute repos.
12 13 14 |
# File 'lib/rbs/cli.rb', line 12 def repos @repos end |
Instance Method Details
#loader ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rbs/cli.rb', line 25 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) lock = config_path&.then { |p| Collection::Config.lockfile_of(p) } loader.add_collection(lock) if lock 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) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rbs/cli.rb', line 48 def (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('--collection PATH', "File path of collection configuration (default: #{Collection::Config::PATH})") do |path| self.config_path = Pathname(path). end opts.on('--no-collection', 'Ignore collection configuration') do self.config_path = nil end opts.on("--repo DIR", "Add RBS repository") do |dir| repos << dir end opts end |