vcard 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +15 -5
  2. data/Gemfile +3 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +17 -0
  5. data/Rakefile +4 -52
  6. data/{LICENSE → VPIM-LICENSE.txt} +2 -2
  7. data/lib/vcard.rb +304 -28
  8. data/lib/vcard/attachment.rb +10 -12
  9. data/lib/vcard/bnf.rb +66 -0
  10. data/lib/vcard/dirinfo.rb +24 -26
  11. data/lib/vcard/enumerator.rb +5 -7
  12. data/lib/vcard/errors.rb +23 -0
  13. data/lib/vcard/field.rb +56 -58
  14. data/lib/vcard/vcard.rb +210 -240
  15. data/lib/vcard/version.rb +3 -0
  16. data/test/field_test.rb +55 -55
  17. data/test/fixtures/bday_decode.vcard +3 -0
  18. data/test/fixtures/bday_decode_2.vcard +6 -0
  19. data/test/fixtures/empty_tel.vcard +3 -0
  20. data/test/fixtures/ex1.vcard +7 -0
  21. data/test/fixtures/ex2.vcard +9 -0
  22. data/test/fixtures/ex3.vcard +30 -0
  23. data/test/fixtures/ex_21.vcard +16 -0
  24. data/test/fixtures/ex_21_case0.vcard +15 -0
  25. data/test/fixtures/ex_apple1.vcard +13 -0
  26. data/test/fixtures/ex_attach.vcard +16 -0
  27. data/test/fixtures/ex_bdays.vcard +8 -0
  28. data/test/fixtures/ex_encode_1.vcard +10 -0
  29. data/test/fixtures/ex_ical_1.vcal +47 -0
  30. data/test/fixtures/gmail.vcard +27 -0
  31. data/test/fixtures/highrise.vcard +41 -0
  32. data/test/fixtures/multiple_occurences_of_type.vcard +17 -0
  33. data/test/fixtures/nickname0.vcard +2 -0
  34. data/test/fixtures/nickname1.vcard +3 -0
  35. data/test/fixtures/nickname2.vcard +3 -0
  36. data/test/fixtures/nickname3.vcard +3 -0
  37. data/test/fixtures/nickname4.vcard +4 -0
  38. data/test/fixtures/nickname5.vcard +5 -0
  39. data/test/fixtures/slash_in_field_name.vcard +3 -0
  40. data/test/fixtures/tst1.vcard +9 -0
  41. data/test/fixtures/url_decode.vcard +4 -0
  42. data/test/test_helper.rb +34 -6
  43. data/test/vcard_test.rb +87 -577
  44. data/vcard.gemspec +19 -0
  45. metadata +88 -43
  46. data/.document +0 -5
  47. data/README.rdoc +0 -7
  48. data/VERSION +0 -1
  49. data/lib/vcard/rfc2425.rb +0 -367
@@ -0,0 +1,17 @@
1
+ begin:VCARD
2
+ version:2.1
3
+ v;x1=a;x2=,a;x3=a,;x4=a,,a;x5=,a,:
4
+ source:ldap://cn=bjorn%20Jensen, o=university%20of%20Michigan, c=US
5
+ fn:Bj=F8rn
6
+ Jensen
7
+ other.name:Jensen;Bj=F8rn
8
+ some.other.value:1.2.3
9
+ some.other.value:some.other
10
+ some.other.value:some.other.value
11
+ v;p-1=;p-2=,,;p-3=a;p-4=a b,"v;p-1=;p-2=,,;p-3=a;p-4=a":v-value
12
+ email;type=internet:
13
+ bjorn@umich.edu
14
+ tel;type=work,voice,msg:+1 313 747-4454
15
+ tel:+...
16
+ key;type=x509;encoding=B:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK
17
+ end:vcard
@@ -0,0 +1,2 @@
1
+ begin:vcard
2
+ end:vcard
@@ -0,0 +1,3 @@
1
+ begin:vcard
2
+ nickname:
3
+ end:vcard
@@ -0,0 +1,3 @@
1
+ begin:vcard
2
+ nickname:
3
+ end:vcard
@@ -0,0 +1,3 @@
1
+ begin:vcard
2
+ nickname: Big Joey
3
+ end:vcard
@@ -0,0 +1,4 @@
1
+ begin:vcard
2
+ nickname:
3
+ nickname: Big Joey
4
+ end:vcard
@@ -0,0 +1,5 @@
1
+ begin:vcard
2
+ nickname:
3
+ nickname: Big Joey
4
+ nickname:Bob
5
+ end:vcard
@@ -0,0 +1,3 @@
1
+ BEGIN:VCARD
2
+ X-messaging/xmpp-All:some@jabber.id
3
+ END:VCARD
@@ -0,0 +1,9 @@
1
+ BEGIN:vCard
2
+ DESCRIPTION:Healey's\n\nLook up exact time.\n
3
+ email;type=work:work@example.com
4
+ email;type=internet,home;type=pref:home@example.com
5
+ fax;type=foo,pref;bar:fax
6
+ name:firstname
7
+ name:secondname
8
+ time;value=time:
9
+ END:vCARD
@@ -0,0 +1,4 @@
1
+ BEGIN:VCARD
2
+ URL:www.email.com
3
+ URL:www.work.com
4
+ END:VCARD
@@ -1,10 +1,38 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
1
+ require "test/unit"
2
+ require "vcard"
4
3
 
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'vcard'
4
+ include Vcard
8
5
 
9
6
  class Test::Unit::TestCase
7
+ # Test equivalence where whitespace is compressed.
8
+
9
+ def assert_equal_nospace(expected, got)
10
+ expected = expected.gsub(/\s+/,'')
11
+ got = expected.gsub(/\s+/,'')
12
+ assert_equal(expected, got)
13
+ end
14
+
15
+ def utf_name_test(c)
16
+ card = Vcard::Vcard.decode(c).first
17
+ assert_equal("name", card.name.family)
18
+ rescue
19
+ $!.message << " #{c.inspect}"
20
+ raise
21
+ end
22
+
23
+ def be(s)
24
+ s.unpack('U*').pack('n*')
25
+ end
26
+
27
+ def le(s)
28
+ s.unpack('U*').pack('v*')
29
+ end
30
+
31
+ def vcard(name)
32
+ open("test/fixtures/#{name}.vcard").read
33
+ end
34
+
35
+ def vcal(name)
36
+ open("test/fixtures/#{name}.vcal").read
37
+ end
10
38
  end
