hdo-storting-importer 0.0.1 → 0.0.2
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.
- data/Gemfile +1 -6
- data/README.md +4 -5
- data/features/convert.feature +189 -0
- data/hdo-storting-importer.gemspec +6 -0
- data/lib/hdo/storting_importer/category.rb +57 -0
- data/lib/hdo/storting_importer/cli.rb +76 -97
- data/lib/hdo/storting_importer/committee.rb +20 -0
- data/lib/hdo/storting_importer/district.rb +20 -0
- data/lib/hdo/storting_importer/issue.rb +51 -0
- data/lib/hdo/storting_importer/party.rb +20 -0
- data/lib/hdo/storting_importer/promise.rb +56 -1
- data/lib/hdo/storting_importer/promise_converter.rb +1 -20
- data/lib/hdo/storting_importer/representative.rb +47 -0
- data/lib/hdo/storting_importer/version.rb +1 -1
- data/lib/hdo/storting_importer/vote.rb +73 -0
- data/lib/hdo/storting_importer.rb +3 -1
- data/spec/hdo/storting_importer/category_spec.rb +25 -1
- data/spec/hdo/storting_importer/committee_spec.rb +22 -1
- data/spec/hdo/storting_importer/district_spec.rb +22 -1
- data/spec/hdo/storting_importer/issue_spec.rb +24 -18
- data/spec/hdo/storting_importer/party_spec.rb +21 -1
- data/spec/hdo/storting_importer/promise_spec.rb +56 -0
- data/spec/hdo/storting_importer/representative_spec.rb +24 -7
- data/spec/hdo/storting_importer/vote_spec.rb +41 -29
- metadata +85 -8
- data/features/import.feature +0 -85
- data/features/step_definitions/import_steps.rb +0 -0
- data/lib/hdo/storting_importer/script_importer.rb +0 -20
@@ -5,18 +5,6 @@ module Hdo
|
|
5
5
|
module StortingImporter
|
6
6
|
describe Vote do
|
7
7
|
|
8
|
-
def create_vote
|
9
|
-
vote = Vote.new('2175', '51448', true, false, 'Forslag 24 - 26 på vegne av Per Olaf Lundteigen', 'ikke_spesifisert', 'ikke_spesifisert', '2012-04-12T16:37:27.053', 2, 96, 71)
|
10
|
-
|
11
|
-
rep = Representative.new('PTA', 'Per-Willy', 'Amundsen', 'M', '1971-01-21T00:00:00', '0001-01-01T00:00:00', 'Troms', 'Fremskrittspartiet', [], '2011-2012')
|
12
|
-
rep.vote_result = 'against'
|
13
|
-
|
14
|
-
vote.propositions << Vote::Proposition.new('1234', 'description', 'on behalf of', 'body', rep)
|
15
|
-
vote.representatives << rep
|
16
|
-
|
17
|
-
vote
|
18
|
-
end
|
19
|
-
|
20
8
|
it "builds votes from the Storting XML list" do
|
21
9
|
xml = <<-XML
|
22
10
|
<?xml version="1.0" encoding="utf-8"?>
|
@@ -85,7 +73,7 @@ module Hdo
|
|
85
73
|
end
|
86
74
|
|
87
75
|
it 'can serialize as HDO XML' do
|
88
|
-
vote =
|
76
|
+
vote = Vote.example
|
89
77
|
vote.to_hdo_xml.should == <<-XML
|
90
78
|
<vote>
|
91
79
|
<externalId>2175</externalId>
|
@@ -103,18 +91,19 @@ module Hdo
|
|
103
91
|
<time>2012-04-12T16:37:27.053</time>
|
104
92
|
<representatives>
|
105
93
|
<representative>
|
106
|
-
<externalId>
|
107
|
-
<firstName>
|
108
|
-
<lastName>
|
94
|
+
<externalId>ADA</externalId>
|
95
|
+
<firstName>André Oktay</firstName>
|
96
|
+
<lastName>Dahl</lastName>
|
109
97
|
<gender>M</gender>
|
110
|
-
<dateOfBirth>
|
98
|
+
<dateOfBirth>1975-07-07T00:00:00</dateOfBirth>
|
111
99
|
<dateOfDeath>0001-01-01T00:00:00</dateOfDeath>
|
112
|
-
<district>
|
113
|
-
<party>
|
100
|
+
<district>Akershus</district>
|
101
|
+
<party>Høyre</party>
|
114
102
|
<committees>
|
103
|
+
<committee>Justiskomiteen</committee>
|
115
104
|
</committees>
|
116
105
|
<period>2011-2012</period>
|
117
|
-
<voteResult>
|
106
|
+
<voteResult>for</voteResult>
|
118
107
|
</representative>
|
119
108
|
</representatives>
|
120
109
|
<propositions>
|
@@ -125,18 +114,18 @@ module Hdo
|
|
125
114
|
<body>body</body>
|
126
115
|
<deliveredBy>
|
127
116
|
<representative>
|
128
|
-
<externalId>
|
129
|
-
<firstName>
|
130
|
-
<lastName>
|
117
|
+
<externalId>ADA</externalId>
|
118
|
+
<firstName>André Oktay</firstName>
|
119
|
+
<lastName>Dahl</lastName>
|
131
120
|
<gender>M</gender>
|
132
|
-
<dateOfBirth>
|
121
|
+
<dateOfBirth>1975-07-07T00:00:00</dateOfBirth>
|
133
122
|
<dateOfDeath>0001-01-01T00:00:00</dateOfDeath>
|
134
|
-
<district>
|
135
|
-
<party>
|
123
|
+
<district>Akershus</district>
|
124
|
+
<party>Høyre</party>
|
136
125
|
<committees>
|
126
|
+
<committee>Justiskomiteen</committee>
|
137
127
|
</committees>
|
138
128
|
<period>2011-2012</period>
|
139
|
-
<voteResult>against</voteResult>
|
140
129
|
</representative>
|
141
130
|
</deliveredBy>
|
142
131
|
</proposition>
|
@@ -145,11 +134,34 @@ module Hdo
|
|
145
134
|
XML
|
146
135
|
end
|
147
136
|
|
148
|
-
it 'can deserialize HDO XML' do
|
149
|
-
orig =
|
137
|
+
it 'can deserialize a HDO XML node' do
|
138
|
+
orig = Vote.example
|
150
139
|
Vote.from_hdo_node(parse(orig.to_hdo_xml)).should == orig
|
151
140
|
end
|
152
141
|
|
142
|
+
it 'can deserialize a HDO XML doc' do
|
143
|
+
orig = Vote.example
|
144
|
+
Vote.from_hdo_doc(parse("<votes>#{orig.to_hdo_xml}</votes>")).should == [orig]
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'has a type name' do
|
148
|
+
Vote.type_name.should == 'vote'
|
149
|
+
Vote::Proposition.type_name.should == 'proposition'
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'has a description' do
|
153
|
+
Vote.description.should be_kind_of(String)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'has an XML example' do
|
157
|
+
Vote.xml_example.should be_kind_of(String)
|
158
|
+
Vote::Proposition.xml_example.should be_kind_of(String)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'has a list of fields' do
|
162
|
+
Vote.fields.should_not be_empty
|
163
|
+
end
|
164
|
+
|
153
165
|
end
|
154
166
|
end
|
155
167
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hdo-storting-importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,88 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-07-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: builder
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: nokogiri
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: aruba
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rest-client
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
14
94
|
description: Gem to process data from data.stortinget.no
|
15
95
|
email:
|
16
96
|
- jari.bakken@gmail.com
|
@@ -27,8 +107,7 @@ files:
|
|
27
107
|
- README.md
|
28
108
|
- Rakefile
|
29
109
|
- bin/hdo-converter
|
30
|
-
- features/
|
31
|
-
- features/step_definitions/import_steps.rb
|
110
|
+
- features/convert.feature
|
32
111
|
- features/support/env.rb
|
33
112
|
- hdo-storting-importer.gemspec
|
34
113
|
- lib/hdo/storting_importer.rb
|
@@ -48,7 +127,6 @@ files:
|
|
48
127
|
- lib/hdo/storting_importer/promise.rb
|
49
128
|
- lib/hdo/storting_importer/promise_converter.rb
|
50
129
|
- lib/hdo/storting_importer/representative.rb
|
51
|
-
- lib/hdo/storting_importer/script_importer.rb
|
52
130
|
- lib/hdo/storting_importer/util.rb
|
53
131
|
- lib/hdo/storting_importer/version.rb
|
54
132
|
- lib/hdo/storting_importer/vote.rb
|
@@ -108,8 +186,7 @@ signing_key:
|
|
108
186
|
specification_version: 3
|
109
187
|
summary: Gem to process data from data.stortinget.no
|
110
188
|
test_files:
|
111
|
-
- features/
|
112
|
-
- features/step_definitions/import_steps.rb
|
189
|
+
- features/convert.feature
|
113
190
|
- features/support/env.rb
|
114
191
|
- spec/fixtures/input/categories.xml
|
115
192
|
- spec/fixtures/input/committees.xml
|
data/features/import.feature
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
Feature: Import data
|
2
|
-
Scenario: Import districts
|
3
|
-
When I run `hdo-converter --only-print districts`
|
4
|
-
Then the stdout should contain:
|
5
|
-
"""
|
6
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
7
|
-
<districts>
|
8
|
-
<district>
|
9
|
-
<externalId>Ak</externalId>
|
10
|
-
<name>Akershus</name>
|
11
|
-
</district>
|
12
|
-
<district>
|
13
|
-
<externalId>AA</externalId>
|
14
|
-
<name>Aust-Agder</name>
|
15
|
-
</district>
|
16
|
-
<district>
|
17
|
-
<externalId>Bu</externalId>
|
18
|
-
<name>Buskerud</name>
|
19
|
-
</district>
|
20
|
-
<district>
|
21
|
-
<externalId>Fi</externalId>
|
22
|
-
<name>Finnmark</name>
|
23
|
-
</district>
|
24
|
-
<district>
|
25
|
-
<externalId>He</externalId>
|
26
|
-
<name>Hedmark</name>
|
27
|
-
</district>
|
28
|
-
<district>
|
29
|
-
<externalId>Ho</externalId>
|
30
|
-
<name>Hordaland</name>
|
31
|
-
</district>
|
32
|
-
<district>
|
33
|
-
<externalId>MR</externalId>
|
34
|
-
<name>Møre og Romsdal</name>
|
35
|
-
</district>
|
36
|
-
<district>
|
37
|
-
<externalId>NT</externalId>
|
38
|
-
<name>Nord-Trøndelag</name>
|
39
|
-
</district>
|
40
|
-
<district>
|
41
|
-
<externalId>No</externalId>
|
42
|
-
<name>Nordland</name>
|
43
|
-
</district>
|
44
|
-
<district>
|
45
|
-
<externalId>Op</externalId>
|
46
|
-
<name>Oppland</name>
|
47
|
-
</district>
|
48
|
-
<district>
|
49
|
-
<externalId>Os</externalId>
|
50
|
-
<name>Oslo</name>
|
51
|
-
</district>
|
52
|
-
<district>
|
53
|
-
<externalId>Ro</externalId>
|
54
|
-
<name>Rogaland</name>
|
55
|
-
</district>
|
56
|
-
<district>
|
57
|
-
<externalId>SF</externalId>
|
58
|
-
<name>Sogn og Fjordane</name>
|
59
|
-
</district>
|
60
|
-
<district>
|
61
|
-
<externalId>ST</externalId>
|
62
|
-
<name>Sør-Trøndelag</name>
|
63
|
-
</district>
|
64
|
-
<district>
|
65
|
-
<externalId>Te</externalId>
|
66
|
-
<name>Telemark</name>
|
67
|
-
</district>
|
68
|
-
<district>
|
69
|
-
<externalId>Tr</externalId>
|
70
|
-
<name>Troms</name>
|
71
|
-
</district>
|
72
|
-
<district>
|
73
|
-
<externalId>VA</externalId>
|
74
|
-
<name>Vest-Agder</name>
|
75
|
-
</district>
|
76
|
-
<district>
|
77
|
-
<externalId>Ve</externalId>
|
78
|
-
<name>Vestfold</name>
|
79
|
-
</district>
|
80
|
-
<district>
|
81
|
-
<externalId>Øs</externalId>
|
82
|
-
<name>Østfold</name>
|
83
|
-
</district>
|
84
|
-
</districts>
|
85
|
-
"""
|
File without changes
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Hdo
|
2
|
-
module StortingImporter
|
3
|
-
class ScriptImporter
|
4
|
-
|
5
|
-
def initialize(app_root)
|
6
|
-
@app_root = app_root
|
7
|
-
end
|
8
|
-
|
9
|
-
def import(xml)
|
10
|
-
Tempfile.open("storting2hdo") do |f|
|
11
|
-
f << xml
|
12
|
-
f.close
|
13
|
-
|
14
|
-
Dir.chdir(@app_root) { system "script/import", f.path }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|