coverband 4.2.1 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -9
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/README.md +32 -28
  5. data/changes.md +31 -11
  6. data/coverband.gemspec +0 -5
  7. data/lib/coverband/adapters/base.rb +8 -13
  8. data/lib/coverband/adapters/file_store.rb +10 -4
  9. data/lib/coverband/adapters/hash_redis_store.rb +182 -0
  10. data/lib/coverband/adapters/redis_store.rb +15 -1
  11. data/lib/coverband/collectors/coverage.rb +5 -7
  12. data/lib/coverband/collectors/view_tracker.rb +124 -0
  13. data/lib/coverband/configuration.rb +21 -1
  14. data/lib/coverband/integrations/background.rb +2 -1
  15. data/lib/coverband/reporters/base.rb +4 -5
  16. data/lib/coverband/reporters/console_report.rb +1 -0
  17. data/lib/coverband/reporters/web.rb +6 -0
  18. data/lib/coverband/utils/absolute_file_converter.rb +47 -0
  19. data/lib/coverband/utils/file_hasher.rb +16 -0
  20. data/lib/coverband/utils/html_formatter.rb +12 -0
  21. data/lib/coverband/utils/railtie.rb +15 -3
  22. data/lib/coverband/utils/relative_file_converter.rb +41 -0
  23. data/lib/coverband/utils/s3_report.rb +2 -2
  24. data/lib/coverband/utils/source_file.rb +1 -3
  25. data/lib/coverband/utils/tasks.rb +1 -0
  26. data/lib/coverband/version.rb +5 -1
  27. data/lib/coverband.rb +7 -1
  28. data/public/application.css +6 -6
  29. data/test/benchmarks/benchmark.rake +25 -49
  30. data/test/benchmarks/init_rails.rake +10 -0
  31. data/test/coverband/adapters/hash_redis_store_test.rb +190 -0
  32. data/test/coverband/adapters/redis_store_test.rb +90 -88
  33. data/test/coverband/collectors/coverage_test.rb +6 -2
  34. data/test/coverband/collectors/view_tracker_test.rb +77 -0
  35. data/test/coverband/integrations/resque_worker_test.rb +2 -3
  36. data/test/coverband/reporters/base_test.rb +1 -78
  37. data/test/coverband/reporters/console_test.rb +1 -4
  38. data/test/coverband/reporters/html_test.rb +9 -9
  39. data/test/coverband/utils/absolute_file_converter_test.rb +56 -0
  40. data/test/coverband/utils/file_hasher_test.rb +29 -0
  41. data/test/coverband/utils/relative_file_converter_test.rb +39 -0
  42. data/test/forked/rails_rake_full_stack_test.rb +9 -1
  43. data/test/integration/full_stack_test.rb +1 -2
  44. data/test/test_helper.rb +6 -7
  45. data/test/unique_files.rb +1 -1
  46. data/views/layout.erb +1 -20
  47. data/views/nav.erb +35 -0
  48. data/views/view_tracker.erb +37 -0
  49. metadata +22 -31
  50. data/lib/coverband/utils/file_path_helper.rb +0 -68
@@ -52,9 +52,9 @@ class ReportHTMLTest < Minitest::Test
52
52
  filename = basic_coverage_file_full_path
53
53
  base_path = '/coverage'
54
54
  html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
55
- filename: filename,
56
- base_path: base_path,
57
- open_report: false).file_details
55
+ filename: filename,
56
+ base_path: base_path,
57
+ open_report: false).file_details
58
58
  assert_match 'Coverage first seen', html
59
59
  end
60
60
 
@@ -64,9 +64,9 @@ class ReportHTMLTest < Minitest::Test
64
64
  filename = 'missing_path'
65
65
  base_path = '/coverage'
66
66
  html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
67
- filename: filename,
68
- base_path: base_path,
69
- open_report: false).file_details
67
+ filename: filename,
68
+ base_path: base_path,
69
+ open_report: false).file_details
70
70
  assert_match 'File No Longer Available', html
71
71
  end
72
72
 
@@ -76,9 +76,9 @@ class ReportHTMLTest < Minitest::Test
76
76
  filename = "#{test_root}/test_helper.rb"
77
77
  base_path = '/coverage'
78
78
  html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
