simplevpim 0.5.1 → 0.5.2

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: 23b8411e8323eb6df94ad8219a0789d71be6cb187fc0ac271c3cc3fe8bece742
4
- data.tar.gz: 784fcd0808daa9bcef34deb53c4295235f82ea8777ae54548b3f59932330f3f0
3
+ metadata.gz: bc71394c9c0159ee90f983faf40cc4890fd2795b1cc6cc33ba07aa4a26b6f656
4
+ data.tar.gz: 377e95b34be82c92a221c424614e06232daa11375a045684b2b472b85755ec98
5
5
  SHA512:
6
- metadata.gz: cf3c0f93a8b533b12b6529736c6c31a336c12d52d41b3ed8ac288f03d55c05ff41b47ba7b5993506548b970fedfb067c8875d28e8049df7180811a6c9ac32e46
7
- data.tar.gz: dc942fd4b16ed70e20f9f75faf121019d09c79f52cf5782b4bbf7c66143fe737a5e287431daaaf6c20012ae87f552653700763be604a4328310981cc8554c17e
6
+ metadata.gz: f6a379e565b4f0d502997692ff94557b1a306d3645a3bae9ff4a28bc45cb2fc8d14c0b084c98aab710e218286f4e242a61f0d725cb24449fb76e9402ee5cb865
7
+ data.tar.gz: f753230325b437765ebf0ce01f36991238f98846ef60a760c253a998e0b286d7fa03db15bea4608c94d340d7c813ac55de4c08a08087de6bff9046176e7e75ac
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/simplevpim.rb CHANGED
@@ -11,20 +11,53 @@ require 'unichron'
11
11
 
12
12
 
13
13
  class SimpleVpim
14
+ using ColouredText
14
15
 
15
16
  attr_reader :to_vcard, :to_vevent, :to_xml
17
+
18
+ a = %i(firstname lastname name tel addr email)
19
+ Contact = Struct.new(*a)
20
+ Event = Struct.new(*%i(title summary start end location description))
21
+
22
+ def initialize(rawobj, debug: false)
23
+
24
+ @debug = debug
16
25
 
17
- def initialize(s)
26
+ obj = if block_given? then
27
+
28
+ if rawobj == :event then
29
+
30
+ e = Event.new
31
+ yield e
32
+ e.to_h
33
+
34
+ elsif rawobj == :contact then
18
35
 
19
- kvx = Kvx.new(s)
36
+ puts 'inside contact' if @debug
37
+ c = Contact.new
38
+ yield c
39
+ c.to_h
40
+
41
+ end
42
+
43
+ else
44
+
45
+ rawobj
46
+
47
+ end
48
+
49
+ puts 'obj: ' + obj.inspect if @debug
50
+
51
+ kvx = Kvx.new(obj, debug: false)
52
+
20
53
  @h = kvx.to_h
21
54
 
22
- if s.lstrip =~ /# vcard/ and @h[:name] then
55
+ if @h[:name] or @h[:firstname] or @h[:lastname] then
23
56
 
24
57
  @to_vcard = make_vcard @h
25
58
  @to_xml = vcard_xml @h
26
59
 
27
- elsif @h[:title] or @h[:summary]
60
+ elsif @h[:start]
28
61
 
29
62
  @to_vevent = make_vevent @h
30
63
  @to_xml = vevent_xml kvx.to_xml
@@ -70,6 +103,11 @@ class SimpleVpim
70
103
  end
71
104
 
72
105
  def make_vcard(h)
106
+
107
+ if @debug then
108
+ puts 'inside make_vcard'.info
109
+ puts 'h: ' + h.inspect
110
+ end
73
111
 
74
112
  card = Vpim::Vcard::Maker.make2 do |maker|
75
113
 
@@ -82,8 +120,23 @@ class SimpleVpim
82
120
 
83
121
  prefix = h[:prefix]
84
122
  suffix = h[:suffix]
85
-
86
- firstname, middlename, surname, fullname = extract_names(h[:name])
123
+
124
+ if h[:name] then
125
+
126
+ firstname, middlename, surname, fullname = extract_names(h[:name])
127
+
128
+ elsif h[:firstname] or h[:lastname]
129
+
130
+ firstname = h[:firstname] if h[:firstname]
131
+ surname = h[:lastname] if h[:lastname]
132
+
133
+ fullname = if h[:fullname] then
134
+ h[:fullname]
135
+ else
136
+ [firstname, surname].compact.join(' ')
137
+ end
138
+
139
+ end
87
140
 
88
141
  maker.add_name do |name|
89
142
  name.prefix = prefix if prefix
@@ -108,6 +161,17 @@ class SimpleVpim
108
161
  maker.add_email(eh) { |e| e.location = 'home' } if eh
109
162
  end
110
163
  end
164
+
165
+
166
+ # -- address ------------------------------
167
+
168
+ adr = h[:addr]
169
+ puts ('adr: ' + adr.inspect).debug if @debug
170
+ if adr then
171
+ maker.add_addr do |addr|
172
+ addr.street = adr
173
+ end
174
+ end
111
175
 
112
176
  # -- urls ---------------------------------
113
177
 
@@ -333,7 +397,22 @@ EOF
333
397
  prefix = h[:prefix]
334
398
  suffix = h[:suffix]
335
399
 
336
- firstname, middlename, surname, fullname = extract_names(h[:name])
400
+ if h[:name] then
401
+
402
+ firstname, middlename, surname, fullname = extract_names(h[:name])
403
+
404
+ elsif h[:firstname] or h[:lastname]
405
+
406
+ firstname = h[:firstname] if h[:firstname]
407
+ surname = h[:lastname] if h[:lastname]
408
+
409
+ fullname = if h[:fullname] then
410
+ h[:fullname]
411
+ else
412
+ [firstname, surname].compact.join(' ')
413
+ end
414
+
415
+ end
337
416
 
338
417
  xml = RexleBuilder.new
339
418
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplevpim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  dBpGyLXPFeCV5Z8rWY+S891OLL3UPvcmIiolU7aaNSwvXBGLesCCH6TrIdhw4q2z
36
36
  pM4lNlA3G8w+xUHw/9AE8V6p
37
37
  -----END CERTIFICATE-----
38
- date: 2021-06-21 00:00:00.000000000 Z
38
+ date: 2021-06-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: hlt
metadata.gz.sig CHANGED
Binary file