rest-json-validator 0.0.2 → 0.0.3
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/rest-json-validator.rb +7 -6
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af82cb1d9556bb679b881df6ce3be1bbeddb939
|
4
|
+
data.tar.gz: 126996186a735f3aeab7783ae5e36704d6819121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfd1b1ab65aeb20650865f57ae0239d50808b04dadf8dc98c8552197d647485f313585f0d991bfe3bc3d08e4b2db64b1f3af92dc2f807624de122a6049163a69
|
7
|
+
data.tar.gz: 344b9db979d8b53b16b35b3dd379ff906e528f2933ef583dc27cbd66ab0fe6ed2f18f539ff34fb992c21d3e62909f82759b14222d8f6adba4c5dd4f99038b307
|
data/lib/rest-json-validator.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module RestJsonValidator
|
2
2
|
class JsonValidator
|
3
3
|
|
4
|
-
def initialize
|
5
|
-
@stack
|
4
|
+
def initialize(receiver: nil)
|
5
|
+
@stack = []
|
6
6
|
@listeners = []
|
7
|
+
@receiver = receiver || self
|
7
8
|
end
|
8
9
|
|
9
10
|
# a listener must implement a method called notify, input string
|
@@ -66,15 +67,15 @@ module RestJsonValidator
|
|
66
67
|
|
67
68
|
def run_field_validators(actual_json, specification, level)
|
68
69
|
if is_sub_composite_checker?(specification)
|
69
|
-
send(specification[:sub_composite_checker], actual_json, find_id(actual_json), 'vetikke')
|
70
|
+
@receiver.send(specification[:sub_composite_checker], actual_json, find_id(actual_json), 'vetikke')
|
70
71
|
else
|
71
72
|
specification.keys.each do |api_key|
|
72
73
|
api_element = specification[api_key]
|
73
74
|
id = find_id(actual_json)
|
74
75
|
if is_field_validator?(api_element, api_key)
|
75
|
-
send(api_element, actual_json[api_key], id, api_key)
|
76
|
+
@receiver.send(api_element, actual_json[api_key], id, api_key)
|
76
77
|
elsif is_composite_checker?(api_element)
|
77
|
-
send(api_element[:composite_checker], actual_json[api_key], id, api_key)
|
78
|
+
@receiver.send(api_element[:composite_checker], actual_json[api_key], id, api_key)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
end
|
@@ -87,7 +88,7 @@ module RestJsonValidator
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def depth_validate_array(actual_json, specification, level, content_checker=nil)
|
90
|
-
send(content_checker.intern, actual_json, @media_id, level) unless content_checker.nil?
|
91
|
+
@receiver.send(content_checker.intern, actual_json, @media_id, level) unless content_checker.nil?
|
91
92
|
actual_json.each do |json_element|
|
92
93
|
validate_json_api_compliance(json_element, specification, level)
|
93
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-json-validator
|
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
|
- John Åsmund Westberg, Aril Spetalen, Magnus de Laval, Dagfinn Olsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Define a specification of a json structure, as well as composing methods
|
14
14
|
to verify its content. Then use this tool to recursively run through the data, and
|
@@ -30,19 +30,18 @@ require_paths:
|
|
30
30
|
- lib
|
31
31
|
required_ruby_version: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '0'
|
36
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
43
|
+
rubygems_version: 2.6.12
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: Tool to test a json structure and data against a specification
|
47
47
|
test_files: []
|
48
|
-
has_rdoc:
|