blumquist 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 249b88b4bc80ec7543759b3b0700d7cfe9f04b3a
4
- data.tar.gz: 3cbb84ab029425323f711d3d210e2db223a9574a
3
+ metadata.gz: 389e1b2f8a0295f3c975f7b3877da1877c32d150
4
+ data.tar.gz: d144ddd0daf59b3ce2719bfe60b7787d0b263417
5
5
  SHA512:
6
- metadata.gz: 770dda447195fd81228acecef7d578f12cdc3a6eecad0768bca384db7696739180b8e9adf4bacbc6cc414892a099abe2a6050016ca2fb0a9e3ded07156cf613c
7
- data.tar.gz: 092f9723612e3625538b50919773b46491ec8fcb80ff48bc0dad65d3a859153b3b35e4b1614dd200e5ddf1fa1d2047001faad4aef6853ecb25fa2eac14f01975
6
+ metadata.gz: 7b0d8b821d05fe847fc2670a86498849fb50f3b0ccfffb9c220c97876ca6d846eac7aadc93ac0692b7e1055d428552f8c4679bea7a57551b070ebb76371b6544
7
+ data.tar.gz: 335da3462e4abb87f212a5c63c83ab6fc6ae3196faeaec8293612a78f824bd98171b663e7e63562fd02fa804baf8502f49883b6d28f7b2785a814eb4150f3822
@@ -1,3 +1,6 @@
1
+ # 0.3.2
2
+ - fix #2 (arrays of primitives)
3
+
1
4
  # 0.3.1
2
5
  - support array type definitions that are expressed as an object
3
6
  or as an array of objects
@@ -102,15 +102,31 @@ class Blumquist
102
102
  # "type": "array",
103
103
  # "items": [{ "$ref": "#/definitions/mytype" }]
104
104
  #
105
- pointer = [@schema[:properties][property][:items]].flatten.first
106
- item_schema = resolve_json_pointer!(pointer)
107
- raise(Errors::MissingArrayItemsType, @schema[:properties][property]) unless item_schema
108
- sub_schema = item_schema.merge(
109
- definitions: @schema[:definitions]
110
- )
111
- @data[property] ||= []
112
- @data[property] = @data[property].map do |item|
113
- Blumquist.new(schema: sub_schema, data: item, validate: @validate)
105
+ # or through
106
+ #
107
+ # "type": "array",
108
+ # "items": [{ "type": "number" }]
109
+ #
110
+ type_def = [@schema[:properties][property][:items]].flatten.first
111
+
112
+ # The items of this array are defined by a pointer
113
+ if type_def[:$ref]
114
+ item_schema = resolve_json_pointer!(type_def)
115
+ raise(Errors::MissingArrayItemsType, @schema[:properties][property]) unless item_schema
116
+
117
+ sub_schema = item_schema.merge(
118
+ definitions: @schema[:definitions]
119
+ )
120
+
121
+ @data[property] ||= []
122
+ @data[property] = @data[property].map do |item|
123
+ Blumquist.new(schema: sub_schema, data: item, validate: @validate)
124
+ end
125
+ elsif primitive_type?(type_def[:type])
126
+
127
+ # We don't know what to do, so let's panic
128
+ else
129
+ raise(Errors::UnsupportedType, type_def[:type])
114
130
  end
115
131
  end
116
132
  end
@@ -1,3 +1,3 @@
1
1
  class Blumquist
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jannis Hermanns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport