turbot-runner 0.0.15 → 0.0.16

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
- NjRiZjhhZGI4ZDI5ODc5NzliZTJkMmQzZDNmNWQyMDgwNGRkNDk2ZQ==
4
+ NjhhZjM2MGFkMTI5NGE3MjE3MDVmZjM3MDIwODczMDNlMGUwNzQ5Yg==
5
5
  data.tar.gz: !binary |-
6
- MjMxNDUzMGQ3NzIyMjJkMWE1ODg4OGJlM2YwMjBhNzU4NDY4MDAzMQ==
6
+ NjExYmExZjJmZDhhMGI2YjJmYWI1OTIzOWRlMTg0YzUxYTE3MjdhYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTMyM2E4NjBhMWJkNTE1NGY0NTlmNGQxOTUwNjBmYWIzNzc3MGZkODJkOTgx
10
- MGEzOGQ5YzEzZDFlNjFjNWJkNzZjYWE1N2RmMmE1YjdlYjM3YzQyNTAxMjgx
11
- MzM3ZGNkZmIxZmQwZjVhNGE1MjVlZjNhMThlY2QyMTY3YzgxNGE=
9
+ YzMyNjI0ZDdlZDcxMTI5MjgxN2ZhMjQyOTBmZjA1MjMwN2VjMGM0MmUzNjk2
10
+ MTU5ZDJjOTc0YzBlMzZjY2Y0MjZlYWM0Mzk2ZjFkYTZiNWQyMTM1MThlZmM5
11
+ ODI4MDMyMmU1NTRkYzVkMzkxZjEwYzI2ZTlkYTRhYWI1MDZiNTE=
12
12
  data.tar.gz: !binary |-
13
- YjRhMGU5OGU0MGUyYzEwZGI1OTcyMTdhMTc4MzlhOTExOTgxMWIyODYxNDFi
14
- NjRhYTc0NGJiMzIxNTRiMDQ1M2IzZmZlZTRkZmZjYTI5MWIwZmQ5MzU2OGMz
15
- Y2I1YjRkZTBiOGJjZjA5MzliZTMxMGI4ZmJlZDk1NGNmODMyNWI=
13
+ ZGU0OTk2MTNiMmFmZjU5ZTc0M2RhYjZkMTE5NTdiMzcxNzRlMDMzMWViOGIw
14
+ MTE5ZjkzZjVjOTA1YjcxNGJhNjljYTQxMGI4MWNkMDVkMzkyYTA4ODkzZTE2
15
+ YjVkYjNlNjJhOTY0MmU4MWMwOTUzNjcwZjc1N2UzOGE3MWQxYjQ=
data/lib/turbot_runner.rb CHANGED
@@ -240,8 +240,7 @@ module TurbotRunner
240
240
  end
241
241
 
242
242
  def close
243
- @stdin.close
244
- @stdout.close
243
+ @wait_thread.kill
245
244
  end
246
245
  end
247
246
  end
@@ -1,3 +1,3 @@
1
1
  module TurbotRunner
2
- VERSION = '0.0.15'
2
+ VERSION = '0.0.16'
3
3
  end
@@ -0,0 +1,15 @@
1
+ {
2
+ "bot_id": "dummy-bot",
3
+ "data_type": "hello",
4
+ "description": "This is a dummy bot",
5
+ "identifying_fields": ["number"],
6
+ "files": ["scraper.py"],
7
+ "transformers": [
8
+ {
9
+ "file": "transformer.py",
10
+ "data_type": "goodbye",
11
+ "identifying_fields": [""]
12
+ }
13
+ ],
14
+ "frequency": "monthly"
15
+ }
@@ -0,0 +1,6 @@
1
+ import json
2
+
3
+ print json.dumps({'n': 5, 'hello': 'hello, 5'})
4
+ print json.dumps({'n': 6, 'hello': 'hello, 6'})
5
+ print json.dumps({'n': 7})
6
+ print json.dumps({'n': 8, 'hello': 'hello, 8'})
@@ -0,0 +1,15 @@
1
+ import json
2
+ import sys
3
+
4
+ while True:
5
+ line = sys.stdin.readline()
6
+ if not line:
7
+ break
8
+
9
+ raw_record = json.loads(line)
10
+ transformed_record = {
11
+ 'n': raw_record['n'],
12
+ 'goodbye': raw_record['hello'].replace('hello', 'goodbye')
13
+ }
14
+
15
+ print json.dumps(transformed_record)
File without changes
File without changes
File without changes
@@ -1,20 +1,19 @@
1
1
  require 'json'
