turbot-runner 0.1.14 → 0.1.15

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
- YTc5YzFlYWVjYTE1NmIzODc1OThmOWM0ZTgxNTU2YWM3MjY4OTVmOQ==
4
+ YjY3ZDJkZjIzNTNiMDJkNzE0ODA2NWRmOWJjMzc4NmRmY2JiYjRiOQ==
5
5
  data.tar.gz: !binary |-
6
- OGI1MzhmMjZhMDU2MzJmNzc4MGMzZTI2ZmYwYmMyMmFkZGJhNjUyNw==
6
+ MjEzNWNkNGRhODdjNjkyOWQyMmZmNjc3YjBmODVlZjBhNTg5ODUwOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDM4OTVmYTY0ZTg4OTg2OTY0ZWMxOThlZDI0ODc1YzcyNmJjZTZhMWNmNGQx
10
- NzRkNWI3MzZmZDM0ODY4Nzc0NmVjNGY2NzU0YzM3ZDVmYjViZDI4ZmY2MzQ4
11
- YjJhOGMwYzE0OTg2ODM2YmNjMzc2NzU0NzE3NzBjMWEzNzRjMzU=
9
+ NTFjMWZhYjZjMWMwNTBlNTA3YWRmNmJmMzA4NGU4Mzk4YWFmYTYzYjc4ZWJh
10
+ NTZiMjU5YjE0NTY2ZmQ4ODQ5NWJhMmRlNWMzYTdkZDZhZDhjZjJlMjM4M2I4
11
+ OTcyNTg3Yjc5MzVmOTBlNWJlN2JiMWZlZTNmMDRkMDgwNGFhMDE=
12
12
  data.tar.gz: !binary |-
13
- MjhkNzgwYjdlMTBhYWY3M2U3ZWZkZGU5ZTYwNzg4N2U3OTQ2OGEzNmUwZmM4
14
- MDA0ZGNiOTQ3NGJjYjQxYWJkOWY0ZGNlMjQ5MzRkNzNmMDI4ZjkwODU3MTY1
15
- OGI1MzFlMTM0NzA4YjQ0ZmVhMDkyMTlhMzk5NzMxNTcxNGZmYzQ=
13
+ YjQ0M2Q5N2ZjY2RmNjcyYzEyMGQyNDAzOTlmOWNiNGM3MzIzYTVmYTU1OGI0
14
+ YjdlYTFhZTYxYmNmY2EwZTAwNjRlZjljMTBlMTNhODAxYTQ5ZDE3YmMwNTcx
15
+ MTJlZmRkODA0Y2ZjYmRkYzI1ZWNiZjQ0MmVjOWViMTg2Nzc4ZDU=
@@ -84,6 +84,7 @@ module TurbotRunner
84
84
  processor.process(line)
85
85
  end
86
86
  end
87
+ rescue Errno::ENOENT
87
88
  end
88
89
 
89
90
  def build_command(script, input_file=nil)
@@ -1,3 +1,3 @@
1
1
  module TurbotRunner
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.15'
3
3
  end
@@ -0,0 +1,15 @@
1
+ {
2
+ "bot_id": "bot-that-crashes-immediately",
3
+ "description": "This is a bot that crashes immediately",
4
+ "language": "ruby",
5
+ "data_type": "primary data",
6
+ "identifying_fields": ["licence_number"],
7
+ "files": ["scraper.rb", "transformer1.rb"],
8
+ "transformers": [
9
+ {
10
+ "file": "transformer1.rb",
11
+ "data_type": "simple-licence",
12
+ "identifying_fields": ["licence_number"]
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1 @@
1
+ raise 'Oh no'
@@ -0,0 +1,15 @@
1
+ require 'json'
2
+
3
+ STDIN.each_line do |line|
4
+ raw_record = JSON.parse(line)
5
+
6
+ transformed_record = {
7
+ :company_name => 'Foo Widgets',
8
+ :company_jurisdiction => 'gb',
9
+ :licence_number => raw_record['licence_number'],
10
+ :source_url => raw_record['source_url'],
11
+ :sample_date => raw_record['sample_date'],
12
+ }
13
+
14
+ puts transformed_record.to_json
15
+ end
@@ -219,11 +219,6 @@ describe TurbotRunner::Runner do
219
219
 
220
220
  describe '#process_output' do
221
221
  before do
222
- # This creates the output to work with
223
- TurbotRunner::Runner.new('spec/bots/bot-with-transformer').run
224
- end
225
-
226
- it 'calls handler once for each line of output' do
227
222
  class Handler < TurbotRunner::BaseHandler
228
223
  attr_reader :records_seen
229
224
 
@@ -237,15 +232,31 @@ describe TurbotRunner::Runner do
237
232
  end
238
233
  end
239
234
 
240
- handler = Handler.new
235
+ @handler = Handler.new
236
+ end
237
+
238
+ it 'calls handler once for each line of output' do
239
+ TurbotRunner::Runner.new('spec/bots/bot-with-transformer').run
240
+
241
+ runner = TurbotRunner::Runner.new(
242
+ 'spec/bots/bot-with-transformer',
243
+ :record_handler => @handler
244
+ )
245
+
246
+ runner.process_output
247
+ expect(@handler.records_seen['primary data']).to eq(10)
248
+ expect(@handler.records_seen['simple-licence']).to eq(10)
249
+ end
250
+
251
+ it 'can cope when scraper has failed immediately' do
252
+ TurbotRunner::Runner.new('spec/bots/bot-that-crashes-immediately').run
253
+
241
254
  runner = TurbotRunner::Runner.new(
242
255
  'spec/bots/bot-with-transformer',
243
- :record_handler => handler
256
+ :record_handler => @handler
244
257
  )
245
258
 
246
259
  runner.process_output
247
- expect(handler.records_seen['primary data']).to eq(10)
248
- expect(handler.records_seen['simple-licence']).to eq(10)
249
260
  end
250
261
  end
251
262
  end
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.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenCorporates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -61,6 +61,9 @@ files:
61
61
  - schema/schemas/simple-licence-schema.json
62
62
  - schema/schemas/simple-subsidiary-schema.json
63
63
  - schema/schemas/subsidiary-relationship-schema.json
64
+ - spec/bots/bot-that-crashes-immediately/manifest.json
65
+ - spec/bots/bot-that-crashes-immediately/scraper.rb
66
+ - spec/bots/bot-that-crashes-immediately/transformer1.rb
64
67
  - spec/bots/bot-that-crashes-in-scraper/manifest.json
65
68
  - spec/bots/bot-that-crashes-in-scraper/scraper.rb
66
69
  - spec/bots/bot-that-crashes-in-scraper/transformer1.rb