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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWJlODcyODQyMDg3YzcyMDFmNjRkMTJmMjkzOWY2NDdjYWJkMmE0ZQ==
4
+ MDA3ZmUyYTExMzFhNjIxOGE1MjkwMDgzNWEwNjM2MzQzY2UwYWJlNw==
5
5
  data.tar.gz: !binary |-
6
- MjI4ODIxYTgxNDg3MWNkOGIyYTdiOTMyMzUxOTE4YzYyMDA4ZmY4Yg==
6
+ Y2EwNGZmNTE2YzY2NjAwOWZjMzYxMGNiYzg5ZDdmOTA2NzQ5MDZhYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODlmN2FmZjEwMDBhOThhMGJkNDcxYjA5MzcwMDhhZmNiODgwYjJlNDc2NDEz
10
- MDc3YTYwMjU2N2EzZTI2MTFlYjM2YjI1OWY5N2JjMzhhODcwM2I0ZGQ4NjY4
11
- ODRlNTEyNzU2Y2IzYmE2ZTc2MzM2NTQ0OTFlY2FiMjhmNDdkNGY=
9
+ ODg4NGFlZTRmY2MwNjJhZDNiMjM3YWIwMGMyMTcyMWZmYjcyZjJhNDY5MTg1
10
+ MGUzNzE3M2RjZGMyZThjYTQ0ZTBkZmJkNzc4N2ZjYzY3ZWRhOWE0YzAwZDYy
11
+ MGUxNjU4MmY4ZGMxM2RjNzE1OTNmZmNiM2Y3YTM5MGQ2M2EwYTc=
12
12
  data.tar.gz: !binary |-
13
- NTAyNjEwNDZjMTJmYTZhYzM1ZGRmMDMyZTJjNmVjZWU2NzIyZmYwMTY0ODYw
14
- OTkyNTEwZDNmYTdiMTMzYmI2YzExYWIyZjM5N2JhY2U1NGU1N2Q5OTIzODJk
15
- ZDM1Mjc2MjA2NmIyMzM2NTBhZDM4NTlmMWI0OTQwMWVmNzhjMWY=
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.expand_path("../../../schema/schemas/#{hyphenated_name}-schema.json", __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
- errors = JSON::Validator.fully_validate(schema, record, :errors_as_objects => true)
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?
@@ -1,3 +1,3 @@
1
1
  module TurbotRunner
2
- VERSION = '0.1.22'
2
+ VERSION = '0.1.23'
3
3
  end
data/lib/turbot_runner.rb CHANGED
@@ -7,3 +7,7 @@ require 'turbot_runner/utils'
7
7
  require 'turbot_runner/validator'
8
8
  require 'turbot_runner/validators'
9
9
  require 'turbot_runner/version'
10
+
11
+ module TurbotRunner
12
+ SCHEMAS_PATH = File.expand_path('../../schema/schemas', __FILE__)
13
+ end
@@ -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
@@ -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 = TurbotRunner::Runner.new('spec/bots/bot-with-invalid-sample-date')
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.22
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-27 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema