turbot-runner 0.2.32 → 0.2.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -3
- data/bin/bundle +105 -0
- data/bin/rspec +29 -0
- data/lib/turbot_runner/runner.rb +5 -7
- data/lib/turbot_runner/version.rb +1 -1
- data/schema/schemas/alternate-registration-schema.json +88 -0
- data/schema/schemas/company-schema.json +14 -1
- data/schema/schemas/control-statement-schema.json +14 -0
- data/schema/schemas/subsequent-registration-schema.json +89 -0
- data/schema/schemas/supplier-relationship-schema.json +82 -0
- data/spec/lib/runner_spec.rb +71 -39
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: da8abedec4c778f73ad6ef717804a4a73349bdcbead7e9ac5be3e07fa8d5a7fa
|
4
|
+
data.tar.gz: 6f848dbec7fd83e678a99f7083ea9e9eb7009ac2962be7fc14bc87bb5f3a7cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4815ac1f507e4c55349b8639bc854ec5e8eb6d1ac8efe5285fd7b439afab6bda4745e5760d165aa695cc91bb8ab31529fc8e3d59d2ab3a32a589ad52d5ee7e72
|
7
|
+
data.tar.gz: 8cb243bbfd0699a29ca20ee802a0e4184a23e45b95b0e4d0e147523aba1cc426bd4dff591e6dc4997ddcd6818445f7b9b7d4d6ea60b9db71c6797c775ec6a840
|
data/.travis.yml
CHANGED
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/lib/turbot_runner/runner.rb
CHANGED
@@ -124,15 +124,13 @@ module TurbotRunner
|
|
124
124
|
# record handling.
|
125
125
|
processor = Processor.new(nil, script_config, @record_handler)
|
126
126
|
file = output_file(script_config[:file])
|
127
|
-
File.
|
128
|
-
|
129
|
-
|
127
|
+
if File.exist?(file)
|
128
|
+
File.open(file) do |f|
|
129
|
+
f.each_line do |line|
|
130
|
+
processor.process(line, opts)
|
131
|
+
end
|
130
132
|
end
|
131
133
|
end
|
132
|
-
rescue Errno::ENOENT => e
|
133
|
-
# We only want to catch ENOENT if the output file doesn't exist, and not
|
134
|
-
# if, for instance, a schema file is missing.
|
135
|
-
raise unless e.message == "No such file or directory - #{output_file(script_config[:file])}"
|
136
134
|
end
|
137
135
|
|
138
136
|
def build_command(script, input_file=nil)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"description": "A representation of multiple registrations for the same entity",
|
4
|
+
"type": "object",
|
5
|
+
"properties": {
|
6
|
+
"data_type": {
|
7
|
+
"enum": [
|
8
|
+
"alternate-registration"
|
9
|
+
]
|
10
|
+
},
|
11
|
+
"alternate_entities": {
|
12
|
+
"description": "array of entities that are linked via alternate registrations",
|
13
|
+
"type": "array",
|
14
|
+
"items": {
|
15
|
+
"$ref": "includes/entity.json",
|
16
|
+
"minLength": 2
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"alternate_registration_start_date": {
|
20
|
+
"description": "date when alternate registration started",
|
21
|
+
"type": "string",
|
22
|
+
"format": "date"
|
23
|
+
},
|
24
|
+
"alternate_registration_end_date": {
|
25
|
+
"description": "date when alternate registration ended",
|
26
|
+
"type": "string",
|
27
|
+
"format": "date"
|
28
|
+
},
|
29
|
+
"publication_date": {
|
30
|
+
"description": "the publication date of the filing/notice that gives details of the alternate registration",
|
31
|
+
"type": "string",
|
32
|
+
"format": "date"
|
33
|
+
},
|
34
|
+
"start_date": {
|
35
|
+
"description": "date when alternate registration was valid from",
|
36
|
+
"type": "string",
|
37
|
+
"format": "date"
|
38
|
+
},
|
39
|
+
"start_date_type": {
|
40
|
+
"enum": [
|
41
|
+
"at",
|
42
|
+
"before",
|
43
|
+
"after"
|
44
|
+
]
|
45
|
+
},
|
46
|
+
"sample_date": {
|
47
|
+
"description": "date when alternate registration was sampled",
|
48
|
+
"type": "string",
|
49
|
+
"format": "date"
|
50
|
+
},
|
51
|
+
"retrieved_at": {
|
52
|
+
"description": "date when alternate registration was retrieved",
|
53
|
+
"type": "string",
|
54
|
+
"format": "date"
|
55
|
+
},
|
56
|
+
"source_url": {
|
57
|
+
"description": "URL of the source of the data (e.g. download URL), or if there is not persistent URL the page from which it can be found (e.g. search page)",
|
58
|
+
"type": "string"
|
59
|
+
},
|
60
|
+
"confidence": {
|
61
|
+
"description": "Confidence in accuracy of data",
|
62
|
+
"enum": [
|
63
|
+
"HIGH",
|
64
|
+
"MEDIUM",
|
65
|
+
"LOW"
|
66
|
+
]
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"additionalProperties": false,
|
70
|
+
"required": [
|
71
|
+
"data_type",
|
72
|
+
"alternate_entities",
|
73
|
+
"retrieved_at",
|
74
|
+
"confidence"
|
75
|
+
],
|
76
|
+
"anyOf": [
|
77
|
+
{
|
78
|
+
"required": [
|
79
|
+
"start_date"
|
80
|
+
]
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"required": [
|
84
|
+
"sample_date"
|
85
|
+
]
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
@@ -132,6 +132,18 @@
|
|
132
132
|
"$ref": "includes/alternative-name.json"
|
133
133
|
}
|
134
134
|
},
|
135
|
+
"subsequent_registrations": {
|
136
|
+
"type": "array",
|
137
|
+
"items": {
|
138
|
+
"$ref": "subsequent-registration-schema.json"
|
139
|
+
}
|
140
|
+
},
|
141
|
+
"alternate_registrations": {
|
142
|
+
"type": "array",
|
143
|
+
"items": {
|
144
|
+
"$ref": "alternate-registration-schema.json"
|
145
|
+
}
|
146
|
+
},
|
135
147
|
"branch": {
|
136
148
|
"type": [
|
137
149
|
"string",
|
@@ -258,6 +270,7 @@
|
|
258
270
|
"required": [
|
259
271
|
"company_number",
|
260
272
|
"name",
|
261
|
-
"jurisdiction_code"
|
273
|
+
"jurisdiction_code",
|
274
|
+
"retrieved_at"
|
262
275
|
]
|
263
276
|
}
|
@@ -76,11 +76,25 @@
|
|
76
76
|
"type": "string",
|
77
77
|
"format": "date"
|
78
78
|
},
|
79
|
+
"start_date_type": {
|
80
|
+
"enum": [
|
81
|
+
"at",
|
82
|
+
"before",
|
83
|
+
"after"
|
84
|
+
]
|
85
|
+
},
|
79
86
|
"end_date": {
|
80
87
|
"description": "Date on which control ended",
|
81
88
|
"type": "string",
|
82
89
|
"format": "date"
|
83
90
|
},
|
91
|
+
"end_date_type": {
|
92
|
+
"enum": [
|
93
|
+
"at",
|
94
|
+
"before",
|
95
|
+
"after"
|
96
|
+
]
|
97
|
+
},
|
84
98
|
"retrieved_at": {
|
85
99
|
"description": "Date-time this was retrieved from the source",
|
86
100
|
"type": "string",
|
@@ -0,0 +1,89 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"description": "A representation of entity registration changing over time",
|
4
|
+
"type": "object",
|
5
|
+
"properties": {
|
6
|
+
"data_type": {
|
7
|
+
"enum": [
|
8
|
+
"subsequent-registration"
|
9
|
+
]
|
10
|
+
},
|
11
|
+
"previous_entity": {
|
12
|
+
"description": "the previous entity",
|
13
|
+
"$ref": "includes/entity.json"
|
14
|
+
},
|
15
|
+
"subsequent_entity": {
|
16
|
+
"description": "the subsequent entity",
|
17
|
+
"$ref": "includes/entity.json"
|
18
|
+
},
|
19
|
+
"subsequent_registration_start_date": {
|
20
|
+
"description": "date when subsequent registration started",
|
21
|
+
"type": "string",
|
22
|
+
"format": "date"
|
23
|
+
},
|
24
|
+
"previous_registration_end_date": {
|
25
|
+
"description": "date when previous registration ended",
|
26
|
+
"type": "string",
|
27
|
+
"format": "date"
|
28
|
+
},
|
29
|
+
"publication_date": {
|
30
|
+
"description": "the publication date of the filing/notice that gives details of the alternate registration",
|
31
|
+
"type": "string",
|
32
|
+
"format": "date"
|
33
|
+
},
|
34
|
+
"start_date": {
|
35
|
+
"description": "date when subsequent registration was valid from",
|
36
|
+
"type": "string",
|
37
|
+
"format": "date"
|
38
|
+
},
|
39
|
+
"start_date_type": {
|
40
|
+
"enum": [
|
41
|
+
"at",
|
42
|
+
"before",
|
43
|
+
"after"
|
44
|
+
]
|
45
|
+
},
|
46
|
+
"sample_date": {
|
47
|
+
"description": "date when subsequent registration was sampled",
|
48
|
+
"type": "string",
|
49
|
+
"format": "date"
|
50
|
+
},
|
51
|
+
"retrieved_at": {
|
52
|
+
"description": "date when subsequent registration was retrieved",
|
53
|
+
"type": "string",
|
54
|
+
"format": "date"
|
55
|
+
},
|
56
|
+
"source_url": {
|
57
|
+
"description": "URL of the source of the data (e.g. download URL), or if there is not persistent URL the page from which it can be found (e.g. search page)",
|
58
|
+
"type": "string"
|
59
|
+
},
|
60
|
+
"confidence": {
|
61
|
+
"description": "Confidence in accuracy of data",
|
62
|
+
"enum": [
|
63
|
+
"HIGH",
|
64
|
+
"MEDIUM",
|
65
|
+
"LOW"
|
66
|
+
]
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"additionalProperties": false,
|
70
|
+
"required": [
|
71
|
+
"data_type",
|
72
|
+
"previous_entity",
|
73
|
+
"subsequent_entity",
|
74
|
+
"retrieved_at",
|
75
|
+
"confidence"
|
76
|
+
],
|
77
|
+
"anyOf": [
|
78
|
+
{
|
79
|
+
"required": [
|
80
|
+
"start_date"
|
81
|
+
]
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"required": [
|
85
|
+
"sample_date"
|
86
|
+
]
|
87
|
+
}
|
88
|
+
]
|
89
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"type": "object",
|
4
|
+
"properties": {
|
5
|
+
"data_type": {
|
6
|
+
"enum": [
|
7
|
+
"supplier-relationship"
|
8
|
+
]
|
9
|
+
},
|
10
|
+
"customer": {
|
11
|
+
"$ref": "includes/entity.json"
|
12
|
+
},
|
13
|
+
"supplier": {
|
14
|
+
"$ref": "includes/entity.json"
|
15
|
+
},
|
16
|
+
"start_date": {
|
17
|
+
"type": "string",
|
18
|
+
"format": "date"
|
19
|
+
},
|
20
|
+
"start_date_type": {
|
21
|
+
"enum": [
|
22
|
+
"at",
|
23
|
+
"before",
|
24
|
+
"after"
|
25
|
+
]
|
26
|
+
},
|
27
|
+
"end_date": {
|
28
|
+
"type": "string",
|
29
|
+
"format": "date"
|
30
|
+
},
|
31
|
+
"end_date_type": {
|
32
|
+
"enum": [
|
33
|
+
"at",
|
34
|
+
"before",
|
35
|
+
"after"
|
36
|
+
]
|
37
|
+
},
|
38
|
+
"sample_date": {
|
39
|
+
"type": "string",
|
40
|
+
"format": "date"
|
41
|
+
},
|
42
|
+
"retrieved_at": {
|
43
|
+
"type": "string",
|
44
|
+
"format": "date"
|
45
|
+
},
|
46
|
+
"source_url": {
|
47
|
+
"type": "string"
|
48
|
+
},
|
49
|
+
"confidence": {
|
50
|
+
"enum": [
|
51
|
+
"HIGH",
|
52
|
+
"MEDIUM",
|
53
|
+
"LOW"
|
54
|
+
]
|
55
|
+
}
|
56
|
+
},
|
57
|
+
"additionalProperties": false,
|
58
|
+
"required": [
|
59
|
+
"data_type",
|
60
|
+
"supplier",
|
61
|
+
"customer",
|
62
|
+
"retrieved_at",
|
63
|
+
"confidence"
|
64
|
+
],
|
65
|
+
"anyOf": [
|
66
|
+
{
|
67
|
+
"required": [
|
68
|
+
"start_date"
|
69
|
+
]
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"required": [
|
73
|
+
"sample_date"
|
74
|
+
]
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"required": [
|
78
|
+
"end_date"
|
79
|
+
]
|
80
|
+
}
|
81
|
+
]
|
82
|
+
}
|
data/spec/lib/runner_spec.rb
CHANGED
@@ -7,6 +7,10 @@ describe TurbotRunner::Runner do
|
|
7
7
|
puts 'If all specs passed, you should now run `ruby spec/manual.rb`'
|
8
8
|
end
|
9
9
|
|
10
|
+
after do
|
11
|
+
FileUtils.rm_rf(File.join(@runner.base_directory, "output")) if @runner
|
12
|
+
end
|
13
|
+
|
10
14
|
describe '#run' do
|
11
15
|
context 'with a bot written in ruby' do
|
12
16
|
before do
|
@@ -69,11 +73,14 @@ describe TurbotRunner::Runner do
|
|
69
73
|
|
70
74
|
context 'with a bot that logs' do
|
71
75
|
context 'when logging to file enabled' do
|
76
|
+
before do
|
77
|
+
@runner = test_runner('logging-bot', :log_to_file => true)
|
78
|
+
end
|
79
|
+
|
72
80
|
it 'logs to file' do
|
73
81
|
expected_log = "doing...\ndone\n"
|
74
|
-
runner
|
75
|
-
runner.
|
76
|
-
expect(runner).to have_error_output_matching('scraper', expected_log)
|
82
|
+
@runner.run
|
83
|
+
expect(@runner).to have_error_output_matching('scraper', expected_log)
|
77
84
|
end
|
78
85
|
end
|
79
86
|
|
@@ -201,15 +208,21 @@ describe TurbotRunner::Runner do
|
|
201
208
|
end
|
202
209
|
|
203
210
|
context 'with a scraper that produces an invalid record' do
|
204
|
-
|
211
|
+
before do
|
205
212
|
@runner = test_runner('invalid-record-bot')
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'returns false' do
|
206
216
|
expect(@runner).to fail_in_scraper
|
207
217
|
end
|
208
218
|
end
|
209
219
|
|
210
220
|
context 'with a scraper that produces invalid JSON' do
|
211
|
-
|
221
|
+
before do
|
212
222
|
@runner = test_runner('invalid-json-bot')
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'returns false' do
|
213
226
|
expect(@runner).to fail_in_scraper
|
214
227
|
end
|
215
228
|
end
|
@@ -220,11 +233,14 @@ describe TurbotRunner::Runner do
|
|
220
233
|
# output file is created; however, the way we're redirecting
|
221
234
|
# stdout using the shell means the file doesn't get created
|
222
235
|
# until
|
223
|
-
|
236
|
+
before do
|
224
237
|
@runner = test_runner('bot-with-pause',
|
225
238
|
:timeout => 1,
|
226
239
|
:log_to_file => true
|
227
240
|
)
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'returns false' do
|
228
244
|
expect(@runner).to fail_in_scraper
|
229
245
|
end
|
230
246
|
end
|
@@ -315,51 +331,67 @@ describe TurbotRunner::Runner do
|
|
315
331
|
@handler = Handler.new
|
316
332
|
end
|
317
333
|
|
318
|
-
|
319
|
-
|
334
|
+
context 'with a bot that runs correctly' do
|
335
|
+
before do
|
336
|
+
@runner = test_runner('bot-with-transformer')
|
337
|
+
@runner.run
|
338
|
+
end
|
320
339
|
|
321
|
-
|
322
|
-
|
323
|
-
|
340
|
+
it 'calls handler once for each line of output' do
|
341
|
+
runner = test_runner('bot-with-transformer',
|
342
|
+
:record_handler => @handler
|
343
|
+
)
|
324
344
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
345
|
+
runner.process_output
|
346
|
+
expect(@handler.records_seen['primary data']).to eq(10)
|
347
|
+
expect(@handler.records_seen['simple-licence']).to eq(10)
|
348
|
+
end
|
329
349
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
350
|
+
it 'passes opts to processor.process' do
|
351
|
+
runner = test_runner('bot-with-transformer',
|
352
|
+
:record_handler => @handler
|
353
|
+
)
|
354
|
+
opts = {frob: 5}
|
355
|
+
processor = double('processor')
|
356
|
+
allow(TurbotRunner::Processor).to receive(:new).and_return(processor)
|
357
|
+
expect(processor).to receive(:process).with(anything, opts).at_least(:once)
|
358
|
+
runner.process_output(opts)
|
359
|
+
end
|
360
|
+
|
361
|
+
context 'when skip_data_types is set' do
|
362
|
+
it 'skips the data type' do
|
363
|
+
runner = test_runner('bot-with-transformer',
|
364
|
+
:record_handler => @handler
|
365
|
+
)
|
366
|
+
|
367
|
+
runner.process_output(skip_data_types: ['primary data'])
|
368
|
+
expect(@handler.records_seen['primary data']).to eq(0)
|
369
|
+
expect(@handler.records_seen['simple-licence']).to eq(10)
|
370
|
+
end
|
371
|
+
end
|
340
372
|
end
|
341
373
|
|
342
|
-
|
343
|
-
|
374
|
+
context 'with a bot that crashes immediately' do
|
375
|
+
before do
|
376
|
+
@runner = test_runner('bot-that-crashes-immediately')
|
377
|
+
@runner.run
|
378
|
+
end
|
344
379
|
|
345
|
-
|
346
|
-
|
347
|
-
|
380
|
+
it 'can cope with the empty files' do
|
381
|
+
runner = test_runner('bot-that-crashes-immediately',
|
382
|
+
:record_handler => @handler
|
383
|
+
)
|
348
384
|
|
349
|
-
|
385
|
+
runner.process_output
|
386
|
+
end
|
350
387
|
end
|
351
388
|
|
352
|
-
context 'when
|
353
|
-
it '
|
354
|
-
test_runner('bot-with-transformer').run
|
355
|
-
|
389
|
+
context 'when no bot has run' do
|
390
|
+
it 'proceeds without errors' do
|
356
391
|
runner = test_runner('bot-with-transformer',
|
357
392
|
:record_handler => @handler
|
358
393
|
)
|
359
|
-
|
360
|
-
runner.process_output(skip_data_types: ['primary data'])
|
361
|
-
expect(@handler.records_seen['primary data']).to eq(0)
|
362
|
-
expect(@handler.records_seen['simple-licence']).to eq(10)
|
394
|
+
runner.process_output
|
363
395
|
end
|
364
396
|
end
|
365
397
|
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.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenCorporates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -68,7 +68,9 @@ dependencies:
|
|
68
68
|
version: 3.4.0
|
69
69
|
description:
|
70
70
|
email: bots@opencorporates.com
|
71
|
-
executables:
|
71
|
+
executables:
|
72
|
+
- bundle
|
73
|
+
- rspec
|
72
74
|
extensions: []
|
73
75
|
extra_rdoc_files: []
|
74
76
|
files:
|
@@ -81,6 +83,8 @@ files:
|
|
81
83
|
- README.md
|
82
84
|
- Rakefile
|
83
85
|
- appveyor.yml
|
86
|
+
- bin/bundle
|
87
|
+
- bin/rspec
|
84
88
|
- lib/turbot_runner.rb
|
85
89
|
- lib/turbot_runner/base_handler.rb
|
86
90
|
- lib/turbot_runner/exceptions.rb
|
@@ -92,6 +96,7 @@ files:
|
|
92
96
|
- lib/turbot_runner/validator.rb
|
93
97
|
- lib/turbot_runner/version.rb
|
94
98
|
- schema/schemas/accounts-statement-schema.json
|
99
|
+
- schema/schemas/alternate-registration-schema.json
|
95
100
|
- schema/schemas/company-schema.json
|
96
101
|
- schema/schemas/control-statement-schema.json
|
97
102
|
- schema/schemas/filing-schema.json
|
@@ -135,7 +140,9 @@ files:
|
|
135
140
|
- schema/schemas/simple-financial-payment-schema.json
|
136
141
|
- schema/schemas/simple-licence-schema.json
|
137
142
|
- schema/schemas/simple-subsidiary-schema.json
|
143
|
+
- schema/schemas/subsequent-registration-schema.json
|
138
144
|
- schema/schemas/subsidiary-relationship-schema.json
|
145
|
+
- schema/schemas/supplier-relationship-schema.json
|
139
146
|
- schema/schemas/trademark-registration-schema.json
|
140
147
|
- spec/bots/bot-that-crashes-immediately/manifest.json
|
141
148
|
- spec/bots/bot-that-crashes-immediately/scraper.rb
|
@@ -215,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
222
|
version: '0'
|
216
223
|
requirements: []
|
217
224
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.
|
225
|
+
rubygems_version: 2.7.6
|
219
226
|
signing_key:
|
220
227
|
specification_version: 4
|
221
228
|
summary: Utilities for running bots with Turbot
|