lhc 6.3.1 → 6.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df32b734a941e2e400a2f41960b512146e90d5f4
4
- data.tar.gz: cb8da5bda727e9559996c51d470efc5c3dcfb5b0
3
+ metadata.gz: 80f4055f440bc7f36343e387c27cbe4526e2969e
4
+ data.tar.gz: 50b0cb3ae16bc7cc9098a2e9069d03d91314304b
5
5
  SHA512:
6
- metadata.gz: 852ce45fb78bfe61eac47f742fd64ba660297bb2d7b32e1d534dd7b23ea949a11b919e99d1b60d153878c01914f5079ea10b802cda504d1aa2d5407957cb38eb
7
- data.tar.gz: eecf72175a37b139a8a4b74682196384898427d18a469a043341701b49cc70f4844c2746dae1493b1913e562036dfd20be2cb6fb578d95145395fe3733a88cf0
6
+ metadata.gz: e71ceba6f6f43b0112aecf6d8b92470628cbdf29e855c237a8ec26a2cf22f13ed24add47230268daf4e74a16574fb4e5b23f72744e7ef36bece5b1945d953e7a
7
+ data.tar.gz: 6f1d15f6cb8b7aff8cfc64553d8366a951f4d8bd579e57c182003be2011955bf8da967de2fb1e9fc0af8c4648e7c285928f2d8a5a7a6ba4fc19b76245bbd019a
data/README.md CHANGED
@@ -165,6 +165,8 @@ response = LHC.get('http://something', ignored_errors: [LHC::NotFound])
165
165
 
166
166
  response.body # nil
167
167
  response.data # nil
168
+ response.error_ignored? # true
169
+ response.request.error_ignored? # true
168
170
  ```
169
171
 
170
172
  ## Interceptors
@@ -39,6 +39,10 @@ class LHC::Request
39
39
  raw.options.fetch(:params, nil) || raw.options[:params] = {}
40
40
  end
41
41
 
42
+ def error_ignored?
43
+ ignore_error?
44
+ end
45
+
42
46
  private
43
47
 
44
48
  attr_accessor :iprocessor
@@ -108,9 +112,11 @@ class LHC::Request
108
112
  end
109
113
 
110
114
  def ignore_error?
111
- errors_ignored.detect do |ignored_error|
112
- error <= ignored_error
113
- end.present?
115
+ @ignore_error ||= begin
116
+ errors_ignored.detect do |ignored_error|
117
+ error <= ignored_error
118
+ end.present?
119
+ end
114
120
  end
115
121
 
116
122
  def error
@@ -9,6 +9,7 @@ class LHC::Response
9
9
  attr_reader :from_cache
10
10
 
11
11
  delegate :effective_url, :code, :headers, :options, :mock, :success?, to: :raw
12
+ delegate :error_ignored?, to: :request
12
13
  alias from_cache? from_cache
13
14
 
14
15
  # A response is initalized with the underlying raw response (typhoeus in our case)
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= "6.3.1"
2
+ VERSION ||= "6.4.0"
3
3
  end
@@ -2,24 +2,29 @@ require 'rails_helper'
2
2
 
3
3
  describe LHC::Request do
4
4
  context 'ignoring LHC::NotFound' do
5
- subject { LHC.get('http://local.ch', ignored_errors: [LHC::NotFound]) }
5
+ let(:response) { LHC.get('http://local.ch', ignored_errors: [LHC::NotFound]) }
6
6
  before { stub_request(:get, 'http://local.ch').to_return(status: 404) }
7
7
 
8
8
  it 'does not raise an error' do
9
- expect { subject }.not_to raise_error
9
+ expect { response }.not_to raise_error
10
10
  end
11
11
 
12
12
  it 'body is nil' do
13
- expect(subject.body).to eq nil
13
+ expect(response.body).to eq nil
14
14
  end
15
15
 
16
16
  it 'data is nil' do
17
- expect(subject.data).to eq nil
17
+ expect(response.data).to eq nil
18
18
  end
19
19
 
20
20
  it 'does raise an error for 500' do
21
21
  stub_request(:get, 'http://local.ch').to_return(status: 500)
22
- expect { subject }.to raise_error LHC::InternalServerError
22
+ expect { response }.to raise_error LHC::InternalServerError
23
+ end
24
+
25
+ it 'provides the information if the error was ignored' do
26
+ expect(response.error_ignored?).to eq true
27
+ expect(response.request.error_ignored?).to eq true
23
28
  end
24
29
  end
25
30
 
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: 6.3.1
4
+ version: 6.4.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: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus