turbot-runner 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWI1YjU1NDhkMjg2ZDkzNDJmNGYzNmU3NTg1OGRlMWExZGY5NDI0NA==
4
+ ZmZhZTI1N2ZkMWFlODhiOGEwNjlhMGE4MzkwMjk1MmQ5OTc2YjcyNg==
5
5
  data.tar.gz: !binary |-
6
- ZDkyNTcxMDhmZjA5NDRjMjczNzdhMTA2MGJlNGJlZTQ3ZjM4NWZkOA==
6
+ NDU1MTY4Yzk1ZDJkMmEwYjM0N2YxMDI3N2IxYjVlYTg0MDE0MTU1Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2Y5NjYyY2ExOWY1ZTg2OWFmMmUyMjlkNmMwZTI4N2NkYjEzZDY4YWY2Njlh
10
- OTJlNWY2N2VjMDQzMDhmMTBjODM5NmI5ZDFjODc3YWQxMjc3ZjAxMjczN2U0
11
- MjZmZmY2ODNiOTIxZmZiYTIyZGE2MDliMDMxNTk3NTQ1MTIxMTA=
9
+ OGI4ZjgyOTJjZGI3ZTVhZWY4YWQ3YzE4Y2I0MjIwZjU3ZDZjZWZjYjk4OTYy
10
+ N2ViZWM2ZTlkMTcxYWUxZjQ1ZTBkNjBjMjc3MWRhYjhiZThkZWZkYTljMjlh
11
+ YTkwZjY1OTNiYzBjNWE3N2NlODcyNjFkMjkzNWM3NzI1YjFjYTQ=
12
12
  data.tar.gz: !binary |-
13
- ODE2N2ZhN2M2MWFjMzJhNDgyNGQzNDBlNGM2OGU2NmEyYjBkNDUyNTkyNzZh
14
- MTU1OGM1YjM3YjJiZmE2OWEzNTNmODJlNTEzNGIxZjc5NmRiN2E3YmVmNWQy
15
- OTFlODIwNGZhOWRlYjliYjJlZjBlMmIwYzhkNGNlOTlhOTFkZDE=
13
+ ODdjNTI1YWNjOWUyOGEzY2ZlYWZhOWFmM2Y5MDNiMWE1Mzc4MDE3YmE2ZTU3
14
+ YTg1NDFiZGNmOWZkNDY3N2IyOWY5YTAwNzc5NDFjYWQ1Y2U4YWUyMDFmZWJm
15
+ ZmU5NWJmMjU0MzJlN2Q0MzQ0NGFkMzhiNDZkYWRlMTNlZjY4OTk=
data/lib/turbot_runner.rb CHANGED
@@ -9,4 +9,9 @@ require 'turbot_runner/version'
9
9
 
10
10
  module TurbotRunner
11
11
  SCHEMAS_PATH = File.expand_path('../../schema/schemas', __FILE__)
12
+
13
+ def self.schema_path(data_type)
14
+ hyphenated_name = data_type.to_s.gsub("_", "-").gsub(" ", "-")
15
+ File.join(SCHEMAS_PATH, "#{hyphenated_name}-schema.json")
16
+ end
12
17
  end
@@ -17,7 +17,7 @@ module TurbotRunner
17
17
  else
18
18
  record = Openc::JsonSchema.convert_dates(schema_path, JSON.parse(line))
19
19
 
20
- error_message = Validator.validate(schema_path, record, @identifying_fields)
20
+ error_message = Validator.validate(@data_type, record, @identifying_fields)
21
21
 
22
22
  if error_message.nil?
23
23
  begin
@@ -41,8 +41,7 @@ module TurbotRunner
41
41
  end
42
42
 
43
43
  def schema_path
44
- hyphenated_name = @data_type.to_s.gsub("_", "-").gsub(" ", "-")
45
- File.join(SCHEMAS_PATH, "#{hyphenated_name}-schema.json")
44
+ TurbotRunner.schema_path(@data_type)
46
45
  end
47
46
  end
48
47
  end
@@ -2,7 +2,8 @@ module TurbotRunner
2
2
  module Validator
3
3
  extend self
4
4
 
5
- def validate(schema_path, record, identifying_fields)
5
+ def validate(data_type, record, identifying_fields)
6
+ schema_path = TurbotRunner.schema_path(data_type)
6
7
  error = Openc::JsonSchema.validate(schema_path, record)
7
8
 
8
9
  message = nil
@@ -1,3 +1,3 @@
1
1
  module TurbotRunner
2
- VERSION = '0.1.25'
2
+ VERSION = '0.1.26'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -2,16 +2,14 @@ require 'turbot_runner'
2
2
 
3
3
  RSpec::Matchers.define(:fail_validation_with) do |expected_error|
4
4
  match do |record|
5
- schema_path = File.join(TurbotRunner::SCHEMAS_PATH, 'primary-data-schema.json')
6
5
  identifying_fields = ['number']
7
- expect(TurbotRunner::Validator.validate(schema_path, record, identifying_fields)).to eq(expected_error)
6
+ expect(TurbotRunner::Validator.validate('primary-data', record, identifying_fields)).to eq(expected_error)
8
7
  end
9
8
  end
10
9
 
11
10
  RSpec::Matchers.define(:be_valid) do
12
11
  match do |record|
13
- schema_path = File.join(TurbotRunner::SCHEMAS_PATH, 'primary-data-schema.json')
14
12
  identifying_fields = ['number']
15
- expect(TurbotRunner::Validator.validate(schema_path, record, identifying_fields)).to eq(nil)
13
+ expect(TurbotRunner::Validator.validate('primary-data', record, identifying_fields)).to eq(nil)
16
14
  end
17
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbot-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenCorporates