p8-metric_fu 0.8.0.16 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/README +17 -63
  2. data/Rakefile +1 -1
  3. data/lib/metric_fu/base.rb +8 -114
  4. data/lib/metric_fu/churn.rb +7 -8
  5. data/lib/metric_fu/flay_reporter.rb +17 -0
  6. data/lib/metric_fu/flog_reporter/base.rb +49 -0
  7. data/lib/metric_fu/flog_reporter/generator.rb +39 -0
  8. data/lib/metric_fu/flog_reporter/operator.rb +10 -0
  9. data/lib/metric_fu/flog_reporter/page.rb +33 -0
  10. data/lib/metric_fu/flog_reporter/scanned_method.rb +28 -0
  11. data/lib/metric_fu/flog_reporter.rb +5 -0
  12. data/lib/tasks/churn.rake +3 -1
  13. data/lib/tasks/coverage.rake +35 -49
  14. data/lib/tasks/flay.rake +4 -1
  15. data/lib/tasks/flog.rake +10 -10
  16. data/lib/tasks/metric_fu.rake +4 -8
  17. data/lib/tasks/metric_fu.rb +1 -1
  18. data/lib/tasks/saikuro.rake +1 -1
  19. data/lib/tasks/stats.rake +1 -1
  20. data/lib/templates/churn.css +38 -0
  21. data/lib/templates/churn.html.erb +3 -6
  22. data/lib/templates/flay.css +38 -0
  23. data/lib/templates/flay.html.erb +10 -17
  24. data/lib/templates/flog.css +39 -0
  25. data/lib/templates/flog.html.erb +14 -19
  26. data/lib/templates/flog_page.html.erb +3 -15
  27. data/spec/base_spec.rb +8 -30
  28. data/spec/churn_spec.rb +3 -10
  29. data/spec/{flay_spec.rb → flay_reporter_spec.rb} +2 -9
  30. data/spec/flog_reporter/base_spec.rb +69 -0
  31. data/spec/md5_tracker_spec.rb +3 -1
  32. data/spec/spec_helper.rb +3 -7
  33. metadata +17 -41
  34. data/Manifest.txt +0 -25
  35. data/lib/metric_fu/flay.rb +0 -17
  36. data/lib/metric_fu/flog.rb +0 -139
  37. data/lib/metric_fu/reek.rb +0 -17
  38. data/lib/metric_fu/roodi.rb +0 -17
  39. data/lib/tasks/railroad.rake +0 -36
  40. data/lib/tasks/reek.rake +0 -6
  41. data/lib/tasks/roodi.rake +0 -7
  42. data/lib/templates/default.css +0 -45
  43. data/lib/templates/reek.html.erb +0 -30
  44. data/lib/templates/roodi.html.erb +0 -26
  45. data/spec/config_spec.rb +0 -110
  46. data/spec/flog_spec.rb +0 -147
  47. data/spec/reek_spec.rb +0 -26
@@ -2,30 +2,25 @@
2
2
  <head>
3
3
  <title>Flog Reporter</title>
4
4
  <style>
5
- <%= inline_css("default.css") %>
5
+ <%= open(File.join(MetricFu::TEMPLATE_DIR, "#{template_name}.css")) { |f| f.read } %>
6
6
  </style>
7
7
  </head>
8
8
  <body>
9
- <h1>Flog Results</h1>
10
- <p><a href='http://ruby.sadi.st/Flog.html'>Flog</a> measures code complexity.</p>
11
- <table>
12
- <tr>
13
- <th>File</th>
14
- <th>Total score</th>
15
- <th>Methods</th>
16
- <th>Average score</th>
17
- <th>Highest score</th>
9
+ <h1>Flogged files</h1>
10
+ <p>Generated on <%= Time.now.localtime %> with <a href='http://ruby.sadi.st/Flog.html'>flog</a></p>
11
+ <table class='report'>
12
+ <tr><th>File</th><th>Total score</th><th>Methods</th><th>Average score</th><th>Highest score</th></tr>
13
+ <% count = 0 %>
14
+ <% flog_hashes.sort {|x,y| y[:page].highest_score <=> x[:page].highest_score }.each do |flog_hash| %>
15
+ <tr class='<%= Base.cycle("light", "dark", count) %>'>
16
+ <td><a href='<%= flog_hash[:path]%>'><%= flog_hash[:path].sub('.html', '.rb') %></a></td>
17
+ <td class='score'><%= sprintf(SCORE_FORMAT, flog_hash[:page].score) %></td>
18
+ <td class='score'><%= flog_hash[:page].scanned_methods.length %></td>
19
+ <td class='score'><%= sprintf(SCORE_FORMAT, flog_hash[:page].average_score) %></td>
20
+ <td class='score'><%= sprintf(SCORE_FORMAT, flog_hash[:page].highest_score) %></td>
18
21
  </tr>
19
- <% pages.sort {|x,y| y.highest_score <=> x.highest_score }.each_with_index do |page, count| %>
20
- <tr class='<%= cycle("light", "dark", count) %>'>
21
- <td><a href='<%= page.path %>'><%= page.path.sub('.html', '.rb') %></a></td>
22
- <td class='score'><%= sprintf(SCORE_FORMAT, page.score) %></td>
23
- <td class='score'><%= page.scanned_methods.length %></td>
24
- <td class='score'><%= sprintf(SCORE_FORMAT, page.average_score) %></td>
25
- <td class='score'><%= sprintf(SCORE_FORMAT, page.highest_score) %></td>
26
- </tr>
22
+ <% count += 1 %>
27
23
  <% end %>
28
24
  </table>
29
- <p>Generated on <%= Time.now.localtime %></p>
30
25
  </body>
31
26
  </html>
@@ -1,25 +1,13 @@
1
1
  <html>
2
2
  <head>
3
3
  <style>
4
- <%= inline_css("default.css") %>
4
+ <%= open(File.join(MetricFu::TEMPLATE_DIR, "flog.css")) { |f| f.read } %>
5
5
  </style>
6
6
  </head>
7
7
  <body>
8
8
  <p>Score: <%= score %></p>
9
9
  <% scanned_methods.each do |sm| %>
10
- <p><strong><%= sm.name %> (<%= sm.score %>)</strong></p>
11
- <table>
12
- <tr>
13
- <th>Score</th>
14
- <th>Operator</th>
15
- </tr>
16
- <% sm.operators.each_with_index do |operator, count| %>
17
- <tr class='<%= cycle("light", "dark", count) %>'>
18
- <td class='score'><%= sprintf(SCORE_FORMAT, operator.score) %></td>
19
- <td class='score'><%= operator.operator %></td>
20
- </tr>
21
- <% end %>
22
- </table>
23
- <% end %>
10
+ <%= sm.to_html %>
11
+ <% end %>
24
12
  </body>
25
13
  </html>
data/spec/base_spec.rb CHANGED
@@ -3,15 +3,15 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  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
- @generator = MetricFu::Base::Generator.new
7
- @generator.should_receive(:open).with("tmp/metric_fu/generator/index.html", "w")
6
+ @generator = MetricFu::Base::Generator.new('base_dir')
7
+ @generator.should_receive(:open).with("base_dir/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
- @generator = MetricFu::Base::Generator.new
13
- @generator.should_receive(:open).with("tmp/metric_fu/generator/metric_fu/custom.html", "w")
14
- @generator.save_html("<html>", 'metric_fu/custom.html')
12
+ @generator = MetricFu::Base::Generator.new('base_dir')
13
+ @generator.should_receive(:open).with("base_dir/metric_fu/custom.html", "w")
14
+ @generator.save_html("<html>", 'metric_fu/custom')
15
15
  end
16
16
  end
17
17
 
@@ -24,34 +24,12 @@ describe MetricFu::Base::Generator do
24
24
  end
25
25
  end
26
26
 
27
- describe "generate_html" do
27
+ describe "generate_report" do
28
28
  it "should create a new Generator and call generate_report on it" do
29
- @generator = MetricFu::Base::Generator.new
30
- @generator.should_receive(:open).with("tmp/metric_fu/generator/index.html", "w")
29
+ @generator = MetricFu::Base::Generator.new('other_dir')
30
+ @generator.should_receive(:open).with("other_dir/index.html", "w")
31
31
  @generator.should_receive(:generate_html).and_return('<html>')
32
32
  @generator.generate_report
33
33
  end
34
34
  end
35
-
36
- describe "cycle" do
37
- it "should create a new Generator and call generate_report on it" do
38
- @generator = MetricFu::Base::Generator.new
39
- @generator.cycle("light", "dark", 0).should == 'light'
40
- @generator.cycle("light", "dark", 1).should == 'dark'
41
- end
42
- end
43
-
44
- describe "template_name" do
45
- it "should return the class name in lowercase" do
46
- @generator = MetricFu::Base::Generator.new
47
- @generator.template_name.should == 'generator'
48
- end
49
- end
50
-
51
- describe "metric_dir" do
52
- it "should return tmp/metric_fu/{the class name in lowercase}" do
53
- MetricFu::Base::Generator.metric_dir.should == 'tmp/metric_fu/generator'
54
- end
55
- end
56
-
57
35
  end
data/spec/churn_spec.rb CHANGED
@@ -11,7 +11,7 @@ describe MetricFu::Churn do
11
11
  git_mock = mock('git')
12
12
  git_mock.should_receive(:get_logs).and_return(logs)
13
13
  Churn::Git.should_receive(:new).and_return(git_mock)
14
- churn = Churn.new(:scm => :git, :minimum_churn_count => 3)
14
+ churn = Churn.new('base_dir', :scm => :git, :minimum_churn_count => 3)
15
15
  churn.analyze
16
16
  churn.instance_variable_get(:@changes).should == {"accept"=>3}
17
17
  end
@@ -22,13 +22,6 @@ describe MetricFu::Churn do
22
22
  end
23
23
 
24
24
  end
25
-
26
- describe "template_name" do
27
- it "should return the class name in lowercase" do
28
- churn = Churn.new
29
- churn.template_name.should == 'churn'
30
- end
31
- end
32
25
 
33
26
  describe "parse_log_for_changes" do
34
27
  it "should count the changes with git" do
@@ -37,7 +30,7 @@ describe MetricFu::Churn do
37
30
  git_mock.should_receive(:get_logs).and_return(logs)
38
31
  Churn::Git.should_receive(:new).and_return(git_mock)
39
32
  File.should_receive(:exist?).with(".git").and_return(true)
40
- changes = Churn.new.send(:parse_log_for_changes)
33
+ changes = Churn.new('base_dir').send(:parse_log_for_changes)
41
34
  changes["home_page/index.html"].should == 1
42
35
  changes["History.txt"].should == 2
43
36
  changes["README"].should == 3
@@ -50,7 +43,7 @@ describe MetricFu::Churn do
50
43
  Churn::Svn.should_receive(:new).and_return(svn_mock)
51
44
  File.should_receive(:exist?).with(".git").and_return(false)
52
45
  File.should_receive(:exist?).with(".svn").and_return(true)
53
- changes = Churn.new.send(:parse_log_for_changes)
46
+ changes = Churn.new('base_dir').send(:parse_log_for_changes)
54
47
  changes["home_page/index.html"].should == 1
55
48
  changes["History.txt"].should == 2
56
49
  changes["README"].should == 3
@@ -1,19 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe MetricFu::Flay do
3
+ describe MetricFu::FlayReporter do
4
4
 
5
5
  describe "generate_html" do
6
6
  it "should create a new Generator and call generate_report on it" do
7
- @generator = MetricFu::Flay.new('other_dir')
7
+ @generator = MetricFu::FlayReporter.new('other_dir')
8
8
  @generator.should_receive(:`).and_return("Matches found in :call (mass = 55)\n\tlib/metric_fu/flog_reporter.rb:2\n\tlib/metric_fu/flog_reporter.rb:3")
9
9
  @generator.generate_html
10
10
  end
11
11
  end
12
-
13
- describe "template_name" do
14
- it "should return the class name in lowercase" do
15
- flay = MetricFu::Flay.new('base_dir')
16
- flay.template_name.should == 'flay'
17
- end
18
- end
19
12
  end
@@ -0,0 +1,69 @@
1
+ require 'spec'
2
+ require File.dirname(__FILE__) + '/../../lib/metric_fu/flog_reporter'
3
+ include MetricFu::FlogReporter
4
+
5
+ describe "FlogReporter::Base" do
6
+ before do
7
+ @alpha_only_method = <<-AOM
8
+ Total flog = 13.6283678106927
9
+
10
+ ErrorMailer#errormail: (12.5)
11
+ 12.0: assignment
12
+ 1.2: []
13
+ 1.2: now
14
+ 1.2: content_type
15
+ AOM
16
+
17
+ @method_that_has_digits = <<-MTHD
18
+ Total flog = 7.08378429936994
19
+
20
+ NoImmunizationReason#to_c32: (7.1)
21
+ 3.0: code
22
+ 2.3: branch
23
+ 1.4: templateId
24
+ 1.2: act
25
+ 1.1: entryRelationship
26
+ MTHD
27
+
28
+ @bang_method = <<-BM
29
+ Total flog = 7.08378429936994
30
+
31
+ NoImmunizationReason#to_c32!: (7.1)
32
+ 3.0: code
33
+ 2.3: branch
34
+ 1.4: templateId
35
+ 1.2: act
36
+ 1.1: entryRelationship
37
+ BM
38
+ end
39
+
40
+ it "should be able to parse an alpha only method" do
41
+ page = Base.parse(@alpha_only_method)
42
+ page.should_not be_nil
43
+ page.score.should == 13.6283678106927
44
+ page.scanned_methods.size.should == 1
45
+ sm = page.scanned_methods.first
46
+ sm.name.should == 'ErrorMailer#errormail'
47
+ sm.score.should == 12.5
48
+ end
49
+
50
+ it "should be able to parse method that has digits" do
51
+ page = Base.parse(@method_that_has_digits)
52
+ page.should_not be_nil
53
+ page.score.should == 7.08378429936994
54
+ page.scanned_methods.size.should == 1
55
+ sm = page.scanned_methods.first
56
+ sm.name.should == 'NoImmunizationReason#to_c32'
57
+ sm.score.should == 7.1
58
+ end
59
+
60
+ it "should be able to parse bang method" do
61
+ page = Base.parse(@bang_method)
62
+ page.should_not be_nil
63
+ page.score.should == 7.08378429936994
64
+ page.scanned_methods.size.should == 1
65
+ sm = page.scanned_methods.first
66
+ sm.name.should == 'NoImmunizationReason#to_c32!'
67
+ sm.score.should == 7.1
68
+ end
69
+ end
@@ -1,4 +1,6 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
1
+ require 'spec'
2
+ require File.join(File.dirname(__FILE__), '../lib/metric_fu/md5_tracker')
3
+ include MetricFu
2
4
 
3
5
  describe MetricFu::MD5Tracker do
4
6
  before do
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,7 @@
1
- require 'rubygems'
2
1
  require 'spec'
3
2
  require 'date'
4
3
 
5
- require File.join(File.dirname(__FILE__), '/../lib/metric_fu/base')
6
- require File.join(File.dirname(__FILE__), '/../lib/metric_fu/flay')
7
- require File.join(File.dirname(__FILE__), '/../lib/metric_fu/flog')
8
- require File.join(File.dirname(__FILE__), '/../lib/metric_fu/md5_tracker')
9
- require File.join(File.dirname(__FILE__), '/../lib/metric_fu/churn')
10
- require File.join(File.dirname(__FILE__), '/../lib/metric_fu/reek')
4
+ require File.dirname(__FILE__) + '/../lib/metric_fu/base'
5
+ require File.dirname(__FILE__) + '/../lib/metric_fu/flay_reporter'
6
+ require File.dirname(__FILE__) + '/../lib/metric_fu/churn'
11
7
  include MetricFu
metadata CHANGED
@@ -1,29 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p8-metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.16
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Scruggs
8
8
  - Sean Soper
9
9
  - Andre Arko
10
- - Petrik de Heus
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
13
 
15
- date: 2009-01-11 00:00:00 -08:00
14
+ date: 2008-10-27 00:00:00 -07:00
16
15
  default_executable:
17
16
  dependencies:
18
- - !ruby/object:Gem::Dependency
19
- name: flay
20
- version_requirement:
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ">"
24
- - !ruby/object:Gem::Version
25
- version: 0.0.0
26
- version:
27
17
  - !ruby/object:Gem::Dependency
28
18
  name: flog
29
19
  version_requirement:
@@ -36,23 +26,14 @@ dependencies:
36
26
  - !ruby/object:Gem::Dependency
37
27
  name: rcov
38
28
  version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">"
42
- - !ruby/object:Gem::Version
43
- version: 0.8.1
44
- version:
45
- - !ruby/object:Gem::Dependency
46
- name: railroad
47
- version_requirement:
48
29
  version_requirements: !ruby/object:Gem::Requirement
49
30
  requirements:
50
31
  - - ">="
51
32
  - !ruby/object:Gem::Version
52
- version: 0.5.0
33
+ version: 0.8.1
53
34
  version:
54
35
  - !ruby/object:Gem::Dependency
55
- name: reek
36
+ name: flay
56
37
  version_requirement:
57
38
  version_requirements: !ruby/object:Gem::Requirement
58
39
  requirements:
@@ -61,7 +42,7 @@ dependencies:
61
42
  version: 0.0.0
62
43
  version:
63
44
  - !ruby/object:Gem::Dependency
64
- name: roodi
45
+ name: diff-lcs
65
46
  version_requirement:
66
47
  version_requirements: !ruby/object:Gem::Requirement
67
48
  requirements:
@@ -77,7 +58,6 @@ extensions: []
77
58
 
78
59
  extra_rdoc_files:
79
60
  - HISTORY
80
- - Manifest.txt
81
61
  - README
82
62
  files:
83
63
  - README
@@ -87,10 +67,13 @@ files:
87
67
  - Rakefile
88
68
  - lib/metric_fu/base.rb
89
69
  - lib/metric_fu/churn.rb
90
- - lib/metric_fu/flay.rb
91
- - lib/metric_fu/flog.rb
92
- - lib/metric_fu/reek.rb
93
- - lib/metric_fu/roodi.rb
70
+ - lib/metric_fu/flay_reporter.rb
71
+ - lib/metric_fu/flog_reporter/base.rb
72
+ - lib/metric_fu/flog_reporter/generator.rb
73
+ - lib/metric_fu/flog_reporter/operator.rb
74
+ - lib/metric_fu/flog_reporter/page.rb
75
+ - lib/metric_fu/flog_reporter/scanned_method.rb
76
+ - lib/metric_fu/flog_reporter.rb
94
77
  - lib/metric_fu/md5_tracker.rb
95
78
  - lib/metric_fu/saikuro/saikuro.rb
96
79
  - lib/metric_fu.rb
@@ -100,19 +83,15 @@ files:
100
83
  - lib/tasks/flay.rake
101
84
  - lib/tasks/flog.rake
102
85
  - lib/tasks/metric_fu.rake
103
- - lib/tasks/railroad.rake
104
- - lib/tasks/reek.rake
105
- - lib/tasks/roodi.rake
106
86
  - lib/tasks/saikuro.rake
107
87
  - lib/tasks/stats.rake
88
+ - lib/templates/churn.css
108
89
  - lib/templates/churn.html.erb
109
- - lib/templates/default.css
90
+ - lib/templates/flay.css
110
91
  - lib/templates/flay.html.erb
92
+ - lib/templates/flog.css
111
93
  - lib/templates/flog.html.erb
112
94
  - lib/templates/flog_page.html.erb
113
- - lib/templates/reek.html.erb
114
- - lib/templates/roodi.html.erb
115
- - Manifest.txt
116
95
  has_rdoc: true
117
96
  homepage: http://metric-fu.rubyforge.org/
118
97
  post_install_message:
@@ -143,10 +122,7 @@ summary: A fistful of code metrics
143
122
  test_files:
144
123
  - spec/base_spec.rb
145
124
  - spec/churn_spec.rb
146
- - spec/config_spec.rb
147
- - spec/flay_spec.rb
148
- - spec/flog_spec.rb
125
+ - spec/flay_reporter_spec.rb
126
+ - spec/flog_reporter/base_spec.rb
149
127
  - spec/md5_tracker_spec.rb
150
- - spec/reek_spec.rb
151
- - spec/roodi_spec.rb
152
128
  - spec/spec_helper.rb
data/Manifest.txt DELETED
@@ -1,25 +0,0 @@
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
@@ -1,17 +0,0 @@
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