onestop-id-registry-validator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +5 -0
- data/lib/onestop_id_registry_validator/onestop_id_registry_validator.rb +63 -0
- data/lib/onestop_id_registry_validator/version.rb +3 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 40113a1ff985fd06c6bf52bcaea1b520debf0434
|
4
|
+
data.tar.gz: 93b4b38ebaa36b57d9ba461445e60b49b4da384c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c388ab512a17e3597273d9d3e3918740ebeb338c679bf5acba5f591c4a5a329695f4ebfb49d89778e11a254cd165dc8bdd587a993b7669ce6294f07065e0845
|
7
|
+
data.tar.gz: 37044971a624a77fe3d9b25b6dbf4290bf9b7fe61a0b9068e16cd81ce0081edfd21448f4a5dbcb20e1c6b6b9a1e704d5907ec30caabb6e884ad0e3864b302010
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Mapzen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'json-schema'
|
2
|
+
require 'onestop_id_client'
|
3
|
+
|
4
|
+
require_relative 'version'
|
5
|
+
|
6
|
+
module OnestopIdRegistryValidator
|
7
|
+
ENTITIES_TO_VALIDATE = [:feeds, :operators]
|
8
|
+
|
9
|
+
JSON::Validator.register_format_validator 'operatorOnestopId', -> (onestop_id) do
|
10
|
+
|
11
|
+
is_a_valid_onestop_id, errors = OnestopIdClient::OnestopId.validate_onestop_id_string(onestop_id, expected_entity_type: 'operator')
|
12
|
+
|
13
|
+
begin
|
14
|
+
OnestopIdClient::Entities::Operator.new(onestop_id: onestop_id)
|
15
|
+
rescue StandardError => e
|
16
|
+
is_a_valid_onestop_id = false
|
17
|
+
errors << e.message
|
18
|
+
end
|
19
|
+
|
20
|
+
raise JSON::Schema::CustomFormatError.new(errors.join(', ')) if !is_a_valid_onestop_id
|
21
|
+
end
|
22
|
+
|
23
|
+
JSON::Validator.register_format_validator 'feedOnestopId', -> (onestop_id) do
|
24
|
+
is_a_valid_onestop_id, errors = OnestopIdClient::OnestopId.validate_onestop_id_string(onestop_id, expected_entity_type: 'feed')
|
25
|
+
|
26
|
+
begin
|
27
|
+
OnestopIdClient::Entities::Feed.new(onestop_id: onestop_id)
|
28
|
+
rescue StandardError => e
|
29
|
+
is_a_valid_onestop_id = false
|
30
|
+
errors << e.message
|
31
|
+
end
|
32
|
+
|
33
|
+
raise JSON::Schema::CustomFormatError.new(errors.join(', ')) if !is_a_valid_onestop_id
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.validate_all
|
37
|
+
errors = {}
|
38
|
+
ENTITIES_TO_VALIDATE.each do |entity_to_validate|
|
39
|
+
OnestopIdClient::Registry.json_files_for_entity(entity_to_validate.to_s).each do |file_path|
|
40
|
+
file = File.open(file_path, 'r')
|
41
|
+
file_errors = validate(entity_to_validate, file.read)
|
42
|
+
errors[File.basename(file)] = file_errors if file_errors && file_errors.length > 0
|
43
|
+
end
|
44
|
+
end
|
45
|
+
if errors.length > 0
|
46
|
+
puts errors.inspect
|
47
|
+
else
|
48
|
+
puts "All JSON feed definition files validated."
|
49
|
+
Process.exit(0)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def self.validate(entity_type, contents)
|
56
|
+
JSON::Validator.fully_validate(
|
57
|
+
File.join(__dir__, 'schemas', "#{entity_type}.json"),
|
58
|
+
contents,
|
59
|
+
errors_as_objects: true,
|
60
|
+
strict: true
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onestop-id-registry-validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Drew Dara-Abrams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: onestop-id-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json-schema
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.10'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.10'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.5'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.5'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-byebug
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
description: ''
|
126
|
+
email:
|
127
|
+
- drew@mapzen.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- LICENSE.txt
|
133
|
+
- README.md
|
134
|
+
- lib/onestop_id_registry_validator/onestop_id_registry_validator.rb
|
135
|
+
- lib/onestop_id_registry_validator/version.rb
|
136
|
+
homepage: https://github.com/transitland/onestop-id-registry-validator
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '2.0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.2.2
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: Validate the Onestop ID Registry/
|
160
|
+
test_files: []
|
161
|
+
has_rdoc:
|