Class: SandiMeter::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/sandi_meter/analyzer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAnalyzer

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

#classesObject (readonly)

Returns the value of attribute classes


12
13
14
# File 'lib/sandi_meter/analyzer.rb', line 12

def classes
  @classes
end

#method_callsObject (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

#methodsObject (readonly)

Returns the value of attribute methods


12
13
14
# File 'lib/sandi_meter/analyzer.rb', line 12

def methods
  @methods
end

#parent_tokenObject

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_protectedObject

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