lhc 12.1.1 → 12.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhc/response/data.rb +2 -2
- data/lib/lhc/response/data/base.rb +2 -6
- data/lib/lhc/version.rb +1 -1
- data/spec/response/data_spec.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c7bdb4bd4a91af430b69b11f503806f9fdc55cae4154dad422ac425c91b5c14
|
4
|
+
data.tar.gz: 625949e2cdbf59636411283b7ce9e6db35273ffb54612c9e3aa5a52d49c0d928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a88ba1534ec293a977484aea27613fc99c7329368b210924b74325904f28a77ac8d6b7e504b3228ee8a39b3f453b8efca1d4fdf354872b0d35177625803b68d
|
7
|
+
data.tar.gz: 2af73f13c98546e6cca30e35ca3bba4c7b2980790fe1ac35de3a339d63883f9d55e5d624932bdafac315dda1c58fa9e809739a5364f289ec73556c213c78f731
|
data/lib/lhc/response/data.rb
CHANGED
@@ -12,9 +12,9 @@ class LHC::Response::Data
|
|
12
12
|
@data = data
|
13
13
|
|
14
14
|
if as_json.is_a?(Hash)
|
15
|
-
@base = LHC::Response::Data::Item.new(response, data: data)
|
15
|
+
@base = LHC::Response::Data::Item.new(@response, data: data)
|
16
16
|
elsif as_json.is_a?(Array)
|
17
|
-
@base = LHC::Response::Data::Collection.new(response, data: data)
|
17
|
+
@base = LHC::Response::Data::Collection.new(@response, data: data)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# but made accssible in the ruby world
|
5
5
|
module LHC::Response::Data::Base
|
6
6
|
def as_json
|
7
|
-
@json ||= (@data || response.format.as_json(response.body))
|
7
|
+
@json ||= (@data || @response.format.as_json(@response.body))
|
8
8
|
end
|
9
9
|
|
10
10
|
def as_open_struct
|
@@ -12,11 +12,7 @@ module LHC::Response::Data::Base
|
|
12
12
|
if @data
|
13
13
|
JSON.parse(@data.to_json, object_class: OpenStruct)
|
14
14
|
else
|
15
|
-
response.format.as_open_struct(response.body)
|
15
|
+
@response.format.as_open_struct(@response.body)
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :response
|
22
18
|
end
|
data/lib/lhc/version.rb
CHANGED
data/spec/response/data_spec.rb
CHANGED
@@ -58,4 +58,28 @@ describe LHC::Response do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
context 'response data if responding error data contains a response' do
|
63
|
+
before do
|
64
|
+
stub_request(:get, "http://listings/")
|
65
|
+
.to_return(status: 404, body: {
|
66
|
+
meta: {
|
67
|
+
errors: [
|
68
|
+
{ code: 2000, msg: 'I like to hide error messages (this is meta).' }
|
69
|
+
]
|
70
|
+
},
|
71
|
+
response: 'why not?'
|
72
|
+
}.to_json)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'does not throw a stack level to deep issue when accessing data in a rescue context' do
|
76
|
+
begin
|
77
|
+
LHC.get('http://listings')
|
78
|
+
rescue LHC::Error => error
|
79
|
+
expect(
|
80
|
+
error.response.request.response.data.meta.errors.detect { |item| item.code == 2000 }.msg
|
81
|
+
).to eq 'I like to hide error messages (this is meta).'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
61
85
|
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: 12.1.
|
4
|
+
version: 12.1.2
|
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: 2020-
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|