turbot-runner 0.2.30 → 0.2.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/bin/bundle +105 -0
- data/bin/rspec +29 -0
- data/lib/turbot_runner.rb +1 -1
- data/lib/turbot_runner/runner.rb +5 -7
- data/lib/turbot_runner/version.rb +1 -1
- data/schema/schemas/accounts-statement-schema.json +48 -29
- data/schema/schemas/alternate-registration-schema.json +88 -0
- data/schema/schemas/alternative-name-schema.json +69 -0
- data/schema/schemas/company-schema.json +22 -6
- data/schema/schemas/control-statement-schema.json +46 -8
- data/schema/schemas/filing-schema.json +3 -4
- data/schema/schemas/financial-payment-schema.json +1 -1
- data/schema/schemas/gazette-notice-schema.json +337 -312
- data/schema/schemas/includes/{accounts_element.json → accounts-element.json} +1 -1
- data/schema/schemas/includes/address.json +2 -3
- data/schema/schemas/includes/{alternative_name.json → alternative-name.json} +1 -1
- data/schema/schemas/includes/base-statement.json +5 -2
- data/schema/schemas/includes/company-for-nesting.json +3 -3
- data/schema/schemas/includes/company.json +1 -1
- data/schema/schemas/includes/date.json +17 -4
- data/schema/schemas/includes/entity.json +2 -2
- data/schema/schemas/includes/{filing_document.json → filing-document.json} +12 -3
- data/schema/schemas/includes/filing.json +1 -1
- data/schema/schemas/includes/financial-payment-data-object.json +1 -1
- data/schema/schemas/includes/identifier.json +1 -1
- data/schema/schemas/includes/{industry_code.json → industry-code.json} +1 -1
- data/schema/schemas/includes/legislation.json +1 -1
- data/schema/schemas/includes/licence-data-object.json +1 -1
- data/schema/schemas/includes/officer.json +1 -1
- data/schema/schemas/includes/organisation.json +8 -5
- data/schema/schemas/includes/permission.json +1 -1
- data/schema/schemas/includes/{person_name.json → person-name.json} +1 -1
- data/schema/schemas/includes/person.json +9 -7
- data/schema/schemas/includes/{previous_name.json → previous-name.json} +1 -1
- data/schema/schemas/includes/range.json +1 -1
- data/schema/schemas/includes/sanction.json +5 -2
- data/schema/schemas/includes/share-parcel-data.json +1 -1
- data/schema/schemas/includes/share-parcel.json +17 -5
- data/schema/schemas/includes/subsidiary-relationship-data.json +1 -1
- data/schema/schemas/includes/total-shares.json +1 -1
- data/schema/schemas/includes/{unknown_entity_type.json → unknown-entity-type.json} +8 -5
- data/schema/schemas/licence-schema.json +1 -1
- data/schema/schemas/primary-data-schema.json +1 -1
- data/schema/schemas/register-entry-schema.json +4 -3
- data/schema/schemas/sanctioned-entity-schema.json +4 -5
- data/schema/schemas/share-parcel-schema.json +1 -1
- data/schema/schemas/simple-financial-payment-schema.json +1 -1
- data/schema/schemas/simple-licence-schema.json +1 -1
- data/schema/schemas/simple-subsidiary-schema.json +1 -1
- data/schema/schemas/subsequent-registration-schema.json +89 -0
- data/schema/schemas/subsidiary-relationship-schema.json +1 -1
- data/schema/schemas/supplier-relationship-schema.json +82 -0
- data/schema/schemas/trademark-registration-schema.json +3 -1
- data/spec/lib/runner_spec.rb +71 -39
- metadata +19 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c73a920e178c0ba176b17be1e10a480b4a663ca4
|
4
|
+
data.tar.gz: 9693383fe1630efcd66b820fa93b889774dd7788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec20be567c6dde2b967e10719998f782905497e895f72c9b59376dff039ccdd573fdac9ad500264e6b5e624c695e91ff323b3cfe3d26387709dfe93cb4e7a7be
|
7
|
+
data.tar.gz: 98ffaeac42ae44c7c2b2cb54deeb45d4902f093539744fcbdf8a688493a8b6b209dd9b00feff2e0d89ab267c19a0c6fc66cce35965ee320aa0ceb3d4c88b9f36
|
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.rb
CHANGED
@@ -20,7 +20,7 @@ module TurbotRunner
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.get_and_validate_schema_path(data_type)
|
23
|
-
hyphenated_name = data_type.to_s.gsub("
|
23
|
+
hyphenated_name = data_type.to_s.gsub(" ", "-")
|
24
24
|
path = File.join(SCHEMAS_PATH, "#{hyphenated_name}-schema.json")
|
25
25
|
raise TurbotRunner::InvalidDataType.new("Could not find #{path}") unless File.exists?(path)
|
26
26
|
path
|
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)
|
@@ -20,60 +20,88 @@
|
|
20
20
|
},
|
21
21
|
"accounts_type": {
|
22
22
|
"description": "The type of accounts – either annual, or quarterly, or null if not known",
|
23
|
-
"enum": [
|
23
|
+
"enum": [
|
24
|
+
"annual",
|
25
|
+
"quarterly",
|
26
|
+
null
|
27
|
+
]
|
24
28
|
},
|
25
29
|
"profit": {
|
26
30
|
"type": "array",
|
27
31
|
"items": {
|
28
|
-
"$ref": "includes/
|
32
|
+
"$ref": "includes/accounts-element.json"
|
29
33
|
}
|
30
34
|
},
|
31
35
|
"revenue": {
|
32
|
-
"type": [
|
36
|
+
"type": [
|
37
|
+
"array",
|
38
|
+
"null"
|
39
|
+
],
|
33
40
|
"items": {
|
34
|
-
"$ref": "includes/
|
41
|
+
"$ref": "includes/accounts-element.json"
|
35
42
|
}
|
36
43
|
},
|
37
44
|
"current_assets": {
|
38
|
-
"type": [
|
45
|
+
"type": [
|
46
|
+
"array",
|
47
|
+
"null"
|
48
|
+
],
|
39
49
|
"items": {
|
40
|
-
"$ref": "includes/
|
50
|
+
"$ref": "includes/accounts-element.json"
|
41
51
|
}
|
42
52
|
},
|
43
53
|
"total_assets": {
|
44
|
-
"type": [
|
54
|
+
"type": [
|
55
|
+
"array",
|
56
|
+
"null"
|
57
|
+
],
|
45
58
|
"items": {
|
46
|
-
"$ref": "includes/
|
59
|
+
"$ref": "includes/accounts-element.json"
|
47
60
|
}
|
48
61
|
},
|
49
62
|
"fixed_assets": {
|
50
|
-
"type": [
|
63
|
+
"type": [
|
64
|
+
"array",
|
65
|
+
"null"
|
66
|
+
],
|
51
67
|
"items": {
|
52
|
-
"$ref": "includes/
|
68
|
+
"$ref": "includes/accounts-element.json"
|
53
69
|
}
|
54
70
|
},
|
55
71
|
"current_liabilities": {
|
56
|
-
"type": [
|
72
|
+
"type": [
|
73
|
+
"array",
|
74
|
+
"null"
|
75
|
+
],
|
57
76
|
"items": {
|
58
|
-
"$ref": "includes/
|
77
|
+
"$ref": "includes/accounts-element.json"
|
59
78
|
}
|
60
79
|
},
|
61
80
|
"total_liabilities": {
|
62
|
-
"type": [
|
81
|
+
"type": [
|
82
|
+
"array",
|
83
|
+
"null"
|
84
|
+
],
|
63
85
|
"items": {
|
64
|
-
"$ref": "includes/
|
86
|
+
"$ref": "includes/accounts-element.json"
|
65
87
|
}
|
66
88
|
},
|
67
89
|
"cash_at_bank": {
|
68
|
-
"type": [
|
90
|
+
"type": [
|
91
|
+
"array",
|
92
|
+
"null"
|
93
|
+
],
|
69
94
|
"items": {
|
70
|
-
"$ref": "includes/
|
95
|
+
"$ref": "includes/accounts-element.json"
|
71
96
|
}
|
72
97
|
},
|
73
98
|
"documents": {
|
74
|
-
"type": [
|
99
|
+
"type": [
|
100
|
+
"array",
|
101
|
+
"null"
|
102
|
+
],
|
75
103
|
"items": {
|
76
|
-
"$ref": "includes/
|
104
|
+
"$ref": "includes/filing-document.json"
|
77
105
|
}
|
78
106
|
},
|
79
107
|
"filing_type_name": {
|
@@ -133,15 +161,6 @@
|
|
133
161
|
"type": "string",
|
134
162
|
"description": "If the accounts filing has been put on sources.opencorporates.com the path to the filing"
|
135
163
|
},
|
136
|
-
"confidence": {
|
137
|
-
"description": "Confidence in accuracy of data",
|
138
|
-
"type": "string",
|
139
|
-
"enum": [
|
140
|
-
"HIGH",
|
141
|
-
"MEDIUM",
|
142
|
-
"LOW"
|
143
|
-
]
|
144
|
-
},
|
145
164
|
"other_attributes": {
|
146
165
|
"description": "Use for other attributes for which we don't yet have curated schema attributes",
|
147
166
|
"type": "object"
|
@@ -155,5 +174,5 @@
|
|
155
174
|
"confidence",
|
156
175
|
"filing_date",
|
157
176
|
"accounts_type"
|
158
|
-
|
159
|
-
}
|
177
|
+
]
|
178
|
+
}
|
@@ -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
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"description": "Doing Business As, also known as fictitious name or trade name",
|
4
|
+
"type": "object",
|
5
|
+
"properties": {
|
6
|
+
"name": {
|
7
|
+
"description": "The name registered",
|
8
|
+
"type": "string"
|
9
|
+
},
|
10
|
+
"type": {
|
11
|
+
"description": "Type of alternative name",
|
12
|
+
"type": "string",
|
13
|
+
"enum": [
|
14
|
+
"Assumed Name",
|
15
|
+
"Trade Name",
|
16
|
+
"DBA / doing business as",
|
17
|
+
"Fictitious name"
|
18
|
+
]
|
19
|
+
},
|
20
|
+
"registered_address": {
|
21
|
+
"description": "The address filing was registered to",
|
22
|
+
"type": "object"
|
23
|
+
},
|
24
|
+
"start_date": {
|
25
|
+
"type": "string",
|
26
|
+
"format": "date"
|
27
|
+
},
|
28
|
+
"end_date": {
|
29
|
+
"type": "string",
|
30
|
+
"format": "date"
|
31
|
+
},
|
32
|
+
"source_url": {
|
33
|
+
"description": "Place where this fact can be verified",
|
34
|
+
"type": "string",
|
35
|
+
"minLength": 1
|
36
|
+
},
|
37
|
+
"confidence": {
|
38
|
+
"description": "Confidence in accuracy of data",
|
39
|
+
"type": "string",
|
40
|
+
"enum": [
|
41
|
+
"HIGH",
|
42
|
+
"MEDIUM",
|
43
|
+
"LOW"
|
44
|
+
]
|
45
|
+
},
|
46
|
+
"sample_date": {
|
47
|
+
"description": "Date on which we know this to be true (usually date this information was retrieved from the source)",
|
48
|
+
"type": "string",
|
49
|
+
"format": "date"
|
50
|
+
},
|
51
|
+
"retrieved_at": {
|
52
|
+
"description": "The time or date at which the source URL was requested",
|
53
|
+
"type": "string",
|
54
|
+
"format": "date"
|
55
|
+
},
|
56
|
+
"other_attributes": {
|
57
|
+
"description": "Dump of all other relevant data for which we don't yet have curated schema attributes",
|
58
|
+
"type": "object"
|
59
|
+
}
|
60
|
+
},
|
61
|
+
"required": [
|
62
|
+
"name",
|
63
|
+
"type",
|
64
|
+
"other_attributes",
|
65
|
+
"retrieved_at",
|
66
|
+
"sample_date",
|
67
|
+
"source_url"
|
68
|
+
]
|
69
|
+
}
|