json_schemer 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Gemfile.lock +3 -3
- data/json_schemer.gemspec +3 -1
- data/lib/json_schemer/format.rb +7 -7
- data/lib/json_schemer/schema/base.rb +8 -2
- data/lib/json_schemer/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8a183671565c8bc3443ea0cb0b729858c4c34208c45da986bc2994504d1dfa3
|
4
|
+
data.tar.gz: dc7005acad88d864d4c7a5781fb0fd9d3e5ec7f78cd152db0cad9591ce650eb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c165cb49f7fb1e0d2253542a0b5d14bf6c624d474fea09ec3e1727ae0f443f74242b423c4f4478b61cb648654e87e7e52dca458792ae4bc771705a2efb999b
|
7
|
+
data.tar.gz: 6e507392188f78799924393b992eb646933fa9ce046b527d89bd368d7e24691d98e2fb4c6286e57e66ff25f6cfc775c5f09a76184433cdfe479ae1681f522ee3
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
json_schemer (0.2.
|
4
|
+
json_schemer (0.2.4)
|
5
5
|
ecma-re-validator (~> 0.2)
|
6
6
|
hana (~> 1.3)
|
7
7
|
regexp_parser (~> 1.5)
|
@@ -22,10 +22,10 @@ PLATFORMS
|
|
22
22
|
ruby
|
23
23
|
|
24
24
|
DEPENDENCIES
|
25
|
-
bundler (~>
|
25
|
+
bundler (~> 1.16)
|
26
26
|
json_schemer!
|
27
27
|
minitest (~> 5.0)
|
28
28
|
rake (~> 10.0)
|
29
29
|
|
30
30
|
BUNDLED WITH
|
31
|
-
|
31
|
+
1.17.3
|
data/json_schemer.gemspec
CHANGED
@@ -20,7 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.
|
23
|
+
spec.required_ruby_version = '~> 2.0'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
24
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
26
28
|
|
data/lib/json_schemer/format.rb
CHANGED
@@ -108,18 +108,18 @@ module JSONSchemer
|
|
108
108
|
|
109
109
|
def valid_date_time?(data)
|
110
110
|
DateTime.rfc3339(data)
|
111
|
-
DATE_TIME_OFFSET_REGEX
|
111
|
+
!!(DATE_TIME_OFFSET_REGEX =~ data)
|
112
112
|
rescue ArgumentError => e
|
113
113
|
raise e unless e.message == 'invalid date'
|
114
114
|
false
|
115
115
|
end
|
116
116
|
|
117
117
|
def valid_email?(data)
|
118
|
-
EMAIL_REGEX
|
118
|
+
!!(EMAIL_REGEX =~ data)
|
119
119
|
end
|
120
120
|
|
121
121
|
def valid_hostname?(data)
|
122
|
-
HOSTNAME_REGEX
|
122
|
+
!!(HOSTNAME_REGEX =~ data && data.split('.').all? { |label| label.size <= 63 })
|
123
123
|
end
|
124
124
|
|
125
125
|
def valid_ip?(data, type)
|
@@ -130,11 +130,11 @@ module JSONSchemer
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def valid_iri?(data)
|
133
|
-
IRI
|
133
|
+
!!(IRI =~ data)
|
134
134
|
end
|
135
135
|
|
136
136
|
def valid_iri_reference?(data)
|
137
|
-
IRELATIVE_REF
|
137
|
+
!!(IRELATIVE_REF =~ data)
|
138
138
|
end
|
139
139
|
|
140
140
|
def valid_uri_template?(data)
|
@@ -145,11 +145,11 @@ module JSONSchemer
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def valid_json_pointer?(data)
|
148
|
-
JSON_POINTER_REGEX
|
148
|
+
!!(JSON_POINTER_REGEX =~ data)
|
149
149
|
end
|
150
150
|
|
151
151
|
def valid_relative_json_pointer?(data)
|
152
|
-
RELATIVE_JSON_POINTER_REGEX
|
152
|
+
!!(RELATIVE_JSON_POINTER_REGEX =~ data)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
@@ -470,7 +470,13 @@ module JSONSchemer
|
|
470
470
|
if insert_property_defaults?
|
471
471
|
properties.each do |property, property_schema|
|
472
472
|
if !data.key?(property) && property_schema.key?('default')
|
473
|
-
|
473
|
+
default = property_schema.fetch('default')
|
474
|
+
data[property] = case default
|
475
|
+
when Numeric, Symbol, true, false, nil
|
476
|
+
default
|
477
|
+
else
|
478
|
+
default.clone
|
479
|
+
end
|
474
480
|
end
|
475
481
|
end
|
476
482
|
end
|
@@ -520,7 +526,7 @@ module JSONSchemer
|
|
520
526
|
[pattern, ecma_262_regex(pattern), property_schema]
|
521
527
|
end
|
522
528
|
regex_pattern_properties.each do |pattern, regex, property_schema|
|
523
|
-
if regex
|
529
|
+
if regex =~ key
|
524
530
|
subinstance = instance.merge(
|
525
531
|
data: value,
|
526
532
|
data_pointer: "#{instance.data_pointer}/#{key}",
|
data/lib/json_schemer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schemer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Harsha
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,9 +144,9 @@ require_paths:
|
|
144
144
|
- lib
|
145
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
|
-
- - "
|
147
|
+
- - "~>"
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
149
|
+
version: '2.0'
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
152
|
- - ">="
|