turbot-runner 0.1.14 → 0.1.15
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 +8 -8
- data/lib/turbot_runner/runner.rb +1 -0
- data/lib/turbot_runner/version.rb +1 -1
- data/spec/bots/bot-that-crashes-immediately/manifest.json +15 -0
- data/spec/bots/bot-that-crashes-immediately/scraper.rb +1 -0
- data/spec/bots/bot-that-crashes-immediately/transformer1.rb +15 -0
- data/spec/lib/runner_spec.rb +20 -9
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjY3ZDJkZjIzNTNiMDJkNzE0ODA2NWRmOWJjMzc4NmRmY2JiYjRiOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjEzNWNkNGRhODdjNjkyOWQyMmZmNjc3YjBmODVlZjBhNTg5ODUwOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTFjMWZhYjZjMWMwNTBlNTA3YWRmNmJmMzA4NGU4Mzk4YWFmYTYzYjc4ZWJh
|
10
|
+
NTZiMjU5YjE0NTY2ZmQ4ODQ5NWJhMmRlNWMzYTdkZDZhZDhjZjJlMjM4M2I4
|
11
|
+
OTcyNTg3Yjc5MzVmOTBlNWJlN2JiMWZlZTNmMDRkMDgwNGFhMDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjQ0M2Q5N2ZjY2RmNjcyYzEyMGQyNDAzOTlmOWNiNGM3MzIzYTVmYTU1OGI0
|
14
|
+
YjdlYTFhZTYxYmNmY2EwZTAwNjRlZjljMTBlMTNhODAxYTQ5ZDE3YmMwNTcx
|
15
|
+
MTJlZmRkODA0Y2ZjYmRkYzI1ZWNiZjQ0MmVjOWViMTg2Nzc4ZDU=
|
data/lib/turbot_runner/runner.rb
CHANGED
@@ -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
|
data/spec/lib/runner_spec.rb
CHANGED
@@ -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.
|
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-
|
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
|