lhc 12.1.1 → 12.1.2

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
  SHA256:
3
- metadata.gz: a8c1cf6d1d9237c3cad231ae1fca7cadfcaaf6283eb429544945715235172b61
4
- data.tar.gz: 9945fabdbdd44fbef2fd472f0e4f7a37f347393b92fda1918abda13d6b65d195
3
+ metadata.gz: 7c7bdb4bd4a91af430b69b11f503806f9fdc55cae4154dad422ac425c91b5c14
4
+ data.tar.gz: 625949e2cdbf59636411283b7ce9e6db35273ffb54612c9e3aa5a52d49c0d928
5
5
  SHA512:
6
- metadata.gz: d208eca04aac94eb7f93b3053590df5c0626165cddf479ca3b1ea94907a71ee530df9de76f86f6b6492f14936a77d06f3ae296c9a854c8f1262866fdc4bad3bf
7
- data.tar.gz: eaa8166c752a295b34a2b6e0c3406bee09f771a77f2f17ba39b509396fa264ce9387ea5f2dc507fa50f51c2287c0d4fe57bc9849dfdada0a7fc2572aaf5527bf
6
+ metadata.gz: 0a88ba1534ec293a977484aea27613fc99c7329368b210924b74325904f28a77ac8d6b7e504b3228ee8a39b3f453b8efca1d4fdf354872b0d35177625803b68d
7
+ data.tar.gz: 2af73f13c98546e6cca30e35ca3bba4c7b2980790fe1ac35de3a339d63883f9d55e5d624932bdafac315dda1c58fa9e809739a5364f289ec73556c213c78f731
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHC
4
- VERSION ||= '12.1.1'
4
+ VERSION ||= '12.1.2'
5
5
  end
@@ -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.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-07-30 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport