forked from jscruggs/metric_fu
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'skip-missing-metrics' into rbp-gchart
- Loading branch information
Showing
13 changed files
with
289 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
module MetricFu | ||
|
||
class FlayGrapher < Grapher | ||
|
||
attr_accessor :flay_score, :labels | ||
|
||
def initialize | ||
super | ||
@flay_score = [] | ||
@labels = {} | ||
end | ||
|
||
def get_metrics(metrics, date) | ||
@flay_score.push(metrics[:flay][:total_score].to_i) | ||
@labels.update( { @labels.size => date }) | ||
if metrics && metrics[:flay] | ||
@flay_score.push(metrics[:flay][:total_score].to_i) | ||
@labels.update( { @labels.size => date }) | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
module MetricFu | ||
|
||
class RcovGrapher < Grapher | ||
|
||
attr_accessor :rcov_percent, :labels | ||
|
||
def initialize | ||
super | ||
self.rcov_percent = [] | ||
self.labels = {} | ||
end | ||
|
||
def get_metrics(metrics, date) | ||
self.rcov_percent.push(metrics[:rcov][:global_percent_run]) | ||
self.labels.update( { self.labels.size => date }) | ||
if metrics && metrics[:rcov] | ||
self.rcov_percent.push(metrics[:rcov][:global_percent_run]) | ||
self.labels.update( { self.labels.size => date }) | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
module MetricFu | ||
|
||
class ReekGrapher < Grapher | ||
|
||
attr_accessor :reek_count, :labels | ||
|
||
def initialize | ||
super | ||
@reek_count = {} | ||
@labels = {} | ||
end | ||
|
||
def get_metrics(metrics, date) | ||
counter = @labels.size | ||
@labels.update( { @labels.size => date }) | ||
|
||
metrics[:reek][:matches].each do |reek_chunk| | ||
reek_chunk[:code_smells].each do |code_smell| | ||
# speaking of code smell... | ||
@reek_count[code_smell[:type]] = [] if @reek_count[code_smell[:type]].nil? | ||
if @reek_count[code_smell[:type]][counter].nil? | ||
@reek_count[code_smell[:type]][counter] = 1 | ||
else | ||
@reek_count[code_smell[:type]][counter] += 1 | ||
if metrics && metrics[:reek] | ||
counter = @labels.size | ||
@labels.update( { @labels.size => date }) | ||
|
||
metrics[:reek][:matches].each do |reek_chunk| | ||
reek_chunk[:code_smells].each do |code_smell| | ||
# speaking of code smell... | ||
@reek_count[code_smell[:type]] = [] if @reek_count[code_smell[:type]].nil? | ||
if @reek_count[code_smell[:type]][counter].nil? | ||
@reek_count[code_smell[:type]][counter] = 1 | ||
else | ||
@reek_count[code_smell[:type]][counter] += 1 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
module MetricFu | ||
|
||
class RoodiGrapher < Grapher | ||
|
||
attr_accessor :roodi_count, :labels | ||
|
||
def initialize | ||
super | ||
@roodi_count = [] | ||
@labels = {} | ||
end | ||
|
||
def get_metrics(metrics, date) | ||
@roodi_count.push(metrics[:roodi][:problems].size) | ||
@labels.update( { @labels.size => date }) | ||
if metrics && metrics[:roodi] | ||
@roodi_count.push(metrics[:roodi][:problems].size) | ||
@labels.update( { @labels.size => date }) | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
|
||
module MetricFu | ||
|
||
class StatsGrapher < Grapher | ||
|
||
attr_accessor :loc_counts, :lot_counts, :labels | ||
|
||
def initialize | ||
super | ||
self.loc_counts = [] | ||
self.lot_counts = [] | ||
self.labels = {} | ||
end | ||
|
||
def get_metrics(metrics, date) | ||
self.loc_counts.push(metrics[:stats][:codeLOC].to_i) | ||
self.lot_counts.push(metrics[:stats][:testLOC].to_i) | ||
self.labels.update( { self.labels.size => date }) | ||
if metrics && metrics[:stats] | ||
self.loc_counts.push(metrics[:stats][:codeLOC].to_i) | ||
self.lot_counts.push(metrics[:stats][:testLOC].to_i) | ||
self.labels.update( { self.labels.size => date }) | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,56 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | ||
|
||
describe FlayGrapher do | ||
describe FlayGrapher do | ||
before :each do | ||
@flay_grapher = MetricFu::FlayGrapher.new | ||
MetricFu.configuration | ||
end | ||
|
||
it "should respond to flay_score and labels" do | ||
@flay_grapher.should respond_to(:flay_score) | ||
@flay_grapher.should respond_to(:labels) | ||
end | ||
|
||
describe "responding to #initialize" do | ||
it "should initialise flay_score and labels" do | ||
@flay_grapher.flay_score.should == [] | ||
@flay_grapher.labels.should == {} | ||
end | ||
end | ||
|
||
describe "responding to #get_metrics" do | ||
before(:each) do | ||
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml"))) | ||
@date = "1/2" | ||
end | ||
|
||
it "should push 476 to flay_score" do | ||
@flay_grapher.flay_score.should_receive(:push).with(476) | ||
@flay_grapher.get_metrics(@metrics, @date) | ||
context "when metrics were not generated" do | ||
before(:each) do | ||
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "metric_missing.yml"))) | ||
@date = "1/2" | ||
end | ||
|
||
it "should not push to flay_score" do | ||
@flay_grapher.flay_score.should_not_receive(:push) | ||
@flay_grapher.get_metrics(@metrics, @date) | ||
end | ||
|
||
it "should not update labels with the date" do | ||
@flay_grapher.labels.should_not_receive(:update) | ||
@flay_grapher.get_metrics(@metrics, @date) | ||
end | ||
end | ||
|
||
it "should update labels with the date" do | ||
@flay_grapher.labels.should_receive(:update).with({ 0 => "1/2" }) | ||
@flay_grapher.get_metrics(@metrics, @date) | ||
|
||
context "when metrics have been generated" do | ||
before(:each) do | ||
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml"))) | ||
@date = "1/2" | ||
end | ||
|
||
it "should push to flay_score" do | ||
@flay_grapher.flay_score.should_receive(:push).with(476) | ||
@flay_grapher.get_metrics(@metrics, @date) | ||
end | ||
|
||
it "should update labels with the date" do | ||
@flay_grapher.labels.should_receive(:update).with({ 0 => "1/2" }) | ||
@flay_grapher.get_metrics(@metrics, @date) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.