coverband 4.2.5.rc.2 → 5.0.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +25 -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 +26 -30
  10. data/config.ru +1 -1
  11. data/coverband.gemspec +29 -34
  12. data/lib/alternative_coverband_patch.rb +5 -0
  13. data/lib/coverband.rb +55 -43
  14. data/lib/coverband/adapters/base.rb +17 -17
  15. data/lib/coverband/adapters/file_store.rb +2 -2
  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/at_exit.rb +1 -1
  19. data/lib/coverband/collectors/coverage.rb +15 -27
  20. data/lib/coverband/collectors/delta.rb +19 -9
  21. data/lib/coverband/collectors/view_tracker.rb +19 -11
  22. data/lib/coverband/configuration.rb +48 -84
  23. data/lib/coverband/integrations/background.rb +3 -3
  24. data/lib/coverband/integrations/rack_server_check.rb +3 -3
  25. data/lib/coverband/integrations/resque.rb +13 -1
  26. data/lib/coverband/reporters/base.rb +10 -10
  27. data/lib/coverband/reporters/console_report.rb +1 -1
  28. data/lib/coverband/reporters/html_report.rb +10 -30
  29. data/lib/coverband/reporters/web.rb +56 -49
  30. data/lib/coverband/utils/absolute_file_converter.rb +6 -6
  31. data/lib/coverband/utils/html_formatter.rb +32 -61
  32. data/lib/coverband/utils/railtie.rb +16 -4
  33. data/lib/coverband/utils/relative_file_converter.rb +2 -2
  34. data/lib/coverband/utils/result.rb +6 -11
  35. data/lib/coverband/utils/results.rb +0 -10
  36. data/lib/coverband/utils/source_file.rb +21 -30
  37. data/lib/coverband/utils/tasks.rb +7 -11
  38. data/lib/coverband/version.rb +1 -1
  39. data/public/application.js +0 -30
  40. data/test/benchmarks/benchmark.rake +97 -92
  41. data/test/benchmarks/dog.rb +1 -1
  42. data/test/benchmarks/init_rails.rake +4 -4
  43. data/test/coverband/adapters/base_test.rb +29 -30
  44. data/test/coverband/adapters/file_store_test.rb +15 -16
  45. data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
  46. data/test/coverband/adapters/redis_store_test.rb +26 -26
  47. data/test/coverband/at_exit_test.rb +2 -2
  48. data/test/coverband/collectors/coverage_test.rb +33 -47
  49. data/test/coverband/collectors/delta_test.rb +51 -23
  50. data/test/coverband/collectors/view_tracker_test.rb +35 -35
  51. data/test/coverband/configuration_test.rb +27 -53
  52. data/test/coverband/coverband_test.rb +11 -11
  53. data/test/coverband/integrations/background_middleware_test.rb +10 -10
  54. data/test/coverband/integrations/background_test.rb +3 -2
  55. data/test/coverband/integrations/rack_server_check_test.rb +7 -7
  56. data/test/coverband/integrations/report_middleware_test.rb +9 -9
  57. data/test/coverband/integrations/resque_worker_test.rb +9 -9
  58. data/test/coverband/integrations/test_resque_job.rb +1 -1
  59. data/test/coverband/reporters/base_test.rb +9 -9
  60. data/test/coverband/reporters/console_test.rb +6 -6
  61. data/test/coverband/reporters/html_test.rb +36 -48
  62. data/test/coverband/reporters/web_test.rb +16 -18
  63. data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
  64. data/test/coverband/utils/file_hasher_test.rb +6 -12
  65. data/test/coverband/utils/file_list_test.rb +13 -13
  66. data/test/coverband/utils/html_formatter_test.rb +9 -23
  67. data/test/coverband/utils/lines_classifier_test.rb +29 -29
  68. data/test/coverband/utils/relative_file_converter_test.rb +13 -13
  69. data/test/coverband/utils/result_test.rb +18 -18
  70. data/test/coverband/utils/results_test.rb +17 -17
  71. data/test/coverband/utils/source_file_line_test.rb +46 -46
  72. data/test/coverband/utils/source_file_test.rb +38 -88
  73. data/test/dog.rb +1 -1
  74. data/test/fake_app/basic_rack.rb +2 -2
  75. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  76. data/test/fixtures/app/models/user.rb +1 -1
  77. data/test/fixtures/sample.rb +1 -1
  78. data/test/fixtures/utf-8.rb +0 -2
  79. data/test/forked/rails_full_stack_test.rb +24 -27
  80. data/test/forked/rails_rake_full_stack_test.rb +7 -26
  81. data/test/integration/full_stack_test.rb +11 -22
  82. data/test/jruby_check.rb +2 -3
  83. data/test/rails4_dummy/Rakefile +1 -1
  84. data/test/rails4_dummy/config.ru +1 -1
  85. data/test/rails4_dummy/config/application.rb +4 -4
  86. data/test/rails4_dummy/config/boot.rb +2 -2
  87. data/test/rails4_dummy/config/coverband.rb +1 -1
  88. data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
  89. data/test/rails4_dummy/config/environment.rb +1 -1
  90. data/test/rails4_dummy/config/routes.rb +2 -2
  91. data/test/rails5_dummy/Rakefile +1 -1
  92. data/test/rails5_dummy/config.ru +1 -1
  93. data/test/rails5_dummy/config/application.rb +3 -3
  94. data/test/rails5_dummy/config/coverband.rb +8 -8
  95. data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
  96. data/test/rails5_dummy/config/environment.rb +1 -1
  97. data/test/rails5_dummy/config/routes.rb +2 -2
  98. data/test/rails6_dummy/Rakefile +1 -1
  99. data/test/rails6_dummy/config.ru +1 -1
  100. data/test/rails6_dummy/config/application.rb +4 -4
  101. data/test/rails6_dummy/config/boot.rb +2 -2
  102. data/test/rails6_dummy/config/coverband.rb +1 -1
  103. data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
  104. data/test/rails6_dummy/config/environment.rb +1 -1
  105. data/test/rails6_dummy/config/routes.rb +2 -2
  106. data/test/rails_test_helper.rb +11 -11
  107. data/test/test_helper.rb +41 -34
  108. data/test/unique_files.rb +10 -10
  109. data/views/layout.erb +2 -12
  110. metadata +5 -43
  111. data/.rubocop.yml +0 -84
  112. data/lib/coverband/integrations/bundler.rb +0 -8
  113. data/lib/coverband/utils/file_groups.rb +0 -53
  114. data/lib/coverband/utils/gem_list.rb +0 -31
  115. data/lib/coverband/utils/s3_report.rb +0 -105
  116. data/test/coverband/utils/file_groups_test.rb +0 -61
  117. data/test/coverband/utils/gem_list_test.rb +0 -48
  118. data/test/coverband/utils/s3_report_test.rb +0 -44
  119. data/views/gem_list.erb +0 -63
