continuous4r 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/History.txt +1 -1
  2. data/Manifest.txt +34 -34
  3. data/PostInstall.txt +3 -0
  4. data/README.rdoc +58 -0
  5. data/Rakefile +28 -3
  6. data/lib/changelog_builder.rb +51 -0
  7. data/lib/continuous4r.rb +63 -426
  8. data/lib/dcov_builder.rb +144 -0
  9. data/lib/flay_builder.rb +38 -0
  10. data/lib/flog_builder.rb +120 -0
  11. data/lib/git_extractor.rb +48 -0
  12. data/lib/rcov_builder.rb +23 -0
  13. data/lib/rdoc_builder.rb +33 -0
  14. data/lib/reek_builder.rb +38 -0
  15. data/lib/roodi_builder.rb +41 -0
  16. data/lib/saikuro_builder.rb +20 -0
  17. data/lib/site/body-changelog.rhtml +1 -1
  18. data/lib/site/body-continuous4r-reports.rhtml +40 -47
  19. data/lib/site/body-dcov.rhtml +1 -21
  20. data/lib/site/body-flay.rhtml +16 -0
  21. data/lib/site/body-flog.rhtml +2 -10
  22. data/lib/site/body-rcov.rhtml +2 -3
  23. data/lib/site/body-rdoc.rhtml +1 -1
  24. data/lib/site/body-reek.rhtml +16 -0
  25. data/lib/site/body-roodi.rhtml +16 -0
  26. data/lib/site/body-saikuro.rhtml +32 -0
  27. data/lib/site/body-scm-usage.rhtml +13 -12
  28. data/lib/site/body-stats.rhtml +1 -1
  29. data/lib/site/body-tests.rhtml +1 -1
  30. data/lib/site/body-xdoclet.rhtml +29 -0
  31. data/lib/site/body-zentest.rhtml +1 -1
  32. data/lib/site/flog.html.erb +33 -0
  33. data/lib/site/flog_page.html.erb +74 -0
  34. data/lib/site/header.rhtml +36 -20
  35. data/lib/site/images/added.png +0 -0
  36. data/lib/site/images/deleted.png +0 -0
  37. data/lib/site/images/modified.png +0 -0
  38. data/lib/site/menu-continuous4r-reports.rhtml +4 -14
  39. data/lib/site/{menu-dcov.rhtml → menu-task.rhtml} +3 -5
  40. data/lib/site/style/maven-base.css +3 -0
  41. data/lib/site/syntax_highlighting.css +30 -0
  42. data/lib/stats_builder.rb +18 -0
  43. data/lib/subversion_extractor.rb +29 -19
  44. data/lib/tasks/continuous4r-project.xml +26 -0
  45. data/lib/tasks/continuous4r.rake +23 -0
  46. data/lib/tasks/continuous4r.rb +6 -0
  47. data/lib/tests_builder.rb +21 -0
  48. data/lib/tests_formatter.rb +13 -46
  49. data/lib/utils.rb +47 -0
  50. data/lib/xdoclet_builder.rb +48 -0
  51. data/lib/zen_test_formatter.rb +58 -28
  52. data/lib/zentest_builder.rb +19 -0
  53. data/script/console +10 -0
  54. data/script/console.cmd +1 -0
  55. data/script/destroy +1 -1
  56. data/script/generate +1 -1
  57. data/test/test_continuous4r.rb +1 -1
  58. data/test/test_helper.rb +1 -0
  59. data/website/index.html +141 -363
  60. data/website/index.txt +169 -228
  61. data/website/template.rhtml +2 -2
  62. metadata +66 -46
  63. data/License.txt +0 -20
  64. data/README.txt +0 -1
  65. data/config/hoe.rb +0 -71
  66. data/config/requirements.rb +0 -17
  67. data/lib/capistrano_formatter.rb +0 -19
  68. data/lib/continuous4r/version.rb +0 -9
  69. data/lib/flog_formatter.rb +0 -48
  70. data/lib/heckle_formatter.rb +0 -27
  71. data/lib/httperf_formatter.rb +0 -160
  72. data/lib/site/body-capistrano.rhtml +0 -8
  73. data/lib/site/body-heckle.rhtml +0 -16
  74. data/lib/site/body-httperf.rhtml +0 -8
  75. data/lib/site/body-kwala.rhtml +0 -35
  76. data/lib/site/body-railroad.rhtml +0 -29
  77. data/lib/site/menu-capistrano.rhtml +0 -23
  78. data/lib/site/menu-changelog.rhtml +0 -23
  79. data/lib/site/menu-flog.rhtml +0 -23
  80. data/lib/site/menu-heckle.rhtml +0 -23
  81. data/lib/site/menu-httperf.rhtml +0 -23
  82. data/lib/site/menu-kwala.rhtml +0 -23
  83. data/lib/site/menu-railroad.rhtml +0 -23
  84. data/lib/site/menu-rcov.rhtml +0 -23
  85. data/lib/site/menu-rdoc.rhtml +0 -23
  86. data/lib/site/menu-stats.rhtml +0 -23
  87. data/lib/site/menu-tests.rhtml +0 -23
  88. data/lib/site/menu-zentest.rhtml +0 -23
  89. data/log/debug.log +0 -0
  90. data/script/txt2html +0 -74
  91. data/script/txt2html.cmd +0 -1
  92. data/setup.rb +0 -1585
  93. data/tasks/deployment.rake +0 -34
  94. data/tasks/environment.rake +0 -7
  95. data/tasks/website.rake +0 -17