@@ -1,54 +1,13 @@
1
- require 'test_helper'
2
-
3
- include Vpim
4
-
5
- # Test equivalence where whitespace is compressed.
6
- def assert_equal_nospace(expected, got)
7
- expected = expected.gsub(/\s+/,'')
8
- got = expected.gsub(/\s+/,'')
9
- assert_equal(expected, got)
10
- end
11
-
12
-
13
- # Test cases: multiple occurrences of type
14
- =begin
15
- begin:VCARD
16
- version:2.1
17
- v;x1=a;x2=,a;x3=a,;x4=a,,a;x5=,a,:
18
- source:ldap://cn=bjorn%20Jensen, o=university%20of%20Michigan, c=US
19
- fn:Bj=F8rn
20
- Jensen
21
- other.name:Jensen;Bj=F8rn
22
- some.other.value:1.2.3
23
- some.other.value:some.other
24
- some.other.value:some.other.value
25
- v;p-1=;p-2=,,;p-3=a;p-4=a b,"v;p-1=;p-2=,,;p-3=a;p-4=a":v-value
26
- email;type=internet:
27
- bjorn@umich.edu
28
- tel;type=work,voice,msg:+1 313 747-4454
29
- tel:+...
30
- key;type=x509;encoding=B:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK
31
- end:vcard
32
- =end
1
+ require "test_helper"
33
2
 
34
3
  class VcardTest < Test::Unit::TestCase
35
4
 
36
5
  # RFC2425 - 8.1. Example 1
37
6
  # Note that this is NOT a valid vCard, it lacks BEGIN/END.
38
- EX1 =<<'EOF'
39
- cn:
40
- cn:Babs Jensen
41
- cn:Barbara J Jensen
42
- sn:Jensen
43
- email:babs@umich.edu
44
- phone:+1 313 747-4454
45
- x-id:1234567890
46
- EOF
47
7
  def test_ex1
48
8
  card = nil
49
- ex1 = EX1
50
- assert_nothing_thrown { card = Vpim::DirectoryInfo.decode(ex1) }
51
- assert_equal_nospace(EX1, card.to_s)
9
+ assert_nothing_thrown { card = Vcard::DirectoryInfo.decode(vcard(:ex1)) }
10
+ assert_equal_nospace(vcard(:ex1), card.to_s)
52
11
 
53
12
  assert_equal("Babs Jensen", card["cn"])
54
13
  assert_equal("Jensen", card["sn"])
@@ -61,23 +20,10 @@ EOF
61
20
  end
62
21
 
63
22
  # RFC2425 - 8.2. Example 2
64
- EX2 = <<-END
65
- begin:VCARD
66
- source:ldap://cn=bjorn%20Jensen, o=university%20of%20Michigan, c=US
67
- name:Bjorn Jensen
68
- fn:Bj=F8rn Jensen
69
- n:Jensen;Bj=F8rn
70
- email;type=internet:bjorn@umich.edu
71
- tel;type=work,voice,msg:+1 313 747-4454
72
- key;type=x509;encoding=B:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK
73
- end:VCARD
74
- END
75
-
76
23
  def test_ex2
77
24
  card = nil
78
- ex2 = EX2
79
- assert_nothing_thrown { card = Vpim::Vcard.decode(ex2).first }
80
- assert_equal(EX2, card.encode(0))
25
+ assert_nothing_thrown { card = Vcard::Vcard.decode(vcard(:ex2)).first }
26
+ assert_equal(vcard(:ex2), card.encode(0))
81
27
  assert_raises(InvalidEncodingError) { card.version }
82
28
 
83
29
  assert_equal("Bj=F8rn Jensen", card.name.fullname)
@@ -116,68 +62,10 @@ end:VCARD
116
62
  card.lines
117
63
  end
118
64
 
119
- =begin
120
- EX3 = <<-END
121
- begin:vcard
122
- source:ldap://cn=Meister%20Berger,o=Universitaet%20Goerlitz,c=DE
123
- name:Meister Berger
124
- fn:Meister Berger
125
- n:Berger;Meister
126
- bday;value=date:1963-09-21
127
- o:Universit=E6t G=F6rlitz
128
- title:Mayor
129
- title;language=de;value=text:Burgermeister
130
- note:The Mayor of the great city of
131
- Goerlitz in the great country of Germany.
132
- email;internet:mb@goerlitz.de
133
- home.tel;type=fax,voice,msg:+49 3581 123456
134
- home.label:Hufenshlagel 1234\n
135
- 02828 Goerlitz\n
136
- Deutschland
137
- key;type=X509;encoding=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQ
138
- AwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zI
139
- ENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQD
140
- ExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc
141
- 1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW
142
- 9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBF
143
- hJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqG
144
- SIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXc
145
- oX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG+E
146
- IBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau+hUMbsQukjANBgkqhkiG9
147
- w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM+M
148
- SlhMfcpbTrONwNjZYW8vJDSoi//yrZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8V
149
- UMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ==
150
- end:vcard
151
- END
152
- assert_equal(
153
- ["other", "some.other"],
154
- card.groups_all
155
- )
156
- #a = []
157
- #card.enum_by_group("some.other").each { |field| a << field }
158
- #assert_equal(card.fields.indexes(6, 7, 8), a)
159
- #assert_equal(card.fields.indexes(6, 7, 8), card.fields_by_group("some.other"))
160
- =end
161
-
162
65
  # This is my vCard exported from OS X's AddressBook.app.
163
- EX_APPLE1 =<<'EOF'
164
- BEGIN:VCARD
165
- VERSION:3.0
166
- N:Roberts;Sam;;;
167
- FN:Roberts Sam
168
- EMAIL;type=HOME;type=pref:sroberts@uniserve.com
169
- TEL;type=WORK;type=pref:905-501-3781
170
- TEL;type=FAX:905-907-4230
171
- TEL;type=HOME:416 535 5341
172
- ADR;type=HOME;type=pref:;;376 Westmoreland Ave.;Toronto;ON;M6H 3
173
- A6;Canada
174
- NOTE:CATEGORIES: Amis/Famille
175
- BDAY;value=date:1970-07-14
176
- END:VCARD
177
- EOF
178
66
  def test_ex_apple1
179
67
  card = nil
180
- assert_nothing_thrown { card = Vpim::Vcard.decode(EX_APPLE1).first }
68
+ assert_nothing_thrown { card = Vcard::Vcard.decode(vcard(:ex_apple1)).first }
181
69
 
182
70
  assert_equal("Roberts Sam", card.name.fullname)
183
71
  assert_equal("Roberts", card.name.family)
@@ -185,54 +73,8 @@ EOF
185
73
  assert_equal("", card.name.prefix)
186
74
  assert_equal("", card.name.suffix)
187
75
 
188
- assert_equal(EX_APPLE1, card.to_s(64))
189
-
190
- check_ex_apple1(card)
191
- end
192
-
193
- NICKNAME0=<<'EOF'
194
- begin:vcard
195
- end:vcard
196
- EOF
197
- NICKNAME1=<<'EOF'
198
- begin:vcard
199
- nickname:
200
- end:vcard
201
- EOF
202
- NICKNAME2=<<'EOF'
203
- begin:vcard
204
- nickname:
205
- end:vcard
206
- EOF
207
- NICKNAME3=<<'EOF'
208
- begin:vcard
209
- nickname: Big Joey
210
- end:vcard
211
- EOF
212
- NICKNAME4=<<'EOF'
213
- begin:vcard
214
- nickname:
215
- nickname: Big Joey
216
- end:vcard
217
- EOF
218
- NICKNAME5=<<'EOF'
219
- begin:vcard
220
- nickname:
221
- nickname: Big Joey
222
- nickname:Bob
223
- end:vcard
224
- EOF
225
- def test_nickname
226
- assert_equal(nil, Vpim::Vcard.decode(NICKNAME0).first.nickname)
227
- assert_equal(nil, Vpim::Vcard.decode(NICKNAME1).first.nickname)
228
- assert_equal(nil, Vpim::Vcard.decode(NICKNAME2).first.nickname)
229
- assert_equal('Big Joey', Vpim::Vcard.decode(NICKNAME3).first.nickname)
230
- assert_equal('Big Joey', Vpim::Vcard.decode(NICKNAME4).first['nickname'])
231
- assert_equal(['Big Joey', 'Bob'], Vpim::Vcard.decode(NICKNAME5).first.nicknames)
232
- end
233
-
76
+ assert_equal(vcard(:ex_apple1), card.to_s(64))
234
77
 
235
- def check_ex_apple1(card)
236
78
  assert_equal("3.0", card[ "version" ])
237
79
  assert_equal(30, card.version)
238
80
 
@@ -254,8 +96,19 @@ EOF
254
96
  assert_equal("CATEGORIES: Amis/Famille", card[ "note" ])
255
97
  end
256
98
 
257
- # Test data for Vpim.expand
258
- EX_EXPAND =<<'EOF'
99
+ def test_nickname
100
+ assert_equal(nil, Vcard::Vcard.decode(vcard(:nickname0)).first.nickname)
101
+ assert_equal(nil, Vcard::Vcard.decode(vcard(:nickname1)).first.nickname)
102
+ assert_equal(nil, Vcard::Vcard.decode(vcard(:nickname2)).first.nickname)
103
+ assert_equal('Big Joey', Vcard::Vcard.decode(vcard(:nickname3)).first.nickname)
104
+ assert_equal('Big Joey', Vcard::Vcard.decode(vcard(:nickname4)).first['nickname'])
105
+ assert_equal(['Big Joey', 'Bob'], Vcard::Vcard.decode(vcard(:nickname5)).first.nicknames)
106
+ end
107
+
108
+
109
+ # Test data for Vcard.expand
110
+ def test_expand
111
+ ex_expand =<<'EOF'
259
112
  BEGIN:a
260
113
  a1:
261
114
  BEGIN:b
@@ -269,9 +122,8 @@ END:b
269
122
  a2:
270
123
  END:a
271
124
  EOF
272
- def test_expand
273
- src = Vpim.decode(EX_EXPAND)
274
- dst = Vpim.expand(src)
125
+ src = Vcard.decode(ex_expand)
126
+ dst = Vcard.expand(src)
275
127
 
276
128
  assert_equal('a', dst[0][0].value)
277
129
  assert_equal('A1', dst[0][1].name)
@@ -280,91 +132,23 @@ EOF
280
132
  assert_equal('C1', dst[0][2][1][1].name)
281
133
  assert_equal('C2', dst[0][2][1][2].name)
282
134
  assert_equal('c', dst[0][2][1][3].value)
283
-
284
- cards = Vpim::Vcard.decode(EX_APPLE1)
285
-
286
- assert_equal(1, cards.length)
287
-
288
- check_ex_apple1(cards[0])
289
135
  end
290
136
 
