simplecov 0.6.4 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +378 -12
- data/CONTRIBUTING.md +51 -0
- data/ISSUE_TEMPLATE.md +23 -0
- data/LICENSE +1 -1
- data/README.md +456 -252
- data/doc/alternate-formatters.md +56 -0
- data/doc/commercial-services.md +20 -0
- data/doc/editor-integration.md +18 -0
- data/lib/simplecov.rb +223 -44
- data/lib/simplecov/command_guesser.rb +47 -35
- data/lib/simplecov/configuration.rb +281 -191
- data/lib/simplecov/defaults.rb +38 -43
- data/lib/simplecov/exit_codes.rb +10 -0
- data/lib/simplecov/file_list.rb +51 -34
- data/lib/simplecov/filter.rb +50 -3
- data/lib/simplecov/formatter.rb +4 -1
- data/lib/simplecov/formatter/multi_formatter.rb +34 -0
- data/lib/simplecov/formatter/simple_formatter.rb +18 -12
- data/lib/simplecov/jruby_fix.rb +44 -0
- data/lib/simplecov/last_run.rb +26 -0
- data/lib/simplecov/lines_classifier.rb +48 -0
- data/lib/simplecov/load_global_config.rb +8 -0
- data/lib/simplecov/no_defaults.rb +4 -0
- data/lib/simplecov/profiles.rb +33 -0
- data/lib/simplecov/profiles/bundler_filter.rb +5 -0
- data/lib/simplecov/profiles/hidden_filter.rb +5 -0
- data/lib/simplecov/profiles/rails.rb +18 -0
- data/lib/simplecov/profiles/root_filter.rb +10 -0
- data/lib/simplecov/profiles/test_frameworks.rb +8 -0
- data/lib/simplecov/railtie.rb +3 -1
- data/lib/simplecov/railties/tasks.rake +9 -7
- data/lib/simplecov/raw_coverage.rb +41 -0
- data/lib/simplecov/result.rb +17 -55
- data/lib/simplecov/result_merger.rb +100 -67
- data/lib/simplecov/source_file.rb +82 -67
- data/lib/simplecov/version.rb +4 -2
- metadata +153 -222
- data/.gitignore +0 -31
- data/.travis.yml +0 -15
- data/Appraisals +0 -8
- data/Gemfile +0 -5
- data/Rakefile +0 -19
- data/cucumber.yml +0 -13
- data/features/config_adapters.feature +0 -44
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -33
- data/features/config_coverage_dir.feature +0 -20
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_merge_timeout.feature +0 -39
- data/features/config_nocov_token.feature +0 -79
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -93
- data/features/cucumber_basic.feature +0 -29
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/rspec_basic.feature +0 -31
- data/features/rspec_fails_on_initialization.feature +0 -14
- data/features/rspec_groups_and_filters_basic.feature +0 -29
- data/features/rspec_groups_and_filters_complex.feature +0 -35
- data/features/rspec_groups_using_filter_class.feature +0 -40
- data/features/rspec_without_simplecov.feature +0 -20
- data/features/skipping_code_blocks_manually.feature +0 -70
- data/features/step_definitions/html_steps.rb +0 -45
- data/features/step_definitions/simplecov_steps.rb +0 -66
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/env.rb +0 -26
- data/features/test_unit_basic.feature +0 -34
- data/features/test_unit_groups_and_filters_basic.feature +0 -29
- data/features/test_unit_groups_and_filters_complex.feature +0 -35
- data/features/test_unit_groups_using_filter_class.feature +0 -40
- data/features/test_unit_without_simplecov.feature +0 -20
- data/features/unicode_compatiblity.feature +0 -67
- data/gemfiles/multi_json-legacy.gemfile +0 -7
- data/gemfiles/multi_json-legacy.gemfile.lock +0 -85
- data/gemfiles/multi_json-new.gemfile +0 -7
- data/gemfiles/multi_json-new.gemfile.lock +0 -85
- data/lib/simplecov/adapters.rb +0 -29
- data/lib/simplecov/merge_helpers.rb +0 -39
- data/simplecov.gemspec +0 -29
- data/test/faked_project/Gemfile +0 -6
- data/test/faked_project/Rakefile +0 -8
- data/test/faked_project/cucumber.yml +0 -13
- data/test/faked_project/features/step_definitions/my_steps.rb +0 -23
- data/test/faked_project/features/support/env.rb +0 -12
- data/test/faked_project/features/test_stuff.feature +0 -6
- data/test/faked_project/lib/faked_project.rb +0 -11
- data/test/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/test/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/test/faked_project/lib/faked_project/some_class.rb +0 -29
- data/test/faked_project/spec/faked_spec.rb +0 -11
- data/test/faked_project/spec/meta_magic_spec.rb +0 -10
- data/test/faked_project/spec/some_class_spec.rb +0 -10
- data/test/faked_project/spec/spec_helper.rb +0 -15
- data/test/faked_project/test/faked_test.rb +0 -11
- data/test/faked_project/test/meta_magic_test.rb +0 -13
- data/test/faked_project/test/some_class_test.rb +0 -15
- data/test/faked_project/test/test_helper.rb +0 -16
- data/test/fixtures/app/controllers/sample_controller.rb +0 -10
- data/test/fixtures/app/models/user.rb +0 -10
- data/test/fixtures/deleted_source_sample.rb +0 -15
- data/test/fixtures/frameworks/rspec_bad.rb +0 -9
- data/test/fixtures/frameworks/rspec_good.rb +0 -9
- data/test/fixtures/frameworks/testunit_bad.rb +0 -9
- data/test/fixtures/frameworks/testunit_good.rb +0 -9
- data/test/fixtures/iso-8859.rb +0 -3
- data/test/fixtures/resultset1.rb +0 -4
- data/test/fixtures/resultset2.rb +0 -5
- data/test/fixtures/sample.rb +0 -16
- data/test/fixtures/utf-8.rb +0 -3
- data/test/helper.rb +0 -35
- data/test/shoulda_macros.rb +0 -29
- data/test/test_1_8_fallbacks.rb +0 -33
- data/test/test_command_guesser.rb +0 -21
- data/test/test_deleted_source.rb +0 -16
- data/test/test_file_list.rb +0 -24
- data/test/test_filters.rb +0 -80
- data/test/test_merge_helpers.rb +0 -107
- data/test/test_result.rb +0 -147
- data/test/test_return_codes.rb +0 -39
- data/test/test_source_file.rb +0 -95
- data/test/test_source_file_line.rb +0 -110
@@ -1,215 +1,305 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "docile"
|
5
|
+
require "simplecov/formatter/multi_formatter"
|
2
6
|
#
|
3
7
|
# Bundles the configuration options used for SimpleCov. All methods
|
4
8
|
# defined here are usable from SimpleCov directly. Please check out
|
5
9
|
# SimpleCov documentation for further info.
|
6
10
|
#
|
7
|
-
module SimpleCov
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
# The root for the project. This defaults to the
|
12
|
-
# current working directory.
|
13
|
-
#
|
14
|
-
# Configure with SimpleCov.root('/my/project/path')
|
15
|
-
#
|
16
|
-
def root(root=nil)
|
17
|
-
return @root if defined? @root and root.nil?
|
18
|
-
@root = File.expand_path(root || Dir.getwd)
|
19
|
-
end
|
11
|
+
module SimpleCov
|
12
|
+
module Configuration # rubocop:disable ModuleLength
|
13
|
+
attr_writer :filters, :groups, :formatter
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
#
|
16
|
+
# The root for the project. This defaults to the
|
17
|
+
# current working directory.
|
18
|
+
#
|
19
|
+
# Configure with SimpleCov.root('/my/project/path')
|
20
|
+
#
|
21
|
+
def root(root = nil)
|
22
|
+
return @root if defined?(@root) && root.nil?
|
23
|
+
@root = File.expand_path(root || Dir.getwd)
|
24
|
+
end
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
26
|
+
#
|
27
|
+
# The name of the output and cache directory. Defaults to 'coverage'
|
28
|
+
#
|
29
|
+
# Configure with SimpleCov.coverage_dir('cov')
|
30
|
+
#
|
31
|
+
def coverage_dir(dir = nil)
|
32
|
+
return @coverage_dir if defined?(@coverage_dir) && dir.nil?
|
33
|
+
@coverage_path = nil # invalidate cache
|
34
|
+
@coverage_dir = (dir || "coverage")
|
35
|
+
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
#
|
38
|
+
# Returns the full path to the output directory using SimpleCov.root
|
39
|
+
# and SimpleCov.coverage_dir, so you can adjust this by configuring those
|
40
|
+
# values. Will create the directory if it's missing
|
41
|
+
#
|
42
|
+
def coverage_path
|
43
|
+
@coverage_path ||= begin
|
44
|
+
coverage_path = File.expand_path(coverage_dir, root)
|
45
|
+
FileUtils.mkdir_p coverage_path
|
46
|
+
coverage_path
|
47
|
+
end
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# also check out the corresponding section in README.rdoc
|
58
|
-
def command_name(name=nil)
|
59
|
-
@name = name unless name.nil?
|
60
|
-
@name ||= SimpleCov::CommandGuesser.guess
|
61
|
-
@name
|
62
|
-
end
|
63
|
-
|
64
|
-
#
|
65
|
-
# Gets or sets the configured formatter.
|
66
|
-
#
|
67
|
-
# Configure with: SimpleCov.formatter(SimpleCov::Formatter::SimpleFormatter)
|
68
|
-
#
|
69
|
-
def formatter(formatter=nil)
|
70
|
-
return @formatter if defined? @formatter and formatter.nil?
|
71
|
-
@formatter = formatter
|
72
|
-
raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
|
73
|
-
@formatter
|
74
|
-
end
|
50
|
+
#
|
51
|
+
# Coverage results will always include files matched by this glob, whether
|
52
|
+
# or not they were explicitly required. Without this, un-required files
|
53
|
+
# will not be present in the final report.
|
54
|
+
#
|
55
|
+
def track_files(glob)
|
56
|
+
@tracked_files = glob
|
57
|
+
end
|
75
58
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
def nocov_token(nocov_token=nil)
|
84
|
-
return @nocov_token if defined? @nocov_token and nocov_token.nil?
|
85
|
-
@nocov_token = (nocov_token || 'nocov')
|
86
|
-
end
|
87
|
-
alias_method :skip_token, :nocov_token
|
59
|
+
#
|
60
|
+
# Returns the glob that will be used to include files that were not
|
61
|
+
# explicitly required.
|
62
|
+
#
|
63
|
+
def tracked_files
|
64
|
+
@tracked_files if defined?(@tracked_files)
|
65
|
+
end
|
88
66
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
67
|
+
#
|
68
|
+
# Returns the list of configured filters. Add filters using SimpleCov.add_filter.
|
69
|
+
#
|
70
|
+
def filters
|
71
|
+
@filters ||= []
|
72
|
+
end
|
95
73
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
74
|
+
# The name of the command (a.k.a. Test Suite) currently running. Used for result
|
75
|
+
# merging and caching. It first tries to make a guess based upon the command line
|
76
|
+
# arguments the current test suite is running on and should automatically detect
|
77
|
+
# unit tests, functional tests, integration tests, rpsec and cucumber and label
|
78
|
+
# them properly. If it fails to recognize the current command, the command name
|
79
|
+
# is set to the shell command that the current suite is running on.
|
80
|
+
#
|
81
|
+
# You can specify it manually with SimpleCov.command_name("test:units") - please
|
82
|
+
# also check out the corresponding section in README.rdoc
|
83
|
+
def command_name(name = nil)
|
84
|
+
@name = name unless name.nil?
|
85
|
+
@name ||= SimpleCov::CommandGuesser.guess
|
86
|
+
@name
|
87
|
+
end
|
102
88
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
def configure(&block)
|
115
|
-
return false unless SimpleCov.usable?
|
116
|
-
instance_exec(&block)
|
117
|
-
end
|
89
|
+
#
|
90
|
+
# Gets or sets the configured formatter.
|
91
|
+
#
|
92
|
+
# Configure with: SimpleCov.formatter(SimpleCov::Formatter::SimpleFormatter)
|
93
|
+
#
|
94
|
+
def formatter(formatter = nil)
|
95
|
+
return @formatter if defined?(@formatter) && formatter.nil?
|
96
|
+
@formatter = formatter
|
97
|
+
raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
|
98
|
+
@formatter
|
99
|
+
end
|
118
100
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
# SimpleCov.at_exit do
|
126
|
-
# puts "Coverage done"
|
127
|
-
# SimpleCov.result.format!
|
128
|
-
# end
|
129
|
-
#
|
130
|
-
def at_exit(&block)
|
131
|
-
return Proc.new {} unless running or block_given?
|
132
|
-
@at_exit = block if block_given?
|
133
|
-
@at_exit ||= Proc.new { SimpleCov.result.format! }
|
134
|
-
end
|
101
|
+
#
|
102
|
+
# Sets the configured formatters.
|
103
|
+
#
|
104
|
+
def formatters=(formatters)
|
105
|
+
@formatter = SimpleCov::Formatter::MultiFormatter.new(formatters)
|
106
|
+
end
|
135
107
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
108
|
+
#
|
109
|
+
# Gets the configured formatters.
|
110
|
+
#
|
111
|
+
def formatters
|
112
|
+
if @formatter.is_a?(SimpleCov::Formatter::MultiFormatter)
|
113
|
+
@formatter.formatters
|
114
|
+
else
|
115
|
+
Array(formatter)
|
116
|
+
end
|
117
|
+
end
|
145
118
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
119
|
+
#
|
120
|
+
# Certain code blocks (i.e. Ruby-implementation specific code) can be excluded from
|
121
|
+
# the coverage metrics by wrapping it inside # :nocov: comment blocks. The nocov token
|
122
|
+
# can be configured to be any other string using this.
|
123
|
+
#
|
124
|
+
# Configure with SimpleCov.nocov_token('skip') or it's alias SimpleCov.skip_token('skip')
|
125
|
+
#
|
126
|
+
def nocov_token(nocov_token = nil)
|
127
|
+
return @nocov_token if defined?(@nocov_token) && nocov_token.nil?
|
128
|
+
@nocov_token = (nocov_token || "nocov")
|
129
|
+
end
|
130
|
+
alias skip_token nocov_token
|
154
131
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
# Of course, this only applies when merging is active (e.g. SimpleCov.use_merging is not false!)
|
162
|
-
#
|
163
|
-
# Default is 600 seconds (10 minutes)
|
164
|
-
#
|
165
|
-
# Configure with SimpleCov.merge_timeout(3600) # 1hr
|
166
|
-
#
|
167
|
-
def merge_timeout(seconds=nil)
|
168
|
-
@merge_timeout = seconds if !seconds.nil? and seconds.kind_of?(Fixnum)
|
169
|
-
@merge_timeout ||= 600
|
170
|
-
end
|
132
|
+
#
|
133
|
+
# Returns the configured groups. Add groups using SimpleCov.add_group
|
134
|
+
#
|
135
|
+
def groups
|
136
|
+
@groups ||= {}
|
137
|
+
end
|
171
138
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
139
|
+
#
|
140
|
+
# Returns the hash of available profiles
|
141
|
+
#
|
142
|
+
def profiles
|
143
|
+
@profiles ||= SimpleCov::Profiles.new
|
144
|
+
end
|
145
|
+
|
146
|
+
def adapters
|
147
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #adapters is deprecated. Use #profiles instead."
|
148
|
+
profiles
|
149
|
+
end
|
150
|
+
|
151
|
+
#
|
152
|
+
# Allows you to configure simplecov in a block instead of prepending SimpleCov to all config methods
|
153
|
+
# you're calling.
|
154
|
+
#
|
155
|
+
# SimpleCov.configure do
|
156
|
+
# add_filter 'foobar'
|
157
|
+
# end
|
158
|
+
#
|
159
|
+
# This is equivalent to SimpleCov.add_filter 'foobar' and thus makes it easier to set a bunch of configure
|
160
|
+
# options at once.
|
161
|
+
#
|
162
|
+
def configure(&block)
|
163
|
+
return false unless SimpleCov.usable?
|
164
|
+
Docile.dsl_eval(self, &block)
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# Gets or sets the behavior to process coverage results.
|
169
|
+
#
|
170
|
+
# By default, it will call SimpleCov.result.format!
|
171
|
+
#
|
172
|
+
# Configure with:
|
173
|
+
#
|
174
|
+
# SimpleCov.at_exit do
|
175
|
+
# puts "Coverage done"
|
176
|
+
# SimpleCov.result.format!
|
177
|
+
# end
|
178
|
+
#
|
179
|
+
def at_exit(&block)
|
180
|
+
return proc {} unless running || block_given?
|
181
|
+
@at_exit = block if block_given?
|
182
|
+
@at_exit ||= proc { SimpleCov.result.format! }
|
183
|
+
end
|
184
|
+
|
185
|
+
#
|
186
|
+
# Returns the project name - currently assuming the last dirname in
|
187
|
+
# the SimpleCov.root is this.
|
188
|
+
#
|
189
|
+
def project_name(new_name = nil)
|
190
|
+
return @project_name if defined?(@project_name) && @project_name && new_name.nil?
|
191
|
+
@project_name = new_name if new_name.is_a?(String)
|
192
|
+
@project_name ||= File.basename(root.split("/").last).capitalize.tr("_", " ")
|
193
|
+
end
|
194
|
+
|
195
|
+
#
|
196
|
+
# Defines whether to use result merging so all your test suites (test:units, test:functionals, cucumber, ...)
|
197
|
+
# are joined and combined into a single coverage report
|
198
|
+
#
|
199
|
+
def use_merging(use = nil)
|
200
|
+
@use_merging = use unless use.nil?
|
201
|
+
@use_merging = true unless defined?(@use_merging) && @use_merging == false
|
202
|
+
end
|
203
|
+
|
204
|
+
#
|
205
|
+
# Defines the maximum age (in seconds) of a resultset to still be included in merged results.
|
206
|
+
# i.e. If you run cucumber features, then later rake test, if the stored cucumber resultset is
|
207
|
+
# more seconds ago than specified here, it won't be taken into account when merging (and is also
|
208
|
+
# purged from the resultset cache)
|
209
|
+
#
|
210
|
+
# Of course, this only applies when merging is active (e.g. SimpleCov.use_merging is not false!)
|
211
|
+
#
|
212
|
+
# Default is 600 seconds (10 minutes)
|
213
|
+
#
|
214
|
+
# Configure with SimpleCov.merge_timeout(3600) # 1hr
|
215
|
+
#
|
216
|
+
def merge_timeout(seconds = nil)
|
217
|
+
@merge_timeout = seconds if seconds.is_a?(Integer)
|
218
|
+
@merge_timeout ||= 600
|
219
|
+
end
|
220
|
+
|
221
|
+
#
|
222
|
+
# Defines the minimum overall coverage required for the testsuite to pass.
|
223
|
+
# SimpleCov will return non-zero if the current coverage is below this threshold.
|
224
|
+
#
|
225
|
+
# Default is 0% (disabled)
|
226
|
+
#
|
227
|
+
def minimum_coverage(coverage = nil)
|
228
|
+
@minimum_coverage ||= (coverage || 0).to_f.round(2)
|
229
|
+
end
|
230
|
+
|
231
|
+
#
|
232
|
+
# Defines the maximum coverage drop at once allowed for the testsuite to pass.
|
233
|
+
# SimpleCov will return non-zero if the coverage decreases by more than this threshold.
|
234
|
+
#
|
235
|
+
# Default is 100% (disabled)
|
236
|
+
#
|
237
|
+
def maximum_coverage_drop(coverage_drop = nil)
|
238
|
+
@maximum_coverage_drop ||= (coverage_drop || 100).to_f.round(2)
|
239
|
+
end
|
240
|
+
|
241
|
+
#
|
242
|
+
# Defines the minimum coverage per file required for the testsuite to pass.
|
243
|
+
# SimpleCov will return non-zero if the current coverage of the least covered file
|
244
|
+
# is below this threshold.
|
245
|
+
#
|
246
|
+
# Default is 0% (disabled)
|
247
|
+
#
|
248
|
+
def minimum_coverage_by_file(coverage = nil)
|
249
|
+
@minimum_coverage_by_file ||= (coverage || 0).to_f.round(2)
|
250
|
+
end
|
251
|
+
|
252
|
+
#
|
253
|
+
# Refuses any coverage drop. That is, coverage is only allowed to increase.
|
254
|
+
# SimpleCov will return non-zero if the coverage decreases.
|
255
|
+
#
|
256
|
+
def refuse_coverage_drop
|
257
|
+
maximum_coverage_drop 0
|
258
|
+
end
|
259
|
+
|
260
|
+
#
|
261
|
+
# Add a filter to the processing chain.
|
262
|
+
# There are four ways to define a filter:
|
263
|
+
#
|
264
|
+
# * as a String that will then be matched against all source files' file paths,
|
265
|
+
# SimpleCov.add_filter 'app/models' # will reject all your models
|
266
|
+
# * as a block which will be passed the source file in question and should either
|
267
|
+
# return a true or false value, depending on whether the file should be removed
|
268
|
+
# SimpleCov.add_filter do |src_file|
|
269
|
+
# File.basename(src_file.filename) == 'environment.rb'
|
270
|
+
# end # Will exclude environment.rb files from the results
|
271
|
+
# * as an array of strings that are matched against all sorce files' file
|
272
|
+
# paths and then ignored (basically string filter multiple times)
|
273
|
+
# SimpleCov.add_filter ['app/models', 'app/helpers'] # ignores both dirs
|
274
|
+
# * as an instance of a subclass of SimpleCov::Filter. See the documentation there
|
275
|
+
# on how to define your own filter classes
|
276
|
+
#
|
277
|
+
def add_filter(filter_argument = nil, &filter_proc)
|
278
|
+
filters << parse_filter(filter_argument, &filter_proc)
|
279
|
+
end
|
280
|
+
|
281
|
+
#
|
282
|
+
# Define a group for files. Works similar to add_filter, only that the first
|
283
|
+
# argument is the desired group name and files PASSING the filter end up in the group
|
284
|
+
# (while filters exclude when the filter is applicable).
|
285
|
+
#
|
286
|
+
def add_group(group_name, filter_argument = nil, &filter_proc)
|
287
|
+
groups[group_name] = parse_filter(filter_argument, &filter_proc)
|
288
|
+
end
|
189
289
|
|
190
|
-
#
|
191
|
-
# Define a group for files. Works similar to add_filter, only that the first
|
192
|
-
# argument is the desired group name and files PASSING the filter end up in the group
|
193
|
-
# (while filters exclude when the filter is applicable).
|
194
|
-
#
|
195
|
-
def add_group(group_name, filter_argument=nil, &filter_proc)
|
196
|
-
groups[group_name] = parse_filter(filter_argument, &filter_proc)
|
197
|
-
end
|
198
|
-
|
199
290
|
private
|
200
291
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
raise ArgumentError, "Please specify either a string or a block to filter with"
|
292
|
+
#
|
293
|
+
# The actual filter processor. Not meant for direct use
|
294
|
+
#
|
295
|
+
def parse_filter(filter_argument = nil, &filter_proc)
|
296
|
+
filter = filter_argument || filter_proc
|
297
|
+
|
298
|
+
if filter
|
299
|
+
SimpleCov::Filter.build_filter(filter)
|
300
|
+
else
|
301
|
+
raise ArgumentError, "Please specify either a filter or a block to filter with"
|
302
|
+
end
|
213
303
|
end
|
214
304
|
end
|
215
305
|
end
|