79
- filename: filename,
80
- base_path: base_path,
81
- open_report: false).file_details
79
+ filename: filename,
80
+ base_path: base_path,
81
+ open_report: false).file_details
82
82
  assert_match 'File No Longer Available', html
83
83
  end
84
84
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
+
5
+ module Coverband
6
+ module Utils
7
+ class AbsoluteFileConverterTest < ::Minitest::Test
8
+ def test_convert
9
+ converter = AbsoluteFileConverter.new([FileUtils.pwd])
10
+ assert_equal("#{FileUtils.pwd}/lib/coverband.rb", converter.convert('./lib/coverband.rb'))
11
+ end
12
+
13
+ def test_convert_multiple_roots
14
+ converter = AbsoluteFileConverter.new(['/foo/bar', FileUtils.pwd])
15
+ assert_equal("#{FileUtils.pwd}/Rakefile", converter.convert('./Rakefile'))
16
+ end
17
+
18
+ test 'relative_path_to_full leave filename from a key with a local path' do
19
+ converter = AbsoluteFileConverter.new(['/app/', '/full/remote_app/path/'])
20
+ assert_equal '/full/remote_app/path/is/a/path.rb', converter.convert('/full/remote_app/path/is/a/path.rb')
21
+ end
22
+
23
+ test 'relative_path_to_full fix filename from a key with a swappable path' do
24
+ key = '/app/is/a/path.rb'
25
+ converter = AbsoluteFileConverter.new(['/app/', '/full/remote_app/path/'])
26
+ expected_path = '/full/remote_app/path/is/a/path.rb'
27
+ File.expects(:exist?).with(key).returns(false)
28
+ File.expects(:exist?).with(expected_path).returns(true)
29
+ assert_equal expected_path, converter.convert(key)
30
+ end
31
+
32
+ test 'relative_path_to_full fix filename a changing deploy path with quotes' do
33
+ converter = AbsoluteFileConverter.new(['/box/apps/app_name/releases/\\d+/', '/full/remote_app/path/'])
34
+ expected_path = '/full/remote_app/path/app/models/user.rb'
35
+ key = '/box/apps/app_name/releases/20140725203539/app/models/user.rb'
36
+ File.expects(:exist?).with('/box/apps/app_name/releases/\\d+/app/models/user.rb').returns(false)
37
+ File.expects(:exist?).with(expected_path).returns(true)
38
+ assert_equal expected_path, converter.convert(key)
39
+ assert_equal expected_path, converter.convert(key)
40
+ end
41
+
42
+ test 'relative_path_to_full fix filename a changing deploy path real world examples' do
43
+ current_app_root = '/var/local/company/company.d/79'
44
+ converter = AbsoluteFileConverter.new(['/var/local/company/company.d/[0-9]*/', "#{current_app_root}/"])
45
+
46
+ expected_path = '/var/local/company/company.d/79/app/controllers/dashboard_controller.rb'
47
+ key = '/var/local/company/company.d/78/app/controllers/dashboard_controller.rb'
48
+ File.expects(:exist?).with('/var/local/company/company.d/[0-9]*/app/controllers/dashboard_controller.rb').returns(false)
49
+ File.expects(:exist?).with(expected_path).returns(true)
50
+ roots = ['/var/local/company/company.d/[0-9]*/', "#{current_app_root}/"]
51
+ assert_equal expected_path, converter.convert(key)
52
+ assert_equal expected_path, converter.convert(key)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
+
5
+ module Coverband
6
+ module Utils
7
+ class FileHasherTest < Minitest::Test
8
+ def test_hash_same_file
9
+ refute_nil FileHasher.hash('./test/dog.rb')
10
+ assert_equal(FileHasher.hash('./test/dog.rb'), FileHasher.hash('./test/dog.rb'))
11
+ assert_equal(FileHasher.hash(File.expand_path('./test/dog.rb')), FileHasher.hash('./test/dog.rb'))
12
+ end
13
+
14
+ def test_hash_different_files
15
+ refute_equal(FileHasher.hash('./test/dog.rb'), FileHasher.hash('./lib/coverband.rb'))
16
+ end
17
+
18
+ def test_hash_file_not_exists
19
+ assert_nil(FileHasher.hash('./made_up_file.py'))
20
+ end
21
+
22
+ def test_hash_gem_file
23
+ spec = Gem::Specification.find_by_name('rainbow')
24
+ assert FileHasher.hash("./gems/rainbow-#{spec.version}/lib/rainbow.rb",
25
+ path_converter: AbsoluteFileConverter.new(Coverband.configuration.gem_paths))
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
+
5
+ module Coverband
6
+ module Utils
7
+ class RelativeFileConverterTest < ::Minitest::Test
8
+ def test_convert
9
+ converter = RelativeFileConverter.new(['/bar/tmp/'])
10
+ assert_equal('./gracie.rb', converter.convert('/bar/tmp/gracie.rb'))
11
+ end
12
+
13
+ def test_convert_without_leading_forward_slash
14
+ converter = RelativeFileConverter.new(['/foo/bar'])
15
+ assert_equal('./file.rb', converter.convert('/foo/bar/file.rb'))
16
+ end
17
+
18
+ def test_multiple_roots
19
+ converter = RelativeFileConverter.new(['/bar/tmp/', '/foo/bar/'])
20
+ assert_equal('./josie.rb', converter.convert('/foo/bar/josie.rb'))
21
+ end
22
+
23
+ def test_no_match
24
+ converter = RelativeFileConverter.new(['/bar/tmp/', '/foo/bar/'])
25
+ assert_equal('/foo/josie.rb', converter.convert('/foo/josie.rb'))
26
+ end
27
+
28
+ def test_middle_path_match
29
+ converter = RelativeFileConverter.new(['/bar/tmp/', '/foo/bar/'])
30
+ assert_equal('/tmp/foo/bar/josie.rb', converter.convert('/tmp/foo/bar/josie.rb'))
31
+ end
32
+
33
+ def test_already_relative_file
34
+ converter = RelativeFileConverter.new(['/bar/tmp/', '/foo/bar/'])
35
+ assert_equal('./foo/bar/josie.rb', converter.convert('./foo/bar/josie.rb'))
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,7 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('../rails_test_helper', File.dirname(__FILE__))
2
4
  require 'rails'
5
+ require 'pundit'
3
6
 
4
7
  class RailsRakeFullStackTest < Minitest::Test
8
+ def setup
9
+ super
10
+ Coverband.configuration.reset
11
+ Coverband.configure("./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband.rb")
12
+ end
5
13
 
6
14
  test 'rake tasks shows coverage properly within eager_loading' do
7
15
  store.instance_variable_set(:@redis_namespace, 'coverband_test')
@@ -18,7 +26,7 @@ class RailsRakeFullStackTest < Minitest::Test
18
26
  store.type = Coverband::RUNTIME_TYPE
19
27
  if ENV['SIMULATE_ONESHOT']
20
28
  pundit_coverage = store.get_coverage_report[Coverband::RUNTIME_TYPE][pundit_file]
21
- assert pundit_coverage['data'].compact.all? { |el| el == 0}
29
+ assert pundit_coverage['data'].compact.all? { |el| el == 0 }
22
30
  else
23
31
  pundit_coverage = store.coverage[pundit_file]
24
32
  assert_nil pundit_coverage
@@ -11,10 +11,9 @@ class FullStackTest < Minitest::Test
11
11
  super
12
12
  Coverband::Collectors::Coverage.instance.reset_instance
13
13
  Coverband.configure do |config|
14
- config.store = Coverband::Adapters::RedisStore.new(Redis.new(), redis_namespace: 'coverband_test')
14
+ config.store = Coverband::Adapters::RedisStore.new(Redis.new, redis_namespace: 'coverband_test')
15
15
  config.s3_bucket = nil
16
16
  config.background_reporting_enabled = true
17
- config.root_paths = ["#{File.expand_path('../', File.dirname(__FILE__))}/"]
18
17
  config.track_gems = true
19
18
  end
20
19
  Coverband.configuration.store.clear!
data/test/test_helper.rb CHANGED
@@ -28,19 +28,20 @@ unless ENV['ONESHOT'] || ENV['SIMULATE_ONESHOT']
28
28
  Coveralls.wear!
29
29
  end
30
30
 
31
-
32
31
  module Coverband
33
32
  module Test
34
33
  def self.reset
35
34
  Coverband.configuration.redis_namespace = 'coverband_test'
