vcard 0.2.16 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deb41c0907ad9041c65948878f1f4b873209698604c9436010191d0ca1489bf1
4
- data.tar.gz: 28680dd09a300f12e132ffc8edc40b4f8f47ea92d6caf746a1fc7dd8f581e990
3
+ metadata.gz: a1a9b1a2c5e533fee3acd4659c5baa7234b36eea86da7082f372fd6415d83e31
4
+ data.tar.gz: 245a9b44434e2fdfbb6c69e32edb81aa43864a7f7f74a4504bac53a1c8148fda
5
5
  SHA512:
6
- metadata.gz: 64a863c62c87930f6d5bd3002ebc4f7b462ba60ed230e0ada8ff58c8f6c3e8be37c2b3e00a77ce6d6b27e51bd0ba8628269f7a32a07a6dfaac98671ead5aefa1
7
- data.tar.gz: c200b2482df4b22e4da2926b7310f05627b067a7db37efaa1674c97fdd60da274a3e01ffceccdef1a89679be32199d2a436262b3a18dd74650672121da280f0c
6
+ metadata.gz: 56df5e3fbce3b326c4daebd7ab9a8dfc7580fe5bd436c0207cd081dc6aa1f0c37df183dd4289651d49fc15f1d1ef0d7ff8b06b01374a55c8a5d1ea8a83f7ecad
7
+ data.tar.gz: f0fde0a4f77ec00a5eedd124de538c7d0fecd6b9bbcc5d05f96ab1545c9a1de83f8f5c2a9bfa4f9f0475e2e901f395f3868b68b7f715251c8a7ff1ad56d9ea40
@@ -0,0 +1,184 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased](https://github.com/qoobaa/vcard/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.3.0...HEAD)
6
+
7
+ ## [v0.3.0](https://github.com/qoobaa/vcard/tree/v0.3.0) (2020-11-20)
8
+
9
+ **Closed issues:**
10
+
11
+ - New release with ruby25 and ruby26 support [\#30](https://github.com/qoobaa/vcard/issues/30)
12
+
13
+ **Merged pull requests:**
14
+
15
+ - Add an `nl` option to encode\(\) and remove caching [\#35](https://github.com/qoobaa/vcard/pull/35) ([knu](https://github.com/knu))
16
+ - Use the default argument in encode\(\) [\#34](https://github.com/qoobaa/vcard/pull/34) ([knu](https://github.com/knu))
17
+ - Do not modify the fields argument in Vcard::Vcard.create\(\) [\#33](https://github.com/qoobaa/vcard/pull/33) ([knu](https://github.com/knu))
18
+ - Wrap lines exactly by a given width \(75 by default\) [\#32](https://github.com/qoobaa/vcard/pull/32) ([knu](https://github.com/knu))
19
+
20
+ ## [v0.2.16](https://github.com/qoobaa/vcard/tree/v0.2.16) (2019-12-01)
21
+
22
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.15...v0.2.16)
23
+
24
+ **Merged pull requests:**
25
+
26
+ - Update supported ruby versions [\#31](https://github.com/qoobaa/vcard/pull/31) ([senzpo](https://github.com/senzpo))
27
+
28
+ ## [v0.2.15](https://github.com/qoobaa/vcard/tree/v0.2.15) (2016-12-01)
29
+
30
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.14...v0.2.15)
31
+
32
+ **Merged pull requests:**
33
+
34
+ - Fix incorrect scope of Vcard.configure and Vcard.configuration methods [\#29](https://github.com/qoobaa/vcard/pull/29) ([solenko](https://github.com/solenko))
35
+
36
+ ## [v0.2.14](https://github.com/qoobaa/vcard/tree/v0.2.14) (2016-11-22)
37
+
38
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.13...v0.2.14)
39
+
40
+ **Closed issues:**
41
+
42
+ - Method for releasing a new gem version [\#27](https://github.com/qoobaa/vcard/issues/27)
43
+
44
+ **Merged pull requests:**
45
+
46
+ - Allow to ignore invalid fields [\#28](https://github.com/qoobaa/vcard/pull/28) ([solenko](https://github.com/solenko))
47
+
48
+ ## [v0.2.13](https://github.com/qoobaa/vcard/tree/v0.2.13) (2016-09-23)
49
+
50
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.12...v0.2.13)
51
+
52
+ **Closed issues:**
53
+
54
+ - vCard v2.1 ADR fields with quoted-printable encoding not decoded [\#22](https://github.com/qoobaa/vcard/issues/22)
55
+ - License missing from gemspec [\#17](https://github.com/qoobaa/vcard/issues/17)
56
+
57
+ **Merged pull requests:**
58
+
59
+ - Fix tests [\#26](https://github.com/qoobaa/vcard/pull/26) ([brendon](https://github.com/brendon))
60
+ - Fix 2.2 2.3 & Remove 1.9.2 [\#25](https://github.com/qoobaa/vcard/pull/25) ([brendon](https://github.com/brendon))
61
+ - Fix travis bundler [\#24](https://github.com/qoobaa/vcard/pull/24) ([brendon](https://github.com/brendon))
62
+ - Add Ruby 2.x for testing [\#23](https://github.com/qoobaa/vcard/pull/23) ([brendon](https://github.com/brendon))
63
+
64
+ ## [v0.2.12](https://github.com/qoobaa/vcard/tree/v0.2.12) (2013-10-30)
65
+
66
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.11...v0.2.12)
67
+
68
+ **Merged pull requests:**
69
+
70
+ - Add work-around for JRuby Regexp issue [\#20](https://github.com/qoobaa/vcard/pull/20) ([dgolombek](https://github.com/dgolombek))
71
+ - Change field's to accept symbols as values [\#19](https://github.com/qoobaa/vcard/pull/19) ([dgolombek](https://github.com/dgolombek))
72
+
73
+ ## [v0.2.11](https://github.com/qoobaa/vcard/tree/v0.2.11) (2013-10-02)
74
+
75
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.10...v0.2.11)
76
+
77
+ ## [v0.2.10](https://github.com/qoobaa/vcard/tree/v0.2.10) (2013-10-01)
78
+
79
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.9...v0.2.10)
80
+
81
+ ## [v0.2.9](https://github.com/qoobaa/vcard/tree/v0.2.9) (2013-09-27)
82
+
83
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.8...v0.2.9)
84
+
85
+ **Closed issues:**
86
+
87
+ - Failing Tests [\#11](https://github.com/qoobaa/vcard/issues/11)
88
+
89
+ **Merged pull requests:**
90
+
91
+ - Fix decoding of multi-line quoted-printable fields [\#16](https://github.com/qoobaa/vcard/pull/16) ([dgolombek](https://github.com/dgolombek))
92
+
93
+ ## [v0.2.8](https://github.com/qoobaa/vcard/tree/v0.2.8) (2013-06-20)
94
+
95
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.7...v0.2.8)
96
+
97
+ ## [v0.2.7](https://github.com/qoobaa/vcard/tree/v0.2.7) (2013-06-20)
98
+
99
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.6...v0.2.7)
100
+
101
+ **Closed issues:**
102
+
103
+ - Encoding line breaks for things like Address and Notes [\#9](https://github.com/qoobaa/vcard/issues/9)
104
+
105
+ **Merged pull requests:**
106
+
107
+ - Add back support for multiple ROLEs [\#15](https://github.com/qoobaa/vcard/pull/15) ([brendon](https://github.com/brendon))
108
+
109
+ ## [v0.2.6](https://github.com/qoobaa/vcard/tree/v0.2.6) (2013-06-19)
110
+
111
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.5...v0.2.6)
112
+
113
+ **Merged pull requests:**
114
+
115
+ - Eliminate carriage returns when encoding text [\#14](https://github.com/qoobaa/vcard/pull/14) ([m1foley](https://github.com/m1foley))
116
+
117
+ ## [v0.2.5](https://github.com/qoobaa/vcard/tree/v0.2.5) (2013-06-19)
118
+
119
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.4...v0.2.5)
120
+
121
+ **Closed issues:**
122
+
123
+ - Role is missing [\#8](https://github.com/qoobaa/vcard/issues/8)
124
+
125
+ **Merged pull requests:**
126
+
127
+ - Newlines bug [\#13](https://github.com/qoobaa/vcard/pull/13) ([brendon](https://github.com/brendon))
128
+ - ROLE can occur multiple times [\#12](https://github.com/qoobaa/vcard/pull/12) ([brendon](https://github.com/brendon))
129
+
130
+ ## [v0.2.4](https://github.com/qoobaa/vcard/tree/v0.2.4) (2013-06-18)
131
+
132
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.3...v0.2.4)
133
+
134
+ **Closed issues:**
135
+
136
+ - Using Ruby 2.0 there is invalid multibyte escape error [\#6](https://github.com/qoobaa/vcard/issues/6)
137
+
138
+ **Merged pull requests:**
139
+
140
+ - Added native support for ROLE with escaping [\#10](https://github.com/qoobaa/vcard/pull/10) ([brendon](https://github.com/brendon))
141
+
142
+ ## [v0.2.3](https://github.com/qoobaa/vcard/tree/v0.2.3) (2013-01-31)
143
+
144
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.2...v0.2.3)
145
+
146
+ **Closed issues:**
147
+
148
+ - Birthday decoding broken in 0.2.0 [\#4](https://github.com/qoobaa/vcard/issues/4)
149
+
150
+ **Merged pull requests:**
151
+
152
+ - Code patch to correct invalid multibyte escape [\#7](https://github.com/qoobaa/vcard/pull/7) ([seth-macpherson](https://github.com/seth-macpherson))
153
+
154
+ ## [v0.2.2](https://github.com/qoobaa/vcard/tree/v0.2.2) (2012-12-17)
155
+
156
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.1...v0.2.2)
157
+
158
+ **Merged pull requests:**
159
+
160
+ - Regex refactor, includes date parsing fix [\#5](https://github.com/qoobaa/vcard/pull/5) ([m1foley](https://github.com/m1foley))
161
+
162
+ ## [v0.2.1](https://github.com/qoobaa/vcard/tree/v0.2.1) (2012-12-16)
163
+
164
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/v0.2.0...v0.2.1)
165
+
166
+ **Merged pull requests:**
167
+
168
+ - Fix wrong scope, add Travis [\#3](https://github.com/qoobaa/vcard/pull/3) ([rngtng](https://github.com/rngtng))
169
+
170
+ ## [v0.2.0](https://github.com/qoobaa/vcard/tree/v0.2.0) (2012-11-26)
171
+
172
+ [Full Changelog](https://github.com/qoobaa/vcard/compare/46a2517b0f9bd073b00f233eeae6f106069ddce5...v0.2.0)
173
+
174
+ **Closed issues:**
175
+
176
+ - incompatible encoding regexp match \(ASCII-8BIT regexp with UTF-8 string\) [\#1](https://github.com/qoobaa/vcard/issues/1)
177
+
178
+ **Merged pull requests:**
179
+
180
+ - remove superfluous encoding detection, which errors with ruby-1.9 [\#2](https://github.com/qoobaa/vcard/pull/2) ([hannesm](https://github.com/hannesm))
181
+
182
+
183
+
184
+ <!-- This Changelog was originally generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator) -->
@@ -92,10 +92,11 @@ module Vcard
92
92
 
93
93
  if profile
94
94
  p = profile.to_str
95
- f = [ Field.create("BEGIN", p) ]
96
- f.concat fields
97
- f.push Field.create("END", p)
98
- fields = f
95
+ fields = [
96
+ Field.create("BEGIN", p),
97
+ *fields,
98
+ Field.create("END", p)
99
+ ]
99
100
  end
100
101
 
101
102
  new(fields, profile)
@@ -192,9 +193,8 @@ module Vcard
192
193
  Enumerator.new(self, cond )
193
194
  end
194
195
 
195
- # Force card to be reencoded from the fields.
196
+ # Obsoleted; force card to be reencoded from the fields.
196
197
  def dirty #:nodoc:
197
- #string = nil
198
198
  end
199
199
 
200
200
  # Append +field+ to the fields. Note that it won't be literally appended
@@ -241,13 +241,12 @@ module Vcard
241
241
  self
242
242
  end
243
243
 
244
+ LF= "\n"
245
+
244
246
  # The string encoding of the DirectoryInfo. See Field#encode for information
245
- # about the width parameter.
246
- def encode(width=nil)
247
- unless @string
248
- @string = @fields.collect { |f| f.encode(width) } . join ""
249
- end
250
- @string
247
+ # about the parameters.
248
+ def encode(width = 75, nl: LF)
249
+ @fields.collect { |f| f.encode(width, nl: nl) }.join
251
250
  end
252
251
 
253
252
  alias to_s encode
@@ -260,10 +259,10 @@ module Vcard
260
259
  raise "No fields to check"
261
260
  end
262
261
  unless @fields.first.name? "BEGIN"
263
- raise "Needs BEGIN, found: #{@fields.first.encode nil}"
262
+ raise "Needs BEGIN, found: #{@fields.first.encode}"
264
263
  end
265
264
  unless @fields.last.name? "END"
266
- raise "Needs END, found: #{@fields.last.encode nil}"
265
+ raise "Needs END, found: #{@fields.last.encode}"
267
266
  end
268
267
  unless @fields.last.value? @fields.first.value
269
268
  raise "BEGIN/END mismatch: (#{@fields.first.value} != #{@fields.last.value}"
@@ -228,9 +228,18 @@ module Vcard
228
228
  Marshal.load(Marshal.dump(self))
229
229
  end
230
230
 
231
- # The String encoding of the Field. The String will be wrapped to a
232
- # maximum line width of +width+, where +0+ means no wrapping, and nil is
233
- # to accept the default wrapping (75, recommended by RFC2425).
231
+ LF = "\n"
232
+
233
+ # The String encoding of the Field. The String will be wrapped
234
+ # to a maximum line width of +width+, where +0+ means no
235
+ # wrapping, and omitting it is to accept the default wrapping
236
+ # (75, recommended by RFC2425).
237
+ #
238
+ # The +nl+ parameter specifies the line delimiter, which is
239
+ # defaulted to LF ("\n") for historical reasons. Relevant RFC's
240
+ # all say it should be CRLF, so it is highly recommended that
241
+ # you specify "\r\n" if you care about maximizing
242
+ # interoperability and interchangeability.
234
243
  #
235
244
  # Note: AddressBook.app 3.0.3 neither understands to unwrap lines when it
236
245
  # imports vCards (it treats them as raw new-line characters), nor wraps
@@ -239,15 +248,16 @@ module Vcard
239
248
  #
240
249
  # FIXME - breaks round-trip encoding, need to change this to not wrap
241
250
  # fields that are already wrapped.
242
- def encode(width=nil)
243
- width = 75 unless width
244
- l = @line
245
- # Wrap to width, unless width is zero.
246
- if width > 0
247
- l = l.gsub(/.{#{width},#{width}}/) { |m| m + "\n " }
251
+ def encode(width = 75, nl: LF)
252
+ l = @line.rstrip
253
+ if width.zero?
254
+ l + nl
255
+ elsif width <= 1
256
+ raise ArgumentError, "#{width} is too narrow"
257
+ else
258
+ # Wrap to width
259
+ l.scan(/\A.{,#{width}}|.{1,#{width - 1}}/).join("#{nl} ") + nl
248
260
  end
249
- # Make sure it's terminated with no more than a single NL.
250
- l.gsub(/\s*\z/, "") + "\n"
251
261
  end
252
262
 
253
263
  alias to_s encode
@@ -608,9 +608,8 @@ module Vcard
608
608
 
609
609
  # Create a vCard 3.0 object with the minimum required fields, plus any
610
610
  # +fields+ you want in the card (they can also be added later).
611
- def self.create(fields = [] )
612
- fields.unshift Field.create("VERSION", "3.0")
613
- super(fields, "VCARD")
611
+ def self.create(fields = [])
612
+ super([Field.create("VERSION", "3.0"), *fields], "VCARD")
614
613
  end
615
614
 
616
615
  # Decode a collection of vCards into an array of Vcard objects.
@@ -1,3 +1,3 @@
1
1
  module Vcard
2
- VERSION = "0.2.16"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -162,8 +162,14 @@ class FieldTest < Test::Unit::TestCase
162
162
  assert_equal("0:xx\n", Vcard::DirectoryInfo::Field.create("0", "x" * 2).encode(4))
163
163
  assert_equal("0:xx\n x\n", Vcard::DirectoryInfo::Field.create("0", "x" * 3).encode(4))
164
164
  assert_equal("0:xx\n xx\n", Vcard::DirectoryInfo::Field.create("0", "x" * 4).encode(4))
165
- assert_equal("0:xx\n xxxx\n", Vcard::DirectoryInfo::Field.create("0", "x" * 6).encode(4))
166
- assert_equal("0:xx\n xxxx\n x\n", Vcard::DirectoryInfo::Field.create("0", "x" * 7).encode(4))
165
+ assert_equal("0:xx\n xxx\n x\n", Vcard::DirectoryInfo::Field.create("0", "x" * 6).encode(4))
166
+ assert_equal("0:xx\n xxx\n xx\n", Vcard::DirectoryInfo::Field.create("0", "x" * 7).encode(4))
167
+ assert_equal("0:xxxxxxx\n", Vcard::DirectoryInfo::Field.create("0", "x" * 7).encode(0))
168
+ assert_equal("0:xxxxxxx\n", Vcard::DirectoryInfo::Field.create("0", "x" * 7).encode())
169
+ assert_equal("0:#{"x" * 73}\n #{"x" * 74}\n #{"x" * 53}\n", Vcard::DirectoryInfo::Field.create("0", "x" * 200).encode())
167
170
  end
168
- end
169
171
 
172
+ def test_nl
173
+ assert_equal("test:#{"value" * 14}\r\n #{"value" * 6}\r\n", Vcard::DirectoryInfo::Field.create("test", "value" * 20).encode(nl: "\r\n"))
174
+ end
175
+ end
@@ -97,6 +97,20 @@ class VcardTest < Test::Unit::TestCase
97
97
  assert_equal("CATEGORIES: Amis/Famille", card[ "note" ])
98
98
  end
99
99
 
100
+ def test_nl
101
+ lf_card = crlf_card = nil
102
+ assert_nothing_thrown {
103
+ lf_card = Vcard::Vcard.decode(vcard(:ex3)).first
104
+ crlf_encoded = lf_card.encode(nl: "\r\n")
105
+ lf_encoded = lf_card.encode
106
+ assert_equal(crlf_encoded.split(/\r\n/), lf_encoded.split(/\n/))
107
+ crlf_card = Vcard::Vcard.decode(crlf_encoded).first
108
+ }
109
+
110
+ assert_equal(lf_card["note"], crlf_card["note"])
111
+ assert_equal(lf_card["home.label"], crlf_card["home.label"])
112
+ end
113
+
100
114
  def test_nickname
101
115
  assert_equal(nil, Vcard::Vcard.decode(vcard(:nickname0)).first.nickname)
102
116
  assert_equal(nil, Vcard::Vcard.decode(vcard(:nickname1)).first.nickname)
@@ -218,6 +232,12 @@ EOF
218
232
  key = Vcard::DirectoryInfo.decode("key;type=x509;encoding=B:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK\n")['key']
219
233
  card << Vcard::DirectoryInfo::Field.create('key', key, 'encoding' => :b64)
220
234
  assert_equal(key, card['key'])
235
+
236
+ field = Vcard::DirectoryInfo::Field.create('key', 'value')
237
+ card = assert_nothing_raised {
238
+ Vcard::Vcard.create([field].freeze)
239
+ }
240
+ assert_equal('value', card['key'])
221
241
  end
222
242
 
223
243
  def test_decode_date
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Kuźma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-01 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Vcard extracted from Vpim
14
14
  email:
@@ -21,6 +21,7 @@ files:
21
21
  - ".ruby-gemset"
22
22
  - ".ruby-version"
23
23
  - ".travis.yml"
24
+ - CHANGELOG.md
24
25
  - Gemfile
25
26
  - LICENSE
26
27
  - README.md