hash_schema 0.1.0 → 0.1.1
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/lib/hash_schema.rb +2 -2
- data/lib/hash_schema/version.rb +1 -1
- data/spec/hash_schema_spec.rb +10 -0
- 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: 7788877ffd7c7aa507ade3fbb84cfbe58a2ad6e8
|
4
|
+
data.tar.gz: 2a2b2aa4fab62601f1cf5af5dd13676a383a1089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dd7c75d6b8f258d3d89d43cca6f1f1641ec3756b797d1b5c3ca01c3d44750ace31a329d2f616a1689b97f8baa85c3af1ca50b52ff7df090310cd2031ed5b19b
|
7
|
+
data.tar.gz: 202e68b5160accf317d017abc5185c1aa05dab9bd6c94281099f36693b98386081ed39ad7a7731d5c4f0926ccbae105116f761a748be5376a7d49e296a1c82ff
|
data/lib/hash_schema.rb
CHANGED
@@ -150,8 +150,8 @@ module HashSchema
|
|
150
150
|
end
|
151
151
|
|
152
152
|
class HashSchema < Schema
|
153
|
-
def initialize(strict: false, **
|
154
|
-
@chain =
|
153
|
+
def initialize(strict: false, schema_hash: {}, **keywords)
|
154
|
+
@chain = schema_hash.merge(keywords)
|
155
155
|
@strict = strict
|
156
156
|
end
|
157
157
|
|
data/lib/hash_schema/version.rb
CHANGED
data/spec/hash_schema_spec.rb
CHANGED
@@ -228,5 +228,15 @@ describe HashSchema do
|
|
228
228
|
expect(schema.validate(data).reject { |_, v| v.nil? }).to include(:y)
|
229
229
|
end
|
230
230
|
end
|
231
|
+
|
232
|
+
context 'when hash keys contain "strict"' do
|
233
|
+
it 'works around by passing the whole hash as "schema_hash"' do
|
234
|
+
schema = subject.new(strict: true, schema_hash: { strict: HashSchema::NumberSchema.new })
|
235
|
+
|
236
|
+
data = { strict: 1 }
|
237
|
+
|
238
|
+
expect(schema.validate(data).reject { |_, v| v.nil? }).to be_empty
|
239
|
+
end
|
240
|
+
end
|
231
241
|
end
|
232
242
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Po Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|