Class: BitClust::Subcommands::RbssigCommand
- Inherits:
-
BitClust::Subcommand
- Object
- BitClust::Subcommand
- BitClust::Subcommands::RbssigCommand
- Defined in:
- lib/bitclust/subcommands/rbssig_command.rb
Constant Summary collapse
- MINIMUM_VERSION =
Gem::Version.new('4.0')
Instance Method Summary collapse
- #exec(argv, options) ⇒ Object
-
#initialize ⇒ RbssigCommand
constructor
A new instance of RbssigCommand.
-
#needs_database? ⇒ Boolean
DB パスは位置引数で受けるのでグローバル --database は不要.
Methods inherited from BitClust::Subcommand
#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root
Constructor Details
#initialize ⇒ RbssigCommand
Returns a new instance of RbssigCommand.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bitclust/subcommands/rbssig_command.rb', line 26 def initialize super @sig_root = nil @sig_dirs = [] @dry_run = false @parser. = "Usage: #{File.basename($0, '.*')} rbssig [options] <dbpath>" @parser.on('--sig-root=PATH', 'ruby/rbs checkout containing core/ and stdlib/.') {|path| @sig_root = path } @parser.on('--sig-dir=PATH', 'Directory of extra .rbs files (repeatable).') {|path| @sig_dirs.push path } @parser.on('--dry-run', 'Compute and print stats without saving.') { @dry_run = true } end |
Instance Method Details
#exec(argv, options) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bitclust/subcommands/rbssig_command.rb', line 48 def exec(argv, ) error('no --sig-root or --sig-dir given') if @sig_root.nil? && @sig_dirs.empty? error("wrong number of arguments (#{argv.size} for 1)") unless argv.size == 1 path = argv.first version = check_version(path) sig_root = @sig_root importer = RbsSigImporter.new( core_root: sig_root && File.join(sig_root, 'core'), repository_root: sig_root && File.join(sig_root, 'stdlib'), sig_dirs: @sig_dirs) stats = if @dry_run apply_dry_run(importer, path) else importer.apply(MethodDatabase.new(path)) end puts "#{File.basename(path)} (version #{version}): " \ "entries_updated=#{stats[:entries_updated]} sigs_matched=#{stats[:sigs_matched]} " \ "methods_missed=#{stats[:methods_missed]}" end |
#needs_database? ⇒ Boolean
DB パスは位置引数で受けるのでグローバル --database は不要
44 45 46 |
# File 'lib/bitclust/subcommands/rbssig_command.rb', line 44 def needs_database? false end |