coverband 4.2.7.rc.1 → 5.0.0.rc.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) 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 +8 -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/coverband.rb +68 -44
  13. data/lib/coverband/adapters/base.rb +17 -18
  14. data/lib/coverband/adapters/file_store.rb +38 -6
  15. data/lib/coverband/adapters/hash_redis_store.rb +24 -21
  16. data/lib/coverband/adapters/redis_store.rb +12 -12
  17. data/lib/coverband/adapters/stdout_store.rb +41 -0
  18. data/lib/coverband/adapters/web_service_store.rb +155 -0
  19. data/lib/coverband/at_exit.rb +1 -1
  20. data/lib/coverband/collectors/coverage.rb +15 -27
  21. data/lib/coverband/collectors/delta.rb +29 -9
  22. data/lib/coverband/collectors/view_tracker.rb +10 -10
  23. data/lib/coverband/collectors/view_tracker_service.rb +59 -0
  24. data/lib/coverband/configuration.rb +149 -112
  25. data/lib/coverband/integrations/background.rb +6 -6
  26. data/lib/coverband/integrations/rack_server_check.rb +3 -3
  27. data/lib/coverband/integrations/resque.rb +2 -2
  28. data/lib/coverband/reporters/base.rb +11 -12
  29. data/lib/coverband/reporters/console_report.rb +1 -1
  30. data/lib/coverband/reporters/html_report.rb +10 -30
  31. data/lib/coverband/reporters/web.rb +55 -50
  32. data/lib/coverband/utils/absolute_file_converter.rb +6 -6
  33. data/lib/coverband/utils/html_formatter.rb +32 -61
  34. data/lib/coverband/utils/railtie.rb +23 -6
  35. data/lib/coverband/utils/relative_file_converter.rb +2 -2
  36. data/lib/coverband/utils/result.rb +6 -11
  37. data/lib/coverband/utils/results.rb +0 -10
  38. data/lib/coverband/utils/source_file.rb +21 -30
  39. data/lib/coverband/utils/tasks.rb +8 -11
  40. data/lib/coverband/version.rb +1 -1
  41. data/public/application.js +0 -30
  42. data/test/benchmarks/benchmark.rake +97 -92
  43. data/test/benchmarks/dog.rb +1 -1
  44. data/test/benchmarks/init_rails.rake +4 -4
  45. data/test/coverband/adapters/base_test.rb +29 -30
  46. data/test/coverband/adapters/file_store_test.rb +19 -20
  47. data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
  48. data/test/coverband/adapters/redis_store_test.rb +26 -26
  49. data/test/coverband/adapters/web_service_store_test.rb +56 -0
  50. data/test/coverband/at_exit_test.rb +2 -2
  51. data/test/coverband/collectors/coverage_test.rb +33 -47
  52. data/test/coverband/collectors/delta_test.rb +52 -23
  53. data/test/coverband/collectors/view_tracker_test.rb +35 -35
  54. data/test/coverband/configuration_test.rb +49 -36
  55. data/test/coverband/coverband_test.rb +11 -11
  56. data/test/coverband/integrations/background_middleware_test.rb +10 -10
  57. data/test/coverband/integrations/background_test.rb +17 -5
  58. data/test/coverband/integrations/rack_server_check_test.rb +7 -7
  59. data/test/coverband/integrations/report_middleware_test.rb +9 -9
  60. data/test/coverband/integrations/resque_worker_test.rb +9 -9
  61. data/test/coverband/integrations/test_resque_job.rb +1 -1
  62. data/test/coverband/reporters/base_test.rb +9 -9
  63. data/test/coverband/reporters/console_test.rb +6 -6
  64. data/test/coverband/reporters/html_test.rb +36 -48
  65. data/test/coverband/reporters/web_test.rb +16 -18
  66. data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
  67. data/test/coverband/utils/file_hasher_test.rb +6 -12
  68. data/test/coverband/utils/file_list_test.rb +13 -13
  69. data/test/coverband/utils/html_formatter_test.rb +9 -23
  70. data/test/coverband/utils/lines_classifier_test.rb +29 -29
  71. data/test/coverband/utils/relative_file_converter_test.rb +13 -13
  72. data/test/coverband/utils/result_test.rb +18 -18
  73. data/test/coverband/utils/results_test.rb +17 -17
  74. data/test/coverband/utils/source_file_line_test.rb +46 -46
  75. data/test/coverband/utils/source_file_test.rb +38 -88
  76. data/test/dog.rb +1 -1
  77. data/test/fake_app/basic_rack.rb +2 -2
  78. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  79. data/test/fixtures/app/models/user.rb +1 -1
  80. data/test/fixtures/sample.rb +1 -1
  81. data/test/fixtures/utf-8.rb +0 -2
  82. data/test/forked/rails_full_stack_test.rb +24 -27
  83. data/test/forked/rails_rake_full_stack_test.rb +7 -26
  84. data/test/integration/full_stack_test.rb +11 -22
  85. data/test/jruby_check.rb +2 -3
  86. data/test/rails4_dummy/Rakefile +1 -1
  87. data/test/rails4_dummy/config.ru +1 -1
  88. data/test/rails4_dummy/config/application.rb +4 -4
  89. data/test/rails4_dummy/config/boot.rb +2 -2
  90. data/test/rails4_dummy/config/coverband.rb +1 -1
  91. data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
  92. data/test/rails4_dummy/config/environment.rb +1 -1
  93. data/test/rails4_dummy/config/routes.rb +2 -2
  94. data/test/rails5_dummy/Rakefile +1 -1
  95. data/test/rails5_dummy/config.ru +1 -1
  96. data/test/rails5_dummy/config/application.rb +3 -3
  97. data/test/rails5_dummy/config/coverband.rb +8 -8
  98. data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
  99. data/test/rails5_dummy/config/environment.rb +1 -1
  100. data/test/rails5_dummy/config/routes.rb +2 -2
  101. data/test/rails6_dummy/Rakefile +1 -1
  102. data/test/rails6_dummy/config.ru +1 -1
  103. data/test/rails6_dummy/config/application.rb +4 -4
  104. data/test/rails6_dummy/config/boot.rb +2 -2
  105. data/test/rails6_dummy/config/coverband.rb +1 -1
  106. data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
  107. data/test/rails6_dummy/config/environment.rb +1 -1
  108. data/test/rails6_dummy/config/routes.rb +2 -2
  109. data/test/rails_test_helper.rb +11 -11
  110. data/test/test_helper.rb +44 -34
  111. data/test/unique_files.rb +10 -10
  112. data/views/layout.erb +2 -12
  113. metadata +27 -33
  114. data/.rubocop.yml +0 -84
  115. data/lib/coverband/integrations/bundler.rb +0 -8
  116. data/lib/coverband/utils/file_groups.rb +0 -53
  117. data/lib/coverband/utils/gem_list.rb +0 -31
  118. data/lib/coverband/utils/s3_report.rb +0 -105
  119. data/test/coverband/utils/file_groups_test.rb +0 -61
  120. data/test/coverband/utils/gem_list_test.rb +0 -48
  121. data/test/coverband/utils/s3_report_test.rb +0 -44
  122. data/views/gem_list.erb +0 -63
