Class: MetricFu::FlogGrapher

Inherits:
Grapher
  • Object
show all
Defined in:
lib/graphs/flog_grapher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Grapher

require_gruff

Constructor Details

#initializeFlogGrapher

Returns a new instance of FlogGrapher.



7
8
9
10
11
12
# File 'lib/graphs/flog_grapher.rb', line 7

def initialize
  super
  self.flog_average = []
  self.labels = {}
  self.top_five_percent_average =[]
end

Instance Attribute Details

#flog_averageObject

Returns the value of attribute flog_average.



5
6
7
# File 'lib/graphs/flog_grapher.rb', line 5

def flog_average
  @flog_average
end

#labelsObject

Returns the value of attribute labels.



5
6
7
# File 'lib/graphs/flog_grapher.rb', line 5

def labels
  @labels
end

#top_five_percent_averageObject

Returns the value of attribute top_five_percent_average.



5
6
7
# File 'lib/graphs/flog_grapher.rb', line 5

def top_five_percent_average
  @top_five_percent_average
end

Instance Method Details

#get_metrics(metrics, date) ⇒ Object



14
15
16
17
18
# File 'lib/graphs/flog_grapher.rb', line 14

def get_metrics(metrics, date)
  self.top_five_percent_average.push(calc_top_five_percent_average(metrics))
  self.flog_average.push(metrics[:flog][:average])
  self.labels.update( { self.labels.size => date })
end

#graph!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/graphs/flog_grapher.rb', line 20

def graph!
  g = Gruff::Line.new(MetricFu.graph_size)
  g.title = "Flog: code complexity"
  g.theme = MetricFu.graph_theme
  g.font = MetricFu.graph_font
  g.data('top five percent average', self.top_five_percent_average)
  g.data('flog average', self.flog_average)
  g.labels = self.labels
  g.title_font_size = MetricFu.graph_title_font_size
  g.legend_box_size = MetricFu.graph_legend_box_size
  g.legend_font_size = MetricFu.graph_legend_font_size
  g.marker_font_size = MetricFu.graph_marker_font_size
  g.write(File.join(MetricFu.output_directory, 'flog.png'))
end