Class: BitClust::Subcommands::MethodsinceCommand
- Inherits:
-
BitClust::Subcommand
- Object
- BitClust::Subcommand
- BitClust::Subcommands::MethodsinceCommand
- Defined in:
- lib/bitclust/subcommands/methodsince_command.rb
Instance Method Summary collapse
- #exec(argv, options) ⇒ Object
-
#initialize ⇒ MethodsinceCommand
constructor
A new instance of MethodsinceCommand.
-
#needs_database? ⇒ Boolean
DB パスは自前の引数(位置引数 + --update)で受けるので、 グローバル --database は不要.
Methods inherited from BitClust::Subcommand
#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root
Constructor Details
#initialize ⇒ MethodsinceCommand
Returns a new instance of MethodsinceCommand.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bitclust/subcommands/methodsince_command.rb', line 24 def initialize super @updates = [] @dry_run = false @parser. = "Usage: #{File.basename($0, '.*')} methodsince [options] <dbpath>..." @parser.on('--update=PATH', 'Writable target database to fill in-place (repeatable).') {|path| @updates.push path } @parser.on('--dry-run', 'Compute and print stats without saving.') { @dry_run = true } end |
Instance Method Details
#exec(argv, options) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bitclust/subcommands/methodsince_command.rb', line 43 def exec(argv, ) error("no --update given (nothing to write to)") if @updates.empty? ladder_paths = (argv + @updates).uniq {|path| File.(path) } calculator = MethodSinceCalculator.new(ladder_paths.map {|path| MethodDatabase.new(path) }) calculator.scan @updates.each do |path| stats, version = @dry_run ? apply_dry_run(calculator, path) : apply_and_save(calculator, path) puts "#{File.basename(path)} (version #{version}): " \ "entries_updated=#{stats[:entries_updated]} since_filled=#{stats[:since_filled]} " \ "until_filled=#{stats[:until_filled]} floor_skipped=#{stats[:floor_skipped]}" end end |
#needs_database? ⇒ Boolean
DB パスは自前の引数(位置引数 + --update)で受けるので、 グローバル --database は不要
39 40 41 |
# File 'lib/bitclust/subcommands/methodsince_command.rb', line 39 def needs_database? false end |