291
- # An iCalendar for Vpim.expand
292
- EX_ICAL_1 =<<'EOF'
293
- BEGIN:VCALENDAR
294
- CALSCALE:GREGORIAN
295
- X-WR-TIMEZONE;VALUE=TEXT:Canada/Eastern
296
- METHOD:PUBLISH
297
- PRODID:-//Apple Computer\, Inc//iCal 1.0//EN
298
- X-WR-RELCALID;VALUE=TEXT:18E75B8C-5722-11D7-AB0B-000393AD088C
299
- X-WR-CALNAME;VALUE=TEXT:Events
300
- VERSION:2.0
301
- BEGIN:VEVENT
302
- SEQUENCE:14
303
- UID:18E74C28-5722-11D7-AB0B-000393AD088C
304
- DTSTAMP:20030301T171521Z
305
- SUMMARY:Bob Log III
306
- DTSTART;TZID=Canada/Eastern:20030328T200000
307
- DTEND;TZID=Canada/Eastern:20030328T230000
308
- DESCRIPTION:Healey's\n\nLook up exact time.\n
309
- BEGIN:VALARM
310
- TRIGGER;VALUE=DURATION:-P2D
311
- ACTION:DISPLAY
312
- DESCRIPTION:Event reminder
313
- END:VALARM
314
- BEGIN:VALARM
315
- ATTENDEE:mailto:sroberts@uniserve.com
316
- TRIGGER;VALUE=DURATION:-P1D
317
- ACTION:EMAIL
318
- SUMMARY:Alarm notification
319
- DESCRIPTION:This is an event reminder
320
- END:VALARM
321
- END:VEVENT
322
- BEGIN:VEVENT
323
- SEQUENCE:1
324
- DTSTAMP:20030312T043534Z
325
- SUMMARY:Small Potatoes 10\nFriday\, March 14th\, 8:00 p.m.\n361 Danforth
326
- Avenue (at Hampton -- Chester subway)\nInfo:_ (416) 480-2802 or (416)
327
- 323-1715\n
328
- UID:18E750A8-5722-11D7-AB0B-000393AD088C
329
- DTSTART;TZID=Canada/Eastern:20030315T000000
330
- DURATION:PT1H
331
- BEGIN:VALARM
332
- ATTENDEE:mailto:sroberts@uniserve.com
333
- TRIGGER;VALUE=DURATION:-P1D
334
- ACTION:EMAIL
335
- SUMMARY:Alarm notification
336
- DESCRIPTION:This is an event reminder
337
- END:VALARM
338
- END:VEVENT
339
- END:VCALENDAR
340
- EOF
137
+ # An iCalendar for Vcard.expand
341
138
  def test_ical_1
342
139
  src = nil
343
140
  dst = nil
344
- assert_nothing_thrown {
345
- src = Vpim.decode(EX_ICAL_1)
346
- dst = Vpim.expand(src)
347
- }
348
-
349
- #p dst
141
+ assert_nothing_thrown do
142
+ src = Vcard.decode(vcal(:ex_ical_1))
143
+ dst = Vcard.expand(src)
144
+ end
350
145
  end
351
146
 
352
147
  # Constructed data.
353
- TST1 =<<'EOF'
354
- BEGIN:vCard
355
- DESCRIPTION:Healey's\n\nLook up exact time.\n
356
- email;type=work:work@example.com
357
- email;type=internet,home;type=pref:home@example.com
358
- fax;type=foo,pref;bar:fax
359
- name:firstname
360
- name:secondname
361
- time;value=time:
362
- END:vCARD
363
- EOF
364
148
  def _test_cons # FIXME
365
149
  card = nil
366
- assert_nothing_thrown { card = Vpim::Vcard.decode(TST1).first }
367
- assert_equal(TST1, card.to_s)
150
+ assert_nothing_thrown { card = Vcard::Vcard.decode(vcard(:tst1)).first }
151
+ assert_equal(vcard(:tst1), card.to_s)
368
152
  assert_equal('Healey\'s\n\nLook up exact time.\n', card[ "description" ])
369
153
 
370
154
  # Test the [] API
@@ -379,137 +163,61 @@ EOF
379
163
 
380
164
 
381
165
  # Test the merging of vCard 2.1 type fields.
382
- #p card
383
- #p card.enum_by_name('fax').entries[0].each_param { |p,v| puts "#{p} = #{v}\n" }
384
-
385
166
  assert_equal('fax', card[ "fax" ])
386
167
  assert_equal('fax', card[ "fax", 'bar' ])
387
168
  end
388
169
 
389
- =begin
390
170
  def test_bad
391
171
  # FIXME: this should THROW, it's badly encoded!
392
- assert_nothing_thrown {
393
- Vpim::Vcard.decode(
394
- "BEGIN:VCARD\nVERSION:3.0\nKEYencoding=b:this could be \nmy certificate\n\nEND:VCARD\n"
395
- )
396
- }
172
+ assert_raises(InvalidEncodingError) do
173
+ Vcard::Vcard.decode("BEGIN:VCARD\nVERSION:3.0\nKEYencoding=b:this could be \nmy certificate\n\nEND:VCARD\n")
174
+ end
397
175
  end
398
- =end
399
176
 
400
177
  def test_create
401
- card = Vpim::Vcard.create
178
+ card = Vcard::Vcard.create
402
179
 
403
- key = Vpim::DirectoryInfo.decode("key;type=x509;encoding=B:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK\n")['key']
180
+ key = Vcard::DirectoryInfo.decode("key;type=x509;encoding=B:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK\n")['key']
404
181
 
405
- card << Vpim::DirectoryInfo::Field.create('key', key, 'encoding' => :b64)
182
+ card << Vcard::DirectoryInfo::Field.create('key', key, 'encoding' => :b64)
406
183
 
407
184
  assert_equal(key, card['key'])
408
-
409
- #p card.to_s
410
185
  end
411
186
 
412
187
  def test_values
413
-
414
188
  # date
415
- assert_equal([2002, 4, 22], Vpim.decode_date(" 20020422 "))
416
- assert_equal([2002, 4, 22], Vpim.decode_date(" 2002-04-22 "))
417
- assert_equal([2002, 4, 22], Vpim.decode_date(" 2002-04-22 \n"))
418
-
419
- assert_equal([[2002, 4, 22]],
420
- Vpim.decode_date_list(" 2002-04-22 "))
421
-
422
- assert_equal([[2002, 4, 22],[2002, 4, 22]],
423
- Vpim.decode_date_list(" 2002-04-22, 2002-04-22,"))
424
-
425
- assert_equal([[2002, 4, 22],[2002, 4, 22]],
426
- Vpim.decode_date_list(" 2002-04-22,,, , ,2002-04-22, , \n"))
427
-
428
- assert_equal([],
429
- Vpim.decode_date_list(" , , "))
189
+ assert_equal [2002, 4, 22], Vcard.decode_date(" 20020422 ")
190
+ assert_equal [2002, 4, 22], Vcard.decode_date(" 2002-04-22 ")
191
+ assert_equal [2002, 4, 22], Vcard.decode_date(" 2002-04-22 \n")
192
+ assert_equal [[2002, 4, 22]], Vcard.decode_date_list(" 2002-04-22 ")
193
+ assert_equal [[2002, 4, 22],[2002, 4, 22]], Vcard.decode_date_list(" 2002-04-22, 2002-04-22,")
194
+ assert_equal [[2002, 4, 22],[2002, 4, 22]], Vcard.decode_date_list(" 2002-04-22,,, , ,2002-04-22, , \n")
195
+ assert_equal [], Vcard.decode_date_list(" , , ")
430
196
 
