hdo-storting-importer 0.0.3 → 0.0.4

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.
@@ -40,6 +40,10 @@ module Hdo
40
40
  @name = name
41
41
  end
42
42
 
43
+ def external_id
44
+ Util.unescape_param @external_id
45
+ end
46
+
43
47
  def to_hdo_xml(builder = Util.builder)
44
48
  builder.party do |party|
45
49
  party.externalId external_id
@@ -125,6 +125,10 @@ module Hdo
125
125
  @vote_result = nil
126
126
  end
127
127
 
128
+ def external_id
129
+ Util.unescape_param @external_id
130
+ end
131
+
128
132
  def to_hdo_xml(builder = Util.builder)
129
133
  builder.representative do |rep|
130
134
  rep.externalId external_id
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module Hdo
2
4
  module StortingImporter
3
5
  module Util
@@ -21,6 +23,20 @@ module Hdo
21
23
  def remove_invalid_html(str)
22
24
  str.gsub("<\\p>", "")
23
25
  end
26
+
27
+ ID_CONVERSIONS = {
28
+ '_AE' => 'Æ',
29
+ '_O' => 'Ø',
30
+ '_A' => 'Å'
31
+ }
32
+
33
+ def unescape_param(query_param)
34
+ q = query_param.dup
35
+ ID_CONVERSIONS.each { |k, v| q.gsub!(k, v) }
36
+
37
+ q
38
+ end
39
+
24
40
  end
25
41
  end
26
42
  end
@@ -1,5 +1,5 @@
1
1
  module Hdo
2
2
  module StortingImporter
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -67,6 +67,11 @@ module Hdo
67
67
  Party.fields.should_not be_empty
68
68
  end
69
69
 
70
+ it 'unescapes non-ASCII characters in the external id' do
71
+ party = Party.new('_AE_O_A', "Senterpartiet")
72
+ party.external_id.should == "ÆØÅ"
73
+ end
74
+
70
75
  end
71
76
  end
72
77
  end
@@ -93,6 +93,13 @@ module Hdo
93
93
  Representative.fields.should_not be_empty
94
94
  end
95
95
 
96
+ it 'unescapes non-ASCII characters in the external id' do
97
+ rep = Representative.example
98
+
99
+ rep.instance_variable_set("@external_id", '_AE_O_A')
100
+ rep.external_id.should == "ÆØÅ"
101
+ end
102
+
96
103
  end
97
104
  end
98
105
  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.3
4
+ version: 0.0.4
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-25 00:00:00.000000000 Z
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder