spaceborne 0.1.38 → 0.1.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/README.md +4 -3
- data/lib/spaceborne/version.rb +1 -1
- data/lib/spaceborne.rb +11 -1
- 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: 47de2c6cb6679f19995cba98157fcf914e181ca5cfc1a7c2be9f011fd593851f
|
4
|
+
data.tar.gz: 1d598c51e65a741cfa8431c6d603aecca8efe4e6077f4a08f39461a8f1bd980b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d08b29b7f93b28aa1f0c1a54b9576483ac0e35d30c42c5c8f9ac62fe157ebea7832175e46df61997398b2f7c3f5f2cbc097b79dcee40b39a84d92e09c3e8167
|
7
|
+
data.tar.gz: ef1903aa05502a28b612046382a2b06612a6231a2582b6e9555c3f138d54b10fbee6cc2fbc5c0c1f16413f733f34d015c53f837ec1531d677de067d9b80c6e27
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
AllCops:
|
2
|
+
SuggestExtensions: false
|
3
|
+
|
1
4
|
Style/FrozenStringLiteralComment:
|
2
5
|
Enabled: false
|
3
6
|
|
@@ -23,7 +26,7 @@ Metrics/ClassLength:
|
|
23
26
|
Exclude:
|
24
27
|
- 'bin/*'
|
25
28
|
|
26
|
-
|
29
|
+
Layout/LineLength:
|
27
30
|
Exclude:
|
28
31
|
- 'spec/airborne/**/*.rb'
|
29
32
|
|
data/README.md
CHANGED
@@ -226,15 +226,16 @@ The following example shows how extensions # 6 & 8 work
|
|
226
226
|
{ "array": [] },
|
227
227
|
{ "foo": "bar" }],
|
228
228
|
"highest_array": [ null,
|
229
|
-
{ "array": [{ "present": "name" }]}]
|
229
|
+
{ "array": [{ "present": "name" }]}],
|
230
|
+
"not_an_array": null
|
230
231
|
}
|
231
232
|
```
|
232
233
|
You can now validate the fact that each element in the collection has a key which is variant, but a value that has a defined format (the first and last field values are strings).
|
233
234
|
|
234
235
|
expect_json_types('array_of_hashes.*.*', first: :string, last: :string)
|
235
236
|
expect_json_types('hash_of_hashes.*', first: :string, last: :string)
|
236
|
-
|
237
|
-
|
237
|
+
expect_json_types(optional('lowest_array.*.array.*'), present: :string)
|
238
|
+
expect_json_types(optional('highest_array.*.array.*'), present: :string)
|
238
239
|
|
239
240
|
|
240
241
|
## Development
|
data/lib/spaceborne/version.rb
CHANGED
data/lib/spaceborne.rb
CHANGED
@@ -156,10 +156,12 @@ module Airborne
|
|
156
156
|
|
157
157
|
# Extend airborne's expectations
|
158
158
|
module RequestExpectations
|
159
|
+
# class used for holding an optional path
|
159
160
|
class OptionalPathExpectations
|
160
161
|
def initialize(string)
|
161
162
|
@string = string
|
162
163
|
end
|
164
|
+
|
163
165
|
def to_s
|
164
166
|
@string.to_s
|
165
167
|
end
|
@@ -272,10 +274,18 @@ module Airborne
|
|
272
274
|
end
|
273
275
|
end
|
274
276
|
|
277
|
+
def shortcut_validation(path, json)
|
278
|
+
return true if json.nil? && path.is_a?(Airborne::OptionalPathExpectations)
|
279
|
+
|
280
|
+
ensure_array_or_hash(path, json)
|
281
|
+
false
|
282
|
+
end
|
283
|
+
|
275
284
|
def get_by_path(path, json, type: false, &block)
|
276
285
|
iterate_path(path) do |parts, part, index|
|
277
286
|
if %w[* ?].include?(part.to_s)
|
278
|
-
|
287
|
+
return if shortcut_validation(path, json)
|
288
|
+
|
279
289
|
type = part
|
280
290
|
walk_with_path(type, index, path, parts, json, &block) && return if index < parts.length.pred
|
281
291
|
|
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.39
|
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-08-
|
11
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|