coverband 4.2.6 → 5.0.0.rc.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +26 -0
  3. data/.travis.yml +2 -1
  4. data/Gemfile +5 -7
  5. data/Gemfile.rails4 +0 -3
  6. data/Gemfile.rails6 +0 -3
  7. data/README.md +24 -77
  8. data/Rakefile +17 -17
  9. data/changes.md +30 -28
  10. data/config.ru +1 -1
  11. data/coverband.gemspec +31 -34
  12. data/lib/alternative_coverband_patch.rb +5 -0
  13. data/lib/coverband.rb +68 -44
  14. data/lib/coverband/adapters/base.rb +17 -18
  15. data/lib/coverband/adapters/file_store.rb +38 -6
  16. data/lib/coverband/adapters/hash_redis_store.rb +24 -21
  17. data/lib/coverband/adapters/redis_store.rb +12 -12
  18. data/lib/coverband/adapters/stdout_store.rb +41 -0
  19. data/lib/coverband/adapters/web_service_store.rb +155 -0
  20. data/lib/coverband/at_exit.rb +1 -1
  21. data/lib/coverband/collectors/coverage.rb +15 -27
  22. data/lib/coverband/collectors/delta.rb +29 -9
  23. data/lib/coverband/collectors/view_tracker.rb +10 -10
  24. data/lib/coverband/collectors/view_tracker_service.rb +59 -0
  25. data/lib/coverband/configuration.rb +150 -113
  26. data/lib/coverband/integrations/background.rb +6 -6
  27. data/lib/coverband/integrations/rack_server_check.rb +3 -3
  28. data/lib/coverband/integrations/resque.rb +13 -1
  29. data/lib/coverband/reporters/base.rb +11 -12
  30. data/lib/coverband/reporters/console_report.rb +1 -1
  31. data/lib/coverband/reporters/html_report.rb +10 -30
  32. data/lib/coverband/reporters/web.rb +55 -50
  33. data/lib/coverband/utils/absolute_file_converter.rb +6 -6
  34. data/lib/coverband/utils/html_formatter.rb +32 -61
  35. data/lib/coverband/utils/railtie.rb +23 -6
  36. data/lib/coverband/utils/relative_file_converter.rb +2 -2
  37. data/lib/coverband/utils/result.rb +6 -11
  38. data/lib/coverband/utils/results.rb +0 -10
  39. data/lib/coverband/utils/source_file.rb +21 -30
  40. data/lib/coverband/utils/tasks.rb +8 -11
  41. data/lib/coverband/version.rb +1 -1
  42. data/public/application.js +0 -30
  43. data/test/benchmarks/benchmark.rake +97 -92
  44. data/test/benchmarks/dog.rb +1 -1
  45. data/test/benchmarks/init_rails.rake +4 -4
  46. data/test/coverband/adapters/base_test.rb +29 -30
  47. data/test/coverband/adapters/file_store_test.rb +19 -20
  48. data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
  49. data/test/coverband/adapters/redis_store_test.rb +26 -26
  50. data/test/coverband/adapters/web_service_store_test.rb +56 -0
  51. data/test/coverband/at_exit_test.rb +2 -2
  52. data/test/coverband/collectors/coverage_test.rb +33 -47
  53. data/test/coverband/collectors/delta_test.rb +52 -23
  54. data/test/coverband/collectors/view_tracker_test.rb +35 -35
  55. data/test/coverband/configuration_test.rb +61 -48
  56. data/test/coverband/coverband_test.rb +11 -11
  57. data/test/coverband/integrations/background_middleware_test.rb +10 -10
  58. data/test/coverband/integrations/background_test.rb +17 -5
  59. data/test/coverband/integrations/rack_server_check_test.rb +7 -7
  60. data/test/coverband/integrations/report_middleware_test.rb +9 -9
  61. data/test/coverband/integrations/resque_worker_test.rb +9 -9
  62. data/test/coverband/integrations/test_resque_job.rb +1 -1
  63. data/test/coverband/reporters/base_test.rb +9 -9
  64. data/test/coverband/reporters/console_test.rb +6 -6
  65. data/test/coverband/reporters/html_test.rb +36 -48
  66. data/test/coverband/reporters/web_test.rb +16 -18
  67. data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
  68. data/test/coverband/utils/file_hasher_test.rb +6 -12
  69. data/test/coverband/utils/file_list_test.rb +13 -13
  70. data/test/coverband/utils/html_formatter_test.rb +9 -23
  71. data/test/coverband/utils/lines_classifier_test.rb +29 -29
  72. data/test/coverband/utils/relative_file_converter_test.rb +13 -13
  73. data/test/coverband/utils/result_test.rb +18 -18
  74. data/test/coverband/utils/results_test.rb +17 -17
  75. data/test/coverband/utils/source_file_line_test.rb +46 -46
  76. data/test/coverband/utils/source_file_test.rb +38 -88
  77. data/test/dog.rb +1 -1
  78. data/test/fake_app/basic_rack.rb +2 -2
  79. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  80. data/test/fixtures/app/models/user.rb +1 -1
  81. data/test/fixtures/sample.rb +1 -1
  82. data/test/fixtures/utf-8.rb +0 -2
  83. data/test/forked/rails_full_stack_test.rb +24 -27
  84. data/test/forked/rails_rake_full_stack_test.rb +7 -26
  85. data/test/integration/full_stack_test.rb +11 -22
  86. data/test/jruby_check.rb +2 -3
  87. data/test/rails4_dummy/Rakefile +1 -1
  88. data/test/rails4_dummy/config.ru +1 -1
  89. data/test/rails4_dummy/config/application.rb +4 -4
  90. data/test/rails4_dummy/config/boot.rb +2 -2
  91. data/test/rails4_dummy/config/coverband.rb +1 -1
  92. data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
  93. data/test/rails4_dummy/config/environment.rb +1 -1
  94. data/test/rails4_dummy/config/routes.rb +2 -2
  95. data/test/rails5_dummy/Rakefile +1 -1
  96. data/test/rails5_dummy/config.ru +1 -1
  97. data/test/rails5_dummy/config/application.rb +3 -3
  98. data/test/rails5_dummy/config/coverband.rb +8 -8
  99. data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
  100. data/test/rails5_dummy/config/environment.rb +1 -1
  101. data/test/rails5_dummy/config/routes.rb +2 -2
  102. data/test/rails6_dummy/Rakefile +1 -1
  103. data/test/rails6_dummy/config.ru +1 -1
  104. data/test/rails6_dummy/config/application.rb +4 -4
  105. data/test/rails6_dummy/config/boot.rb +2 -2
  106. data/test/rails6_dummy/config/coverband.rb +1 -1
  107. data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
  108. data/test/rails6_dummy/config/environment.rb +1 -1
  109. data/test/rails6_dummy/config/routes.rb +2 -2
  110. data/test/rails_test_helper.rb +11 -11
  111. data/test/test_helper.rb +44 -34
  112. data/test/unique_files.rb +10 -10
  113. data/views/layout.erb +2 -12
  114. metadata +29 -34
  115. data/.rubocop.yml +0 -84
  116. data/lib/coverband/integrations/bundler.rb +0 -8
  117. data/lib/coverband/utils/file_groups.rb +0 -53
  118. data/lib/coverband/utils/gem_list.rb +0 -31
  119. data/lib/coverband/utils/s3_report.rb +0 -105
  120. data/test/coverband/utils/file_groups_test.rb +0 -61
  121. data/test/coverband/utils/gem_list_test.rb +0 -48
  122. data/test/coverband/utils/s3_report_test.rb +0 -44
  123. data/views/gem_list.erb +0 -63
@@ -12,7 +12,7 @@ module Coverband
12
12
  scov_style_report.each_pair do |file, usage|
13
13
  # TODO: In Coverband 5 deprecate none hash format
14
14
  if usage.is_a?(Hash)
15
- Coverband.configuration.logger.info "#{file}: #{usage['data']}"
15
+ Coverband.configuration.logger.info "#{file}: #{usage["data"]}"
16
16
  else
17
17
  Coverband.configuration.logger.info "#{file}: #{usage}"
18
18
  end
@@ -3,16 +3,15 @@
3
3
  module Coverband
4
4
  module Reporters
5
5
  class HTMLReport < Base
6
- attr_accessor :filtered_report_files, :open_report, :static, :notice,
7
- :base_path, :filename
6
+ attr_accessor :filtered_report_files, :open_report, :notice,
7
+ :base_path, :filename
8
8
 
9
9
  def initialize(store, options = {})
10
10
  coverband_reports = Coverband::Reporters::Base.report(store, options)
11
11
  self.open_report = options.fetch(:open_report) { true }
12
- self.static = options.fetch(:static) { true }
13
12
  # TODO: refactor notice out to top level of web only
14
13
  self.notice = options.fetch(:notice) { nil }
15
- self.base_path = options.fetch(:base_path) { nil }
14
+ self.base_path = options.fetch(:base_path) { "./" }
16
15
  self.filename = options.fetch(:filename) { nil }
17
16
 
18
17
  self.filtered_report_files = self.class.fix_reports(coverband_reports)
@@ -20,16 +19,12 @@ module Coverband
20
19
 
21
20
  def file_details
22
21
  Coverband::Utils::HTMLFormatter.new(filtered_report_files,
23
- base_path: base_path,
24
- notice: notice).format_source_file!(filename)
22
+ base_path: base_path,
23
+ notice: notice).format_source_file!(filename)
25
24
  end
26
25
 
27
26
  def report
28
- if static?
29
- report_static_site
30
- else
31
- report_dynamic_html
32
- end
27
+ report_dynamic_html
33
28
  end
34
29
 
35
30
  def report_data
@@ -38,31 +33,16 @@ module Coverband
38
33
 
39
34
  private
40
35
 
41
- def static?
42
- static
43
- end
44
-
45
- def report_static_site
46
- Coverband::Utils::HTMLFormatter.new(filtered_report_files).format_static_html!
47
- if open_report
48
- `open #{Coverband.configuration.root}/coverage/index.html`
49
- else
50
- Coverband.configuration.logger.info 'report is ready and viewable: open coverage/index.html'
51
- end
52
-
53
- Coverband::Utils::S3Report.instance.persist! if Coverband.configuration.s3_bucket
54
- end
55
-
56
36
  def report_dynamic_html
57
37
  Coverband::Utils::HTMLFormatter.new(filtered_report_files,
58
- base_path: base_path,
59
- notice: notice).format_dynamic_html!
38
+ base_path: base_path,
39
+ notice: notice).format_dynamic_html!
60
40
  end
61
41
 
62
42
  def report_dynamic_data
63
43
  Coverband::Utils::HTMLFormatter.new(filtered_report_files,
64
- base_path: base_path,
65
- notice: notice).format_dynamic_data!
44
+ base_path: base_path,
45
+ notice: notice).format_dynamic_data!
66
46
  end
67
47
  end
68
48
  end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "coverband"
4
+
3
5
  begin
4
- require 'rack'
6
+ require "rack"
5
7
  rescue LoadError
6
- puts 'error loading Coverband web reporter as Rack is not available'
8
+ puts "error loading Coverband web reporter as Rack is not available"
7
9
  end
8
10
 
9
11
  module Coverband
@@ -11,28 +13,28 @@ module Coverband
11
13
  class Web
12
14
  attr_reader :request
13
15
 
14
- def initialize
15
- full_path = Gem::Specification.find_by_name('coverband').full_gem_path
16
+ def init_web
17
+ full_path = Gem::Specification.find_by_name("coverband").full_gem_path
16
18
  @static = Rack::Static.new(self,
17
- root: File.expand_path('public', full_path),
18
- urls: [/.*\.css/, /.*\.js/, /.*\.gif/, /.*\.png/])
19
+ root: File.expand_path("public", full_path),
20
+ urls: [/.*\.css/, /.*\.js/, /.*\.gif/, /.*\.png/])
19
21
  end
20
22
 
21
23
  def check_auth
22
24
  return true unless Coverband.configuration.password
23
25
 
24
- auth_header = request.get_header('HTTP_AUTHORIZATION')
26
+ auth_header = request.get_header("HTTP_AUTHORIZATION")
25
27
  return unless auth_header
26
28
 
27
- Coverband.configuration.password == Base64.decode64(auth_header.split[1]).split(':')[1]
29
+ Coverband.configuration.password == Base64.decode64(auth_header.split[1]).split(":")[1]
28
30
  end
29
31
 
30
32
  def call(env)
31
33
  @request = Rack::Request.new(env)
32
34
 