@@ -39,23 +39,33 @@ module Coverband
39
39
 
40
40
  def self.reset
41
41
  @@previous_coverage = {}
42
+ @@project_directory = File.expand_path(Coverband.configuration.root)
43
+ @@ignore_patterns = Coverband.configuration.ignore
42
44
  end
43
45
 
44
46
  private
45
47
 
46
48
  def generate
47
- # TODO: if we filtered before doing this we would avoid calculating the line diff on a ton of files
48
- # This would be a fairly noticeable perf win
49
49
  current_coverage.each_with_object({}) do |(file, line_counts), new_results|
50
+ ###
51
+ # Eager filter:
52
+ # Normally I would break this out into additional methods
53
+ # and improve the readability but this is in a tight loop
54
+ # on the critical performance path, and any refactoring I come up with
55
+ # would slow down the performance.
56
+ ###
57
+ next unless @@ignore_patterns.none? { |pattern| file.match(pattern) } &&
58
+ file.start_with?(@@project_directory)
59
+
50
60
  # This handles Coverage branch support, setup by default in
51
61
  # simplecov 0.18.x
52
62
  arr_line_counts = line_counts.is_a?(Hash) ? line_counts[:lines] : line_counts
53
63
  new_results[file] = if @@previous_coverage && @@previous_coverage[file]
54
- prev_line_counts = @@previous_coverage[file].is_a?(Hash) ? @@previous_coverage[file][:lines] : @@previous_coverage[file]
55
- array_diff(arr_line_counts, prev_line_counts)
56
- else
57
- arr_line_counts
58
- end
64
+ prev_line_counts = @@previous_coverage[file].is_a?(Hash) ? @@previous_coverage[file][:lines] : @@previous_coverage[file]
65
+ array_diff(arr_line_counts, prev_line_counts)
66
+ else
67
+ arr_line_counts
68
+ end
59
69
  end
60
70
  end
61
71
 
@@ -68,9 +78,9 @@ module Coverband
68
78
  def transform_oneshot_lines_results(results)
69
79
  results.each_with_object({}) do |(file, coverage), new_results|
70
80
  @@stubs[file] ||= ::Coverage.line_stub(file)
71
- transformed_line_counts = coverage[:oneshot_lines].each_with_object(@@stubs[file].dup) do |line_number, line_counts|
81
+ transformed_line_counts = coverage[:oneshot_lines].each_with_object(@@stubs[file].dup) { |line_number, line_counts|
72
82
  line_counts[line_number - 1] = 1
73
- end
83
+ }
74
84
  new_results[file] = transformed_line_counts
75
85
  end
76
86
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'singleton'
3
+ require "singleton"
4
4
 
5
5
  module Coverband
6
6
  module Collectors
@@ -14,12 +14,12 @@ module Coverband
14
14
  # TODO: test and ensure slim, haml, and other support
15
15
  ###
16
16
  class ViewTracker
17
- DEFAULT_TARGET = Dir.glob('app/views/**/*.html.erb').reject { |file| file.match(/(_mailer)/) }
17
+ DEFAULT_TARGET = Dir.glob("app/views/**/*.html.erb").reject { |file| file.match(/(_mailer)/) }
18
18
  attr_accessor :target, :logged_views, :views_to_record
19
19
  attr_reader :logger, :roots, :store, :ignore_patterns
20
20
 
21
21
  def initialize(options = {})
22
- raise NotImplementedError, 'View Tracker requires Rails 4 or greater' unless self.class.supported_version?
22
+ raise NotImplementedError, "View Tracker requires Rails 4 or greater" unless self.class.supported_version?
23
23
 
24
24
  @project_directory = File.expand_path(Coverband.configuration.root)
25
25
  @ignore_patterns = Coverband.configuration.ignore
@@ -28,7 +28,7 @@ module Coverband
28
28
  @target = options.fetch(:target) { DEFAULT_TARGET }
29
29
 
30
30
  @roots = options.fetch(:roots) { Coverband.configuration.all_root_patterns }
31
- @roots = @roots.split(',') if @roots.is_a?(String)
31
+ @roots = @roots.split(",") if @roots.is_a?(String)
32
32
  @one_time_timestamp = false
33
33
 
34
34
  @logged_views = []
@@ -65,7 +65,7 @@ module Coverband
65
65
  normalized_views = {}
66
66
  views.each_pair do |view, time|
67
67
  roots.each do |root|
