hdo-storting-importer 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/hdo-storting-importer.gemspec +1 -0
- data/lib/hdo/storting_importer/cli.rb +1 -2
- data/lib/hdo/storting_importer/promise.rb +2 -2
- data/lib/hdo/storting_importer/version.rb +1 -1
- data/lib/hdo/storting_importer.rb +2 -2
- data/spec/hdo/storting_importer/converter_spec.rb +0 -4
- data/spec/hdo/storting_importer/promise_spec.rb +5 -0
- metadata +18 -3
- data/lib/hdo/storting_importer/promise_converter.rb +0 -29
@@ -106,8 +106,7 @@ module Hdo
|
|
106
106
|
if csv =~ /^http/
|
107
107
|
content << open(csv).read
|
108
108
|
else
|
109
|
-
|
110
|
-
content << File.read(File.expand_path(csv), encoding: "ISO-8859-1").encode("UTF-8")
|
109
|
+
content << File.read(File.expand_path(csv))
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
@@ -72,7 +72,7 @@ module Hdo
|
|
72
72
|
pr[:party].to_s.strip,
|
73
73
|
pr[:body].to_s.strip,
|
74
74
|
pr[:general].to_s.downcase == 'ja',
|
75
|
-
pr[:categories].to_s.split(",")
|
75
|
+
pr[:categories].to_s.split(","),
|
76
76
|
pr[:source].to_s.strip,
|
77
77
|
pr[:page].to_s.strip
|
78
78
|
)
|
@@ -83,7 +83,7 @@ module Hdo
|
|
83
83
|
@party = party
|
84
84
|
@body = body
|
85
85
|
@general = general
|
86
|
-
@categories = categories
|
86
|
+
@categories = categories.map(&:strip).map { |e| UnicodeUtils.upcase(e) }
|
87
87
|
@source = source
|
88
88
|
@page = page
|
89
89
|
end
|
@@ -5,6 +5,8 @@ require 'pathname'
|
|
5
5
|
require 'open-uri'
|
6
6
|
require 'erb'
|
7
7
|
require 'logger'
|
8
|
+
require 'builder'
|
9
|
+
require 'unicode_utils'
|
8
10
|
|
9
11
|
module Hdo
|
10
12
|
module StortingImporter
|
@@ -56,8 +58,6 @@ require 'hdo/storting_importer/representative'
|
|
56
58
|
require 'hdo/storting_importer/vote'
|
57
59
|
|
58
60
|
require 'hdo/storting_importer/converter'
|
59
|
-
require 'hdo/storting_importer/promise_converter'
|
60
|
-
|
61
61
|
require 'hdo/storting_importer/cli'
|
62
62
|
|
63
63
|
|
@@ -93,6 +93,11 @@ XML
|
|
93
93
|
Promise.example.short_inspect.should be_kind_of(String)
|
94
94
|
end
|
95
95
|
|
96
|
+
it 'correctly upcases non-ASCII category names' do
|
97
|
+
promise = Promise.new("Party", "Body", true, ["æøå"], "PP", 8)
|
98
|
+
promise.categories.should == ["ÆØÅ"]
|
99
|
+
end
|
100
|
+
|
96
101
|
end
|
97
102
|
end
|
98
103
|
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.6
|
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-07-
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: unicode_utils
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
description: Gem to process data from data.stortinget.no
|
95
111
|
email:
|
96
112
|
- jari.bakken@gmail.com
|
@@ -126,7 +142,6 @@ files:
|
|
126
142
|
- lib/hdo/storting_importer/parsing_data_source.rb
|
127
143
|
- lib/hdo/storting_importer/party.rb
|
128
144
|
- lib/hdo/storting_importer/promise.rb
|
129
|
-
- lib/hdo/storting_importer/promise_converter.rb
|
130
145
|
- lib/hdo/storting_importer/representative.rb
|
131
146
|
- lib/hdo/storting_importer/util.rb
|
132
147
|
- lib/hdo/storting_importer/version.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'csv'
|
4
|
-
require 'builder'
|
5
|
-
|
6
|
-
module Hdo
|
7
|
-
module StortingImporter
|
8
|
-
class PromiseConverter
|
9
|
-
def initialize(exported_spreadsheet)
|
10
|
-
content = File.read(File.expand_path(exported_spreadsheet), encoding: "ISO-8859-1").encode("UTF-8")
|
11
|
-
@promises = Promise.from_csv(content)
|
12
|
-
end
|
13
|
-
|
14
|
-
def xml
|
15
|
-
builder = Builder::XmlMarkup.new :indent => 2
|
16
|
-
builder.instruct!
|
17
|
-
|
18
|
-
builder.promises do |promises|
|
19
|
-
@promises.each do |data|
|
20
|
-
next if data.body == "Løftetekst" || data.body.nil? || data.body.empty?
|
21
|
-
data.to_hdo_xml(promises)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
builder.target!
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|