33
- return [401, { 'www-authenticate' => 'Basic realm=""' }, ['']] unless check_auth
35
+ return [401, {"www-authenticate" => 'Basic realm=""'}, [""]] unless check_auth
34
36
 
35
- request_path_info = (request.path_info == '') ? '/' : request.path_info
37
+ request_path_info = request.path_info == "" ? "/" : request.path_info
36
38
  if request.post?
37
39
  case request_path_info
38
40
  when %r{\/clear_view_tracking_file}
@@ -44,40 +46,40 @@ module Coverband
44
46
  when %r{\/clear}
45
47
  clear
46
48
  else
47
- [404, { 'Content-Type' => 'text/html' }, ['404 error!']]
49
+ [404, {"Content-Type" => "text/html"}, ["404 error!"]]
48
50
  end
49
51
  else
50
52
  case request_path_info
51
53
  when /.*\.(css|js|gif|png)/
52
54
  @static.call(env)
53
55
  when %r{\/settings}
54
- [200, { 'Content-Type' => 'text/html' }, [settings]]
56
+ [200, {"Content-Type" => "text/html"}, [settings]]
55
57
  when %r{\/view_tracker_data}
56
- [200, { 'Content-Type' => 'text/json' }, [view_tracker_data]]
58
+ [200, {"Content-Type" => "text/json"}, [view_tracker_data]]
57
59
  when %r{\/view_tracker}
58
- [200, { 'Content-Type' => 'text/html' }, [view_tracker]]
60
+ [200, {"Content-Type" => "text/html"}, [view_tracker]]
59
61
  when %r{\/enriched_debug_data}
60
- [200, { 'Content-Type' => 'text/json' }, [enriched_debug_data]]
62
+ [200, {"Content-Type" => "text/json"}, [enriched_debug_data]]
61
63
  when %r{\/debug_data}
62
- [200, { 'Content-Type' => 'text/json' }, [debug_data]]
64
+ [200, {"Content-Type" => "text/json"}, [debug_data]]
63
65
  when %r{\/load_file_details}
64
- [200, { 'Content-Type' => 'text/json' }, [load_file_details]]
66
+ [200, {"Content-Type" => "text/json"}, [load_file_details]]
65
67
  when %r{\/$}
66
- [200, { 'Content-Type' => 'text/html' }, [index]]
68
+ [200, {"Content-Type" => "text/html"}, [index]]
67
69
  else
68
- [404, { 'Content-Type' => 'text/html' }, ['404 error!']]
70
+ [404, {"Content-Type" => "text/html"}, ["404 error!"]]
69
71
  end
70
72
  end
71
73
  end
72
74
 
73
75
  def index
74
- notice = "<strong>Notice:</strong> #{Rack::Utils.escape_html(request.params['notice'])}<br/>"
75
- notice = request.params['notice'] ? notice : ''
76
+ notice = "<strong>Notice:</strong> #{Rack::Utils.escape_html(request.params["notice"])}<br/>"
77
+ notice = request.params["notice"] ? notice : ""
76
78
  Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
77
- static: false,
78
- base_path: base_path,
79
- notice: notice,
80
- open_report: false).report
79
+ static: false,
80
+ base_path: base_path,
81
+ notice: notice,
82
+ open_report: false).report
81
83
  end
82
84
 
83
85
  def settings
@@ -85,11 +87,11 @@ module Coverband
85
87
  end
86
88
 
87
89
  def view_tracker
88
- notice = "<strong>Notice:</strong> #{Rack::Utils.escape_html(request.params['notice'])}<br/>"
89
- notice = request.params['notice'] ? notice : ''
90
+ notice = "<strong>Notice:</strong> #{Rack::Utils.escape_html(request.params["notice"])}<br/>"
91
+ notice = request.params["notice"] ? notice : ""
90
92
  Coverband::Utils::HTMLFormatter.new(nil,
91
- notice: notice,
92
- base_path: base_path).format_view_tracker!
93
+ notice: notice,
94
+ base_path: base_path).format_view_tracker!
93
95
  end
94
96
 
95
97
  def view_tracker_data
@@ -102,62 +104,62 @@ module Coverband
102
104
 
103
105
  def enriched_debug_data
104
106
  Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
105
- static: false,
106
- base_path: base_path,
107
- notice: '',
108
- open_report: false).report_data
107
+ static: false,
108
+ base_path: base_path,
109
+ notice: "",
110
+ open_report: false).report_data
109
111
  end
