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 +8 -8
- data/lib/turbot_runner.rb +5 -0
- data/lib/turbot_runner/processor.rb +2 -3
- data/lib/turbot_runner/validator.rb +2 -1
- data/lib/turbot_runner/version.rb +1 -1
- data/spec/spec_helper.rb +2 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmZhZTI1N2ZkMWFlODhiOGEwNjlhMGE4MzkwMjk1MmQ5OTc2YjcyNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDU1MTY4Yzk1ZDJkMmEwYjM0N2YxMDI3N2IxYjVlYTg0MDE0MTU1Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGI4ZjgyOTJjZGI3ZTVhZWY4YWQ3YzE4Y2I0MjIwZjU3ZDZjZWZjYjk4OTYy
|
10
|
+
N2ViZWM2ZTlkMTcxYWUxZjQ1ZTBkNjBjMjc3MWRhYjhiZThkZWZkYTljMjlh
|
11
|
+
YTkwZjY1OTNiYzBjNWE3N2NlODcyNjFkMjkzNWM3NzI1YjFjYTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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(
|
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
|
-
|
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(
|
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
|
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(
|
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(
|
13
|
+
expect(TurbotRunner::Validator.validate('primary-data', record, identifying_fields)).to eq(nil)
|
16
14
|
end
|
17
15
|
end
|