Module: Hdo::StortingImporter
- Defined in:
- lib/hdo/storting_importer.rb,
lib/hdo/storting_importer/cli.rb,
lib/hdo/storting_importer/util.rb,
lib/hdo/storting_importer/vote.rb,
lib/hdo/storting_importer/party.rb,
lib/hdo/storting_importer/promise.rb,
lib/hdo/storting_importer/version.rb,
lib/hdo/storting_importer/category.rb,
lib/hdo/storting_importer/district.rb,
lib/hdo/storting_importer/committee.rb,
lib/hdo/storting_importer/data_source.rb,
lib/hdo/storting_importer/inspectable.rb,
lib/hdo/storting_importer/proposition.rb,
lib/hdo/storting_importer/ivar_equality.rb,
lib/hdo/storting_importer/representative.rb,
lib/hdo/storting_importer/api_data_source.rb,
lib/hdo/storting_importer/has_json_schema.rb,
lib/hdo/storting_importer/in_memory_cache.rb,
lib/hdo/storting_importer/disk_data_source.rb,
lib/hdo/storting_importer/parliament_issue.rb,
lib/hdo/storting_importer/party_membership.rb,
lib/hdo/storting_importer/parliament_period.rb,
lib/hdo/storting_importer/parliament_session.rb,
lib/hdo/storting_importer/caching_data_source.rb,
lib/hdo/storting_importer/parsing_data_source.rb,
lib/hdo/storting_importer/committee_membership.rb,
lib/hdo/storting_importer/parliament_issue_details.rb
Defined Under Namespace
Modules: HasJsonSchema, Inspectable, IvarEquality, Util
Classes: ApiDataSource, CLI, CachingDataSource, Category, Committee, CommitteeMembership, DataSource, DiskDataSource, District, Field, InMemoryCache, ParliamentIssue, ParliamentIssueDetails, ParliamentPeriod, ParliamentSession, ParsingDataSource, Party, PartyMembership, Promise, Proposition, Representative, ValidationError, Vote
Constant Summary
collapse
- EXTERNAL_ID_FIELD =
Field.new(:externalId, false, :string, 'An optional external id, matching potential id fields in the input data. This is useful if you want to reimport previous data without creating duplicates.')
- VERSION =
"0.5.8"
Class Method Summary
collapse
Class Method Details
.lib ⇒ Object
23
24
25
|
# File 'lib/hdo/storting_importer.rb', line 23
def self.lib
@lib ||= Pathname.new(File.expand_path("../..", __FILE__))
end
|
.logger ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/hdo/storting_importer.rb', line 89
def self.logger
@logger ||= (
out = $stdout
if defined?(Rails)
klass = Class.new(Logger) do
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
klass.new(out)
else
Logger.new(out)
end
)
end
|
.print_types(opts = {}) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/hdo/storting_importer.rb', line 46
def self.print_types(opts = {})
out = opts[:io] || $stdout
json = !!opts[:json]
max_name_size = 0
max_type_size = 0
type_strings = []
types.each do |type|
type.fields.each do |e|
required = 'required' if e.required
type_strings << (type_string = "#{required}:#{e.type}")
max_name_size = [e.name.size, max_name_size].max
max_type_size = [type_string.size, max_type_size].max
end
end
types.each_with_index do |type, type_idx|
out.puts "\x1b[1m#{type.kind}\x1b[0m\n"
type.fields.each_with_index do |field, field_idx|
parts = [
field.name.to_s.rjust(max_name_size + 5),
type_strings[type_idx + field_idx].rjust(max_type_size),
"\t#{field.description}"
]
out.puts parts.join ' '
end
out.puts "\n\n"
if json
puts type.json_example.split("\n")
puts "\n\n"
end
end
end
|
.root ⇒ Object
19
20
21
|
# File 'lib/hdo/storting_importer.rb', line 19
def self.root
@root ||= Pathname.new(File.expand_path("../../..", __FILE__))
end
|
.types ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/hdo/storting_importer.rb', line 27
def self.types
[
Category,
Committee,
CommitteeMembership,
District,
ParliamentIssue,
ParliamentIssueDetails,
ParliamentSession,
ParliamentPeriod,
Party,
PartyMembership,
Promise,
Proposition,
Representative,
Vote,
]
end
|