431
197
  # time
432
- assert_equal(
433
- [4, 53, 22, 0, nil],
434
- Vpim.decode_time(" 04:53:22 \n")
435
- )
436
- assert_equal(
437
- [4, 53, 22, 0.10, nil],
438
- Vpim.decode_time(" 04:53:22.10 \n")
439
- )
440
- assert_equal(
441
- [4, 53, 22, 0.10, "Z"],
442
- Vpim.decode_time(" 04:53:22.10Z \n")
443
- )
444
- assert_equal(
445
- [4, 53, 22, 0, "Z"],
446
- Vpim.decode_time(" 045322Z \n")
447
- )
448
- assert_equal(
449
- [4, 53, 22, 0, "+0530"],
450
- Vpim.decode_time(" 04:5322+0530 \n")
451
- )
452
- assert_equal(
453
- [4, 53, 22, 0.10, "Z"],
454
- Vpim.decode_time(" 045322.10Z \n")
455
- )
198
+ assert_equal [4, 53, 22, 0, nil], Vcard.decode_time(" 04:53:22 \n")
199
+ assert_equal [4, 53, 22, 0.10, nil], Vcard.decode_time(" 04:53:22.10 \n")
200
+ assert_equal [4, 53, 22, 0.10, "Z"], Vcard.decode_time(" 04:53:22.10Z \n")
201
+ assert_equal [4, 53, 22, 0, "Z"], Vcard.decode_time(" 045322Z \n")
202
+ assert_equal [4, 53, 22, 0, "+0530"], Vcard.decode_time(" 04:5322+0530 \n")
203
+ assert_equal [4, 53, 22, 0.10, "Z"], Vcard.decode_time(" 045322.10Z \n")
456
204
 
457
205
  # date-time
458
- assert_equal(
459
- [2002, 4, 22, 4, 53, 22, 0, nil],
460
- Vpim.decode_date_time("20020422T04:53:22 \n")
461
- )
462
- assert_equal(
463
- [2002, 4, 22, 4, 53, 22, 0.10, nil],
464
- Vpim.decode_date_time(" 2002-04-22T04:53:22.10 \n")
465
- )
466
- assert_equal(
467
- [2002, 4, 22, 4, 53, 22, 0.10, "Z"],
468
- Vpim.decode_date_time(" 20020422T04:53:22.10Z \n")
469
- )
470
- assert_equal(
471
- [2002, 4, 22, 4, 53, 22, 0, "Z"],
472
- Vpim.decode_date_time(" 20020422T045322Z \n")
473
- )
474
- assert_equal(
475
- [2002, 4, 22, 4, 53, 22, 0, "+0530"],
476
- Vpim.decode_date_time(" 20020422T04:5322+0530 \n")
477
- )
478
- assert_equal(
479
- [2002, 4, 22, 4, 53, 22, 0.10, "Z"],
480
- Vpim.decode_date_time(" 20020422T045322.10Z \n")
481
- )
482
- assert_equal(
483
- [2003, 3, 25, 3, 20, 35, 0, "Z"],
484
- Vpim.decode_date_time("20030325T032035Z")
485
- )
206
+ assert_equal [2002, 4, 22, 4, 53, 22, 0, nil], Vcard.decode_date_time("20020422T04:53:22 \n")
207
+ assert_equal [2002, 4, 22, 4, 53, 22, 0.10, nil], Vcard.decode_date_time(" 2002-04-22T04:53:22.10 \n")
208
+ assert_equal [2002, 4, 22, 4, 53, 22, 0.10, "Z"], Vcard.decode_date_time(" 20020422T04:53:22.10Z \n")
209
+ assert_equal [2002, 4, 22, 4, 53, 22, 0, "Z"], Vcard.decode_date_time(" 20020422T045322Z \n")
210
+ assert_equal [2002, 4, 22, 4, 53, 22, 0, "+0530"], Vcard.decode_date_time(" 20020422T04:5322+0530 \n")
211
+ assert_equal [2002, 4, 22, 4, 53, 22, 0.10, "Z"], Vcard.decode_date_time(" 20020422T045322.10Z \n")
212
+ assert_equal [2003, 3, 25, 3, 20, 35, 0, "Z"], Vcard.decode_date_time("20030325T032035Z")
486
213
 
487
214
  # text
488
- assert_equal(
489
- "aa,\n\n,\\,\\a;;b",
490
- Vpim.decode_text('aa,\\n\\n,\\\\\,\\\\a\;\;b')
491
- )
492
- assert_equal(
493
- ['', "1\n2,3", "bbb", '', "zz", ''],
494
- Vpim.decode_text_list(',1\\n2\\,3,bbb,,zz,')
495
- )
215
+ assert_equal "aa,\n\n,\\,\\a;;b", Vcard.decode_text('aa,\\n\\n,\\\\\,\\\\a\;\;b')
216
+ assert_equal ['', "1\n2,3", "bbb", '', "zz", ''], Vcard.decode_text_list(',1\\n2\\,3,bbb,,zz,')
496
217
  end
497
218
 
498
- EX_ENCODE_1 =<<'EOF'
499
- BEGIN:VCARD
500
- VERSION:3.0
501
- N:Roberts;Sam;;;
502
- FN:Roberts Sam
503
- EMAIL;type=HOME;type=pref:sroberts@uniserve.com
504
- TEL;type=HOME:416 535 5341
505
- ADR;type=HOME;type=pref:;;376 Westmoreland Ave.;Toronto;ON;M6H 3A6;Canada
506
- NOTE:CATEGORIES: Amis/Famille
507
- BDAY;value=date:1970-07-14
508
- END:VCARD
509
- EOF
510
-
511
219
  def test_create_1
512
- card = Vpim::Vcard.create
220
+ card = Vcard::Vcard.create
513
221
 
514
222
  card << DirectoryInfo::Field.create('n', 'Roberts;Sam;;;')
