metric_fu 4.4.4 → 4.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.metrics +0 -3
- data/.travis.yml +1 -1
- data/.yardopts +0 -1
- data/CONTRIBUTING.md +1 -0
- data/CONTRIBUTORS +61 -2
- data/Gemfile +14 -11
- data/Gemfile.devtools +40 -0
- data/Guardfile +30 -0
- data/HISTORY.md +54 -1
- data/README.md +86 -56
- data/bin/mf-cane +8 -6
- data/bin/mf-churn +8 -7
- data/bin/mf-flay +8 -7
- data/bin/mf-reek +8 -7
- data/bin/mf-roodi +8 -7
- data/bin/mf-saikuro +8 -6
- data/certs/bf4.pem +22 -0
- data/checksum/metric_fu-4.4.4.gem.sha512 +1 -0
- data/checksum/metric_fu-4.5.0.gem.sha512 +1 -0
- data/etc/README.md +16 -0
- data/etc/erd.dot +173 -0
- data/etc/erd.png +0 -0
- data/lib/metric_fu.rb +56 -12
- data/lib/metric_fu/cli/helper.rb +8 -2
- data/lib/metric_fu/cli/parser.rb +86 -50
- data/lib/metric_fu/configuration.rb +4 -31
- data/lib/metric_fu/environment.rb +1 -1
- data/lib/metric_fu/formatter/html.rb +5 -5
- data/lib/metric_fu/gem_run.rb +68 -0
- data/lib/metric_fu/gem_version.rb +57 -0
- data/lib/metric_fu/io.rb +1 -1
- data/lib/metric_fu/load_files.rb +3 -5
- data/lib/metric_fu/loader.rb +31 -2
- data/lib/metric_fu/logging/mf_debugger.rb +1 -0
- data/lib/metric_fu/metric.rb +23 -1
- data/lib/metric_fu/metrics/cane/cane.rb +7 -3
- data/lib/metric_fu/metrics/cane/cane_grapher.rb +19 -0
- data/lib/metric_fu/metrics/cane/template_awesome/cane.html.erb +0 -4
- data/lib/metric_fu/metrics/churn/churn.rb +6 -7
- data/lib/metric_fu/metrics/flay/flay.rb +2 -4
- data/lib/metric_fu/metrics/flay/flay_grapher.rb +19 -0
- data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +0 -4
- data/lib/metric_fu/metrics/flog/flog.rb +0 -2
- data/lib/metric_fu/metrics/flog/flog_grapher.rb +19 -0
- data/lib/metric_fu/metrics/flog/template_awesome/flog.html.erb +0 -4
- data/lib/metric_fu/metrics/generator.rb +34 -24
- data/lib/metric_fu/metrics/graph.rb +8 -14
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +7 -5
- data/lib/metric_fu/metrics/hotspots/template_awesome/hotspots.html.erb +4 -6
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +0 -2
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher.rb +19 -0
- data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +0 -4
- data/lib/metric_fu/metrics/rcov/rcov_grapher.rb +19 -0
- data/lib/metric_fu/metrics/rcov/template_awesome/rcov.html.erb +0 -4
- data/lib/metric_fu/metrics/reek/init.rb +1 -1
- data/lib/metric_fu/metrics/reek/reek.rb +12 -8
- data/lib/metric_fu/metrics/reek/reek_grapher.rb +19 -0
- data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +0 -4
- data/lib/metric_fu/metrics/roodi/roodi.rb +2 -3
- data/lib/metric_fu/metrics/roodi/roodi_grapher.rb +19 -0
- data/lib/metric_fu/metrics/roodi/template_awesome/roodi.html.erb +0 -4
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +69 -33
- data/lib/metric_fu/metrics/saikuro/scratch_file.rb +8 -9
- data/lib/metric_fu/metrics/stats/stats_grapher.rb +20 -0
- data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +0 -4
- data/lib/metric_fu/reporting/graphs/grapher.rb +69 -3
- data/lib/metric_fu/reporting/result.rb +5 -1
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +7 -3
- data/lib/metric_fu/run.rb +13 -7
- data/lib/metric_fu/tasks/metric_fu.rake +50 -3
- data/lib/metric_fu/utility.rb +10 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +7 -4
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/.gitkeep +0 -0
- data/spec/dummy/.metrics +4 -0
- data/spec/dummy/lib/.gitkeep +0 -0
- data/spec/dummy/spec/.gitkeep +0 -0
- data/spec/{resources/yml → fixtures}/20090630.yml +1 -1
- data/spec/{resources/yml → fixtures}/hotspots/flog.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/generator.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/generator_analysis.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/reek.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/roodi.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/saikuro.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/several_metrics.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/stats.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/three_metrics_on_same_file.yml +0 -0
- data/spec/{resources → fixtures}/line_numbers/foo.rb +0 -0
- data/spec/{resources → fixtures}/line_numbers/module.rb +0 -0
- data/spec/{resources → fixtures}/line_numbers/module_surrounds_class.rb +0 -0
- data/spec/{resources → fixtures}/line_numbers/two_classes.rb +0 -0
- data/spec/{resources/yml → fixtures}/metric_missing.yml +0 -0
- data/spec/{resources → fixtures}/saikuro/app/controllers/sessions_controller.rb_cyclo.html +0 -0
- data/spec/{resources → fixtures}/saikuro/app/controllers/users_controller.rb_cyclo.html +0 -0
- data/spec/{resources → fixtures}/saikuro/index_cyclo.html +0 -0
- data/spec/{resources → fixtures}/saikuro_sfiles/thing.rb_cyclo.html +0 -0
- data/spec/metric_fu/configuration_spec.rb +1 -1
- data/spec/metric_fu/data_structures/line_numbers_spec.rb +13 -11
- data/spec/metric_fu/formatter/html_spec.rb +2 -2
- data/spec/metric_fu/gem_version_spec.rb +14 -0
- data/spec/metric_fu/loader_spec.rb +12 -0
- data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
- data/spec/metric_fu/metrics/cane/cane_spec.rb +7 -7
- data/spec/metric_fu/metrics/churn/churn_spec.rb +1 -1
- data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/flay/flay_spec.rb +2 -2
- data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +3 -3
- data/spec/metric_fu/metrics/generator_spec.rb +1 -35
- data/spec/metric_fu/metrics/graph_spec.rb +7 -24
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +2 -2
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +2 -2
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -5
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +2 -3
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +1 -1
- data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +1 -4
- data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/reek/reek_spec.rb +1 -1
- data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +3 -3
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +14 -10
- data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +2 -2
- data/spec/metric_fu/reporting/graphs/{engines/bluff_spec.rb → grapher_spec.rb} +8 -2
- data/spec/{run_spec.rb → metric_fu/run_spec.rb} +8 -13
- data/spec/spec_helper.rb +30 -5
- data/spec/support/deferred_garbaged_collection.rb +34 -0
- data/spec/support/helper_methods.rb +1 -15
- data/spec/support/suite.rb +4 -24
- data/spec/support/test_fixtures.rb +39 -0
- data/spec/support/timeout.rb +7 -0
- metadata +129 -104
- metadata.gz.sig +1 -0
- data/lib/metric_fu/metrics/cane/cane_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/cane/cane_gchart_grapher.rb +0 -25
- data/lib/metric_fu/metrics/flay/flay_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/flay/flay_gchart_grapher.rb +0 -20
- data/lib/metric_fu/metrics/flog/flog_bluff_grapher.rb +0 -17
- data/lib/metric_fu/metrics/flog/flog_gchart_grapher.rb +0 -28
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_gchart_grapher.rb +0 -27
- data/lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/rcov/rcov_gchart_grapher.rb +0 -22
- data/lib/metric_fu/metrics/reek/reek_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/reek/reek_gchart_grapher.rb +0 -30
- data/lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/roodi/roodi_gchart_grapher.rb +0 -20
- data/lib/metric_fu/metrics/stats/stats_bluff_grapher.rb +0 -17
- data/lib/metric_fu/metrics/stats/stats_gchart_grapher.rb +0 -27
- data/lib/metric_fu/reporting/graphs/engines/bluff.rb +0 -33
- data/lib/metric_fu/reporting/graphs/engines/gchart.rb +0 -72
- data/lib/metric_fu/reporting/graphs/engines/init.rb +0 -19
- data/lib/metric_fu_requires.rb +0 -63
- data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +0 -161
data/lib/metric_fu/metric.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'set'
|
2
|
+
MetricFu.lib_require { 'gem_run' }
|
2
3
|
# Encapsulates the configuration options for each metric
|
3
4
|
module MetricFu
|
4
5
|
class Metric
|
@@ -28,11 +29,33 @@ module MetricFu
|
|
28
29
|
not_implemented
|
29
30
|
end
|
30
31
|
|
32
|
+
def gem_name
|
33
|
+
name
|
34
|
+
end
|
35
|
+
|
31
36
|
# @return metric run options [Hash]
|
32
37
|
def run_options
|
33
38
|
default_run_options.merge(configured_run_options)
|
34
39
|
end
|
35
40
|
|
41
|
+
def default_run_args
|
42
|
+
run_options.map { |k, v| "--#{k} #{v}" }.join(' ')
|
43
|
+
end
|
44
|
+
|
45
|
+
def run
|
46
|
+
not_implemented
|
47
|
+
end
|
48
|
+
|
49
|
+
def run_external(args = default_run_args)
|
50
|
+
runner = GemRun.new({
|
51
|
+
gem_name: gem_name.to_s,
|
52
|
+
metric_name: name.to_s,
|
53
|
+
# version: ,
|
54
|
+
args: args,
|
55
|
+
})
|
56
|
+
runner.run
|
57
|
+
end
|
58
|
+
|
36
59
|
def configured_run_options
|
37
60
|
@configured_run_options
|
38
61
|
end
|
@@ -97,6 +120,5 @@ module MetricFu
|
|
97
120
|
@libraries << file.strip
|
98
121
|
end
|
99
122
|
|
100
|
-
|
101
123
|
end
|
102
124
|
end
|
@@ -7,9 +7,13 @@ module MetricFu
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def emit
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
args = [
|
11
|
+
abc_max_param,
|
12
|
+
style_measure_param,
|
13
|
+
no_doc_param,
|
14
|
+
no_readme_param
|
15
|
+
].join
|
16
|
+
@output = run!(args)
|
13
17
|
end
|
14
18
|
|
15
19
|
def analyze
|
@@ -3,6 +3,10 @@ module MetricFu
|
|
3
3
|
class CaneGrapher < Grapher
|
4
4
|
attr_accessor :cane_violations, :labels
|
5
5
|
|
6
|
+
def self.metric
|
7
|
+
:cane
|
8
|
+
end
|
9
|
+
|
6
10
|
def initialize
|
7
11
|
super
|
8
12
|
@cane_violations = []
|
@@ -15,6 +19,21 @@ module MetricFu
|
|
15
19
|
@labels.update( { @labels.size => date })
|
16
20
|
end
|
17
21
|
end
|
22
|
+
|
23
|
+
def title
|
24
|
+
'Cane: code quality threshold violations'
|
25
|
+
end
|
26
|
+
|
27
|
+
def data
|
28
|
+
[
|
29
|
+
['cane', @cane_violations.join(',')]
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def output_filename
|
34
|
+
'cane.js'
|
35
|
+
end
|
36
|
+
|
18
37
|
end
|
19
38
|
end
|
20
39
|
|
@@ -13,12 +13,8 @@
|
|
13
13
|
<p><a href='https://github.com/square/cane'>Cane</a> reports code quality threshold violations.</p>
|
14
14
|
|
15
15
|
<% graph_name = 'cane' %>
|
16
|
-
<% if MetricFu.configuration.graph_engine == :gchart %>
|
17
|
-
<img src="<%= graph_name %>.png?<%= Time.now.to_i %>" />
|
18
|
-
<% else %>
|
19
16
|
<canvas id="graph"></canvas>
|
20
17
|
<script language="javascript" src="<%= graph_name %>.js?<%= Time.now.to_i %>" type="text/javascript"></script>
|
21
|
-
<% end %>
|
22
18
|
|
23
19
|
<% if @cane[:violations][:abc_complexity] && @cane[:violations][:abc_complexity].size > 0 %>
|
24
20
|
<h3>Methods exceeding allowed Abc complexity (<%= @cane[:violations][:abc_complexity].size %>)</h3>
|
@@ -26,7 +26,12 @@ module MetricFu
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def generate_churn_metrics
|
29
|
-
|
29
|
+
output = churn_code
|
30
|
+
ensure_output_is_valid_yaml(output)
|
31
|
+
end
|
32
|
+
|
33
|
+
def churn_code
|
34
|
+
run!(build_churn_options)
|
30
35
|
end
|
31
36
|
|
32
37
|
def ensure_output_is_valid_yaml(output)
|
@@ -38,12 +43,6 @@ module MetricFu
|
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
41
|
-
def churn_code
|
42
|
-
command = "mf-churn #{build_churn_options}"
|
43
|
-
mf_debug "** #{command}"
|
44
|
-
`#{command}`
|
45
|
-
end
|
46
|
-
|
47
46
|
def build_churn_options
|
48
47
|
opts = ["--yaml"]
|
49
48
|
churn_options.each do |churn_option, command_flag|
|
@@ -8,10 +8,8 @@ module MetricFu
|
|
8
8
|
|
9
9
|
def emit
|
10
10
|
minimum_score_parameter = options[:minimum_score] ? "--mass #{options[:minimum_score]} " : ""
|
11
|
-
|
12
|
-
|
13
|
-
mf_debug "** #{command}"
|
14
|
-
@output = `#{command}`
|
11
|
+
args = "#{minimum_score_parameter} #{options[:dirs_to_flay].join(" ")}"
|
12
|
+
@output = run!(args)
|
15
13
|
end
|
16
14
|
|
17
15
|
def analyze
|
@@ -3,6 +3,10 @@ module MetricFu
|
|
3
3
|
class FlayGrapher < Grapher
|
4
4
|
attr_accessor :flay_score, :labels
|
5
5
|
|
6
|
+
def self.metric
|
7
|
+
:flay
|
8
|
+
end
|
9
|
+
|
6
10
|
def initialize
|
7
11
|
super
|
8
12
|
@flay_score = []
|
@@ -15,5 +19,20 @@ module MetricFu
|
|
15
19
|
@labels.update( { @labels.size => date })
|
16
20
|
end
|
17
21
|
end
|
22
|
+
|
23
|
+
def title
|
24
|
+
'Flay: duplication'
|
25
|
+
end
|
26
|
+
|
27
|
+
def data
|
28
|
+
[
|
29
|
+
['flay', @flay_score.join(',')]
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def output_filename
|
34
|
+
'flay.js'
|
35
|
+
end
|
36
|
+
|
18
37
|
end
|
19
38
|
end
|
@@ -3,12 +3,8 @@
|
|
3
3
|
<p><a href='http://ruby.sadi.st/Flay.html'>Flay</a> analyzes ruby code for structural similarities.</p>
|
4
4
|
|
5
5
|
<% graph_name = 'flay' %>
|
6
|
-
<% if MetricFu.configuration.graph_engine == :gchart %>
|
7
|
-
<img src="<%= graph_name %>.png?<%= Time.now.to_i %>" />
|
8
|
-
<% else %>
|
9
6
|
<canvas id="graph"></canvas>
|
10
7
|
<script language="javascript" src="<%= graph_name %>.js?<%= Time.now.to_i %>" type="text/javascript"></script>
|
11
|
-
<% end %>
|
12
8
|
|
13
9
|
<h4>Total Score (lower is better): <%= @flay[:total_score] %></h4>
|
14
10
|
<h5>Scores less than <%= MetricFu::Metric.get_metric('flay').run_options[:minimum_score] %> are not shown or part of the total</h5>
|
@@ -3,6 +3,10 @@ module MetricFu
|
|
3
3
|
class FlogGrapher < Grapher
|
4
4
|
attr_accessor :flog_average, :labels, :top_five_percent_average
|
5
5
|
|
6
|
+
def self.metric
|
7
|
+
:flog
|
8
|
+
end
|
9
|
+
|
6
10
|
def initialize
|
7
11
|
super
|
8
12
|
@flog_average = []
|
@@ -18,6 +22,21 @@ module MetricFu
|
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
25
|
+
def title
|
26
|
+
'Flog: code complexity'
|
27
|
+
end
|
28
|
+
|
29
|
+
def data
|
30
|
+
[
|
31
|
+
['average', @flog_average.join(',')],
|
32
|
+
['top 5% average', @top_five_percent_average.join(',')]
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
def output_filename
|
37
|
+
'flog.js'
|
38
|
+
end
|
39
|
+
|
21
40
|
private
|
22
41
|
|
23
42
|
def calc_top_five_percent_average(metrics)
|
@@ -2,12 +2,8 @@
|
|
2
2
|
<p><a href='http://ruby.sadi.st/Flog.html'>Flog</a> measures code complexity.</p>
|
3
3
|
|
4
4
|
<% graph_name = 'flog' %>
|
5
|
-
<% if MetricFu.configuration.graph_engine == :gchart %>
|
6
|
-
<img src="<%= graph_name %>.png?<%= Time.now.to_i %>" />
|
7
|
-
<% else %>
|
8
5
|
<canvas id="graph"></canvas>
|
9
6
|
<script language="javascript" src="<%= graph_name %>.js?<%= Time.now.to_i %>" type="text/javascript"></script>
|
10
|
-
<% end %>
|
11
7
|
|
12
8
|
<h2>Total Flog score for all methods: <%= round_to_tenths @flog[:total]%></h2>
|
13
9
|
<h2>Average Flog score for all methods: <%= round_to_tenths @flog[:average]%></h2>
|
@@ -38,12 +38,24 @@ module MetricFu
|
|
38
38
|
@options = options
|
39
39
|
end
|
40
40
|
|
41
|
+
def self.metric
|
42
|
+
not_implemented
|
43
|
+
end
|
44
|
+
|
45
|
+
def metric
|
46
|
+
self.class.metric
|
47
|
+
end
|
48
|
+
|
41
49
|
@generators = []
|
42
50
|
# @return all subclassed generators [Array<MetricFu::Generator>]
|
43
51
|
def self.generators
|
44
52
|
@generators
|
45
53
|
end
|
46
54
|
|
55
|
+
def self.metric
|
56
|
+
not_implemented
|
57
|
+
end
|
58
|
+
|
47
59
|
def self.get_generator(metric)
|
48
60
|
generators.find{|generator|generator.metric.to_s == metric.to_s.downcase}
|
49
61
|
end
|
@@ -76,12 +88,17 @@ module MetricFu
|
|
76
88
|
paths - files_to_remove
|
77
89
|
end
|
78
90
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
91
|
+
def metric
|
92
|
+
self.class.metric
|
93
|
+
end
|
94
|
+
|
95
|
+
def metric_config
|
96
|
+
MetricFu::Metric.get_metric(metric)
|
97
|
+
end
|
98
|
+
|
99
|
+
def run!(args)
|
100
|
+
metric_config.run_external(args)
|
83
101
|
end
|
84
|
-
define_method("before_to_h".to_sym) {}
|
85
102
|
|
86
103
|
# Provides a template method to drive the production of a metric
|
87
104
|
# from a concrete implementation of this class. Each concrete
|
@@ -93,15 +110,10 @@ module MetricFu
|
|
93
110
|
# methods to allow extra hooks into the processing methods, and help
|
94
111
|
# to keep the logic of your Generators clean.
|
95
112
|
def generate_result
|
96
|
-
mf_debug "Executing #{
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
send("#{meth}".to_sym)
|
101
|
-
send("after_#{meth}".to_sym)
|
102
|
-
end
|
103
|
-
before_to_h()
|
104
|
-
to_h()
|
113
|
+
mf_debug "Executing #{metric}"
|
114
|
+
emit
|
115
|
+
analyze
|
116
|
+
to_h
|
105
117
|
end
|
106
118
|
|
107
119
|
def round_to_tenths(decimal)
|
@@ -110,27 +122,25 @@ module MetricFu
|
|
110
122
|
end
|
111
123
|
|
112
124
|
def emit #:nodoc:
|
113
|
-
|
114
|
-
This method must be implemented by a concrete class descending
|
115
|
-
from Generator. See generator class documentation for more
|
116
|
-
information.
|
117
|
-
EOF
|
125
|
+
self.class.not_implemented
|
118
126
|
end
|
119
127
|
|
120
128
|
def analyze #:nodoc:
|
121
|
-
|
122
|
-
This method must be implemented by a concrete class descending
|
123
|
-
from Generator. See generator class documentation for more
|
124
|
-
information.
|
125
|
-
EOF
|
129
|
+
self.class.not_implemented
|
126
130
|
end
|
127
131
|
|
128
132
|
def to_h #:nodoc:
|
133
|
+
self.class.not_implemented
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.not_implemented
|
129
137
|
raise <<-EOF
|
138
|
+
Required method #{caller[0]} not implemented in #{__FILE__}.
|
130
139
|
This method must be implemented by a concrete class descending
|
131
140
|
from Generator. See generator class documentation for more
|
132
141
|
information.
|
133
142
|
EOF
|
134
143
|
end
|
144
|
+
|
135
145
|
end
|
136
146
|
end
|
@@ -12,14 +12,14 @@ module MetricFu
|
|
12
12
|
self.graphers = []
|
13
13
|
end
|
14
14
|
|
15
|
-
def add(
|
16
|
-
grapher =
|
17
|
-
|
15
|
+
def add(metric_name, graph_engine, output_directory = MetricFu::Io::FileSystem.directory('output_directory'))
|
16
|
+
grapher = MetricFu::Grapher.get_grapher(metric_name).
|
17
|
+
new.tap{|g| g.output_directory = output_directory }
|
18
|
+
self.graphers.push grapher
|
18
19
|
rescue NameError => e
|
19
20
|
mf_log "#{e.message} called in MetricFu::Graph.add with #{graph_type}"
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
23
|
def generate
|
24
24
|
return if self.graphers.empty?
|
25
25
|
mf_log "Generating graphs"
|
@@ -31,12 +31,10 @@ module MetricFu
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
def grapher_from_type_and_engine(graph_type, graph_engine)
|
35
|
-
grapher_name = graph_type.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } + graph_engine.to_s.capitalize + "Grapher"
|
36
|
-
MetricFu.const_get(grapher_name)
|
37
|
-
end
|
38
34
|
def metric_files
|
39
|
-
|
35
|
+
MetricFu::Utility.glob(
|
36
|
+
File.join(MetricFu::Io::FileSystem.directory('data_directory'), '*.yml')
|
37
|
+
).sort
|
40
38
|
end
|
41
39
|
|
42
40
|
def generate_graphs_for_files
|
@@ -48,17 +46,13 @@ module MetricFu
|
|
48
46
|
def generate_graphs_for_file(metric_file)
|
49
47
|
mf_log "Generating graphs for #{metric_file}"
|
50
48
|
date_parts = year_month_day_from_filename(metric_file)
|
51
|
-
metrics =
|
49
|
+
metrics = MetricFu::Utility.load_yaml(metric_file)
|
52
50
|
|
53
51
|
build_graph(metrics, "#{date_parts[:m]}/#{date_parts[:d]}")
|
54
52
|
rescue NameError => e
|
55
53
|
mf_log "#{e.message} called in MetricFu::Graph.generate with #{metric_file}"
|
56
54
|
end
|
57
55
|
|
58
|
-
def load_yaml_metric_file(metric_file)
|
59
|
-
YAML.load(File.open(metric_file))
|
60
|
-
end
|
61
|
-
|
62
56
|
def build_graph(metrics, sortable_prefix)
|
63
57
|
self.graphers.each do |grapher|
|
64
58
|
grapher.get_metrics(metrics, sortable_prefix)
|
@@ -8,10 +8,10 @@ module MetricFu
|
|
8
8
|
@analyzers.values
|
9
9
|
end
|
10
10
|
def self.analyzer_for_metric(metric)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
@analyzers.fetch(metric.to_sym) do
|
12
|
+
message = "Unknown metric #{metric}. We only know #{@analyzers.keys.inspect}"
|
13
|
+
fail MetricFu::AnalysisError, message
|
14
|
+
end
|
15
15
|
end
|
16
16
|
def self.inherited(subclass)
|
17
17
|
mf_debug "Adding #{subclass} to #{@analyzers.inspect}"
|
@@ -42,7 +42,9 @@ module MetricFu
|
|
42
42
|
:average => MetricFu::HotspotScoringStrategies.average(scores),
|
43
43
|
:sum => MetricFu::HotspotScoringStrategies.sum(scores),
|
44
44
|
:absent => 0,
|
45
|
-
}.fetch(reduce_strategy)
|
45
|
+
}.fetch(reduce_strategy) do
|
46
|
+
fail "#{reduce_strategy} not a known reduce strategy"
|
47
|
+
end
|
46
48
|
end
|
47
49
|
|
48
50
|
def reduce_strategy
|
@@ -34,12 +34,10 @@
|
|
34
34
|
<b>
|
35
35
|
<%= display_location(location) %>
|
36
36
|
</b>
|
37
|
-
<%
|
38
|
-
|
39
|
-
<
|
40
|
-
|
41
|
-
»</small>
|
42
|
-
<% end %>
|
37
|
+
<% unless per_file_data[file].empty? %>
|
38
|
+
<small>«
|
39
|
+
<b><a href="<%= file.gsub(%r{/}, '_') %>.html<%= (line.nil? ? '' : "#line#{line}") %>">annotate</a></b>
|
40
|
+
»</small>
|
43
41
|
<% end %>
|
44
42
|
<br/><br/>
|
45
43
|
<!-- TODO HOTSPOTS for metric fu nice metric_link method -->
|