schemacop 2.0.0 → 2.2.0
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/.rubocop.yml +1 -17
- data/.travis.yml +0 -2
- data/CHANGELOG.md +19 -0
- data/README.md +39 -6
- data/Rakefile +5 -1
- data/VERSION +1 -1
- data/doc/Schemacop.html +3 -3
- data/doc/Schemacop/ArrayValidator.html +1 -1
- data/doc/Schemacop/BooleanValidator.html +1 -1
- data/doc/Schemacop/Collector.html +1 -1
- data/doc/Schemacop/Exceptions.html +1 -1
- data/doc/Schemacop/Exceptions/InvalidSchemaError.html +1 -1
- data/doc/Schemacop/Exceptions/ValidationError.html +1 -1
- data/doc/Schemacop/FieldNode.html +1 -1
- data/doc/Schemacop/FloatValidator.html +1 -1
- data/doc/Schemacop/HashValidator.html +30 -4
- data/doc/Schemacop/IntegerValidator.html +1 -1
- data/doc/Schemacop/NilValidator.html +1 -1
- data/doc/Schemacop/Node.html +2 -2
- data/doc/Schemacop/NodeResolver.html +1 -1
- data/doc/Schemacop/NodeSupportingField.html +1 -1
- data/doc/Schemacop/NodeSupportingType.html +1 -1
- data/doc/Schemacop/NodeWithBlock.html +1 -1
- data/doc/Schemacop/NumberValidator.html +1 -1
- data/doc/Schemacop/ObjectValidator.html +1 -1
- data/doc/Schemacop/RootNode.html +1 -1
- data/doc/Schemacop/Schema.html +1 -1
- data/doc/Schemacop/StringValidator.html +1 -1
- data/doc/Schemacop/SymbolValidator.html +145 -0
- data/doc/ScopedEnv.html +1 -1
- data/doc/_index.html +8 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +37 -7
- data/doc/index.html +37 -7
- data/doc/top-level-namespace.html +1 -1
- data/lib/schemacop.rb +2 -0
- data/lib/schemacop/node_supporting_field.rb +2 -4
- data/lib/schemacop/validator/hash_validator.rb +15 -2
- data/lib/schemacop/validator/symbol_validator.rb +5 -0
- data/schemacop.gemspec +8 -8
- data/test/types_test.rb +1 -0
- data/test/validator_symbol_test.rb +16 -0
- metadata +26 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 553c564f36cf2b16bd1bc72f48f75abcaef6d66e
|
4
|
+
data.tar.gz: 9546f609f7e8e58db4012efd82ca4dee1ae21788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c033fe31d11708a6f499869d9736b4b42081c02860270e48776ac86e9181f0522668dd3fa18ab80f31f2621453a3ac32493fab6e2da1502d61d028a58a621f25
|
7
|
+
data.tar.gz: 219c873fbeac36c803011553d34a88d073da8c30b61119cf0647f8fc3347cc736f8ad4306411a23173a79043592c4a697b3f984134cc91a0ac5f7c02b37817f1
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.3
|
3
|
-
|
4
2
|
Exclude:
|
5
3
|
- 'local/**/*'
|
6
4
|
- 'vendor/**/*'
|
@@ -10,21 +8,13 @@ AllCops:
|
|
10
8
|
- 'db/schema.rb'
|
11
9
|
- 'locale/translations.rb'
|
12
10
|
- 'lib/scratch.rb'
|
11
|
+
- 'schemacop.gemspec'
|
13
12
|
|
14
13
|
DisplayCopNames: true
|
15
14
|
|
16
|
-
Style/FrozenStringLiteralComment:
|
17
|
-
Enabled: false
|
18
|
-
|
19
15
|
Style/SignalException:
|
20
16
|
EnforcedStyle: only_fail
|
21
17
|
|
22
|
-
Style/ConditionalAssignment:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/IndentArray:
|
26
|
-
EnforcedStyle: consistent
|
27
|
-
|
28
18
|
Metrics/MethodLength:
|
29
19
|
Enabled: false
|
30
20
|
|
@@ -53,9 +43,6 @@ Metrics/LineLength:
|
|
53
43
|
Metrics/BlockNesting:
|
54
44
|
Enabled: false
|
55
45
|
|
56
|
-
Metrics/BlockLength:
|
57
|
-
Enabled: false
|
58
|
-
|
59
46
|
Style/IfUnlessModifier:
|
60
47
|
Enabled: false
|
61
48
|
|
@@ -93,8 +80,5 @@ Style/ClassAndModuleChildren:
|
|
93
80
|
#
|
94
81
|
# The compact style is only forced, for classes / modules with one child.
|
95
82
|
|
96
|
-
Style/NumericPredicate:
|
97
|
-
Enabled: false
|
98
|
-
|
99
83
|
Style/FormatString:
|
100
84
|
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,25 @@
|
|
10
10
|
### Changes
|
11
11
|
-->
|
12
12
|
|
13
|
+
## 2.2.0 (2017-05-17)
|
14
|
+
|
15
|
+
### Changes
|
16
|
+
|
17
|
+
* Handle `ActiveSupport::HashWithIndifferentAccess` objects gracefully when
|
18
|
+
performing the validation. This allows the user to specify the schema using
|
19
|
+
a mixture of symbols and strings, but during the validation of a
|
20
|
+
`HashWithIndifferentAccess` it transparently converts the keys, both in the
|
21
|
+
schema and in the hash, to symbols.
|
22
|
+
|
23
|
+
In the event that a key is defined both in the string and symbol version,
|
24
|
+
Schemacop expects a Ruby hash and will throw a ValidationError otherwise.
|
25
|
+
|
26
|
+
## 2.1.0 (2017-05-16)
|
27
|
+
|
28
|
+
### New features
|
29
|
+
|
30
|
+
* Validator for type Symbol, accessible with the symbol `:symbol`
|
31
|
+
|
13
32
|
## 2.0.0 (2017-05-15)
|
14
33
|
|
15
34
|
### Changes
|
data/README.md
CHANGED
@@ -226,8 +226,8 @@ option `min` is supported by the `:string` validator (covered later).
|
|
226
226
|
|
227
227
|
### Field Line
|
228
228
|
|
229
|
-
Inside a Type Line of type `:hash
|
230
|
-
|
229
|
+
Inside a Type Line of type `:hash`, you may specify an arbitrary number of field
|
230
|
+
lines (one for each key-value pair you want to be in the hash).
|
231
231
|
|
232
232
|
Field Lines start with one of the following six identifiers: `req`, `req?`,
|
233
233
|
`req!`, `opt`, `opt?` or `opt!`:
|
@@ -273,11 +273,42 @@ end
|
|
273
273
|
You might find the notation cumbersome, and you'd be right to say so. Luckily
|
274
274
|
there are plenty of short forms available which we will see below.
|
275
275
|
|
276
|
+
#### Handling hashes with indifferent access
|
277
|
+
|
278
|
+
Schemacop has special handling for objects of the class
|
279
|
+
`ActiveSupport::HashWithIndifferentAccess`: You may specify the keys as symbols
|
280
|
+
or strings, and Schemacop will handle the conversion necessary for proper
|
281
|
+
validation internally. Note that if you define the same key as string and
|
282
|
+
symbol, it will throw a `ValidationError` [exception](#exceptions) when asked to
|
283
|
+
validate a hash with indifferent access.
|
284
|
+
|
285
|
+
Thus, the following two schema definitions are equivalent when validating a hash
|
286
|
+
with indifferent access:
|
287
|
+
|
288
|
+
```ruby
|
289
|
+
Schema.new do
|
290
|
+
type :hash do
|
291
|
+
req :name do
|
292
|
+
type :string
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
Schema.new do
|
298
|
+
type :hash do
|
299
|
+
req 'name' do
|
300
|
+
type :string
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
```
|
305
|
+
|
276
306
|
## Types
|
277
307
|
|
278
|
-
|
279
|
-
|
280
|
-
|
308
|
+
Types are defined via their validators, which is a class under `validator/`.
|
309
|
+
Each validator is sourced by `schemacop.rb`.
|
310
|
+
|
311
|
+
The following types are supported by Schemacop by default:
|
281
312
|
|
282
313
|
* `:boolean` accepts a Ruby TrueClass or FalseClass instance.
|
283
314
|
|
@@ -297,6 +328,8 @@ another `your_validator.rb` class under `validator/`): -->
|
|
297
328
|
|
298
329
|
- supported options: `min`, `max` (bounds for string length)
|
299
330
|
|
331
|
+
* `:symbol` accepts a Ruby Symbol.
|
332
|
+
|
300
333
|
* `:object` accepts an arbitrary Ruby object (any object if no option is given).
|
301
334
|
|
302
335
|
- supported option: `classes`: Ruby class (or an array of them) that will be
|
@@ -314,7 +347,7 @@ another `your_validator.rb` class under `validator/`): -->
|
|
314
347
|
- TODO no lookahead for different arrays, see
|
315
348
|
validator_array_test#test_multiple_arrays
|
316
349
|
|
317
|
-
* `:hash` accepts a Ruby Hash
|
350
|
+
* `:hash` accepts a Ruby Hash or an `ActiveSupport::HashWithIndifferentAccess`.
|
318
351
|
|
319
352
|
- accepts a block with an arbitrary number of Field Lines.
|
320
353
|
|
data/Rakefile
CHANGED
@@ -18,11 +18,15 @@ task :gemspec do
|
|
18
18
|
spec.add_development_dependency 'rake'
|
19
19
|
spec.add_development_dependency 'ci_reporter', '~> 2.0'
|
20
20
|
spec.add_development_dependency 'ci_reporter_minitest'
|
21
|
-
spec.add_development_dependency 'activesupport'
|
22
21
|
spec.add_development_dependency 'haml'
|
23
22
|
spec.add_development_dependency 'yard'
|
24
23
|
spec.add_development_dependency 'rubocop', '0.35.1'
|
25
24
|
spec.add_development_dependency 'redcarpet'
|
25
|
+
|
26
|
+
# This lower bound for ActiveSupport is not necessarily true. Schemacop
|
27
|
+
# needs access to ActiveSupport::HashWithIndifferentAccess and expects
|
28
|
+
# behavior of that as in version 5 of ActiveSupport.
|
29
|
+
spec.add_dependency 'activesupport', '>= 4.0', '< 6'
|
26
30
|
end
|
27
31
|
|
28
32
|
File.open('schemacop.gemspec', 'w') { |f| f.write(gemspec.to_ruby.strip) }
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/doc/Schemacop.html
CHANGED
@@ -79,7 +79,7 @@
|
|
79
79
|
<dl>
|
80
80
|
<dt>Defined in:</dt>
|
81
81
|
<dd>lib/schemacop.rb<span class="defines">,<br />
|
82
|
-
lib/schemacop/node.rb,<br /> lib/schemacop/schema.rb,<br /> lib/schemacop/collector.rb,<br /> lib/schemacop/root_node.rb,<br /> lib/schemacop/field_node.rb,<br /> lib/schemacop/node_resolver.rb,<br /> lib/schemacop/node_with_block.rb,<br /> lib/schemacop/node_supporting_type.rb,<br /> lib/schemacop/node_supporting_field.rb,<br /> lib/schemacop/validator/nil_validator.rb,<br /> lib/schemacop/validator/hash_validator.rb,<br /> lib/schemacop/validator/array_validator.rb,<br /> lib/schemacop/validator/float_validator.rb,<br /> lib/schemacop/validator/number_validator.rb,<br /> lib/schemacop/validator/object_validator.rb,<br /> lib/schemacop/validator/string_validator.rb,<br /> lib/schemacop/validator/boolean_validator.rb,<br /> lib/schemacop/validator/integer_validator.rb</span>
|
82
|
+
lib/schemacop/node.rb,<br /> lib/schemacop/schema.rb,<br /> lib/schemacop/collector.rb,<br /> lib/schemacop/root_node.rb,<br /> lib/schemacop/field_node.rb,<br /> lib/schemacop/node_resolver.rb,<br /> lib/schemacop/node_with_block.rb,<br /> lib/schemacop/node_supporting_type.rb,<br /> lib/schemacop/node_supporting_field.rb,<br /> lib/schemacop/validator/nil_validator.rb,<br /> lib/schemacop/validator/hash_validator.rb,<br /> lib/schemacop/validator/array_validator.rb,<br /> lib/schemacop/validator/float_validator.rb,<br /> lib/schemacop/validator/number_validator.rb,<br /> lib/schemacop/validator/object_validator.rb,<br /> lib/schemacop/validator/string_validator.rb,<br /> lib/schemacop/validator/symbol_validator.rb,<br /> lib/schemacop/validator/boolean_validator.rb,<br /> lib/schemacop/validator/integer_validator.rb</span>
|
83
83
|
</dd>
|
84
84
|
</dl>
|
85
85
|
|
@@ -93,7 +93,7 @@
|
|
93
93
|
|
94
94
|
|
95
95
|
|
96
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Schemacop/ArrayValidator.html" title="Schemacop::ArrayValidator (class)">ArrayValidator</a></span>, <span class='object_link'><a href="Schemacop/BooleanValidator.html" title="Schemacop::BooleanValidator (class)">BooleanValidator</a></span>, <span class='object_link'><a href="Schemacop/Collector.html" title="Schemacop::Collector (class)">Collector</a></span>, <span class='object_link'><a href="Schemacop/FieldNode.html" title="Schemacop::FieldNode (class)">FieldNode</a></span>, <span class='object_link'><a href="Schemacop/FloatValidator.html" title="Schemacop::FloatValidator (class)">FloatValidator</a></span>, <span class='object_link'><a href="Schemacop/HashValidator.html" title="Schemacop::HashValidator (class)">HashValidator</a></span>, <span class='object_link'><a href="Schemacop/IntegerValidator.html" title="Schemacop::IntegerValidator (class)">IntegerValidator</a></span>, <span class='object_link'><a href="Schemacop/NilValidator.html" title="Schemacop::NilValidator (class)">NilValidator</a></span>, <span class='object_link'><a href="Schemacop/Node.html" title="Schemacop::Node (class)">Node</a></span>, <span class='object_link'><a href="Schemacop/NodeResolver.html" title="Schemacop::NodeResolver (class)">NodeResolver</a></span>, <span class='object_link'><a href="Schemacop/NodeSupportingField.html" title="Schemacop::NodeSupportingField (class)">NodeSupportingField</a></span>, <span class='object_link'><a href="Schemacop/NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span>, <span class='object_link'><a href="Schemacop/NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span>, <span class='object_link'><a href="Schemacop/NumberValidator.html" title="Schemacop::NumberValidator (class)">NumberValidator</a></span>, <span class='object_link'><a href="Schemacop/ObjectValidator.html" title="Schemacop::ObjectValidator (class)">ObjectValidator</a></span>, <span class='object_link'><a href="Schemacop/RootNode.html" title="Schemacop::RootNode (class)">RootNode</a></span>, <span class='object_link'><a href="Schemacop/Schema.html" title="Schemacop::Schema (class)">Schema</a></span>, <span class='object_link'><a href="Schemacop/StringValidator.html" title="Schemacop::StringValidator (class)">StringValidator</a></span>
|
96
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Schemacop/ArrayValidator.html" title="Schemacop::ArrayValidator (class)">ArrayValidator</a></span>, <span class='object_link'><a href="Schemacop/BooleanValidator.html" title="Schemacop::BooleanValidator (class)">BooleanValidator</a></span>, <span class='object_link'><a href="Schemacop/Collector.html" title="Schemacop::Collector (class)">Collector</a></span>, <span class='object_link'><a href="Schemacop/FieldNode.html" title="Schemacop::FieldNode (class)">FieldNode</a></span>, <span class='object_link'><a href="Schemacop/FloatValidator.html" title="Schemacop::FloatValidator (class)">FloatValidator</a></span>, <span class='object_link'><a href="Schemacop/HashValidator.html" title="Schemacop::HashValidator (class)">HashValidator</a></span>, <span class='object_link'><a href="Schemacop/IntegerValidator.html" title="Schemacop::IntegerValidator (class)">IntegerValidator</a></span>, <span class='object_link'><a href="Schemacop/NilValidator.html" title="Schemacop::NilValidator (class)">NilValidator</a></span>, <span class='object_link'><a href="Schemacop/Node.html" title="Schemacop::Node (class)">Node</a></span>, <span class='object_link'><a href="Schemacop/NodeResolver.html" title="Schemacop::NodeResolver (class)">NodeResolver</a></span>, <span class='object_link'><a href="Schemacop/NodeSupportingField.html" title="Schemacop::NodeSupportingField (class)">NodeSupportingField</a></span>, <span class='object_link'><a href="Schemacop/NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span>, <span class='object_link'><a href="Schemacop/NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span>, <span class='object_link'><a href="Schemacop/NumberValidator.html" title="Schemacop::NumberValidator (class)">NumberValidator</a></span>, <span class='object_link'><a href="Schemacop/ObjectValidator.html" title="Schemacop::ObjectValidator (class)">ObjectValidator</a></span>, <span class='object_link'><a href="Schemacop/RootNode.html" title="Schemacop::RootNode (class)">RootNode</a></span>, <span class='object_link'><a href="Schemacop/Schema.html" title="Schemacop::Schema (class)">Schema</a></span>, <span class='object_link'><a href="Schemacop/StringValidator.html" title="Schemacop::StringValidator (class)">StringValidator</a></span>, <span class='object_link'><a href="Schemacop/SymbolValidator.html" title="Schemacop::SymbolValidator (class)">SymbolValidator</a></span>
|
97
97
|
|
98
98
|
|
99
99
|
</p>
|
@@ -109,7 +109,7 @@
|
|
109
109
|
</div>
|
110
110
|
|
111
111
|
<div id="footer">
|
112
|
-
Generated on
|
112
|
+
Generated on Wed May 17 10:53:58 2017 by
|
113
113
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
114
114
|
0.9.9 (ruby-2.3.1).
|
115
115
|
</div>
|
@@ -319,7 +319,7 @@
|
|
319
319
|
</div>
|
320
320
|
|
321
321
|
<div id="footer">
|
322
|
-
Generated on
|
322
|
+
Generated on Wed May 17 10:53:58 2017 by
|
323
323
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
324
324
|
0.9.9 (ruby-2.3.1).
|
325
325
|
</div>
|
@@ -135,7 +135,7 @@
|
|
135
135
|
</div>
|
136
136
|
|
137
137
|
<div id="footer">
|
138
|
-
Generated on
|
138
|
+
Generated on Wed May 17 10:53:58 2017 by
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
140
140
|
0.9.9 (ruby-2.3.1).
|
141
141
|
</div>
|
@@ -525,7 +525,7 @@
|
|
525
525
|
</div>
|
526
526
|
|
527
527
|
<div id="footer">
|
528
|
-
Generated on
|
528
|
+
Generated on Wed May 17 10:53:58 2017 by
|
529
529
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
530
530
|
0.9.9 (ruby-2.3.1).
|
531
531
|
</div>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on
|
108
|
+
Generated on Wed May 17 10:53:58 2017 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.9.9 (ruby-2.3.1).
|
111
111
|
</div>
|
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Wed May 17 10:53:58 2017 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.9 (ruby-2.3.1).
|
120
120
|
</div>
|
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Wed May 17 10:53:58 2017 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.9 (ruby-2.3.1).
|
120
120
|
</div>
|
@@ -399,7 +399,7 @@
|
|
399
399
|
</div>
|
400
400
|
|
401
401
|
<div id="footer">
|
402
|
-
Generated on
|
402
|
+
Generated on Wed May 17 10:53:58 2017 by
|
403
403
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
404
404
|
0.9.9 (ruby-2.3.1).
|
405
405
|
</div>
|
@@ -148,7 +148,7 @@
|
|
148
148
|
</div>
|
149
149
|
|
150
150
|
<div id="footer">
|
151
|
-
Generated on
|
151
|
+
Generated on Wed May 17 10:53:58 2017 by
|
152
152
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
153
153
|
0.9.9 (ruby-2.3.1).
|
154
154
|
</div>
|
@@ -226,7 +226,20 @@
|
|
226
226
|
13
|
227
227
|
14
|
228
228
|
15
|
229
|
-
16
|
229
|
+
16
|
230
|
+
17
|
231
|
+
18
|
232
|
+
19
|
233
|
+
20
|
234
|
+
21
|
235
|
+
22
|
236
|
+
23
|
237
|
+
24
|
238
|
+
25
|
239
|
+
26
|
240
|
+
27
|
241
|
+
28
|
242
|
+
29</pre>
|
230
243
|
</td>
|
231
244
|
<td>
|
232
245
|
<pre class="code"><span class="info file"># File 'lib/schemacop/validator/hash_validator.rb', line 5</span>
|
@@ -234,8 +247,21 @@
|
|
234
247
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='rparen'>)</span>
|
235
248
|
<span class='kw'>super</span>
|
236
249
|
|
237
|
-
<span class='id identifier
|
238
|
-
|
250
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>HashWithIndifferentAccess</span>
|
251
|
+
<span class='id identifier rubyid_allowed_fields'>allowed_fields</span> <span class='op'>=</span> <span class='ivar'>@fields</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>:</span> <span class='id identifier rubyid_k'>k</span> <span class='rbrace'>}</span>
|
252
|
+
<span class='id identifier rubyid_data_keys'>data_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>:</span> <span class='id identifier rubyid_k'>k</span> <span class='rbrace'>}</span>
|
253
|
+
|
254
|
+
<span class='comment'># If the same key is specified in the schema as string and symbol, we
|
255
|
+
</span> <span class='comment'># definitely expect a Ruby hash and not one with indifferent access
|
256
|
+
</span> <span class='kw'>if</span> <span class='ivar'>@fields</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>!=</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_allowed_fields'>allowed_fields</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
257
|
+
<span class='id identifier rubyid_fail'>fail</span> <span class='const'><span class='object_link'><a href="Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Exceptions/ValidationError.html" title="Schemacop::Exceptions::ValidationError (class)">ValidationError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Hash expected, but got ActiveSupport::HashWithIndifferentAccess.</span><span class='tstring_end'>'</span></span>
|
258
|
+
<span class='kw'>end</span>
|
259
|
+
<span class='kw'>else</span>
|
260
|
+
<span class='id identifier rubyid_allowed_fields'>allowed_fields</span> <span class='op'>=</span> <span class='ivar'>@fields</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
|
261
|
+
<span class='id identifier rubyid_data_keys'>data_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
|
262
|
+
<span class='kw'>end</span>
|
263
|
+
|
264
|
+
<span class='id identifier rubyid_obsolete_keys'>obsolete_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_data_keys'>data_keys</span> <span class='op'>-</span> <span class='id identifier rubyid_allowed_fields'>allowed_fields</span>
|
239
265
|
|
240
266
|
<span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Obsolete keys: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_obsolete_keys'>obsolete_keys</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_obsolete_keys'>obsolete_keys</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
|
241
267
|
|
@@ -253,7 +279,7 @@
|
|
253
279
|
</div>
|
254
280
|
|
255
281
|
<div id="footer">
|
256
|
-
Generated on
|
282
|
+
Generated on Wed May 17 10:53:58 2017 by
|
257
283
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
258
284
|
0.9.9 (ruby-2.3.1).
|
259
285
|
</div>
|
@@ -148,7 +148,7 @@
|
|
148
148
|
</div>
|
149
149
|
|
150
150
|
<div id="footer">
|
151
|
-
Generated on
|
151
|
+
Generated on Wed May 17 10:53:58 2017 by
|
152
152
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
153
153
|
0.9.9 (ruby-2.3.1).
|
154
154
|
</div>
|
@@ -135,7 +135,7 @@
|
|
135
135
|
</div>
|
136
136
|
|
137
137
|
<div id="footer">
|
138
|
-
Generated on
|
138
|
+
Generated on Wed May 17 10:53:58 2017 by
|
139
139
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
140
140
|
0.9.9 (ruby-2.3.1).
|
141
141
|
</div>
|
data/doc/Schemacop/Node.html
CHANGED
@@ -101,7 +101,7 @@
|
|
101
101
|
|
102
102
|
<div id="subclasses">
|
103
103
|
<h2>Direct Known Subclasses</h2>
|
104
|
-
<p class="children"><span class='object_link'><a href="BooleanValidator.html" title="Schemacop::BooleanValidator (class)">BooleanValidator</a></span>, <span class='object_link'><a href="NilValidator.html" title="Schemacop::NilValidator (class)">NilValidator</a></span>, <span class='object_link'><a href="NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span>, <span class='object_link'><a href="NumberValidator.html" title="Schemacop::NumberValidator (class)">NumberValidator</a></span>, <span class='object_link'><a href="ObjectValidator.html" title="Schemacop::ObjectValidator (class)">ObjectValidator</a></span>, <span class='object_link'><a href="StringValidator.html" title="Schemacop::StringValidator (class)">StringValidator</a></span></p>
|
104
|
+
<p class="children"><span class='object_link'><a href="BooleanValidator.html" title="Schemacop::BooleanValidator (class)">BooleanValidator</a></span>, <span class='object_link'><a href="NilValidator.html" title="Schemacop::NilValidator (class)">NilValidator</a></span>, <span class='object_link'><a href="NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span>, <span class='object_link'><a href="NumberValidator.html" title="Schemacop::NumberValidator (class)">NumberValidator</a></span>, <span class='object_link'><a href="ObjectValidator.html" title="Schemacop::ObjectValidator (class)">ObjectValidator</a></span>, <span class='object_link'><a href="StringValidator.html" title="Schemacop::StringValidator (class)">StringValidator</a></span>, <span class='object_link'><a href="SymbolValidator.html" title="Schemacop::SymbolValidator (class)">SymbolValidator</a></span></p>
|
105
105
|
</div>
|
106
106
|
|
107
107
|
|
@@ -1416,7 +1416,7 @@
|
|
1416
1416
|
</div>
|
1417
1417
|
|
1418
1418
|
<div id="footer">
|
1419
|
-
Generated on
|
1419
|
+
Generated on Wed May 17 10:53:58 2017 by
|
1420
1420
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1421
1421
|
0.9.9 (ruby-2.3.1).
|
1422
1422
|
</div>
|
@@ -232,7 +232,7 @@
|
|
232
232
|
</div>
|
233
233
|
|
234
234
|
<div id="footer">
|
235
|
-
Generated on
|
235
|
+
Generated on Wed May 17 10:53:58 2017 by
|
236
236
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
237
237
|
0.9.9 (ruby-2.3.1).
|
238
238
|
</div>
|
@@ -580,7 +580,7 @@
|
|
580
580
|
</div>
|
581
581
|
|
582
582
|
<div id="footer">
|
583
|
-
Generated on
|
583
|
+
Generated on Wed May 17 10:53:58 2017 by
|
584
584
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
585
585
|
0.9.9 (ruby-2.3.1).
|
586
586
|
</div>
|
@@ -604,7 +604,7 @@ as it formerly was the case in the constructor.</p>
|
|
604
604
|
</div>
|
605
605
|
|
606
606
|
<div id="footer">
|
607
|
-
Generated on
|
607
|
+
Generated on Wed May 17 10:53:58 2017 by
|
608
608
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
609
609
|
0.9.9 (ruby-2.3.1).
|
610
610
|
</div>
|
@@ -279,7 +279,7 @@
|
|
279
279
|
</div>
|
280
280
|
|
281
281
|
<div id="footer">
|
282
|
-
Generated on
|
282
|
+
Generated on Wed May 17 10:53:58 2017 by
|
283
283
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
284
284
|
0.9.9 (ruby-2.3.1).
|
285
285
|
</div>
|
@@ -222,7 +222,7 @@
|
|
222
222
|
</div>
|
223
223
|
|
224
224
|
<div id="footer">
|
225
|
-
Generated on
|
225
|
+
Generated on Wed May 17 10:53:58 2017 by
|
226
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
227
227
|
0.9.9 (ruby-2.3.1).
|
228
228
|
</div>
|
@@ -278,7 +278,7 @@
|
|
278
278
|
</div>
|
279
279
|
|
280
280
|
<div id="footer">
|
281
|
-
Generated on
|
281
|
+
Generated on Wed May 17 10:53:58 2017 by
|
282
282
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
283
283
|
0.9.9 (ruby-2.3.1).
|
284
284
|
</div>
|