515
223
  card << DirectoryInfo::Field.create('fn', 'Roberts Sam')
@@ -520,23 +228,10 @@ EOF
520
228
  card << DirectoryInfo::Field.create('adr', ';;376 Westmoreland Ave.;Toronto;ON;M6H 3A6;Canada', 'type' => ['home', 'pref'])
521
229
  # TODO - allow the date to be a Date, and for value to be set correctly
522
230
  card << DirectoryInfo::Field.create('bday', Date.new(1970, 7, 14), 'value' => 'date')
523
-
524
- # puts card.to_s
525
231
  end
526
232
 
527
- EX_BDAYS = <<'EOF'
528
- BEGIN:VCARD
529
- BDAY;value=date:206-12-15
530
- END:VCARD
531
- BEGIN:VCARD
532
- BDAY;value=date:2003-12-09
533
- END:VCARD
534
- BEGIN:VCARD
535
- END:VCARD
536
- EOF
537
-
538
233
  def test_birthday
539
- cards = Vpim::Vcard.decode(EX_BDAYS)
234
+ cards = Vcard::Vcard.decode(vcard(:ex_bdays))
540
235
 
541
236
  expected = [
542
237
  Date.new(Time.now.year, 12, 15),
@@ -544,81 +239,37 @@ EOF
544
239
  nil
545
240
  ]
546
241
 
547
- expected.each_with_index do | d, i|
548
- #pp d
549
- #pp i
550
- #pp cards[i]
551
- #pp cards[i].birthday.to_s
552
- #pp cards[i].birthday.class
553
- assert_equal(d, cards[i].birthday)
554
- end
555
-
242
+ expected.each_with_index { | d, i| assert_equal(d, cards[i].birthday) }
556
243
  end
557
244
 
558
- EX_ATTACH=<<'---'
559
- BEGIN:VCARD
560
- VERSION:3.0
561
- N:Middle Family;Ny_full
562
- PHOTO:val\nue
563
- PHOTO;encoding=8bit:val\nue
564
- PHOTO;encoding=8bit:val\nue
565
- PHOTO;encoding=8bit;type=atype:val\nue
566
- PHOTO;value=binary;encoding=8bit:val\nue
567
- PHOTO;value=binary;encoding=8bit:val\nue
568
- PHOTO;value=binary;encoding=8bit;type=atype:val\nue
569
- PHOTO;value=text;encoding=8bit:val\nue
570
- PHOTO;value=text;encoding=8bit:val\nue
571
- PHOTO;value=text;encoding=8bit;type=atype:val\nue
572
- PHOTO;value=uri:my://
573
- PHOTO;value=uri;type=atype:my://
574
- END:VCARD
575
- ---
576
245
  def test_attach
577
- card = Vpim::Vcard.decode(EX_ATTACH).first
246
+ card = Vcard::Vcard.decode(vcard(:ex_attach)).first
578
247
  card.lines # FIXME - assert values are as expected
579
248
  end
580
249
 
581
- EX_21=<<'---'
582
- BEGIN:VCARD
583
- VERSION:2.1
584
- X-EVOLUTION-FILE-AS:AAA Our Fax
585
- FN:AAA Our Fax
586
- N:AAA Our Fax
587
- ADR;WORK;PREF:
588
- LABEL;WORK;PREF:
589
- TEL;WORK;FAX:925 833-7660
590
- TEL;HOME;FAX:925 833-7660
591
- TEL;VOICE:1
592
- TEL;FAX:2
593
- EMAIL;INTERNET:e@c
594
- TITLE:
595
- NOTE:
596
- UID:pas-id-3F93E22900000001
597
- END:VCARD
598
- ---
599
250
  def test_v21_modification
600
- card0 = Vpim::Vcard.decode(EX_21).first
601
- card1 = Vpim::Vcard::Maker.make2(card0) do |maker|
251
+ card0 = Vcard::Vcard.decode(vcard(:ex_21)).first
252
+ card1 = Vcard::Vcard::Maker.make2(card0) do |maker|
602
253
  maker.nickname = 'nickname'
603
254
  end
604
- card2 = Vpim::Vcard.decode(card1.encode).first
255
+ card2 = Vcard::Vcard.decode(card1.encode).first
605
256
 
606
257
  assert_equal(card0.version, card1.version)
607
258
  assert_equal(card0.version, card2.version)
608
259
  end
609
260
 
610
261
  def test_v21_versioned_copy
611
- card0 = Vpim::Vcard.decode(EX_21).first
612
- card1 = Vpim::Vcard::Maker.make2(Vpim::DirectoryInfo.create([], 'VCARD')) do |maker|
262
+ card0 = Vcard::Vcard.decode(vcard(:ex_21)).first
263
+ card1 = Vcard::Vcard::Maker.make2(Vcard::DirectoryInfo.create([], 'VCARD')) do |maker|
613
264
  maker.copy card0
614
265
  end
615
- card2 = Vpim::Vcard.decode(card1.encode).first
266
+ card2 = Vcard::Vcard.decode(card1.encode).first
616
267
 
617
268
  assert_equal(card0.version, card2.version)
618
269
  end
619
270
 
620
271
  def test_v21_strip_version
621
- card0 = Vpim::Vcard.decode(EX_21).first
272
+ card0 = Vcard::Vcard.decode(vcard(:ex_21)).first
622
273
 
623
274
  card0.delete card0.field('VERSION')
624
275
  card0.delete card0.field('TEL')
@@ -633,37 +284,18 @@ END:VCARD
633
284
  card0.delete card0.field('BEGIN')
634
285
  end
635
286
 
636
- card1 = Vpim::Vcard::Maker.make2(Vpim::DirectoryInfo.create([], 'VCARD')) do |maker|
287
+ card1 = Vcard::Vcard::Maker.make2(Vcard::DirectoryInfo.create([], 'VCARD')) do |maker|
637
288
  maker.copy card0
638
289
  end
639
- card2 = Vpim::Vcard.decode(card1.encode).first
290
+ card2 = Vcard::Vcard.decode(card1.encode).first
640
291
 
641
292
  assert_equal(30, card2.version)
642
293
  assert_equal(nil, card2.field('TEL'))
643
294
  end
