Class: BitClust::Subcommands::AncestorsCommand

Inherits:
BitClust::Subcommand show all
Includes:
CrossRubyUtils
Defined in:
lib/bitclust/subcommands/ancestors_command.rb

Instance Method Summary collapse

Methods inherited from BitClust::Subcommand

#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root

Constructor Details

#initializeAncestorsCommand



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bitclust/subcommands/ancestors_command.rb', line 14

def initialize
  super
  @prefix = nil
  @requires = []
  @version = RUBY_VERSION
  @all = false
  @verbose = false
  @parser.banner = "Usage: \#{File.basename($0, '.*')} ancestors [-r<lib>] [--ruby=<VER>] --db=PATH <classname>\n \#{File.basename($0, '.*')} ancestors [-r<lib>] [--ruby=<VER>] --db=PATH --all\nNG Sample:\n  $ \#{File.basename($0, '.*')} ancestors -rfoo --ruby=1.9.1 --db=./db Foo\n  NG : Foo\n  + FooModule (The Ruby have this class/module in ancestors of the class)\n  - BarModule (The Database have this class/module in ancestors of the class)\nOptions:\n  BANNER\n  @parser.on('-d', '--database=PATH', 'Database prefix.') {|path|\n    @prefix = path\n  }\n  @parser.on('-r LIB', 'Requires library LIB') {|lib|\n    @requires.push lib\n  }\n  @parser.on('--ruby=[VER]', \"The version of Ruby interpreter\"){|ver|\n    @version = ver\n  }\n  @parser.on('-v', '--verbose', 'Show differences'){\n    @verbose = true\n  }\n  @parser.on('--all', 'Check anccestors for all classes'){\n    @all = true\n  }\nend\n"

Instance Method Details

#exec(argv, options) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bitclust/subcommands/ancestors_command.rb', line 48

def exec(argv, options)
  classname = argv[0]
  db = MethodDatabase.new(@prefix)
  ruby = get_ruby(@version)
  if classname && !@all
    check_ancestors(db, ruby, @requires, classname)
  else
    $stderr.puts 'check all...'
    check_all_ancestors(db, ruby, @requires)
  end
end