vcr 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +37 -2
- data/Gemfile +2 -2
- data/README.md +10 -1
- data/Rakefile +43 -7
- data/Upgrade.md +45 -0
- data/features/.nav +1 -0
- data/features/cassettes/automatic_re_recording.feature +19 -17
- data/features/cassettes/dynamic_erb.feature +32 -28
- data/features/cassettes/exclusive.feature +28 -24
- data/features/cassettes/format.feature +213 -31
- data/features/cassettes/update_content_length_header.feature +20 -18
- data/features/configuration/filter_sensitive_data.feature +4 -4
- data/features/configuration/hooks.feature +27 -23
- data/features/http_libraries/em_http_request.feature +79 -75
- data/features/record_modes/all.feature +14 -14
- data/features/record_modes/new_episodes.feature +15 -15
- data/features/record_modes/none.feature +15 -15
- data/features/record_modes/once.feature +15 -15
- data/features/request_matching/body.feature +25 -23
- data/features/request_matching/custom_matcher.feature +25 -23
- data/features/request_matching/headers.feature +32 -36
- data/features/request_matching/host.feature +27 -25
- data/features/request_matching/identical_request_sequence.feature +27 -25
- data/features/request_matching/method.feature +27 -25
- data/features/request_matching/path.feature +27 -25
- data/features/request_matching/playback_repeats.feature +27 -25
- data/features/request_matching/uri.feature +27 -25
- data/features/request_matching/uri_without_param.feature +28 -26
- data/features/step_definitions/cli_steps.rb +71 -17
- data/features/support/env.rb +3 -1
- data/features/support/http_lib_filters.rb +6 -3
- data/features/support/vcr_cucumber_helpers.rb +4 -2
- data/lib/vcr.rb +6 -2
- data/lib/vcr/cassette.rb +75 -51
- data/lib/vcr/cassette/migrator.rb +111 -0
- data/lib/vcr/cassette/serializers.rb +35 -0
- data/lib/vcr/cassette/serializers/json.rb +23 -0
- data/lib/vcr/cassette/serializers/psych.rb +24 -0
- data/lib/vcr/cassette/serializers/syck.rb +35 -0
- data/lib/vcr/cassette/serializers/yaml.rb +24 -0
- data/lib/vcr/configuration.rb +6 -1
- data/lib/vcr/errors.rb +1 -1
- data/lib/vcr/library_hooks/excon.rb +1 -7
- data/lib/vcr/library_hooks/typhoeus.rb +6 -22
- data/lib/vcr/library_hooks/webmock.rb +1 -1
- data/lib/vcr/middleware/faraday.rb +1 -1
- data/lib/vcr/request_matcher_registry.rb +43 -30
- data/lib/vcr/structs.rb +209 -0
- data/lib/vcr/tasks/vcr.rake +9 -0
- data/lib/vcr/version.rb +1 -1
- data/spec/fixtures/cassette_spec/1_x_cassette.yml +110 -0
- data/spec/fixtures/cassette_spec/example.yml +79 -78
- data/spec/fixtures/cassette_spec/with_localhost_requests.yml +79 -77
- data/spec/fixtures/fake_example.com_responses.yml +78 -76
- data/spec/fixtures/match_requests_on.yml +147 -145
- data/spec/monkey_patches.rb +5 -5
- data/spec/support/http_library_adapters.rb +48 -0
- data/spec/support/shared_example_groups/hook_into_http_library.rb +53 -20
- data/spec/support/sinatra_app.rb +12 -0
- data/spec/vcr/cassette/http_interaction_list_spec.rb +1 -1
- data/spec/vcr/cassette/migrator_spec.rb +183 -0
- data/spec/vcr/cassette/serializers_spec.rb +122 -0
- data/spec/vcr/cassette_spec.rb +147 -83
- data/spec/vcr/configuration_spec.rb +11 -1
- data/spec/vcr/library_hooks/typhoeus_spec.rb +3 -3
- data/spec/vcr/library_hooks/webmock_spec.rb +7 -1
- data/spec/vcr/request_ignorer_spec.rb +1 -1
- data/spec/vcr/request_matcher_registry_spec.rb +46 -4
- data/spec/vcr/structs_spec.rb +309 -0
- data/spec/vcr_spec.rb +7 -0
- data/vcr.gemspec +9 -12
- metadata +75 -61
- data/lib/vcr/structs/http_interaction.rb +0 -58
- data/lib/vcr/structs/normalizers/body.rb +0 -24
- data/lib/vcr/structs/normalizers/header.rb +0 -64
- data/lib/vcr/structs/normalizers/status_message.rb +0 -17
- data/lib/vcr/structs/normalizers/uri.rb +0 -34
- data/lib/vcr/structs/request.rb +0 -13
- data/lib/vcr/structs/response.rb +0 -13
- data/lib/vcr/structs/response_status.rb +0 -5
- data/lib/vcr/util/yaml.rb +0 -11
- data/spec/support/shared_example_groups/normalizers.rb +0 -94
- data/spec/vcr/structs/http_interaction_spec.rb +0 -89
- data/spec/vcr/structs/request_spec.rb +0 -39
- data/spec/vcr/structs/response_spec.rb +0 -44
- data/spec/vcr/structs/response_status_spec.rb +0 -9
data/spec/vcr_spec.rb
CHANGED
@@ -157,6 +157,13 @@ describe VCR do
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
+
describe '.serializers' do
|
161
|
+
it 'always returns the same memoized cassette serializers instance' do
|
162
|
+
VCR.cassette_serializers.should be_a(VCR::Cassette::Serializers)
|
163
|
+
VCR.cassette_serializers.should be(VCR.cassette_serializers)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
160
167
|
describe '.configuration' do
|
161
168
|
it 'returns the configuration object' do
|
162
169
|
VCR.configuration.should be_a(VCR::Configuration)
|
data/vcr.gemspec
CHANGED
@@ -21,7 +21,10 @@ Gem::Specification.new do |s|
|
|
21
21
|
'bundler' => '~> 1.0.7',
|
22
22
|
'rake' => '~> 0.9.2',
|
23
23
|
|
24
|
-
'
|
24
|
+
'cucumber' => '~> 1.0.3',
|
25
|
+
'aruba' => '~> 0.4.6',
|
26
|
+
|
27
|
+
'rspec' => '~> 2.7',
|
25
28
|
'shoulda' => '~> 2.9.2',
|
26
29
|
|
27
30
|
'fakeweb' => '~> 1.3.0',
|
@@ -34,24 +37,18 @@ Gem::Specification.new do |s|
|
|
34
37
|
|
35
38
|
'timecop' => '~> 0.3.5',
|
36
39
|
'rack' => '1.1.0',
|
37
|
-
'sinatra' => '~> 1.1.0'
|
38
|
-
}.each do |lib, version|
|
39
|
-
s.add_development_dependency lib, version
|
40
|
-
end
|
40
|
+
'sinatra' => '~> 1.1.0',
|
41
41
|
|
42
|
-
|
43
|
-
{
|
44
|
-
'cucumber' => '~> 1.0.3',
|
45
|
-
'aruba' => '~> 0.4.6',
|
42
|
+
'multi_json' => '~> 1.0.3'
|
46
43
|
}.each do |lib, version|
|
47
44
|
s.add_development_dependency lib, version
|
48
|
-
end
|
45
|
+
end
|
49
46
|
|
50
47
|
{
|
51
48
|
'patron' => '~> 0.4.15',
|
52
49
|
'em-http-request' => '~> 0.3.0',
|
53
|
-
'curb' => '
|
54
|
-
'typhoeus' => '~> 0.2
|
50
|
+
'curb' => '0.7.15',
|
51
|
+
'typhoeus' => '~> 0.3.2'
|
55
52
|
}.each do |lib, version|
|
56
53
|
s.add_development_dependency lib, version
|
57
54
|
end unless RUBY_PLATFORM == 'java'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196455
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 2.0.0.
|
11
|
+
- 2
|
12
|
+
version: 2.0.0.beta2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Myron Marston
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
20
|
+
date: 2011-11-07 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -138,11 +138,11 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
hash:
|
141
|
+
hash: 13
|
142
142
|
segments:
|
143
143
|
- 2
|
144
|
-
-
|
145
|
-
version: "2.
|
144
|
+
- 7
|
145
|
+
version: "2.7"
|
146
146
|
name: rspec
|
147
147
|
type: :development
|
148
148
|
prerelease: false
|
@@ -151,15 +151,15 @@ dependencies:
|
|
151
151
|
version_requirements: &id009 !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
153
153
|
requirements:
|
154
|
-
- -
|
154
|
+
- - ~>
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
hash:
|
156
|
+
hash: 17
|
157
157
|
segments:
|
158
158
|
- 1
|
159
|
-
- 1
|
160
159
|
- 0
|
161
|
-
|
162
|
-
|
160
|
+
- 3
|
161
|
+
version: 1.0.3
|
162
|
+
name: multi_json
|
163
163
|
type: :development
|
164
164
|
prerelease: false
|
165
165
|
requirement: *id009
|
@@ -167,7 +167,7 @@ dependencies:
|
|
167
167
|
version_requirements: &id010 !ruby/object:Gem::Requirement
|
168
168
|
none: false
|
169
169
|
requirements:
|
170
|
-
- -
|
170
|
+
- - "="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
hash: 19
|
173
173
|
segments:
|
@@ -175,7 +175,7 @@ dependencies:
|
|
175
175
|
- 1
|
176
176
|
- 0
|
177
177
|
version: 1.1.0
|
178
|
-
name:
|
178
|
+
name: rack
|
179
179
|
type: :development
|
180
180
|
prerelease: false
|
181
181
|
requirement: *id010
|
@@ -185,13 +185,13 @@ dependencies:
|
|
185
185
|
requirements:
|
186
186
|
- - ~>
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
hash:
|
188
|
+
hash: 3
|
189
189
|
segments:
|
190
|
-
- 1
|
191
190
|
- 0
|
192
|
-
-
|
193
|
-
|
194
|
-
|
191
|
+
- 4
|
192
|
+
- 6
|
193
|
+
version: 0.4.6
|
194
|
+
name: aruba
|
195
195
|
type: :development
|
196
196
|
prerelease: false
|
197
197
|
requirement: *id011
|
@@ -201,13 +201,13 @@ dependencies:
|
|
201
201
|
requirements:
|
202
202
|
- - ~>
|
203
203
|
- !ruby/object:Gem::Version
|
204
|
-
hash:
|
204
|
+
hash: 19
|
205
205
|
segments:
|
206
|
+
- 1
|
207
|
+
- 1
|
206
208
|
- 0
|
207
|
-
|
208
|
-
|
209
|
-
version: 0.6.5
|
210
|
-
name: excon
|
209
|
+
version: 1.1.0
|
210
|
+
name: sinatra
|
211
211
|
type: :development
|
212
212
|
prerelease: false
|
213
213
|
requirement: *id012
|
@@ -217,13 +217,13 @@ dependencies:
|
|
217
217
|
requirements:
|
218
218
|
- - ~>
|
219
219
|
- !ruby/object:Gem::Version
|
220
|
-
hash:
|
220
|
+
hash: 25
|
221
221
|
segments:
|
222
222
|
- 1
|
223
|
+
- 0
|
223
224
|
- 7
|
224
|
-
|
225
|
-
|
226
|
-
name: webmock
|
225
|
+
version: 1.0.7
|
226
|
+
name: bundler
|
227
227
|
type: :development
|
228
228
|
prerelease: false
|
229
229
|
requirement: *id013
|
@@ -233,13 +233,13 @@ dependencies:
|
|
233
233
|
requirements:
|
234
234
|
- - ~>
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
hash:
|
236
|
+
hash: 13
|
237
237
|
segments:
|
238
238
|
- 0
|
239
|
-
- 4
|
240
239
|
- 6
|
241
|
-
|
242
|
-
|
240
|
+
- 5
|
241
|
+
version: 0.6.5
|
242
|
+
name: excon
|
243
243
|
type: :development
|
244
244
|
prerelease: false
|
245
245
|
requirement: *id014
|
@@ -264,6 +264,22 @@ dependencies:
|
|
264
264
|
none: false
|
265
265
|
requirements:
|
266
266
|
- - ~>
|
267
|
+
- !ruby/object:Gem::Version
|
268
|
+
hash: 3
|
269
|
+
segments:
|
270
|
+
- 1
|
271
|
+
- 7
|
272
|
+
- 4
|
273
|
+
version: 1.7.4
|
274
|
+
name: webmock
|
275
|
+
type: :development
|
276
|
+
prerelease: false
|
277
|
+
requirement: *id016
|
278
|
+
- !ruby/object:Gem::Dependency
|
279
|
+
version_requirements: &id017 !ruby/object:Gem::Requirement
|
280
|
+
none: false
|
281
|
+
requirements:
|
282
|
+
- - "="
|
267
283
|
- !ruby/object:Gem::Version
|
268
284
|
hash: 29
|
269
285
|
segments:
|
@@ -274,9 +290,9 @@ dependencies:
|
|
274
290
|
name: curb
|
275
291
|
type: :development
|
276
292
|
prerelease: false
|
277
|
-
requirement: *
|
293
|
+
requirement: *id017
|
278
294
|
- !ruby/object:Gem::Dependency
|
279
|
-
version_requirements: &
|
295
|
+
version_requirements: &id018 !ruby/object:Gem::Requirement
|
280
296
|
none: false
|
281
297
|
requirements:
|
282
298
|
- - ~>
|
@@ -290,9 +306,9 @@ dependencies:
|
|
290
306
|
name: patron
|
291
307
|
type: :development
|
292
308
|
prerelease: false
|
293
|
-
requirement: *
|
309
|
+
requirement: *id018
|
294
310
|
- !ruby/object:Gem::Dependency
|
295
|
-
version_requirements: &
|
311
|
+
version_requirements: &id019 !ruby/object:Gem::Requirement
|
296
312
|
none: false
|
297
313
|
requirements:
|
298
314
|
- - ~>
|
@@ -306,23 +322,23 @@ dependencies:
|
|
306
322
|
name: em-http-request
|
307
323
|
type: :development
|
308
324
|
prerelease: false
|
309
|
-
requirement: *
|
325
|
+
requirement: *id019
|
310
326
|
- !ruby/object:Gem::Dependency
|
311
|
-
version_requirements: &
|
327
|
+
version_requirements: &id020 !ruby/object:Gem::Requirement
|
312
328
|
none: false
|
313
329
|
requirements:
|
314
330
|
- - ~>
|
315
331
|
- !ruby/object:Gem::Version
|
316
|
-
hash:
|
332
|
+
hash: 23
|
317
333
|
segments:
|
318
334
|
- 0
|
335
|
+
- 3
|
319
336
|
- 2
|
320
|
-
|
321
|
-
version: 0.2.1
|
337
|
+
version: 0.3.2
|
322
338
|
name: typhoeus
|
323
339
|
type: :development
|
324
340
|
prerelease: false
|
325
|
-
requirement: *
|
341
|
+
requirement: *id020
|
326
342
|
description: VCR provides a simple API to record and replay your test suite's HTTP interactions. It works with a variety of HTTP client libraries, HTTP stubbing libraries and testing frameworks.
|
327
343
|
email: myron.marston@gmail.com
|
328
344
|
executables: []
|
@@ -344,6 +360,7 @@ files:
|
|
344
360
|
- LICENSE
|
345
361
|
- README.md
|
346
362
|
- Rakefile
|
363
|
+
- Upgrade.md
|
347
364
|
- benchmarks/http_stubbing_libraries.rb
|
348
365
|
- cucumber.yml
|
349
366
|
- features/.nav
|
@@ -394,7 +411,13 @@ files:
|
|
394
411
|
- lib/vcr.rb
|
395
412
|
- lib/vcr/cassette.rb
|
396
413
|
- lib/vcr/cassette/http_interaction_list.rb
|
414
|
+
- lib/vcr/cassette/migrator.rb
|
397
415
|
- lib/vcr/cassette/reader.rb
|
416
|
+
- lib/vcr/cassette/serializers.rb
|
417
|
+
- lib/vcr/cassette/serializers/json.rb
|
418
|
+
- lib/vcr/cassette/serializers/psych.rb
|
419
|
+
- lib/vcr/cassette/serializers/syck.rb
|
420
|
+
- lib/vcr/cassette/serializers/yaml.rb
|
398
421
|
- lib/vcr/configuration.rb
|
399
422
|
- lib/vcr/deprecations.rb
|
400
423
|
- lib/vcr/errors.rb
|
@@ -410,26 +433,20 @@ files:
|
|
410
433
|
- lib/vcr/request_handler.rb
|
411
434
|
- lib/vcr/request_ignorer.rb
|
412
435
|
- lib/vcr/request_matcher_registry.rb
|
413
|
-
- lib/vcr/structs
|
414
|
-
- lib/vcr/
|
415
|
-
- lib/vcr/structs/normalizers/header.rb
|
416
|
-
- lib/vcr/structs/normalizers/status_message.rb
|
417
|
-
- lib/vcr/structs/normalizers/uri.rb
|
418
|
-
- lib/vcr/structs/request.rb
|
419
|
-
- lib/vcr/structs/response.rb
|
420
|
-
- lib/vcr/structs/response_status.rb
|
436
|
+
- lib/vcr/structs.rb
|
437
|
+
- lib/vcr/tasks/vcr.rake
|
421
438
|
- lib/vcr/test_frameworks/cucumber.rb
|
422
439
|
- lib/vcr/test_frameworks/rspec.rb
|
423
440
|
- lib/vcr/util/hooks.rb
|
424
441
|
- lib/vcr/util/internet_connection.rb
|
425
442
|
- lib/vcr/util/variable_args_block_caller.rb
|
426
443
|
- lib/vcr/util/version_checker.rb
|
427
|
-
- lib/vcr/util/yaml.rb
|
428
444
|
- lib/vcr/version.rb
|
429
445
|
- script/FullBuildRakeFile
|
430
446
|
- script/full_build
|
431
447
|
- script/spec
|
432
448
|
- spec/capture_warnings.rb
|
449
|
+
- spec/fixtures/cassette_spec/1_x_cassette.yml
|
433
450
|
- spec/fixtures/cassette_spec/empty.yml
|
434
451
|
- spec/fixtures/cassette_spec/example.yml
|
435
452
|
- spec/fixtures/cassette_spec/with_localhost_requests.yml
|
@@ -441,12 +458,13 @@ files:
|
|
441
458
|
- spec/support/http_library_adapters.rb
|
442
459
|
- spec/support/ruby_interpreter.rb
|
443
460
|
- spec/support/shared_example_groups/hook_into_http_library.rb
|
444
|
-
- spec/support/shared_example_groups/normalizers.rb
|
445
461
|
- spec/support/shared_example_groups/version_checking.rb
|
446
462
|
- spec/support/sinatra_app.rb
|
447
463
|
- spec/support/vcr_localhost_server.rb
|
448
464
|
- spec/vcr/cassette/http_interaction_list_spec.rb
|
465
|
+
- spec/vcr/cassette/migrator_spec.rb
|
449
466
|
- spec/vcr/cassette/reader_spec.rb
|
467
|
+
- spec/vcr/cassette/serializers_spec.rb
|
450
468
|
- spec/vcr/cassette_spec.rb
|
451
469
|
- spec/vcr/configuration_spec.rb
|
452
470
|
- spec/vcr/deprecations_spec.rb
|
@@ -460,10 +478,7 @@ files:
|
|
460
478
|
- spec/vcr/middleware/rack_spec.rb
|
461
479
|
- spec/vcr/request_ignorer_spec.rb
|
462
480
|
- spec/vcr/request_matcher_registry_spec.rb
|
463
|
-
- spec/vcr/
|
464
|
-
- spec/vcr/structs/request_spec.rb
|
465
|
-
- spec/vcr/structs/response_spec.rb
|
466
|
-
- spec/vcr/structs/response_status_spec.rb
|
481
|
+
- spec/vcr/structs_spec.rb
|
467
482
|
- spec/vcr/test_frameworks/cucumber_spec.rb
|
468
483
|
- spec/vcr/test_frameworks/rspec_spec.rb
|
469
484
|
- spec/vcr/util/hooks_spec.rb
|
@@ -554,6 +569,7 @@ test_files:
|
|
554
569
|
- features/test_frameworks/shoulda.feature
|
555
570
|
- features/test_frameworks/test_unit.feature
|
556
571
|
- spec/capture_warnings.rb
|
572
|
+
- spec/fixtures/cassette_spec/1_x_cassette.yml
|
557
573
|
- spec/fixtures/cassette_spec/empty.yml
|
558
574
|
- spec/fixtures/cassette_spec/example.yml
|
559
575
|
- spec/fixtures/cassette_spec/with_localhost_requests.yml
|
@@ -565,12 +581,13 @@ test_files:
|
|
565
581
|
- spec/support/http_library_adapters.rb
|
566
582
|
- spec/support/ruby_interpreter.rb
|
567
583
|
- spec/support/shared_example_groups/hook_into_http_library.rb
|
568
|
-
- spec/support/shared_example_groups/normalizers.rb
|
569
584
|
- spec/support/shared_example_groups/version_checking.rb
|
570
585
|
- spec/support/sinatra_app.rb
|
571
586
|
- spec/support/vcr_localhost_server.rb
|
572
587
|
- spec/vcr/cassette/http_interaction_list_spec.rb
|
588
|
+
- spec/vcr/cassette/migrator_spec.rb
|
573
589
|
- spec/vcr/cassette/reader_spec.rb
|
590
|
+
- spec/vcr/cassette/serializers_spec.rb
|
574
591
|
- spec/vcr/cassette_spec.rb
|
575
592
|
- spec/vcr/configuration_spec.rb
|
576
593
|
- spec/vcr/deprecations_spec.rb
|
@@ -584,10 +601,7 @@ test_files:
|
|
584
601
|
- spec/vcr/middleware/rack_spec.rb
|
585
602
|
- spec/vcr/request_ignorer_spec.rb
|
586
603
|
- spec/vcr/request_matcher_registry_spec.rb
|
587
|
-
- spec/vcr/
|
588
|
-
- spec/vcr/structs/request_spec.rb
|
589
|
-
- spec/vcr/structs/response_spec.rb
|
590
|
-
- spec/vcr/structs/response_status_spec.rb
|
604
|
+
- spec/vcr/structs_spec.rb
|
591
605
|
- spec/vcr/test_frameworks/cucumber_spec.rb
|
592
606
|
- spec/vcr/test_frameworks/rspec_spec.rb
|
593
607
|
- spec/vcr/util/hooks_spec.rb
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
require 'vcr/structs/normalizers/body'
|
3
|
-
require 'vcr/structs/normalizers/header'
|
4
|
-
require 'vcr/structs/normalizers/status_message'
|
5
|
-
require 'vcr/structs/normalizers/uri'
|
6
|
-
require 'vcr/structs/request'
|
7
|
-
require 'vcr/structs/response'
|
8
|
-
|
9
|
-
module VCR
|
10
|
-
class HTTPInteraction < Struct.new(:request, :response)
|
11
|
-
extend ::Forwardable
|
12
|
-
def_delegators :request, :uri, :method
|
13
|
-
|
14
|
-
def ignore!
|
15
|
-
# we don't want to store any additional
|
16
|
-
# ivars on this object because that would get
|
17
|
-
# serialized with the object...so we redefine
|
18
|
-
# `ignored?` instead.
|
19
|
-
(class << self; self; end).class_eval do
|
20
|
-
undef ignored?
|
21
|
-
def ignored?; true; end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def ignored?
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
def filter!(text, replacement_text)
|
30
|
-
return self if [text, replacement_text].any? { |t| t.to_s.empty? }
|
31
|
-
filter_object!(self, text, replacement_text)
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def filter_object!(object, text, replacement_text)
|
37
|
-
if object.respond_to?(:gsub)
|
38
|
-
object.gsub!(text, replacement_text) if object.include?(text)
|
39
|
-
elsif Hash === object
|
40
|
-
filter_hash!(object, text, replacement_text)
|
41
|
-
elsif object.respond_to?(:each)
|
42
|
-
# This handles nested arrays and structs
|
43
|
-
object.each { |o| filter_object!(o, text, replacement_text) }
|
44
|
-
end
|
45
|
-
|
46
|
-
object
|
47
|
-
end
|
48
|
-
|
49
|
-
def filter_hash!(hash, text, replacement_text)
|
50
|
-
filter_object!(hash.values, text, replacement_text)
|
51
|
-
|
52
|
-
hash.keys.each do |k|
|
53
|
-
new_key = filter_object!(k.dup, text, replacement_text)
|
54
|
-
hash[new_key] = hash.delete(k) unless k == new_key
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|