coverband 6.0.1 → 6.0.3.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +10 -0
  3. data/.github/workflows/main.yml +2 -3
  4. data/.standard.yml +1 -1
  5. data/Gemfile +1 -1
  6. data/LICENSE +1 -1
  7. data/README.md +24 -10
  8. data/Rakefile +1 -1
  9. data/changes.md +12 -1
  10. data/coverband.gemspec +3 -3
  11. data/lib/coverband/adapters/base.rb +10 -10
  12. data/lib/coverband/adapters/file_store.rb +1 -1
  13. data/lib/coverband/adapters/hash_redis_store.rb +160 -10
  14. data/lib/coverband/adapters/null_store.rb +1 -1
  15. data/lib/coverband/adapters/stdout_store.rb +1 -1
  16. data/lib/coverband/adapters/web_service_store.rb +5 -7
  17. data/lib/coverband/collectors/coverage.rb +1 -1
  18. data/lib/coverband/collectors/route_tracker.rb +1 -1
  19. data/lib/coverband/collectors/translation_tracker.rb +2 -2
  20. data/lib/coverband/collectors/view_tracker.rb +1 -1
  21. data/lib/coverband/configuration.rb +12 -6
  22. data/lib/coverband/integrations/rack_server_check.rb +1 -3
  23. data/lib/coverband/reporters/base.rb +7 -7
  24. data/lib/coverband/reporters/html_report.rb +12 -4
  25. data/lib/coverband/reporters/json_report.rb +42 -4
  26. data/lib/coverband/reporters/web.rb +16 -2
  27. data/lib/coverband/reporters/web_pager.rb +28 -0
  28. data/lib/coverband/utils/absolute_file_converter.rb +19 -19
  29. data/lib/coverband/utils/file_hasher.rb +3 -3
  30. data/lib/coverband/utils/html_formatter.rb +4 -4
  31. data/lib/coverband/utils/method_definition_scanner.rb +1 -1
  32. data/lib/coverband/utils/railtie.rb +4 -6
  33. data/lib/coverband/utils/relative_file_converter.rb +7 -7
  34. data/lib/coverband/utils/results.rb +14 -14
  35. data/lib/coverband/utils/source_file.rb +2 -2
  36. data/lib/coverband/utils/tasks.rb +1 -1
  37. data/lib/coverband/version.rb +1 -1
  38. data/lib/coverband.rb +19 -3
  39. data/public/application.js +35 -0
  40. data/public/dependencies.js +1 -1
  41. data/roadmap.md +1 -1
  42. data/test/benchmarks/benchmark.rake +5 -5
  43. data/test/coverband/adapters/file_store_test.rb +1 -1
  44. data/test/coverband/adapters/hash_redis_store_test.rb +48 -0
  45. data/test/coverband/collectors/coverage_test.rb +1 -1
  46. data/test/coverband/reporters/json_test.rb +1 -1
  47. data/test/coverband/utils/source_file_test.rb +11 -11
  48. data/test/fixtures/casting_invitor.rb +1 -1
  49. data/test/fixtures/sample.rb +2 -2
  50. data/test/fixtures/skipped_and_executed.rb +1 -1
  51. data/test/forked/rails_rake_full_stack_test.rb +1 -1
  52. data/test/integration/full_stack_send_deferred_eager_test.rb +52 -0
  53. data/test/test_helper.rb +3 -5
  54. data/test/unique_files.rb +1 -1
  55. data/views/file_list.erb +38 -32
  56. data/views/layout.erb +3 -3
  57. metadata +17 -139
  58. data/LICENSE.txt +0 -22
@@ -1147,7 +1147,7 @@ this._iRecordsTotal:this.aiDisplayMaster.length};this.fnRecordsDisplay=function(
1147
1147
  bSort:true,bInfo:true,bAutoWidth:true,bProcessing:false,bSortClasses:true,bStateSave:false,bServerSide:false};this.oScroll={sX:"",sXInner:"",sY:"",bCollapse:false,iBarWidth:0};this.aanFeatures=[];this.oLanguage={sProcessing:"Processing...",sLengthMenu:"Show _MENU_ entries",sZeroRecords:"No matching records found",sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)",
