Class: BitClust::Subcommands::ClassesCommand
- Inherits:
-
BitClust::Subcommand
- Object
- BitClust::Subcommand
- BitClust::Subcommands::ClassesCommand
- Includes:
- CrossRubyUtils
- Defined in:
- lib/bitclust/subcommands/classes_command.rb
Instance Method Summary collapse
- #defined_classes(ruby, lib, rejects) ⇒ Object
- #exec(argv, options) ⇒ Object
-
#initialize ⇒ ClassesCommand
constructor
A new instance of ClassesCommand.
-
#needs_database? ⇒ Boolean
システムの ruby を調べるだけで DB を使わない.
- #parse(argv) ⇒ Object
Methods inherited from BitClust::Subcommand
#align_progress_bar_title, #error, #help, #option_error, #srcdir_root
Constructor Details
#initialize ⇒ ClassesCommand
Returns a new instance of ClassesCommand.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bitclust/subcommands/classes_command.rb', line 12 def initialize super @rejects = [] @verbose = false @parser. = "Usage: #{File.basename($0, '.*')} [-r<lib>] <lib>" @parser.on('-r', '--reject=LIB', 'Reject library LIB') {|lib| @rejects.concat lib.split(',') } @parser.on('-v', '--verbose', 'Show all ruby version.') { @verbose = true } end |
Instance Method Details
#defined_classes(ruby, lib, rejects) ⇒ Object
40 41 42 43 44 45 46 47 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 75 76 |
# File 'lib/bitclust/subcommands/classes_command.rb', line 40 def defined_classes(ruby, lib, rejects) script = <<-SCRIPT def class_extent result = [] ObjectSpace.each_object(Module) do |c| result.push c end result end %w(#{rejects.join(" ")}).each do |lib| begin require lib rescue LoadError end end if "#{lib}" == "_builtin" class_extent().each do |c| puts c end else before = class_extent() begin require "#{lib}" rescue LoadError $stderr.puts "\#{RUBY_VERSION} (\#{RUBY_RELEASE_DATE}): library not exist: #{lib}" exit end after = class_extent() (after - before).each do |c| puts c end end SCRIPT output = `#{ruby} -e '#{script}'` output.split end |
#exec(argv, options) ⇒ Object
35 36 37 38 |
# File 'lib/bitclust/subcommands/classes_command.rb', line 35 def exec(argv, ) lib = argv[0] print_crossruby_table {|ruby| defined_classes(ruby, lib, @rejects) } end |
#needs_database? ⇒ Boolean
システムの ruby を調べるだけで DB を使わない
31 32 33 |
# File 'lib/bitclust/subcommands/classes_command.rb', line 31 def needs_database? false end |
#parse(argv) ⇒ Object
25 26 27 28 |
# File 'lib/bitclust/subcommands/classes_command.rb', line 25 def parse(argv) super option_error('wrong number of arguments') unless argv.size == 1 end |