lhs 14.0.1 → 14.0.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 +4 -4
- data/.rubocop.yml +3 -0
- data/lhs.gemspec +1 -1
- data/lib/lhs/concerns/record/chainable.rb +3 -3
- data/lib/lhs/concerns/record/find.rb +2 -2
- data/lib/lhs/concerns/record/find_by.rb +2 -2
- data/lib/lhs/concerns/record/request.rb +1 -0
- data/lib/lhs/version.rb +1 -1
- data/spec/record/ignore_errors_spec.rb +30 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7522953bf45a34511846a1b84fb66d60afb359ef
|
4
|
+
data.tar.gz: 1cc7f7f9efda635f6421370dce4f9701d2ff5bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85a6f023c1e558947992ba04f93a37dac7fb9d7465cf4aafa1c5d92d4b950205cf227c56af63cd20f7545cdf2ce20c7a15d1ee51ff5998e603a2d9f02626f7f8
|
7
|
+
data.tar.gz: 74dcce5b6bc450bb9d2791c91b4b3b15171db2226b89b8d7b296746eff53640c7c5e73da516d9fc8a4bd0f39a6cb4b7a964f7e71475746606bf221b4a0d637a3
|
data/.rubocop.yml
CHANGED
data/lhs.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.requirements << 'Ruby >= 2.3.0'
|
21
21
|
s.required_ruby_version = '>= 2.3.0'
|
22
22
|
|
23
|
-
s.add_dependency 'lhc', '>= 6.
|
23
|
+
s.add_dependency 'lhc', '>= 6.4.0'
|
24
24
|
s.add_dependency 'activesupport', '> 4.2'
|
25
25
|
s.add_dependency 'activemodel'
|
26
26
|
|
@@ -311,9 +311,9 @@ class LHS::Record
|
|
311
311
|
end
|
312
312
|
|
313
313
|
def resolve
|
314
|
-
@resolved
|
315
|
-
|
316
|
-
)
|
314
|
+
return @resolved if defined?(@resolved)
|
315
|
+
response_data = @record_class.request(resolved_options)
|
316
|
+
@resolved = response_data ? @record_class.new(response_data) : nil
|
317
317
|
end
|
318
318
|
|
319
319
|
def resolved_options
|
@@ -17,8 +17,8 @@ class LHS::Record
|
|
17
17
|
else
|
18
18
|
find_by_id(args, options)
|
19
19
|
end
|
20
|
-
return data if data.is_a?(Array) || !data._record
|
21
|
-
data._record.new(data)
|
20
|
+
return data if data && (data.is_a?(Array) || !data._record)
|
21
|
+
data ? data._record.new(data) : nil
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -24,9 +24,9 @@ class LHS::Record
|
|
24
24
|
options ||= {}
|
25
25
|
params = params.dup.merge(limit: 1).merge(options.fetch(:params, {}))
|
26
26
|
data = request(options.merge(params: params))
|
27
|
-
if data._proxy.is_a?(LHS::Collection)
|
27
|
+
if data && data._proxy.is_a?(LHS::Collection)
|
28
28
|
data.first || raise(LHC::NotFound.new('No item was found.', data._request.response))
|
29
|
-
|
29
|
+
elsif data
|
30
30
|
data._record.new(data)
|
31
31
|
end
|
32
32
|
end
|
@@ -495,6 +495,7 @@ class LHS::Record
|
|
495
495
|
endpoint = find_endpoint(options[:params], options.fetch(:url, nil))
|
496
496
|
apply_limit!(options) if options[:all]
|
497
497
|
response = LHC.request(process_options(options, endpoint))
|
498
|
+
return nil if response.error_ignored?
|
498
499
|
data = LHS::Data.new(response.body, nil, self, response.request, endpoint)
|
499
500
|
single_request_load_and_merge_remaining_objects!(data, options, endpoint)
|
500
501
|
expand_items(data, options[:expanded]) if data.collection? && options[:expanded]
|
data/lib/lhs/version.rb
CHANGED
@@ -78,4 +78,34 @@ describe LHS::Record do
|
|
78
78
|
.fetch
|
79
79
|
expect(record).to eq nil
|
80
80
|
end
|
81
|
+
|
82
|
+
context 'response body' do
|
83
|
+
|
84
|
+
let(:body) { { error_message: 'you are not worthy' }.to_json }
|
85
|
+
|
86
|
+
it 'returns nil also when ignoring errors on find' do
|
87
|
+
stub_request(:get, "http://local.ch/v2/records/1").to_return(status: 500, body: body)
|
88
|
+
record = Record
|
89
|
+
.ignore(LHC::Error)
|
90
|
+
.find(1)
|
91
|
+
expect(record).to eq nil
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'returns nil also when ignoring errors on find' do
|
95
|
+
stub_request(:get, "http://local.ch/v2/records?color=blue").to_return(status: 500, body: body)
|
96
|
+
record = Record
|
97
|
+
.ignore(LHC::Error)
|
98
|
+
.where(color: 'blue')
|
99
|
+
.fetch
|
100
|
+
expect(record).to eq nil
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'returns nil also when ignoring errors on find' do
|
104
|
+
stub_request(:get, "http://local.ch/v2/records?color=blue&limit=1").to_return(status: 500, body: body)
|
105
|
+
record = Record
|
106
|
+
.ignore(LHC::Error)
|
107
|
+
.find_by(color: 'blue')
|
108
|
+
expect(record).to eq nil
|
109
|
+
end
|
110
|
+
end
|
81
111
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.0.
|
4
|
+
version: 14.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.
|
19
|
+
version: 6.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.
|
26
|
+
version: 6.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|