1148
1148
  sInfoPostFix:"",sSearch:"Search:",sUrl:"",oPaginate:{sFirst:"First",sPrevious:"Previous",sNext:"Next",sLast:"Last"}};this.aoData=[];this.aiDisplay=[];this.aiDisplayMaster=[];this.aoColumns=[];this.iNextId=0;this.asDataSearch=[];this.oPreviousSearch={sSearch:"",bRegex:false,bSmart:true};this.aoPreSearchCols=[];this.aaSorting=[[0,"asc",0]];this.aaSortingFixed=null;this.asStripClasses=[];this.asDestoryStrips=[];this.fnFooterCallback=this.fnHeaderCallback=this.fnRowCallback=null;this.aoDrawCallback=[];
1149
1149
  this.fnInitComplete=null;this.sTableId="";this.nTableWrapper=this.nTBody=this.nTFoot=this.nTHead=this.nTable=null;this.iDefaultSortIndex=0;this.bInitialised=false;this.aoOpenRows=[];this.sDom="lfrtip";this.sPaginationType="two_button";this.iCookieDuration=7200;this.sCookiePrefix="SpryMedia_DataTables_";this.sAjaxSource=null;this.bAjaxDataGet=true;this.fnServerData=function(a,b,c){j.ajax({url:a,data:b,success:c,dataType:"json",cache:false,error:function(){alert("DataTables warning: JSON data from server failed to load or be parsed. This is most likely to be caused by a JSON formatting error.")}})};
1150
- this.fnFormatNumber=function(a){if(a<1E3)return a;else{var b=a+"";a=b.split("");var c="";b=b.length;for(var d=0;d<b;d++){if(d%3===0&&d!==0)c=","+c;c=a[b-d-1]+c}}return c};this.aLengthMenu=[10,25,50,100];this.iDraw=0;this.iDrawError=-1;this._iDisplayLength=10;this._iDisplayStart=0;this._iDisplayEnd=10;this._iRecordsDisplay=this._iRecordsTotal=0;this.bJUI=false;this.oClasses=m.oStdClasses;this.bSorted=this.bFiltered=false;this.oInit=null}function q(a){return function(){var b=[B(this[m.iApiIndex])].concat(Array.prototype.slice.call(arguments));
1150
+ this.fnFormatNumber=function(a){if(a<1E3)return a;else{var b=a+"";a=b.split("");var c="";b=b.length;for(var d=0;d<b;d++){if(d%3===0&&d!==0)c=","+c;c=a[b-d-1]+c}}return c};this.aLengthMenu=[250];this.iDraw=0;this.iDrawError=-1;this._iDisplayLength=250;this._iDisplayStart=0;this._iDisplayEnd=250;this._iRecordsDisplay=this._iRecordsTotal=0;this.bJUI=false;this.oClasses=m.oStdClasses;this.bSorted=this.bFiltered=false;this.oInit=null}function q(a){return function(){var b=[B(this[m.iApiIndex])].concat(Array.prototype.slice.call(arguments));
1151
1151
  return m.oApi[a].apply(this,b)}}function r(a){if(a.bInitialised===false)setTimeout(function(){r(a)},200);else{na(a);z(a);if(a.oFeatures.bSort)O(a);else{a.aiDisplay=a.aiDisplayMaster.slice();F(a);D(a)}if(a.sAjaxSource!==null&&!a.oFeatures.bServerSide){K(a,true);a.fnServerData.call(a.oInstance,a.sAjaxSource,null,function(b){for(var c=0;c<b.aaData.length;c++)w(a,b.aaData[c]);a.iInitDisplayStart=a._iDisplayStart;if(a.oFeatures.bSort)O(a);else{a.aiDisplay=a.aiDisplayMaster.slice();F(a);D(a)}K(a,false);
1152
1152
  typeof a.fnInitComplete=="function"&&a.fnInitComplete.call(a.oInstance,a,b)})}else{typeof a.fnInitComplete=="function"&&a.fnInitComplete.call(a.oInstance,a);a.oFeatures.bServerSide||K(a,false)}}}function u(a,b,c){n(a.oLanguage,b,"sProcessing");n(a.oLanguage,b,"sLengthMenu");n(a.oLanguage,b,"sEmptyTable");n(a.oLanguage,b,"sZeroRecords");n(a.oLanguage,b,"sInfo");n(a.oLanguage,b,"sInfoEmpty");n(a.oLanguage,b,"sInfoFiltered");n(a.oLanguage,b,"sInfoPostFix");n(a.oLanguage,b,"sSearch");if(typeof b.oPaginate!=
1153
1153
  "undefined"){n(a.oLanguage.oPaginate,b.oPaginate,"sFirst");n(a.oLanguage.oPaginate,b.oPaginate,"sPrevious");n(a.oLanguage.oPaginate,b.oPaginate,"sNext");n(a.oLanguage.oPaginate,b.oPaginate,"sLast")}typeof b.sEmptyTable=="undefined"&&typeof b.sZeroRecords!="undefined"&&n(a.oLanguage,b,"sZeroRecords","sEmptyTable");c&&r(a)}function y(a,b){a.aoColumns[a.aoColumns.length++]={sType:null,_bAutoType:true,bVisible:true,bSearchable:true,bSortable:true,asSorting:["asc","desc"],sSortingClass:a.oClasses.sSortable,
data/roadmap.md CHANGED
@@ -53,4 +53,4 @@ Will be the fully modern release that drops maintenance legacy support in favor
53
53
 
54
54
  It is important for a project to not only know what problems it is trying to solve, but what things are out of scope. We will start to try to document that here:
55
55
 
56
- * We have in the past tried to add coverage tracking for all gems, this added a lot of complexity and compuation overhead and slowed things down to much. It also was of less value than we had hoped. There are alterntative ways to instrument a shared library to track across multiple applications, and single application gem utilization is easier to handle in a one of basis. It is unlikely we will support that again.
56
+ * We have in the past tried to add coverage tracking for all gems, this added a lot of complexity and computation overhead and slowed things down to much. It also was of less value than we had hoped. There are alternative ways to instrument a shared library to track across multiple applications, and single application gem utilization is easier to handle in a one of basis. It is unlikely we will support that again.
@@ -5,7 +5,7 @@ namespace :benchmarks do
5
5
  # Enable and start GC before each job run. Disable GC afterwards.
6
6
  #
7
7
  # Inspired by https://www.omniref.com/ruby/2.2.1/symbols/Benchmark/bm?#annotation=4095926&line=182
8
- class GCSuite
8
+ class GCSuite # standard:disable Lint/ConstantDefinitionInBlock
9
9
  def warming(*)
10
10
  run_gc
11
11
  end
@@ -99,11 +99,11 @@ namespace :benchmarks do
99
99
  Coverband::Collectors::Coverage.instance.reset_instance
100
100
  end
101
101
 
102
- LINES = 45
103
- NON_NIL_LINES = 18
102
+ lines = 45
103
+ non_nil_lines = 18
104
104
  def fake_line_numbers
105
- LINES.times.map do |line|
106
- coverage = line < NON_NIL_LINES ? rand(5) : nil
105
+ lines.times.map do |line|
106
+ coverage = (line < non_nil_lines) ? rand(5) : nil
107
107
  end
108
108
  end
109
109
 
@@ -16,7 +16,7 @@ class AdaptersFileStoreTest < Minitest::Test
16
16
  previous_file_path = "#{@test_file_path}.#{::Process.pid}"
17
17
  `rm #{@test_file_path}` if File.exist?(@test_file_path)
18
18
  `rm #{previous_file_path}` if File.exist?(previous_file_path)
19
- File.open(previous_file_path, "w") { |f| f.write(test_data.to_json) }
19
+ File.write(previous_file_path, test_data.to_json)
20
20
  @store = Coverband::Adapters::FileStore.new(@test_file_path)
21
21
  end
22
22
 
@@ -192,4 +192,52 @@ class HashRedisStoreTest < Minitest::Test
192
192
  @store.clear_file!("app_path/dog.rb")
193
193
  assert_nil @store.get_coverage_report[:merged]["./dog.rb"]
194
194
  end
195
+
196
+ def test_get_coverage_cache
197
+ @store = Coverband::Adapters::HashRedisStore.new(
198
+ @redis,
199
+ redis_namespace: "coverband_test",
200
+ relative_file_converter: MockRelativeFileConverter,
201
+ get_coverage_cache: true
202
+ )
203
+ @store.get_coverage_cache.stubs(:deferred_time).returns(0)
204
+ @store.get_coverage_cache.clear!
205
+ mock_file_hash
206
+ yesterday = DateTime.now.prev_day.to_time
207
+ mock_time(yesterday)
208
+ @store.save_report(
209
+ "app_path/dog.rb" => [0, 1, 2]
210
+ )
211
+ assert_equal(
212
+ {
213
+ "first_updated_at" => yesterday.to_i,
214
+ "last_updated_at" => yesterday.to_i,
215
+ "file_hash" => "abcd",
216
+ "data" => [0, 1, 2]
217
+ },
218
+ @store.coverage["./dog.rb"]
219
+ )
220
+ @store.save_report(
221
+ "app_path/dog.rb" => [0, 1, 2]
222
+ )
223
+ assert_equal(
224
+ {
225
+ "first_updated_at" => yesterday.to_i,
226
+ "last_updated_at" => yesterday.to_i,
227
+ "file_hash" => "abcd",
228
+ "data" => [0, 1, 2]
229
+ },
230
+ @store.coverage["./dog.rb"]
231
+ )
232
+ sleep 0.1 # wait caching thread finish
233
+ assert_equal(
234
+ {
235
+ "first_updated_at" => yesterday.to_i,
236
+ "last_updated_at" => yesterday.to_i,
237
+ "file_hash" => "abcd",
238
+ "data" => [0, 2, 4]
239
+ },
240
+ @store.coverage["./dog.rb"]
241
+ )
242
+ end
195
243
  end
@@ -53,7 +53,7 @@ class CollectorsCoverageTest < Minitest::Test
53
53
  end
54
54
 
55
55
  test "defaults to a redis store" do
56
- assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get("@store").class
56
+ assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get(:@store).class
57
57
  end
58
58
 
59
59
  test "report_coverage raises errors in tests" do
@@ -38,7 +38,7 @@ class ReportJSONTest < Minitest::Test
38
38
  json = Coverband::Reporters::JSONReport.new(@store).report
39
39
  parsed = JSON.parse(json)
40
40
 
41
- expected_keys = ["never_loaded", "runtime_percentage", "lines_of_code", "lines_covered", "lines_missed", "covered_percent", "covered_strength"]
41
+ expected_keys = ["never_loaded", "runtime_percentage", "lines_of_code", "lines_covered", "lines_runtime", "lines_missed", "covered_percent", "covered_strength"]
42
42
 
43
43
  assert_equal parsed["files"].length, 2
44
44
  parsed["files"].keys.each do |file|
@@ -7,10 +7,10 @@ require File.expand_path("../../test_helper", File.dirname(__FILE__))
7
7
  # initial version of test pulled into Coverband from Simplecov 12/19/2018
8
8
  ####
9
9
  describe Coverband::Utils::SourceFile do
10
- COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil].freeze
10
+ coverage_for_sample_rb = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil].freeze
11
11
  describe "a source file initialized with some coverage data" do
12
12
  subject do
13
- Coverband::Utils::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB)
13
+ Coverband::Utils::SourceFile.new(source_fixture("sample.rb"), coverage_for_sample_rb)
14
14
  end
