Sha256: 684e518000d56e933a91caa6716e87195112d8c9b4cdb5f02cce377a847a0869

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'graph'
require 'gruff'
module MetricFu
  
  class ReekGrapher
    
    attr_accessor :reek_count, :labels
    
    def initialize
      self.reek_count = {}
      self.labels= {}
    end
    
    def get_metrics(metrics, date)
      counter = self.labels.size
      self.labels.update( { counter => date })
      
      metrics[:reek][:matches].each do |reek_chunk|
        reek_chunk[:code_smells].each do |code_smell|
          # speaking of code smell...
          self.reek_count[code_smell[:type]] = [] if self.reek_count[code_smell[:type]].nil?
          self.reek_count[code_smell[:type]][counter].nil? ? self.reek_count[code_smell[:type]][counter] = 1 : self.reek_count[code_smell[:type]][counter] += 1
        end
      end
    end
    
    def graph!
      g = Gruff::Line.new("1024x768")
      g.title = "Reek: code smells"
      g.theme = MetricFu.graph_theme
      g.font = MetricFu.graph_font
      self.reek_count.each_pair do |type, count|
        g.data(type, count)
      end
      g.labels = self.labels
      g.write(File.join(MetricFu.output_directory, 'reek.png'))
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
edouard-metric_fu-1.0.4 lib/graphs/reek_grapher.rb