Class: Phlexing::RubyAnalyzer
- Inherits:
-
Object
- Object
- Phlexing::RubyAnalyzer
- Defined in:
- lib/phlexing/ruby_analyzer.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
Returns the value of attribute calls.
-
#consts ⇒ Object
Returns the value of attribute consts.
-
#idents ⇒ Object
Returns the value of attribute idents.
-
#includes ⇒ Object
Returns the value of attribute includes.
-
#instance_methods ⇒ Object
Returns the value of attribute instance_methods.
-
#ivars ⇒ Object
Returns the value of attribute ivars.
-
#locals ⇒ Object
Returns the value of attribute locals.
Class Method Summary collapse
Instance Method Summary collapse
- #analyze(source) ⇒ Object
- #analyze_ruby(code) ⇒ Object
-
#initialize ⇒ RubyAnalyzer
constructor
A new instance of RubyAnalyzer.
Constructor Details
#initialize ⇒ RubyAnalyzer
Returns a new instance of RubyAnalyzer.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/phlexing/ruby_analyzer.rb', line 13 def initialize @ivars = Set.new @locals = Set.new @idents = Set.new @calls = Set.new @consts = Set.new @instance_methods = Set.new @includes = Set.new @visitor = Visitor.new(self) end |
Instance Attribute Details
#calls ⇒ Object
Returns the value of attribute calls.
7 8 9 |
# File 'lib/phlexing/ruby_analyzer.rb', line 7 def calls @calls end |
#consts ⇒ Object
Returns the value of attribute consts.
7 8 9 |
# File 'lib/phlexing/ruby_analyzer.rb', line 7 def consts @consts end |
#idents ⇒ Object
Returns the value of attribute idents.
7 8 9 |
# File 'lib/phlexing/ruby_analyzer.rb', line 7 def idents @idents end |
#includes ⇒ Object
Returns the value of attribute includes.
7 8 9 |
# File 'lib/phlexing/ruby_analyzer.rb', line 7 def includes @includes end |
#instance_methods ⇒ Object
Returns the value of attribute instance_methods.
7 8 9 |
# File 'lib/phlexing/ruby_analyzer.rb', line 7 def instance_methods @instance_methods end |
#ivars ⇒ Object
Returns the value of attribute ivars.
7 8 9 |
# File 'lib/phlexing/ruby_analyzer.rb', line 7 def ivars @ivars end |
#locals ⇒ Object
Returns the value of attribute locals.
7 8 9 |
# File 'lib/phlexing/ruby_analyzer.rb', line 7 def locals @locals end |
Class Method Details
.call(source) ⇒ Object
9 10 11 |
# File 'lib/phlexing/ruby_analyzer.rb', line 9 def self.call(source) new.analyze(source) end |
Instance Method Details
#analyze(source) ⇒ Object
24 25 26 27 28 |
# File 'lib/phlexing/ruby_analyzer.rb', line 24 def analyze(source) code = extract_ruby_from_erb(source.to_s) analyze_ruby(code) end |
#analyze_ruby(code) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/phlexing/ruby_analyzer.rb', line 30 def analyze_ruby(code) program = SyntaxTree.parse(code) @visitor.visit(program) self rescue SyntaxTree::Parser::ParseError, NoMethodError self end |