15
15
 
16
16
  it "has a filename" do
@@ -70,7 +70,7 @@ describe Coverband::Utils::SourceFile do
70
70
 
71
71
  describe "simulating potential Ruby 1.9 defect -- see Issue #56" do
72
72
  subject do
73
- Coverband::Utils::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB + [nil])
73
+ Coverband::Utils::SourceFile.new(source_fixture("sample.rb"), coverage_for_sample_rb + [nil])
74
74
  end
75
75
 
76
76
  it "has 16 source lines regardless of extra data in coverage array" do
@@ -88,10 +88,10 @@ describe Coverband::Utils::SourceFile do
88
88
  end
89
89
 
90
90
  describe "a file that is never relevant" do
91
- COVERAGE_FOR_NEVER_RB = [nil, nil].freeze
91
+ coverage_for_never_rb = [nil, nil].freeze
92
92
 
93
93
  subject do
94
- Coverband::Utils::SourceFile.new(source_fixture("never.rb"), COVERAGE_FOR_NEVER_RB)
94
+ Coverband::Utils::SourceFile.new(source_fixture("never.rb"), coverage_for_never_rb)
95
95
  end
96
96
 
97
97
  it "has 0.0 covered_strength" do
@@ -104,10 +104,10 @@ describe Coverband::Utils::SourceFile do
104
104
  end