@@ -1,29 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'securerandom'
4
- require 'fileutils'
5
- require 'erb'
6
- require 'ostruct'
3
+ require "securerandom"
4
+ require "fileutils"
5
+ require "erb"
6
+ require "ostruct"
7
7
 
8
- UNIQUE_FILES_DIR = './test/unique_files'
8
+ UNIQUE_FILES_DIR = "./test/unique_files"
9
9
 
10
- def require_unique_file(file = 'dog.rb', variables = {})
10
+ def require_unique_file(file = "dog.rb", variables = {})
11
11
  uuid = SecureRandom.uuid
12
12
  dir = "#{UNIQUE_FILES_DIR}/#{uuid}"
13
- file_name = file.sub('.erb', '')
13
+ file_name = file.sub(".erb", "")
14
14
  temp_file = "#{dir}/#{file_name}"
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.open(temp_file, "w") { |w| w.write(file_contents) }
19
19
  require temp_file
20
20
  Coverband::Utils::RelativeFileConverter.convert(File.expand_path(temp_file))
21
21
  end
22
22
 
23
23
  @@dogs = 0
24
24
  def require_class_unique_file
25
- @@dogs +=1
26
- require_unique_file('dog.rb.erb', dog_number: @@dogs)
25
+ @@dogs += 1
26
+ require_unique_file("dog.rb.erb", dog_number: @@dogs)
27
27
  end
28
28
 
29
29
  def remove_unique_files
@@ -18,11 +18,7 @@
18
18
  <%= display_nav %>
19
19
 
20
20
  <div id="content">
21
- <%= formatted_file_list("All Files", result, result.source_files) unless view_gems? %>
22
-
23
- <% result.groups.each do |name, files| %>
24
- <%= formatted_file_list(name, result, files) %>
25
- <% end %>
21
+ <%= formatted_file_list("Coverage", result, result.source_files) %>
26
22
  </div>
27
23
 
28
24
  <div id="footer">
@@ -31,13 +27,7 @@
31
27
 
32
28
  <div class="source_files">
33
29
  <% result.source_files.each do |source_file| %>
34
- <% if (!source_file.gem? || (view_gems? && gem_details? && source_file.gem? )) %>
35
- <% if static_html? %>
36
- <%= formatted_source_file(result, source_file) %>
37
- <% else %>
38
- <%= formatted_source_file_loader(result, source_file) %>
39
- <% end %>
40
- <% end %>
30
+ <%= formatted_source_file_loader(result, source_file) %>
41
31
  <% end %>
42
32
  </div>
43
33
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.7.rc.1
4
+ version: 5.0.0.rc.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-11 00:00:00.000000000 Z
12
+ date: 2020-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: aws-sdk-s3
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '1'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: benchmark-ips
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +166,21 @@ dependencies:
180
166
  - !ruby/object:Gem::Version
181
167
  version: '0'
182
168
  - !ruby/object:Gem::Dependency
183
- name: rubocop
169
+ name: standard
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - '='
173
+ - !ruby/object:Gem::Version
174
+ version: 0.2.5
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - '='
180
+ - !ruby/object:Gem::Version
181
+ version: 0.2.5
182
+ - !ruby/object:Gem::Dependency
183
+ name: standardrb
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - ">="
@@ -194,7 +194,7 @@ dependencies:
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  - !ruby/object:Gem::Dependency
197
- name: rubocop-performance
197
+ name: coveralls
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - ">="
@@ -208,7 +208,7 @@ dependencies:
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  - !ruby/object:Gem::Dependency
211
- name: coveralls
211
+ name: minitest-profile
212
212
  requirement: !ruby/object:Gem::Requirement
213
213
  requirements:
214
214
  - - ">="
@@ -222,7 +222,7 @@ dependencies:
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  - !ruby/object:Gem::Dependency
225
- name: minitest-profile
225
+ name: webmock
226
226
  requirement: !ruby/object:Gem::Requirement
227
227
  requirements:
228
228
  - - ">="
@@ -258,7 +258,7 @@ extra_rdoc_files: []
258
258
  files:
259
259
  - ".gitignore"
260
260
  - ".jrubyrc"
261
- - ".rubocop.yml"
261
+ - ".standard.yml"
262
262
  - ".travis.yml"
263
263
  - CODE_OF_CONDUCT.md
264
264
  - Gemfile
@@ -277,14 +277,16 @@ files:
277
277
  - lib/coverband/adapters/file_store.rb
278
278
  - lib/coverband/adapters/hash_redis_store.rb
279
279
  - lib/coverband/adapters/redis_store.rb
280
+ - lib/coverband/adapters/stdout_store.rb
281
+ - lib/coverband/adapters/web_service_store.rb
280
282
  - lib/coverband/at_exit.rb
281
283
  - lib/coverband/collectors/coverage.rb
282
284
  - lib/coverband/collectors/delta.rb
283
285
  - lib/coverband/collectors/view_tracker.rb
286
+ - lib/coverband/collectors/view_tracker_service.rb
284
287
  - lib/coverband/configuration.rb
285
288
  - lib/coverband/integrations/background.rb
286
289
  - lib/coverband/integrations/background_middleware.rb
287
- - lib/coverband/integrations/bundler.rb
288
290
  - lib/coverband/integrations/rack_server_check.rb
289
291
  - lib/coverband/integrations/report_middleware.rb
290
292
  - lib/coverband/integrations/resque.rb
@@ -293,10 +295,8 @@ files:
293
295
  - lib/coverband/reporters/html_report.rb
294
296
  - lib/coverband/reporters/web.rb
295
297
  - lib/coverband/utils/absolute_file_converter.rb
296
- - lib/coverband/utils/file_groups.rb
297
298
  - lib/coverband/utils/file_hasher.rb
