fruit_to_lime 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module FruitToLime
|
2
3
|
class Tag
|
3
4
|
def serialize_name
|
@@ -11,7 +12,7 @@ module FruitToLime
|
|
11
12
|
end
|
12
13
|
def to_xml
|
13
14
|
varn = serialize_name
|
14
|
-
"<#{varn}>#{ @value.to_s.encode(:xml => :text) }</#{varn}>"
|
15
|
+
"<#{varn}>#{ @value.to_s.encode('utf-8').encode(:xml => :text) }</#{varn}>"
|
15
16
|
end
|
16
17
|
def to_s
|
17
18
|
return "tag: '#{@value}'"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module FruitToLime
|
2
3
|
module SerializeHelper
|
3
4
|
|
@@ -32,7 +33,7 @@ module SerializeHelper
|
|
32
33
|
elsif (varv.is_a?(Array))
|
33
34
|
varv = varv.map { |elem| SerializeHelper::serialize(elem) }.join("\n")
|
34
35
|
else
|
35
|
-
varv = varv.to_s.encode(:xml => :text)
|
36
|
+
varv = varv.to_s.encode('UTF-8').encode(:xml => :text)
|
36
37
|
end
|
37
38
|
"<#{varn}>#{ varv }</#{varn}>"
|
38
39
|
end.join("\n")
|
@@ -15,6 +15,9 @@ describe FruitToLime::SerializeHelper do
|
|
15
15
|
it "should contain start tag" do
|
16
16
|
serialized.should match(/<Note>/)
|
17
17
|
end
|
18
|
+
it "should be utf-8" do
|
19
|
+
serialized.encoding.should equal Encoding::UTF_8
|
20
|
+
end
|
18
21
|
end
|
19
22
|
describe "Serialize person" do
|
20
23
|
let(:serialized) {
|
@@ -24,12 +27,17 @@ describe FruitToLime::SerializeHelper do
|
|
24
27
|
p.last_name = "Anka"
|
25
28
|
p.source_ref = FruitToLime::SourceRef.new({:name=>'Go',:id=>"PASE122345"})
|
26
29
|
p.postal_address.city = "Ankeborg"
|
27
|
-
p.tags="tag:anka"
|
30
|
+
p.tags="tag:anka,tag:Bj\u{00F6}rk"
|
28
31
|
cf = FruitToLime::CustomField.new
|
29
32
|
cf.id = "2"
|
30
33
|
cf.title = "cf title"
|
31
34
|
cf.value = "cf value"
|
32
35
|
p.custom_fields.push(cf)
|
36
|
+
cf2 = FruitToLime::CustomField.new
|
37
|
+
cf2.id = "3"
|
38
|
+
cf2.title = "cf title2"
|
39
|
+
cf2.value = "cf Bj\u{00F6}rk"
|
40
|
+
p.custom_fields.push(cf2)
|
33
41
|
FruitToLime::SerializeHelper::serialize(p)
|
34
42
|
}
|
35
43
|
it "should contain first and last name" do
|
@@ -47,18 +55,32 @@ describe FruitToLime::SerializeHelper do
|
|
47
55
|
serialized.should match(/PASE/)
|
48
56
|
serialized.should match(/122345/)
|
49
57
|
end
|
58
|
+
it "should handle sv chars in tags" do
|
59
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
60
|
+
end
|
61
|
+
it "should handle sv chars in custom value" do
|
62
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
63
|
+
end
|
64
|
+
it "should be utf-8" do
|
65
|
+
serialized.encoding.should equal Encoding::UTF_8
|
66
|
+
end
|
50
67
|
end
|
51
68
|
describe "Serialize organization" do
|
52
69
|
let(:serialized) {
|
53
70
|
o = FruitToLime::Organization.new
|
54
71
|
o.name = "Ankeborgs bibliotek"
|
55
|
-
o.tags="tag:bibliotek"
|
72
|
+
o.tags="tag:bibliotek,tag:Bj\u{00F6}rk"
|
56
73
|
o.source_ref = FruitToLime::SourceRef.new({:name=>'Go',:id=>"PASE122345"})
|
57
74
|
cf = FruitToLime::CustomField.new
|
58
75
|
cf.id = "2"
|
59
76
|
cf.title = "cf title"
|
60
77
|
cf.value = "cf value"
|
61
78
|
o.custom_fields.push(cf)
|
79
|
+
cf2 = FruitToLime::CustomField.new
|
80
|
+
cf2.id = "3"
|
81
|
+
cf2.title = "cf title2"
|
82
|
+
cf2.value = "cf Bj\u{00F6}rk"
|
83
|
+
o.custom_fields.push(cf2)
|
62
84
|
FruitToLime::SerializeHelper::serialize(o)
|
63
85
|
}
|
64
86
|
it "should contain name" do
|
@@ -77,6 +99,15 @@ describe FruitToLime::SerializeHelper do
|
|
77
99
|
serialized.should match(/PASE/)
|
78
100
|
serialized.should match(/122345/)
|
79
101
|
end
|
102
|
+
it "should handle sv chars in tags" do
|
103
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
104
|
+
end
|
105
|
+
it "should handle sv chars in custom value" do
|
106
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
107
|
+
end
|
108
|
+
it "should be utf-8" do
|
109
|
+
serialized.encoding.should equal Encoding::UTF_8
|
110
|
+
end
|
80
111
|
end
|
81
112
|
|
82
113
|
describe "Serialize goimport" do
|
@@ -90,6 +121,9 @@ describe FruitToLime::SerializeHelper do
|
|
90
121
|
it "should contain name" do
|
91
122
|
serialized.should match(/Ankeborgs bibliotek/)
|
92
123
|
end
|
124
|
+
it "should be utf-8" do
|
125
|
+
serialized.encoding.should equal Encoding::UTF_8
|
126
|
+
end
|
93
127
|
end
|
94
128
|
describe "Get import rows" do
|
95
129
|
describe "for person" do
|