Class: CCReport

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

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ CCReport

Returns a new instance of CCReport.



5
6
7
8
9
# File 'lib/cc_report.rb', line 5

def initialize source
  @output = ""
  @analyser = ComplexityAnalyser.new
  @source = source
end

Instance Method Details

#as_csvObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cc_report.rb', line 11

def as_csv
  begin
    @analyser.parse @source
    @output += "Name, CC"
    @analyser.functions.each do |function|
      @output += "\n#{function[:name]},#{function[:complexity]}"
    end
  rescue
    @output = "WARNING: Could not parse \n#{source} \n: SKIPPED"
  end
  @output
end