644
295
 
645
296
 
646
- EX_21_CASE0=<<'---'
647
- BEGIN:VCARD
648
- VERSION:2.1
649
- N:Middle Family;Ny_full
650
- TEL;PREF;HOME;VOICE:0123456789
651
- TEL;FAX:0123456789
652
- TEL;CELL;VOICE:0123456789
653
- TEL;HOME;VOICE:0123456789
654
- TEL;WORK;VOICE:0123456789
655
- EMAIL:email@email.com
656
- EMAIL:work@work.com
657
- URL:www.email.com
658
- URL:www.work.com
659
- LABEL;CHARSET=ISO-8859-1;ENCODING=QUOTED-PRINTABLE:Box 1234=0AWorkv=E4gen =
660
- 2=0AWorkv=E4gen 1=0AUme=E5=0AV=E4sterbotten=0A12345=0AS
661
- END:VCARD
662
- ---
663
297
  def test_v21_case0
664
- card = Vpim::Vcard.decode(EX_21_CASE0).first
665
- # pp card.field('LABEL').value_raw
666
- # pp card.field('LABEL').value
298
+ Vcard::Vcard.decode(vcard(:ex_21_case0)).first
667
299
  end
668
300
 
669
301
  def test_modify_name
@@ -715,7 +347,7 @@ END:VCARD
715
347
  def test_add_note
716
348
  note = "hi\' \ \"\",,;; \n \n field"
717
349
 
718
- card = Vpim::Vcard::Maker.make2 do |m|
350
+ card = Vcard::Vcard::Maker.make2 do |m|
719
351
  m.add_note(note)
720
352
  m.name {}
721
353
  end
@@ -724,40 +356,20 @@ END:VCARD
724
356
  end
725
357
 
726
358
  def test_empty_tel
727
- cin = <<___
728
- BEGIN:VCARD
729
- TEL;HOME;FAX:
730
- END:VCARD
731
- ___
732
-
733
- card = Vpim::Vcard.decode(cin).first
359
+ card = Vcard::Vcard.decode(vcard(:empty_tel)).first
734
360
  assert_equal(card.telephone, nil)
735
361
  assert_equal(card.telephone('HOME'), nil)
736
362
  assert_equal([], card.telephones)
737
-
738
363
  end
739
364
 
740
365
  def test_slash_in_field_name
741
- cin = <<___
742
- BEGIN:VCARD
743
- X-messaging/xmpp-All:some@jabber.id
744
- END:VCARD
745
- ___
746
-
747
- card = Vpim::Vcard.decode(cin).first
366
+ card = Vcard::Vcard.decode(vcard(:slash_in_field_name)).first
748
367
  assert_equal(card.value("X-messaging/xmpp-All"), "some@jabber.id")
749
368
  assert_equal(card["X-messaging/xmpp-All"], "some@jabber.id")
750
369
  end
751
370
 
752
371
  def test_url_decode
753
- cin=<<'---'
754
- BEGIN:VCARD
755
- URL:www.email.com
756
- URL:www.work.com
757
- END:VCARD
758
- ---
759
- card = Vpim::Vcard.decode(cin).first
760
-
372
+ card = Vcard::Vcard.decode(vcard(:url_decode)).first
761
373
  assert_equal("www.email.com", card.url.uri)
762
374
  assert_equal("www.email.com", card.url.uri.to_s)
763
375
  assert_equal("www.email.com", card.urls.first.uri)
@@ -765,12 +377,7 @@ END:VCARD
765
377
  end
766
378
 
767
379
  def test_bday_decode
768
- cin=<<'---'
769
- BEGIN:VCARD
770
- BDAY:1970-07-14
771
- END:VCARD
772
- ---
773
- card = Vpim::Vcard.decode(cin).first
380
+ card = Vcard::Vcard.decode(vcard(:bday_decode)).first
774
381
 
775
382
  card.birthday
776
383
 
@@ -779,16 +386,10 @@ END:VCARD
779
386
 
780
387
  # Nobody should have multiple bdays, I hope, but its allowed syntactically,
781
388
  # so test it, along with some variant forms of BDAY
782
- cin=<<'---'
783
- BEGIN:VCARD
784
- BDAY:1970-07-14
785
- BDAY:70-7-14
786
- BDAY:1970-07-15T03:45:12
787
- BDAY:1970-07-15T03:45:12Z
788
- END:VCARD
789
- ---
790
- card = Vpim::Vcard.decode(cin).first
389
+ end
791
390
 
391
+ def test_bday_decode_2
392
+ card = Vcard::Vcard.decode(vcard(:bday_decode_2)).first
792
393
  assert_equal(Date.new(1970, 7, 14), card.birthday)
793
394
  assert_equal(4, card.values("bday").size)
794
395
  assert_equal(Date.new(1970, 7, 14), card.values("bday").first)
@@ -797,24 +398,6 @@ END:VCARD
797
398
  assert_equal(DateTime.new(1970, 7, 15, 3, 45, 12).to_s, card.values("bday").last.to_s)
798
399
  end
799
400
 
800
- def utf_name_test(c)
801
-
802
- begin
803
- card = Vpim::Vcard.decode(c).first
804
- assert_equal("name", card.name.family)
805
- rescue
806
- $!.message << " #{c.inspect}"
807
- raise
808
- end
809
- end
810
-
811
- def be(s)
812
- s.unpack('U*').pack('n*')
813
- end
814
- def le(s)
815
- s.unpack('U*').pack('v*')
816
- end
817
-
818
401
  def test_utf_heuristics
819
402
  bom = "\xEF\xBB\xBF"
820
403
  dat = "BEGIN:VCARD\nN:name\nEND:VCARD\n"
@@ -836,58 +419,14 @@ END:VCARD
836
419
 
837
420
  # Broken output from Highrise. Report to support@highrisehq.com
838
421
  def test_highrises_invalid_google_talk_field