36
35
  Coverband.configuration.store.instance_variable_set(:@redis_namespace, 'coverband_test')
37
36
  Coverband.configuration.store.class.class_variable_set(:@@path_cache, {})
38
- [:eager_loading, :runtime].each do |type|
37
+ %i[eager_loading runtime].each do |type|
39
38
  Coverband.configuration.store.type = type
40
39
  Coverband.configuration.store.clear!
41
40
  end
42
41
  Coverband.configuration.reset
43
42
  Coverband::Collectors::Coverage.instance.reset_instance
43
+ Coverband::Utils::RelativeFileConverter.reset
44
+ Coverband::Utils::AbsoluteFileConverter.reset
44
45
  Coverband.configuration.redis_namespace = 'coverband_test'
45
46
  Coverband::Background.stop
46
47
  end
@@ -82,10 +83,8 @@ def test(name, &block)
82
83
  end
83
84
  end
84
85
 
85
- def mock_file_hash
86
- mock_file = mock('mock_file')
87
- mock_file.expects(:hexdigest).at_least_once.returns('abcd')
88
- Digest::MD5.expects(:file).at_least_once.returns(mock_file)
86
+ def mock_file_hash(hash: 'abcd')
87
+ Coverband::Utils::FileHasher.expects(:hash).at_least_once.returns(hash)
89
88
  end
90
89
 
91
90
  def example_line
@@ -124,7 +123,7 @@ end
124
123
  # This handles an issue where the store is setup in tests prior to being able to set the namespace
125
124
  ###
126
125
  def store
127
- if Coverband.configuration.store.redis_namespace=='coverband_test'
126
+ if Coverband.configuration.store.redis_namespace == 'coverband_test'
128
127
  Coverband.configuration.store
129
128
  else
130
129
  Coverband.configuration.redis_namespace = 'coverband_test'
data/test/unique_files.rb CHANGED
@@ -17,7 +17,7 @@ def require_unique_file(file = 'dog.rb', variables = {})
17
17
  file_contents = ERB.new(file_contents).result(OpenStruct.new(variables).instance_eval { binding }) if variables.any?
18
18
  File.open(temp_file, 'w') { |w| w.write(file_contents) }
19
19
  require temp_file
20
- Coverband::Utils::FilePathHelper.full_path_to_relative(File.expand_path(temp_file))
20
+ Coverband::Utils::RelativeFileConverter.convert(File.expand_path(temp_file))
21
21
  end
22
22
 
23
23
  def remove_unique_files
data/views/layout.erb CHANGED
@@ -15,26 +15,7 @@
15
15
  <img src="<%= assets_path('loading.gif') %>" alt="loading"/>
16
16
  </div>
17
17
  <div id="wrapper" style="display:none;">
18
- <div id="header">
19
- <a href='<%= base_path %>'>Coverband Admin</a> &nbsp;
20
- <a href='<%= base_path %>settings'>Info</a> &nbsp;
21
- <% if Coverband.configuration.web_enable_clear %>
22
- <%= button("#{base_path}clear", 'clear coverage report', delete: true) %>
23
- <% end %>
24
- <% if Coverband.configuration.web_debug %>
25
- <a href='<%= base_path %>debug_data'>Debug Data</a> &nbsp;
26
- <% end %>
27
- </div>
28
- <% if notice.to_s.length > 0 %>
29
- <div class="notice"><%= notice %></div>
30
- <% end %>
31
- <div class="timestamp">Generated <%= timeago(Time.now) %></div>
32
- <br/>
33
- <div class="timestamp">
34
- Coverage Recording Started: <%= timeago(result.source_files.first_seen_at) %>
35
- </div>
36
-
37
- <ul class="group_tabs"></ul>
18
+ <%= display_nav %>
38
19
 
39
20
  <div id="content">
40
21
  <%= formatted_file_list("All Files", result, result.source_files) unless view_gems? %>
