json_schemer 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile.lock +6 -6
- data/json_schemer.gemspec +4 -4
- data/lib/json_schemer.rb +2 -2
- data/lib/json_schemer/cached_ref_resolver.rb +0 -1
- data/lib/json_schemer/format.rb +8 -8
- data/lib/json_schemer/schema/base.rb +6 -4
- data/lib/json_schemer/schema/draft4.rb +0 -1
- data/lib/json_schemer/schema/draft6.rb +0 -1
- data/lib/json_schemer/schema/draft7.rb +0 -1
- data/lib/json_schemer/version.rb +1 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73e909cd3b478fdfd80f7b4cf6f662e2b2089f9e4d36e53545250e08d6108ded
|
4
|
+
data.tar.gz: ce95d5099ca09f52616555570b014c4d4501f4ef3742fb70c06f61846d061aeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6e683f487d15ac6c88bed99e18ef73e949816a980abfe2edf066e2f92831e08d8245c9685104fe6df2d51e00de9b1670909681f1785704faf8adc17ec3ca26
|
7
|
+
data.tar.gz: dc9d610aade61f19a6f168d64945f0c90021548f9ead54bd8a76d9dfae2f0d2aa35c3e534fdd724b087faf8ed318704654dda63eedc531a37be0669e1f46c9e8
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
json_schemer (0.2.
|
5
|
-
ecma-re-validator (~> 0.2
|
6
|
-
hana (~> 1.3
|
7
|
-
regexp_parser (~> 1.5
|
8
|
-
uri_template (~> 0.7
|
4
|
+
json_schemer (0.2.2)
|
5
|
+
ecma-re-validator (~> 0.2)
|
6
|
+
hana (~> 1.3)
|
7
|
+
regexp_parser (~> 1.5)
|
8
|
+
uri_template (~> 0.7)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
hana (1.3.5)
|
16
16
|
minitest (5.11.3)
|
17
17
|
rake (10.5.0)
|
18
|
-
regexp_parser (1.
|
18
|
+
regexp_parser (1.6.0)
|
19
19
|
uri_template (0.7.0)
|
20
20
|
|
21
21
|
PLATFORMS
|
data/json_schemer.gemspec
CHANGED
@@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
|
|
32
32
|
# spec.add_development_dependency "jsonschema", "~> 2.0.2"
|
33
33
|
# spec.add_development_dependency "rj_schema", "~> 0.2.0"
|
34
34
|
|
35
|
-
spec.add_runtime_dependency "ecma-re-validator", "~> 0.2
|
36
|
-
spec.add_runtime_dependency "hana", "~> 1.3
|
37
|
-
spec.add_runtime_dependency "uri_template", "~> 0.7
|
38
|
-
spec.add_runtime_dependency "regexp_parser", "~> 1.5
|
35
|
+
spec.add_runtime_dependency "ecma-re-validator", "~> 0.2"
|
36
|
+
spec.add_runtime_dependency "hana", "~> 1.3"
|
37
|
+
spec.add_runtime_dependency "uri_template", "~> 0.7"
|
38
|
+
spec.add_runtime_dependency "regexp_parser", "~> 1.5"
|
39
39
|
end
|
data/lib/json_schemer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
require 'base64'
|
3
|
+
require 'ipaddr'
|
4
4
|
require 'json'
|
5
5
|
require 'net/http'
|
6
6
|
require 'pathname'
|
@@ -9,7 +9,7 @@ require 'uri'
|
|
9
9
|
|
10
10
|
require 'ecma-re-validator'
|
11
11
|
require 'hana'
|
12
|
-
require '
|
12
|
+
require 'regexp_parser'
|
13
13
|
require 'uri_template'
|
14
14
|
|
15
15
|
require 'json_schemer/version'
|
data/lib/json_schemer/format.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
module JSONSchemer
|
4
3
|
module Format
|
5
4
|
# this is no good
|
@@ -9,6 +8,7 @@ module JSONSchemer
|
|
9
8
|
JSON_POINTER_REGEX_STRING = '(\/([^~\/]|~[01])*)*'
|
10
9
|
JSON_POINTER_REGEX = /\A#{JSON_POINTER_REGEX_STRING}\z/.freeze
|
11
10
|
RELATIVE_JSON_POINTER_REGEX = /\A(0|[1-9]\d*)(#|#{JSON_POINTER_REGEX_STRING})?\z/.freeze
|
11
|
+
DATE_TIME_OFFSET_REGEX = /(Z|[\+\-]([01][0-9]|2[0-3]):[0-5][0-9])\z/i.freeze
|
12
12
|
|
13
13
|
# https://github.com/ruby-rdf/rdf
|
14
14
|
|
@@ -108,18 +108,18 @@ module JSONSchemer
|
|
108
108
|
|
109
109
|
def valid_date_time?(data)
|
110
110
|
DateTime.rfc3339(data)
|
111
|
-
|
111
|
+
DATE_TIME_OFFSET_REGEX.match?(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
|
-
|
118
|
+
EMAIL_REGEX.match?(data)
|
119
119
|
end
|
120
120
|
|
121
121
|
def valid_hostname?(data)
|
122
|
-
|
122
|
+
HOSTNAME_REGEX.match?(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
|
-
|
133
|
+
IRI.match?(data)
|
134
134
|
end
|
135
135
|
|
136
136
|
def valid_iri_reference?(data)
|
137
|
-
|
137
|
+
IRELATIVE_REF.match?(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
|
-
|
148
|
+
JSON_POINTER_REGEX.match?(data)
|
149
149
|
end
|
150
150
|
|
151
151
|
def valid_relative_json_pointer?(data)
|
152
|
-
|
152
|
+
RELATIVE_JSON_POINTER_REGEX.match?(data)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
module JSONSchemer
|
4
3
|
module Schema
|
5
4
|
class Base
|
@@ -506,7 +505,7 @@ module JSONSchemer
|
|
506
505
|
[pattern, ecma_262_regex(pattern), property_schema]
|
507
506
|
end
|
508
507
|
regex_pattern_properties.each do |pattern, regex, property_schema|
|
509
|
-
if regex
|
508
|
+
if regex.match?(key)
|
510
509
|
subinstance = instance.merge(
|
511
510
|
data: value,
|
512
511
|
data_pointer: "#{instance.data_pointer}/#{key}",
|
@@ -552,10 +551,13 @@ module JSONSchemer
|
|
552
551
|
end
|
553
552
|
|
554
553
|
def join_uri(a, b)
|
555
|
-
|
554
|
+
b = URI.parse(b) if b
|
555
|
+
if a && b && a.relative? && b.relative?
|
556
|
+
b
|
557
|
+
elsif a && b
|
556
558
|
URI.join(a, b)
|
557
559
|
elsif b
|
558
|
-
|
560
|
+
b
|
559
561
|
else
|
560
562
|
a
|
561
563
|
end
|
data/lib/json_schemer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Harsha
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,56 +58,56 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.2
|
61
|
+
version: '0.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.2
|
68
|
+
version: '0.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: hana
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.3
|
75
|
+
version: '1.3'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.3
|
82
|
+
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: uri_template
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.7
|
89
|
+
version: '0.7'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.7
|
96
|
+
version: '0.7'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: regexp_parser
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.5
|
103
|
+
version: '1.5'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.5
|
110
|
+
version: '1.5'
|
111
111
|
description:
|
112
112
|
email:
|
113
113
|
- davishmcclurg@gmail.com
|