vcard 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,7 +54,7 @@ module Vcard
54
54
 
55
55
  # Convert a RFC 2425 date into an array of [year, month, day].
56
56
  def self.decode_date(v) # :nodoc:
57
- unless v =~ %r{^\s*#{Bnf::DATE}\s*$}
57
+ if !(v =~ Bnf::DATE)
58
58
  raise ::Vcard::InvalidEncodingError, "date not valid (#{v})"
59
59
  end
60
60
  [$1.to_i, $2.to_i, $3.to_i]
@@ -85,7 +85,7 @@ module Vcard
85
85
 
86
86
  # Convert a RFC 2425 time into an array of [hour,min,sec,secfrac,timezone]
87
87
  def self.decode_time(v) # :nodoc:
88
- unless match = %r{^\s*#{Bnf::TIME}\s*$}.match(v)
88
+ if !(match = Bnf::TIME.match(v))
89
89
  raise ::Vcard::InvalidEncodingError, "time '#{v}' not valid"
90
90
  end
91
91
  hour, min, sec, secfrac, tz = match.to_a[1..5]
@@ -94,13 +94,11 @@ module Vcard
94
94
  end
95
95
 
96
96
  def self.array_datetime_to_time(dtarray) #:nodoc:
97
- # We get [ year, month, day, hour, min, sec, usec, tz ]
98
- begin
99
- tz = (dtarray.pop == "Z") ? :gm : :local
100
- Time.send(tz, *dtarray)
101
- rescue ArgumentError => e
102
- raise ::Vcard::InvalidEncodingError, "#{tz} #{e} (#{dtarray.join(', ')})"
103
- end
97
+ # We get [ year, month, day, hour, min, sec, usec, tz ]
98
+ tz = (dtarray.pop == "Z") ? :gm : :local
99
+ Time.send(tz, *dtarray)
100
+ rescue ArgumentError => e
101
+ raise ::Vcard::InvalidEncodingError, "#{tz} #{e} (#{dtarray.join(', ')})"
104
102
  end
105
103
 
106
104
  # Convert a RFC 2425 time into an array of Time objects.
@@ -110,7 +108,7 @@ module Vcard
110
108
 
111
109
  # Convert a RFC 2425 date-time into an array of [year,mon,day,hour,min,sec,secfrac,timezone]
112
110
  def self.decode_date_time(v) # :nodoc:
113
- unless match = %r{^\s*#{Bnf::DATE}T#{Bnf::TIME}\s*$}.match(v)
111
+ if !(match = Bnf::DATE_TIME.match(v))
114
112
  raise ::Vcard::InvalidEncodingError, "date-time '#{v}' not valid"
115
113
  end
116
114
  year, month, day, hour, min, sec, secfrac, tz = match.to_a[1..8]
@@ -137,7 +135,7 @@ module Vcard
137
135
 
138
136
  # Convert an RFC2425 INTEGER value into an Integer
139
137
  def self.decode_integer(v) # :nodoc:
140
- unless %r{\s*#{Bnf::INTEGER}\s*}.match(v)
138
+ if !(v =~ Bnf::INTEGER)
141
139
  raise ::Vcard::InvalidEncodingError, "integer not valid (#{v})"
142
140
  end
143
141
  v.to_i
@@ -227,8 +225,7 @@ module Vcard
227
225
  # paramtext = *SAFE-CHAR
228
226
  # quoted-string = DQUOTE *QSAFE-CHAR DQUOTE
229
227
  def self.encode_paramtext(value)
230
- case value
231
- when %r{\A#{Bnf::SAFECHAR}*\z}
228
+ if value =~ Bnf::ALL_SAFECHARS
232
229
  value
233
230
  else
234
231
  raise ::Vcard::Unencodable, "paramtext #{value.inspect}"
@@ -236,17 +233,15 @@ module Vcard
236
233
  end
237
234
 
238
235
  def self.encode_paramvalue(value)
239
- case value
240
- when %r{\A#{Bnf::SAFECHAR}*\z}
236
+ if value =~ Bnf::ALL_SAFECHARS
241
237
  value
242
- when %r{\A#{Bnf::QSAFECHAR}*\z}
238
+ elsif value =~ Bnf::ALL_QSAFECHARS
243
239
  '"' + value + '"'
244
240
  else
245
241
  raise ::Vcard::Unencodable, "param-value #{value.inspect}"
246
242
  end
247
243
  end
248
244
 
249
-
250
245
  # Unfold the lines in +card+, then return an array of one Field object per
251
246
  # line.
252
247
  def self.decode(card) #:nodoc:
@@ -5,43 +5,41 @@
5
5
  # VPIM-LICENSE.txt for details.
6
6
 
7
7
  module Vcard
8
- # Contains regular expression strings for the EBNF of RFC 2425.
8
+ # Contains regular expressions for the EBNF of RFC 2425.
9
9
  module Bnf #:nodoc:
10
10
 
11
11
  # 1*(ALPHA / DIGIT / "-")
12
- # Note: I think I can add A-Z here, and get rid of the "i" matches elsewhere.
13
- # Note: added "_" to allowed because its produced by Notes (X-LOTUS-CHILD_UID:)
14
- # Note: added "/" to allowed because its produced by KAddressBook (X-messaging/xmpp-All:)
15
- # Note: added " " to allowed because its produced by highrisehq.com (X-GOOGLE TALK:)
16
- NAME = "[-a-z0-9_/][-a-z0-9_/ ]*"
12
+ # Note: "_" allowed because produced by Notes (X-LOTUS-CHILD_UID:)
13
+ # Note: "/" allowed because produced by KAddressBook (X-messaging/xmpp-All:)
14
+ # Note: " " allowed because produced by highrisehq.com (X-GOOGLE TALK:)
15
+ NAME = /[\w\/-][ \w\/-]*/
17
16
 
18
17
  # <"> <Any character except CTLs, DQUOTE> <">
19
- QSTR = '"([^"]*)"'
18
+ QSTR = /"([^"]*)"/
20
19
 
21
20
  # *<Any character except CTLs, DQUOTE, ";", ":", ",">
22
- PTEXT = '([^";:,]+)'
21
+ PTEXT = /([^";:,]+)/
23
22
 
24
23
  # param-value = ptext / quoted-string
25
- PVALUE = "(?:#{QSTR}|#{PTEXT})"
24
+ PVALUE = /(?:#{QSTR}|#{PTEXT})/
26
25
 
27
26
  # param = name "=" param-value *("," param-value)
28
27
  # Note: v2.1 allows a type or encoding param-value to appear without the type=
29
28
  # or the encoding=. This is hideous, but we try and support it, if there
30
29
  # is no "=", then $2 will be "", and we will treat it as a v2.1 param.
31
- PARAM = ";(#{NAME})(=?)((?:#{PVALUE})?(?:,#{PVALUE})*)"
30
+ PARAM = /;(#{NAME})(=?)((?:#{PVALUE})?(?:,#{PVALUE})*)/
32
31
 
33
32
  # V3.0: contentline = [group "."] name *(";" param) ":" value
34
33
  # V2.1: contentline = *( group "." ) name *(";" param) ":" value
35
- #
36
34
  # We accept the V2.1 syntax for backwards compatibility.
37
- #LINE = "((?:#{NAME}\\.)*)?(#{NAME})([^:]*)\:(.*)"
38
- LINE = "^((?:#{NAME}\\.)*)?(#{NAME})((?:#{PARAM})*):(.*)$"
35
+ LINE = /\A((?:#{NAME}\.)*)?(#{NAME})((?:#{PARAM})*):(.*)\z/
39
36
 
40
37
  # date = date-fullyear ["-"] date-month ["-"] date-mday
41
38
  # date-fullyear = 4 DIGIT
42
39
  # date-month = 2 DIGIT
43
40
  # date-mday = 2 DIGIT
44
- DATE = "(\d\d\d\d)-?(\d\d)-?(\d\d)"
41
+ DATE_PARTIAL = /(\d\d\d\d)-?(\d\d)-?(\d\d)/
42
+ DATE = /\A\s*#{DATE_PARTIAL}\s*\z/
45
43
 
46
44
  # time = time-hour [":"] time-minute [":"] time-second [time-secfrac] [time-zone]
47
45
  # time-hour = 2 DIGIT
@@ -50,17 +48,23 @@ module Vcard
50
48
  # time-secfrac = "," 1*DIGIT
51
49
  # time-zone = "Z" / time-numzone
52
50
  # time-numzone = sign time-hour [":"] time-minute
53
- TIME = "(\d\d):?(\d\d):?(\d\d)(\.\d+)?(Z|[-+]\d\d:?\d\d)?"
51
+ TIME_PARTIAL = /(\d\d):?(\d\d):?(\d\d)(\.\d+)?(Z|[-+]\d\d:?\d\d)?/
52
+ TIME = /\A\s*#{TIME_PARTIAL}\s*\z/
53
+
54
+ # date-time = date "T" time
55
+ DATE_TIME = /\A\s*#{DATE_PARTIAL}T#{TIME_PARTIAL}\s*\z/
54
56
 
55
57
  # integer = (["+"] / "-") 1*DIGIT
56
- INTEGER = "[-+]?\d+"
58
+ INTEGER = /\A\s*[-+]?\d+\s*\z/
57
59
 
58
60
  # QSAFE-CHAR = WSP / %x21 / %x23-7E / NON-US-ASCII
59
61
  # ; Any character except CTLs and DQUOTE
60
- QSAFECHAR = "[ \t\x21\x23-\x7e\x80-\xff]"
62
+ QSAFECHAR = /[ \t\x21\x23-\x7e\x80-\xff]/
63
+ ALL_QSAFECHARS = /\A#{QSAFECHAR}*\z/
61
64
 
62
65
  # SAFE-CHAR = WSP / %x21 / %x23-2B / %x2D-39 / %x3C-7E / NON-US-ASCII
63
66
  # ; Any character except CTLs, DQUOTE, ";", ":", ","
64
- SAFECHAR = "[ \t\x21\x23-\x2b\x2d-\x39\x3c-\x7e\x80-\xff]"
67
+ SAFECHAR = /[ \t\x21\x23-\x2b\x2d-\x39\x3c-\x7e\x80-\xff]/
68
+ ALL_SAFECHARS = /\A#{SAFECHAR}*\z/
65
69
  end
66
70
  end
@@ -100,7 +100,7 @@ module Vcard
100
100
 
101
101
  # Decode a field.
102
102
  def Field.decode0(atline) # :nodoc:
103
- unless atline =~ %r{#{Bnf::LINE}}i
103
+ if !(atline =~ Bnf::LINE)
104
104
  raise ::Vcard::InvalidEncodingError, atline
105
105
  end
106
106
 
@@ -126,7 +126,7 @@ module Vcard
126
126
  if paramslist.size > 1
127
127
 
128
128
  # v3.0 and v2.1 params
129
- paramslist.scan( %r{#{Bnf::PARAM}}i ) do
129
+ paramslist.scan( Bnf::PARAM ) do
130
130
 
131
131
  # param names are case-insensitive, and multi-valued
132
132
  name = $1.upcase
@@ -156,7 +156,7 @@ module Vcard
156
156
  atparams[name] = []
157
157
  end
158
158
 
159
- params.scan( %r{#{Bnf::PVALUE}} ) do
159
+ params.scan( Bnf::PVALUE ) do
160
160
  atparams[name] << ($1 || $2)
161
161
  end
162
162
  end
@@ -407,7 +407,7 @@ module Vcard
407
407
  v = param("VALUE")
408
408
  if v
409
409
  if v.size > 1
410
- raise InvalidEncodingError, "multi-valued param 'VALUE' (#{values})"
410
+ raise ::Vcard::InvalidEncodingError, "multi-valued param 'VALUE' (#{values})"
411
411
  end
412
412
  v = v.first.downcase
413
413
  end
@@ -427,27 +427,25 @@ module Vcard
427
427
  # saying what the year is that breaks, so they at least know that
428
428
  # its ridiculous! I think I need my own DateTime variant.
429
429
  def to_time
430
- begin
431
- ::Vcard.decode_date_time_list(value).collect do |d|
432
- # We get [ year, month, day, hour, min, sec, usec, tz ]
433
- begin
434
- if(d.pop == "Z")
435
- Time.gm(*d)
436
- else
437
- Time.local(*d)
438
- end
439
- rescue ArgumentError => e
440
- raise ::Vcard::InvalidEncodingError, "Time.gm(#{d.join(', ')}) failed with #{e.message}"
441
- end
442
- end
443
- rescue ::Vcard::InvalidEncodingError
444
- ::Vcard.decode_date_list(value).collect do |d|
445
- # We get [ year, month, day ]
446
- begin
430
+ ::Vcard.decode_date_time_list(value).collect do |d|
431
+ # We get [ year, month, day, hour, min, sec, usec, tz ]
432
+ begin
433
+ if(d.pop == "Z")
447
434
  Time.gm(*d)
448
- rescue ArgumentError => e
449
- raise ::Vcard::InvalidEncodingError, "Time.gm(#{d.join(', ')}) failed with #{e.message}"
435
+ else
436
+ Time.local(*d)
450
437
  end
438
+ rescue ArgumentError => e
439
+ raise ::Vcard::InvalidEncodingError, "Time.gm(#{d.join(', ')}) failed with #{e.message}"
440
+ end
441
+ end
442
+ rescue ::Vcard::InvalidEncodingError
443
+ ::Vcard.decode_date_list(value).collect do |d|
444
+ # We get [ year, month, day ]
445
+ begin
446
+ Time.gm(*d)
447
+ rescue ArgumentError => e
448
+ raise ::Vcard::InvalidEncodingError, "Time.gm(#{d.join(', ')}) failed with #{e.message}"
451
449
  end
452
450
  end
453
451
  end
@@ -460,16 +458,14 @@ module Vcard
460
458
  # decoding is tried first as a DATE-TIME, then as a DATE, if neither
461
459
  # works an InvalidEncodingError will be raised.
462
460
  def to_date
463
- begin
464
- ::Vcard.decode_date_time_list(value).collect do |d|
465
- # We get [ year, month, day, hour, min, sec, usec, tz ]
466
- Date.new(d[0], d[1], d[2])
467
- end
468
- rescue ::Vcard::InvalidEncodingError
469
- ::Vcard.decode_date_list(value).collect do |d|
470
- # We get [ year, month, day ]
471
- Date.new(*d)
472
- end
461
+ ::Vcard.decode_date_time_list(value).collect do |d|
462
+ # We get [ year, month, day, hour, min, sec, usec, tz ]
463
+ Date.new(d[0], d[1], d[2])
464
+ end
465
+ rescue ::Vcard::InvalidEncodingError
466
+ ::Vcard.decode_date_list(value).collect do |d|
467
+ # We get [ year, month, day ]
468
+ Date.new(*d)
473
469
  end
474
470
  end
475
471
 
@@ -591,14 +587,11 @@ module Vcard
591
587
  # new fields, not old fields.
592
588
  def mutate(g, n, p, v) #:nodoc:
593
589
  line = Field.encode0(g, n, p, v)
594
-
595
- begin
596
- @group, @name, @params, @value = Field.decode0(line)
597
- @line = line
598
- rescue ::Vcard::InvalidEncodingError => e
599
- raise ArgumentError, e.to_s
600
- end
590
+ @group, @name, @params, @value = Field.decode0(line)
591
+ @line = line
601
592
  self
593
+ rescue ::Vcard::InvalidEncodingError => e
594
+ raise ArgumentError, e.to_s
602
595
  end
603
596
 
604
597
  private :mutate
@@ -440,23 +440,18 @@ module Vcard
440
440
  end
441
441
 
442
442
  def decode_bday(field) #:nodoc:
443
- begin
444
- return decode_date_or_datetime(field)
445
-
446
- rescue ::Vcard::InvalidEncodingError
447
- # Hack around BDAY dates hat are correct in the month and day, but have
448
- # some kind of garbage in the year.
449
- if field.value =~ /^\s*(\d+)-(\d+)-(\d+)\s*$/
450
- y = $1.to_i
451
- m = $2.to_i
452
- d = $3.to_i
453
- if(y < 1900)
454
- y = Time.now.year
455
- end
456
- Line.new( field.group, field.name, Date.new(y, m, d) )
457
- else
458
- raise
459
- end
443
+ decode_date_or_datetime(field)
444
+ rescue ::Vcard::InvalidEncodingError
445
+ # Hack around BDAY dates hat are correct in the month and day, but have
446
+ # some kind of garbage in the year.
447
+ if field.value =~ /^\s*(\d+)-(\d+)-(\d+)\s*$/
448
+ y = $1.to_i
449
+ y = Time.now.year if y < 1900
450
+ m = $2.to_i
451
+ d = $3.to_i
452
+ Line.new( field.group, field.name, Date.new(y, m, d) )
453
+ else
454
+ raise
460
455
  end
461
456
  end
462
457
 
@@ -570,11 +565,9 @@ module Vcard
570
565
 
571
566
  # Return line for a field
572
567
  def f2l(field) #:nodoc:
573
- begin
574
- Line.decode(@@decode, self, field)
575
- rescue ::Vcard::InvalidEncodingError
576
- # Skip invalidly encoded fields.
577
- end
568
+ Line.decode(@@decode, self, field)
569
+ rescue ::Vcard::InvalidEncodingError
570
+ # Skip invalidly encoded fields.
578
571
  end
579
572
 
580
573
  # With no block, returns an Array of Line. If +name+ is specified, the
@@ -1034,7 +1027,7 @@ module Vcard
1034
1027
  def make # :nodoc:
1035
1028
  yield self
1036
1029
  unless @card["N"]
1037
- raise Unencodeable, "N field is mandatory"
1030
+ raise ::Vcard::Unencodeable, "N field is mandatory"
1038
1031
  end
1039
1032
  fn = @card.field("FN")
1040
1033
  if fn && fn.value.strip.length == 0
@@ -1377,14 +1370,12 @@ module Vcard
1377
1370
 
1378
1371
  # Delete +line+ if block yields true.
1379
1372
  def delete_if #:yield: line
1380
- begin
1381
- @card.delete_if do |line|
1382
- yield line
1383
- end
1384
- rescue NoMethodError
1385
- # FIXME - this is a hideous hack, allowing a DirectoryInfo to
1386
- # be passed instead of a Vcard, and for it to almost work. Yuck.
1373
+ @card.delete_if do |line|
1374
+ yield line
1387
1375
  end
1376
+ rescue NoMethodError
1377
+ # FIXME - this is a hideous hack, allowing a DirectoryInfo to
1378
+ # be passed instead of a Vcard, and for it to almost work. Yuck.
1388
1379
  end
1389
1380
 
1390
1381
  end
@@ -1,3 +1,3 @@
1
1
  module Vcard
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -75,16 +75,17 @@ class FieldTest < Test::Unit::TestCase
75
75
  assert_equal("name;encoding=B:dmFsdWU=", line = Field.encode0(nil, "name", { "encoding"=>:b64 }, "value"))
76
76
  assert_equal([ nil, "NAME", { "ENCODING"=>["B"]}, ["value"].pack("m").chomp ], Field.decode0(line))
77
77
 
78
- assert_equal("group.name:value", line = Field.encode0("group", "name", {}, "value"))
79
- assert_equal([ "GROUP", "NAME", {}, "value"], Field.decode0(line))
78
+ line = Field.encode0("group", "name", {}, "value")
79
+ assert_equal "group.name:value", line
80
+ assert_equal [ "GROUP", "NAME", {}, "value"], Field.decode0(line)
80
81
  end
81
82
 
82
- def tEst_invalid_fields
83
+ def test_invalid_fields
83
84
  [
84
85
  "g.:",
85
86
  ":v",
86
87
  ].each do |line|
87
- assert_raises(Vcard::InvalidEncodingError) { Field.decode0(line) }
88
+ assert_raises(::Vcard::InvalidEncodingError) { Field.decode0(line) }
88
89
  end
89
90
  end
90
91
 
@@ -24,7 +24,7 @@ class VcardTest < Test::Unit::TestCase
24
24
  card = nil
25
25
  assert_nothing_thrown { card = Vcard::Vcard.decode(vcard(:ex2)).first }
26
26
  assert_equal(vcard(:ex2), card.encode(0))
27
- assert_raises(InvalidEncodingError) { card.version }
27
+ assert_raises(::Vcard::InvalidEncodingError) { card.version }
28
28
 
29
29
  assert_equal("Bj=F8rn Jensen", card.name.fullname)
30
30
  assert_equal("Jensen", card.name.family)
@@ -169,40 +169,41 @@ EOF
169
169
 
170
170
  def test_bad
171
171
  # FIXME: this should THROW, it's badly encoded!
172
- assert_raises(InvalidEncodingError) do
172
+ assert_raises(::Vcard::InvalidEncodingError) do
173
173
  Vcard::Vcard.decode("BEGIN:VCARD\nVERSION:3.0\nKEYencoding=b:this could be \nmy certificate\n\nEND:VCARD\n")
174
174
  end
175
175
  end
176
176
 
177
177
  def test_create
178
178
  card = Vcard::Vcard.create
179
-
180
179
  key = Vcard::DirectoryInfo.decode("key;type=x509;encoding=B:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK\n")['key']
181
-
182
180
  card << Vcard::DirectoryInfo::Field.create('key', key, 'encoding' => :b64)
183
-
184
181
  assert_equal(key, card['key'])
185
182
  end
186
183
 
187
- def test_values
188
- # date
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")
184
+ def test_decode_date
185
+ assert_equal [2002, 4, 22], Vcard.decode_date(" 20020422 ")
186
+ assert_equal [2002, 4, 22], Vcard.decode_date(" 2002-04-22 ")
187
+ assert_equal [2002, 4, 22], Vcard.decode_date(" 2002-04-22 \n")
188
+ end
189
+
190
+ def test_decode_date_list
192
191
  assert_equal [[2002, 4, 22]], Vcard.decode_date_list(" 2002-04-22 ")
193
192
  assert_equal [[2002, 4, 22],[2002, 4, 22]], Vcard.decode_date_list(" 2002-04-22, 2002-04-22,")
194
193
  assert_equal [[2002, 4, 22],[2002, 4, 22]], Vcard.decode_date_list(" 2002-04-22,,, , ,2002-04-22, , \n")
195
194
  assert_equal [], Vcard.decode_date_list(" , , ")
195
+ end
196
196
 
197
- # time
197
+ def test_decode_time
198
198
  assert_equal [4, 53, 22, 0, nil], Vcard.decode_time(" 04:53:22 \n")
199
199
  assert_equal [4, 53, 22, 0.10, nil], Vcard.decode_time(" 04:53:22.10 \n")
200
200
  assert_equal [4, 53, 22, 0.10, "Z"], Vcard.decode_time(" 04:53:22.10Z \n")
201
201
  assert_equal [4, 53, 22, 0, "Z"], Vcard.decode_time(" 045322Z \n")
202
202
  assert_equal [4, 53, 22, 0, "+0530"], Vcard.decode_time(" 04:5322+0530 \n")
203
203
  assert_equal [4, 53, 22, 0.10, "Z"], Vcard.decode_time(" 045322.10Z \n")
204
+ end
204
205
 
205
- # date-time
206
+ def test_decode_date_time
206
207
  assert_equal [2002, 4, 22, 4, 53, 22, 0, nil], Vcard.decode_date_time("20020422T04:53:22 \n")
207
208
  assert_equal [2002, 4, 22, 4, 53, 22, 0.10, nil], Vcard.decode_date_time(" 2002-04-22T04:53:22.10 \n")
208
209
  assert_equal [2002, 4, 22, 4, 53, 22, 0.10, "Z"], Vcard.decode_date_time(" 20020422T04:53:22.10Z \n")
@@ -210,9 +211,13 @@ EOF
210
211
  assert_equal [2002, 4, 22, 4, 53, 22, 0, "+0530"], Vcard.decode_date_time(" 20020422T04:5322+0530 \n")
211
212
  assert_equal [2002, 4, 22, 4, 53, 22, 0.10, "Z"], Vcard.decode_date_time(" 20020422T045322.10Z \n")
212
213
  assert_equal [2003, 3, 25, 3, 20, 35, 0, "Z"], Vcard.decode_date_time("20030325T032035Z")
214
+ end
213
215
 
214
- # text
216
+ def test_decode_text
215
217
  assert_equal "aa,\n\n,\\,\\a;;b", Vcard.decode_text('aa,\\n\\n,\\\\\,\\\\a\;\;b')
218
+ end
219
+
220
+ def test_decode_text_list
216
221
  assert_equal ['', "1\n2,3", "bbb", '', "zz", ''], Vcard.decode_text_list(',1\\n2\\,3,bbb,,zz,')
217
222
  end
218
223
 
@@ -301,11 +306,11 @@ EOF
301
306
  def test_modify_name
302
307
  card = Vcard.decode("begin:vcard\nend:vcard\n").first
303
308
 
304
- assert_raises(InvalidEncodingError) do
309
+ assert_raises(::Vcard::InvalidEncodingError) do
305
310
  card.name
306
311
  end
307
312
 
308
- assert_raises(Unencodeable) do
313
+ assert_raises(::Vcard::Unencodeable) do
309
314
  Vcard::Maker.make2(card) {}
310
315
  end
311
316
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
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-12-16 00:00:00.000000000 Z
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Vcard extracted from Vpim
15
15
  email:
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  segments:
80
80
  - 0
81
- hash: -144601945951725492
81
+ hash: 376442794917458825
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  segments:
89
89
  - 0
90
- hash: -144601945951725492
90
+ hash: 376442794917458825
91
91
  requirements: []
92
92
  rubyforge_project:
93
93
  rubygems_version: 1.8.24