lhc 15.1.3 → 15.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lhc.gemspec +1 -2
- data/lib/lhc/interceptors/rollbar.rb +11 -2
- data/lib/lhc/version.rb +1 -1
- data/spec/error/to_s_spec.rb +2 -2
- data/spec/interceptors/rollbar/main_spec.rb +19 -0
- metadata +3 -138
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b791317124325a44a99ca08c5cfabb611affd67d38603476151c106b84d924
|
4
|
+
data.tar.gz: 198d4f707ab907c7209ea1f8bbf41452f46fb3079dbf14a73f243ed37b09d6dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6955a082a0e31f564f7b4c6243bfd8274e684cb392702f38d81f044d9ccbc9ff20085428d2529e6a48bd3f194ff69c99686c7744ce681ac8234942f1d4830f5
|
7
|
+
data.tar.gz: 5b11847bfb5f8a9e00797e7c8d87dbd5f9784c6f60cb926d414723fc16faf0fba871ffc6917e63475a6a6a3ae8b49b112b7c6f8fc716a6ee61deaa42d2a040f0
|
data/lhc.gemspec
CHANGED
@@ -15,8 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.summary = 'Advanced HTTP Client for Ruby, fueled with interceptors'
|
16
16
|
s.description = 'LHC is an extended/advanced HTTP client. Implementing basic http-communication enhancements like interceptors, exception handling, format handling, accessing response data, configuring endpoints and placeholders and fully compatible, RFC-compliant URL-template support.'
|
17
17
|
|
18
|
-
s.files
|
19
|
-
s.test_files = `git ls-files -- spec/*`.split("\n")
|
18
|
+
s.files = `git ls-files`.split("\n")
|
20
19
|
s.require_paths = ['lib']
|
21
20
|
|
22
21
|
s.requirements << 'Ruby >= 2.0.0'
|
@@ -8,7 +8,7 @@ class LHC::Rollbar < LHC::Interceptor
|
|
8
8
|
|
9
9
|
def after_response
|
10
10
|
return unless Object.const_defined?(:Rollbar)
|
11
|
-
return
|
11
|
+
return unless report?
|
12
12
|
|
13
13
|
request = response.request
|
14
14
|
additional_params = request.options.fetch(:rollbar, {})
|
@@ -29,9 +29,18 @@ class LHC::Rollbar < LHC::Interceptor
|
|
29
29
|
}.merge additional_params
|
30
30
|
begin
|
31
31
|
Rollbar.warning("Status: #{response.code} URL: #{request.url}", data)
|
32
|
-
rescue Encoding::UndefinedConversionError
|
32
|
+
rescue JSON::GeneratorError, Encoding::UndefinedConversionError
|
33
33
|
sanitized_data = data.deep_transform_values { |value| self.class.fix_invalid_encoding(value) }
|
34
34
|
Rollbar.warning("Status: #{response.code} URL: #{request.url}", sanitized_data)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def report?
|
41
|
+
return false if response.success?
|
42
|
+
return false if response.request.error_ignored?
|
43
|
+
|
44
|
+
true
|
45
|
+
end
|
37
46
|
end
|
data/lib/lhc/version.rb
CHANGED
data/spec/error/to_s_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe LHC::Error do
|
|
15
15
|
expect { "#{valid} #{invalid}" }.to raise_error Encoding::CompatibilityError
|
16
16
|
end
|
17
17
|
it 'to_json on an array raises an error' do
|
18
|
-
expect { [valid, invalid].to_json }.to raise_error
|
18
|
+
expect { [valid, invalid].to_json }.to raise_error JSON::GeneratorError
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'to_s on a hash does not raise an error' do
|
@@ -23,7 +23,7 @@ describe LHC::Error do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'to_json on a hash does raise an error' do
|
26
|
-
expect { { valid: valid, invalid: invalid }.to_json }.to raise_error
|
26
|
+
expect { { valid: valid, invalid: invalid }.to_json }.to raise_error JSON::GeneratorError
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -65,5 +65,24 @@ describe LHC::Rollbar do
|
|
65
65
|
request: hash_including(url: anything, method: anything, headers: hash_including(private_key: LHC::Scrubber::SCRUB_DISPLAY), params: { api_key: LHC::Scrubber::SCRUB_DISPLAY })
|
66
66
|
)
|
67
67
|
end
|
68
|
+
|
69
|
+
context 'ignored errors' do
|
70
|
+
it 'does not report to rollbar if the error is ignored' do
|
71
|
+
stub_request(:get, 'http://local.ch').to_return(status: 404)
|
72
|
+
LHC.get('http://local.ch', ignore: [LHC::NotFound])
|
73
|
+
expect(::Rollbar).not_to have_received(:warning)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'does report to rollbar' do
|
77
|
+
stub_request(:get, 'http://local.ch').to_return(status: 400)
|
78
|
+
expect(-> { LHC.get('http://local.ch', ignore: [LHC::NotFound]) }).to raise_error LHC::BadRequest
|
79
|
+
expect(::Rollbar).not_to have_received(:warning)
|
80
|
+
.with(
|
81
|
+
'Status: 400 URL: http://local.ch',
|
82
|
+
response: hash_including(body: anything, code: anything, headers: anything, time: anything, timeout?: anything),
|
83
|
+
request: hash_including(url: anything, method: anything, headers: hash_including(private_key: LHC::Scrubber::SCRUB_DISPLAY), params: { api_key: LHC::Scrubber::SCRUB_DISPLAY })
|
84
|
+
)
|
85
|
+
end
|
86
|
+
end
|
68
87
|
end
|
69
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 15.
|
4
|
+
version: 15.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhc/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -467,139 +467,4 @@ rubygems_version: 3.1.4
|
|
467
467
|
signing_key:
|
468
468
|
specification_version: 4
|
469
469
|
summary: Advanced HTTP Client for Ruby, fueled with interceptors
|
470
|
-
test_files:
|
471
|
-
- spec/basic_methods/delete_spec.rb
|
472
|
-
- spec/basic_methods/get_spec.rb
|
473
|
-
- spec/basic_methods/post_spec.rb
|
474
|
-
- spec/basic_methods/put_spec.rb
|
475
|
-
- spec/basic_methods/request_spec.rb
|
476
|
-
- spec/basic_methods/request_without_rails_spec.rb
|
477
|
-
- spec/config/endpoints_spec.rb
|
478
|
-
- spec/config/placeholders_spec.rb
|
479
|
-
- spec/config/scrubs_spec.rb
|
480
|
-
- spec/core_ext/hash/deep_transform_values_spec.rb
|
481
|
-
- spec/dummy/README.rdoc
|
482
|
-
- spec/dummy/Rakefile
|
483
|
-
- spec/dummy/app/assets/config/manifest.js
|
484
|
-
- spec/dummy/app/assets/images/.keep
|
485
|
-
- spec/dummy/app/assets/javascripts/application.js
|
486
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
487
|
-
- spec/dummy/app/controllers/application_controller.rb
|
488
|
-
- spec/dummy/app/controllers/concerns/.keep
|
489
|
-
- spec/dummy/app/helpers/application_helper.rb
|
490
|
-
- spec/dummy/app/mailers/.keep
|
491
|
-
- spec/dummy/app/models/.keep
|
492
|
-
- spec/dummy/app/models/concerns/.keep
|
493
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
494
|
-
- spec/dummy/bin/bundle
|
495
|
-
- spec/dummy/bin/rails
|
496
|
-
- spec/dummy/bin/rake
|
497
|
-
- spec/dummy/config.ru
|
498
|
-
- spec/dummy/config/application.rb
|
499
|
-
- spec/dummy/config/boot.rb
|
500
|
-
- spec/dummy/config/environment.rb
|
501
|
-
- spec/dummy/config/environments/development.rb
|
502
|
-
- spec/dummy/config/environments/production.rb
|
503
|
-
- spec/dummy/config/environments/test.rb
|
504
|
-
- spec/dummy/config/initializers/assets.rb
|
505
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
506
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
507
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
508
|
-
- spec/dummy/config/initializers/inflections.rb
|
509
|
-
- spec/dummy/config/initializers/mime_types.rb
|
510
|
-
- spec/dummy/config/initializers/session_store.rb
|
511
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
512
|
-
- spec/dummy/config/locales/en.yml
|
513
|
-
- spec/dummy/config/routes.rb
|
514
|
-
- spec/dummy/config/secrets.yml
|
515
|
-
- spec/dummy/lib/assets/.keep
|
516
|
-
- spec/dummy/log/.keep
|
517
|
-
- spec/dummy/public/404.html
|
518
|
-
- spec/dummy/public/422.html
|
519
|
-
- spec/dummy/public/500.html
|
520
|
-
- spec/dummy/public/favicon.ico
|
521
|
-
- spec/dummy/tmp/cache/.gitkeep
|
522
|
-
- spec/endpoint/compile_spec.rb
|
523
|
-
- spec/endpoint/match_spec.rb
|
524
|
-
- spec/endpoint/placeholders_spec.rb
|
525
|
-
- spec/endpoint/remove_interpolated_params_spec.rb
|
526
|
-
- spec/endpoint/values_as_params_spec.rb
|
527
|
-
- spec/error/dup_spec.rb
|
528
|
-
- spec/error/find_spec.rb
|
529
|
-
- spec/error/response_spec.rb
|
530
|
-
- spec/error/timeout_spec.rb
|
531
|
-
- spec/error/to_s_spec.rb
|
532
|
-
- spec/formats/form_spec.rb
|
533
|
-
- spec/formats/json_spec.rb
|
534
|
-
- spec/formats/multipart_spec.rb
|
535
|
-
- spec/formats/plain_spec.rb
|
536
|
-
- spec/interceptors/after_request_spec.rb
|
537
|
-
- spec/interceptors/after_response_spec.rb
|
538
|
-
- spec/interceptors/auth/basic_auth_spec.rb
|
539
|
-
- spec/interceptors/auth/bearer_spec.rb
|
540
|
-
- spec/interceptors/auth/body_spec.rb
|
541
|
-
- spec/interceptors/auth/long_basic_auth_credentials_spec.rb
|
542
|
-
- spec/interceptors/auth/no_instance_var_for_options_spec.rb
|
543
|
-
- spec/interceptors/auth/reauthentication_configuration_spec.rb
|
544
|
-
- spec/interceptors/auth/reauthentication_spec.rb
|
545
|
-
- spec/interceptors/before_request_spec.rb
|
546
|
-
- spec/interceptors/before_response_spec.rb
|
547
|
-
- spec/interceptors/caching/hydra_spec.rb
|
548
|
-
- spec/interceptors/caching/main_spec.rb
|
549
|
-
- spec/interceptors/caching/methods_spec.rb
|
550
|
-
- spec/interceptors/caching/multilevel_cache_spec.rb
|
551
|
-
- spec/interceptors/caching/options_spec.rb
|
552
|
-
- spec/interceptors/caching/parameters_spec.rb
|
553
|
-
- spec/interceptors/caching/response_status_spec.rb
|
554
|
-
- spec/interceptors/caching/to_cache_spec.rb
|
555
|
-
- spec/interceptors/default_interceptors_spec.rb
|
556
|
-
- spec/interceptors/default_timeout/main_spec.rb
|
557
|
-
- spec/interceptors/define_spec.rb
|
558
|
-
- spec/interceptors/dup_spec.rb
|
559
|
-
- spec/interceptors/logging/main_spec.rb
|
560
|
-
- spec/interceptors/monitoring/caching_spec.rb
|
561
|
-
- spec/interceptors/monitoring/main_spec.rb
|
562
|
-
- spec/interceptors/prometheus_spec.rb
|
563
|
-
- spec/interceptors/response_competition_spec.rb
|
564
|
-
- spec/interceptors/retry/main_spec.rb
|
565
|
-
- spec/interceptors/return_response_spec.rb
|
566
|
-
- spec/interceptors/rollbar/invalid_encoding_spec.rb
|
567
|
-
- spec/interceptors/rollbar/main_spec.rb
|
568
|
-
- spec/interceptors/throttle/main_spec.rb
|
569
|
-
- spec/interceptors/throttle/reset_track_spec.rb
|
570
|
-
- spec/interceptors/zipkin/distributed_tracing_spec.rb
|
571
|
-
- spec/rails_helper.rb
|
572
|
-
- spec/request/body_spec.rb
|
573
|
-
- spec/request/encoding_spec.rb
|
574
|
-
- spec/request/error_handling_spec.rb
|
575
|
-
- spec/request/headers_spec.rb
|
576
|
-
- spec/request/ignore_errors_spec.rb
|
577
|
-
- spec/request/option_dup_spec.rb
|
578
|
-
- spec/request/parallel_requests_spec.rb
|
579
|
-
- spec/request/params_encoding_spec.rb
|
580
|
-
- spec/request/request_without_rails_spec.rb
|
581
|
-
- spec/request/scrubbed_headers_spec.rb
|
582
|
-
- spec/request/scrubbed_options_spec.rb
|
583
|
-
- spec/request/scrubbed_params_spec.rb
|
584
|
-
- spec/request/url_patterns_spec.rb
|
585
|
-
- spec/request/user_agent_spec.rb
|
586
|
-
- spec/request/user_agent_without_rails_spec.rb
|
587
|
-
- spec/response/body_spec.rb
|
588
|
-
- spec/response/code_spec.rb
|
589
|
-
- spec/response/data_accessor_spec.rb
|
590
|
-
- spec/response/data_spec.rb
|
591
|
-
- spec/response/effective_url_spec.rb
|
592
|
-
- spec/response/headers_spec.rb
|
593
|
-
- spec/response/options_spec.rb
|
594
|
-
- spec/response/scrubbed_options_spec.rb
|
595
|
-
- spec/response/success_spec.rb
|
596
|
-
- spec/response/time_spec.rb
|
597
|
-
- spec/spec_helper.rb
|
598
|
-
- spec/support/fixtures/json/feedback.json
|
599
|
-
- spec/support/fixtures/json/feedbacks.json
|
600
|
-
- spec/support/fixtures/json/localina_content_ad.json
|
601
|
-
- spec/support/load_json.rb
|
602
|
-
- spec/support/reset_config.rb
|
603
|
-
- spec/support/zipkin_mock.rb
|
604
|
-
- spec/timeouts/no_signal_spec.rb
|
605
|
-
- spec/timeouts/timings_spec.rb
|
470
|
+
test_files: []
|