mwilden-metric_fu 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/HISTORY +136 -0
  2. data/MIT-LICENSE +22 -0
  3. data/Manifest.txt +25 -0
  4. data/README +1 -0
  5. data/Rakefile +18 -0
  6. data/TODO +13 -0
  7. data/lib/base/base_template.rb +146 -0
  8. data/lib/base/configuration.rb +207 -0
  9. data/lib/base/generator.rb +160 -0
  10. data/lib/base/graph.rb +37 -0
  11. data/lib/base/md5_tracker.rb +52 -0
  12. data/lib/base/report.rb +100 -0
  13. data/lib/generators/churn.rb +91 -0
  14. data/lib/generators/flay.rb +34 -0
  15. data/lib/generators/flog.rb +140 -0
  16. data/lib/generators/rcov.rb +87 -0
  17. data/lib/generators/reek.rb +37 -0
  18. data/lib/generators/roodi.rb +31 -0
  19. data/lib/generators/saikuro.rb +208 -0
  20. data/lib/generators/stats.rb +43 -0
  21. data/lib/graphs/flay_grapher.rb +34 -0
  22. data/lib/graphs/flog_grapher.rb +37 -0
  23. data/lib/graphs/rcov_grapher.rb +34 -0
  24. data/lib/graphs/reek_grapher.rb +44 -0
  25. data/lib/graphs/roodi_grapher.rb +34 -0
  26. data/lib/metric_fu.rb +24 -0
  27. data/lib/templates/awesome/awesome_template.rb +30 -0
  28. data/lib/templates/awesome/churn.html.erb +19 -0
  29. data/lib/templates/awesome/default.css +75 -0
  30. data/lib/templates/awesome/flay.html.erb +27 -0
  31. data/lib/templates/awesome/flog.html.erb +46 -0
  32. data/lib/templates/awesome/index.html.erb +28 -0
  33. data/lib/templates/awesome/layout.html.erb +27 -0
  34. data/lib/templates/awesome/rcov.html.erb +36 -0
  35. data/lib/templates/awesome/reek.html.erb +34 -0
  36. data/lib/templates/awesome/roodi.html.erb +21 -0
  37. data/lib/templates/awesome/saikuro.html.erb +71 -0
  38. data/lib/templates/awesome/stats.html.erb +41 -0
  39. data/lib/templates/standard/churn.html.erb +31 -0
  40. data/lib/templates/standard/default.css +64 -0
  41. data/lib/templates/standard/flay.html.erb +34 -0
  42. data/lib/templates/standard/flog.html.erb +53 -0
  43. data/lib/templates/standard/index.html.erb +38 -0
  44. data/lib/templates/standard/rcov.html.erb +43 -0
  45. data/lib/templates/standard/reek.html.erb +42 -0
  46. data/lib/templates/standard/roodi.html.erb +29 -0
  47. data/lib/templates/standard/saikuro.html.erb +84 -0
  48. data/lib/templates/standard/standard_template.rb +26 -0
  49. data/lib/templates/standard/stats.html.erb +55 -0
  50. data/spec/base/base_template_spec.rb +161 -0
  51. data/spec/base/configuration_spec.rb +303 -0
  52. data/spec/base/generator_spec.rb +181 -0
  53. data/spec/base/md5_tracker_spec.rb +57 -0
  54. data/spec/base/report_spec.rb +139 -0
  55. data/spec/generators/churn_spec.rb +152 -0
  56. data/spec/generators/flay_spec.rb +104 -0
  57. data/spec/generators/flog_spec.rb +219 -0
  58. data/spec/generators/reek_spec.rb +60 -0
  59. data/spec/generators/saikuro_spec.rb +58 -0
  60. data/spec/generators/stats_spec.rb +74 -0
  61. data/spec/graphs/flog_grapher_spec.rb +15 -0
  62. data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
  63. data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
  64. data/spec/resources/saikuro/index_cyclo.html +155 -0
  65. data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +11 -0
  66. data/spec/spec.opts +8 -0
  67. data/spec/spec_helper.rb +28 -0
  68. data/tasks/metric_fu.rake +22 -0
  69. data/vendor/_fonts/monaco.ttf +0 -0
  70. data/vendor/saikuro/saikuro.rb +1214 -0
  71. metadata +179 -0
@@ -0,0 +1,37 @@
1
+ module MetricFu
2
+
3
+ class Reek < Generator
4
+ REEK_REGEX = /^(\S+) (.*) \((.*)\)$/
5
+
6
+ def self.verify_dependencies!
7
+ `reek --help`
8
+ raise 'sudo gem install reek # if you want the reek tasks' unless $?.success?
9
+ end
10
+
11
+ def emit
12
+ files_to_reek = MetricFu.reek[:dirs_to_reek].map{|dir| Dir[File.join(dir, "**/*.rb")] }
13
+ @output = `reek #{files_to_reek.join(" ")}`
14
+ end
15
+
16
+ def analyze
17
+ @matches = @output.chomp.split("\n\n").map{|m| m.split("\n") }
18
+ @matches = @matches.map do |match|
19
+ file_path = match.shift.split('--').first
20
+ file_path = file_path.gsub('"', ' ').strip
21
+ code_smells = match.map do |smell|
22
+ match_object = smell.match(REEK_REGEX)
23
+ next unless match_object
24
+ {:method => match_object[1].strip,
25
+ :message => match_object[2].strip,
26
+ :type => match_object[3].strip}
27
+ end.compact
28
+ {:file_path => file_path, :code_smells => code_smells}
29
+ end
30
+ end
31
+
32
+ def to_h
33
+ {:reek => {:matches => @matches}}
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,31 @@
1
+ module MetricFu
2
+ class Roodi < Generator
3
+
4
+ def self.verify_dependencies!
5
+ `roodi --help`
6
+ raise 'sudo gem install roodi # if you want the roodi tasks' unless $?.success?
7
+ end
8
+
9
+
10
+ def emit
11
+ files_to_analyze = MetricFu.roodi[:dirs_to_roodi].map{|dir| Dir[File.join(dir, "**/*.rb")] }
12
+ @output = `roodi #{files_to_analyze.join(" ")}`
13
+ end
14
+
15
+ def analyze
16
+ @matches = @output.chomp.split("\n").map{|m| m.split(" - ") }
17
+ total = @matches.pop
18
+ @matches.reject! {|array| array.empty? }
19
+ @matches.map! do |match|
20
+ file, line = match[0].split(':')
21
+ problem = match[1]
22
+ {:file => file, :line => line, :problem => problem}
23
+ end
24
+ @roodi_results = {:total => total, :problems => @matches}
25
+ end
26
+
27
+ def to_h
28
+ {:roodi => @roodi_results}
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,208 @@
1
+ module MetricFu
2
+
3
+ class Saikuro < Generator
4
+
5
+ def emit
6
+ relative_path = [File.dirname(__FILE__), '..', '..',
7
+ 'vendor', 'saikuro', 'saikuro.rb']
8
+ saikuro = File.expand_path(File.join(relative_path))
9
+
10
+ MetricFu.saikuro[:input_directory] = format_directories
11
+
12
+ options_string = MetricFu.saikuro.inject("") do |options, option|
13
+ options + "--#{option.join(' ')} "
14
+ end
15
+
16
+ sh %{ruby "#{saikuro}" #{options_string}} do |ok, response|
17
+ unless ok
18
+ puts "Saikuro failed with exit status: #{response.exitstatus}"
19
+ exit 1
20
+ end
21
+ end
22
+ end
23
+
24
+ def format_directories
25
+ dirs = MetricFu.saikuro[:input_directory].join(" | ")
26
+ "\"#{dirs}\""
27
+ end
28
+
29
+ def analyze
30
+ @files = []
31
+ saikuro_results.each do |path|
32
+ if Saikuro::SFile.is_valid_text_file?(path)
33
+ file = Saikuro::SFile.new(path)
34
+ if file
35
+ @files << file
36
+ end
37
+ end
38
+ end
39
+ @files = @files.sort_by do |file|
40
+ file.elements.
41
+ max {|a,b| a.complexity.to_i <=> b.complexity.to_i}.
42
+ complexity.to_i
43
+ end
44
+ @files.reverse!
45
+ klasses = []
46
+ @files.each {|f| klasses << f.elements}
47
+ klasses.flatten!
48
+ @classes = klasses.sort_by {|k| k.complexity.to_i}
49
+ @classes.reverse!
50
+ meths = []
51
+ @files.each {|f|
52
+ f.elements.each {|el|
53
+ el.defs.each {|defn|
54
+ defn.name = "#{el.name}##{defn.name}"
55
+ meths << defn}
56
+ }
57
+ }
58
+ meths = meths.sort_by {|meth| meth.complexity.to_i}
59
+ @meths = meths.reverse
60
+ end
61
+
62
+ def to_h
63
+ files = @files.map do |file|
64
+ my_file = file.to_h
65
+ my_file[:filename] = file.filename
66
+ my_file
67
+ end
68
+ {:saikuro => {:files => files,
69
+ :classes => @classes.map {|c| c.to_h},
70
+ :methods => @meths.map {|m| m.to_h}
71
+ }
72
+ }
73
+ end
74
+
75
+ def saikuro_results
76
+ Dir.glob("#{metric_directory}/**/*.html")
77
+ end
78
+ end
79
+
80
+ class Saikuro::SFile
81
+
82
+ attr_reader :elements
83
+
84
+ def initialize(path)
85
+ @path = path
86
+ @file_handle = File.open(@path, "r")
87
+ @elements = []
88
+ get_elements
89
+ end
90
+
91
+ def self.is_valid_text_file?(path)
92
+ File.open(path, "r") do |f|
93
+ if f.eof? || !f.readline.match(/--/)
94
+ return false
95
+ else
96
+ return true
97
+ end
98
+ end
99
+ end
100
+
101
+ def filename
102
+ File.basename(@path, '_cyclo.html')
103
+ end
104
+
105
+ def to_h
106
+ merge_classes
107
+ {:classes => @elements}
108
+ end
109
+
110
+ def get_elements
111
+ begin
112
+ while (line = @file_handle.readline) do
113
+ return [] if line.nil? || line !~ /\S/
114
+ element ||= nil
115
+ if line.match /START/
116
+ unless element.nil?
117
+ @elements << element
118
+ element = nil
119
+ end
120
+ line = @file_handle.readline
121
+ element = Saikuro::ParsingElement.new(line)
122
+ elsif line.match /END/
123
+ @elements << element if element
124
+ element = nil
125
+ else
126
+ element << line if element
127
+ end
128
+ end
129
+ rescue EOFError
130
+ nil
131
+ end
132
+ end
133
+
134
+
135
+ def merge_classes
136
+ new_elements = []
137
+ get_class_names.each do |target_class|
138
+ elements = @elements.find_all {|el| el.name == target_class }
139
+ complexity = 0
140
+ lines = 0
141
+ defns = []
142
+ elements.each do |el|
143
+ complexity += el.complexity.to_i
144
+ lines += el.lines.to_i
145
+ defns << el.defs
146
+ end
147
+
148
+ new_element = {:class_name => target_class,
149
+ :complexity => complexity,
150
+ :lines => lines,
151
+ :methods => defns.flatten.map {|d| d.to_h}}
152
+ new_element[:methods] = new_element[:methods].
153
+ sort_by {|x| x[:complexity] }.
154
+ reverse
155
+
156
+ new_elements << new_element
157
+ end
158
+ @elements = new_elements if new_elements
159
+ end
160
+
161
+ def get_class_names
162
+ class_names = []
163
+ @elements.each do |element|
164
+ unless class_names.include?(element.name)
165
+ class_names << element.name
166
+ end
167
+ end
168
+ class_names
169
+ end
170
+
171
+ end
172
+
173
+ class Saikuro::ParsingElement
174
+ TYPE_REGEX=/Type:(.*) Name/
175
+ NAME_REGEX=/Name:(.*) Complexity/
176
+ COMPLEXITY_REGEX=/Complexity:(.*) Lines/
177
+ LINES_REGEX=/Lines:(.*)/
178
+
179
+ attr_reader :complexity, :lines, :defs, :element_type
180
+ attr_accessor :name
181
+
182
+ def initialize(line)
183
+ @line = line
184
+ @element_type = line.match(TYPE_REGEX)[1].strip
185
+ @name = line.match(NAME_REGEX)[1].strip
186
+ @complexity = line.match(COMPLEXITY_REGEX)[1].strip
187
+ @lines = line.match(LINES_REGEX)[1].strip
188
+ @defs = []
189
+ end
190
+
191
+ def <<(line)
192
+ @defs << Saikuro::ParsingElement.new(line)
193
+ end
194
+
195
+ def to_h
196
+ base = {:name => @name, :complexity => @complexity.to_i, :lines => @lines.to_i}
197
+ unless @defs.empty?
198
+ defs = @defs.map do |my_def|
199
+ my_def = my_def.to_h
200
+ my_def.delete(:defs)
201
+ my_def
202
+ end
203
+ base[:defs] = defs
204
+ end
205
+ return base
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,43 @@
1
+ module MetricFu
2
+
3
+ class Stats < Generator
4
+
5
+ def emit
6
+ `rake stats > #{metric_directory + '/stats.txt'}`
7
+ end
8
+
9
+ def analyze
10
+ output = File.open(metric_directory + '/stats.txt').read
11
+ output = output.split("\n")
12
+ output = output.find_all {|line| line[0].chr != "+" }
13
+ output = output.find_all {|line| line[0].chr != "(" }
14
+ output.shift
15
+ totals = output.pop
16
+ totals = totals.split(" ").find_all {|el| ! el.empty? }
17
+ @stats = {}
18
+ @stats[:codeLOC] = totals[0].match(/\d.*/)[0].to_i
19
+ @stats[:testLOC] = totals[1].match(/\d.*/)[0].to_i
20
+ @stats[:code_to_test_ratio] = totals[2].match(/1\:(\d.*)/)[1].to_f
21
+
22
+ @stats[:lines] = output.map do |line|
23
+ elements = line.split("|")
24
+ elements.map! {|el| el.strip }
25
+ elements = elements.find_all {|el| ! el.empty? }
26
+ info_line = {}
27
+ info_line[:name] = elements.shift
28
+ elements.map! {|el| el.to_i }
29
+ [:lines, :loc, :classes, :methods,
30
+ :methods_per_class, :loc_per_method].each do |sym|
31
+ info_line[sym] = elements.shift
32
+ end
33
+ info_line
34
+ end
35
+ @stats
36
+ end
37
+
38
+ def to_h
39
+ {:stats => @stats}
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ require 'gruff'
2
+ module MetricFu
3
+
4
+ class FlayGrapher
5
+
6
+ attr_accessor :flay_score, :labels
7
+
8
+ def initialize
9
+ self.flay_score = []
10
+ self.labels = {}
11
+ end
12
+
13
+ def get_metrics(metrics, date)
14
+ self.flay_score.push(metrics[:flay][:total_score].to_i)
15
+ self.labels.update( { self.labels.size => date })
16
+ end
17
+
18
+ def graph!
19
+ g = Gruff::Line.new(MetricFu.graph_size)
20
+ g.title = "Flay: duplication"
21
+ g.theme = MetricFu.graph_theme
22
+ g.font = MetricFu.graph_font
23
+ g.data('flay', self.flay_score)
24
+ g.labels = self.labels
25
+ g.title_font_size = MetricFu.graph_title_font_size
26
+ g.legend_box_size = MetricFu.graph_legend_box_size
27
+ g.legend_font_size = MetricFu.graph_legend_font_size
28
+ g.marker_font_size = MetricFu.graph_marker_font_size
29
+ g.write(File.join(MetricFu.output_directory, 'flay.png'))
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,37 @@
1
+ require 'gruff'
2
+ module MetricFu
3
+
4
+ class FlogGrapher
5
+
6
+ attr_accessor :flog_total, :flog_average, :labels
7
+
8
+ def initialize
9
+ self.flog_total = []
10
+ self.flog_average = []
11
+ self.labels = {}
12
+ end
13
+
14
+ def get_metrics(metrics, date)
15
+ self.flog_total.push(metrics[:flog][:total])
16
+ self.flog_average.push(metrics[:flog][:average])
17
+ self.labels.update( { self.labels.size => date })
18
+ end
19
+
20
+ def graph!
21
+ g = Gruff::Line.new(MetricFu.graph_size)
22
+ g.title = "Flog: code complexity"
23
+ g.theme = MetricFu.graph_theme
24
+ g.font = MetricFu.graph_font
25
+ g.data('flog total', self.flog_total)
26
+ g.data('flog average', self.flog_average)
27
+ g.labels = self.labels
28
+ g.title_font_size = MetricFu.graph_title_font_size
29
+ g.legend_box_size = MetricFu.graph_legend_box_size
30
+ g.legend_font_size = MetricFu.graph_legend_font_size
31
+ g.marker_font_size = MetricFu.graph_marker_font_size
32
+ g.write(File.join(MetricFu.output_directory, 'flog.png'))
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,34 @@
1
+ require 'gruff'
2
+ module MetricFu
3
+
4
+ class RcovGrapher
5
+
6
+ attr_accessor :rcov_percent, :labels
7
+
8
+ def initialize
9
+ self.rcov_percent = []
10
+ self.labels = {}
11
+ end
12
+
13
+ def get_metrics(metrics, date)
14
+ self.rcov_percent.push(metrics[:rcov][:global_percent_run])
15
+ self.labels.update( { self.labels.size => date })
16
+ end
17
+
18
+ def graph!
19
+ g = Gruff::Line.new(MetricFu.graph_size)
20
+ g.title = "Rcov: code coverage"
21
+ g.theme = MetricFu.graph_theme
22
+ g.font = MetricFu.graph_font
23
+ g.data('rcov', self.rcov_percent)
24
+ g.labels = self.labels
25
+ g.title_font_size = MetricFu.graph_title_font_size
26
+ g.legend_box_size = MetricFu.graph_legend_box_size
27
+ g.legend_font_size = MetricFu.graph_legend_font_size
28
+ g.marker_font_size = MetricFu.graph_marker_font_size
29
+ g.write(File.join(MetricFu.output_directory, 'rcov.png'))
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,44 @@
1
+ require 'gruff'
2
+ module MetricFu
3
+
4
+ class ReekGrapher
5
+
6
+ attr_accessor :reek_count, :labels
7
+
8
+ def initialize
9
+ self.reek_count = {}
10
+ self.labels= {}
11
+ end
12
+
13
+ def get_metrics(metrics, date)
14
+ counter = self.labels.size
15
+ self.labels.update( { counter => date })
16
+
17
+ metrics[:reek][:matches].each do |reek_chunk|
18
+ reek_chunk[:code_smells].each do |code_smell|
19
+ # speaking of code smell...
20
+ self.reek_count[code_smell[:type]] = [] if self.reek_count[code_smell[:type]].nil?
21
+ self.reek_count[code_smell[:type]][counter].nil? ? self.reek_count[code_smell[:type]][counter] = 1 : self.reek_count[code_smell[:type]][counter] += 1
22
+ end
23
+ end
24
+ end
25
+
26
+ def graph!
27
+ g = Gruff::Line.new(MetricFu.graph_size)
28
+ g.title = "Reek: code smells"
29
+ g.theme = MetricFu.graph_theme
30
+ g.font = MetricFu.graph_font
31
+ self.reek_count.each_pair do |type, count|
32
+ g.data(type, count)
33
+ end
34
+ g.labels = self.labels
35
+ g.title_font_size = MetricFu.graph_title_font_size
36
+ g.legend_box_size = MetricFu.graph_legend_box_size
37
+ g.legend_font_size = MetricFu.graph_legend_font_size
38
+ g.marker_font_size = MetricFu.graph_marker_font_size
39
+ g.write(File.join(MetricFu.output_directory, 'reek.png'))
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,34 @@
1
+ require 'gruff'
2
+ module MetricFu
3
+
4
+ class RoodiGrapher
5
+
6
+ attr_accessor :roodi_count, :labels
7
+
8
+ def initialize
9
+ self.roodi_count = []
10
+ self.labels = {}
11
+ end
12
+
13
+ def get_metrics(metrics, date)
14
+ self.roodi_count.push(metrics[:roodi][:problems].size)
15
+ self.labels.update( { self.labels.size => date })
16
+ end
17
+
18
+ def graph!
19
+ g = Gruff::Line.new(MetricFu.graph_size)
20
+ g.title = "Roodi: design problems"
21
+ g.theme = MetricFu.graph_theme
22
+ g.font = MetricFu.graph_font
23
+ g.data('roodi', self.roodi_count)
24
+ g.labels = self.labels
25
+ g.title_font_size = MetricFu.graph_title_font_size
26
+ g.legend_box_size = MetricFu.graph_legend_box_size
27
+ g.legend_font_size = MetricFu.graph_legend_font_size
28
+ g.marker_font_size = MetricFu.graph_marker_font_size
29
+ g.write(File.join(MetricFu.output_directory, 'roodi.png'))
30
+ end
31
+
32
+ end
33
+
34
+ end
data/lib/metric_fu.rb ADDED
@@ -0,0 +1,24 @@
1
+ # Load a few things to make our lives easier elsewhere.
2
+ module MetricFu
3
+ LIB_ROOT = File.dirname(__FILE__)
4
+ end
5
+ base_dir = File.join(MetricFu::LIB_ROOT, 'base')
6
+ generator_dir = File.join(MetricFu::LIB_ROOT, 'generators')
7
+ template_dir = File.join(MetricFu::LIB_ROOT, 'templates')
8
+ graph_dir = File.join(MetricFu::LIB_ROOT, 'graphs')
9
+
10
+ # We need to require these two things first because our other classes
11
+ # depend on them.
12
+ require File.join(base_dir, 'report')
13
+ require File.join(base_dir, 'generator')
14
+ require File.join(base_dir, 'graph')
15
+
16
+ # Load the rakefile so users of the gem get the default metric_fu task
17
+ load File.join(MetricFu::LIB_ROOT, '..', 'tasks', 'metric_fu.rake')
18
+
19
+ # Now load everything else that's in the directory
20
+ Dir[File.join(base_dir, '*.rb')].each{|l| require l }
21
+ Dir[File.join(generator_dir, '*.rb')].each {|l| require l }
22
+ Dir[File.join(template_dir, 'standard/*.rb')].each {|l| require l}
23
+ Dir[File.join(template_dir, 'awesome/*.rb')].each {|l| require l}
24
+ Dir[File.join(graph_dir, '*.rb')].each {|l| require l}
@@ -0,0 +1,30 @@
1
+ class AwesomeTemplate < MetricFu::Template
2
+
3
+ def write
4
+ # Getting rid of the crap before and after the project name from integrity
5
+ @name = File.basename(Dir.pwd).gsub(/^\w+-|-\w+$/, "")
6
+
7
+ report.each_pair do |section, contents|
8
+ if template_exists?(section)
9
+ create_instance_var(section, contents)
10
+ @html = erbify(section)
11
+ html = erbify('layout')
12
+ fn = output_filename(section)
13
+ MetricFu.report.save_output(html, MetricFu.output_directory, fn)
14
+ end
15
+ end
16
+
17
+ # Instance variables we need should already be created from above
18
+ if template_exists?('index')
19
+ @html = erbify('index')
20
+ html = erbify('layout')
21
+ fn = output_filename('index')
22
+ MetricFu.report.save_output(html, MetricFu.output_directory, fn)
23
+ end
24
+ end
25
+
26
+ def this_directory
27
+ File.dirname(__FILE__)
28
+ end
29
+ end
30
+
@@ -0,0 +1,19 @@
1
+ <h3>Source Control Churn Results</h3>
2
+ <p>Files that change a lot in your project may be bad a sign.
3
+ This task uses your source control log to identify those files.
4
+ </p>
5
+ <table>
6
+ <tr>
7
+ <th>File Path</th>
8
+ <th>Times Changed</th>
9
+ </tr>
10
+ <% count = 0 %>
11
+ <% @churn[:changes].each do |change| %>
12
+ <tr>
13
+ <td><%= link_to_filename(change[:file_path]) %></td>
14
+ <td><%= change[:times_changed] %></td>
15
+ </tr>
16
+ <% count += 1 %>
17
+ <% end %>
18
+ </table>
19
+ <p>Generated on <%= Time.now.localtime %></p>
@@ -0,0 +1,75 @@
1
+ table {
2
+ margin-top: 20px;
3
+ border-collapse: collapse;
4
+ border: 1px solid #666;
5
+ background: #fff;
6
+ margin-bottom: 20px;
7
+ }
8
+
9
+ table tr.light {
10
+ background: #fff;
11
+ }
12
+
13
+ table tr.dark {
14
+ background: #f9f9f9;
15
+ }
16
+
17
+ table tr:hover {
18
+ background: #FFFFC0;
19
+ }
20
+
21
+ table td, table th {
22
+ padding: 4px;
23
+ font-size: 11px;
24
+ }
25
+ table th {
26
+ text-align: center;
27
+ color: #337022;
28
+ background: #DDFFCC;
29
+ font-weight: bold;
30
+ border: #99D688 1px solid;
31
+ }
32
+
33
+ table td {
34
+ border: #d0d0d0 1px solid;
35
+ }
36
+
37
+ table td.score {
38
+ text-align: right;
39
+ }
40
+
41
+ .warning {
42
+ background: yellow;
43
+ }
44
+ .rcov_code td {
45
+ border-bottom: 1px solid #ddd ;
46
+ padding: 0;
47
+ margin: 0;
48
+ }
49
+ .rcov_code tr {
50
+ border: 0px;
51
+ padding:0px;
52
+ margin: 0px;
53
+ }
54
+ .rcov_code pre {
55
+ border: 0px;
56
+ padding: 0px;
57
+ margin: 0px;
58
+ }
59
+ .rcov_run {}
60
+ .rcov_not_run {
61
+ background-color: #d88;
62
+ }
63
+ .rcov_run a, .rcov_not_run a {
64
+ text-decoration: none;
65
+ }
66
+ .rcov_run a {
67
+ color: #333;
68
+ }
69
+ .rcov_not_run a {
70
+ color: #000;
71
+ }
72
+ .rcov_overflow {
73
+ overflow: auto;
74
+ font-size: 50%;
75
+ }
@@ -0,0 +1,27 @@
1
+ <h3>Flay Results</h3>
2
+
3
+ <p><a href='http://ruby.sadi.st/Flay.html'>Flay</a> analyzes ruby code for structural similarities.</p>
4
+
5
+ <img src="flay.png?<%= Time.now %>">
6
+
7
+ <h4>Total Score (lower is better): <%= @flay[:total_score] %></h4>
8
+
9
+ <table>
10
+ <tr>
11
+ <th>Files</th>
12
+ <th>Matches</th>
13
+ </tr>
14
+ <% count = 0 %>
15
+ <% @flay[:matches].each do |match| %>
16
+ <tr class='<%= cycle("light", "dark", count) %>'>
17
+ <td>
18
+ <% match[:matches].each do |file| %>
19
+ <%= link_to_filename(file[:name], file[:line]) %><br/>
20
+ <% end %>
21
+ </td>
22
+ <td><%= match[:reason] %></td>
23
+ </tr>
24
+ <% count += 1 %>
25
+ <% end %>
26
+ </table>
27
+ <p>Generated on <%= Time.now.localtime %></p>