turbot-runner 0.1.31 → 0.1.32

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
- MjFkNmJhN2U2YjY3NGRmOTczOGFkNjdlODhjNWUzNzc4Zjg3ZWZkZA==
4
+ YTUyZjJjODU0Mzg5ODhmOGMxZGFhYjc0ZjRmM2RkYTZmOTUzOTlkZg==
5
5
  data.tar.gz: !binary |-
6
- MTlmNDMxODQwN2ZiZDQzNTBlNDY1ZmI4ZTI4MmU3OGVkYmFhNTI4OA==
6
+ YzcyOTU0NmFmZGU3NGZiNmUyZmRhZGE5YjA2YWU5Y2UwOTI5OWI3OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjlhZjMwNDgyMTVlYTE5N2Y2MWMyYmJiMDIzOGViMGQ0ZDk4OWRlZjU2OWJi
10
- YWIyY2M0YTJlOWY4ZDJhMTJkYjViZGY1ZmVkMDY2ZjlhMzhlYjJkOGZlMmM4
11
- Y2Y3M2IzNmFmZTUzMDY4MTFlYjcxZDVhMDQyNjNjYzg0OGZiZDA=
9
+ N2E3NmRlYjk4MjE0NGQzYmIxOWUxODcwODI1OWU5NDEzNjNhM2UyZWUyYjEy
10
+ ZTgxY2IzZjEzZmU1YmFjMWNjMjU3NGI4YmIwZGZlOTM5NWVhMzI2NzViOTUz
11
+ NGRhNDdiZWM2NDQ2NjIwMDcxNGM1MjI1OGNmMDgxYjYyNjdjMTc=
12
12
  data.tar.gz: !binary |-
13
- YTEyNjhjYjJmODE2ODljOTE1NmY2M2ZjNjg1OGRlYTc3OWQ1MjM3ZDUwNjBi
14
- ZmMwYjk2NWNiMjJmZmQ2M2ZjYjk1M2QwMjQ1MmFhZDBjNGE3YjczMzMxZjFi
15
- ODhiNzkzZWNiMzZlY2NlYjUxYzQ1Yjg0MWU4M2ZhYjhlNmZkNWU=
13
+ OTM1ZDEyODdlNTkwMmIzNGEwZTE4NWViMTg1MmVhYzRjYWFkMDlmY2U3Mjgx
14
+ Njg3ODdjNTQzYTgyMDg2ZjBlZWMyNThiZjg1ODdjYmU2ZDhlZmY1NTkzYmY4
15
+ NWI5MjQ3YTZiNGNjYTdiMjJmOWViMmQyMGVkNWM2ZTFjOTg4M2Q=
data/lib/turbot_runner.rb CHANGED
@@ -11,7 +11,16 @@ module TurbotRunner
11
11
  SCHEMAS_PATH = File.expand_path('../../schema/schemas', __FILE__)
12
12
 
13
13
  def self.schema_path(data_type)
14
+ @schema_paths ||= Hash.new do |h, k|
15
+ h[k] = get_and_validate_schema_path(k)
16
+ end
17
+ @schema_paths[data_type]
18
+ end
19
+
20
+ def self.get_and_validate_schema_path(data_type)
14
21
  hyphenated_name = data_type.to_s.gsub("_", "-").gsub(" ", "-")
15
- File.join(SCHEMAS_PATH, "#{hyphenated_name}-schema.json")
22
+ path = File.join(SCHEMAS_PATH, "#{hyphenated_name}-schema.json")
23
+ raise TurbotRunner::InvalidDataType unless File.exists?(path)
24
+ path
16
25
  end
17
26
  end
@@ -1,3 +1,4 @@
1
1
  module TurbotRunner
2
2
  class InterruptRun < StandardError; end
3
+ class InvalidDataType < StandardError; end
3
4
  end
@@ -1,3 +1,3 @@
1
1
  module TurbotRunner
2
- VERSION = '0.1.31'
2
+ VERSION = '0.1.32'
3
3
  end
@@ -0,0 +1,8 @@
1
+ {
2
+ "bot_id": "bot-with-invalid-data-type",
3
+ "description": "This bot has an invalid data type",
4
+ "language": "ruby",
5
+ "data_type": "fishmonger licence",
6
+ "identifying_fields": ["licence_number"],
7
+ "files": ["scraper.rb"]
8
+ }
@@ -0,0 +1,10 @@
1
+ require 'json'
2
+
3
+ 0.upto(9) do |n|
4
+ record = {
5
+ :licence_number => "XYZ#{n}",
6
+ :source_url => 'http://example.com',
7
+ :sample_date => '2014-06-01'
8
+ }
9
+ puts(record.to_json)
10
+ end
@@ -226,6 +226,16 @@ describe TurbotRunner::Runner do
226
226
  expect(@runner.run).to be(false)
227
227
  end
228
228
  end
229
+
230
+ context 'with a bot with an invalid data type' do
231
+ before do
232
+ @runner = test_runner('bot-with-invalid-data-type')
233
+ end
234
+
235
+ it 'raises InvalidDataType' do
236
+ expect{@runner.run}.to raise_error(TurbotRunner::InvalidDataType)
237
+ end
238
+ end
229
239
  end
230
240
 
231
241
  describe '#process_output' do
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.31
4
+ version: 0.1.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenCorporates
@@ -86,6 +86,8 @@ files:
86
86
  - spec/bots/bot-that-expects-file/manifest.json
87
87
  - spec/bots/bot-that-expects-file/scraper.rb
88
88
  - spec/bots/bot-that-expects-file/something.txt
89
+ - spec/bots/bot-with-invalid-data-type/manifest.json
90
+ - spec/bots/bot-with-invalid-data-type/scraper.rb
89
91
  - spec/bots/bot-with-invalid-sample-date/manifest.json
90
92
  - spec/bots/bot-with-invalid-sample-date/scraper.rb
91
93
  - spec/bots/bot-with-pause/manifest.json