turbot-runner 0.1.22 → 0.1.23
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 +8 -8
- data/lib/turbot_runner/processor.rb +1 -1
- data/lib/turbot_runner/validator.rb +5 -2
- data/lib/turbot_runner/version.rb +1 -1
- data/lib/turbot_runner.rb +4 -0
- data/spec/lib/processor_spec.rb +31 -0
- data/spec/lib/runner_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDA3ZmUyYTExMzFhNjIxOGE1MjkwMDgzNWEwNjM2MzQzY2UwYWJlNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2EwNGZmNTE2YzY2NjAwOWZjMzYxMGNiYzg5ZDdmOTA2NzQ5MDZhYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODg4NGFlZTRmY2MwNjJhZDNiMjM3YWIwMGMyMTcyMWZmYjcyZjJhNDY5MTg1
|
10
|
+
MGUzNzE3M2RjZGMyZThjYTQ0ZTBkZmJkNzc4N2ZjYzY3ZWRhOWE0YzAwZDYy
|
11
|
+
MGUxNjU4MmY4ZGMxM2RjNzE1OTNmZmNiM2Y3YTM5MGQ2M2EwYTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWYxZjZkYjA4MGU4ZTk2MzU2MDg4ZWFhMDQ0ZjA2OGJkODlmNDA1OWMxYmQy
|
14
|
+
NTcxYjQyYTBmZWI2NGY3YTYyOWNkMDRlNjc1MzAyMTY5MWJhYmE0OGY2Y2E3
|
15
|
+
ODE2MDU1MDI5Nzc1ZDQ3OGIxM2JlYTYwNWZmZTk3ZDcyOTllNGE=
|
@@ -143,7 +143,7 @@ module TurbotRunner
|
|
143
143
|
|
144
144
|
def load_schema
|
145
145
|
hyphenated_name = @data_type.to_s.gsub("_", "-").gsub(" ", "-")
|
146
|
-
path = File.
|
146
|
+
path = File.join(SCHEMAS_PATH, "#{hyphenated_name}-schema.json")
|
147
147
|
JSON.load(File.read(path))
|
148
148
|
end
|
149
149
|
|
@@ -5,8 +5,11 @@ module TurbotRunner
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def validate(schema, record)
|
8
|
-
|
9
|
-
|
8
|
+
# We must change directory for the relative paths in schemas to make sense.
|
9
|
+
errors = Dir.chdir(SCHEMAS_PATH) do
|
10
|
+
JSON::Validator.fully_validate(schema, record, :errors_as_objects => true)
|
11
|
+
end
|
12
|
+
|
10
13
|
# For now, we just handle the first error.
|
11
14
|
error = errors[0]
|
12
15
|
return if error.nil?
|
data/lib/turbot_runner.rb
CHANGED
data/spec/lib/processor_spec.rb
CHANGED
@@ -156,6 +156,37 @@ describe TurbotRunner::Processor do
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
it 'can handle schemas with $refs' do
|
161
|
+
handler = TurbotRunner::BaseHandler.new
|
162
|
+
script_config = {
|
163
|
+
:data_type => 'rich-licence',
|
164
|
+
:identifying_fields => ['licence_number']
|
165
|
+
}
|
166
|
+
|
167
|
+
script_runner = instance_double('ScriptRunner')
|
168
|
+
allow(script_runner).to receive(:interrupt_and_mark_as_failed)
|
169
|
+
processor = TurbotRunner::Processor.new(script_runner, script_config, handler)
|
170
|
+
|
171
|
+
record = {
|
172
|
+
:licence_holder => {
|
173
|
+
:entity_type => 'company',
|
174
|
+
:entity_properties => {
|
175
|
+
:name => 'Hairy Goat Breeding Ltd',
|
176
|
+
:jurisdiction_code => 'gb',
|
177
|
+
}
|
178
|
+
},
|
179
|
+
:licence_number => '1234',
|
180
|
+
:permissions => ['Goat breeding'],
|
181
|
+
:licence_issuer => 'Sheep and Goat Board of Bermuda',
|
182
|
+
:jurisdiction_of_licence => 'bm',
|
183
|
+
:source_url => 'http://example.com',
|
184
|
+
:sample_date => '2015-01-01'
|
185
|
+
}
|
186
|
+
|
187
|
+
expect(handler).to receive(:handle_valid_record)
|
188
|
+
processor.process(record.to_json)
|
189
|
+
end
|
159
190
|
end
|
160
191
|
|
161
192
|
describe '#convert_record' do
|
data/spec/lib/runner_spec.rb
CHANGED
@@ -219,7 +219,7 @@ describe TurbotRunner::Runner do
|
|
219
219
|
|
220
220
|
context 'with a bot that emits an invalid sample date' do
|
221
221
|
before do
|
222
|
-
@runner =
|
222
|
+
@runner = test_runner('bot-with-invalid-sample-date')
|
223
223
|
end
|
224
224
|
|
225
225
|
it 'returns false' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbot-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenCorporates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|