hdo-storting-importer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.gitmodules +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +8 -0
- data/LICENSE +20 -0
- data/README.md +14 -0
- data/Rakefile +11 -0
- data/bin/hdo-converter +7 -0
- data/features/import.feature +85 -0
- data/features/step_definitions/import_steps.rb +0 -0
- data/features/support/env.rb +7 -0
- data/hdo-storting-importer.gemspec +17 -0
- data/lib/hdo/storting_importer/api_data_source.rb +62 -0
- data/lib/hdo/storting_importer/category.rb +55 -0
- data/lib/hdo/storting_importer/cli.rb +141 -0
- data/lib/hdo/storting_importer/committee.rb +35 -0
- data/lib/hdo/storting_importer/converter.rb +45 -0
- data/lib/hdo/storting_importer/core_ext/enumerable.rb +12 -0
- data/lib/hdo/storting_importer/data_source.rb +22 -0
- data/lib/hdo/storting_importer/disk_data_source.rb +61 -0
- data/lib/hdo/storting_importer/district.rb +36 -0
- data/lib/hdo/storting_importer/issue.rb +90 -0
- data/lib/hdo/storting_importer/ivar_equality.rb +22 -0
- data/lib/hdo/storting_importer/parsing_data_source.rb +59 -0
- data/lib/hdo/storting_importer/party.rb +31 -0
- data/lib/hdo/storting_importer/promise.rb +49 -0
- data/lib/hdo/storting_importer/promise_converter.rb +48 -0
- data/lib/hdo/storting_importer/representative.rb +106 -0
- data/lib/hdo/storting_importer/script_importer.rb +20 -0
- data/lib/hdo/storting_importer/util.rb +26 -0
- data/lib/hdo/storting_importer/version.rb +5 -0
- data/lib/hdo/storting_importer/vote.rb +171 -0
- data/lib/hdo/storting_importer.rb +41 -0
- data/spec/fixtures/input/categories.xml +1351 -0
- data/spec/fixtures/input/committees.xml +92 -0
- data/spec/fixtures/input/districts.xml +101 -0
- data/spec/fixtures/input/issues.xml +2852 -0
- data/spec/fixtures/input/parties.xml +42 -0
- data/spec/fixtures/input/promises-a.csv +341 -0
- data/spec/fixtures/input/propositions_2175.xml +64 -0
- data/spec/fixtures/input/propositions_2176.xml +64 -0
- data/spec/fixtures/input/representatives.xml +3218 -0
- data/spec/fixtures/input/representatives_today.xml +4872 -0
- data/spec/fixtures/input/vote_results_2175.xml +4400 -0
- data/spec/fixtures/input/vote_results_2176.xml +4400 -0
- data/spec/fixtures/input/votes.xml +85 -0
- data/spec/fixtures/output/categories.xml +803 -0
- data/spec/fixtures/output/committees.xml +71 -0
- data/spec/fixtures/output/districts.xml +79 -0
- data/spec/fixtures/output/issues.xml +836 -0
- data/spec/fixtures/output/parties.xml +31 -0
- data/spec/fixtures/output/promises-a.xml +3224 -0
- data/spec/fixtures/output/representatives.xml +2567 -0
- data/spec/fixtures/output/votes.xml +4899 -0
- data/spec/hdo/storting_importer/category_spec.rb +76 -0
- data/spec/hdo/storting_importer/committee_spec.rb +46 -0
- data/spec/hdo/storting_importer/converter_spec.rb +72 -0
- data/spec/hdo/storting_importer/district_spec.rb +54 -0
- data/spec/hdo/storting_importer/issue_spec.rb +115 -0
- data/spec/hdo/storting_importer/party_spec.rb +52 -0
- data/spec/hdo/storting_importer/promise_spec.rb +38 -0
- data/spec/hdo/storting_importer/representative_spec.rb +81 -0
- data/spec/hdo/storting_importer/vote_spec.rb +155 -0
- data/spec/spec_helper.rb +39 -0
- metadata +145 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module Hdo
|
5
|
+
module StortingImporter
|
6
|
+
describe Vote do
|
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
|
+
it "builds votes from the Storting XML list" do
|
21
|
+
xml = <<-XML
|
22
|
+
<?xml version="1.0" encoding="utf-8"?>
|
23
|
+
<sak_votering_oversikt xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://data.stortinget.no">
|
24
|
+
<versjon>1.0</versjon>
|
25
|
+
<sak_id>51448</sak_id>
|
26
|
+
<sak_votering_liste>
|
27
|
+
<sak_votering>
|
28
|
+
<versjon>1.0</versjon>
|
29
|
+
<alternativ_votering_id>-1</alternativ_votering_id>
|
30
|
+
<antall_for>2</antall_for>
|
31
|
+
<antall_ikke_tilstede>71</antall_ikke_tilstede>
|
32
|
+
<antall_mot>96</antall_mot>
|
33
|
+
<behandlingsrekkefoelge>1</behandlingsrekkefoelge>
|
34
|
+
<dagsorden_sak_nummer>2</dagsorden_sak_nummer>
|
35
|
+
<fri_votering>false</fri_votering>
|
36
|
+
<kommentar i:nil="true" />
|
37
|
+
<personlig_votering>true</personlig_votering>
|
38
|
+
<president>
|
39
|
+
<versjon>1.0</versjon>
|
40
|
+
<doedsdato>0001-01-01T00:00:00</doedsdato>
|
41
|
+
<etternavn>Nybakk</etternavn>
|
42
|
+
<foedselsdato>1947-02-14T00:00:00</foedselsdato>
|
43
|
+
<fornavn>Marit</fornavn>
|
44
|
+
<id>MN</id>
|
45
|
+
<kjoenn>kvinne</kjoenn>
|
46
|
+
<fylke>
|
47
|
+
<versjon>1.0</versjon>
|
48
|
+
<id>Os</id>
|
49
|
+
<navn>Oslo</navn>
|
50
|
+
</fylke>
|
51
|
+
<parti>
|
52
|
+
<versjon>1.0</versjon>
|
53
|
+
<id>A</id>
|
54
|
+
<navn>Arbeiderpartiet</navn>
|
55
|
+
</parti>
|
56
|
+
</president>
|
57
|
+
<sak_id>51448</sak_id>
|
58
|
+
<vedtatt>false</vedtatt>
|
59
|
+
<votering_id>2175</votering_id>
|
60
|
+
<votering_metode>ikke_spesifisert</votering_metode>
|
61
|
+
<votering_resultat_type>ikke_spesifisert</votering_resultat_type>
|
62
|
+
<votering_resultat_type_tekst i:nil="true" />
|
63
|
+
<votering_tema>Forslag 24 - 26 på vegne av Per Olaf Lundteigen</votering_tema>
|
64
|
+
<votering_tid>2012-04-12T16:37:27.053</votering_tid>
|
65
|
+
</sak_votering>
|
66
|
+
</sak_votering_liste>
|
67
|
+
</sak_votering_oversikt>
|
68
|
+
XML
|
69
|
+
|
70
|
+
votes = Vote.from_storting_doc(parse(xml))
|
71
|
+
votes.size.should == 1
|
72
|
+
|
73
|
+
vote = votes.first
|
74
|
+
vote.external_id.should == "2175"
|
75
|
+
vote.external_issue_id.should == "51448"
|
76
|
+
vote.should be_personal
|
77
|
+
vote.enacted.should be_false
|
78
|
+
vote.subject.should == 'Forslag 24 - 26 på vegne av Per Olaf Lundteigen'
|
79
|
+
vote.method.should == 'ikke_spesifisert'
|
80
|
+
vote.result_type.should == 'ikke_spesifisert'
|
81
|
+
vote.time.should == '2012-04-12T16:37:27.053'
|
82
|
+
vote.counts.for.should == 2
|
83
|
+
vote.counts.against.should == 96
|
84
|
+
vote.counts.absent.should == 71
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'can serialize as HDO XML' do
|
88
|
+
vote = create_vote
|
89
|
+
vote.to_hdo_xml.should == <<-XML
|
90
|
+
<vote>
|
91
|
+
<externalId>2175</externalId>
|
92
|
+
<externalIssueId>51448</externalIssueId>
|
93
|
+
<counts>
|
94
|
+
<for>2</for>
|
95
|
+
<against>96</against>
|
96
|
+
<absent>71</absent>
|
97
|
+
</counts>
|
98
|
+
<personal>true</personal>
|
99
|
+
<enacted>false</enacted>
|
100
|
+
<subject>Forslag 24 - 26 på vegne av Per Olaf Lundteigen</subject>
|
101
|
+
<method>ikke_spesifisert</method>
|
102
|
+
<resultType>ikke_spesifisert</resultType>
|
103
|
+
<time>2012-04-12T16:37:27.053</time>
|
104
|
+
<representatives>
|
105
|
+
<representative>
|
106
|
+
<externalId>PTA</externalId>
|
107
|
+
<firstName>Per-Willy</firstName>
|
108
|
+
<lastName>Amundsen</lastName>
|
109
|
+
<gender>M</gender>
|
110
|
+
<dateOfBirth>1971-01-21T00:00:00</dateOfBirth>
|
111
|
+
<dateOfDeath>0001-01-01T00:00:00</dateOfDeath>
|
112
|
+
<district>Troms</district>
|
113
|
+
<party>Fremskrittspartiet</party>
|
114
|
+
<committees>
|
115
|
+
</committees>
|
116
|
+
<period>2011-2012</period>
|
117
|
+
<voteResult>against</voteResult>
|
118
|
+
</representative>
|
119
|
+
</representatives>
|
120
|
+
<propositions>
|
121
|
+
<proposition>
|
122
|
+
<externalId>1234</externalId>
|
123
|
+
<description>description</description>
|
124
|
+
<onBehalfOf>on behalf of</onBehalfOf>
|
125
|
+
<body>body</body>
|
126
|
+
<deliveredBy>
|
127
|
+
<representative>
|
128
|
+
<externalId>PTA</externalId>
|
129
|
+
<firstName>Per-Willy</firstName>
|
130
|
+
<lastName>Amundsen</lastName>
|
131
|
+
<gender>M</gender>
|
132
|
+
<dateOfBirth>1971-01-21T00:00:00</dateOfBirth>
|
133
|
+
<dateOfDeath>0001-01-01T00:00:00</dateOfDeath>
|
134
|
+
<district>Troms</district>
|
135
|
+
<party>Fremskrittspartiet</party>
|
136
|
+
<committees>
|
137
|
+
</committees>
|
138
|
+
<period>2011-2012</period>
|
139
|
+
<voteResult>against</voteResult>
|
140
|
+
</representative>
|
141
|
+
</deliveredBy>
|
142
|
+
</proposition>
|
143
|
+
</propositions>
|
144
|
+
</vote>
|
145
|
+
XML
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'can deserialize HDO XML' do
|
149
|
+
orig = create_vote
|
150
|
+
Vote.from_hdo_node(parse(orig.to_hdo_xml)).should == orig
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'hdo/storting_importer'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module Hdo
|
6
|
+
module StortingImporter
|
7
|
+
module SpecHelper
|
8
|
+
FIXTURES = Pathname.new(File.expand_path("../fixtures", __FILE__))
|
9
|
+
|
10
|
+
def input_fixture(name)
|
11
|
+
FIXTURES.join(input_path("#{name}.xml")).read
|
12
|
+
end
|
13
|
+
|
14
|
+
def output_fixture(name)
|
15
|
+
FIXTURES.join(output_path("#{name}.xml")).read
|
16
|
+
end
|
17
|
+
|
18
|
+
def input_path(filename)
|
19
|
+
FIXTURES.join("input/#{filename}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def output_path(filename)
|
23
|
+
FIXTURES.join("output/#{filename}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse(str)
|
27
|
+
doc = Nokogiri::XML.parse(str)
|
28
|
+
doc.remove_namespaces!
|
29
|
+
|
30
|
+
doc
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.configure do |c|
|
38
|
+
c.include Hdo::StortingImporter::SpecHelper
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hdo-storting-importer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jari Bakken
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gem to process data from data.stortinget.no
|
15
|
+
email:
|
16
|
+
- jari.bakken@gmail.com
|
17
|
+
executables:
|
18
|
+
- hdo-converter
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .gitmodules
|
24
|
+
- .travis.yml
|
25
|
+
- Gemfile
|
26
|
+
- LICENSE
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- bin/hdo-converter
|
30
|
+
- features/import.feature
|
31
|
+
- features/step_definitions/import_steps.rb
|
32
|
+
- features/support/env.rb
|
33
|
+
- hdo-storting-importer.gemspec
|
34
|
+
- lib/hdo/storting_importer.rb
|
35
|
+
- lib/hdo/storting_importer/api_data_source.rb
|
36
|
+
- lib/hdo/storting_importer/category.rb
|
37
|
+
- lib/hdo/storting_importer/cli.rb
|
38
|
+
- lib/hdo/storting_importer/committee.rb
|
39
|
+
- lib/hdo/storting_importer/converter.rb
|
40
|
+
- lib/hdo/storting_importer/core_ext/enumerable.rb
|
41
|
+
- lib/hdo/storting_importer/data_source.rb
|
42
|
+
- lib/hdo/storting_importer/disk_data_source.rb
|
43
|
+
- lib/hdo/storting_importer/district.rb
|
44
|
+
- lib/hdo/storting_importer/issue.rb
|
45
|
+
- lib/hdo/storting_importer/ivar_equality.rb
|
46
|
+
- lib/hdo/storting_importer/parsing_data_source.rb
|
47
|
+
- lib/hdo/storting_importer/party.rb
|
48
|
+
- lib/hdo/storting_importer/promise.rb
|
49
|
+
- lib/hdo/storting_importer/promise_converter.rb
|
50
|
+
- lib/hdo/storting_importer/representative.rb
|
51
|
+
- lib/hdo/storting_importer/script_importer.rb
|
52
|
+
- lib/hdo/storting_importer/util.rb
|
53
|
+
- lib/hdo/storting_importer/version.rb
|
54
|
+
- lib/hdo/storting_importer/vote.rb
|
55
|
+
- spec/fixtures/input/categories.xml
|
56
|
+
- spec/fixtures/input/committees.xml
|
57
|
+
- spec/fixtures/input/districts.xml
|
58
|
+
- spec/fixtures/input/issues.xml
|
59
|
+
- spec/fixtures/input/parties.xml
|
60
|
+
- spec/fixtures/input/promises-a.csv
|
61
|
+
- spec/fixtures/input/propositions_2175.xml
|
62
|
+
- spec/fixtures/input/propositions_2176.xml
|
63
|
+
- spec/fixtures/input/representatives.xml
|
64
|
+
- spec/fixtures/input/representatives_today.xml
|
65
|
+
- spec/fixtures/input/vote_results_2175.xml
|
66
|
+
- spec/fixtures/input/vote_results_2176.xml
|
67
|
+
- spec/fixtures/input/votes.xml
|
68
|
+
- spec/fixtures/output/categories.xml
|
69
|
+
- spec/fixtures/output/committees.xml
|
70
|
+
- spec/fixtures/output/districts.xml
|
71
|
+
- spec/fixtures/output/issues.xml
|
72
|
+
- spec/fixtures/output/parties.xml
|
73
|
+
- spec/fixtures/output/promises-a.xml
|
74
|
+
- spec/fixtures/output/representatives.xml
|
75
|
+
- spec/fixtures/output/votes.xml
|
76
|
+
- spec/hdo/storting_importer/category_spec.rb
|
77
|
+
- spec/hdo/storting_importer/committee_spec.rb
|
78
|
+
- spec/hdo/storting_importer/converter_spec.rb
|
79
|
+
- spec/hdo/storting_importer/district_spec.rb
|
80
|
+
- spec/hdo/storting_importer/issue_spec.rb
|
81
|
+
- spec/hdo/storting_importer/party_spec.rb
|
82
|
+
- spec/hdo/storting_importer/promise_spec.rb
|
83
|
+
- spec/hdo/storting_importer/representative_spec.rb
|
84
|
+
- spec/hdo/storting_importer/vote_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
homepage: http://github.com/holderdeord/hdo-storting-importer
|
87
|
+
licenses: []
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.24
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: Gem to process data from data.stortinget.no
|
110
|
+
test_files:
|
111
|
+
- features/import.feature
|
112
|
+
- features/step_definitions/import_steps.rb
|
113
|
+
- features/support/env.rb
|
114
|
+
- spec/fixtures/input/categories.xml
|
115
|
+
- spec/fixtures/input/committees.xml
|
116
|
+
- spec/fixtures/input/districts.xml
|
117
|
+
- spec/fixtures/input/issues.xml
|
118
|
+
- spec/fixtures/input/parties.xml
|
119
|
+
- spec/fixtures/input/promises-a.csv
|
120
|
+
- spec/fixtures/input/propositions_2175.xml
|
121
|
+
- spec/fixtures/input/propositions_2176.xml
|
122
|
+
- spec/fixtures/input/representatives.xml
|
123
|
+
- spec/fixtures/input/representatives_today.xml
|
124
|
+
- spec/fixtures/input/vote_results_2175.xml
|
125
|
+
- spec/fixtures/input/vote_results_2176.xml
|
126
|
+
- spec/fixtures/input/votes.xml
|
127
|
+
- spec/fixtures/output/categories.xml
|
128
|
+
- spec/fixtures/output/committees.xml
|
129
|
+
- spec/fixtures/output/districts.xml
|
130
|
+
- spec/fixtures/output/issues.xml
|
131
|
+
- spec/fixtures/output/parties.xml
|
132
|
+
- spec/fixtures/output/promises-a.xml
|
133
|
+
- spec/fixtures/output/representatives.xml
|
134
|
+
- spec/fixtures/output/votes.xml
|
135
|
+
- spec/hdo/storting_importer/category_spec.rb
|
136
|
+
- spec/hdo/storting_importer/committee_spec.rb
|
137
|
+
- spec/hdo/storting_importer/converter_spec.rb
|
138
|
+
- spec/hdo/storting_importer/district_spec.rb
|
139
|
+
- spec/hdo/storting_importer/issue_spec.rb
|
140
|
+
- spec/hdo/storting_importer/party_spec.rb
|
141
|
+
- spec/hdo/storting_importer/promise_spec.rb
|
142
|
+
- spec/hdo/storting_importer/representative_spec.rb
|
143
|
+
- spec/hdo/storting_importer/vote_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
has_rdoc:
|