data/views/nav.erb ADDED
@@ -0,0 +1,35 @@
1
+
2
+ <div id="header">
3
+ <a href='<%= base_path %>'>Coverband Admin</a> &nbsp;
4
+ <a href='<%= base_path %>settings'>Info</a> &nbsp;
5
+ <% if Coverband.configuration.web_enable_clear %>
6
+ <%= button("#{base_path}clear", 'clear coverage report', delete: true) %>
7
+ <% end %>
8
+ <% if Coverband.configuration.web_debug %>
9
+ <a href='<%= base_path %>debug_data'>Debug Data</a> &nbsp;
10
+ <% end %>
11
+ </div>
12
+ <% if notice.to_s.length > 0 %>
13
+ <div class="notice"><%= notice %></div>
14
+ <% end %>
15
+ <div class="timestamp">Generated <%= timeago(Time.now) %></div>
16
+ <br/>
17
+ <% if defined?(result) %>
18
+ <div class="timestamp">
19
+ Coverage Recording Started: <%= timeago(result.source_files.first_seen_at) %>
20
+ </div>
21
+ <% end %>
22
+
23
+ <ul class="group_tabs">
24
+ </ul>
25
+
26
+ <ul class="extra_tabs">
27
+ <% if nav_options[:show_coverage_link] %>
28
+ <li><a href='<%= base_path %>'>Coverage</a></li>
29
+ <% end %>
30
+ <% if Coverband.configuration.track_views %>
31
+ <li class='<%= nav_options[:show_coverage_link] ? 'active' : '' %>'>
32
+ <a href='<%= base_path %>view_tracker'>Views Tracker</a>
33
+ </li>
34
+ <% end %>
35
+ </ul>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>Coverband Info: <%= Coverband::VERSION %></title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <script src='<%= assets_path('application.js') %>' type='text/javascript'></script>
7
+ <link href='<%= assets_path('application.css') %>' media='screen, projection, print' rel='stylesheet' type='text/css'>
8
+ <link rel="icon" type="image/png" href="<%= assets_path('favicon.png') %>" />
9
+ </head>
10
+
11
+ <body>
12
+ <div id="wrapper" style="">
13
+ <%= display_nav(show_coverage_link: true) %>
14
+ <div id="content">
15
+ <% tracker = Coverband::Collectors::ViewTracker.new(store: Coverband.configuration.store) %>
16
+ <h2>Unused Views: (<%= tracker.unused_views.length %>)</h2>
17
+ <p>These views have never been rendered</p>
18
+ <ul>
19
+ <% tracker.unused_views.each do |view_file| %>
20
+ <li><%= view_file %></li>
21
+ <% end %>
22
+ </ul>
23
+
24
+ <h2>Used Views: (<%= tracker.used_views.length %>)</h2>
25
+ <p>These views have been rendered at least once</p>
26
+ <ul>
27
+ <% tracker.used_views.each do |view_file| %>
28
+ <li><%= view_file %></li>
29
+ <% end %>
30
+ </ul>
31
+ </div>
32
+ <div id="footer">
33
+ Generated by <a href="http://github.com/danmayer/coverband">Coverband</a> v<%= Coverband::VERSION %>
34
+ </div>
35
+ </div>
36
+ </body>
37
+ </html>
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.1
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-28 00:00:00.000000000 Z
12
+ date: 2019-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-s3
@@ -193,34 +193,6 @@ dependencies:
193
193
  - - ">="
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
- - !ruby/object:Gem::Dependency
197
- name: minitest-reporters
198
- requirement: !ruby/object:Gem::Requirement
199
- requirements:
200
- - - ">="
201
- - !ruby/object:Gem::Version
202
- version: '0'
203
- type: :development
204
- prerelease: false
205
- version_requirements: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - ">="
208
- - !ruby/object:Gem::Version
209
- version: '0'
210
- - !ruby/object:Gem::Dependency
211
- name: classifier-reborn
212
- requirement: !ruby/object:Gem::Requirement
213
- requirements:
214
- - - ">="
215
- - !ruby/object:Gem::Version
216
- version: '0'
217
- type: :development
218
- prerelease: false
219
- version_requirements: !ruby/object:Gem::Requirement
220
- requirements:
221
- - - ">="
222
- - !ruby/object:Gem::Version
223
- version: '0'
224
196
  - !ruby/object:Gem::Dependency
225
197
  name: coveralls
226
198
  requirement: !ruby/object:Gem::Requirement
@@ -287,6 +259,7 @@ files:
287
259
  - ".gitignore"
288
260
  - ".rubocop.yml"
289
261
  - ".travis.yml"
262
+ - CODE_OF_CONDUCT.md
290
263
  - Gemfile
291
264
  - Gemfile.rails4
292
265
  - LICENSE
@@ -299,10 +272,12 @@ files:
299
272
  - lib/coverband.rb
300
273
  - lib/coverband/adapters/base.rb
301
274
  - lib/coverband/adapters/file_store.rb
275
+ - lib/coverband/adapters/hash_redis_store.rb
302
276
  - lib/coverband/adapters/redis_store.rb
303
277
  - lib/coverband/at_exit.rb
304
278
  - lib/coverband/collectors/coverage.rb
305
279
  - lib/coverband/collectors/delta.rb
280
+ - lib/coverband/collectors/view_tracker.rb
306
281
  - lib/coverband/configuration.rb
307
282
  - lib/coverband/integrations/background.rb
308
283
  - lib/coverband/integrations/background_middleware.rb
@@ -314,13 +289,15 @@ files:
314
289
  - lib/coverband/reporters/console_report.rb
315
290
  - lib/coverband/reporters/html_report.rb
316
291
  - lib/coverband/reporters/web.rb
292
+ - lib/coverband/utils/absolute_file_converter.rb
317
293
  - lib/coverband/utils/file_groups.rb
294
+ - lib/coverband/utils/file_hasher.rb
318
295
  - lib/coverband/utils/file_list.rb
319
- - lib/coverband/utils/file_path_helper.rb
320
296
  - lib/coverband/utils/gem_list.rb
321
297
  - lib/coverband/utils/html_formatter.rb
322
298
  - lib/coverband/utils/lines_classifier.rb
323
299
  - lib/coverband/utils/railtie.rb
300
+ - lib/coverband/utils/relative_file_converter.rb
324
301
  - lib/coverband/utils/result.rb
325
302
  - lib/coverband/utils/results.rb
326
303
  - lib/coverband/utils/s3_report.rb
@@ -358,12 +335,15 @@ files:
358
335
  - test/benchmarks/coverage_fork.sh
359
336
  - test/benchmarks/dog.rb
360
337
  - test/benchmarks/graph_bench.sh
338
+ - test/benchmarks/init_rails.rake
361
339
  - test/coverband/adapters/base_test.rb
362
340
  - test/coverband/adapters/file_store_test.rb
341
+ - test/coverband/adapters/hash_redis_store_test.rb
363
342
  - test/coverband/adapters/redis_store_test.rb
364
343
  - test/coverband/at_exit_test.rb
365
344
  - test/coverband/collectors/coverage_test.rb
366
345
  - test/coverband/collectors/delta_test.rb
346
+ - test/coverband/collectors/view_tracker_test.rb
367
347
  - test/coverband/configuration_test.rb
368
348
  - test/coverband/coverband_test.rb
369
349
  - test/coverband/integrations/background_middleware_test.rb
@@ -376,11 +356,14 @@ files:
376
356
  - test/coverband/reporters/console_test.rb
377
357
  - test/coverband/reporters/html_test.rb
378
358
  - test/coverband/reporters/web_test.rb
359
+ - test/coverband/utils/absolute_file_converter_test.rb
379
360
  - test/coverband/utils/file_groups_test.rb
361
+ - test/coverband/utils/file_hasher_test.rb
380
362
  - test/coverband/utils/file_list_test.rb
381
363
  - test/coverband/utils/gem_list_test.rb
382
364
  - test/coverband/utils/html_formatter_test.rb
383
365
  - test/coverband/utils/lines_classifier_test.rb
366
+ - test/coverband/utils/relative_file_converter_test.rb
384
367
  - test/coverband/utils/result_test.rb
385
368
  - test/coverband/utils/results_test.rb
386
369
  - test/coverband/utils/s3_report_test.rb
@@ -423,9 +406,11 @@ files:
423
406
  - views/file_list.erb
424
407
  - views/gem_list.erb
425
408
  - views/layout.erb
409
+ - views/nav.erb
426
410
  - views/settings.erb
427
411
  - views/source_file.erb
428
412
  - views/source_file_loader.erb
413
+ - views/view_tracker.erb
429
414
  homepage: https://github.com/danmayer/coverband
430
415
  licenses:
431
416
  - MIT
@@ -455,12 +440,15 @@ test_files:
455
440
  - test/benchmarks/coverage_fork.sh
