json_schema 0.17.1 → 0.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cf8900a129a96f214a53b4af5a0e0699133f0e1
4
- data.tar.gz: c914c0583a0f0d883d8409132cd2a28b2478f97f
3
+ metadata.gz: 635babaf9176db9c16a7564e0cdb8804ba209201
4
+ data.tar.gz: c866943726dbe55237d5c7931793d5ecf149945a
5
5
  SHA512:
6
- metadata.gz: 60aa779de4b3f0f7a6b706f8196d62789cde70b445bb52b860706cd22eb4da981a2836f13b4c505b6bb53509707a574dc8c02b5c490bf2c78be836aef42d2fa7
7
- data.tar.gz: 788739556222ff63a2f3a3b1cf94bac833dbdcfa6224cd8f243bf86a15b7bba81c69930d0e01567abbf1a4a42e7a06eb5eb1745c67349f1c64a6e77dfad72860
6
+ metadata.gz: 5caf545cbf4684cad41d64fc889d5c167f2e4f3980b91014a7367fef4f070a4fd5b77b138f80f12f34b3d62fbae11bd0890a67d1a490228db59a4cccf9b1a263
7
+ data.tar.gz: ff16d212597fbeab145f40023052e1e792014cd78c7ebafc65bd75af7c505879622a65cbbe037037ff287ceb3274288da603f6afcf21c79eb5628a4dd398ee8f
@@ -25,23 +25,21 @@ module JsonSchema
25
25
  def attr_copyable(attr, options = {})
26
26
  attr_accessor(attr)
27
27
 
28
+ ref = :"@#{attr}"
28
29
  # Usually the default being assigned here is nil.
29
- self.copyable_attrs["@#{attr}".to_sym] = options[:default]
30
+ self.copyable_attrs[ref] = options[:default]
30
31
 
31
32
  if default = options[:default]
32
33
  # remove the reader already created by attr_accessor
33
34
  remove_method(attr)
34
35
 
36
+ need_dup = [Array, Hash, Set].include?(default.class)
35
37
  define_method(attr) do
36
- val = instance_variable_get(:"@#{attr}")
38
+ val = instance_variable_get(ref)
37
39
  if !val.nil?
38
40
  val
39
41
  else
40
- if [Array, Hash, Set].include?(default.class)
41
- default.dup
42
- else
43
- default
44
- end
42
+ need_dup ? default.class.new : default
45
43
  end
46
44
  end
47
45
  end
@@ -172,22 +172,17 @@ module JsonSchema
172
172
  def validate_any_of(schema, data, errors, path)
173
173
  return true if schema.any_of.empty?
174
174
 
175
- sub_errors = []
176
-
177
- subschemata_validity = schema.any_of.map do |subschema|
175
+ sub_errors = schema.any_of.map do |subschema|
178
176
  current_sub_errors = []
179
- sub_errors << current_sub_errors
180
- validate_data(subschema, data, current_sub_errors, path)
177
+ return true if validate_data(subschema, data, current_sub_errors, path)
178
+ current_sub_errors
181
179
  end
182
180
 
183
- unless subschemata_validity.any? { |valid| valid == true }
184
- message = %{No subschema in "anyOf" matched.}
185
- errors << ValidationError.new(schema, path, message, :any_of_failed,
186
- sub_errors: sub_errors, data: data)
187
- return false
188
- end
181
+ message = %{No subschema in "anyOf" matched.}
182
+ errors << ValidationError.new(schema, path, message, :any_of_failed,
183
+ sub_errors: sub_errors, data: data)
189
184
 
190
- true
185
+ false
191
186
  end
192
187
 
193
188
  def validate_dependencies(schema, data, errors, path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-12 00:00:00.000000000 Z
11
+ date: 2018-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecma-re-validator