2
2
  require 'turbot_runner'
3
3
 
4
- describe TurbotRunner::BaseRunner do
5
- it 'can run a bot' do
6
-
7
- class SpecRunner < TurbotRunner::BaseRunner
8
- def validate(record, data_type)
9
- if record['n'] == 3
10
- [:error]
11
- else
12
- []
13
- end
14
- end
4
+ class SpecRunner < TurbotRunner::BaseRunner
5
+ def validate(record, data_type)
6
+ if record['n'] % 4 == 3
7
+ [:error]
8
+ else
9
+ []
15
10
  end
11
+ end
12
+ end
16
13
 
17
- runner = SpecRunner.new('spec/dummy-bot')
14
+ describe TurbotRunner::BaseRunner do
15
+ it 'can run a ruby bot' do
16
+ runner = SpecRunner.new('spec/dummy-bot-ruby')
18
17
 
19
18
  expect(runner).to receive(:handle_valid_record).with({'n' => 1, 'hello' => 'hello, 1'}, 'hello')
20
19
  expect(runner).to receive(:handle_valid_record).with({'n' => 1, 'goodbye' => 'goodbye, 1'}, 'goodbye')
@@ -26,4 +25,18 @@ describe TurbotRunner::BaseRunner do
26
25
  expect(runner).to receive(:handle_successful_run)
27
26
  runner.run
28
27
  end
28
+
29
+ it 'can run a python bot' do
30
+ runner = SpecRunner.new('spec/dummy-bot-python')
31
+
32
+ expect(runner).to receive(:handle_valid_record).with({'n' => 5, 'hello' => 'hello, 5'}, 'hello')
33
+ expect(runner).to receive(:handle_valid_record).with({'n' => 5, 'goodbye' => 'goodbye, 5'}, 'goodbye')
34
+ expect(runner).to receive(:handle_valid_record).with({'n' => 6, 'hello' => 'hello, 6'}, 'hello')
35
+ expect(runner).to receive(:handle_valid_record).with({'n' => 6, 'goodbye' => 'goodbye, 6'}, 'goodbye')
36
+ expect(runner).to receive(:handle_invalid_record).with({'n' => 7}, 'hello', [:error])
37
+ expect(runner).to receive(:handle_valid_record).with({'n' => 8, 'hello' => 'hello, 8'}, 'hello')
38
+ expect(runner).to receive(:handle_valid_record).with({'n' => 8, 'goodbye' => 'goodbye, 8'}, 'goodbye')
39
+ expect(runner).to receive(:handle_successful_run)
40
+ runner.run
41
+ end
29
42
  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.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenCorporates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -51,9 +51,12 @@ files:
51
51
  - schema/schemas/share-parcel-schema.json
52
52
  - schema/schemas/simple-licence-schema.json
53
53
  - schema/schemas/subsidiary-relationship-schema.json
54
- - spec/dummy-bot/manifest.json
55
- - spec/dummy-bot/scraper.rb
56
- - spec/dummy-bot/transformer.rb
54
+ - spec/dummy-bot-python/manifest.json
55
+ - spec/dummy-bot-python/scraper.py
56
+ - spec/dummy-bot-python/transformer.py
57
+ - spec/dummy-bot-ruby/manifest.json
58
+ - spec/dummy-bot-ruby/scraper.rb
59
+ - spec/dummy-bot-ruby/transformer.rb
57
60
  - spec/turbot_runner_spec.rb
58
61
  homepage: http://turbot.opencorporates.com/
59
62
  licenses: