vcard 0.2.0 → 0.2.1

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.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rvmrc
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ script: bundle exec rake
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
+ # - ruby-head
8
+ # - ree
9
+ # - rbx-18mode
10
+ # - rbx-19mode
11
+ # - jruby-18mode
12
+ # - jruby-19mode
13
+ # - jruby-head
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: 1.8.7
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+
6
+ gem "rake"
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This library is free software; you can redistribute it and/or modify
4
4
  # it under the same terms as the ruby language itself, see the file
5
- # LICENSE-VPIM.txt for details.
5
+ # VPIM-LICENSE.txt for details.
6
6
 
7
7
  require "date"
8
8
  require "open-uri"
@@ -55,7 +55,7 @@ module Vcard
55
55
  # Convert a RFC 2425 date into an array of [year, month, day].
56
56
  def self.decode_date(v) # :nodoc:
57
57
  unless v =~ %r{^\s*#{Bnf::DATE}\s*$}
58
- raise Vcard::InvalidEncodingError, "date not valid (#{v})"
58
+ raise ::Vcard::InvalidEncodingError, "date not valid (#{v})"
59
59
  end
60
60
  [$1.to_i, $2.to_i, $3.to_i]
61
61
  end
@@ -86,7 +86,7 @@ module Vcard
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
88
  unless match = %r{^\s*#{Bnf::TIME}\s*$}.match(v)
89
- raise Vcard::InvalidEncodingError, "time '#{v}' not valid"
89
+ raise ::Vcard::InvalidEncodingError, "time '#{v}' not valid"
90
90
  end
91
91
  hour, min, sec, secfrac, tz = match.to_a[1..5]
92
92
 
@@ -99,7 +99,7 @@ module Vcard
99
99
  tz = (dtarray.pop == "Z") ? :gm : :local
100
100
  Time.send(tz, *dtarray)
101
101
  rescue ArgumentError => e
102
- raise Vcard::InvalidEncodingError, "#{tz} #{e} (#{dtarray.join(', ')})"
102
+ raise ::Vcard::InvalidEncodingError, "#{tz} #{e} (#{dtarray.join(', ')})"
103
103
  end
104
104
  end
105
105
 
@@ -111,7 +111,7 @@ module Vcard
111
111
  # Convert a RFC 2425 date-time into an array of [year,mon,day,hour,min,sec,secfrac,timezone]
112
112
  def self.decode_date_time(v) # :nodoc:
113
113
  unless match = %r{^\s*#{Bnf::DATE}T#{Bnf::TIME}\s*$}.match(v)
114
- raise Vcard::InvalidEncodingError, "date-time '#{v}' not valid"
114
+ raise ::Vcard::InvalidEncodingError, "date-time '#{v}' not valid"
115
115
  end
116
116
  year, month, day, hour, min, sec, secfrac, tz = match.to_a[1..8]
117
117
 
@@ -138,7 +138,7 @@ module Vcard
138
138
  # Convert an RFC2425 INTEGER value into an Integer
139
139
  def self.decode_integer(v) # :nodoc:
140
140
  unless %r{\s*#{Bnf::INTEGER}\s*}.match(v)
141
- raise Vcard::InvalidEncodingError, "integer not valid (#{v})"
141
+ raise ::Vcard::InvalidEncodingError, "integer not valid (#{v})"
142
142
  end
143
143
  v.to_i
144
144
  end
@@ -231,7 +231,7 @@ module Vcard
231
231
  when %r{\A#{Bnf::SAFECHAR}*\z}
232
232
  value
233
233
  else
234
- raise Vcard::Unencodable, "paramtext #{value.inspect}"
234
+ raise ::Vcard::Unencodable, "paramtext #{value.inspect}"
235
235
  end
236
236
  end
237
237
 
@@ -242,7 +242,7 @@ module Vcard
242
242
  when %r{\A#{Bnf::QSAFECHAR}*\z}
243
243
  '"' + value + '"'
244
244
  else
245
- raise Vcard::Unencodable, "param-value #{value.inspect}"
245
+ raise ::Vcard::Unencodable, "param-value #{value.inspect}"
246
246
  end
247
247
  end
248
248
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This library is free software; you can redistribute it and/or modify
4
4
  # it under the same terms as the ruby language itself, see the file
5
- # LICENSE-VPIM.txt for details.
5
+ # VPIM-LICENSE.txt for details.
6
6
 
7
7
  module Vcard
8
8
 
@@ -39,7 +39,7 @@ module Vcard
39
39
  when "binary"
40
40
  Inline.new(field.value, format)
41
41
  else
42
- raise InvalidEncodingError, "Attachment of type #{kind} is not allowed"
42
+ raise ::Vcard::InvalidEncodingError, "Attachment of type #{kind} is not allowed"
43
43
  end
44
44
  end
45
45
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This library is free software; you can redistribute it and/or modify
4
4
  # it under the same terms as the ruby language itself, see the file
5
- # LICENSE-VPIM.txt for details.
5
+ # VPIM-LICENSE.txt for details.
6
6
 
7
7
  module Vcard
8
8
  # Contains regular expression strings for the EBNF of RFC 2425.
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This library is free software; you can redistribute it and/or modify
4
4
  # it under the same terms as the ruby language itself, see the file
5
- # LICENSE-VPIM.txt for details.
5
+ # VPIM-LICENSE.txt for details.
6
6
 
7
7
  module Vcard
8
8
  # An RFC 2425 directory info object.
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This library is free software; you can redistribute it and/or modify
4
4
  # it under the same terms as the ruby language itself, see the file
5
- # LICENSE-VPIM.txt for details.
5
+ # VPIM-LICENSE.txt for details.
6
6
 
7
7
  module Vcard
8
8
  # This is a way for an object to have multiple ways of being enumerated via
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This library is free software; you can redistribute it and/or modify
4
4
  # it under the same terms as the ruby language itself, see the file
5
- # LICENSE-VPIM.txt for details.
5
+ # VPIM-LICENSE.txt for details.
6
6
 
7
7
  module Vcard
8
8
  # Exception used to indicate that data being decoded is invalid, the message
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This library is free software; you can redistribute it and/or modify
4
4
  # it under the same terms as the ruby language itself, see the file
5
- # LICENSE-VPIM.txt for details.
5
+ # VPIM-LICENSE.txt for details.
6
6
 
7
7
  module Vcard
8
8
  # A vCard, a specialization of a directory info object.
@@ -211,7 +211,7 @@ module Vcard
211
211
  value = to_str.strip
212
212
 
213
213
  if value.length < 1
214
- raise InvalidEncodingError, "EMAIL must have a value"
214
+ raise ::Vcard::InvalidEncodingError, "EMAIL must have a value"
215
215
  end
216
216
 
217
217
  params = [ @location, @nonstandard ]
@@ -231,7 +231,7 @@ module Vcard
231
231
  value = field.to_text.strip
232
232
 
233
233
  if value.length < 1
234
- raise InvalidEncodingError, "EMAIL must have a value"
234
+ raise ::Vcard::InvalidEncodingError, "EMAIL must have a value"
235
235
  end
236
236
 
237
237
  eml = Email.new(value)
@@ -301,7 +301,7 @@ module Vcard
301
301
  value = to_str.strip
302
302
 
303
303
  if value.length < 1
304
- raise InvalidEncodingError, "TEL must have a value"
304
+ raise ::Vcard::InvalidEncodingError, "TEL must have a value"
305
305
  end
306
306
 
307
307
  params = [ @location, @capability, @nonstandard ]
@@ -320,7 +320,7 @@ module Vcard
320
320
  value = field.to_text.strip
321
321
 
322
322
  if value.length < 1
323
- raise InvalidEncodingError, "TEL must have a value"
323
+ raise ::Vcard::InvalidEncodingError, "TEL must have a value"
324
324
  end
325
325
 
326
326
  tel = Telephone.new(value)
@@ -498,7 +498,7 @@ module Vcard
498
498
  when "vcard", nil
499
499
  Line.new( field.group, field.name, ::Vcard.decode(::Vcard.decode_text(field.value_raw)).first )
500
500
  else
501
- raise InvalidEncodingError, "AGENT type #{field.kind} is not allowed"
501
+ raise ::Vcard::InvalidEncodingError, "AGENT type #{field.kind} is not allowed"
502
502
  end
503
503
  end
504
504
 
@@ -572,7 +572,7 @@ module Vcard
572
572
  def f2l(field) #:nodoc:
573
573
  begin
574
574
  Line.decode(@@decode, self, field)
575
- rescue InvalidEncodingError
575
+ rescue ::Vcard::InvalidEncodingError
576
576
  # Skip invalidly encoded fields.
577
577
  end
578
578
  end
@@ -1,3 +1,3 @@
1
1
  module Vcard
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,6 @@
1
+ BEGIN:VCARD
2
+ VERSION:3.0
3
+ N:;Given Name;;;
4
+ FN:Given Name
5
+ BDAY:19801025
6
+ END:VCARD
@@ -379,8 +379,6 @@ EOF
379
379
  def test_bday_decode
380
380
  card = Vcard::Vcard.decode(vcard(:bday_decode)).first
381
381
 
382
- card.birthday
383
-
384
382
  assert_equal(Date.new(1970, 7, 14), card.birthday)
385
383
  assert_equal(1, card.values("bday").size)
386
384
 
@@ -398,6 +396,12 @@ EOF
398
396
  assert_equal(DateTime.new(1970, 7, 15, 3, 45, 12).to_s, card.values("bday").last.to_s)
399
397
  end
400
398
 
399
+ def test_bday_decode_3
400
+ card = Vcard::Vcard.decode(vcard(:bday_decode_3)).first
401
+
402
+ assert_equal(Date.new(1980, 10, 25), card.birthday)
403
+ end
404
+
401
405
  def test_utf_heuristics
402
406
  bom = "\xEF\xBB\xBF"
403
407
  dat = "BEGIN:VCARD\nN:name\nEND:VCARD\n"
@@ -474,4 +478,3 @@ EOF
474
478
  _test_org("Megamix Corp.", "Marketing")
475
479
  end
476
480
  end
477
-
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.0
4
+ version: 0.2.1
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-11-26 00:00:00.000000000 Z
12
+ date: 2012-12-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Vcard extracted from Vpim
15
15
  email:
@@ -19,6 +19,7 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
+ - .travis.yml
22
23
  - Gemfile
23
24
  - LICENSE.txt
24
25
  - README.md
@@ -36,6 +37,7 @@ files:
36
37
  - test/field_test.rb
37
38
  - test/fixtures/bday_decode.vcard
38
39
  - test/fixtures/bday_decode_2.vcard
40
+ - test/fixtures/bday_decode_3.vcard
39
41
  - test/fixtures/empty_tel.vcard
40
42
  - test/fixtures/ex1.vcard
41
43
  - test/fixtures/ex2.vcard
@@ -74,12 +76,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
76
  - - ! '>='
75
77
  - !ruby/object:Gem::Version
76
78
  version: '0'
79
+ segments:
80
+ - 0
81
+ hash: -144601945951725492
77
82
  required_rubygems_version: !ruby/object:Gem::Requirement
78
83
  none: false
79
84
  requirements:
80
85
  - - ! '>='
81
86
  - !ruby/object:Gem::Version
82
87
  version: '0'
88
+ segments:
89
+ - 0
90
+ hash: -144601945951725492
83
91
  requirements: []
84
92
  rubyforge_project:
85
93
  rubygems_version: 1.8.24
@@ -90,6 +98,7 @@ test_files:
90
98
  - test/field_test.rb
91
99
  - test/fixtures/bday_decode.vcard
92
100
  - test/fixtures/bday_decode_2.vcard
101
+ - test/fixtures/bday_decode_3.vcard
93
102
  - test/fixtures/empty_tel.vcard
94
103
  - test/fixtures/ex1.vcard
95
104
  - test/fixtures/ex2.vcard
@@ -115,4 +124,3 @@ test_files:
115
124
  - test/fixtures/url_decode.vcard
116
125
  - test/test_helper.rb
117
126
  - test/vcard_test.rb
118
- has_rdoc: