danmayer-metric_fu 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/HISTORY +237 -0
  2. data/MIT-LICENSE +22 -0
  3. data/README +29 -0
  4. data/Rakefile +18 -0
  5. data/TODO +6 -0
  6. data/lib/base/base_template.rb +172 -0
  7. data/lib/base/churn_analyzer.rb +38 -0
  8. data/lib/base/code_issue.rb +97 -0
  9. data/lib/base/configuration.rb +199 -0
  10. data/lib/base/flay_analyzer.rb +50 -0
  11. data/lib/base/flog_analyzer.rb +43 -0
  12. data/lib/base/generator.rb +166 -0
  13. data/lib/base/graph.rb +44 -0
  14. data/lib/base/line_numbers.rb +74 -0
  15. data/lib/base/location.rb +85 -0
  16. data/lib/base/md5_tracker.rb +52 -0
  17. data/lib/base/metric_analyzer.rb +404 -0
  18. data/lib/base/ranking.rb +34 -0
  19. data/lib/base/rcov_analyzer.rb +43 -0
  20. data/lib/base/reek_analyzer.rb +163 -0
  21. data/lib/base/report.rb +108 -0
  22. data/lib/base/roodi_analyzer.rb +37 -0
  23. data/lib/base/saikuro_analyzer.rb +48 -0
  24. data/lib/base/scoring_strategies.rb +29 -0
  25. data/lib/base/stats_analyzer.rb +37 -0
  26. data/lib/base/table.rb +102 -0
  27. data/lib/generators/churn.rb +28 -0
  28. data/lib/generators/flay.rb +31 -0
  29. data/lib/generators/flog.rb +111 -0
  30. data/lib/generators/hotspots.rb +52 -0
  31. data/lib/generators/rails_best_practices.rb +53 -0
  32. data/lib/generators/rcov.rb +122 -0
  33. data/lib/generators/reek.rb +81 -0
  34. data/lib/generators/roodi.rb +35 -0
  35. data/lib/generators/saikuro.rb +256 -0
  36. data/lib/generators/stats.rb +58 -0
  37. data/lib/graphs/engines/bluff.rb +113 -0
  38. data/lib/graphs/engines/gchart.rb +157 -0
  39. data/lib/graphs/flay_grapher.rb +18 -0
  40. data/lib/graphs/flog_grapher.rb +57 -0
  41. data/lib/graphs/grapher.rb +11 -0
  42. data/lib/graphs/rails_best_practices_grapher.rb +19 -0
  43. data/lib/graphs/rcov_grapher.rb +18 -0
  44. data/lib/graphs/reek_grapher.rb +30 -0
  45. data/lib/graphs/roodi_grapher.rb +18 -0
  46. data/lib/graphs/stats_grapher.rb +20 -0
  47. data/lib/metric_fu.rb +40 -0
  48. data/lib/templates/awesome/awesome_template.rb +73 -0
  49. data/lib/templates/awesome/churn.html.erb +58 -0
  50. data/lib/templates/awesome/css/buttons.css +82 -0
  51. data/lib/templates/awesome/css/default.css +91 -0
  52. data/lib/templates/awesome/css/integrity.css +334 -0
  53. data/lib/templates/awesome/css/reset.css +7 -0
  54. data/lib/templates/awesome/css/syntax.css +19 -0
  55. data/lib/templates/awesome/flay.html.erb +34 -0
  56. data/lib/templates/awesome/flog.html.erb +55 -0
  57. data/lib/templates/awesome/hotspots.html.erb +62 -0
  58. data/lib/templates/awesome/index.html.erb +34 -0
  59. data/lib/templates/awesome/layout.html.erb +30 -0
  60. data/lib/templates/awesome/rails_best_practices.html.erb +27 -0
  61. data/lib/templates/awesome/rcov.html.erb +42 -0
  62. data/lib/templates/awesome/reek.html.erb +40 -0
  63. data/lib/templates/awesome/roodi.html.erb +27 -0
  64. data/lib/templates/awesome/saikuro.html.erb +71 -0
  65. data/lib/templates/awesome/stats.html.erb +51 -0
  66. data/lib/templates/javascripts/bluff-min.js +1 -0
  67. data/lib/templates/javascripts/excanvas.js +35 -0
  68. data/lib/templates/javascripts/js-class.js +1 -0
  69. data/lib/templates/standard/churn.html.erb +31 -0
  70. data/lib/templates/standard/default.css +64 -0
  71. data/lib/templates/standard/flay.html.erb +34 -0
  72. data/lib/templates/standard/flog.html.erb +57 -0
  73. data/lib/templates/standard/hotspots.html.erb +54 -0
  74. data/lib/templates/standard/index.html.erb +41 -0
  75. data/lib/templates/standard/rails_best_practices.html.erb +29 -0
  76. data/lib/templates/standard/rcov.html.erb +43 -0
  77. data/lib/templates/standard/reek.html.erb +42 -0
  78. data/lib/templates/standard/roodi.html.erb +29 -0
  79. data/lib/templates/standard/saikuro.html.erb +84 -0
  80. data/lib/templates/standard/standard_template.rb +26 -0
  81. data/lib/templates/standard/stats.html.erb +55 -0
  82. data/spec/base/base_template_spec.rb +177 -0
  83. data/spec/base/configuration_spec.rb +276 -0
  84. data/spec/base/generator_spec.rb +223 -0
  85. data/spec/base/graph_spec.rb +61 -0
  86. data/spec/base/line_numbers_spec.rb +62 -0
  87. data/spec/base/md5_tracker_spec.rb +57 -0
  88. data/spec/base/report_spec.rb +146 -0
  89. data/spec/generators/churn_spec.rb +41 -0
  90. data/spec/generators/flay_spec.rb +105 -0
  91. data/spec/generators/flog_spec.rb +70 -0
  92. data/spec/generators/rails_best_practices_spec.rb +52 -0
  93. data/spec/generators/rcov_spec.rb +180 -0
  94. data/spec/generators/reek_spec.rb +134 -0
  95. data/spec/generators/roodi_spec.rb +24 -0
  96. data/spec/generators/saikuro_spec.rb +74 -0
  97. data/spec/generators/stats_spec.rb +74 -0
  98. data/spec/graphs/engines/bluff_spec.rb +19 -0
  99. data/spec/graphs/engines/gchart_spec.rb +156 -0
  100. data/spec/graphs/flay_grapher_spec.rb +56 -0
  101. data/spec/graphs/flog_grapher_spec.rb +108 -0
  102. data/spec/graphs/rails_best_practices_grapher_spec.rb +61 -0
  103. data/spec/graphs/rcov_grapher_spec.rb +56 -0
  104. data/spec/graphs/reek_grapher_spec.rb +65 -0
  105. data/spec/graphs/roodi_grapher_spec.rb +56 -0
  106. data/spec/graphs/stats_grapher_spec.rb +68 -0
  107. data/spec/resources/line_numbers/foo.rb +33 -0
  108. data/spec/resources/line_numbers/module.rb +11 -0
  109. data/spec/resources/line_numbers/module_surrounds_class.rb +15 -0
  110. data/spec/resources/line_numbers/two_classes.rb +11 -0
  111. data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
  112. data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
  113. data/spec/resources/saikuro/index_cyclo.html +155 -0
  114. data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +11 -0
  115. data/spec/resources/yml/20090630.yml +7922 -0
  116. data/spec/resources/yml/metric_missing.yml +1 -0
  117. data/spec/spec.opts +6 -0
  118. data/spec/spec_helper.rb +7 -0
  119. data/tasks/metric_fu.rake +22 -0
  120. metadata +462 -0
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Churn do
4
+
5
+ describe "analyze method" do
6
+ before :each do
7
+ MetricFu::Configuration.run {}
8
+ File.stub!(:directory?).and_return(true)
9
+ @changes = {"lib/generators/flog.rb"=>2, "lib/metric_fu.rb"=>3}
10
+ end
11
+
12
+ it "should be empty on error" do
13
+ churn = MetricFu::Churn.new
14
+ churn.instance_variable_set(:@output, "Churning requires a subversion or git repo")
15
+ result = churn.analyze
16
+ result.should == [:churn => {}]
17
+ end
18
+
19
+ it "should return yaml results" do
20
+ churn = MetricFu::Churn.new
21
+ churn.instance_variable_set(:@output, "--- \n:churn: \n :changed_files: \n - spec/graphs/flog_grapher_spec.rb\n - spec/base/graph_spec.rb\n - lib/templates/awesome/layout.html.erb\n - lib/graphs/rcov_grapher.rb\n - lib/base/base_template.rb\n - spec/graphs/grapher_spec.rb\n - lib/templates/awesome/flog.html.erb\n - lib/templates/awesome/flay.html.erb\n - lib/graphs/roodi_grapher.rb\n - lib/graphs/reek_grapher.rb\n - HISTORY\n - spec/graphs/roodi_grapher_spec.rb\n - lib/generators/rcov.rb\n - spec/graphs/engines/gchart_spec.rb\n - spec/graphs/rcov_grapher_spec.rb\n - lib/templates/javascripts/excanvas.js\n - lib/templates/javascripts/bluff-min.js\n - spec/graphs/reek_grapher_spec.rb\n")
22
+ result = churn.analyze
23
+ result.should == {:churn=>{:changed_files=>["spec/graphs/flog_grapher_spec.rb", "spec/base/graph_spec.rb", "lib/templates/awesome/layout.html.erb", "lib/graphs/rcov_grapher.rb", "lib/base/base_template.rb", "spec/graphs/grapher_spec.rb", "lib/templates/awesome/flog.html.erb", "lib/templates/awesome/flay.html.erb", "lib/graphs/roodi_grapher.rb", "lib/graphs/reek_grapher.rb", "HISTORY", "spec/graphs/roodi_grapher_spec.rb", "lib/generators/rcov.rb", "spec/graphs/engines/gchart_spec.rb", "spec/graphs/rcov_grapher_spec.rb", "lib/templates/javascripts/excanvas.js", "lib/templates/javascripts/bluff-min.js", "spec/graphs/reek_grapher_spec.rb"]}}
24
+ end
25
+
26
+ end
27
+
28
+ describe "to_h method" do
29
+ before :each do
30
+ MetricFu::Configuration.run {}
31
+ File.stub!(:directory?).and_return(true)
32
+ end
33
+
34
+ it "should put the changes into a hash" do
35
+ churn = MetricFu::Churn.new
36
+ churn.instance_variable_set(:@churn, {:churn => 'results'})
37
+ churn.to_h[:churn].should == "results"
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,105 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Flay do
4
+ describe "emit method" do
5
+ it "should look at the dirs" do
6
+ MetricFu::Configuration.run {|config| config.flay = { :dirs_to_flay => ['app', 'lib'], :filetypes => ['rb'] } }
7
+ File.stub!(:directory?).and_return(true)
8
+ @flay = MetricFu::Flay.new('base_dir')
9
+
10
+ @flay.should_receive(:`).with("flay app lib")
11
+ output = @flay.emit
12
+ end
13
+
14
+ it "should limit flay scores by the minimum_score" do
15
+ MetricFu::Configuration.run {|config| config.flay = { :dirs_to_flay => [], :minimum_score => 99 } }
16
+ File.stub!(:directory?).and_return(true)
17
+ @flay = MetricFu::Flay.new('base_dir')
18
+
19
+ @flay.should_receive(:`).with("flay --mass 99 ")
20
+ output = @flay.emit
21
+ end
22
+ end
23
+
24
+ describe "analyze method" do
25
+ before :each do
26
+ lines = <<-HERE
27
+ Total score (lower is better) = 246
28
+
29
+
30
+ 1) IDENTICAL code found in :or (mass*2 = 68)
31
+ app/controllers/link_targets_controller.rb:57
32
+ app/controllers/primary_sites_controller.rb:138
33
+
34
+ 2) Similar code found in :if (mass = 64)
35
+ app/controllers/primary_sites_controller.rb:75
36
+ app/controllers/primary_sites_controller.rb:76
37
+ app/controllers/primary_sites_controller.rb:88
38
+ app/controllers/primary_sites_controller.rb:89
39
+ HERE
40
+ MetricFu::Configuration.run {}
41
+ File.stub!(:directory?).and_return(true)
42
+ @flay = MetricFu::Flay.new('base_dir')
43
+ @flay.instance_variable_set(:@output, lines)
44
+ end
45
+
46
+ it "should analyze and return matches" do
47
+ @flay.analyze.should == [ ["Total score (lower is better) = 246"],
48
+ ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
49
+ "app/controllers/link_targets_controller.rb:57",
50
+ "app/controllers/primary_sites_controller.rb:138"],
51
+ ["2) Similar code found in :if (mass = 64)",
52
+ "app/controllers/primary_sites_controller.rb:75",
53
+ "app/controllers/primary_sites_controller.rb:76",
54
+ "app/controllers/primary_sites_controller.rb:88",
55
+ "app/controllers/primary_sites_controller.rb:89"] ]
56
+ end
57
+ end
58
+
59
+ describe "to_h method" do
60
+
61
+ before :each do
62
+ lines = [ ["Total score (lower is better) = 284"],
63
+ ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
64
+ "app/controllers/link_targets_controller.rb:57",
65
+ "app/controllers/primary_sites_controller.rb:138"],
66
+ ["2) Similar code found in :if (mass = 64)",
67
+ "app/controllers/primary_sites_controller.rb:75",
68
+ "app/controllers/primary_sites_controller.rb:76",
69
+ "app/controllers/primary_sites_controller.rb:88",
70
+ "app/controllers/primary_sites_controller.rb:89"],
71
+ ["3) Similar code found in :defn (mass = 40)",
72
+ "app/controllers/link_targets_controller.rb:40",
73
+ "app/controllers/primary_sites_controller.rb:98"],
74
+ ["4) Similar code found in :defn (mass = 38)",
75
+ "app/controllers/link_targets_controller.rb:13",
76
+ "app/controllers/primary_sites_controller.rb:50"],
77
+ ["5) Similar code found in :defn (mass = 38)",
78
+ "app/models/primary_site.rb:104",
79
+ "app/models/primary_site.rb:109"],
80
+ ["6) Similar code found in :call (mass = 36)",
81
+ "app/controllers/bookmarklet_integration_controller.rb:6",
82
+ "app/controllers/bookmarklet_integration_controller.rb:17"]]
83
+
84
+ MetricFu::Configuration.run {}
85
+ File.stub!(:directory?).and_return(true)
86
+ flay = MetricFu::Flay.new('base_dir')
87
+ flay.instance_variable_set(:@matches, lines)
88
+ @results = flay.to_h
89
+ end
90
+
91
+ it "should find the total_score" do
92
+ @results[:flay][:total_score].should == '284'
93
+ end
94
+
95
+ it "should have 6 matches" do
96
+ @results[:flay][:matches].size.should == 6
97
+ end
98
+
99
+ it "should capture info for match" do
100
+ @results[:flay][:matches].first[:reason].should =~ /IDENTICAL/
101
+ @results[:flay][:matches].first[:matches].first[:name].should =~ /link_targets_controller/
102
+ @results[:flay][:matches].first[:matches].first[:line].should == "57"
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,70 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ describe Flog do
3
+ before :each do
4
+ MetricFu::Configuration.run {}
5
+ File.stub!(:directory?).and_return(true)
6
+ @flog = MetricFu::Flog.new('base_dir')
7
+ end
8
+
9
+ describe "emit method" do
10
+ it "should look for files and flog them" do
11
+ Dir.should_receive(:glob).with("lib/**/*.rb").and_return(["found/file.rb"])
12
+ ::Flog.should_receive(:parse_options).with(["--all", "--details"]).and_return("options")
13
+ ::Flog.should_receive(:new).with("options").and_return(flogger = mock('flogger'))
14
+ flogger.should_receive(:flog).with(["found/file.rb"])
15
+ @flog.emit
16
+ end
17
+ end
18
+
19
+ describe "analyze method" do
20
+ it "should harvest the flog information and put it into method_containers" do
21
+ first_full_method_name = "ClassName#first_method_name"
22
+ second_full_method_name = "ClassName#second_method_name"
23
+
24
+ flogger = mock('flogger', :calls => {first_full_method_name => {:branch => 11.1, :puts => 1.1},
25
+ second_full_method_name => {:branch => 22.2, :puts => 2.2}},
26
+ :method_locations => {first_full_method_name => '/file/location.rb:11',
27
+ second_full_method_name => '/file/location.rb:22'},
28
+ :totals => {first_full_method_name => 11.11,
29
+ second_full_method_name => 22.22})
30
+ @flog.instance_variable_set(:@flogger, flogger)
31
+ @flog.analyze
32
+ method_containers = @flog.instance_variable_get(:@method_containers)
33
+ method_containers.size.should == 1
34
+
35
+ expected={:methods=>{"ClassName#first_method_name" => { :path=>"/file/location.rb:11",
36
+ :score=>11.11,
37
+ :operators=>{ :branch=>11.1,
38
+ :puts=>1.1}},
39
+ "ClassName#second_method_name" => {:path=>"/file/location.rb:22",
40
+ :score=>22.22,
41
+ :operators=>{ :branch=>22.2,
42
+ :puts=>2.2}}},
43
+ :path=>"/file/location.rb",
44
+ :average_score=>((11.11 + 22.22) / 2.0),
45
+ :total_score=>33.33,
46
+ :highest_score=>22.22,
47
+ :name=>"ClassName"}
48
+
49
+ method_containers["ClassName"].to_h.should == expected
50
+ end
51
+ end
52
+
53
+ describe "to_h method" do
54
+ it "should make-a nice hash" do
55
+ flogger = mock('flogger', :total => 111.1, :average => 7.3)
56
+ @flog.instance_variable_set(:@flogger, flogger)
57
+ method_containers = {:ignore_me_1 => mock('container_1', :highest_score => 11.1, :to_h => 'container_1'),
58
+ :ignore_me_2 => mock('container_2', :highest_score => 33.3, :to_h => 'container_2'),
59
+ :ignore_me_3 => mock('container_3', :highest_score => 22.2, :to_h => 'container_3')}
60
+ @flog.instance_variable_set(:@method_containers, method_containers)
61
+
62
+ expected = {:flog => { :total => 111.1,
63
+ :average => 7.3,
64
+ :method_containers => ['container_2', 'container_3', 'container_1']}}
65
+
66
+ @flog.to_h.should == expected
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe RailsBestPractices do
4
+ describe "emit method" do
5
+ it "should gather the raw data" do
6
+ MetricFu::Configuration.run {}
7
+ practices = MetricFu::RailsBestPractices.new
8
+ practices.should_receive(:`).with("rails_best_practices --without-color .")
9
+ practices.emit
10
+ end
11
+ end
12
+
13
+ describe "analyze method" do
14
+ before :each do
15
+ output = <<-HERE.gsub(/^[^\S\n]*/, "")
16
+ ./app/views/admin/testimonials/_form.html.erb:17 - replace instance variable with local variable
17
+ ./app/controllers/admin/campaigns_controller.rb:24,45,68,85 - use before_filter for show,edit,update,destroy
18
+
19
+ go to http://wiki.github.com/flyerhzm/rails_best_practices to see how to solve these errors.
20
+
21
+ Found 2 errors.
22
+ HERE
23
+ MetricFu::Configuration.run {}
24
+ practices = MetricFu::RailsBestPractices.new
25
+ practices.instance_variable_set(:@output, output)
26
+ @results = practices.analyze
27
+ end
28
+
29
+ it "should get the total" do
30
+ @results[:total].should == ["Found 2 errors."]
31
+ end
32
+
33
+ it "should get the problems" do
34
+ @results[:problems].size.should == 2
35
+ @results[:problems].first.should == { :line => "17",
36
+ :problem => "replace instance variable with local variable",
37
+ :file => "app/views/admin/testimonials/_form.html.erb" }
38
+ @results[:problems][1].should == { :line => "24,45,68,85",
39
+ :problem => "use before_filter for show,edit,update,destroy",
40
+ :file => "app/controllers/admin/campaigns_controller.rb" }
41
+ end
42
+ end
43
+
44
+ describe "to_h method" do
45
+ it "should put things into a hash" do
46
+ MetricFu::Configuration.run {}
47
+ practices = MetricFu::RailsBestPractices.new
48
+ practices.instance_variable_set(:@rails_best_practices_results, "the_practices")
49
+ practices.to_h[:rails_best_practices].should == "the_practices"
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,180 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe MetricFu::Rcov do
4
+
5
+ before :each do
6
+ MetricFu::Configuration.run {}
7
+ File.stub!(:directory?).and_return(true)
8
+ @rcov = MetricFu::Rcov.new('base_dir')
9
+ end
10
+
11
+ describe "emit" do
12
+ before :each do
13
+ @rcov.stub!(:puts)
14
+ MetricFu.rcov[:external] = nil
15
+ end
16
+
17
+ it "should clear out previous output and make output folder" do
18
+ @rcov.stub!(:`)
19
+ FileUtils.should_receive(:rm_rf).with(MetricFu::Rcov.metric_directory, :verbose => false)
20
+ Dir.should_receive(:mkdir).with(MetricFu::Rcov.metric_directory)
21
+ @rcov.emit
22
+ end
23
+
24
+ it "should set the RAILS_ENV" do
25
+ FileUtils.stub!(:rm_rf)
26
+ Dir.stub!(:mkdir)
27
+ MetricFu.rcov[:environment] = "metrics"
28
+ @rcov.should_receive(:`).with(/RAILS_ENV=metrics/)
29
+ @rcov.emit
30
+ end
31
+ end
32
+
33
+ describe "with RCOV_OUTPUT fed into" do
34
+ before :each do
35
+ MetricFu.rcov[:external] = nil
36
+ File.should_receive(:open).
37
+ with(MetricFu::Rcov.metric_directory + '/rcov.txt').
38
+ and_return(mock("io", :read => RCOV_OUTPUT))
39
+ @files = @rcov.analyze
40
+ end
41
+
42
+ describe "analyze" do
43
+ it "should compute percent of lines run" do
44
+ @files["lib/templates/awesome/awesome_template.rb"][:percent_run].should == 13
45
+ @files["lib/templates/standard/standard_template.rb"][:percent_run].should == 14
46
+ end
47
+
48
+ it "should know which lines were run" do
49
+ @files["lib/templates/awesome/awesome_template.rb"][:lines].
50
+ should include({:content=>"require 'fileutils'", :was_run=>true})
51
+ end
52
+
53
+ it "should know which lines NOT were run" do
54
+ @files["lib/templates/awesome/awesome_template.rb"][:lines].
55
+ should include({:content=>" if template_exists?(section)", :was_run=>false})
56
+ end
57
+ end
58
+
59
+ describe "to_h" do
60
+ it "should calculate total percentage for all files" do
61
+ @rcov.to_h[:rcov][:global_percent_run].should == 13.7
62
+ end
63
+ end
64
+ end
65
+ describe "with external configuration option set" do
66
+ before :each do
67
+ @rcov.stub!(:puts)
68
+ MetricFu.rcov[:external] = "coverage/rcov.txt"
69
+ end
70
+
71
+ it "should emit nothing if external configuration option is set" do
72
+ FileUtils.should_not_receive(:rm_rf)
73
+ @rcov.emit
74
+ end
75
+
76
+ it "should open the external rcov analysis file" do
77
+ File.should_receive(:open).
78
+ with(MetricFu.rcov[:external]).
79
+ and_return(mock("io", :read => RCOV_OUTPUT))
80
+ @files = @rcov.analyze
81
+ end
82
+
83
+ end
84
+
85
+
86
+ RCOV_OUTPUT = <<-HERE
87
+ Profiling enabled.
88
+ .............................................................................................................................................................................................
89
+
90
+
91
+ Top 10 slowest examples:
92
+ 0.2707830 MetricFu::RoodiGrapher responding to #get_metrics should push 13 to roodi_count
93
+ 0.1994550 MetricFu::RcovGrapher responding to #get_metrics should update labels with the date
94
+ 0.1985800 MetricFu::ReekGrapher responding to #get_metrics should set a hash of code smells to reek_count
95
+ 0.1919860 MetricFu::ReekGrapher responding to #get_metrics should update labels with the date
96
+ 0.1907400 MetricFu::RoodiGrapher responding to #get_metrics should update labels with the date
97
+ 0.1883000 MetricFu::FlogGrapher responding to #get_metrics should update labels with the date
98
+ 0.1882650 MetricFu::FlayGrapher responding to #get_metrics should push 476 to flay_score
99
+ 0.1868780 MetricFu::FlogGrapher responding to #get_metrics should push to top_five_percent_average
100
+ 0.1847730 MetricFu::FlogGrapher responding to #get_metrics should push 9.9 to flog_average
101
+ 0.1844090 MetricFu::FlayGrapher responding to #get_metrics should update labels with the date
102
+
103
+ Finished in 2.517686 seconds
104
+
105
+ 189 examples, 0 failures
106
+ ================================================================================
107
+ lib/templates/awesome/awesome_template.rb
108
+ ================================================================================
109
+ require 'fileutils'
110
+
111
+ class AwesomeTemplate < MetricFu::Template
112
+
113
+ def write
114
+ !! # Getting rid of the crap before and after the project name from integrity
115
+ !! @name = File.basename(Dir.pwd).gsub(/^\w+-|-\w+$/, "")
116
+ !!
117
+ !! # Copy Bluff javascripts to output directory
118
+ !! Dir[File.join(this_directory, '..', 'javascripts', '*')].each do |f|
119
+ !! FileUtils.copy(f, File.join(MetricFu.output_directory, File.basename(f)))
120
+ !! end
121
+ !!
122
+ !! report.each_pair do |section, contents|
123
+ !! if template_exists?(section)
124
+ !! create_instance_var(section, contents)
125
+ !! @html = erbify(section)
126
+ !! html = erbify('layout')
127
+ !! fn = output_filename(section)
128
+ !! MetricFu.report.save_output(html, MetricFu.output_directory, fn)
129
+ !! end
130
+ !! end
131
+ !!
132
+ !! # Instance variables we need should already be created from above
133
+ !! if template_exists?('index')
134
+ !! @html = erbify('index')
135
+ !! html = erbify('layout')
136
+ !! fn = output_filename('index')
137
+ !! MetricFu.report.save_output(html, MetricFu.output_directory, fn)
138
+ !! end
139
+ !! end
140
+
141
+ def this_directory
142
+ !! File.dirname(__FILE__)
143
+ !! end
144
+ !! end
145
+
146
+ ================================================================================
147
+ lib/templates/standard/standard_template.rb
148
+ ================================================================================
149
+ class StandardTemplate < MetricFu::Template
150
+
151
+
152
+ def write
153
+ !! report.each_pair do |section, contents|
154
+ !! if template_exists?(section)
155
+ !! create_instance_var(section, contents)
156
+ !! html = erbify(section)
157
+ !! fn = output_filename(section)
158
+ !! MetricFu.report.save_output(html, MetricFu.output_directory, fn)
159
+ !! end
160
+ !! end
161
+ !!
162
+ !! # Instance variables we need should already be created from above
163
+ !! if template_exists?('index')
164
+ !! html = erbify('index')
165
+ !! fn = output_filename('index')
166
+ !! MetricFu.report.save_output(html, MetricFu.output_directory, fn)
167
+ !! end
168
+ !! end
169
+
170
+ def this_directory
171
+ !! File.dirname(__FILE__)
172
+ !! end
173
+ !! end
174
+
175
+ HERE
176
+
177
+ end
178
+
179
+
180
+