110
112
 
111
113
  def load_file_details
112
- filename = request.params['filename']
114
+ filename = request.params["filename"]
113
115
  Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
114
- filename: filename,
115
- base_path: base_path,
116
- open_report: false).file_details
116
+ filename: filename,
117
+ base_path: base_path,
118
+ open_report: false).file_details
117
119
  end
118
120
 
119
121
  def clear
120
122
  if Coverband.configuration.web_enable_clear
121
123
  Coverband.configuration.store.clear!
122
- notice = 'coverband coverage cleared'
124
+ notice = "coverband coverage cleared"
123
125
  else
124
- notice = 'web_enable_clear isnt enabled in your configuration'
126
+ notice = "web_enable_clear isnt enabled in your configuration"
125
127
  end
126
- [301, { 'Location' => "#{base_path}?notice=#{notice}" }, []]
128
+ [301, {"Location" => "#{base_path}?notice=#{notice}"}, []]
127
129
  end
128
130
 
129
131
  def clear_file
130
132
  if Coverband.configuration.web_enable_clear
131
- filename = request.params['filename']
133
+ filename = request.params["filename"]
132
134
  Coverband.configuration.store.clear_file!(filename)
133
135
  notice = "coverage for file #{filename} cleared"
134
136
  else
135
- notice = 'web_enable_clear isnt enabled in your configuration'
137
+ notice = "web_enable_clear isnt enabled in your configuration"
136
138
  end
137
- [301, { 'Location' => "#{base_path}?notice=#{notice}" }, []]
139
+ [301, {"Location" => "#{base_path}?notice=#{notice}"}, []]
138
140
  end
139
141
 
140
142
  def clear_view_tracking
141
143
  if Coverband.configuration.web_enable_clear
142
144
  tracker = Coverband::Collectors::ViewTracker.new(store: Coverband.configuration.store)
143
145
  tracker.reset_recordings
144
- notice = 'view tracking reset'
146
+ notice = "view tracking reset"
145
147
  else
146
- notice = 'web_enable_clear isnt enabled in your configuration'
148
+ notice = "web_enable_clear isnt enabled in your configuration"
147
149
  end
148
- [301, { 'Location' => "#{base_path}/view_tracker?notice=#{notice}" }, []]
150
+ [301, {"Location" => "#{base_path}/view_tracker?notice=#{notice}"}, []]
149
151
  end
150
152
 
151
153
  def clear_view_tracking_file
152
154
  if Coverband.configuration.web_enable_clear
153
155
  tracker = Coverband::Collectors::ViewTracker.new(store: Coverband.configuration.store)
154
- filename = request.params['filename']
156
+ filename = request.params["filename"]
155
157
  tracker.clear_file!(filename)
156
158
  notice = "coverage for file #{filename} cleared"
157
159
  else
158
- notice = 'web_enable_clear isnt enabled in your configuration'
160
+ notice = "web_enable_clear isnt enabled in your configuration"
159
161
  end
160
- [301, { 'Location' => "#{base_path}/view_tracker?notice=#{notice}" }, []]
162
+ [301, {"Location" => "#{base_path}/view_tracker?notice=#{notice}"}, []]
161
163
  end
162
164
 
163
165
  private
@@ -167,8 +169,11 @@ module Coverband
167
169
  # mount Coverband::Web, at: '/coverage'
168
170
  # "/coverage/collect_coverage?" become:
169
171
  # /coverage/
172
+ # NOTE: DO NOT let standardrb `autofix` this to regex match
173
+ # %r{\/.*\/}.match?(request.path) ? request.path.match("\/.*\/")[0] : "/"
174
+ # ^^ the above is NOT valid Ruby 2.3/2.4 even though rubocop / standard think it is
170
175
  def base_path
171
- request.path =~ %r{\/.*\/} ? request.path.match("\/.*\/")[0] : '/'
176
+ request.path =~ %r{\/.*\/} ? request.path.match("\/.*\/")[0] : "/"
172
177
  end
173
178
  end
174
179
  end
@@ -25,9 +25,9 @@ module Coverband
25
25
  relative_filename = relative_path
26
26
  local_filename = relative_filename
27
27
  @roots.each do |root|