839
- c = <<'__'
840
- BEGIN:VCARD
841
- VERSION:3.0
842
- REV:20080409T095515Z
843
- X-YAHOO;TYPE=HOME:yahoo.john
844
- X-GOOGLE TALK;TYPE=WORK:gtalk.john
845
- X-SAMETIME;TYPE=WORK:sametime.john
846
- X-SKYPE;TYPE=WORK:skype.john
847
- X-MSN;TYPE=WORK:msn.john
848
- X-JABBER;TYPE=WORK:jabber.john
849
- N:Doe;John;;;
850
- ADR;TYPE=WORK:;;456 Grandview Building\, Wide Street;San Diego;CA;90204;
851
- United States
852
- ADR;TYPE=HOME:;;123 Sweet Home\, Narrow Street;New York;NY;91102;United
853
- States
854
- URL;TYPE=OTHER:http\://www.homepage.com
855
- URL;TYPE=HOME:http\://www.home.com
856
- URL;TYPE=WORK:http\://www.work.com
857
- URL;TYPE=OTHER:http\://www.other.com
858
- URL;TYPE=OTHER:http\://www.custom.com
859
- ORG:John Doe & Partners Limited;;
860
- TEL;TYPE=WORK:11111111
861
- TEL;TYPE=CELL:22222222
862
- TEL;TYPE=HOME:33333333
863
- TEL;TYPE=OTHER:44444444
864
- TEL;TYPE=FAX:55555555
865
- TEL;TYPE=FAX:66666666
866
- TEL;TYPE=PAGER:77777777
867
- TEL;TYPE=OTHER:88888888
868
- TEL;TYPE=OTHER:99999999
869
- UID:cc548e11-569e-3bf5-a9aa-722de4571f4a
870
- X-ICQ;TYPE=HOME:icq.john
871
- EMAIL;TYPE=WORK,INTERNET:john.doe@work.com
872
- EMAIL;TYPE=HOME,INTERNET:john.doe@home.com
873
- EMAIL;TYPE=OTHER,INTERNET:john.doe@other.com
874
- EMAIL;TYPE=OTHER,INTERNET:john.doe@custom.com
875
- TITLE:Sales Manager
876
- X-OTHER;TYPE=WORK:other.john
877
- X-AIM;TYPE=WORK:aim.john
878
- X-QQ;TYPE=WORK:qq.john
879
- FN:John Doe
880
- END:VCARD
881
- __
882
-
883
- card = Vpim::Vcard.decode(c).first
422
+ c = vcard(:highrise)
423
+ card = Vcard::Vcard.decode(c).first
884
424
  assert_equal("Doe", card.name.family)
885
425
  assert_equal("456 Grandview Building, Wide Street", card.address('work').street)
886
426
  assert_equal("123 Sweet Home, Narrow Street", card.address('home').street)
887
427
  assert_equal("John Doe & Partners Limited", card.org.first)
888
428
  assert_equal("gtalk.john", card.value("x-google talk"))
889
429
  assert_equal("http\\://www.homepage.com", card.url.uri)
890
-
891
430
  end
892
431
 
893
432
  def _test_gmail_vcard_export
@@ -895,42 +434,14 @@ __
895
434
  # line continuation.
896
435
  # GOOGLE BUG - vCards are being exported with embedded "=" in them, so
897
436
  # become unparseable.
898
- c = <<'__'
899
- BEGIN:VCARD
900
- VERSION:3.0
901
- FN:Stepcase TestUser
902
- N:TestUser;Stepcase;;;
903
- EMAIL;TYPE=INTERNET:testuser@stepcase.com
904
- X-GTALK:gtalk.step
905
- X-AIM:aim.step
906
- X-YAHOO:yahoo.step
907
- X-MSN:msn.step
908
- X-ICQ:icq.step
909
- X-JABBER:jabber.step
910
- TEL;TYPE=FAX:44444444
911
- TEL;TYPE=PAGER:66666666
912
- TEL;TYPE=HOME:22222222
913
- TEL;TYPE=CELL:11111111
914
- TEL;TYPE=FAX:55555555
915
- TEL;TYPE=WORK:33333333
916
- LABEL;TYPE=HOME;ENCODING=QUOTED-PRINTABLE:123 Home, Home Street=0D=0A=
917
- Kowloon, N/A=0D=0A=
918
- Hong Kong
919
- LABEL;TYPE=HOME;ENCODING=QUOTED-PRINTABLE:321 Office, Work Road=0D=0A=
920
- Tsuen Wan NT=0D=0A=
921
- Hong Kong
922
- TITLE:CTO
923
- ORG:Stepcase.com
924
- NOTE:Stepcase test user is a robot.
925
- END:VCARD
926
- __
927
- card = Vpim::Vcard.decode(c).first
437
+ c = vcard(:gmail)
438
+ card = Vcard::Vcard.decode(c).first
928
439
  assert_equal("123 Home, Home Street\r\n Kowloon, N/A\r\n Hong Kong", card.value("label"))
929
440
  end
930
441
 
931
442
  def test_title
932
443
  title = "She Who Must Be Obeyed"
933
- card = Vpim::Vcard::Maker.make2 do |m|
444
+ card = Vcard::Vcard::Maker.make2 do |m|
934
445
  m.name do |n|
935
446
  n.given = "Hilda"
936
447
  n.family = "Rumpole"
@@ -938,12 +449,12 @@ __
938
449
  m.title = title
939
450
  end
940
451
  assert_equal(title, card.title)
941
- card = Vpim::Vcard.decode(card.encode).first
452
+ card = Vcard::Vcard.decode(card.encode).first
942
453
  assert_equal(title, card.title)
943
454
  end
944
455
 
945
456
  def _test_org(*org)
946
- card = Vpim::Vcard::Maker.make2 do |m|
457
+ card = Vcard::Vcard::Maker.make2 do |m|
947
458
  m.name do |n|
948
459
  n.given = "Hilda"
949
460
  n.family = "Rumpole"
@@ -951,7 +462,7 @@ __
951
462
  m.org = org
952
463
  end
953
464
  assert_equal(org, card.org)
954
- card = Vpim::Vcard.decode(card.encode).first
465
+ card = Vcard::Vcard.decode(card.encode).first
955
466
  assert_equal(org, card.org)
956
467
  end
957
468
 
@@ -962,6 +473,5 @@ __
962
473
  def test_org_multiple
963
474
  _test_org("Megamix Corp.", "Marketing")
964
475
  end
965
-
966
476
  end
967
477