json_structure 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -1
- data/lib/json_structure.rb +20 -12
- data/lib/json_structure/any.rb +7 -0
- data/lib/json_structure/boolean.rb +7 -0
- data/lib/json_structure/number.rb +0 -7
- data/lib/json_structure/object.rb +1 -1
- data/lib/json_structure/string.rb +3 -3
- data/lib/json_structure/type.rb +2 -6
- data/lib/json_structure/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddd50a60ceb48fde2376452cd100867cfc839f40
|
4
|
+
data.tar.gz: 12aedfb98c64758d0b69905111fd730b0811649a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee77013efd9d01e9bf5e42c9a10ee78ba79ae2b3678872cc7ea3d3e26f6c2e71ad9e6d49a977150e56e796165c72e2b4a8898ba8495ea9441a7c2c412cedc9f6
|
7
|
+
data.tar.gz: 1694e8b09ce760d8625315ed96526491ca3c6ba779e11311ef4c70cf19a5565fc7b7db16c5848eee97c987fcc86b9734b8c5fb2e83dc7d0900a8a6287de46daf
|
data/Rakefile
CHANGED
data/lib/json_structure.rb
CHANGED
@@ -6,6 +6,10 @@ require 'json_structure/string'
|
|
6
6
|
require 'json_structure/null'
|
7
7
|
require 'json_structure/any_of'
|
8
8
|
require 'json_structure/value'
|
9
|
+
require 'json_structure/any'
|
10
|
+
require 'json_structure/boolean'
|
11
|
+
|
12
|
+
require 'json_structure/version'
|
9
13
|
|
10
14
|
module JsonStructure
|
11
15
|
def self.build(&block)
|
@@ -13,18 +17,22 @@ module JsonStructure
|
|
13
17
|
end
|
14
18
|
|
15
19
|
class Builder
|
16
|
-
[
|
17
|
-
Type
|
18
|
-
Object_
|
19
|
-
Array
|
20
|
-
Number
|
21
|
-
Integer
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
%w[
|
21
|
+
Type
|
22
|
+
Object_
|
23
|
+
Array
|
24
|
+
Number
|
25
|
+
Integer
|
26
|
+
String
|
27
|
+
Null
|
28
|
+
AnyOf
|
29
|
+
Value
|
30
|
+
Any
|
31
|
+
Boolean
|
32
|
+
].each do |name|
|
33
|
+
klass = JsonStructure.const_get(name)
|
34
|
+
|
35
|
+
method = name
|
28
36
|
.gsub(/([a-z])([A-Z])/, '\1_\2')
|
29
37
|
.gsub(/_+$/, '')
|
30
38
|
.downcase
|
@@ -9,9 +9,9 @@ module JsonStructure
|
|
9
9
|
def ===(value)
|
10
10
|
return false unless value.is_a?(::String)
|
11
11
|
|
12
|
-
return false
|
13
|
-
return false
|
14
|
-
return false
|
12
|
+
return false if @min_length && value.size < @min_length
|
13
|
+
return false if @max_length && value.size > @max_length
|
14
|
+
return false if @pattern && @pattern !~ value
|
15
15
|
true
|
16
16
|
end
|
17
17
|
end
|
data/lib/json_structure/type.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_structure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaido Iwamoto
|
@@ -55,8 +55,10 @@ files:
|
|
55
55
|
- bin/setup
|
56
56
|
- json_structure.gemspec
|
57
57
|
- lib/json_structure.rb
|
58
|
+
- lib/json_structure/any.rb
|
58
59
|
- lib/json_structure/any_of.rb
|
59
60
|
- lib/json_structure/array.rb
|
61
|
+
- lib/json_structure/boolean.rb
|
60
62
|
- lib/json_structure/null.rb
|
61
63
|
- lib/json_structure/number.rb
|
62
64
|
- lib/json_structure/object.rb
|