vcard_parser 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vcard_parser/vcard.rb +1 -0
- data/lib/vcard_parser/version.rb +1 -1
- data/specs/data/vcard3.0.vcf +6 -0
- data/specs/unit/3.0/field_spec.rb +1 -1
- data/specs/unit/vcard_spec.rb +27 -22
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e163f43c16a755bc2431f450dae008e6ff4e1c
|
4
|
+
data.tar.gz: 75caa1354c96992ae2d1bad66251dfcdd46094b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361f3695db494bcbeae7581d46bb0eff68f3ee0f9903fb650d3074c2ffbb906e3e765a99b87ab64f4c089dcb2e1bb6c2389235aa07798d4ae2ca102ae9226ba9
|
7
|
+
data.tar.gz: 41a04060d9549cf2103c6e658eba8dbf077e88d1f09ce7eb0aa459d3a212753ab66d3049272b5086c3f74c0adaac1f8378fd80875349196eab9c6fb1d5556468
|
data/lib/vcard_parser/vcard.rb
CHANGED
@@ -19,6 +19,7 @@ module VCardParser
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.parse(data)
|
22
|
+
data.gsub!(/\r?\n /, "") # inline base64 data to not break parser
|
22
23
|
data.scan(VCARD_FORMAT).map do |vcard_data|
|
23
24
|
# find the version to choose the correct parser
|
24
25
|
lines = vcard_data[0].each_line.map(&:strip)
|
data/lib/vcard_parser/version.rb
CHANGED
data/specs/data/vcard3.0.vcf
CHANGED
@@ -8,6 +8,12 @@ item1.TEL;type=pref:2 56 38 54
|
|
8
8
|
item2.TEL;type=pref:5 66
|
9
9
|
TEL;type=CELL;type=VOICE:3 55
|
10
10
|
item2.ADR;type=HOME;type=pref:;;3 rue du chat;Dris;;90880;FRANCE
|
11
|
+
PHOTO;encoding=b;type=JPEG:/9j/4AAQSkZJRgABAQAAAQABAAD/4gxYSUNDX1BST0ZJTEUA
|
12
|
+
AQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1
|
13
|
+
JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
14
|
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8A
|
15
|
+
AAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5k
|
16
|
+
IrAeZa3dxHuA3Lv3KVYKw/tboA//2Q==
|
11
17
|
BDAY;value=date:1900-01-01
|
12
18
|
REV:2012-10-31T16:08:22Z
|
13
19
|
UID:11
|
data/specs/unit/vcard_spec.rb
CHANGED
@@ -71,7 +71,7 @@ END:VCARD
|
|
71
71
|
vcards[1]["UID"].value.should == "12"
|
72
72
|
end
|
73
73
|
|
74
|
-
should 'enumerate attributes' do
|
74
|
+
should 'enumerate attributes 1' do
|
75
75
|
vcards = VCardParser::VCard.parse( data_file('vcard3.0.vcf') )
|
76
76
|
vcards.size.should == 1
|
77
77
|
|
@@ -81,10 +81,10 @@ END:VCARD
|
|
81
81
|
attrs << a
|
82
82
|
end
|
83
83
|
|
84
|
-
attrs.size.should ==
|
84
|
+
attrs.size.should == 12
|
85
85
|
end
|
86
86
|
|
87
|
-
should 'enumerate attributes' do
|
87
|
+
should 'enumerate attributes 2' do
|
88
88
|
vcards = VCardParser::VCard.parse( data_file('vcard3.0.vcf') )
|
89
89
|
vcards.size.should == 1
|
90
90
|
|
@@ -94,74 +94,79 @@ END:VCARD
|
|
94
94
|
attrs << a
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
n = -1
|
98
|
+
attrs[n+= 1].tap do |a|
|
98
99
|
a.group.should == "item2"
|
99
100
|
a.name.should == "ADR"
|
100
101
|
a.value.should == ";;3 rue du chat;Dris;;90880;FRANCE"
|
101
102
|
a.params.should == {'type' => ['HOME', 'pref']}
|
102
103
|
end
|
103
104
|
|
104
|
-
attrs[1].tap do |a|
|
105
|
+
attrs[n+= 1].tap do |a|
|
105
106
|
a.name.should == "BDAY"
|
106
107
|
a.value.should == Time.parse('1900-01-01')
|
107
108
|
a.params.should == {'value' => ['date']}
|
108
109
|
end
|
109
110
|
|
110
111
|
|
111
|
-
attrs[
|
112
|
+
attrs[n+= 1].tap do |a|
|
112
113
|
a.name.should == "FN"
|
113
114
|
a.value.should == "Christophe Durand"
|
114
115
|
a.params.should == {}
|
115
116
|
end
|
116
117
|
|
117
|
-
attrs[
|
118
|
+
attrs[n+= 1].tap do |a|
|
118
119
|
a.name.should == "N"
|
119
120
|
a.value.should == "Durand;Christophe;;;"
|
120
121
|
a.params.should == {}
|
121
122
|
end
|
122
123
|
|
123
|
-
attrs[
|
124
|
+
attrs[n+= 1].tap do |a|
|
124
125
|
a.name.should == "ORG"
|
125
126
|
a.value.should == "Op;"
|
126
127
|
a.params.should == {}
|
127
128
|
end
|
128
|
-
|
129
129
|
|
130
|
-
attrs[
|
130
|
+
attrs[n+= 1].tap do |a|
|
131
|
+
a.name.should == "PHOTO"
|
132
|
+
a.value.should.include?("AAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlub")
|
133
|
+
a.params.should == {"encoding"=>["b"], "type"=>["JPEG"]}
|
134
|
+
end
|
135
|
+
|
136
|
+
attrs[n+= 1].tap do |a|
|
131
137
|
a.name.should == "PRODID"
|
132
138
|
a.value.should == "-//Apple Inc.//iOS 5.0.1//EN"
|
133
139
|
a.params.should == {}
|
134
140
|
end
|
135
141
|
|
136
|
-
attrs[
|
142
|
+
attrs[n+= 1].tap do |a|
|
137
143
|
a.name.should == "REV"
|
138
144
|
a.value.should == Time.parse("2012-10-31T16:08:22Z")
|
139
145
|
a.params.should == {}
|
140
146
|
end
|
141
147
|
|
142
|
-
attrs[
|
143
|
-
a.group.should == nil
|
144
|
-
a.name.should == "TEL"
|
145
|
-
a.value.should == "3 55"
|
146
|
-
a.params.should == {'type' => %w(CELL VOICE)}
|
147
|
-
end
|
148
|
-
|
149
|
-
attrs[8].tap do |a|
|
148
|
+
attrs[n+= 1].tap do |a|
|
150
149
|
a.group.should == "item1"
|
151
150
|
a.name.should == "TEL"
|
152
151
|
a.value.should == "2 56 38 54"
|
153
152
|
a.params.should == {'type' => %w(pref)}
|
154
153
|
end
|
155
|
-
|
156
|
-
attrs[
|
154
|
+
|
155
|
+
attrs[n+= 1].tap do |a|
|
157
156
|
a.group.should == "item2"
|
158
157
|
a.name.should == "TEL"
|
159
158
|
a.value.should == "5 66"
|
160
159
|
a.params.should == {'type' => %w(pref)}
|
161
160
|
end
|
162
161
|
|
162
|
+
attrs[n+= 1].tap do |a|
|
163
|
+
a.group.should == nil
|
164
|
+
a.name.should == "TEL"
|
165
|
+
a.value.should == "3 55"
|
166
|
+
a.params.should == {'type' => %w(CELL VOICE)}
|
167
|
+
end
|
163
168
|
|
164
|
-
attrs[
|
169
|
+
attrs[n+=1].tap do |a|
|
165
170
|
a.name.should == "UID"
|
166
171
|
a.value.should == "11"
|
167
172
|
a.params.should == {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcard_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Ammous
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A vCard parser
|
14
14
|
email:
|
@@ -17,8 +17,8 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- .gitignore
|
21
|
-
- .travis.yml
|
20
|
+
- ".gitignore"
|
21
|
+
- ".travis.yml"
|
22
22
|
- ChangeLog
|
23
23
|
- Gemfile
|
24
24
|
- Guardfile
|
@@ -45,17 +45,17 @@ require_paths:
|
|
45
45
|
- lib
|
46
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
requirements: []
|
57
57
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.
|
58
|
+
rubygems_version: 2.2.2
|
59
59
|
signing_key:
|
60
60
|
specification_version: 4
|
61
61
|
summary: A simple vCard parser
|