28
- relative_filename = relative_filename.sub(/^#{root}/, './')
28
+ relative_filename = relative_filename.sub(/^#{root}/, "./")
29
29
  # once we have a relative path break out of the loop
30
- break if relative_filename.start_with? './'
30
+ break if relative_filename.start_with? "./"
31
31
  end
32
32
  # the filename for our reports is expected to be a full path.
33
33
  # roots.last should be roots << current_root}/
@@ -36,10 +36,10 @@ module Coverband
36
36
  # above only works for app files
37
37
  # we need to rethink some of this logic
38
38
  # gems aren't at project root and can have multiple locations
39
- local_root = @roots.find do |root|
40
- File.exist?(relative_filename.gsub('./', root))
41
- end
42
- local_root ? relative_filename.gsub('./', local_root) : local_filename
39
+ local_root = @roots.find { |root|
40
+ File.exist?(relative_filename.gsub("./", root))
41
+ }
42
+ local_root ? relative_filename.gsub("./", local_root) : local_filename
43
43
  end
44
44
  end
45
45
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'erb'
4
- require 'cgi'
5
- require 'fileutils'
6
- require 'digest/sha1'
7
- require 'time'
3
+ require "erb"
4
+ require "cgi"
5
+ require "fileutils"
6
+ require "digest/sha1"
7
+ require "time"
8
8
 
9
9
  ####
10
10
  # Thanks for all the help SimpleCov https://github.com/colszowka/simplecov-html
@@ -17,14 +17,10 @@ module Coverband
17
17
 
18
18
  def initialize(report, options = {})
19
19
  @notice = options.fetch(:notice) { nil }
20
- @base_path = options.fetch(:base_path) { nil }
20
+ @base_path = options.fetch(:base_path) { "./" }
21
21
  @coverage_result = Coverband::Utils::Results.new(report) if report
22
22
  end
23
23
 
24
- def format_static_html!
25
- format(@coverage_result)
26
- end
27
-
28
24
  def format_dynamic_html!
29
25
  format_html(@coverage_result)
30
26
  end
@@ -47,41 +43,41 @@ module Coverband
47
43
  if source_file
48
44
  formatted_source_file(@coverage_result, source_file)
49
45
  else
50
- 'File No Longer Available'
46
+ "File No Longer Available"
51
47
  end
52
48
  end
53
49
 
54
50
  private
55
51
 
56
52
  def format_settings
57
- template('settings').result(binding)
53
+ template("settings").result(binding)
58
54
  end
59
55
 
60
56
  def format_view_tracker
61
- template('view_tracker').result(binding)
57
+ template("view_tracker").result(binding)
62
58
  end
63
59
 
64
60
  def format(result)
65
- Dir[File.join(File.dirname(__FILE__), '../../../public/*')].each do |path|
61
+ Dir[File.join(File.dirname(__FILE__), "../../../public/*")].each do |path|
66
62
  FileUtils.cp_r(path, asset_output_path)
67
63
  end
68
64
 
69
- File.open(File.join(output_path, 'index.html'), 'wb') do |file|
70
- file.puts template('layout').result(binding)
65
+ File.open(File.join(output_path, "index.html"), "wb") do |file|
66
+ file.puts template("layout").result(binding)
71
67
  end
72
68
  end
73
69
 
74
70
  def format_html(result)
75
- template('layout').result(binding)
71
+ template("layout").result(binding)
76
72
  end
77
73
 
78
74
  def format_data(result)
79
- template('data').result(binding)
75
+ template("data").result(binding)
80
76
  end
81
77
 
82
78
  # Returns the an erb instance for the template of given name
83
79
  def template(name)
84
- ERB.new(File.read(File.join(File.dirname(__FILE__), '../../../views/', "#{name}.erb")))
80
+ ERB.new(File.read(File.join(File.dirname(__FILE__), "../../../views/", "#{name}.erb")))
85
81
  end
86
82
 
87
83
  def output_path
@@ -97,90 +93,70 @@ module Coverband
97
93
  end
98
94
 
99
95
  def served_html?
100
- !static_html?
101
- end
102
-
103
- def static_html?
104
- base_path.nil?
96
+ true
105
97
  end
106
98
 
107
99
  def assets_path(name)
108
- if static_html?
109
- File.join(name)
110
- else
111
- File.join(base_path, name)
112
- end
100
+ File.join(base_path, name)
113
101
  end
114
102
 
115
103
  def button(url, title, opts = {})
116
104
  delete = opts.fetch(:delete) { false }
117
- button_css = delete ? 'coveraband-button del' : 'coveraband-button'
105
+ button_css = delete ? "coveraband-button del" : "coveraband-button"
118
106
  button = "<form action='#{url}' class='coverband-admin-form' method='post'>"
119
107
  button += "<button class='#{button_css}' type='submit'>#{title}</button>"
120
- button + '</form>'
108
+ button + "</form>"
121
109
  end
122
110
 
123
111
  def display_nav(nav_options = {})
124
- template('nav').result(binding)
112
+ template("nav").result(binding)
125
113
  end
126
114
 
127
115
  # Returns the html for the given source_file
128
116
  def formatted_source_file(result, source_file)
129
- template('source_file').result(binding)
117
+ template("source_file").result(binding)
130
118
  rescue Encoding::CompatibilityError => e
131
119
  puts "Encoding error file:#{source_file.filename} Coverband/ERB error #{e.message}."
132
120
  end
133
121
 
134
122
  # Returns the html to ajax load a given source_file
135
123
  def formatted_source_file_loader(result, source_file)
136
- template('source_file_loader').result(binding)
124
+ template("source_file_loader").result(binding)
137
125
  rescue Encoding::CompatibilityError => e
138
126
  puts "Encoding error file:#{source_file.filename} Coverband/ERB error #{e.message}."
139
127
  end
140
128
 
141
129
  # Returns a table containing the given source files
142
130
  def formatted_file_list(title, result, source_files, options = {})
143
- title_id = title.gsub(/^[^a-zA-Z]+/, '').gsub(/[^a-zA-Z0-9\-\_]/, '')
131
+ title_id = title.gsub(/^[^a-zA-Z]+/, "").gsub(/[^a-zA-Z0-9\-\_]/, "")
144
132
  # Silence a warning by using the following variable to assign to itself:
145
133
  # "warning: possibly useless use of a variable in void context"
146
134
  # The variable is used by ERB via binding.
147
135
  title_id = title_id
148
136
  options = options
149
137
 
150
- if title == 'Gems'
151
- template('gem_list').result(binding)
152
- else
153
- template('file_list').result(binding)
154
- end
155
- end
156
-
157
- def view_gems?
158
- Coverband.configuration.track_gems
159
- end
160
-
161
- def gem_details?
162
- Coverband.configuration.gem_details
138
+ template("file_list").result(binding)
163
139
  end
164
140
 
165
141
  def coverage_css_class(covered_percent)
166
142
  if covered_percent.nil?
167
- ''
143
+ ""
168
144
  elsif covered_percent > 90
169
- 'green'
145
+ "green"
170
146
  elsif covered_percent > 80
171
- 'yellow'
147
+ "yellow"
172
148
  else
173
- 'red'
149
+ "red"
174
150
  end
175
151
  end
176
152
 
177
153
  def strength_css_class(covered_strength)
178
154
  if covered_strength > 1
179
- 'green'
155
+ "green"
180
156
  elsif covered_strength == 1
181
- 'yellow'
157
+ "yellow"
182
158
  else
183
- 'red'
159
+ "red"
184
160
  end
185
161
  end
186
162
 
@@ -193,7 +169,7 @@ module Coverband
193
169
  if time
194
170
  "<abbr class=\"timeago\" title=\"#{time.iso8601}\">#{time.iso8601}</abbr>"
195
171
  else
196
- 'Not Available'
172
+ "Not Available"
197
173
  end
198
174
  end
199
175
 
@@ -201,11 +177,6 @@ module Coverband
201
177
  source_file.short_name
202
178
  end
203
179
 
204
- def link_to_gem_list(gem_name)
205
- gem_id = gem_name.gsub(/^[^a-zA-Z]+/, '').gsub(/[^a-zA-Z0-9\-\_]/, '')
206
- %(<a href="##{gem_id}" class="gem-link" title="#{gem_name}">#{gem_name}</a>)
207
- end
208
-
209
180
  def link_to_source_file(source_file)
210
181
  %(<a href="##{id source_file}" class="src_link" title="#{shortened_filename source_file}">#{shortened_filename source_file}</a>)
211
182
  end