Class: ZombieScout::Parser
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- ZombieScout::Parser
- Defined in:
- lib/zombie_scout/parser.rb
Instance Attribute Summary collapse
-
#called_methods ⇒ Object
readonly
Returns the value of attribute called_methods.
-
#defined_methods ⇒ Object
readonly
Returns the value of attribute defined_methods.
Instance Method Summary collapse
-
#initialize(ruby_source) ⇒ Parser
constructor
A new instance of Parser.
- #on_class(node) ⇒ Object
- #on_def(node) ⇒ Object
- #on_defs(node) ⇒ Object
- #on_module(node) ⇒ Object
- #on_send(node) ⇒ Object
Constructor Details
#initialize(ruby_source) ⇒ Parser
Returns a new instance of Parser.
8 9 10 11 12 13 14 15 |
# File 'lib/zombie_scout/parser.rb', line 8 def initialize(ruby_source) @ruby_source = ruby_source @defined_methods = [] @called_methods = [] @class_module_stack = [] node = ::Parser::CurrentRuby.parse(@ruby_source.source) process(node) end |
Instance Attribute Details
#called_methods ⇒ Object (readonly)
Returns the value of attribute called_methods.
6 7 8 |
# File 'lib/zombie_scout/parser.rb', line 6 def called_methods @called_methods end |
#defined_methods ⇒ Object (readonly)
Returns the value of attribute defined_methods.
6 7 8 |
# File 'lib/zombie_scout/parser.rb', line 6 def defined_methods @defined_methods end |
Instance Method Details
#on_class(node) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/zombie_scout/parser.rb', line 17 def on_class(node) classname_const, superclass, body = *node classname = ConstExtracter.new.process(classname_const) @class_module_stack.push(classname) process(body) @class_module_stack.pop end |
#on_def(node) ⇒ Object
33 34 35 36 37 |
# File 'lib/zombie_scout/parser.rb', line 33 def on_def(node) method_name, args, body = *node stash_method(method_name, node) process(body) end |
#on_defs(node) ⇒ Object
39 40 41 42 43 |
# File 'lib/zombie_scout/parser.rb', line 39 def on_defs(node) self_node, method_name, args, body = *node stash_method(method_name, node) process(body) end |
#on_module(node) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/zombie_scout/parser.rb', line 25 def on_module(node) modulename_const, body = *node modulename = ConstExtracter.new.process(modulename_const) @class_module_stack.push(modulename) process(body) @class_module_stack.pop end |
#on_send(node) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/zombie_scout/parser.rb', line 45 def on_send(node) receiver, method_name, *args = *node if respond_to?(:"handle_#{method_name}", true) send(:"handle_#{method_name}", args, node) end @called_methods << method_name process_all(args) end |