p8-metric_fu 0.9.0.3 → 0.9.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +14 -7
- data/lib/metric_fu/base.rb +62 -75
- data/lib/metric_fu/churn.rb +1 -1
- data/lib/tasks/coverage.rake +5 -5
- data/lib/tasks/railroad.rake +4 -4
- data/lib/tasks/saikuro.rake +2 -2
- data/lib/tasks/stats.rake +1 -1
- data/spec/base_spec.rb +4 -4
- data/{lib/metric_fu → vendor}/saikuro/saikuro.rb +0 -0
- metadata +2 -2
data/Manifest.txt
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
History.txt
|
2
2
|
Manifest.txt
|
3
|
-
metric_fu-0.7.gem
|
4
3
|
metric_fu.gemspec
|
5
4
|
MIT-LICENSE
|
6
5
|
Rakefile
|
@@ -9,11 +8,11 @@ TODO.txt
|
|
9
8
|
lib/metric_fu.rb
|
10
9
|
lib/metric_fu/base.rb
|
11
10
|
lib/metric_fu/churn.rb
|
12
|
-
lib/metric_fu/
|
13
|
-
lib/metric_fu/
|
11
|
+
lib/metric_fu/flay.rb
|
12
|
+
lib/metric_fu/flog.rb
|
13
|
+
lib/metric_fu/reek.rb
|
14
|
+
lib/metric_fu/roodi.rb
|
14
15
|
lib/metric_fu/md5_tracker.rb
|
15
|
-
lib/metric_fu/saikuro/saikuro.rb
|
16
|
-
lib/metric_fu/saikuro/SAIKURO_README
|
17
16
|
lib/tasks/churn.rake
|
18
17
|
lib/tasks/coverage.rake
|
19
18
|
lib/tasks/flog.rake
|
@@ -21,5 +20,13 @@ lib/tasks/metric_fu.rake
|
|
21
20
|
lib/tasks/metric_fu.rb
|
22
21
|
lib/tasks/saikuro.rake
|
23
22
|
lib/tasks/stats.rake
|
24
|
-
|
25
|
-
|
23
|
+
spec/base_spec.rb
|
24
|
+
spec/churn_spec.rb
|
25
|
+
spec/config_spec.rb
|
26
|
+
spec/flay_spec.rb
|
27
|
+
spec/flog_spec.rb
|
28
|
+
spec/md5_tracker_spec.rb
|
29
|
+
spec/reek_spec.rb
|
30
|
+
spec/spec_helper.rb
|
31
|
+
vendor/saikuro/saikuro.rb
|
32
|
+
vendor/saikuro/SAIKURO_README
|
data/lib/metric_fu/base.rb
CHANGED
@@ -1,31 +1,13 @@
|
|
1
1
|
require 'erb'
|
2
2
|
module MetricFu
|
3
3
|
|
4
|
-
TEMPLATE_DIR = File.join(File.dirname(__FILE__), '..', 'templates')
|
5
|
-
BASE_DIRECTORY = ENV['CC_BUILD_ARTIFACTS'] || 'tmp/metric_fu'
|
6
|
-
|
7
4
|
class << self
|
8
5
|
# The Configuration instance used to configure the Rails environment
|
9
6
|
def configuration
|
10
7
|
@@configuration ||= Configuration.new
|
11
8
|
end
|
12
9
|
|
13
|
-
|
14
|
-
configuration.churn
|
15
|
-
end
|
16
|
-
|
17
|
-
def coverage
|
18
|
-
configuration.coverage
|
19
|
-
end
|
20
|
-
|
21
|
-
def flay
|
22
|
-
configuration.flay
|
23
|
-
end
|
24
|
-
|
25
|
-
def flog
|
26
|
-
configuration.flog
|
27
|
-
end
|
28
|
-
|
10
|
+
# The metrics configured for this project
|
29
11
|
def metrics
|
30
12
|
configuration.metrics
|
31
13
|
end
|
@@ -33,18 +15,6 @@ module MetricFu
|
|
33
15
|
def open_in_browser?
|
34
16
|
configuration.general[:open_in_browser] && PLATFORM['darwin'] && !run_by_cruise_control?
|
35
17
|
end
|
36
|
-
|
37
|
-
def saikuro
|
38
|
-
configuration.saikuro
|
39
|
-
end
|
40
|
-
|
41
|
-
def reek
|
42
|
-
configuration.reek
|
43
|
-
end
|
44
|
-
|
45
|
-
def roodi
|
46
|
-
configuration.roodi
|
47
|
-
end
|
48
18
|
|
49
19
|
def run_by_cruise_control?
|
50
20
|
!!ENV['CC_BUILD_ARTIFACTS']
|
@@ -78,12 +48,22 @@ module MetricFu
|
|
78
48
|
# Churning requires a subversion or git repo
|
79
49
|
metrics << :churn if can_churn?
|
80
50
|
metrics.sort{|v1, v2| v1.to_s <=> v2.to_s}
|
81
|
-
end
|
51
|
+
end
|
82
52
|
|
83
53
|
end
|
84
54
|
|
55
|
+
default_metrics.each do |meth|
|
56
|
+
method = <<-EOF
|
57
|
+
def self.#{meth}
|
58
|
+
configuration.#{meth}
|
59
|
+
end
|
60
|
+
EOF
|
61
|
+
class_eval(method)
|
62
|
+
end
|
63
|
+
|
85
64
|
class Configuration
|
86
|
-
attr_accessor :churn, :coverage, :flay, :flog, :metrics, :reek, :roodi, :saikuro,
|
65
|
+
attr_accessor :churn, :coverage, :flay, :flog, :metrics, :reek, :roodi, :saikuro,
|
66
|
+
:general, :template_dir, :base_directory
|
87
67
|
def initialize
|
88
68
|
raise "Use config.churn instead of MetricFu::CHURN_OPTIONS" if defined? ::MetricFu::CHURN_OPTIONS
|
89
69
|
raise "Use config.flog[:dirs_to_flog] instead of MetricFu::DIRECTORIES_TO_FLOG" if defined? ::MetricFu::DIRECTORIES_TO_FLOG
|
@@ -106,8 +86,10 @@ module MetricFu
|
|
106
86
|
@flog = { :dirs_to_flog => MetricFu.code_dirs}
|
107
87
|
@reek = { :dirs_to_reek => MetricFu.code_dirs}
|
108
88
|
@roodi = { :dirs_to_roodi => MetricFu.code_dirs}
|
109
|
-
@metrics
|
89
|
+
@metrics = MetricFu.default_metrics
|
110
90
|
@saikuro = {}
|
91
|
+
@template_dir = File.join(File.dirname(__FILE__), '..', 'templates')
|
92
|
+
@base_directory = ENV['CC_BUILD_ARTIFACTS'] || 'tmp/metric_fu'
|
111
93
|
end
|
112
94
|
|
113
95
|
def saikuro=(options)
|
@@ -115,7 +97,48 @@ module MetricFu
|
|
115
97
|
@saikuro = options
|
116
98
|
end
|
117
99
|
end
|
118
|
-
|
100
|
+
|
101
|
+
########################
|
102
|
+
# Template methods
|
103
|
+
module TemplateHelpers
|
104
|
+
|
105
|
+
def inline_css(css)
|
106
|
+
open(File.join(MetricFu.configuration.template_dir, css)) { |f| f.read }
|
107
|
+
end
|
108
|
+
|
109
|
+
def link_to_filename(name, line = nil)
|
110
|
+
if MetricFu.run_by_cruise_control?
|
111
|
+
cc_link_to_filename(name, line)
|
112
|
+
else
|
113
|
+
system_link_to_filename(name, line)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def cycle(first_value, second_value, iteration)
|
118
|
+
return first_value if iteration % 2 == 0
|
119
|
+
return second_value
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
def cc_link_to_filename(name, line = nil)
|
124
|
+
if MetricFu.configuration.general[:url_prefix]
|
125
|
+
MetricFu.configuration.general[:url_prefix] += '/' unless MetricFu.configuration.general[:url_prefix] =~ /\/$/
|
126
|
+
%{<a href="#{MetricFu.configuration.general[:url_prefix]}#{name}?line=#{line}##{line}">#{name}</a>}
|
127
|
+
else
|
128
|
+
%{"#{name}"} # No link for cruise control without a prefix
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def system_link_to_filename(name, line = nil)
|
133
|
+
filename = File.expand_path(name)
|
134
|
+
if PLATFORM['darwin']
|
135
|
+
%{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}</a>}
|
136
|
+
else
|
137
|
+
%{<a href="file://#{filename}">#{name}</a>}
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
119
142
|
module Base
|
120
143
|
|
121
144
|
######################################################################
|
@@ -123,12 +146,14 @@ module MetricFu
|
|
123
146
|
#
|
124
147
|
class Generator
|
125
148
|
|
149
|
+
include MetricFu::TemplateHelpers
|
150
|
+
|
126
151
|
def initialize(options={})
|
127
152
|
@base_dir = self.class.metric_dir
|
128
153
|
end
|
129
154
|
|
130
155
|
def self.metric_dir
|
131
|
-
File.join(
|
156
|
+
File.join(MetricFu.configuration.base_directory, template_name)
|
132
157
|
end
|
133
158
|
|
134
159
|
def self.template_name
|
@@ -160,47 +185,9 @@ module MetricFu
|
|
160
185
|
end
|
161
186
|
|
162
187
|
def template_file
|
163
|
-
File.join(MetricFu
|
188
|
+
File.join(MetricFu.configuration.template_dir, "#{template_name}.html.erb")
|
164
189
|
end
|
165
190
|
|
166
|
-
########################
|
167
|
-
# Template methods
|
168
|
-
|
169
|
-
def inline_css(css)
|
170
|
-
open(File.join(MetricFu::TEMPLATE_DIR, css)) { |f| f.read }
|
171
|
-
end
|
172
|
-
|
173
|
-
def link_to_filename(name, line = nil)
|
174
|
-
if MetricFu.run_by_cruise_control?
|
175
|
-
cc_link_to_filename(name, line)
|
176
|
-
else
|
177
|
-
system_link_to_filename(name, line)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def cycle(first_value, second_value, iteration)
|
182
|
-
return first_value if iteration % 2 == 0
|
183
|
-
return second_value
|
184
|
-
end
|
185
|
-
|
186
|
-
private
|
187
|
-
def cc_link_to_filename(name, line = nil)
|
188
|
-
if MetricFu.configuration.general[:url_prefix]
|
189
|
-
MetricFu.configuration.general[:url_prefix] += '/' unless MetricFu.configuration.general[:url_prefix] =~ /\/$/
|
190
|
-
%{<a href="#{MetricFu.configuration.general[:url_prefix]}#{name}?line=#{line}##{line}">#{name}</a>}
|
191
|
-
else
|
192
|
-
%{"#{name}"} # No link for cruise control without a prefix
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def system_link_to_filename(name, line = nil)
|
197
|
-
filename = File.expand_path(name)
|
198
|
-
if PLATFORM['darwin']
|
199
|
-
%{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}</a>}
|
200
|
-
else
|
201
|
-
%{<a href="file://#{filename}">#{name}</a>}
|
202
|
-
end
|
203
|
-
end
|
204
191
|
end
|
205
192
|
end
|
206
193
|
|
data/lib/metric_fu/churn.rb
CHANGED
@@ -8,7 +8,7 @@ module MetricFu
|
|
8
8
|
class Churn < Base::Generator
|
9
9
|
|
10
10
|
def initialize(options={})
|
11
|
-
@base_dir = File.join(MetricFu
|
11
|
+
@base_dir = File.join(MetricFu.configuration.base_directory, template_name)
|
12
12
|
if MetricFu.uses_git?
|
13
13
|
@source_control = Git.new(options[:start_date])
|
14
14
|
elsif MetricFu.uses_svn?
|
data/lib/tasks/coverage.rake
CHANGED
@@ -7,9 +7,9 @@ begin
|
|
7
7
|
|
8
8
|
namespace :metrics do
|
9
9
|
|
10
|
-
COVERAGE_DIR = File.join(MetricFu
|
11
|
-
COVERAGE_DATA_FILE = File.join(MetricFu
|
12
|
-
SPEC_HTML_FILE = File.join(MetricFu
|
10
|
+
COVERAGE_DIR = File.join(MetricFu.configuration.base_directory, 'coverage')
|
11
|
+
COVERAGE_DATA_FILE = File.join(MetricFu.configuration.base_directory, 'coverage.data')
|
12
|
+
SPEC_HTML_FILE = File.join(MetricFu.configuration.base_directory, 'specs.html')
|
13
13
|
|
14
14
|
namespace :coverage do
|
15
15
|
rcov_output = COVERAGE_DIR
|
@@ -19,7 +19,7 @@ begin
|
|
19
19
|
|
20
20
|
desc "RCov task to generate report"
|
21
21
|
Rcov::RcovTask.new(:do => :clean) do |t|
|
22
|
-
FileUtils.mkdir_p(MetricFu
|
22
|
+
FileUtils.mkdir_p(MetricFu.configuration.base_directory) unless File.directory?(MetricFu.configuration.base_directory)
|
23
23
|
t.test_files = FileList[*MetricFu.coverage[:test_files]]
|
24
24
|
t.rcov_opts = MetricFu.coverage[:rcov_opts]
|
25
25
|
t.output_dir = COVERAGE_DIR
|
@@ -29,7 +29,7 @@ begin
|
|
29
29
|
# TODO not sure what this improves but it requires the diff-lcs gem
|
30
30
|
# http://github.com/indirect/metric_fu/commit/b9c1cf75f09d5b531b388cd01661eb16b5126968#diff-1
|
31
31
|
# Spec::Rake::SpecTask.new(:do => :clean) do |t|
|
32
|
-
# FileUtils.mkdir_p(MetricFu
|
32
|
+
# FileUtils.mkdir_p(MetricFu.configuration.base_directory) unless File.directory?(MetricFu.configuration.base_directory)
|
33
33
|
# t.ruby_opts = ['-rtest/unit']
|
34
34
|
# t.spec_files = FileList['test/**/*_test.rb', 'spec/**/*spec.rb']
|
35
35
|
# t.spec_opts = ["--format", "html:#{SPEC_HTML_FILE}", "--diff"]
|
data/lib/tasks/railroad.rake
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
namespace :metrics do
|
2
2
|
|
3
|
-
RAILROAD_DIR = File.join(MetricFu
|
3
|
+
RAILROAD_DIR = File.join(MetricFu.configuration.base_directory, 'railroad')
|
4
4
|
RAILROAD_FILE = File.join(RAILROAD_DIR, 'index.html')
|
5
5
|
|
6
6
|
task :railroad => ['railroad:all'] do
|
@@ -16,21 +16,21 @@ namespace :metrics do
|
|
16
16
|
desc "Create a railroad models report"
|
17
17
|
task :models do
|
18
18
|
#mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
|
19
|
-
`railroad -M -a -m -l -v | neato -Tpng > #{File.join(MetricFu
|
19
|
+
`railroad -M -a -m -l -v | neato -Tpng > #{File.join(MetricFu.configuration.base_directory,'model-diagram.png')}`
|
20
20
|
#`echo "<a href=\"railroad/models.png\">Model diagram</a><br />" >> #{RAILROAD_FILE}`
|
21
21
|
end
|
22
22
|
|
23
23
|
desc "Create a railroad controllers report"
|
24
24
|
task :controllers do
|
25
25
|
#mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
|
26
|
-
`railroad -C -l -v | neato -Tpng > #{File.join(MetricFu
|
26
|
+
`railroad -C -l -v | neato -Tpng > #{File.join(MetricFu.configuration.base_directory,'controller-diagram.png')}`
|
27
27
|
#`echo "<a href=\"railroad/controllers.png\">Controller diagram</a><br />" >> #{RAILROAD_FILE}`
|
28
28
|
end
|
29
29
|
|
30
30
|
desc "Create a railroad acts_as_state_machine report"
|
31
31
|
task :aasm do
|
32
32
|
#mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
|
33
|
-
`railroad -A -l -v | neato -Tpng > #{File.join(MetricFu
|
33
|
+
`railroad -A -l -v | neato -Tpng > #{File.join(MetricFu.configuration.base_directory,'aasm-diagram.png')}`
|
34
34
|
#`echo "<a href=\"railroad/aasm.png\">State machine diagram</a><br />" >> #{RAILROAD_FILE}`
|
35
35
|
end
|
36
36
|
|
data/lib/tasks/saikuro.rake
CHANGED
@@ -4,8 +4,8 @@ namespace :metrics do
|
|
4
4
|
|
5
5
|
desc "A cyclomatic complexity report using Saikuro"
|
6
6
|
task :saikuro do
|
7
|
-
SAIKURO_DIR = File.join(MetricFu
|
8
|
-
SAIKURO = File.expand_path(File.join(File.dirname(__FILE__), '..', '
|
7
|
+
SAIKURO_DIR = File.join(MetricFu.configuration.base_directory, 'saikuro')
|
8
|
+
SAIKURO = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'saikuro', 'saikuro.rb'))
|
9
9
|
|
10
10
|
raise "SAIKURO_OPTIONS is now MetricFu::SAIKURO_OPTIONS" if defined?(SAIKURO_OPTIONS)
|
11
11
|
options = { :output_directory => SAIKURO_DIR,
|
data/lib/tasks/stats.rake
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -4,13 +4,13 @@ describe MetricFu::Base::Generator do
|
|
4
4
|
describe "save_html" do
|
5
5
|
it "should save to a index.html in the base_dir" do
|
6
6
|
@generator = MetricFu::Base::Generator.new
|
7
|
-
@generator.should_receive(:open).with("#{MetricFu
|
7
|
+
@generator.should_receive(:open).with("#{MetricFu.configuration.base_directory}/generator/index.html", "w")
|
8
8
|
@generator.save_html("<html>")
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should save to a custom.html to the base_dir if 'custom' is passed as name" do
|
12
12
|
@generator = MetricFu::Base::Generator.new
|
13
|
-
@generator.should_receive(:open).with("#{MetricFu
|
13
|
+
@generator.should_receive(:open).with("#{MetricFu.configuration.base_directory}/generator/metric_fu/custom.html", "w")
|
14
14
|
@generator.save_html("<html>", 'metric_fu/custom.html')
|
15
15
|
end
|
16
16
|
end
|
@@ -27,7 +27,7 @@ describe MetricFu::Base::Generator do
|
|
27
27
|
describe "generate_html" do
|
28
28
|
it "should create a new Generator and call generate_report on it" do
|
29
29
|
@generator = MetricFu::Base::Generator.new
|
30
|
-
@generator.should_receive(:open).with("#{MetricFu
|
30
|
+
@generator.should_receive(:open).with("#{MetricFu.configuration.base_directory}/generator/index.html", "w")
|
31
31
|
@generator.should_receive(:generate_html).and_return('<html>')
|
32
32
|
@generator.generate_report
|
33
33
|
end
|
@@ -50,7 +50,7 @@ describe MetricFu::Base::Generator do
|
|
50
50
|
|
51
51
|
describe "metric_dir" do
|
52
52
|
it "should return tmp/metric_fu/{the class name in lowercase}" do
|
53
|
-
MetricFu::Base::Generator.metric_dir.should == "#{MetricFu
|
53
|
+
MetricFu::Base::Generator.metric_dir.should == "#{MetricFu.configuration.base_directory}/generator"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: p8-metric_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0.
|
4
|
+
version: 0.9.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Scruggs
|
@@ -98,7 +98,6 @@ files:
|
|
98
98
|
- lib/metric_fu/reek.rb
|
99
99
|
- lib/metric_fu/roodi.rb
|
100
100
|
- lib/metric_fu/md5_tracker.rb
|
101
|
-
- lib/metric_fu/saikuro/saikuro.rb
|
102
101
|
- lib/metric_fu.rb
|
103
102
|
- lib/tasks/metric_fu.rb
|
104
103
|
- lib/tasks/churn.rake
|
@@ -118,6 +117,7 @@ files:
|
|
118
117
|
- lib/templates/flog_page.html.erb
|
119
118
|
- lib/templates/reek.html.erb
|
120
119
|
- lib/templates/roodi.html.erb
|
120
|
+
- vendor/saikuro/saikuro.rb
|
121
121
|
- Manifest.txt
|
122
122
|
has_rdoc: true
|
123
123
|
homepage: http://metric-fu.rubyforge.org/
|