105
105
 
106
106
  describe "a file where nothing is ever executed mixed with skipping #563" do
107
- COVERAGE_FOR_SKIPPED_RB = [nil, nil, nil, nil].freeze
107
+ coverage_for_skipped_rb = [nil, nil, nil, nil].freeze
108
108
 
109
109
  subject do
110
- Coverband::Utils::SourceFile.new(source_fixture("skipped.rb"), COVERAGE_FOR_SKIPPED_RB)
110
+ Coverband::Utils::SourceFile.new(source_fixture("skipped.rb"), coverage_for_skipped_rb)
111
111
  end
112
112
 
113
113
  it "has 0.0 covered_strength" do
@@ -120,10 +120,10 @@ describe Coverband::Utils::SourceFile do
120
120
  end
121
121
 
122
122
  describe "a file where everything is skipped and missed #563" do
123
- COVERAGE_FOR_SKIPPED_RB_2 = [nil, nil, 0, nil].freeze
123
+ coverage_for_skipped_rb_2 = [nil, nil, 0, nil].freeze
124
124
 
125
125
  subject do
126
- Coverband::Utils::SourceFile.new(source_fixture("skipped.rb"), COVERAGE_FOR_SKIPPED_RB_2)
126
+ Coverband::Utils::SourceFile.new(source_fixture("skipped.rb"), coverage_for_skipped_rb_2)
127
127
  end
128
128
 
129
129
  it "has 0.0 covered_strength" do
@@ -136,10 +136,10 @@ describe Coverband::Utils::SourceFile do
136
136
  end
137
137
 
138
138
  describe "a file where everything is skipped/irrelevamt but executed #563" do
139
- COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB = [nil, nil, 1, 1, 0, nil, nil, nil].freeze
139
+ coverage_for_skkiped_and_executed_rb = [nil, nil, 1, 1, 0, nil, nil, nil].freeze
140
140
 
141
141
  subject do
