Class: SandiMeter::Analyzer
- Inherits:
-
Object
- Object
- SandiMeter::Analyzer
- Defined in:
- lib/sandi_meter/analyzer.rb
Instance Attribute Summary collapse
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#method_calls ⇒ Object
readonly
Returns the value of attribute method_calls.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#parent_token ⇒ Object
Returns the value of attribute parent_token.
-
#private_or_protected ⇒ Object
Returns the value of attribute private_or_protected.
Instance Method Summary collapse
- #analyze(file_path) ⇒ Object
-
#initialize ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize ⇒ Analyzer
Returns a new instance of Analyzer.
14 15 16 17 18 |
# File 'lib/sandi_meter/analyzer.rb', line 14 def initialize @classes = [] @methods = {} @method_calls = [] end |
Instance Attribute Details
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
12 13 14 |
# File 'lib/sandi_meter/analyzer.rb', line 12 def classes @classes end |
#method_calls ⇒ Object (readonly)
Returns the value of attribute method_calls.
12 13 14 |
# File 'lib/sandi_meter/analyzer.rb', line 12 def method_calls @method_calls end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
12 13 14 |
# File 'lib/sandi_meter/analyzer.rb', line 12 def methods @methods end |
#parent_token ⇒ Object
Returns the value of attribute parent_token.
11 12 13 |
# File 'lib/sandi_meter/analyzer.rb', line 11 def parent_token @parent_token end |
#private_or_protected ⇒ Object
Returns the value of attribute private_or_protected.
11 12 13 |
# File 'lib/sandi_meter/analyzer.rb', line 11 def private_or_protected @private_or_protected end |
Instance Method Details
#analyze(file_path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sandi_meter/analyzer.rb', line 20 def analyze(file_path) @file_path = file_path @file_body = File.read(file_path) @file_lines = @file_body.split(/$/).map { |l| l.gsub("\n", '') } @indentation_warnings = indentation_warnings # TODO # add better determination wheter file is controller @controller = !!(file_path =~ /\w+_controller.rb$/) sexp = Ripper.sexp(@file_body) scan_sexp(sexp) output end |