spaceborne 0.1.39 → 0.1.43
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/lib/spaceborne/version.rb +1 -1
- data/lib/spaceborne.rb +20 -15
- 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: 19e97691f8756aaeecafb192cd726205e85ba69c98dfc40f1990aaa1b770bf30
|
|
4
|
+
data.tar.gz: 7c3fd96cbd3c684494e7f9a28ab485aac083ddac59ab001d39d5da09ca288bca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb75f8a4d79c6b4cdc76ba22d3daaa556a7d1482a3c0f8c27291bc4686c8f487e3f77539c987ca8a8fccbf573413e09ee0d318281dea561692aa345949d9df1d
|
|
7
|
+
data.tar.gz: 1bdcde6c073c90d29f8fe735fe9776b7122a20279474ceb0bdbdff87e4c153d26daaa50cf731d0314949a07208c9a1842c255986ae6fc3bc88998ac1af519264
|
data/lib/spaceborne/version.rb
CHANGED
data/lib/spaceborne.rb
CHANGED
|
@@ -186,7 +186,9 @@ module Airborne
|
|
|
186
186
|
|
|
187
187
|
def exception_path_adder(args, body)
|
|
188
188
|
yield
|
|
189
|
-
rescue RSpec::Expectations::ExpectationNotMetError,
|
|
189
|
+
rescue RSpec::Expectations::ExpectationNotMetError,
|
|
190
|
+
ExpectationError,
|
|
191
|
+
Airborne::ExpectationError => e
|
|
190
192
|
e.message << "\nexpect arguments: #{args}\ndata element: #{body}"
|
|
191
193
|
raise e
|
|
192
194
|
end
|
|
@@ -227,28 +229,28 @@ module Airborne
|
|
|
227
229
|
if data.is_a?(Hash)
|
|
228
230
|
OptionalHashTypeExpectations.new(data)
|
|
229
231
|
else
|
|
230
|
-
OptionalPathExpectations.new(data)
|
|
232
|
+
Airborne::OptionalPathExpectations.new(data)
|
|
231
233
|
end
|
|
232
234
|
end
|
|
233
235
|
end
|
|
234
236
|
|
|
235
237
|
# extension to handle hash value checking
|
|
236
238
|
module PathMatcher
|
|
237
|
-
def handle_container(json, &block)
|
|
239
|
+
def handle_container(path, json, &block)
|
|
238
240
|
case json.class.name
|
|
239
241
|
when 'Array'
|
|
240
242
|
expect_all(json, &block)
|
|
241
243
|
when 'Hash'
|
|
242
244
|
json.each { |k, _v| yield json[k] }
|
|
243
245
|
else
|
|
244
|
-
raise ExpectationError, "expected array or hash, got #{json.class.name}"
|
|
246
|
+
raise ExpectationError, "expected array or hash at #{path}, got #{json.class.name}"
|
|
245
247
|
end
|
|
246
248
|
end
|
|
247
249
|
|
|
248
250
|
def handle_type(type, path, json, &block)
|
|
249
|
-
case type
|
|
251
|
+
case type.to_s
|
|
250
252
|
when '*'
|
|
251
|
-
handle_container(json, &block)
|
|
253
|
+
handle_container(path, json, &block)
|
|
252
254
|
when '?'
|
|
253
255
|
expect_one(path, json, &block)
|
|
254
256
|
else
|
|
@@ -275,19 +277,16 @@ module Airborne
|
|
|
275
277
|
end
|
|
276
278
|
|
|
277
279
|
def shortcut_validation(path, json)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
ensure_array_or_hash(path, json)
|
|
281
|
-
false
|
|
280
|
+
json.nil? && path.is_a?(Airborne::OptionalPathExpectations)
|
|
282
281
|
end
|
|
283
282
|
|
|
284
283
|
def get_by_path(path, json, type: false, &block)
|
|
285
284
|
iterate_path(path) do |parts, part, index|
|
|
286
|
-
if
|
|
287
|
-
return if shortcut_validation(path, json)
|
|
285
|
+
return if shortcut_validation(path, json)
|
|
288
286
|
|
|
287
|
+
if %w[* ?].include?(part.to_s)
|
|
289
288
|
type = part
|
|
290
|
-
walk_with_path(type, index, path, parts, json, &block) && return if index < parts.length.pred
|
|
289
|
+
walk_with_path(type.to_s, index, path, parts, json, &block) && return if index < parts.length.pred
|
|
291
290
|
|
|
292
291
|
next
|
|
293
292
|
end
|
|
@@ -304,14 +303,20 @@ module Airborne
|
|
|
304
303
|
' from JSON response'
|
|
305
304
|
end
|
|
306
305
|
|
|
306
|
+
def handle_missing_errors(type, path, sub_path, element, &block)
|
|
307
|
+
exception_path_adder({ type: type, path: sub_path }, element) do
|
|
308
|
+
get_by_path(make_sub_path_optional(path, sub_path), element, &block)
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
307
312
|
def walk_with_path(type, index, path, parts, json, &block)
|
|
308
313
|
last_error = nil
|
|
309
314
|
item_count = json.length
|
|
310
315
|
error_count = 0
|
|
311
316
|
json.each do |element|
|
|
317
|
+
sub_path = parts[(index.next)...(parts.length)].join('.')
|
|
312
318
|
begin
|
|
313
|
-
sub_path
|
|
314
|
-
get_by_path(make_sub_path_optional(path, sub_path), element, &block)
|
|
319
|
+
handle_missing_errors(type, path, sub_path, element, &block)
|
|
315
320
|
rescue Exception => e
|
|
316
321
|
last_error = e
|
|
317
322
|
error_count += 1
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spaceborne
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.43
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keith Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-09-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|