@@ -0,0 +1,144 @@
1
+ require 'dcov'
2
+
3
+ # ==========================================================================
4
+ # Surcharge du module Dcov pour l'adapter aux besoins de continous4r
5
+ # author: Vincent Dubois
6
+ # date: 10 fevrier 2009
7
+ # ==========================================================================
8
+ module Dcov
9
+ # Generates HTML output
10
+ class Generator # < Ruport::Formatter::HTML
11
+ # renders :html, :for => StatsRenderer
12
+
13
+ include Dcov::StatsRenderer::Helpers
14
+
15
+ attr_reader :data
16
+ def initialize(data)
17
+ @data = data
18
+ end
19
+
20
+ def to_s
21
+ build_stats_header + build_stats_body + build_stats_footer
22
+ end
23
+
24
+ def build_stats_header
25
+ # Little CSS, a little HTML...
26
+ output = ""
27
+ output << """<h2>Dcov results</h2>\n\n<p><a href='http://dcov.rubyforge.org' target='_blank'>Dcov</a> is a documentation coverage analyzer for ruby.</p>"""
28
+ end
29
+
30
+ def build_stats_body
31
+ output = ""
32
+ output << "<h3>Summary</h3><p>\n"
33
+ output << "<table class='bodyTable' style='width: 200px;'><tr><th>Type</th><th>Coverage</th></tr>"
34
+ output << "<tr class='a'><td><b>Class</b></td><td style='text-align: right;'>#{class_coverage}%</td></tr>\n"
35
+ output << "<tr class='b'><td><b>Module</b></td><td style='text-align: right;'>#{module_coverage}%</td></tr>\n"
36
+ output << "<tr class='a'><td><b>Method</b></td><td style='text-align: right;'>#{method_coverage}%</td></tr></table>\n"
37
+ output << "</p>\n\n"
38
+
39
+ if data[:structured].length > 0
40
+ output << "<h3>Details</h3><p><table class='bodyTable'><tr><th>Class/Module name</th><th>Method name</th></tr>\n"
41
+ end
42
+ indice = 0
43
+ nbtr = 0
44
+ data[:structured].each do |key,value|
45
+ class_error_presence = (value[0].comment.nil? or value[0].comment == '') unless value[0].is_a?(Dcov::TopLevel)
46
+ method_error_presence = false
47
+ count_method_error_presence = 0
48
+ value[1].each do |itm|
49
+ method_error_presence = true if (itm.comment.nil? or itm.comment == '')
50
+ count_method_error_presence += 1 if (itm.comment.nil? or itm.comment == '')
51
+ end
52
+ if class_error_presence == true or method_error_presence == true
53
+ nbtr += 1
54
+ output << "<tr class='#{indice % 2 == 0 ? 'a' : 'b'}'>"
55
+ if class_error_presence == true or method_error_presence == true
56
+ output << "<td>#{"<b>" if class_error_presence == true}#{key.is_a?(String) ? key : key.full_name }#{"</b> in <a href='xdoclet/#{value[0].in_files.first.file_absolute_name.gsub(/\//,'_')}.html' target='_blank'>#{value[0].in_files.first.file_absolute_name}</a>" if class_error_presence == true}</td>"
57
+ else
58
+ output << "<td>&#160;</td>"
59
+ end
60
+ if count_method_error_presence == 1
61
+ value[1].each do |itm|
62
+ output << ((itm.comment.nil? || itm.comment == '') ? "<td><ol><li><b>#{itm.name}</b> in <a href='xdoclet/#{itm.token_stream.first.text.sub(/^# File /, '').sub(/, line (\d+)$/, '').gsub(/\//,'_')}.html##{itm.token_stream.first.text.sub(/^# File /, '').sub(/, line (\d+)$/, ':\1').split(/:/)[1]}' target='_blank'>#{itm.token_stream.first.text.sub(/^# File /, '').sub(/, line (\d+)$/, ':\1')}</a></b></li></ol></td>" : "")
63
+ end
64
+ elsif count_method_error_presence > 1
65
+ output << "<td><ol>"
66
+ value[1].each do |itm|
67
+ output << ((itm.comment.nil? || itm.comment == '') ? "<li><b>#{itm.name}</b> in <a href='xdoclet/#{itm.token_stream.first.text.sub(/^# File /, '').sub(/, line (\d+)$/, '').gsub(/\//,'_')}.html##{itm.token_stream.first.text.sub(/^# File /, '').sub(/, line (\d+)$/, ':\1').split(/:/)[1]}' target='_blank'>#{itm.token_stream.first.text.sub(/^# File /, '').sub(/, line (\d+)$/, ':\1')}</a></b></li>" : "")
68
+ end
69
+ output << "</ol></td>"
70
+ else
71
+ output << "<td>&#160;</td>"
72
+ end
73
+ if class_error_presence == true or method_error_presence == true
74
+ indice += 1
75
+ output << "</tr>"
76
+ end
77
+ end
78
+ end
79
+ if nbtr == 0
80
+ output << "<tr class='a'><td colspan='2'>There is no undocumented Ruby code.</td></tr>"
81
+ end
82
+ output << "</table>"
83
+ output
84
+ end
85
+
86
+ def build_stats_footer
87
+ output = ""
88
+ output << "</ol>\n\n</body></html>"
89
+ end
90
+
91
+ end
92
+
93
+ class Analyzer
94
+ def generate
95
+ print "Generating dcov report..."
96
+
97
+ generator = Dcov::Generator.new @stats.renderable_data
98
+ report = generator.to_s
99
+ print "done.\n"
100
+
101
+ print "Writing report..."
102
+ FileUtils.mkdir("#{Continuous4r::WORK_DIR}/dcov")
103
+ if (!File.exists?("#{Continuous4r::WORK_DIR}/dcov/coverage.html")) || (File.writable?("#{Continuous4r::WORK_DIR}/dcov/coverage.html"))
104
+ output_file = File.open("#{Continuous4r::WORK_DIR}/dcov/coverage.html", "w")
105
+ output_file.write report
106
+ output_file.close
107
+ print "done.\n"
108
+ else
109
+ raise "Can't write to [#{Continuous4r::WORK_DIR}/dcov/coverage.html]."
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+ # ==========================================================================
116
+ # Construction de la tache dcov (couverture rdoc)
117
+ # author: Vincent Dubois
118
+ # date: 06 fevrier 2009
119
+ # ==========================================================================
120
+ class DcovBuilder
121
+ include Utils
122
+
123
+ # Implementation de la construction de la tache
124
+ def build(project_name, auto_install, proxy_option)
125
+ # On verifie la presence de dcov
126
+ Utils.verify_gem_presence("dcov", auto_install, proxy_option)
127
+ # On lance la generation
128
+ puts " Building dcov rdoc coverage report..."
129
+ files = Array.new
130
+ files << Dir.glob("app/**/*.rb")
131
+ files << Dir.glob("lib/**/*.rb")
132
+ files.flatten!
133
+ options = {
134
+ :path => RAILS_ROOT,
135
+ :output_format => 'html',
136
+ :files => files
137
+ }
138
+ Dcov::Analyzer.new(options)
139
+ if !File.exist?("#{Continuous4r::WORK_DIR}/dcov/coverage.html")
140
+ raise " Execution of dcov failed.\n BUILD FAILED."
141
+ end
142
+ end
143
+ end
144
+
@@ -0,0 +1,38 @@
1
+ # ==========================================================================
2
+ # Construction de la tache flay (doublons dans du code ruby)
3
+ # author: Vincent Dubois
4
+ # date: 08 fevrier 2009
5
+ # ==========================================================================
6
+ class FlayBuilder
7
+ include Utils
8
+
9
+ # Implementation de la construction de la tache
10
+ def build(project_name, auto_install, proxy_option)
11
+ # On verifie la presence de flay
12
+ Utils.verify_gem_presence("flay", auto_install, proxy_option)
13
+ # On lance la generation (produite dans tmp/metric_fu/flay)
14
+ puts " Building flay report..."
15
+ ENV['HOME'] = ENV['USERPROFILE'] if Config::CONFIG['host_os'] =~ /mswin/ and ENV['HOME'].nil?
16
+ files = Array.new
17
+ files << Dir.glob("app/**/*.rb")
18
+ files << Dir.glob("lib/**/*.rb")
19
+ files << Dir.glob("test/**/*.rb")
20
+ files.flatten!
21
+ flay_command = "flay"
22
+ files.each do |file|
23
+ flay_command += " '#{file}'"
24
+ end
25
+ flay_result = Utils.run_command(flay_command)
26
+ matches = flay_result.chomp.split("\n\n").map{|m| m.split("\n ") }
27
+ FileUtils.mkdir("#{Continuous4r::WORK_DIR}/flay")
28
+ flay_file = File.open("#{Continuous4r::WORK_DIR}/flay/index.html","w")
29
+ matches.each_with_index do |match, count|
30
+ flay_file.write("<tr class='#{count % 2 == 0 ? "a" : "b"}'><td>")
31
+ match[1..-1].each do |filename|
32
+ flay_file.write("<a href='xdoclet/#{filename.split(":")[0].gsub(/\//,'_')}.html##{filename.split(":")[1]}' target='_blank'>#{filename}</a><br/>")
33
+ end
34
+ flay_file.write("</td><td>#{match.first}</td></tr>")
35
+ end
36
+ flay_file.close
37
+ end
38
+ end
@@ -0,0 +1,120 @@
1
+ # ==========================================================================
2
+ # Construction de la tache flog (complexite du code ruby)
3
+ # Code inspired by the metric_fu gem by Jake Scruggs
4
+ # author: Vincent Dubois
5
+ # date: 06 fevrier 2009
6
+ # ==========================================================================
7
+ class FlogBuilder
8
+ include Utils
9
+
10
+ class Page
11
+ attr_accessor :filename, :score, :scanned_methods
12
+
13
+ def initialize(score, scanned_methods = [])
14
+ @score = score.to_f
15
+ @scanned_methods = scanned_methods
16
+ end
17
+
18
+ def path
19
+ @path ||= File.basename(filename, ".txt") + '.html'
20
+ end
21
+
22
+ def to_html
23
+ ERB.new(File.read(File.join(File.dirname(__FILE__), "site/flog_page.html.erb"))).result(binding)
24
+ end
25
+
26
+ def average_score
27
+ return 0 if scanned_methods.length == 0
28
+ sum = 0
29
+ scanned_methods.each do |m|
30
+ sum += m.score
31
+ end
32
+ sum / scanned_methods.length
33
+ end
34
+
35
+ def highest_score
36
+ scanned_methods.inject(0) do |highest, m|
37
+ m.score > highest ? m.score : highest
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ class Operator
44
+ attr_accessor :score, :operator
45
+
46
+ def initialize(score, operator)
47
+ @score = score.to_f
48
+ @operator = operator
49
+ end
50
+ end
51
+
52
+ class ScannedMethod
53
+ attr_accessor :name, :score, :operators
54
+
55
+ def initialize(name, score, operators = [])
56
+ @name = name
57
+ @score = score.to_f
58
+ @operators = operators
59
+ end
60
+ end
61
+
62
+ METHOD_LINE_REGEX = /([A-Za-z]+#.*):\s\((\d+\.\d+)\)/
63
+ OPERATOR_LINE_REGEX = /\s+(\d+\.\d+):\s(.*)$/
64
+
65
+ def parse(text)
66
+ score = text[/\w+ = (\d+\.\d+)/, 1]
67
+ return nil unless score
68
+ page = Page.new(score)
69
+
70
+ text.each_line do |method_line|
71
+ if match = method_line.match(METHOD_LINE_REGEX)
72
+ page.scanned_methods << ScannedMethod.new(match[1], match[2])
73
+ end
74
+
75
+ if match = method_line.match(OPERATOR_LINE_REGEX)
76
+ return if page.scanned_methods.empty?
77
+ page.scanned_methods.last.operators << Operator.new(match[1], match[2])
78
+ end
79
+ end
80
+ page
81
+ end
82
+
83
+ def save_html(content, file='index.html')
84
+ f = File.open("#{Continuous4r::WORK_DIR}/flog/#{file}", "w")
85
+ f.write(content)
86
+ f.close
87
+ end
88
+
89
+ # Implementation de la construction de la tache
90
+ def build(project_name, auto_install, proxy_option)
91
+ # On verifie la presence de flog
92
+ Utils.verify_gem_presence("flog", auto_install, proxy_option)
93
+ # On lance la generation
94
+ puts " Building flog report..."
95
+ FileUtils.mkdir("#{Continuous4r::WORK_DIR}/flog")
96
+ files = Array.new
97
+ files << Dir.glob("app/**/*.rb")
98
+ files << Dir.glob("lib/**/*.rb")
99
+ files << Dir.glob("test/**/*.rb")
100
+ files.flatten!
101
+ files.each do |filename|
102
+ puts "Processing #{filename}..."
103
+ output_dir = "#{Continuous4r::WORK_DIR}/flog/#{filename.split("/")[0..-2].join("/")}"
104
+ FileUtils.mkdir_p(output_dir, :verbose => false) unless File.directory?(output_dir)
105
+ Utils.run_command("flog #{filename} > #{Continuous4r::WORK_DIR}/flog/#{filename.split('.')[0]}.txt")
106
+ end
107
+ pages = Array.new
108
+ Dir.glob("#{Continuous4r::WORK_DIR}/flog/**/*.txt").each do |filename|
109
+ page = parse(File.read(filename))
110
+ if page
111
+ page.filename = filename
112
+ pages << page
113
+ end
114
+ end
115
+ pages.each do |page|
116
+ save_html(page.to_html, page.path)
117
+ end
118
+ save_html(ERB.new(File.read(File.join(File.dirname(__FILE__), "site/flog.html.erb"))).result(binding))
119
+ end
120
+ end
@@ -0,0 +1,48 @@
1
+ # ====================================================
2
+ # Classe d'extraction des informations de Git
3
+ # Author: Vincent Dubois
4
+ # Date: 19 fevrier 2009
5
+ # ====================================================
6
+ module GitExtractor
7
+
8
+ # Methode qui permet de fabriquer le flux HTML a partir des informations
9
+ # presentes dans le referentiel
10
+ def self.extract_changelog scm_current_version, file_name
11
+ git_revisions = Utils.run_command("git log").split(/$/).select{ |l| l =~ /^commit / }.collect { |l| l[8..(l.length-1)] }
12
+ revision = git_revisions[0]
13
+ begin
14
+ git_url = File.read(".git/config").split(/$/).select {|l| l =~ /url = /}[0].split(/url = /)[1]
15
+ puts " Computing changelog for #{git_url}..."
16
+ rescue
17
+ puts " Computing changelog, from commit #{scm_current_version} to revision #{revision}..."
18
+ end
19
+ i = 0
20
+ html = "<table class='bodyTable'><thead><th>Commit</th><th>Date</th><th>Author</th><th>File(s)</th><th>Comment</th></thead><tbody>"
21
+ commits = Utils.run_command("git log --name-status").split(/^commit/)
22
+ commits.delete_at(0)
23
+ commits.each_with_index do |commit, index|
24
+ commit_details = commit.split(/$/)
25
+ puts " Changelog for commit #{commit_details[0].strip}..."
26
+ html = html + "<tr class='#{ index % 2 == 0 ? 'a' : 'b'}'><td><strong>#{commit_details[0].strip}</strong></td>"
27
+ html = html + "<td>#{commit_details[2].strip.split(/Date: /)[1]}</td><td>#{commit_details[1].strip.split(/Author: /)[1]}</td><td>"
28
+ (6..(commit_details.length - 3)).to_a.each do |file_detail|
29
+ file_status = "added"
30
+ if commit_details[file_detail].strip.at(0) == 'A'
31
+ file_status = "added"
32
+ elsif commit_details[file_detail].strip.at(0) == 'M'
33
+ file_status = "modified"
34
+ elsif commit_details[file_detail].strip.at(0) == 'D'
35
+ file_status = "deleted"
36
+ end
37
+ html = html + "<img src='images/#{file_status}.png' align='absmiddle'/>&#160;#{commit_details[file_detail].strip.split(Regexp.new("\t"))[1]}<br/>"
38
+ end
39
+ html = html + "</td><td>#{commit_details[4].strip}</td></tr>"
40
+ end
41
+ html = html + "</tbody></table>"
42
+ changelog_file = File.open(file_name,"w")
43
+ changelog_file.write(html)
44
+ changelog_file.close
45
+ return revision
46
+ end
47
+
48
+ end
@@ -0,0 +1,23 @@
1
+ # ==========================================================================
2
+ # Construction de la tache rcov (couverture des tests sur le code)
3
+ # author: Vincent Dubois
4
+ # date: 06 fevrier 2009
5
+ # ==========================================================================
6
+ class RcovBuilder
7
+ include Utils
8
+
9
+ # Implementation de la construction de la tache
10
+ def build(project_name, auto_install, proxy_option)
11
+ # On verifie la presence de rcov
12
+ Utils.verify_gem_presence("rcov", auto_install, proxy_option)
13
+ # On lance la generation
14
+ puts " Building rcov code coverage report..."
15
+ rcov_pass = Utils.run_command("rcov --rails --exclude rcov,rubyforge,builder,mime-types,xml-simple test/rcov*.rb")
16
+ if rcov_pass.index("Finished in").nil?
17
+ raise " Execution of rcov failed with command 'rcov --rails --exclude rcov,rubyforge test/rcov*.rb'.\n BUILD FAILED."
18
+ end
19
+ # On recupere le rapport genere
20
+ Dir.mkdir "#{Continuous4r::WORK_DIR}/rcov"
21
+ FileUtils.mv("coverage", "#{Continuous4r::WORK_DIR}/rcov/")
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ # ==========================================================================
2
+ # Construction de la tache rdoc (apidoc)
3
+ # author: Vincent Dubois
4
+ # date: 06 fevrier 2009
5
+ # ==========================================================================
6
+ class RdocBuilder
7
+ include Utils
8
+
9
+ # Implementation de la construction de la tache
10
+ def build(project_name, auto_install, proxy_option)
11
+ # On lance la generation
12
+ puts " Building rdoc api and rdoc generation report..."
13
+ if !File.exist?("#{RAILS_ROOT}/doc")
14
+ FileUtils.mkdir("#{RAILS_ROOT}/doc")
15
+ end
16
+ if !File.exist?("#{RAILS_ROOT}/doc/README_FOR_APP")
17
+ if File.exist?("#{RAILS_ROOT}/README")
18
+ FileUtils.copy_file("#{RAILS_ROOT}/README", "#{RAILS_ROOT}/doc/README_FOR_APP")
19
+ else
20
+ FileUtils.touch("#{RAILS_ROOT}/doc/README_FOR_APP")
21
+ end
22
+ end
23
+ File.delete("rdoc.log") if File.exist?("rdoc.log")
24
+ rdoc_pass = system("rake doc:app > rdoc.log")
25
+ if !rdoc_pass
26
+ raise " Execution of rdoc failed with command 'rake doc:reapp'.\n BUILD FAILED."
27
+ end
28
+ # On recupere la documentation et le fichier de log generes
29
+ Dir.mkdir "#{Continuous4r::WORK_DIR}/rdoc"
30
+ FileUtils.mv("doc/app/", "#{Continuous4r::WORK_DIR}/rdoc/")
31
+ FileUtils.mv("rdoc.log", "#{Continuous4r::WORK_DIR}/rdoc/")
32
+ end
33
+ end
@@ -0,0 +1,38 @@
1
+ # ==========================================================================
2
+ # Construction de la tache reek (imperfections dans le code Ruby)
3
+ # author: Vincent Dubois
4
+ # date: 08 fevrier 2009
5
+ # ==========================================================================
6
+ class ReekBuilder
7
+ include Utils
8
+
9
+ # Implementation de la construction de la tache
10
+ def build(project_name, auto_install, proxy_option)
11
+ # On verifie la presence de reek
12
+ Utils.verify_gem_presence("reek", auto_install, proxy_option)
13
+ # On lance la generation
14
+ puts " Building reek report..."
15
+ files = Array.new
16
+ files << Dir.glob("app/**/*.rb")
17
+ files << Dir.glob("lib/**/*.rb")
18
+ files << Dir.glob("test/**/*.rb")
19
+ files.flatten!
20
+ reek_command = "reek"
21
+ files.each do |file|
22
+ reek_command += " '#{file}'"
23
+ end
24
+ reek_result = Utils.run_command(reek_command)
25
+ matches = reek_result.chomp.split("\n\n").map{|m| m.split("\n") }
26
+ FileUtils.mkdir("#{Continuous4r::WORK_DIR}/reek")
27
+ reek_file = File.open("#{Continuous4r::WORK_DIR}/reek/index.html","w")
28
+ matches.each_with_index do |match, count|
29
+ reek_file.write("<tr class='#{count % 2 == 0 ? "a" : "b"}'>")
30
+ reek_file.write("<td><a href='xdoclet/#{match.first.split("\"")[1].gsub(/\//,'_')}.html' target='_blank'>#{match.first.split("\"")[1]}</a> #{match.first.split("\"")[2]}</td><td>")
31
+ match[1..-1].each do |filename|
32
+ reek_file.write("#{filename}<br/>")
33
+ end
34
+ reek_file.write("</td></tr>")
35
+ end
36
+ reek_file.close
37
+ end
38
+ end