hdo-storting-importer 0.3.2 → 0.3.3
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/.travis.yml +1 -1
- data/LICENSE +1 -1
- data/README.md +5 -0
- data/hdo-storting-importer.gemspec +1 -0
- data/lib/hdo/storting_importer/parsing_data_source.rb +4 -0
- data/lib/hdo/storting_importer/representative.rb +12 -2
- data/lib/hdo/storting_importer/schema/representative.json +4 -0
- data/lib/hdo/storting_importer/version.rb +1 -1
- data/lib/hdo/storting_importer/vote.rb +4 -4
- data/spec/hdo/storting_importer/representative_spec.rb +10 -0
- data/spec/hdo/storting_importer/vote_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +19 -9
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
[](http://travis-ci.org/holderdeord/hdo-storting-importer)
|
2
|
+
[](https://codeclimate.com/github/holderdeord/hdo-storting-importer)
|
3
|
+
[](https://gemnasium.com/holderdeord/hdo-storting-importer)
|
4
|
+
[](https://coveralls.io/r/holderdeord/hdo-storting-importer)
|
5
|
+
|
1
6
|
What
|
2
7
|
====
|
3
8
|
|
@@ -10,7 +10,7 @@ module Hdo
|
|
10
10
|
attr_reader :external_id, :first_name, :last_name, :date_of_birth, :date_of_death,
|
11
11
|
:district, :parties, :committees, :period, :gender
|
12
12
|
|
13
|
-
attr_accessor :vote_result
|
13
|
+
attr_accessor :vote_result, :permanent_substitute_for
|
14
14
|
|
15
15
|
schema_path StortingImporter.lib.join("hdo/storting_importer/schema/representative.json").to_s
|
16
16
|
|
@@ -64,7 +64,7 @@ module Hdo
|
|
64
64
|
CommitteeMembership.new(id, start_date, end_date)
|
65
65
|
end
|
66
66
|
|
67
|
-
new(
|
67
|
+
rep = new(
|
68
68
|
node.css("id").first.text,
|
69
69
|
node.css("fornavn").first.text,
|
70
70
|
node.css("etternavn").first.text,
|
@@ -75,6 +75,13 @@ module Hdo
|
|
75
75
|
parties,
|
76
76
|
committees
|
77
77
|
)
|
78
|
+
|
79
|
+
sub = node.css('fast_vara_for').first
|
80
|
+
if sub && sub['nil'] != 'true'
|
81
|
+
rep.permanent_substitute_for = sub.css("id").first.text
|
82
|
+
end
|
83
|
+
|
84
|
+
rep
|
78
85
|
end
|
79
86
|
|
80
87
|
def self.from_hash(hash)
|
@@ -89,6 +96,7 @@ module Hdo
|
|
89
96
|
Array(hash['committees']).map { |e| CommitteeMembership.from_hash(e) }
|
90
97
|
|
91
98
|
v.vote_result = hash['voteResult']
|
99
|
+
v.permanent_substitute_for = hash['permanentSubstituteFor']
|
92
100
|
|
93
101
|
v
|
94
102
|
end
|
@@ -105,6 +113,7 @@ module Hdo
|
|
105
113
|
@committees = committees
|
106
114
|
|
107
115
|
@vote_result = nil
|
116
|
+
@permanent_substitute_for = nil
|
108
117
|
end
|
109
118
|
|
110
119
|
def short_inspect
|
@@ -130,6 +139,7 @@ module Hdo
|
|
130
139
|
}
|
131
140
|
|
132
141
|
h['voteResult'] = @vote_result if @vote_result
|
142
|
+
h['permanentSubstituteFor'] = @permanent_substitute_for if @permanent_substitute_for
|
133
143
|
|
134
144
|
h
|
135
145
|
end
|
@@ -54,6 +54,10 @@
|
|
54
54
|
"type": "string",
|
55
55
|
"description": "If this representative object is part of a hdo#vote, this property describes how the representative voted. Valid values are for|against|absent.",
|
56
56
|
"pattern": "for|against|absent"
|
57
|
+
},
|
58
|
+
"permanentSubstituteFor": {
|
59
|
+
"type": "string",
|
60
|
+
"description": "A representative the current representative is a permanent substitute for."
|
57
61
|
}
|
58
62
|
}
|
59
63
|
}
|
@@ -8,7 +8,7 @@ module Hdo
|
|
8
8
|
include Inspectable
|
9
9
|
|
10
10
|
attr_reader :external_id, :external_issue_id, :personal, :enacted, :subject,
|
11
|
-
:
|
11
|
+
:method_name, :result_type, :time, :counts
|
12
12
|
attr_accessor :propositions, :representatives
|
13
13
|
|
14
14
|
alias_method :personal?, :personal
|
@@ -87,13 +87,13 @@ module Hdo
|
|
87
87
|
vote
|
88
88
|
end
|
89
89
|
|
90
|
-
def initialize(external_id, external_issue_id, personal, enacted, subject,
|
90
|
+
def initialize(external_id, external_issue_id, personal, enacted, subject, method_name, result_type, time, for_count, against_count, absent_count)
|
91
91
|
@external_id = external_id
|
92
92
|
@external_issue_id = external_issue_id
|
93
93
|
@personal = personal
|
94
94
|
@enacted = enacted
|
95
95
|
@subject = subject
|
96
|
-
@
|
96
|
+
@method_name = method_name
|
97
97
|
@result_type = result_type
|
98
98
|
@time = time
|
99
99
|
@counts = Counts.new(Integer(for_count || 0), Integer(against_count || 0), Integer(absent_count || 0))
|
@@ -141,7 +141,7 @@ module Hdo
|
|
141
141
|
'personal' => @personal,
|
142
142
|
'enacted' => @enacted,
|
143
143
|
'subject' => @subject,
|
144
|
-
'method' => @
|
144
|
+
'method' => @method_name,
|
145
145
|
'resultType' => @result_type,
|
146
146
|
'time' => @time,
|
147
147
|
'representatives' => @representatives.map(&:to_hash),
|
@@ -106,6 +106,16 @@ module Hdo
|
|
106
106
|
obj.first_name.should == 'foo'
|
107
107
|
end
|
108
108
|
|
109
|
+
it 'serializes the "permanent substitute for" field' do
|
110
|
+
obj = Representative.example
|
111
|
+
obj.permanent_substitute_for = "JB"
|
112
|
+
|
113
|
+
data = obj.to_hash
|
114
|
+
data['permanentSubstituteFor'].should == "JB"
|
115
|
+
|
116
|
+
Representative.from_hash(data).permanent_substitute_for.should == "JB"
|
117
|
+
end
|
118
|
+
|
109
119
|
end
|
110
120
|
end
|
111
121
|
end
|
@@ -67,7 +67,7 @@ module Hdo
|
|
67
67
|
vote.should be_personal
|
68
68
|
vote.enacted.should be_false
|
69
69
|
vote.subject.should == 'Forslag 24 - 26 på vegne av Per Olaf Lundteigen'
|
70
|
-
vote.
|
70
|
+
vote.method_name.should == 'ikke_spesifisert'
|
71
71
|
vote.result_type.should == 'ikke_spesifisert'
|
72
72
|
vote.time.should == '2012-04-12T16:37:27.053'
|
73
73
|
vote.counts.for.should == 2
|
data/spec/spec_helper.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.3
|
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:
|
12
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -267,6 +267,22 @@ dependencies:
|
|
267
267
|
- - ! '>='
|
268
268
|
- !ruby/object:Gem::Version
|
269
269
|
version: '0'
|
270
|
+
- !ruby/object:Gem::Dependency
|
271
|
+
name: coveralls
|
272
|
+
requirement: !ruby/object:Gem::Requirement
|
273
|
+
none: false
|
274
|
+
requirements:
|
275
|
+
- - ! '>='
|
276
|
+
- !ruby/object:Gem::Version
|
277
|
+
version: '0'
|
278
|
+
type: :development
|
279
|
+
prerelease: false
|
280
|
+
version_requirements: !ruby/object:Gem::Requirement
|
281
|
+
none: false
|
282
|
+
requirements:
|
283
|
+
- - ! '>='
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
270
286
|
description: Gem to process data from data.stortinget.no
|
271
287
|
email:
|
272
288
|
- jari.bakken@gmail.com
|
@@ -359,21 +375,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
359
375
|
- - ! '>='
|
360
376
|
- !ruby/object:Gem::Version
|
361
377
|
version: '0'
|
362
|
-
segments:
|
363
|
-
- 0
|
364
|
-
hash: 1318751592972283247
|
365
378
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
366
379
|
none: false
|
367
380
|
requirements:
|
368
381
|
- - ! '>='
|
369
382
|
- !ruby/object:Gem::Version
|
370
383
|
version: '0'
|
371
|
-
segments:
|
372
|
-
- 0
|
373
|
-
hash: 1318751592972283247
|
374
384
|
requirements: []
|
375
385
|
rubyforge_project:
|
376
|
-
rubygems_version: 1.8.
|
386
|
+
rubygems_version: 1.8.23
|
377
387
|
signing_key:
|
378
388
|
specification_version: 3
|
379
389
|
summary: Gem to process data from data.stortinget.no
|