142
- Coverband::Utils::SourceFile.new(source_fixture("skipped_and_executed.rb"), COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
142
+ Coverband::Utils::SourceFile.new(source_fixture("skipped_and_executed.rb"), coverage_for_skkiped_and_executed_rb)
143
143
  end
144
144
 
145
145
  it "has 0.0 covered_strength" do
@@ -34,7 +34,7 @@ class CastingInviter
34
34
 
35
35
  def invalid_invitees
36
36
  @invalid_invitees ||=
37
- invitee_list.map { |item| item unless item.match(EMAIL_REGEX) }.compact
37
+ invitee_list.reject { |item| item.match(EMAIL_REGEX) }
38
38
  end
39
39
 
40
40
  def invitee_list
@@ -8,9 +8,9 @@ class Foo
8
8
  @foo
9
9
  end
10
10
 
11
- #:nocov:
11
+ # :nocov:
12
12
  def skipped
13
13
  @foo * 2
14
14
  end
15
- #:nocov:
15
+ # :nocov:
16
16
  end
@@ -5,4 +5,4 @@ class Foo
5
5
  0
6
6
  end
7
7
  end
8
- #:nocov:
8
+ # :nocov:
@@ -11,7 +11,7 @@ class RailsRakeFullStackTest < Minitest::Test
11
11
  end
12
12
 
13
13
  # test 'rake tasks shows coverage properly within eager_loading' do
14
- # this was testing gem data, which we no logner support and I dont know if this makes sense anymre
14
+ # this was testing gem data, which we no longer support and I dont know if this makes sense anymre
15
15
  # end
16
16
 
17
17
  test "ignored rake tasks don't add coverage" do
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("../test_helper", File.dirname(__FILE__))
4
+ require "rack"
5
+
6
+ class FullStackSendDeferredEagerTest < Minitest::Test
7
+ REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
8
+ TEST_RACK_APP = "../fake_app/basic_rack.rb"
9
+
10
+ def setup
11
+ super
12
+ Coverband::Collectors::Coverage.instance.reset_instance
13
+ Coverband.configure do |config|
14
+ config.background_reporting_enabled = false
15
+ config.track_gems = true
16
+ config.defer_eager_loading_data = true
17
+ config.send_deferred_eager_loading_data = false
18
+ end
19
+ Coverband.start
20
+ Coverband::Collectors::Coverage.instance.eager_loading!
21
+ @rack_file = require_unique_file "fake_app/basic_rack.rb"
22
+ Coverband.report_coverage
23
+ Coverband::Collectors::Coverage.instance.runtime!
24
+ end
25
+
26
+ test "call app" do
27
+ # eager loaded class coverage starts empty
28
+ Coverband.eager_loading_coverage!
29
+ expected = {}
30
+ assert_equal expected, Coverband.configuration.store.coverage
31
+
32
+ Coverband::Collectors::Coverage.instance.runtime!
33
+ request = Rack::MockRequest.env_for("/anything.json")
34
+ middleware = Coverband::BackgroundMiddleware.new(fake_app_with_lines)
35
+ results = middleware.call(request)
36
+ assert_equal "Hello Rack!", results.last
37
+ Coverband.report_coverage
38
+ expected = [nil, nil, 0, nil, 0, 0, 1, nil, nil]
39
+ assert_equal expected, Coverband.configuration.store.coverage[@rack_file]["data"]
40
+
41
+ # eager loaded class coverage is skipped at first normal coverage report
42
+ Coverband.eager_loading_coverage!
43
+ expected = {}
44
+ assert_equal expected, Coverband.configuration.store.coverage
45
+ end
46
+
47
+ private
48
+
49
+ def fake_app_with_lines
50
+ @fake_app_with_lines ||= ::HelloWorld.new
51
+ end
52
+ end
data/test/test_helper.rb CHANGED
@@ -92,11 +92,11 @@ Mocha::Configuration.prevent(:stubbing_method_unnecessarily)
92
92
  Mocha::Configuration.prevent(:stubbing_non_existent_method)
93
93
 
94
94
  def test(name, &block)
95
- test_name = "test_#{name.gsub(/\s+/, "_")}".to_sym
95
+ test_name = :"test_#{name.gsub(/\s+/, "_")}"
96
96
  defined = begin
97
97
  instance_method(test_name)
98
- rescue
99
- false
98
+ rescue
99
+ false
100
100
  end
101
101
  raise "#{test_name} is already defined in #{self}" if defined
102
102
 
@@ -172,8 +172,6 @@ ensure
172
172
  $stderr = previous_stderr
173
173
  end
174
174
 
175
- require "coverband"
176
-
177
175
  Coverband::Configuration.class_eval do
178
176
  def test_env
179
177
  true
data/test/unique_files.rb CHANGED
@@ -15,7 +15,7 @@ def require_unique_file(file = "dog.rb", variables = {})
15
15
  FileUtils.mkdir_p(Pathname.new(temp_file).dirname.to_s)
16
16
  file_contents = File.read("./test/#{file}")
17
17
  file_contents = ERB.new(file_contents).result(OpenStruct.new(variables).instance_eval { binding }) if variables.any?
18
- File.open(temp_file, "w") { |w| w.write(file_contents) }
18
+ File.write(temp_file, file_contents)
19
19
  require temp_file
20
20
  Coverband::Utils::RelativeFileConverter.convert(File.expand_path(temp_file))
21
21
  end
data/views/file_list.erb CHANGED
@@ -2,23 +2,27 @@
2
2
  <% unless options[:skip_nav] %>
3
3
  <h2>
4
4
  <span class="group_name"><%= title %></span>
5
- (<span class="covered_percent"><span class="<%= coverage_css_class(source_files.covered_percent) %>"><%= source_files.covered_percent.round(2) %>%</span></span>
6
- covered at
7
- <span class="covered_strength">
8
- <span class="<%= strength_css_class(source_files.covered_strength) %>">
9
- <%= source_files.covered_strength.round(2) %>
10
- </span>
11
- </span> hits/line)
5
+ <% unless page %>
6
+ (<span class="covered_percent"><span class="<%= coverage_css_class(source_files.covered_percent) %>"><%= source_files.covered_percent.round(2) %>%</span></span>
7
+ covered at
8
+ <span class="covered_strength">
9
+ <span class="<%= strength_css_class(source_files.covered_strength) %>">
10
+ <%= source_files.covered_strength.round(2) %>
11
+ </span>
12
+ </span> hits/line)
13
+ <% end %>
12
14
  </h2>
13
15
  <% end %>
14
16
  <a name="<%= title_id %>"></a>
15
17
  <div>
16
- <b><%= source_files.length %></b> files in total.
17
- <b><%= source_files.lines_of_code %></b> relevant lines.
18
- <span class="green"><b><%= source_files.covered_lines %></b> lines covered</span> and
19
- <span class="red"><b><%= source_files.missed_lines %></b> lines missed </span>
18
+ <% unless page %>
19
+ <b><%= source_files.length %></b> files in total.
20
+ <b><%= source_files.lines_of_code %></b> relevant lines.
21
+ <span class="green"><b><%= source_files.covered_lines %></b> lines covered</span> and
22
+ <span class="red"><b><%= source_files.missed_lines %></b> lines missed </span>
23
+ <% end %>
20
24
  </div>
21
- <table class="file_list">
25
+ <table class="file_list <%= page ? "unsorted" : "sorted" %>">
22
26
  <thead>
23
27
  <tr>
24
28
  <th title="The source file name">File</th>
@@ -33,26 +37,28 @@
33
37
  </tr>
34
38
  </thead>
35
39
  <tbody>
36
- <% source_files.each do |source_file| %>
37
- <tr>
38
- <% source_class = source_file.never_loaded ? 'strong red' : 'strong'%>
39
- <td class="<%= source_class %>">
40
- <%= link_to_source_file(source_file) %>
41
- </td>
42
- <td class="<%= coverage_css_class(source_file.covered_percent) %> strong"><%= source_file.covered_percent.round(2).to_s %> %</td>
43
- <% runtime_percentage = result.runtime_relevant_coverage(source_file) %>
44
- <td class="<%= "#{coverage_css_class(runtime_percentage)}" %> strong">
45
- <%= "#{runtime_percentage || '0'} %" %>
46
- </td>
47
- <td><%= source_file.lines.count %></td>
48
- <td><%= source_file.covered_lines.count + source_file.missed_lines.count %></td>
49
- <td><%= source_file.covered_lines.count %></td>
50
- <td>
51
- <%= result.file_with_type(source_file, Coverband::RUNTIME_TYPE)&.covered_lines_count || 0 %>
52
- </td>
53
- <td><%= source_file.missed_lines.count %></td>
54
- <td><%= source_file.covered_strength %></td>
55
- </tr>
40
+ <% unless page %>
41
+ <% source_files.each do |source_file| %>
42
+ <tr>
43
+ <% source_class = source_file.never_loaded ? 'strong red' : 'strong'%>
44
+ <td class="<%= source_class %>">
45
+ <%= link_to_source_file(source_file) %>
46
+ </td>
47
+ <td class="<%= coverage_css_class(source_file.covered_percent) %> strong"><%= source_file.covered_percent.round(2).to_s %> %</td>
48
+ <% runtime_percentage = result.runtime_relevant_coverage(source_file) %>
49
+ <td class="<%= "#{coverage_css_class(runtime_percentage)}" %> strong">
50
+ <%= "#{runtime_percentage || '0'} %" %>
51
+ </td>
52
+ <td><%= source_file.lines.count %></td>
53
+ <td><%= source_file.covered_lines.count + source_file.missed_lines.count %></td>
54
+ <td><%= source_file.covered_lines.count %></td>
55
+ <td>
56
+ <%= result.file_with_type(source_file, Coverband::RUNTIME_TYPE)&.covered_lines_count || 0 %>
57
+ </td>
58
+ <td><%= source_file.missed_lines.count %></td>
59
+ <td><%= source_file.covered_strength %></td>
60
+ </tr>
61
+ <% end %>
56
62
  <% end %>
57
63
  </tbody>
58
64
  </table>
data/views/layout.erb CHANGED
@@ -26,9 +26,9 @@
26
26
  </div>
27
27
 
28
28
  <div class="source_files">
29
- <% result.source_files.each do |source_file| %>
30
- <%= formatted_source_file_loader(result, source_file) %>
31
- <% end %>
29
+ <% result.source_files.each do |source_file| %>
30
+ <%= formatted_source_file_loader(result, source_file) %>
31
+ <% end %>
32
32
  </div>
33
33
  </div>
34
34
  </body>