68
- view = view.gsub(/#{root}/, '')
68
+ view = view.gsub(/#{root}/, "")
69
69
  end
70
70
  normalized_views[view] = time
71
71
  end
@@ -90,7 +90,7 @@ module Coverband
90
90
  if (tracking_time = redis_store.get(tracker_time_key))
91
91
  Time.at(tracking_time.to_i).iso8601
92
92
  else
93
- 'N/A'
93
+ "N/A"
94
94
  end
95
95
  end
96
96
 
@@ -108,21 +108,21 @@ module Coverband
108
108
  end
109
109
 
110
110
  def report_views_tracked
111
- redis_store.set(tracker_time_key, Time.now.to_i) unless @one_time_timestamp || redis_store.exists(tracker_time_key)
111
+ redis_store.set(tracker_time_key, Time.now.to_i) unless @one_time_timestamp || tracker_time_key_exists?
112
112
  @one_time_timestamp = true
113
113
  reported_time = Time.now.to_i
114
114
  views_to_record.each do |file|
115
115
  redis_store.hset(tracker_key, file, reported_time)
116
116
  end
117
117
  self.views_to_record = []
118
- rescue StandardError => e
118
+ rescue => e
119
119
  # we don't want to raise errors if Coverband can't reach redis.
120
120
  # This is a nice to have not a bring the system down
121
121
  logger&.error "Coverband: view_tracker failed to store, error #{e.class.name}"
122
122
  end
123
123
 
124
124
  def self.supported_version?
125
- defined?(Rails) && defined?(Rails::VERSION) && Rails::VERSION::STRING.split('.').first.to_i >= 4
125
+ defined?(Rails) && defined?(Rails::VERSION) && Rails::VERSION::STRING.split(".").first.to_i >= 4
126
126
  end
127
127
 
128
128
  protected
@@ -145,12 +145,20 @@ module Coverband
145
145
  store.raw_store
146
146
  end
147
147
 
148
+ def tracker_time_key_exists?
149
+ if defined?(redis_store.exists?)
150
+ redis_store.exists?(tracker_time_key)
151
+ else
152
+ redis_store.exists(tracker_time_key)
153
+ end
154
+ end
155
+
148
156
  def tracker_key
149
- 'render_tracker_2'
157
+ "render_tracker_2"
150
158
  end
151
159
 
152
160
  def tracker_time_key
153
- 'render_tracker_time'
161
+ "render_tracker_time"
154
162
  end
155
163
  end
156
164
  end
@@ -3,16 +3,16 @@
3
3
  module Coverband
4
4
  class Configuration
5
5
  attr_accessor :root_paths, :root,
6
- :additional_files, :verbose,
7
- :reporter, :redis_namespace, :redis_ttl,
8
- :background_reporting_enabled,
9
- :background_reporting_sleep_seconds, :test_env,
10
- :web_enable_clear, :gem_details, :web_debug, :report_on_exit,
11
- :simulate_oneshot_lines_coverage, :track_views, :view_tracker,
12
- :reporting_wiggle
6
+ :additional_files, :verbose,
7
+ :reporter, :redis_namespace, :redis_ttl,
8
+ :background_reporting_enabled,
9
+ :background_reporting_sleep_seconds, :test_env,
10
+ :web_enable_clear, :gem_details, :web_debug, :report_on_exit,
11
+ :simulate_oneshot_lines_coverage, :track_views, :view_tracker,
12
+ :reporting_wiggle
13
13
 
14
14
  attr_writer :logger, :s3_region, :s3_bucket, :s3_access_key_id,
15
- :s3_secret_access_key, :password
15
+ :s3_secret_access_key, :password
16
16
  attr_reader :track_gems, :ignore, :use_oneshot_lines_coverage
17
17
 
18
18
  #####
@@ -22,25 +22,25 @@ module Coverband
22
22
  # * should we skip /bin/rails webpacker:compile ?
23
23
  # * Perhaps detect heroku deployment ENV var opposed to tasks?
24
24
  #####
25
- IGNORE_TASKS = ['coverband:clear',
26
- 'coverband:coverage',
27
- 'coverband:coverage_server',
28
- 'coverband:migrate',
29
- 'assets:precompile',
30
- 'db:version',
31
- 'db:create',
32
- 'db:drop',
33
- 'db:seed',
34
- 'db:setup',
35
- 'db:test:prepare',
36
- 'db:structure:dump',
37
- 'db:structure:load',
38
- 'db:version']
25
+ IGNORE_TASKS = ["coverband:clear",
26
+ "coverband:coverage",
27
+ "coverband:coverage_server",
28
+ "coverband:migrate",
29
+ "assets:precompile",
30
+ "db:version",
31
+ "db:create",
32
+ "db:drop",
33
+ "db:seed",
34
+ "db:setup",
35
+ "db:test:prepare",
36
+ "db:structure:dump",
37
+ "db:structure:load",
38
+ "db:version"]
39
39
 
40
40
  # Heroku when building assets runs code from a dynamic directory
41
41
  # /tmp was added to avoid coverage from /tmp/build directories during
42
42
  # heroku asset compilation
43
- IGNORE_DEFAULTS = %w[vendor/ .erb$ .slim$ /tmp internal:prelude schema.rb]
43
+ IGNORE_DEFAULTS = %w[vendor/ .erb$ .slim$ /tmp internal:prelude db/schema.rb]
44
44
 
45
45
  # Add in missing files which were never loaded
46
46
  # we need to know what all paths to check for unloaded files
@@ -57,7 +57,7 @@ module Coverband
57
57
  @search_paths = TRACKED_DEFAULT_PATHS.dup
58
58
  @additional_files = []
59
59
  @verbose = false
60
- @reporter = 'scov'
60
+ @reporter = "scov"
61
61
  @logger = nil
62
62
  @store = nil
63
63
  @background_reporting_enabled = true
@@ -67,21 +67,21 @@ module Coverband
67
67
  @track_gems = false
68
68
  @gem_details = false
69
69
  @track_views = false
70
- @groups = {}
71
70
  @web_debug = false
72
71
  @report_on_exit = true
73
- @use_oneshot_lines_coverage = ENV['ONESHOT'] || false
74
- @simulate_oneshot_lines_coverage = ENV['SIMULATE_ONESHOT'] || false
72
+ @use_oneshot_lines_coverage = ENV["ONESHOT"] || false
73
+ @simulate_oneshot_lines_coverage = ENV["SIMULATE_ONESHOT"] || false
75
74
  @current_root = nil
76
75
  @all_root_paths = nil
77
76
  @all_root_patterns = nil
78
77
  @password = nil
79
78
 
80
- # TODO: should we push these to adapter configs
79
+ # TODO: these are deprecated
81
80
  @s3_region = nil
82
81
  @s3_bucket = nil
83
82
  @s3_access_key_id = nil
84
83
  @s3_secret_access_key = nil
84
+
85
85
  @redis_namespace = nil
86
86
  @redis_ttl = 2_592_000 # in seconds. Default is 30 days.
87
87
  @reporting_wiggle = nil
@@ -89,30 +89,30 @@ module Coverband
89
89
 
90
90
  def logger
91
91
  @logger ||= if defined?(Rails.logger) && Rails.logger
92
- Rails.logger
93
- else
94
- Logger.new(STDOUT)
95
- end
92
+ Rails.logger
93
+ else
94
+ Logger.new(STDOUT)
95
+ end
96
96
  end
97
97
 
98
98
  def password
99
- @password || ENV['COVERBAND_PASSWORD']
99
+ @password || ENV["COVERBAND_PASSWORD"]
100
100
  end
101
101
 
102
102
  def s3_bucket
103
- @s3_bucket || ENV['AWS_BUCKET']
103
+ puts "deprecated, s3 is no longer support"
104
104
  end
105
105
 
106
106
  def s3_region
107
- @s3_region || ENV['AWS_REGION']
107
+ puts "deprecated, s3 is no longer support"
108
108
  end
109
109
 
110
110
  def s3_access_key_id
111
- @s3_access_key_id || ENV['AWS_ACCESS_KEY_ID']
111
+ puts "deprecated, s3 is no longer support"
112
112
  end
113
113
 
114
114
  def s3_secret_access_key
115
- @s3_secret_access_key || ENV['AWS_SECRET_ACCESS_KEY']
115
+ puts "deprecated, s3 is no longer support"
116
116
  end
117
117
 
118
118
  def store
@@ -120,7 +120,7 @@ module Coverband
120
120
  end
121
121
 
122
122
  def store=(store)
123
- raise 'Pass in an instance of Coverband::Adapters' unless store.is_a?(Coverband::Adapters::Base)
123
+ raise "Pass in an instance of Coverband::Adapters" unless store.is_a?(Coverband::Adapters::Base)
124
124
 
125
125
  # Default to 5 minutes if using the hash redis store
126
126
  # This is a safer default for the high server volumes that need the hash store
@@ -134,7 +134,7 @@ module Coverband
134
134
  # Search Paths
135
135
  ###
136
136
  def tracked_search_paths
137
- "#{Coverband.configuration.current_root}/{#{@search_paths.join(',')}}/**/*.{rb}"
137
+ "#{Coverband.configuration.current_root}/{#{@search_paths.join(",")}}/**/*.{rb}"
138
138
  end
139
139
 
140
140
  ###
@@ -151,43 +151,8 @@ module Coverband
151
151
  @ignore = (@ignore + ignored_array).uniq
152
152
  end
153
153
 
154
- def track_gems=(value)
155
- @track_gems = value
156
- return unless @track_gems
157
-
158
- # by default we ignore vendor where many deployments put gems
159
- # we will remove this default if track_gems is set
160
- @ignore.delete('vendor/')
161
- # while we want to allow vendored gems we don't want to track vendored ruby STDLIB
162
- @ignore << 'vendor/ruby-*' unless @ignore.include?('vendor/ruby-*')
163
- add_group('App', root)
164
- # TODO: rework support for multiple gem paths
165
- # this works but seems hacky and error prone
166
- # basically since it is converted to a regex we join all the paths
167
- # with a regex 'OR' using '|'
168
- add_group('Gems', gem_paths.join('|'))
169
- end
170
-
171
- #
172
- # Returns the configured groups. Add groups using SimpleCov.add_group
173
- #
174
- def groups
175
- @groups ||= {}
176
- end
177
-
178
- #
179
- # Define a group for files. Works similar to add_filter, only that the first
180
- # argument is the desired group name and files PASSING the filter end up in the group
181
- # (while filters exclude when the filter is applicable).
182
- #
183
- def add_group(group_name, filter_argument = nil)
184
- groups[group_name] = filter_argument
185
- end
186
-
187
- def gem_paths
188
- # notes ignore any paths that aren't on this system, resolves
189
- # bug related to multiple ruby version managers / bad dot files
190
- Gem::PathSupport.new(ENV).path.select { |path| File.exist?(path) }
154
+ def track_gems=(_value)
155
+ puts "gem tracking is deprecated, setting this will be ignored"
191
156
  end
192
157
 
193
158
  def current_root
@@ -198,7 +163,6 @@ module Coverband
198
163
  return @all_root_paths if @all_root_paths
199
164
 
200
165
  @all_root_paths = Coverband.configuration.root_paths.dup
201
- @all_root_paths += Coverband.configuration.gem_paths.dup if Coverband.configuration.track_gems
202
166
  @all_root_paths << "#{Coverband.configuration.current_root}/"
203
167
  @all_root_paths
204
168
  end
@@ -210,30 +174,30 @@ module Coverband
210
174
  SKIPPED_SETTINGS = %w[@s3_secret_access_key @store]
211
175
  def to_h
212
176
  instance_variables
213
- .each_with_object('gem_paths': gem_paths) do |var, hash|
214
- hash[var.to_s.delete('@')] = instance_variable_get(var) unless SKIPPED_SETTINGS.include?(var.to_s)
177
+ .each_with_object({}) do |var, hash|
178
+ hash[var.to_s.delete("@")] = instance_variable_get(var) unless SKIPPED_SETTINGS.include?(var.to_s)
215
179
  end
216
180
  end
217
181
 
218
182
  def use_oneshot_lines_coverage=(value)
219
- raise(Exception, 'One shot line coverage is only available in ruby >= 2.6') unless one_shot_coverage_implemented_in_ruby_version? || !value
183
+ raise(StandardError, "One shot line coverage is only available in ruby >= 2.6") unless one_shot_coverage_implemented_in_ruby_version? || !value
220
184
 
221
185
  @use_oneshot_lines_coverage = value
222
186
  end
223
187
 
224
188
  def one_shot_coverage_implemented_in_ruby_version?
225
- Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
189
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
226
190
  end
227
191
 
228
192
  private
229
193
 
230
194
  def redis_url
231
- ENV['COVERBAND_REDIS_URL'] || ENV['REDIS_URL']
195
+ ENV["COVERBAND_REDIS_URL"] || ENV["REDIS_URL"]
232
196
  end
233
197
 
234
198
  def redis_store_options
235
- { ttl: Coverband.configuration.redis_ttl,
236
- redis_namespace: Coverband.configuration.redis_namespace }
199
+ {ttl: Coverband.configuration.redis_ttl,
200
+ redis_namespace: Coverband.configuration.redis_namespace}
237
201
  end
238
202
  end
239
203
  end
@@ -27,9 +27,9 @@ module Coverband
27
27
  @semaphore.synchronize do
28
28
  return if running?
29
29
 
30
- logger.debug('Coverband: Starting background reporting') if Coverband.configuration.verbose
30
+ logger.debug("Coverband: Starting background reporting") if Coverband.configuration.verbose
31
31
  sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds
32
- @thread = Thread.new do
32
+ @thread = Thread.new {
33
33
  loop do
34
34
  Coverband.report_coverage
35
35
  Coverband.configuration.view_tracker&.report_views_tracked
@@ -41,7 +41,7 @@ module Coverband
41
41
  end
42
42
  sleep(sleep_seconds)
43
43
  end
44
- end
44
+ }
45
45
  end
46
46
  end
47
47
  end
@@ -15,14 +15,14 @@ module Coverband
15
15
  end
16
16
 
17
17
  def rack_server?
18
- @stack.any? { |line| line.path.include?('lib/rack/') }
18
+ @stack.any? { |line| line.path.include?("lib/rack/") }
19
19
  end
20
20
 
21
21
  def rails_server?
22
22
  @stack.any? do |location|
23
23
  (
24
- location.path.include?('rails/commands/commands_tasks.rb') && location.label == 'server' ||
25
- location.path.include?('rails/commands/server/server_command.rb') && location.label == 'perform'
24
+ location.path.include?("rails/commands/commands_tasks.rb") && location.label == "server" ||
25
+ location.path.include?("rails/commands/server/server_command.rb") && location.label == "perform"
26
26
  )
27
27
  end
28
28
  end
@@ -22,4 +22,16 @@ module Coverband
22
22
  end
23
23
  end
24
24
 
25
- Resque::Job.prepend(Coverband::ResqueWorker)
25
+ if defined?(Coverband::COVERBAND_ALTERNATE_PATCH)
26
+ Resque::Job.class_eval do
27
+ def perform_with_coverband
28
+ perform_without_coverband
29
+ ensure
30
+ Coverband.report_coverage
31
+ end
32
+ alias perform_without_coverband perform
33
+ alias perform perform_with_coverband
34
+ end
35
+ else
36
+ Resque::Job.prepend(Coverband::ResqueWorker)
37
+ end