298
299
  - lib/coverband/utils/file_list.rb
299
- - lib/coverband/utils/gem_list.rb
300
300
  - lib/coverband/utils/html_formatter.rb
301
301
  - lib/coverband/utils/jruby_ext.rb
302
302
  - lib/coverband/utils/lines_classifier.rb
@@ -304,7 +304,6 @@ files:
304
304
  - lib/coverband/utils/relative_file_converter.rb
305
305
  - lib/coverband/utils/result.rb
306
306
  - lib/coverband/utils/results.rb
307
- - lib/coverband/utils/s3_report.rb
308
307
  - lib/coverband/utils/source_file.rb
309
308
  - lib/coverband/utils/tasks.rb
310
309
  - lib/coverband/version.rb
@@ -351,6 +350,7 @@ files:
351
350
  - test/coverband/adapters/file_store_test.rb
352
351
  - test/coverband/adapters/hash_redis_store_test.rb
353
352
  - test/coverband/adapters/redis_store_test.rb
353
+ - test/coverband/adapters/web_service_store_test.rb
354
354
  - test/coverband/at_exit_test.rb
355
355
  - test/coverband/collectors/coverage_test.rb
356
356
  - test/coverband/collectors/delta_test.rb
@@ -368,16 +368,13 @@ files:
368
368
  - test/coverband/reporters/html_test.rb
369
369
  - test/coverband/reporters/web_test.rb
370
370
  - test/coverband/utils/absolute_file_converter_test.rb
371
- - test/coverband/utils/file_groups_test.rb
372
371
  - test/coverband/utils/file_hasher_test.rb
373
372
  - test/coverband/utils/file_list_test.rb
374
- - test/coverband/utils/gem_list_test.rb
375
373
  - test/coverband/utils/html_formatter_test.rb
376
374
  - test/coverband/utils/lines_classifier_test.rb
377
375
  - test/coverband/utils/relative_file_converter_test.rb
378
376
  - test/coverband/utils/result_test.rb
379
377
  - test/coverband/utils/results_test.rb
380
- - test/coverband/utils/s3_report_test.rb
381
378
  - test/coverband/utils/source_file_line_test.rb
382
379
  - test/coverband/utils/source_file_test.rb
383
380
  - test/dog.rb
@@ -430,7 +427,6 @@ files:
430
427
  - test/unique_files.rb
431
428
  - views/data.erb
432
429
  - views/file_list.erb
433
- - views/gem_list.erb
434
430
  - views/layout.erb
435
431
  - views/nav.erb
436
432
  - views/settings.erb
@@ -456,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
456
452
  - !ruby/object:Gem::Version
457
453
  version: 1.3.1
458
454
  requirements: []
459
- rubygems_version: 3.0.3
455
+ rubygems_version: 3.0.6
460
456
  signing_key:
461
457
  specification_version: 4
462
458
  summary: Rack middleware to measure production code usage (LOC runtime usage)
@@ -472,6 +468,7 @@ test_files:
472
468
  - test/coverband/adapters/file_store_test.rb
473
469
  - test/coverband/adapters/hash_redis_store_test.rb
474
470
  - test/coverband/adapters/redis_store_test.rb
471
+ - test/coverband/adapters/web_service_store_test.rb
475
472
  - test/coverband/at_exit_test.rb
476
473
  - test/coverband/collectors/coverage_test.rb
477
474
  - test/coverband/collectors/delta_test.rb
@@ -489,16 +486,13 @@ test_files:
489
486
  - test/coverband/reporters/html_test.rb
490
487
  - test/coverband/reporters/web_test.rb
491
488
  - test/coverband/utils/absolute_file_converter_test.rb
492
- - test/coverband/utils/file_groups_test.rb
493
489
  - test/coverband/utils/file_hasher_test.rb
494
490
  - test/coverband/utils/file_list_test.rb
495
- - test/coverband/utils/gem_list_test.rb
496
491
  - test/coverband/utils/html_formatter_test.rb
497
492
  - test/coverband/utils/lines_classifier_test.rb
498
493
  - test/coverband/utils/relative_file_converter_test.rb
499
494
  - test/coverband/utils/result_test.rb
500
495
  - test/coverband/utils/results_test.rb
501
- - test/coverband/utils/s3_report_test.rb
502
496
  - test/coverband/utils/source_file_line_test.rb
503
497
  - test/coverband/utils/source_file_test.rb
