Class: BitClust::Subcommands::ExtractCommand
- Inherits:
-
BitClust::Subcommand
- Object
- BitClust::Subcommand
- BitClust::Subcommands::ExtractCommand
- Defined in:
- lib/bitclust/subcommands/extract_command.rb
Instance Method Summary collapse
- #exec(argv, options) ⇒ Object
-
#initialize ⇒ ExtractCommand
constructor
A new instance of ExtractCommand.
- #show_library(lib) ⇒ Object
Methods inherited from BitClust::Subcommand
#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root
Constructor Details
#initialize ⇒ ExtractCommand
Returns a new instance of ExtractCommand.
12 13 14 15 16 17 18 |
# File 'lib/bitclust/subcommands/extract_command.rb', line 12 def initialize super @parser. = "Usage: #{File.basename($0, '.*')} <file>..." @parser.on('-c', '--check-only', 'Check syntax and output status.') { @check_only = true } end |
Instance Method Details
#exec(argv, options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bitclust/subcommands/extract_command.rb', line 20 def exec(argv, ) success = true argv.each do |path| begin lib = RRDParser.parse_stdlib_file(path) if @check_only $stderr.puts "#{path}: OK" else show_library lib end rescue WriterError => err raise if $DEBUG $stderr.puts "#{File.basename($0, '.*')}: FAIL: #{err.}" success = false end end exit success end |
#show_library(lib) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bitclust/subcommands/extract_command.rb', line 39 def show_library(lib) puts "= Library #{lib.name}" lib.classes.each do |c| puts "#{c.type} #{c.name}" c.each do |m| puts "\t* #{m.klass.name}#{m.typemark}#{m.names.join(',')}" end end unless lib.methods.empty? puts "Additional Methods:" lib.methods.each do |m| puts "\t* #{m.klass.name}#{m.typemark}#{m.names.join(',')}" end end end |