indirect-metric_fu 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +19 -0
- data/MIT-LICENSE +1 -1
- data/Manifest.txt +25 -0
- data/README +74 -21
- data/Rakefile +4 -10
- data/lib/metric_fu/base.rb +116 -9
- data/lib/metric_fu/churn.rb +8 -7
- data/lib/metric_fu/flay.rb +17 -0
- data/lib/metric_fu/flog.rb +129 -0
- data/lib/metric_fu/reek.rb +17 -0
- data/lib/metric_fu/roodi.rb +17 -0
- data/lib/metric_fu.rb +17 -3
- data/lib/tasks/churn.rake +1 -3
- data/lib/tasks/coverage.rake +19 -10
- data/lib/tasks/flay.rake +1 -4
- data/lib/tasks/flog.rake +10 -10
- data/lib/tasks/metric_fu.rake +8 -4
- data/lib/tasks/metric_fu.rb +1 -1
- data/lib/tasks/railroad.rake +39 -0
- data/lib/tasks/reek.rake +6 -0
- data/lib/tasks/roodi.rake +7 -0
- data/lib/tasks/saikuro.rake +1 -1
- data/lib/tasks/stats.rake +2 -3
- data/lib/templates/churn.html.erb +7 -4
- data/lib/templates/default.css +45 -0
- data/lib/templates/flay.html.erb +17 -10
- data/lib/templates/flog.html.erb +27 -15
- data/lib/templates/flog_page.html.erb +15 -3
- data/lib/templates/reek.html.erb +30 -0
- data/lib/templates/roodi.html.erb +26 -0
- data/spec/base_spec.rb +31 -9
- data/spec/churn_spec.rb +11 -4
- data/spec/config_spec.rb +110 -0
- data/spec/{flay_reporter_spec.rb → flay_spec.rb} +10 -3
- data/spec/flog_spec.rb +208 -0
- data/spec/md5_tracker_spec.rb +1 -3
- data/spec/reek_spec.rb +26 -0
- data/spec/spec_helper.rb +7 -3
- metadata +42 -18
- data/lib/metric_fu/flay_reporter.rb +0 -17
- data/lib/metric_fu/flog_reporter/base.rb +0 -49
- data/lib/metric_fu/flog_reporter/generator.rb +0 -39
- data/lib/metric_fu/flog_reporter/operator.rb +0 -10
- data/lib/metric_fu/flog_reporter/page.rb +0 -33
- data/lib/metric_fu/flog_reporter/scanned_method.rb +0 -28
- data/lib/metric_fu/flog_reporter.rb +0 -5
- data/lib/templates/churn.css +0 -38
- data/lib/templates/flay.css +0 -38
- data/lib/templates/flog.css +0 -39
- data/spec/flog_reporter/base_spec.rb +0 -69
data/HISTORY
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
=== MetricFu 0.9.0 / 2009-1-25
|
2
|
+
|
3
|
+
* Adding line numbers to the views so that people viewing it on cc.rb can figure out where the problems are
|
4
|
+
* Merging in changes from Jay Zeschin having to do with the railroad task -- I still have no idea how to use it (lemme know if you figure it out)
|
5
|
+
* Added totals to Flog results
|
6
|
+
* Moved rcov options to configuration
|
7
|
+
|
8
|
+
=== MetricFu 0.8.9 / 2009-1-20
|
9
|
+
|
10
|
+
* Thanks to Andre Arko and Petrik de Heus for adding the following features:
|
11
|
+
* The source control type is auto-detected for Churn
|
12
|
+
* Moved all presentation to templates
|
13
|
+
* Wrote specs for all classes
|
14
|
+
* Added flay, Reek and Roodi metrics
|
15
|
+
* There's now a configuration class (see README for details)
|
16
|
+
* Unification of metrics reports
|
17
|
+
* Metrics can be generated using one command
|
18
|
+
* Adding new metrics reports has been standardized
|
19
|
+
|
1
20
|
=== MetricFu 0.8.0 / 2008-10-06
|
2
21
|
|
3
22
|
* Source Control Churn now supports git (thanks to Erik St Martin)
|
data/MIT-LICENSE
CHANGED
data/Manifest.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
metric_fu-0.7.gem
|
4
|
+
metric_fu.gemspec
|
5
|
+
MIT-LICENSE
|
6
|
+
Rakefile
|
7
|
+
README
|
8
|
+
TODO.txt
|
9
|
+
lib/metric_fu.rb
|
10
|
+
lib/metric_fu/base.rb
|
11
|
+
lib/metric_fu/churn.rb
|
12
|
+
lib/metric_fu/flay_reporter.rb
|
13
|
+
lib/metric_fu/flog_reporter.rb
|
14
|
+
lib/metric_fu/md5_tracker.rb
|
15
|
+
lib/metric_fu/saikuro/saikuro.rb
|
16
|
+
lib/metric_fu/saikuro/SAIKURO_README
|
17
|
+
lib/tasks/churn.rake
|
18
|
+
lib/tasks/coverage.rake
|
19
|
+
lib/tasks/flog.rake
|
20
|
+
lib/tasks/metric_fu.rake
|
21
|
+
lib/tasks/metric_fu.rb
|
22
|
+
lib/tasks/saikuro.rake
|
23
|
+
lib/tasks/stats.rake
|
24
|
+
test/test_helper.rb
|
25
|
+
test/test_md5_tracker.rb
|
data/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Version 0.
|
1
|
+
Version 0.9.0
|
2
2
|
http://github.com/jscruggs/metric_fu
|
3
3
|
|
4
|
-
Metric_fu began its life as a plugin for Rails that generated code metrics reports. As of version 0.7.0, metric_fu is a gem owing to the excellent work done by Sean Soper.
|
4
|
+
Metric_fu began its life as a plugin for Rails that generated code metrics reports. As of version 0.7.0, metric_fu is a gem owing to the excellent work done by Sean Soper.
|
5
5
|
|
6
6
|
Metric_fu is a set of rake tasks that make it easy to generate metrics reports. It uses Saikuro, Flog, Rcov, and Rails' built-in stats task to create a series of reports. It's designed to integrate easily with CruiseControl.rb by placing files in the Custom Build Artifacts folder.
|
7
7
|
|
@@ -12,7 +12,7 @@ Then in your Rakefile:
|
|
12
12
|
require 'metric_fu'
|
13
13
|
|
14
14
|
If you like to vendor gems, you can unpack metric_fu into vendor/gems and require it like so:
|
15
|
-
require 'vendor/gems/jscruggs-metric_fu-0.
|
15
|
+
require 'vendor/gems/jscruggs-metric_fu-0.9.0/lib/metric_fu'
|
16
16
|
|
17
17
|
then you don't have to install it on every box you run it on.
|
18
18
|
|
@@ -23,13 +23,13 @@ You must have Rcov and Flog installed to get coverage and flog reports. Metric_
|
|
23
23
|
****Usage****
|
24
24
|
|
25
25
|
Out of the box metrics provides these tasks:
|
26
|
-
rake metrics:all
|
27
|
-
rake metrics:all_with_migrate # Useful for continuous integration
|
26
|
+
rake metrics:all # Generate coverage, cyclomatic complexity, flog, flay, railroad and churn reports
|
28
27
|
rake metrics:churn # Which files change the most
|
29
28
|
rake metrics:coverage # Generate and open coverage report
|
30
29
|
rake metrics:coverage:clean # Delete aggregate coverage data.
|
31
30
|
rake metrics:coverage:clobber_do # Remove rcov products for do
|
32
31
|
rake metrics:coverage:do # RCov task to generate report
|
32
|
+
rake metrics:flay # Generate code duplication report with flay
|
33
33
|
rake metrics:flog:all # Generate and open flog report
|
34
34
|
rake metrics:flog:clean # Delete aggregate flog data.
|
35
35
|
rake metrics:flog:controllers # Flog code in app/controllers
|
@@ -37,8 +37,12 @@ rake metrics:flog:custom # Generate a flog report from specified direct
|
|
37
37
|
rake metrics:flog:helpers # Flog code in app/helpers
|
38
38
|
rake metrics:flog:lib # Flog code in lib
|
39
39
|
rake metrics:flog:models # Flog code in app/models
|
40
|
+
rake metrics:reek # A code smell report using Reek
|
40
41
|
rake metrics:saikuro # A cyclomatic complexity report using Saikuro
|
41
|
-
|
42
|
+
|
43
|
+
Rails projects also have the following tasks:
|
44
|
+
|
45
|
+
rake metrics:stats # A stats report
|
42
46
|
|
43
47
|
See below for more detail on the individual tasks. It's recommended to use CruiseControl.rb to set up a metrics build. See the CruiseControl.rb online docs for more info on how to set up cc.rb and, once you've got that figured out, change the cruise_config.rb file inside your project to have these lines:
|
44
48
|
|
@@ -48,32 +52,85 @@ project.scheduler.polling_interval = 24.hours
|
|
48
52
|
Which will check for updates every 24 hours and run all the metrics rake tasks (migrating your test db first). The output will be visible from an individual build's detail page.
|
49
53
|
|
50
54
|
|
55
|
+
****Notes on configuration****
|
56
|
+
|
57
|
+
Metric_fu can be customized to your liking by adding the following to your Rakefile
|
58
|
+
|
59
|
+
MetricFu::Configuration.run do |config|
|
60
|
+
#define which metrics you want to use
|
61
|
+
config.metrics = [:coverage, :flog]
|
62
|
+
config.churn = { :start_date => lambda{ 3.months.ago } }
|
63
|
+
config.coverage = { :test_files => ['test/**/test_*.rb'] }
|
64
|
+
config.flog = { :dirs_to_flog => ['cms/app', 'cms/lib'] }
|
65
|
+
config.flay = { :dirs_to_flay => ['cms/app', 'cms/lib'] }
|
66
|
+
config.saikuro = { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
|
67
|
+
end
|
68
|
+
|
69
|
+
|
51
70
|
****Notes on metrics:coverage****
|
52
71
|
|
53
72
|
When creating a coverage report, metric_fu runs all the tests in the test folder and specs in spec folder using Rcov.
|
73
|
+
You can configure the coverage test files pattern:
|
74
|
+
config.coverage[:test_files] = ['test/**/test_*.rb']
|
75
|
+
|
76
|
+
The default value is ['test/**/*_test.rb', 'spec/**/*_spec.rb']
|
77
|
+
|
78
|
+
You may also configure Rcov options:
|
79
|
+
config.coverage = { :test_files => ['test/**/*_test.rb'],
|
80
|
+
:rcov_opts => ["--exclude /gems/,/Library/"] }
|
81
|
+
|
82
|
+
The default value is { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'],
|
83
|
+
:rcov_opts => ["--sort coverage", "--html", "--rails", "--exclude /gems/,/Library/,spec"] }
|
54
84
|
|
55
85
|
|
56
86
|
****Notes on metrics:saikuro****
|
57
87
|
|
58
|
-
Saikuro is bundled with metric_fu so you don't have to install it. Look at the SAIKURO_README (or the internet) for more documentation on Saikuro. If you wish to change the options Saikuro is run with, then set this constant in your
|
59
|
-
|
60
|
-
|
88
|
+
Saikuro is bundled with metric_fu so you don't have to install it. Look at the SAIKURO_README (or the internet) for more documentation on Saikuro. If you wish to change the options Saikuro is run with, then set this constant in your configuration:
|
89
|
+
|
90
|
+
config.saikuro = { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
|
91
|
+
|
92
|
+
config.saikuro is a hash that gets merged with the default options hash. The above example will set the warn_cyclo to 3 and the error_cyclo to 4 (which is way too low -- it's just an example) instructing Saikuro to flag methods with a higher cyclomatic complexity in it's report.
|
93
|
+
|
94
|
+
If you want to have Saikuro look at multiple folders you can put something like this in your configuration:
|
61
95
|
|
62
|
-
|
96
|
+
config.saikuro = {"--input_directory" => '"cms/app | cms/lib"'}
|
63
97
|
|
64
|
-
|
65
|
-
|
98
|
+
|
99
|
+
****Notes on metrics:flay****
|
100
|
+
|
101
|
+
Flay analyzes ruby code for structural similarities.
|
102
|
+
You can configure which directories need to be flayed.
|
103
|
+
The defaults are 'lib' for non Rails projects and ['app', 'lib'] for Rails projects.
|
104
|
+
|
105
|
+
config.flay[:dirs_to_flay] = ['cms/app', 'cms/lib']
|
66
106
|
|
67
107
|
|
68
108
|
****Notes on metrics:flog****
|
69
109
|
|
70
110
|
Flog is another way of measuring complexity (or tortured code as the Flog authors like to put it). You should check out the awesome, and a little scary, Flog website for more info.
|
111
|
+
'rake metrics:flog:custom' allows you to specify a custom set of directories to Flog (in your configuration).
|
112
|
+
The defaults are 'lib' for non Rails projects and ['app', 'lib'] for Rails projects.
|
113
|
+
|
114
|
+
config.flog[:dirs_to_flog] = ['cms/app', 'cms/lib']
|
115
|
+
|
116
|
+
|
117
|
+
****Notes on metrics:reek****
|
71
118
|
|
72
|
-
|
119
|
+
Reek detects common code smells in ruby code.
|
120
|
+
You can configure which directories need to be checked.
|
121
|
+
The defaults are 'lib' for non Rails projects and ['app', 'lib'] for Rails projects.
|
73
122
|
|
74
|
-
|
123
|
+
config.reek[:dirs_to_reek] = ['cms/app', 'cms/lib']
|
75
124
|
|
76
125
|
|
126
|
+
****Notes on metrics:roodi****
|
127
|
+
|
128
|
+
Roodi parses your Ruby code and warns you about design issues you have based on the checks that is has configured.
|
129
|
+
You can configure which directories need to be checked.
|
130
|
+
The defaults are 'lib' for non Rails projects and ['app', 'lib'] for Rails projects.
|
131
|
+
|
132
|
+
config.roodi[:dirs_to_roodi] = ['cms/app', 'cms/lib']
|
133
|
+
|
77
134
|
****Notes on metrics:stats****
|
78
135
|
|
79
136
|
This is just 'rake stats' for Rails put into a file. On my projects I like to be able to look at CruiseControl and get stats about the app at different points in time.
|
@@ -83,19 +140,15 @@ This is just 'rake stats' for Rails put into a file. On my projects I like to b
|
|
83
140
|
|
84
141
|
Files that change a lot in your project may be bad a sign. This task uses "svn log" to identify those files and put them in a report. The default is to start counting changes from the beginning of your project, which might be too far back so you can change like so:
|
85
142
|
|
86
|
-
|
143
|
+
config.churn = { :start_date => lambda{ 3.months.ago } }
|
87
144
|
|
88
145
|
The Proc is there because '3.months.ago' only works when after the Rails Environment is loaded (and Rails extends Fixnum) which I didn't want to do every time you run a rake task.
|
89
146
|
|
90
147
|
You can also change the minimum churn count like so:
|
91
148
|
|
92
|
-
|
93
|
-
|
94
|
-
If you use git, then tell churn about it:
|
95
|
-
|
96
|
-
MetricFu::CHURN_OPTIONS = {:scm => :git}
|
149
|
+
config.churn = { :minimum_churn_count => 3 }
|
97
150
|
|
98
151
|
|
99
152
|
****Thanks****
|
100
153
|
|
101
|
-
I'd like to thank the authors of Saikuro, Flog, Rcov, CruiseControl.rb, and Rails for creating such excellent open source products. Also Sean Soper, Michael Schubert, Kurtis Seebaldt, Toby Tripp, Paul Gross, and Chirdeep Shetty for their help and advice.
|
154
|
+
I'd like to thank the authors of Saikuro, Flog, Rcov, CruiseControl.rb, Flay, Reek, Roodi and Rails for creating such excellent open source products. Also Andre Arko, Petrik de Heus, Sean Soper, Erik St Martin, Andy Gregorowicz, Bastien, Michael Schubert, Kurtis Seebaldt, Toby Tripp, Paul Gross, and Chirdeep Shetty for their help and advice.
|
data/Rakefile
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'spec/rake/spectask'
|
4
|
-
require File.join(File.dirname(__FILE__), 'lib', 'metric_fu')
|
1
|
+
require "rake"
|
2
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
5
3
|
|
6
|
-
desc "Run
|
7
|
-
|
8
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
9
|
-
end
|
10
|
-
|
11
|
-
task :default => [:"metrics:all"]
|
4
|
+
desc "Run the specs."
|
5
|
+
task :default => :spec
|
data/lib/metric_fu/base.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'erb'
|
1
2
|
module MetricFu
|
2
3
|
|
3
4
|
TEMPLATE_DIR = File.join(File.dirname(__FILE__), '..', 'templates')
|
@@ -6,23 +7,38 @@ module MetricFu
|
|
6
7
|
|
7
8
|
if RAILS
|
8
9
|
CODE_DIRS = ['app', 'lib']
|
10
|
+
DEFAULT_METRICS = [:coverage, :churn, :flog, :flay, :reek, :roodi, :stats, :saikuro ]
|
9
11
|
else
|
10
12
|
CODE_DIRS = ['lib']
|
13
|
+
DEFAULT_METRICS = [:coverage, :churn, :flog, :flay, :reek, :roodi, :saikuro ]
|
11
14
|
end
|
12
15
|
|
13
16
|
module Base
|
17
|
+
|
18
|
+
######################################################################
|
19
|
+
# Base class for report Generators
|
20
|
+
#
|
14
21
|
class Generator
|
15
22
|
|
16
|
-
def initialize(
|
17
|
-
@base_dir =
|
23
|
+
def initialize(options={})
|
24
|
+
@base_dir = self.class.metric_dir
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.metric_dir
|
28
|
+
File.join(BASE_DIRECTORY, template_name)
|
18
29
|
end
|
19
30
|
|
20
|
-
def self.
|
21
|
-
self.
|
31
|
+
def self.template_name
|
32
|
+
self.to_s.split('::').last.downcase
|
22
33
|
end
|
23
34
|
|
24
|
-
def
|
25
|
-
|
35
|
+
def self.generate_report(options={})
|
36
|
+
FileUtils.mkdir_p(metric_dir, :verbose => false) unless File.directory?(metric_dir)
|
37
|
+
self.new(options).generate_report
|
38
|
+
end
|
39
|
+
|
40
|
+
def save_html(content, file='index.html')
|
41
|
+
open("#{@base_dir}/#{file}", "w") do |f|
|
26
42
|
f.puts content
|
27
43
|
end
|
28
44
|
end
|
@@ -36,18 +52,109 @@ module MetricFu
|
|
36
52
|
html = ERB.new(File.read(template_file)).result(binding)
|
37
53
|
end
|
38
54
|
|
55
|
+
def template_name
|
56
|
+
self.class.template_name
|
57
|
+
end
|
58
|
+
|
39
59
|
def template_file
|
40
60
|
File.join(MetricFu::TEMPLATE_DIR, "#{template_name}.html.erb")
|
41
61
|
end
|
42
62
|
|
63
|
+
########################
|
64
|
+
# Template methods
|
65
|
+
|
66
|
+
def inline_css(css)
|
67
|
+
open(File.join(MetricFu::TEMPLATE_DIR, css)) { |f| f.read }
|
68
|
+
end
|
69
|
+
|
43
70
|
def link_to_filename(name, line = nil)
|
44
71
|
filename = File.expand_path(name)
|
45
72
|
if PLATFORM['darwin']
|
46
|
-
%{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}</a>}
|
73
|
+
%{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}:#{line}</a>}
|
47
74
|
else
|
48
|
-
%{<a href="file://#{filename}">#{name}</a>}
|
75
|
+
%{<a href="file://#{filename}">#{name}:#{line}</a>}
|
49
76
|
end
|
50
77
|
end
|
78
|
+
|
79
|
+
def cycle(first_value, second_value, iteration)
|
80
|
+
return first_value if iteration % 2 == 0
|
81
|
+
return second_value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class << self
|
87
|
+
# The Configuration instance used to configure the Rails environment
|
88
|
+
def configuration
|
89
|
+
@@configuration ||= Configuration.new
|
90
|
+
end
|
91
|
+
|
92
|
+
def churn
|
93
|
+
configuration.churn
|
94
|
+
end
|
95
|
+
|
96
|
+
def coverage
|
97
|
+
configuration.coverage
|
98
|
+
end
|
99
|
+
|
100
|
+
def flay
|
101
|
+
configuration.flay
|
102
|
+
end
|
103
|
+
|
104
|
+
def flog
|
105
|
+
configuration.flog
|
106
|
+
end
|
107
|
+
|
108
|
+
def metrics
|
109
|
+
configuration.metrics
|
110
|
+
end
|
111
|
+
|
112
|
+
def open_in_browser?
|
113
|
+
PLATFORM['darwin'] && !ENV['CC_BUILD_ARTIFACTS']
|
114
|
+
end
|
115
|
+
|
116
|
+
def saikuro
|
117
|
+
configuration.saikuro
|
118
|
+
end
|
119
|
+
|
120
|
+
def reek
|
121
|
+
configuration.reek
|
122
|
+
end
|
123
|
+
|
124
|
+
def roodi
|
125
|
+
configuration.roodi
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
class Configuration
|
131
|
+
attr_accessor :churn, :coverage, :flay, :flog, :metrics, :reek, :roodi, :saikuro
|
132
|
+
def initialize
|
133
|
+
raise "Use config.churn instead of MetricFu::CHURN_OPTIONS" if defined? ::MetricFu::CHURN_OPTIONS
|
134
|
+
raise "Use config.flog[:dirs_to_flog] instead of MetricFu::DIRECTORIES_TO_FLOG" if defined? ::MetricFu::DIRECTORIES_TO_FLOG
|
135
|
+
raise "Use config.saikuro instead of MetricFu::SAIKURO_OPTIONS" if defined? ::MetricFu::SAIKURO_OPTIONS
|
136
|
+
reset
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.run()
|
140
|
+
yield MetricFu.configuration
|
141
|
+
end
|
142
|
+
|
143
|
+
def reset
|
144
|
+
@churn = {}
|
145
|
+
@coverage = { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'],
|
146
|
+
:rcov_opts => ["--sort coverage", "--html", "--rails", "--exclude /gems/,/Library/,spec"] }
|
147
|
+
@flay = { :dirs_to_flay => CODE_DIRS}
|
148
|
+
@flog = { :dirs_to_flog => CODE_DIRS}
|
149
|
+
@reek = { :dirs_to_reek => CODE_DIRS}
|
150
|
+
@roodi = { :dirs_to_roodi => CODE_DIRS}
|
151
|
+
@metrics = DEFAULT_METRICS
|
152
|
+
@saikuro = {}
|
153
|
+
end
|
154
|
+
|
155
|
+
def saikuro=(options)
|
156
|
+
raise "saikuro need to be a Hash" unless options.is_a?(Hash)
|
157
|
+
@saikuro = options
|
51
158
|
end
|
52
159
|
end
|
53
|
-
end
|
160
|
+
end
|
data/lib/metric_fu/churn.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
module MetricFu
|
2
|
+
|
3
|
+
def self.generate_churn_report
|
4
|
+
Churn.generate_report(MetricFu.churn)
|
5
|
+
system("open #{Churn.metric_dir}/index.html") if open_in_browser?
|
6
|
+
end
|
7
|
+
|
2
8
|
class Churn < Base::Generator
|
3
9
|
|
4
|
-
def initialize(
|
5
|
-
@base_dir =
|
10
|
+
def initialize(options={})
|
11
|
+
@base_dir = File.join(MetricFu::BASE_DIRECTORY, template_name)
|
6
12
|
if File.exist?(".git")
|
7
13
|
@source_control = Git.new(options[:start_date])
|
8
14
|
elsif File.exist?(".svn")
|
@@ -18,11 +24,6 @@ module MetricFu
|
|
18
24
|
@changes = parse_log_for_changes.reject! {|file, change_count| change_count < @minimum_churn_count}
|
19
25
|
end
|
20
26
|
|
21
|
-
# should be dynamically read from the class
|
22
|
-
def template_name
|
23
|
-
'churn'
|
24
|
-
end
|
25
|
-
|
26
27
|
private
|
27
28
|
|
28
29
|
def parse_log_for_changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MetricFu
|
2
|
+
|
3
|
+
def self.generate_flay_report
|
4
|
+
Flay.generate_report
|
5
|
+
system("open #{Flay.metric_dir}/index.html") if open_in_browser?
|
6
|
+
end
|
7
|
+
|
8
|
+
class Flay < Base::Generator
|
9
|
+
|
10
|
+
def analyze
|
11
|
+
files_to_flay = MetricFu.flay[:dirs_to_flay].map{|dir| Dir[File.join(dir, "**/*.rb")] }
|
12
|
+
output = `flay #{files_to_flay.join(" ")}`
|
13
|
+
@matches = output.chomp.split("\n\n").map{|m| m.split("\n ") }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|