hdo-storting-importer 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Rakefile +0 -1
- data/features/convert.feature +97 -79
- data/hdo-storting-importer.gemspec +5 -0
- data/lib/hdo/storting_importer/category.rb +16 -56
- data/lib/hdo/storting_importer/cli.rb +6 -34
- data/lib/hdo/storting_importer/committee.rb +13 -24
- data/lib/hdo/storting_importer/converter.rb +4 -9
- data/lib/hdo/storting_importer/district.rb +12 -24
- data/lib/hdo/storting_importer/fusion_table.rb +52 -0
- data/lib/hdo/storting_importer/has_json_schema.rb +85 -0
- data/lib/hdo/storting_importer/issue.rb +29 -60
- data/lib/hdo/storting_importer/party.rb +13 -24
- data/lib/hdo/storting_importer/promise.rb +60 -55
- data/lib/hdo/storting_importer/proposition.rb +61 -0
- data/lib/hdo/storting_importer/representative.rb +37 -70
- data/lib/hdo/storting_importer/schema/category.json +28 -0
- data/lib/hdo/storting_importer/schema/committee.json +21 -0
- data/lib/hdo/storting_importer/schema/district.json +21 -0
- data/lib/hdo/storting_importer/schema/issue.json +62 -0
- data/lib/hdo/storting_importer/schema/party.json +21 -0
- data/lib/hdo/storting_importer/schema/promise.json +42 -0
- data/lib/hdo/storting_importer/schema/proposition.json +34 -0
- data/lib/hdo/storting_importer/schema/representative.json +61 -0
- data/lib/hdo/storting_importer/schema/vote.json +64 -0
- data/lib/hdo/storting_importer/schema.json +5 -0
- data/lib/hdo/storting_importer/util.rb +13 -11
- data/lib/hdo/storting_importer/version.rb +1 -1
- data/lib/hdo/storting_importer/vote.rb +46 -143
- data/lib/hdo/storting_importer.rb +12 -3
- data/spec/fixtures/output/categories.json +1 -0
- data/spec/fixtures/output/committees.json +1 -0
- data/spec/fixtures/output/districts.json +1 -0
- data/spec/fixtures/output/issues.json +1 -0
- data/spec/fixtures/output/parties.json +1 -0
- data/spec/fixtures/output/representatives.json +1 -0
- data/spec/fixtures/output/votes.json +1 -0
- data/spec/hdo/storting_importer/category_spec.rb +29 -33
- data/spec/hdo/storting_importer/committee_spec.rb +29 -16
- data/spec/hdo/storting_importer/converter_spec.rb +3 -3
- data/spec/hdo/storting_importer/district_spec.rb +27 -18
- data/spec/hdo/storting_importer/issue_spec.rb +44 -27
- data/spec/hdo/storting_importer/party_spec.rb +25 -16
- data/spec/hdo/storting_importer/promise_spec.rb +54 -40
- data/spec/hdo/storting_importer/proposition_spec.rb +44 -0
- data/spec/hdo/storting_importer/representative_spec.rb +73 -26
- data/spec/hdo/storting_importer/vote_spec.rb +73 -75
- data/spec/spec_helper.rb +21 -1
- metadata +95 -3
- data/.gitmodules +0 -3
@@ -72,90 +72,92 @@ module Hdo
|
|
72
72
|
vote.counts.absent.should == 71
|
73
73
|
end
|
74
74
|
|
75
|
-
it 'can serialize as
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
</propositions>
|
133
|
-
</vote>
|
134
|
-
XML
|
75
|
+
it 'can serialize as JSON' do
|
76
|
+
Vote.example.to_json.should be_json <<-JSON
|
77
|
+
{
|
78
|
+
"kind": "hdo#vote",
|
79
|
+
"externalId": "2175",
|
80
|
+
"externalIssueId": "51448",
|
81
|
+
"counts": {
|
82
|
+
"for": 2,
|
83
|
+
"against": 96,
|
84
|
+
"absent": 71
|
85
|
+
},
|
86
|
+
"personal": true,
|
87
|
+
"enacted": false,
|
88
|
+
"subject": "Forslag 24 - 26 på vegne av Per Olaf Lundteigen",
|
89
|
+
"method": "ikke_spesifisert",
|
90
|
+
"resultType": "ikke_spesifisert",
|
91
|
+
"time": "2012-04-12T16:37:27.053",
|
92
|
+
"representatives": [
|
93
|
+
{
|
94
|
+
"kind": "hdo#representative",
|
95
|
+
"externalId": "ADA",
|
96
|
+
"firstName": "André Oktay",
|
97
|
+
"lastName": "Dahl",
|
98
|
+
"gender": "M",
|
99
|
+
"dateOfBirth": "1975-07-07T00:00:00",
|
100
|
+
"dateOfDeath": "0001-01-01T00:00:00",
|
101
|
+
"district": "Akershus",
|
102
|
+
"party": "Høyre",
|
103
|
+
"committees": ["Justiskomiteen"],
|
104
|
+
"period": "2011-2012",
|
105
|
+
"voteResult": "for"
|
106
|
+
}
|
107
|
+
],
|
108
|
+
"propositions": [
|
109
|
+
{
|
110
|
+
"kind": "hdo#proposition",
|
111
|
+
"externalId": "1234",
|
112
|
+
"description": "description",
|
113
|
+
"onBehalfOf": "on behalf of",
|
114
|
+
"body": "body",
|
115
|
+
"deliveredBy": {
|
116
|
+
"kind": "hdo#representative",
|
117
|
+
"externalId": "ADA",
|
118
|
+
"firstName": "André Oktay",
|
119
|
+
"lastName": "Dahl",
|
120
|
+
"gender": "M",
|
121
|
+
"dateOfBirth": "1975-07-07T00:00:00",
|
122
|
+
"dateOfDeath": "0001-01-01T00:00:00",
|
123
|
+
"district": "Akershus",
|
124
|
+
"party": "Høyre",
|
125
|
+
"committees": ["Justiskomiteen"],
|
126
|
+
"period": "2011-2012"
|
127
|
+
}
|
128
|
+
}
|
129
|
+
]
|
130
|
+
}
|
131
|
+
JSON
|
135
132
|
end
|
136
133
|
|
137
|
-
it 'can deserialize
|
134
|
+
it 'can deserialize JSON' do
|
138
135
|
orig = Vote.example
|
139
|
-
Vote.
|
136
|
+
Vote.from_json(orig.to_json).should == orig
|
140
137
|
end
|
141
138
|
|
142
|
-
it 'can deserialize a
|
143
|
-
orig = Vote.example
|
144
|
-
Vote.
|
139
|
+
it 'can deserialize a JSON array' do
|
140
|
+
orig = [Vote.example]
|
141
|
+
Vote.from_json(orig.to_json).should == orig
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'fails if the given JSON is invalid' do
|
145
|
+
json = Vote.example.to_hash
|
146
|
+
json.delete :personal
|
147
|
+
|
148
|
+
expect { Vote.from_json(json.to_json) }.to raise_error(ValidationError)
|
145
149
|
end
|
146
150
|
|
147
|
-
it 'has a
|
148
|
-
Vote.
|
149
|
-
Vote::Proposition.type_name.should == 'proposition'
|
151
|
+
it 'has a kind' do
|
152
|
+
Vote.kind.should == 'hdo#vote'
|
150
153
|
end
|
151
154
|
|
152
155
|
it 'has a description' do
|
153
156
|
Vote.description.should be_kind_of(String)
|
154
157
|
end
|
155
158
|
|
156
|
-
it 'has
|
157
|
-
Vote.
|
158
|
-
Vote::Proposition.xml_example.should be_kind_of(String)
|
159
|
+
it 'has a JSON example' do
|
160
|
+
Vote.json_example.should be_kind_of(String)
|
159
161
|
end
|
160
162
|
|
161
163
|
it 'has a list of fields' do
|
@@ -164,10 +166,6 @@ module Hdo
|
|
164
166
|
|
165
167
|
it 'has #short_inspect' do
|
166
168
|
Vote.example.short_inspect.should be_kind_of(String)
|
167
|
-
|
168
|
-
str = Vote::Proposition.example.short_inspect
|
169
|
-
str.should be_kind_of(String)
|
170
|
-
str.should_not include("nil")
|
171
169
|
end
|
172
170
|
|
173
171
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'hdo/storting_importer'
|
3
|
+
require 'pry'
|
3
4
|
require 'pp'
|
4
5
|
|
5
6
|
module Hdo
|
@@ -12,7 +13,7 @@ module Hdo
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def output_fixture(name)
|
15
|
-
FIXTURES.join(output_path("#{name}.
|
16
|
+
FIXTURES.join(output_path("#{name}.json")).read
|
16
17
|
end
|
17
18
|
|
18
19
|
def input_path(filename)
|
@@ -30,6 +31,25 @@ module Hdo
|
|
30
31
|
doc
|
31
32
|
end
|
32
33
|
|
34
|
+
class EqualsJson
|
35
|
+
def initialize(expected)
|
36
|
+
@expected = MultiJson.decode(expected)
|
37
|
+
end
|
38
|
+
def matches?(target)
|
39
|
+
@target = MultiJson.decode(target)
|
40
|
+
@target.eql?(@expected)
|
41
|
+
end
|
42
|
+
def failure_message
|
43
|
+
"expected #{@target.inspect} to be #{@expected}"
|
44
|
+
end
|
45
|
+
def negative_failure_message
|
46
|
+
"expected #{@target.inspect} not to be #{@expected}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def be_json(expected)
|
51
|
+
EqualsJson.new(expected)
|
52
|
+
end
|
33
53
|
end
|
34
54
|
end
|
35
55
|
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.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -123,6 +123,70 @@ dependencies:
|
|
123
123
|
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: yajl-ruby
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: jschematic
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.1.0
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 0.1.0
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: pry
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: rspec
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
126
190
|
description: Gem to process data from data.stortinget.no
|
127
191
|
email:
|
128
192
|
- jari.bakken@gmail.com
|
@@ -132,7 +196,6 @@ extensions: []
|
|
132
196
|
extra_rdoc_files: []
|
133
197
|
files:
|
134
198
|
- .gitignore
|
135
|
-
- .gitmodules
|
136
199
|
- .travis.yml
|
137
200
|
- Gemfile
|
138
201
|
- LICENSE
|
@@ -152,13 +215,26 @@ files:
|
|
152
215
|
- lib/hdo/storting_importer/data_source.rb
|
153
216
|
- lib/hdo/storting_importer/disk_data_source.rb
|
154
217
|
- lib/hdo/storting_importer/district.rb
|
218
|
+
- lib/hdo/storting_importer/fusion_table.rb
|
219
|
+
- lib/hdo/storting_importer/has_json_schema.rb
|
155
220
|
- lib/hdo/storting_importer/inspectable.rb
|
156
221
|
- lib/hdo/storting_importer/issue.rb
|
157
222
|
- lib/hdo/storting_importer/ivar_equality.rb
|
158
223
|
- lib/hdo/storting_importer/parsing_data_source.rb
|
159
224
|
- lib/hdo/storting_importer/party.rb
|
160
225
|
- lib/hdo/storting_importer/promise.rb
|
226
|
+
- lib/hdo/storting_importer/proposition.rb
|
161
227
|
- lib/hdo/storting_importer/representative.rb
|
228
|
+
- lib/hdo/storting_importer/schema.json
|
229
|
+
- lib/hdo/storting_importer/schema/category.json
|
230
|
+
- lib/hdo/storting_importer/schema/committee.json
|
231
|
+
- lib/hdo/storting_importer/schema/district.json
|
232
|
+
- lib/hdo/storting_importer/schema/issue.json
|
233
|
+
- lib/hdo/storting_importer/schema/party.json
|
234
|
+
- lib/hdo/storting_importer/schema/promise.json
|
235
|
+
- lib/hdo/storting_importer/schema/proposition.json
|
236
|
+
- lib/hdo/storting_importer/schema/representative.json
|
237
|
+
- lib/hdo/storting_importer/schema/vote.json
|
162
238
|
- lib/hdo/storting_importer/util.rb
|
163
239
|
- lib/hdo/storting_importer/version.rb
|
164
240
|
- lib/hdo/storting_importer/vote.rb
|
@@ -175,13 +251,20 @@ files:
|
|
175
251
|
- spec/fixtures/input/vote_results_2175.xml
|
176
252
|
- spec/fixtures/input/vote_results_2176.xml
|
177
253
|
- spec/fixtures/input/votes.xml
|
254
|
+
- spec/fixtures/output/categories.json
|
178
255
|
- spec/fixtures/output/categories.xml
|
256
|
+
- spec/fixtures/output/committees.json
|
179
257
|
- spec/fixtures/output/committees.xml
|
258
|
+
- spec/fixtures/output/districts.json
|
180
259
|
- spec/fixtures/output/districts.xml
|
260
|
+
- spec/fixtures/output/issues.json
|
181
261
|
- spec/fixtures/output/issues.xml
|
262
|
+
- spec/fixtures/output/parties.json
|
182
263
|
- spec/fixtures/output/parties.xml
|
183
264
|
- spec/fixtures/output/promises-a.xml
|
265
|
+
- spec/fixtures/output/representatives.json
|
184
266
|
- spec/fixtures/output/representatives.xml
|
267
|
+
- spec/fixtures/output/votes.json
|
185
268
|
- spec/fixtures/output/votes.xml
|
186
269
|
- spec/hdo/storting_importer/category_spec.rb
|
187
270
|
- spec/hdo/storting_importer/committee_spec.rb
|
@@ -190,6 +273,7 @@ files:
|
|
190
273
|
- spec/hdo/storting_importer/issue_spec.rb
|
191
274
|
- spec/hdo/storting_importer/party_spec.rb
|
192
275
|
- spec/hdo/storting_importer/promise_spec.rb
|
276
|
+
- spec/hdo/storting_importer/proposition_spec.rb
|
193
277
|
- spec/hdo/storting_importer/representative_spec.rb
|
194
278
|
- spec/hdo/storting_importer/vote_spec.rb
|
195
279
|
- spec/spec_helper.rb
|
@@ -233,13 +317,20 @@ test_files:
|
|
233
317
|
- spec/fixtures/input/vote_results_2175.xml
|
234
318
|
- spec/fixtures/input/vote_results_2176.xml
|
235
319
|
- spec/fixtures/input/votes.xml
|
320
|
+
- spec/fixtures/output/categories.json
|
236
321
|
- spec/fixtures/output/categories.xml
|
322
|
+
- spec/fixtures/output/committees.json
|
237
323
|
- spec/fixtures/output/committees.xml
|
324
|
+
- spec/fixtures/output/districts.json
|
238
325
|
- spec/fixtures/output/districts.xml
|
326
|
+
- spec/fixtures/output/issues.json
|
239
327
|
- spec/fixtures/output/issues.xml
|
328
|
+
- spec/fixtures/output/parties.json
|
240
329
|
- spec/fixtures/output/parties.xml
|
241
330
|
- spec/fixtures/output/promises-a.xml
|
331
|
+
- spec/fixtures/output/representatives.json
|
242
332
|
- spec/fixtures/output/representatives.xml
|
333
|
+
- spec/fixtures/output/votes.json
|
243
334
|
- spec/fixtures/output/votes.xml
|
244
335
|
- spec/hdo/storting_importer/category_spec.rb
|
245
336
|
- spec/hdo/storting_importer/committee_spec.rb
|
@@ -248,6 +339,7 @@ test_files:
|
|
248
339
|
- spec/hdo/storting_importer/issue_spec.rb
|
249
340
|
- spec/hdo/storting_importer/party_spec.rb
|
250
341
|
- spec/hdo/storting_importer/promise_spec.rb
|
342
|
+
- spec/hdo/storting_importer/proposition_spec.rb
|
251
343
|
- spec/hdo/storting_importer/representative_spec.rb
|
252
344
|
- spec/hdo/storting_importer/vote_spec.rb
|
253
345
|
- spec/spec_helper.rb
|
data/.gitmodules
DELETED