504
498
  - test/dog.rb
@@ -1,84 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
3
- Exclude:
4
- - vendor/bundle/**/*
5
- - docs/**/*
6
- - test/rails6_dummy/**/*
7
- - test/rails5_dummy/**/*
8
- - test/fixtures/**/*
9
- # Get the code passing first then we will enable for tests
10
- - test/**/*
11
- Documentation:
12
- Enabled: false
13
- Metrics/MethodLength:
14
- Enabled: false
15
- Layout/LineLength:
16
- Max: 160
17
- Metrics/BlockNesting:
18
- Max: 5
19
- Metrics/BlockLength:
20
- Max: 30
21
- Metrics/CyclomaticComplexity:
22
- Enabled: false
23
- Metrics/PerceivedComplexity:
24
- Enabled: false
25
- Metrics/AbcSize:
26
- Enabled: false
27
- Metrics/ClassLength:
28
- Enabled: false
29
- Metrics/ModuleLength:
30
- Enabled: false
31
- Metrics/ParameterLists:
32
- Max: 10
33
- Naming/AccessorMethodName:
34
- Enabled: false
35
- Naming/RescuedExceptionsVariableName:
36
- Enabled: false
37
- Naming/PredicateName:
38
- Enabled: true
39
- Style/TernaryParentheses:
40
- Enabled: false
41
- Style/MutableConstant:
42
- Enabled: false
43
- Style/IdenticalConditionalBranches:
44
- Enabled: false
45
- Style/ClassVars:
46
- Enabled: false
47
- Style/MultilineBlockChain:
48
- Enabled: false
49
- Style/StringLiterals:
50
- Enabled: false
51
- Style/IfInsideElse:
52
- Enabled: false
53
- Style/FrozenStringLiteralComment:
54
- Enabled: true
55
- Style/GuardClause:
56
- Enabled: true
57
- Style/NumericPredicate:
58
- Enabled: true
59
- Style/NumericLiterals:
60
- Enabled: false
61
- Style/NumericLiteralPrefix:
62
- Enabled: false
63
- Style/ClassAndModuleChildren:
64
- Enabled: false
65
- Style/SymbolArray:
66
- Enabled: false
67
- Style/SymbolProc:
68
- Enabled: false
69
- Style/RegexpLiteral:
70
- Enabled: false
71
- Layout/MultilineMethodCallIndentation:
72
- Enabled: true
73
- Layout/MultilineOperationIndentation:
74
- Enabled: true
75
- Lint/RescueException:
76
- Enabled: true
77
- Lint/UselessAccessModifier:
78
- Enabled: true
79
- Lint/ShadowingOuterLocalVariable:
80
- Enabled: true
81
- Style/FormatString:
82
- Enabled: true
83
- Security/Eval:
84
- Enabled: true
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BundlerEagerLoad
4
- def require(*groups)
5
- Coverband.eager_loading_coverage { super }
6
- end
7
- end
8
- Bundler.singleton_class.prepend BundlerEagerLoad
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #
4
- # Applies the configured groups to the given array of Coverband::SourceFile items
5
- #
6
- module Coverband
7
- module Utils
8
- class FileGroups
9
- def initialize(files)
10
- @grouped = {}
11
- @files = files
12
- filter_to_groups
13
- end
14
-
15
- def grouped_results
16
- @grouped
17
- end
18
-
19
- private
20
-
21
- def filter_to_groups
22
- grouped_files = []
23
- Coverband.configuration.groups.each do |name, filter|
24
- if name == 'Gems'
25
- gem_lists = gem_files(name, filter)
26
- grouped_files.concat(gem_lists.flatten) if gem_lists.flatten.any?
27
- else
28
- app_files(name, filter)
29
- grouped_files += @grouped[name]
30
- end
31
- end
32
- if !Coverband.configuration.groups.empty? && !(other_files = @files.reject do |source_file|
33
- grouped_files.include?(source_file)
34
- end).empty?
35
- @grouped['Ungrouped'] = Coverband::Utils::FileList.new(other_files)
36
- end
37
- end
38
-
39
- def gem_files(name, filter)
40
- grouped_gems = @files.select { |source_file| source_file.filename =~ /#{filter}/ }.group_by(&:gem_name)
41
- gem_lists = grouped_gems.values.map { |gem_files| Coverband::Utils::FileList.new(gem_files) }
42
- @grouped[name] = Coverband::Utils::GemList.new(gem_lists) if gem_lists.flatten.any?
43
- gem_lists
44
- end
45
-
46
- def app_files(name, filter)
47
- @grouped[name] = Coverband::Utils::FileList.new(@files.select do |source_file|
48
- source_file.filename =~ /#{filter}/ && source_file.filename !~ /#{Coverband.configuration.gem_paths.first}/
49
- end)
50
- end
51
- end
52
- end
53
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ####
4
- # An array of FileLists instances with helpers to roll up the stats
5
- # methods for calculating coverage across them etc.
6
- ####
7
- module Coverband
8
- module Utils
9
- class GemList < FileList
10
- # Returns the count of lines that have coverage
11
- def covered_lines
12
- to_a.map(&:covered_lines).inject(:+)
13
- end
14
-
15
- # Returns the count of lines that have been missed
16
- def missed_lines
17
- to_a.map(&:missed_lines).inject(:+)
18
- end
19
-
20
- # Returns the count of lines that are not relevant for coverage
21
- def never_lines
22
- to_a.map(&:never_lines).inject(:+)
23
- end
24
-
25
- # Returns the count of skipped lines
26
- def skipped_lines
27
- to_a.map(&:skipped_lines).inject(:+)
28
- end
29
- end
30
- end
31
- end
@@ -1,105 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Coverband
4
- module Utils
5
- ###
6
- # TODO: this is currently a html report writer
7
- # this should support writing coverage the current method should be fine
8
- # to write every report to S3 and sum them later or use the 2 pass
9
- # method we do for redis if in a background thread
10
- ###
11
- class S3Report
12
- def self.instance
13
- s3_options = {
14
- region: Coverband.configuration.s3_region,
15
- access_key_id: Coverband.configuration.s3_access_key_id,
16
- secret_access_key: Coverband.configuration.s3_secret_access_key
17
- }
18
- new(Coverband.configuration.s3_bucket, s3_options)
19
- end
20
-
21
- def initialize(bucket_name, options = {})
22
- @bucket_name = bucket_name
23
- @region = options[:region]
24
- @access_key_id = options[:access_key_id]
25
- @secret_access_key = options[:secret_access_key]
26
- begin
27
- require 'aws-sdk-s3'
28
- rescue StandardError
29
- err_msg = 'Coverband requires aws-sdk in order use S3Report.'
30
- Coverband.configuration.logger&.error err_msg
31
- end
32
- end
33
-
34
- def persist!
35
- if defined?(Aws)
36
- object.put(body: coverage_content)
37
- else
38
- object.write(coverage_content)
39
- end
40
- end
41
-
42
- def retrieve
43
- if defined?(Aws)
44
- s3_client.get_object(bucket: Coverband.configuration.s3_bucket,
45
- key: 'coverband/index.html').body.read
46
- else
47
- object.read
48
- end
49
- end
50
-
51
- private
52
-
53
- def coverage_content
54
- version = Coverband::VERSION
55
- File.read("#{Coverband.configuration.root}/coverage/index.html").gsub("./assets/#{version}/", '')
56
- end
57
-
58
- def object
59
- if defined?(Aws)
60
- bucket.object('coverband/index.html')
61
- else
62
- bucket.objects['coverband/index.html']
63
- end
64
- end
65
-
66
- def client_options
67
- {
68
- region: @region,
69
- access_key_id: @access_key_id,
70
- secret_access_key: @secret_access_key
71
- }
72
- end
73
-
74
- def s3_client
75
- if defined?(Aws)
76
- # AWS SDK v2
77
- Aws::S3::Client.new(client_options)
78
- else
79
- # AWS SDK v1
80
- AWS::S3::Client.new(client_options)
81
- end
82
- end
83
-
84
- def s3
85
- resource_options = { client: s3_client }
86
- resource_options = {} if client_options.values.any?(&:nil?)
87
- if defined?(Aws)
88
- # AWS SDK v2
89
- Aws::S3::Resource.new(resource_options)
90
- else
91
- # AWS SDK v1
92
- AWS::S3.new(resource_options)
93
- end
94
- end
95
-
96
- def bucket
97
- if defined?(Aws)
98
- s3.bucket(@bucket_name)
99
- else
100
- s3.buckets[@bucket_name]
101
- end
102
- end
103
- end
104
- end
105
- end