456
441
  - test/benchmarks/dog.rb
457
442
  - test/benchmarks/graph_bench.sh
443
+ - test/benchmarks/init_rails.rake
458
444
  - test/coverband/adapters/base_test.rb
459
445
  - test/coverband/adapters/file_store_test.rb
446
+ - test/coverband/adapters/hash_redis_store_test.rb
460
447
  - test/coverband/adapters/redis_store_test.rb
461
448
  - test/coverband/at_exit_test.rb
462
449
  - test/coverband/collectors/coverage_test.rb
463
450
  - test/coverband/collectors/delta_test.rb
451
+ - test/coverband/collectors/view_tracker_test.rb
464
452
  - test/coverband/configuration_test.rb
465
453
  - test/coverband/coverband_test.rb
466
454
  - test/coverband/integrations/background_middleware_test.rb
@@ -473,11 +461,14 @@ test_files:
473
461
  - test/coverband/reporters/console_test.rb
474
462
  - test/coverband/reporters/html_test.rb
475
463
  - test/coverband/reporters/web_test.rb
464
+ - test/coverband/utils/absolute_file_converter_test.rb
476
465
  - test/coverband/utils/file_groups_test.rb
466
+ - test/coverband/utils/file_hasher_test.rb
477
467
  - test/coverband/utils/file_list_test.rb
478
468
  - test/coverband/utils/gem_list_test.rb
479
469
  - test/coverband/utils/html_formatter_test.rb
480
470
  - test/coverband/utils/lines_classifier_test.rb
471
+ - test/coverband/utils/relative_file_converter_test.rb
481
472
  - test/coverband/utils/result_test.rb
482
473
  - test/coverband/utils/results_test.rb
483
474
  - test/coverband/utils/s3_report_test.rb
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ####
4
- # Helper functions for shared logic related to file path manipulation
5
- ####
6
- module Coverband
7
- module Utils
8
- module FilePathHelper
9
- module_function
10
-
11
- @@path_cache = {}
12
-
13
- ###
14
- # Takes a full path and converts to a relative path
15
- ###
16
- def full_path_to_relative(full_path)
17
- return @@path_cache[full_path] if @@path_cache.key?(full_path)
18
-
19
- relative_filename = full_path
20
- Coverband.configuration.all_root_patterns.each do |root|
21
- relative_filename = relative_filename.sub(root, './')
22
- # once we have a relative path break out of the loop
23
- break if relative_filename.start_with? './'
24
- end
25
-
26
- @@path_cache[full_path] = relative_filename
27
-
28
- relative_filename
29
- end
30
-
31
- ###
32
- # relative_path_to_full code takes:
33
- # relative_path: which is a full path the same as reported by Coverage
34
- # roots: if a collection of all possible full app paths
35
- # EX: [Coverband.configuration.root_paths, "#{current_root}/"]
36
- # The LAST item should be the current file system root
37
- # it expands that expands and adds a '/' as that isn't there from Dir.pwd
38
- #
39
- # NOTEs on configuration.root_paths usage
40
- # strings: matching is pretty simple for full string paths
41
- # regex: to get regex to work for changing deploy directories
42
- # the regex must be double escaped in double quotes
43
- # (if using \d for example)
44
- # or use single qoutes
45
- # example: '/box/apps/app_name/releases/\d+/'
46
- # example: '/var/local/company/company.d/[0-9]*/'
47
- ###
48
- def relative_path_to_full(relative_path, roots)
49
- relative_filename = relative_path
50
- local_filename = relative_filename
51
- roots.each do |root|
52
- relative_filename = relative_filename.sub(/^#{root}/, './')
53
- # once we have a relative path break out of the loop
54
- break if relative_filename.start_with? './'
55
- end
56
- # the filename for our reports is expected to be a full path.
57
- # roots.last should be roots << current_root}/
58
- # a fully expanded path of config.root
59
- # filename = filename.gsub('./', roots.last)
60
- # above only works for app files
61
- # we need to rethink some of this logic
62
- # gems aren't at project root and can have multiple locations
63
- local_root = roots.find { |root| File.exist?(relative_filename.gsub('./', root)) }
64
- local_root ? relative_filename.gsub('./', local_root) : local_filename
65
- end
66
- end
67
- end
68
- end