turbot-runner 0.2.16 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +1 -0
- data/appveyor.yml +36 -0
- data/lib/turbot_runner/runner.rb +4 -4
- data/lib/turbot_runner/script_runner.rb +1 -1
- data/lib/turbot_runner/validator.rb +1 -1
- data/lib/turbot_runner/version.rb +1 -1
- data/schema/schemas/gazette-notice-schema.json +7 -0
- data/schema/schemas/includes/classification.json +12 -3
- data/spec/lib/runner_spec.rb +7 -48
- data/spec/{manual_spec.rb → manual.rb} +0 -0
- data/spec/spec_helper.rb +10 -22
- data/spec/support/custom_matchers.rb +73 -0
- data/spec/support/helpers.rb +6 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e85fb58506f16103a8e9a785220a673a4254354
|
4
|
+
data.tar.gz: 84664025f5f4f43fad8e23aa3151a4846370affa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bab922c04adfdd99e6ccafa102e4141db907a2105072f7e2f9ee2720f5693ec0e1708fb9cf6ca09087332d1bb0c7e34272e87c192ff981d0074bb0f42134eef6
|
7
|
+
data.tar.gz: 50f73d518937b38821ae6d5fa386886e03d6b898e8d1042f8a65bcb2e0aa0f1b480509bc9079b49cfd61f688f082c9a89698b08203f9ab15b1951a14fb01e328
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/turbot-runner.svg)](https://badge.fury.io/rb/turbot-runner)
|
4
4
|
[![Build Status](https://secure.travis-ci.org/openc/turbot-runner.png)](https://travis-ci.org/openc/turbot-runner)
|
5
|
+
[![Build Status](https://ci.appveyor.com/api/projects/status/8wvd4ygxhk6wj94s?svg=true)](https://ci.appveyor.com/project/jpmckinney/turbot-runner)
|
5
6
|
[![Dependency Status](https://gemnasium.com/openc/turbot-runner.png)](https://gemnasium.com/openc/turbot-runner)
|
6
7
|
[![Coverage Status](https://coveralls.io/repos/openc/turbot-runner/badge.png)](https://coveralls.io/r/openc/turbot-runner)
|
7
8
|
[![Code Climate](https://codeclimate.com/github/openc/turbot-runner.png)](https://codeclimate.com/github/openc/turbot-runner)
|
data/appveyor.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# @see https://mattbrictson.com/how-to-test-ruby-windows
|
2
|
+
# @see https://github.com/apiaryio/apiary-client/blob/master/appveyor.yml
|
3
|
+
version: '{build}'
|
4
|
+
skip_tags: true
|
5
|
+
install:
|
6
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
7
|
+
- ruby --version
|
8
|
+
- gem --version
|
9
|
+
- gem install bundler --no-ri --no-rdoc
|
10
|
+
- bundler --version
|
11
|
+
- git submodule update --init --recursive
|
12
|
+
build_script:
|
13
|
+
- bundle install --jobs=3 --retry=3
|
14
|
+
test_script:
|
15
|
+
- bundle exec rspec -b < Nul
|
16
|
+
artifacts:
|
17
|
+
- path: pkg\*.gem
|
18
|
+
environment:
|
19
|
+
matrix:
|
20
|
+
- ruby_version: "193"
|
21
|
+
- ruby_version: "200"
|
22
|
+
- ruby_version: "200-x64"
|
23
|
+
- ruby_version: "21"
|
24
|
+
- ruby_version: "21-x64"
|
25
|
+
- ruby_version: "22"
|
26
|
+
- ruby_version: "22-x64"
|
27
|
+
# @see https://www.appveyor.com/docs/build-cache
|
28
|
+
cache:
|
29
|
+
- C:\Ruby193\bin -> appveyor.yml
|
30
|
+
- C:\Ruby193\lib\ruby\gems\1.9.1 -> appveyor.yml
|
31
|
+
- C:\Ruby200\bin -> appveyor.yml
|
32
|
+
- C:\Ruby200\lib\ruby\gems\2.0.0 -> appveyor.yml
|
33
|
+
- C:\Ruby21\bin -> appveyor.yml
|
34
|
+
- C:\Ruby21\lib\ruby\gems\2.1.0 -> appveyor.yml
|
35
|
+
- C:\Ruby22\bin -> appveyor.yml
|
36
|
+
- C:\Ruby22\lib\ruby\gems\2.2.0 -> appveyor.yml
|
data/lib/turbot_runner/runner.rb
CHANGED
@@ -38,10 +38,10 @@ module TurbotRunner
|
|
38
38
|
# Run the transformers even if the scraper fails
|
39
39
|
transformers_succeeded = true
|
40
40
|
transformers.each do |transformer_config|
|
41
|
-
config = transformer_config.merge(
|
41
|
+
config = transformer_config.merge({
|
42
42
|
:base_directory => @base_directory,
|
43
|
-
:duplicates_allowed => duplicates_allowed
|
44
|
-
)
|
43
|
+
:duplicates_allowed => duplicates_allowed,
|
44
|
+
})
|
45
45
|
transformers_succeeded = run_script(config, input_file=scraper_output_file) && transformers_succeeded
|
46
46
|
end
|
47
47
|
|
@@ -166,7 +166,7 @@ module TurbotRunner
|
|
166
166
|
:file => scraper_script,
|
167
167
|
:data_type => scraper_data_type,
|
168
168
|
:identifying_fields => scraper_identifying_fields,
|
169
|
-
:duplicates_allowed => duplicates_allowed
|
169
|
+
:duplicates_allowed => duplicates_allowed,
|
170
170
|
}
|
171
171
|
end
|
172
172
|
|
@@ -12,7 +12,7 @@ module TurbotRunner
|
|
12
12
|
@script_config = script_config
|
13
13
|
record_handler = options[:record_handler] || BaseHandler.new # A BaseHandler does nothing
|
14
14
|
@processor = Processor.new(self, script_config, record_handler)
|
15
|
-
@timeout = options[:timeout] ||
|
15
|
+
@timeout = options[:timeout] || 86_400
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
@@ -31,6 +31,13 @@
|
|
31
31
|
"$ref": "includes/entity.json"
|
32
32
|
}
|
33
33
|
},
|
34
|
+
"related_entities": {
|
35
|
+
"description": "Other entities that the notice is about",
|
36
|
+
"type": "array",
|
37
|
+
"items": {
|
38
|
+
"$ref": "includes/entity.json"
|
39
|
+
}
|
40
|
+
},
|
34
41
|
"about": {
|
35
42
|
"description": "The content of the notice",
|
36
43
|
"type": "object",
|
data/spec/lib/runner_spec.rb
CHANGED
@@ -2,6 +2,11 @@ require 'json'
|
|
2
2
|
require 'turbot_runner'
|
3
3
|
|
4
4
|
describe TurbotRunner::Runner do
|
5
|
+
after(:all) do
|
6
|
+
puts
|
7
|
+
puts 'If all specs passed, you should now run `ruby spec/manual.rb`'
|
8
|
+
end
|
9
|
+
|
5
10
|
describe '#run' do
|
6
11
|
context 'with a bot written in ruby' do
|
7
12
|
before do
|
@@ -74,7 +79,7 @@ describe TurbotRunner::Runner do
|
|
74
79
|
|
75
80
|
context 'when logging to file not enabled' do
|
76
81
|
xit 'logs to stderr' do
|
77
|
-
# This is tested in
|
82
|
+
# This is tested in manual.rb
|
78
83
|
end
|
79
84
|
end
|
80
85
|
end
|
@@ -161,7 +166,7 @@ describe TurbotRunner::Runner do
|
|
161
166
|
|
162
167
|
context 'with a bot that is interrupted in scraper' do
|
163
168
|
xit 'produces truncated output' do
|
164
|
-
# This is tested in
|
169
|
+
# This is tested in manual.rb
|
165
170
|
end
|
166
171
|
end
|
167
172
|
|
@@ -357,49 +362,3 @@ describe TurbotRunner::Runner do
|
|
357
362
|
end
|
358
363
|
end
|
359
364
|
end
|
360
|
-
|
361
|
-
|
362
|
-
RSpec::Matchers.define(:have_output) do |script, expected|
|
363
|
-
match do |runner|
|
364
|
-
expected_path = File.join('spec', 'outputs', expected)
|
365
|
-
expected_output = File.readlines(expected_path).map {|line| JSON.parse(line)}
|
366
|
-
actual_path = File.join(runner.base_directory, 'output', "#{script}.out")
|
367
|
-
actual_output = File.readlines(actual_path).map {|line| JSON.parse(line)}
|
368
|
-
expect(expected_output).to eq(actual_output)
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
|
373
|
-
RSpec::Matchers.define(:have_error_output_matching) do |script, expected|
|
374
|
-
match do |runner|
|
375
|
-
actual_path = File.join(runner.base_directory, 'output', "#{script}.err")
|
376
|
-
actual_output = File.read(actual_path)
|
377
|
-
expect(actual_output).to match(expected)
|
378
|
-
end
|
379
|
-
end
|
380
|
-
|
381
|
-
|
382
|
-
RSpec::Matchers.define(:succeed) do
|
383
|
-
match do |runner|
|
384
|
-
expect(runner.run).to eq(TurbotRunner::Runner::RC_OK)
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
|
389
|
-
RSpec::Matchers.define(:fail_in_scraper) do
|
390
|
-
match do |runner|
|
391
|
-
expect(runner.run).to eq(TurbotRunner::Runner::RC_SCRAPER_FAILED)
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
|
396
|
-
RSpec::Matchers.define(:fail_in_transformer) do
|
397
|
-
match do |runner|
|
398
|
-
expect(runner.run).to eq(TurbotRunner::Runner::RC_TRANSFORMER_FAILED)
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
def test_runner(name, opts={})
|
403
|
-
test_bot_location = File.join(File.dirname(__FILE__), '../bots', name)
|
404
|
-
TurbotRunner::Runner.new(test_bot_location, opts)
|
405
|
-
end
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -1,31 +1,19 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
|
4
|
-
require '
|
5
|
-
|
6
|
-
SimpleCov.
|
7
|
-
|
3
|
+
unless RUBY_PLATFORM =~ /mswin32|mingw32/
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter 'spec'
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
require 'rspec'
|
11
13
|
|
14
|
+
Dir['./spec/support/**/*.rb'].sort.each { |f| require f}
|
12
15
|
require File.dirname(__FILE__) + '/../lib/turbot_runner'
|
13
16
|
|
14
|
-
RSpec
|
15
|
-
|
16
|
-
identifying_fields = ['number']
|
17
|
-
@error = TurbotRunner::Validator.validate('primary-data', record, identifying_fields, Set.new)
|
18
|
-
expect(@error).to eq(expected_error)
|
19
|
-
end
|
20
|
-
|
21
|
-
failure_message do |actual|
|
22
|
-
"Expected error to be #{expected_error}, but was #{@error}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
RSpec::Matchers.define(:be_valid) do
|
27
|
-
match do |record|
|
28
|
-
identifying_fields = ['number']
|
29
|
-
expect(TurbotRunner::Validator.validate('primary-data', record, identifying_fields, Set.new)).to eq(nil)
|
30
|
-
end
|
17
|
+
RSpec.configure do |c|
|
18
|
+
c.include(Helpers)
|
31
19
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
RSpec::Matchers.define(:fail_validation_with) do |expected_error|
|
2
|
+
match do |record|
|
3
|
+
identifying_fields = ['number']
|
4
|
+
@error = TurbotRunner::Validator.validate('primary-data', record, identifying_fields, Set.new)
|
5
|
+
expect(@error).to eq(expected_error)
|
6
|
+
end
|
7
|
+
|
8
|
+
failure_message do |actual|
|
9
|
+
"Expected error to be #{expected_error}, but was #{@error}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
RSpec::Matchers.define(:be_valid) do
|
14
|
+
match do |record|
|
15
|
+
identifying_fields = ['number']
|
16
|
+
expect(TurbotRunner::Validator.validate('primary-data', record, identifying_fields, Set.new)).to eq(nil)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec::Matchers.define(:have_output) do |script, expected|
|
21
|
+
match do |runner|
|
22
|
+
expected_path = File.join('spec', 'outputs', expected)
|
23
|
+
@expected_output = File.readlines(expected_path).map {|line| JSON.parse(line)}
|
24
|
+
actual_path = File.join(runner.base_directory, 'output', "#{script}.out")
|
25
|
+
@actual_output = File.readlines(actual_path).map {|line| JSON.parse(line)}
|
26
|
+
expect(@expected_output).to eq(@actual_output)
|
27
|
+
end
|
28
|
+
|
29
|
+
failure_message do |actual|
|
30
|
+
"Expected output to be #{@expected_output}, but was #{@actual_output}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Matchers.define(:have_error_output_matching) do |script, expected|
|
35
|
+
match do |runner|
|
36
|
+
actual_path = File.join(runner.base_directory, 'output', "#{script}.err")
|
37
|
+
actual_output = File.read(actual_path)
|
38
|
+
expect(actual_output).to match(expected)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
RSpec::Matchers.define(:succeed) do
|
43
|
+
match do |runner|
|
44
|
+
@actual_run = runner.run
|
45
|
+
expect(@actual_run).to eq(TurbotRunner::Runner::RC_OK)
|
46
|
+
end
|
47
|
+
|
48
|
+
failure_message do |actual|
|
49
|
+
"Expected output to be TurbotRunner::Runner::RC_OK, but was #{@actual_run}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
RSpec::Matchers.define(:fail_in_scraper) do
|
54
|
+
match do |runner|
|
55
|
+
@actual_run = runner.run
|
56
|
+
expect(@actual_run).to eq(TurbotRunner::Runner::RC_SCRAPER_FAILED)
|
57
|
+
end
|
58
|
+
|
59
|
+
failure_message do |actual|
|
60
|
+
"Expected output to be TurbotRunner::Runner::RC_SCRAPER_FAILED, but was #{@actual_run}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
RSpec::Matchers.define(:fail_in_transformer) do
|
65
|
+
match do |runner|
|
66
|
+
@actual_run = runner.run
|
67
|
+
expect(@actual_run).to eq(TurbotRunner::Runner::RC_TRANSFORMER_FAILED)
|
68
|
+
end
|
69
|
+
|
70
|
+
failure_message do |actual|
|
71
|
+
"Expected output to be TurbotRunner::Runner::RC_TRANSFORMER_FAILED, but was #{@actual_run}"
|
72
|
+
end
|
73
|
+
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.2.
|
4
|
+
version: 0.2.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenCorporates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- Gemfile
|
94
94
|
- README.md
|
95
95
|
- Rakefile
|
96
|
+
- appveyor.yml
|
96
97
|
- lib/turbot_runner.rb
|
97
98
|
- lib/turbot_runner/base_handler.rb
|
98
99
|
- lib/turbot_runner/exceptions.rb
|
@@ -190,11 +191,13 @@ files:
|
|
190
191
|
- spec/lib/runner_spec.rb
|
191
192
|
- spec/lib/utils_spec.rb
|
192
193
|
- spec/lib/validator_spec.rb
|
193
|
-
- spec/
|
194
|
+
- spec/manual.rb
|
194
195
|
- spec/outputs/full-scraper.out
|
195
196
|
- spec/outputs/full-transformer.out
|
196
197
|
- spec/outputs/truncated-scraper.out
|
197
198
|
- spec/spec_helper.rb
|
199
|
+
- spec/support/custom_matchers.rb
|
200
|
+
- spec/support/helpers.rb
|
198
201
|
- turbot-runner.gemspec
|
199
202
|
homepage: http://turbot.opencorporates.com/
|
200
203
|
licenses:
|
@@ -271,9 +274,11 @@ test_files:
|
|
271
274
|
- spec/lib/runner_spec.rb
|
272
275
|
- spec/lib/utils_spec.rb
|
273
276
|
- spec/lib/validator_spec.rb
|
274
|
-
- spec/
|
277
|
+
- spec/manual.rb
|
275
278
|
- spec/outputs/full-scraper.out
|
276
279
|
- spec/outputs/full-transformer.out
|
277
280
|
- spec/outputs/truncated-scraper.out
|
278
281
|
- spec/spec_helper.rb
|
282
|
+
- spec/support/custom_matchers.rb
|
283
|
+
- spec/support/helpers.rb
|
279
284
|
has_rdoc:
|