blumquist 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/blumquist.rb +17 -6
- data/lib/blumquist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 150c41e7fb3e641e3ce7593c7c9284fd67e8b460
|
4
|
+
data.tar.gz: 36068814a20c207c6076832c3e7d30402dcd77b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a20db0cf40272b03861a20231d4eec2630493d9bc0c4a1d47248c4b4072826bba2d6e117d98b242b9fa0ed9b6c79d6b0500d442b69e09bdb28250905573d0b
|
7
|
+
data.tar.gz: edffb883241b8688c65eb1025fd318119d364eb4f6885c0f342fd5efee4b445fe929a4a2045ae321e440caef734130a72a7534005910a95f4e1e59bd640c970d
|
data/CHANGELOG.md
CHANGED
data/lib/blumquist.rb
CHANGED
@@ -54,13 +54,11 @@ class Blumquist
|
|
54
54
|
|
55
55
|
def define_getters
|
56
56
|
@schema[:properties].each do |property, type_def|
|
57
|
-
types = [type_def[:type]].flatten - ["null"]
|
58
|
-
type = types.first
|
59
|
-
|
60
57
|
# The type_def can contain one or more types.
|
61
|
-
# We only support
|
58
|
+
# We only support multiple primitive types, or one
|
62
59
|
# normal type and the null type.
|
63
|
-
|
60
|
+
types = [type_def[:type]].flatten - ["null"]
|
61
|
+
type = types.first
|
64
62
|
|
65
63
|
# Wrap objects recursively
|
66
64
|
if type == 'object' || type_def[:oneOf]
|
@@ -73,6 +71,8 @@ class Blumquist
|
|
73
71
|
# Nothing to do for primitive values
|
74
72
|
elsif primitive_type?(type)
|
75
73
|
|
74
|
+
elsif all_primitive_types(types)
|
75
|
+
|
76
76
|
# We don't know what to do, so let's panic
|
77
77
|
else
|
78
78
|
raise(Errors::UnsupportedType, type)
|
@@ -214,6 +214,8 @@ class Blumquist
|
|
214
214
|
@data[property] = @data[property].map do |item|
|
215
215
|
Blumquist.new(schema: sub_schema, data: item, validate: false)
|
216
216
|
end
|
217
|
+
|
218
|
+
# The items are objects, defined directly or through oneOf
|
217
219
|
elsif type_def[:type] == 'object' || type_def[:oneOf]
|
218
220
|
sub_schema = type_def.merge(
|
219
221
|
definitions: @schema[:definitions]
|
@@ -224,11 +226,20 @@ class Blumquist
|
|
224
226
|
blumquistify_object(schema: sub_schema, data: item)
|
225
227
|
end
|
226
228
|
|
229
|
+
# The items are all of the same primitive type
|
227
230
|
elsif primitive_type?(type_def[:type])
|
228
231
|
|
232
|
+
# The items might all be primitives, that would be OK
|
233
|
+
elsif all_primitive_types(type_def[:type])
|
234
|
+
|
229
235
|
# We don't know what to do, so let's panic
|
230
236
|
else
|
231
237
|
raise(Errors::UnsupportedType, type_def[:type])
|
232
238
|
end
|
233
239
|
end
|
234
|
-
|
240
|
+
|
241
|
+
def all_primitive_types(types)
|
242
|
+
return false unless types.is_a?(Array)
|
243
|
+
types.all? { |t| primitive_type?(t) }
|
244
|
+
end
|
245
|
+
end
|
data/lib/blumquist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blumquist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jannis Hermanns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|