devver-metric_fu 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +182 -0
- data/MIT-LICENSE +22 -0
- data/Manifest.txt +25 -0
- data/README.textile +27 -0
- data/Rakefile +15 -0
- data/TODO +9 -0
- data/lib/base/base_template.rb +145 -0
- data/lib/base/configuration.rb +182 -0
- data/lib/base/generator.rb +167 -0
- data/lib/base/graph.rb +39 -0
- data/lib/base/md5_tracker.rb +52 -0
- data/lib/base/report.rb +100 -0
- data/lib/generators/churn.rb +34 -0
- data/lib/generators/flay.rb +35 -0
- data/lib/generators/flog.rb +167 -0
- data/lib/generators/rails_best_practices.rb +31 -0
- data/lib/generators/rcov.rb +82 -0
- data/lib/generators/reek.rb +64 -0
- data/lib/generators/roodi.rb +33 -0
- data/lib/generators/saikuro.rb +221 -0
- data/lib/generators/stats.rb +59 -0
- data/lib/graphs/engines/bluff.rb +99 -0
- data/lib/graphs/engines/gchart.rb +118 -0
- data/lib/graphs/flay_grapher.rb +20 -0
- data/lib/graphs/flog_grapher.rb +40 -0
- data/lib/graphs/grapher.rb +11 -0
- data/lib/graphs/rails_best_practices_grapher.rb +20 -0
- data/lib/graphs/rcov_grapher.rb +20 -0
- data/lib/graphs/reek_grapher.rb +32 -0
- data/lib/graphs/roodi_grapher.rb +20 -0
- data/lib/metric_fu.rb +31 -0
- data/lib/templates/awesome/awesome_template.rb +37 -0
- data/lib/templates/awesome/churn.html.erb +58 -0
- data/lib/templates/awesome/css/buttons.css +82 -0
- data/lib/templates/awesome/css/default.css +91 -0
- data/lib/templates/awesome/css/integrity.css +335 -0
- data/lib/templates/awesome/css/reset.css +7 -0
- data/lib/templates/awesome/flay.html.erb +34 -0
- data/lib/templates/awesome/flog.html.erb +53 -0
- data/lib/templates/awesome/index.html.erb +31 -0
- data/lib/templates/awesome/layout.html.erb +30 -0
- data/lib/templates/awesome/rails_best_practices.html.erb +27 -0
- data/lib/templates/awesome/rcov.html.erb +42 -0
- data/lib/templates/awesome/reek.html.erb +40 -0
- data/lib/templates/awesome/roodi.html.erb +27 -0
- data/lib/templates/awesome/saikuro.html.erb +71 -0
- data/lib/templates/awesome/stats.html.erb +41 -0
- data/lib/templates/javascripts/bluff-min.js +1 -0
- data/lib/templates/javascripts/excanvas.js +35 -0
- data/lib/templates/javascripts/js-class.js +1 -0
- data/lib/templates/standard/churn.html.erb +31 -0
- data/lib/templates/standard/default.css +64 -0
- data/lib/templates/standard/flay.html.erb +34 -0
- data/lib/templates/standard/flog.html.erb +53 -0
- data/lib/templates/standard/index.html.erb +41 -0
- data/lib/templates/standard/rails_best_practices.html.erb +29 -0
- data/lib/templates/standard/rcov.html.erb +43 -0
- data/lib/templates/standard/reek.html.erb +42 -0
- data/lib/templates/standard/roodi.html.erb +29 -0
- data/lib/templates/standard/saikuro.html.erb +84 -0
- data/lib/templates/standard/standard_template.rb +26 -0
- data/lib/templates/standard/stats.html.erb +55 -0
- data/spec/base/base_template_spec.rb +161 -0
- data/spec/base/configuration_spec.rb +270 -0
- data/spec/base/generator_spec.rb +244 -0
- data/spec/base/graph_spec.rb +24 -0
- data/spec/base/md5_tracker_spec.rb +57 -0
- data/spec/base/report_spec.rb +139 -0
- data/spec/generators/churn_spec.rb +43 -0
- data/spec/generators/flay_spec.rb +110 -0
- data/spec/generators/flog_spec.rb +238 -0
- data/spec/generators/reek_spec.rb +125 -0
- data/spec/generators/saikuro_spec.rb +58 -0
- data/spec/generators/stats_spec.rb +74 -0
- data/spec/graphs/engines/bluff_spec.rb +18 -0
- data/spec/graphs/engines/gchart_spec.rb +108 -0
- data/spec/graphs/flay_grapher_spec.rb +37 -0
- data/spec/graphs/flog_grapher_spec.rb +45 -0
- data/spec/graphs/rcov_grapher_spec.rb +37 -0
- data/spec/graphs/reek_grapher_spec.rb +46 -0
- data/spec/graphs/roodi_grapher_spec.rb +37 -0
- data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
- data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
- data/spec/resources/saikuro/index_cyclo.html +155 -0
- data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +11 -0
- data/spec/resources/yml/20090630.yml +7844 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +7 -0
- data/tasks/metric_fu.rake +22 -0
- metadata +253 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module MetricFu
|
4
|
+
class Grapher
|
5
|
+
BLUFF_GRAPH_SIZE = "1000x600"
|
6
|
+
BLUFF_DEFAULT_OPTIONS = <<-EOS
|
7
|
+
var g = new Bluff.Line('graph', "#{BLUFF_GRAPH_SIZE}");
|
8
|
+
g.theme_37signals();
|
9
|
+
g.tooltips = true;
|
10
|
+
g.title_font_size = "24px"
|
11
|
+
g.legend_font_size = "12px"
|
12
|
+
g.marker_font_size = "10px"
|
13
|
+
EOS
|
14
|
+
end
|
15
|
+
|
16
|
+
class FlayBluffGrapher < FlayGrapher
|
17
|
+
def graph!
|
18
|
+
content = <<-EOS
|
19
|
+
#{BLUFF_DEFAULT_OPTIONS}
|
20
|
+
g.title = 'Flay: duplication';
|
21
|
+
g.data('flay', [#{@flay_score.join(',')}]);
|
22
|
+
g.labels = #{@labels.to_json};
|
23
|
+
g.draw();
|
24
|
+
EOS
|
25
|
+
File.open(File.join(MetricFu.output_directory, 'flay.js'), 'w') {|f| f << content }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class FlogBluffGrapher < FlogGrapher
|
30
|
+
def graph!
|
31
|
+
content = <<-EOS
|
32
|
+
#{BLUFF_DEFAULT_OPTIONS}
|
33
|
+
g.title = 'Flog: code complexity';
|
34
|
+
g.data('average', [#{@flog_average.join(',')}]);
|
35
|
+
g.data('top 5% average', [#{@top_five_percent_average.join(',')}])
|
36
|
+
g.labels = #{@labels.to_json};
|
37
|
+
g.draw();
|
38
|
+
EOS
|
39
|
+
File.open(File.join(MetricFu.output_directory, 'flog.js'), 'w') {|f| f << content }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class RcovBluffGrapher < RcovGrapher
|
44
|
+
def graph!
|
45
|
+
content = <<-EOS
|
46
|
+
#{BLUFF_DEFAULT_OPTIONS}
|
47
|
+
g.title = 'Rcov: code coverage';
|
48
|
+
g.data('rcov', [#{@rcov_percent.join(',')}]);
|
49
|
+
g.labels = #{@labels.to_json};
|
50
|
+
g.draw();
|
51
|
+
EOS
|
52
|
+
File.open(File.join(MetricFu.output_directory, 'rcov.js'), 'w') {|f| f << content }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class ReekBluffGrapher < ReekGrapher
|
57
|
+
def graph!
|
58
|
+
legend = @reek_count.keys.sort
|
59
|
+
data = ""
|
60
|
+
legend.each do |name|
|
61
|
+
data += "g.data('#{name}', [#{@reek_count[name].join(',')}])\n"
|
62
|
+
end
|
63
|
+
content = <<-EOS
|
64
|
+
#{BLUFF_DEFAULT_OPTIONS}
|
65
|
+
g.title = 'Reek: code smells';
|
66
|
+
#{data}
|
67
|
+
g.labels = #{@labels.to_json};
|
68
|
+
g.draw();
|
69
|
+
EOS
|
70
|
+
File.open(File.join(MetricFu.output_directory, 'reek.js'), 'w') {|f| f << content }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class RoodiBluffGrapher < RoodiGrapher
|
75
|
+
def graph!
|
76
|
+
content = <<-EOS
|
77
|
+
#{BLUFF_DEFAULT_OPTIONS}
|
78
|
+
g.title = 'Roodi: design problems';
|
79
|
+
g.data('roodi', [#{@roodi_count.join(',')}]);
|
80
|
+
g.labels = #{@labels.to_json};
|
81
|
+
g.draw();
|
82
|
+
EOS
|
83
|
+
File.open(File.join(MetricFu.output_directory, 'roodi.js'), 'w') {|f| f << content }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class RailsBestPracticesBluffGrapher < RailsBestPracticesGrapher
|
88
|
+
def graph!
|
89
|
+
content = <<-EOS
|
90
|
+
#{BLUFF_DEFAULT_OPTIONS}
|
91
|
+
g.title = 'Rails Best Practices: design problems';
|
92
|
+
g.data('rails_best_practices', [#{@rails_best_practices_count.join(',')}]);
|
93
|
+
g.labels = #{@labels.to_json};
|
94
|
+
g.draw();
|
95
|
+
EOS
|
96
|
+
File.open(File.join(MetricFu.output_directory, 'rails_best_practices.js'), 'w') {|f| f << content }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module MetricFu
|
2
|
+
module GchartGrapher
|
3
|
+
COLORS = %w{009999 FF7400 A60000 008500 E6399B 344AD7 00B860 D5CCB9}
|
4
|
+
GCHART_GRAPH_SIZE = "1000x300" # maximum permitted image size is 300000 pixels
|
5
|
+
|
6
|
+
NUMBER_OF_TICKS = 6
|
7
|
+
def determine_y_axis_scale(values)
|
8
|
+
values.collect! {|val| val || 0.0 }
|
9
|
+
if values.empty?
|
10
|
+
@max_value = 10
|
11
|
+
@yaxis = [0, 2, 4, 6, 8, 10]
|
12
|
+
else
|
13
|
+
@max_value = values.max + Integer(0.1 * values.max)
|
14
|
+
portion_size = (@max_value / (NUMBER_OF_TICKS - 1).to_f).ceil
|
15
|
+
@yaxis = []
|
16
|
+
NUMBER_OF_TICKS.times {|n| @yaxis << Integer(portion_size * n) }
|
17
|
+
@max_value = @yaxis.last
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Grapher
|
23
|
+
include MetricFu::GchartGrapher
|
24
|
+
|
25
|
+
def self.require_graphing_gem
|
26
|
+
require 'gchart'
|
27
|
+
rescue LoadError
|
28
|
+
puts "#"*99 + "\n" +
|
29
|
+
"If you want to use google charts for graphing, you'll need to install the googlecharts rubygem." +
|
30
|
+
"\n" + "#"*99
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class FlayGchartGrapher < FlayGrapher
|
35
|
+
def graph!
|
36
|
+
determine_y_axis_scale(@flay_score)
|
37
|
+
url = Gchart.line(
|
38
|
+
:size => GCHART_GRAPH_SIZE,
|
39
|
+
:title => URI.escape("Flay: duplication"),
|
40
|
+
:data => @flay_score,
|
41
|
+
:max_value => @max_value,
|
42
|
+
:axis_with_labels => 'x,y',
|
43
|
+
:axis_labels => [@labels.values, @yaxis],
|
44
|
+
:format => 'file',
|
45
|
+
:filename => File.join(MetricFu.output_directory, 'flay.png'))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class FlogGchartGrapher < FlogGrapher
|
50
|
+
def graph!
|
51
|
+
determine_y_axis_scale(@top_five_percent_average + @flog_average)
|
52
|
+
url = Gchart.line(
|
53
|
+
:size => GCHART_GRAPH_SIZE,
|
54
|
+
:title => URI.escape("Flog: code complexity"),
|
55
|
+
:data => [@flog_average, @top_five_percent_average],
|
56
|
+
:stacked => false,
|
57
|
+
:bar_colors => COLORS[0..1],
|
58
|
+
:legend => ['average', 'top 5%25 average'],
|
59
|
+
:max_value => @max_value,
|
60
|
+
:axis_with_labels => 'x,y',
|
61
|
+
:axis_labels => [@labels.values, @yaxis],
|
62
|
+
:format => 'file',
|
63
|
+
:filename => File.join(MetricFu.output_directory, 'flog.png'))
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class RcovGchartGrapher < RcovGrapher
|
68
|
+
def graph!
|
69
|
+
url = Gchart.line(
|
70
|
+
:size => GCHART_GRAPH_SIZE,
|
71
|
+
:title => URI.escape("Rcov: code coverage"),
|
72
|
+
:data => self.rcov_percent,
|
73
|
+
:max_value => 101,
|
74
|
+
:axis_with_labels => 'x,y',
|
75
|
+
:axis_labels => [self.labels.values, [0,20,40,60,80,100]],
|
76
|
+
:format => 'file',
|
77
|
+
:filename => File.join(MetricFu.output_directory, 'rcov.png')
|
78
|
+
)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class ReekGchartGrapher < ReekGrapher
|
83
|
+
def graph!
|
84
|
+
determine_y_axis_scale(@reek_count.values.flatten.uniq)
|
85
|
+
values = []
|
86
|
+
legend = @reek_count.keys.sort
|
87
|
+
legend.collect {|k| values << @reek_count[k]}
|
88
|
+
|
89
|
+
url = Gchart.line(
|
90
|
+
:size => GCHART_GRAPH_SIZE,
|
91
|
+
:title => URI.escape("Reek: code smells"),
|
92
|
+
:data => values,
|
93
|
+
:stacked => false,
|
94
|
+
:bar_colors => COLORS,
|
95
|
+
:legend => legend,
|
96
|
+
:max_value => @max_value,
|
97
|
+
:axis_with_labels => 'x,y',
|
98
|
+
:axis_labels => [@labels.values, @yaxis],
|
99
|
+
:format => 'file',
|
100
|
+
:filename => File.join(MetricFu.output_directory, 'reek.png'))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class RoodiGchartGrapher < RoodiGrapher
|
105
|
+
def graph!
|
106
|
+
determine_y_axis_scale(@roodi_count)
|
107
|
+
url = Gchart.line(
|
108
|
+
:size => GCHART_GRAPH_SIZE,
|
109
|
+
:title => URI.escape("Roodi: potential design problems"),
|
110
|
+
:data => @roodi_count,
|
111
|
+
:max_value => @max_value,
|
112
|
+
:axis_with_labels => 'x,y',
|
113
|
+
:axis_labels => [@labels.values, @yaxis],
|
114
|
+
:format => 'file',
|
115
|
+
:filename => File.join(MetricFu.output_directory, 'roodi.png'))
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MetricFu
|
2
|
+
|
3
|
+
class FlayGrapher < Grapher
|
4
|
+
|
5
|
+
attr_accessor :flay_score, :labels
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@flay_score = []
|
10
|
+
@labels = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_metrics(metrics, date)
|
14
|
+
@flay_score.push(metrics[:flay][:total_score].to_i)
|
15
|
+
@labels.update( { @labels.size => date })
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module MetricFu
|
2
|
+
|
3
|
+
class FlogGrapher < Grapher
|
4
|
+
|
5
|
+
attr_accessor :flog_average, :labels, :top_five_percent_average
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@flog_average = []
|
10
|
+
@labels = {}
|
11
|
+
@top_five_percent_average =[]
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_metrics(metrics, date)
|
15
|
+
@top_five_percent_average.push(calc_top_five_percent_average(metrics))
|
16
|
+
@flog_average.push(metrics[:flog][:average])
|
17
|
+
@labels.update( { @labels.size => date })
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def calc_top_five_percent_average(metrics)
|
23
|
+
methods = metrics[:flog][:pages].inject([]) {|methods, page| methods << page[:scanned_methods]}
|
24
|
+
methods.flatten!
|
25
|
+
methods = methods.sort_by {|method| method[:score]}.reverse
|
26
|
+
|
27
|
+
number_of_methods_that_is_five_percent = (methods.size * 0.05).ceil
|
28
|
+
|
29
|
+
total_for_five_percent =
|
30
|
+
methods[0...number_of_methods_that_is_five_percent].inject(0) {|total, method| total += method[:score] }
|
31
|
+
if number_of_methods_that_is_five_percent == 0
|
32
|
+
0.0
|
33
|
+
else
|
34
|
+
total_for_five_percent / number_of_methods_that_is_five_percent.to_f
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MetricFu
|
2
|
+
|
3
|
+
class RailsBestPracticesGrapher < Grapher
|
4
|
+
|
5
|
+
attr_accessor :rails_best_practices_count, :labels
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@rails_best_practices_count = []
|
10
|
+
@labels = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_metrics(metrics, date)
|
14
|
+
@rails_best_practices_count.push(metrics[:rails_best_practices][:problems].size)
|
15
|
+
@labels.update( { @labels.size => date })
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MetricFu
|
2
|
+
|
3
|
+
class RcovGrapher < Grapher
|
4
|
+
|
5
|
+
attr_accessor :rcov_percent, :labels
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
self.rcov_percent = []
|
10
|
+
self.labels = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_metrics(metrics, date)
|
14
|
+
self.rcov_percent.push(metrics[:rcov][:global_percent_run])
|
15
|
+
self.labels.update( { self.labels.size => date })
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MetricFu
|
2
|
+
|
3
|
+
class ReekGrapher < Grapher
|
4
|
+
|
5
|
+
attr_accessor :reek_count, :labels
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@reek_count = {}
|
10
|
+
@labels = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_metrics(metrics, date)
|
14
|
+
counter = @labels.size
|
15
|
+
@labels.update( { @labels.size => date })
|
16
|
+
|
17
|
+
metrics[:reek][:matches].each do |reek_chunk|
|
18
|
+
reek_chunk[:code_smells].each do |code_smell|
|
19
|
+
# speaking of code smell...
|
20
|
+
@reek_count[code_smell[:type]] = [] if @reek_count[code_smell[:type]].nil?
|
21
|
+
if @reek_count[code_smell[:type]][counter].nil?
|
22
|
+
@reek_count[code_smell[:type]][counter] = 1
|
23
|
+
else
|
24
|
+
@reek_count[code_smell[:type]][counter] += 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MetricFu
|
2
|
+
|
3
|
+
class RoodiGrapher < Grapher
|
4
|
+
|
5
|
+
attr_accessor :roodi_count, :labels
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@roodi_count = []
|
10
|
+
@labels = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_metrics(metrics, date)
|
14
|
+
@roodi_count.push(metrics[:roodi][:problems].size)
|
15
|
+
@labels.update( { @labels.size => date })
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/metric_fu.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'yaml'
|
3
|
+
# Load a few things to make our lives easier elsewhere.
|
4
|
+
module MetricFu
|
5
|
+
LIB_ROOT = File.dirname(__FILE__)
|
6
|
+
end
|
7
|
+
base_dir = File.join(MetricFu::LIB_ROOT, 'base')
|
8
|
+
generator_dir = File.join(MetricFu::LIB_ROOT, 'generators')
|
9
|
+
template_dir = File.join(MetricFu::LIB_ROOT, 'templates')
|
10
|
+
graph_dir = File.join(MetricFu::LIB_ROOT, 'graphs')
|
11
|
+
|
12
|
+
# We need to require these two things first because our other classes
|
13
|
+
# depend on them.
|
14
|
+
require File.join(base_dir, 'report')
|
15
|
+
require File.join(base_dir, 'generator')
|
16
|
+
require File.join(base_dir, 'graph')
|
17
|
+
|
18
|
+
# prevent the task from being run multiple times.
|
19
|
+
unless Rake::Task.task_defined? "metrics:all"
|
20
|
+
# Load the rakefile so users of the gem get the default metric_fu task
|
21
|
+
load File.join(MetricFu::LIB_ROOT, '..', 'tasks', 'metric_fu.rake')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Now load everything else that's in the directory
|
25
|
+
Dir[File.join(base_dir, '*.rb')].each{|l| require l }
|
26
|
+
Dir[File.join(generator_dir, '*.rb')].each {|l| require l }
|
27
|
+
Dir[File.join(template_dir, 'standard/*.rb')].each {|l| require l}
|
28
|
+
Dir[File.join(template_dir, 'awesome/*.rb')].each {|l| require l}
|
29
|
+
require graph_dir + "/grapher"
|
30
|
+
Dir[File.join(graph_dir, '*.rb')].each {|l| require l}
|
31
|
+
Dir[File.join(graph_dir, 'engines', '*.rb')].each {|l| require l}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class AwesomeTemplate < MetricFu::Template
|
4
|
+
|
5
|
+
def write
|
6
|
+
# Getting rid of the crap before and after the project name from integrity
|
7
|
+
@name = File.basename(Dir.pwd).gsub(/^\w+-|-\w+$/, "")
|
8
|
+
|
9
|
+
# Copy Bluff javascripts to output directory
|
10
|
+
Dir[File.join(this_directory, '..', 'javascripts', '*')].each do |f|
|
11
|
+
FileUtils.copy(f, File.join(MetricFu.output_directory, File.basename(f)))
|
12
|
+
end
|
13
|
+
|
14
|
+
report.each_pair do |section, contents|
|
15
|
+
if template_exists?(section)
|
16
|
+
create_instance_var(section, contents)
|
17
|
+
@html = erbify(section)
|
18
|
+
html = erbify('layout')
|
19
|
+
fn = output_filename(section)
|
20
|
+
MetricFu.report.save_output(html, MetricFu.output_directory, fn)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Instance variables we need should already be created from above
|
25
|
+
if template_exists?('index')
|
26
|
+
@html = erbify('index')
|
27
|
+
html = erbify('layout')
|
28
|
+
fn = output_filename('index')
|
29
|
+
MetricFu.report.save_output(html, MetricFu.output_directory, fn)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def this_directory
|
34
|
+
File.dirname(__FILE__)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|