vpim 0.17 → 0.323
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/lib/vpim/dirinfo.rb +11 -5
- data/lib/vpim/field.rb +26 -21
- data/lib/vpim/icalendar.rb +21 -105
- data/lib/vpim/maker/vcard.rb +31 -28
- data/lib/vpim/property/base.rb +63 -0
- data/lib/vpim/property/common.rb +159 -0
- data/lib/vpim/property/location.rb +29 -0
- data/lib/vpim/property/priority.rb +35 -0
- data/lib/vpim/property/resources.rb +16 -0
- data/lib/vpim/rfc2425.rb +21 -4
- data/lib/vpim/rrule.rb +1 -1
- data/lib/vpim/vcard.rb +5 -5
- data/lib/vpim/version.rb +16 -0
- data/lib/vpim/vevent.rb +54 -204
- data/lib/vpim/vpim.rb +10 -15
- data/lib/vpim.rb +14 -0
- metadata +9 -19
- data/lib/vpim/agent/plist.rb +0 -86
- data/lib/vpim/date.rb~ +0 -198
- data/lib/vpim/dirinfo.rb~ +0 -242
- data/lib/vpim/duration.rb~ +0 -121
- data/lib/vpim/enumerator.rb~ +0 -29
- data/lib/vpim/field.rb~ +0 -594
- data/lib/vpim/icalendar.rb~ +0 -548
- data/lib/vpim/maker/vcard.rb~ +0 -382
- data/lib/vpim/rfc2425.rb~ +0 -246
- data/lib/vpim/rrule.rb~ +0 -482
- data/lib/vpim/time.rb~ +0 -42
- data/lib/vpim/vcard.rb~ +0 -232
- data/lib/vpim/vevent.rb~ +0 -381
- data/lib/vpim/vpim.rb~ +0 -128
@@ -0,0 +1,159 @@
|
|
1
|
+
module Vpim
|
2
|
+
class Icalendar
|
3
|
+
module Property
|
4
|
+
|
5
|
+
# Properties common to Vevent, Vtodo, and Vjournal.
|
6
|
+
module Common
|
7
|
+
|
8
|
+
# This property defines the access classification for a calendar
|
9
|
+
# component.
|
10
|
+
#
|
11
|
+
# An access classification is only one component of the general
|
12
|
+
# security system within a calendar application. It provides a method
|
13
|
+
# of capturing the scope of the access the calendar owner intends for
|
14
|
+
# information within an individual calendar entry. The access
|
15
|
+
# classification of an individual iCalendar component is useful when
|
16
|
+
# measured along with the other security components of a calendar
|
17
|
+
# system (e.g., calendar user authentication, authorization, access
|
18
|
+
# rights, access role, etc.). Hence, the semantics of the individual
|
19
|
+
# access classifications cannot be completely defined by this memo
|
20
|
+
# alone. Additionally, due to the "blind" nature of most exchange
|
21
|
+
# processes using this memo, these access classifications cannot serve
|
22
|
+
# as an enforcement statement for a system receiving an iCalendar
|
23
|
+
# object. Rather, they provide a method for capturing the intention of
|
24
|
+
# the calendar owner for the access to the calendar component.
|
25
|
+
#
|
26
|
+
# Property Name: CLASS
|
27
|
+
#
|
28
|
+
# Property Value: one of "PUBLIC", "PRIVATE", "CONFIDENTIAL", default
|
29
|
+
# is "PUBLIC" if no CLASS property is found.
|
30
|
+
def access_class
|
31
|
+
proptoken 'CLASS', ["PUBLIC", "PRIVATE", "CONFIDENTIAL"], "PUBLIC"
|
32
|
+
end
|
33
|
+
|
34
|
+
def created
|
35
|
+
proptime 'CREATED'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Description of the calendar component, or nil if there is no description.
|
39
|
+
def description
|
40
|
+
proptext 'DESCRIPTION'
|
41
|
+
end
|
42
|
+
|
43
|
+
# The time stamp for this calendar component.
|
44
|
+
def dtstamp
|
45
|
+
proptime 'DTSTAMP'
|
46
|
+
end
|
47
|
+
|
48
|
+
# The start time for this calendar component.
|
49
|
+
def dtstart
|
50
|
+
proptime 'DTSTART'
|
51
|
+
end
|
52
|
+
|
53
|
+
def lastmod
|
54
|
+
proptime 'LAST-MODIFIED'
|
55
|
+
end
|
56
|
+
|
57
|
+
# Return the event organizer, an object of Icalendar::Address (or nil if
|
58
|
+
# there is no ORGANIZER field).
|
59
|
+
def organizer
|
60
|
+
organizer = @properties.field('ORGANIZER')
|
61
|
+
|
62
|
+
if organizer
|
63
|
+
organizer = Icalendar::Address.new(organizer)
|
64
|
+
end
|
65
|
+
|
66
|
+
organizer.freeze
|
67
|
+
end
|
68
|
+
|
69
|
+
=begin
|
70
|
+
recurid
|
71
|
+
seq
|
72
|
+
=end
|
73
|
+
|
74
|
+
# Status values are not rejected during decoding. However, if the
|
75
|
+
# status is requested, and it's value is not one of the defined
|
76
|
+
# allowable values, an exception is raised.
|
77
|
+
def status
|
78
|
+
case self
|
79
|
+
when Vpim::Icalendar::Vevent
|
80
|
+
proptoken 'STATUS', ['TENTATIVE', 'CONFIRMED', 'CANCELLED']
|
81
|
+
|
82
|
+
when Vpim::Icalendar::Vtodo
|
83
|
+
proptoken 'STATUS', ['NEEDS-ACTION', 'COMPLETED', 'IN-PROCESS', 'CANCELLED']
|
84
|
+
|
85
|
+
when Vpim::Icalendar::Vevent
|
86
|
+
proptoken 'STATUS', ['DRAFT', 'FINAL', 'CANCELLED']
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# TODO - def status? ...
|
91
|
+
|
92
|
+
# TODO - def status= ...
|
93
|
+
|
94
|
+
# Summary description of the calendar component, or nil if there is no
|
95
|
+
# SUMMARY property.
|
96
|
+
def summary
|
97
|
+
proptext 'SUMMARY'
|
98
|
+
end
|
99
|
+
|
100
|
+
# The unique identifier of this calendar component, a string.
|
101
|
+
def uid
|
102
|
+
proptext 'UID'
|
103
|
+
end
|
104
|
+
|
105
|
+
def url
|
106
|
+
propvalue 'URL'
|
107
|
+
end
|
108
|
+
|
109
|
+
# Return an array of attendees, an empty array if there are none. The
|
110
|
+
# attendees are objects of Icalendar::Address. If +uri+ is specified
|
111
|
+
# only the return the attendees with this +uri+.
|
112
|
+
def attendees(uri = nil)
|
113
|
+
attendees = @properties.enum_by_name('ATTENDEE').map { |a| Icalendar::Address.new(a).freeze }
|
114
|
+
attendees.freeze
|
115
|
+
if uri
|
116
|
+
attendees.select { |a| a == uri }
|
117
|
+
else
|
118
|
+
attendees
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Return true if the +uri+, usually a mailto: URI, is an attendee.
|
123
|
+
def attendee?(uri)
|
124
|
+
attendees.include? uri
|
125
|
+
end
|
126
|
+
|
127
|
+
# categories = "CATEGORIES" catparam ":" text *("," text)
|
128
|
+
# comment = "COMMENT" commparam ":" text
|
129
|
+
# contact = "CONTACT" contparam ":" text
|
130
|
+
|
131
|
+
# This property defines the categories for a calendar component.
|
132
|
+
#
|
133
|
+
# Property Name: CATEGORIES
|
134
|
+
#
|
135
|
+
# Value Type: TEXT
|
136
|
+
#
|
137
|
+
# Ruby Type: Array of String
|
138
|
+
#
|
139
|
+
# This property is used to specify categories or subtypes of the
|
140
|
+
# calendar component. The categories are useful in searching for a
|
141
|
+
# calendar component of a particular type and category.
|
142
|
+
def categories
|
143
|
+
proptextlistarray 'CATEGORIES'
|
144
|
+
end
|
145
|
+
|
146
|
+
def comments
|
147
|
+
proptextarray 'COMMENT'
|
148
|
+
end
|
149
|
+
|
150
|
+
def contacts
|
151
|
+
proptextarray 'CONTACT'
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Vpim
|
2
|
+
class Icalendar
|
3
|
+
module Property
|
4
|
+
module Location
|
5
|
+
# Physical location information relevant to the component, or nil if
|
6
|
+
# there is no LOCATION property.
|
7
|
+
def location
|
8
|
+
proptext 'LOCATION'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Array of Float, +[ latitude, longitude]+.
|
12
|
+
#
|
13
|
+
# North or equator is postive latitude, East of meridian is positive logitude.
|
14
|
+
#
|
15
|
+
# See RFC2445 for more info... there are lots of special cases.
|
16
|
+
def geo
|
17
|
+
prop = @properties.detect { |f| f.name? 'GEO' }
|
18
|
+
if prop
|
19
|
+
prop = Vpim.decode_list(prop.value_raw, ';') do |item| item.to_f end
|
20
|
+
end
|
21
|
+
prop
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Vpim
|
2
|
+
class Icalendar
|
3
|
+
module Property
|
4
|
+
module Priority
|
5
|
+
|
6
|
+
# +priority+ is a number from 1 to 9, with 1 being the highest
|
7
|
+
# priority, 9 being the lowest. 0 means "no priority", equivalent to
|
8
|
+
# not specifying the PRIORITY field.
|
9
|
+
#
|
10
|
+
# The other integer values are reserved by RFC2445.
|
11
|
+
#
|
12
|
+
# TODO
|
13
|
+
# - methods to compare priorities?
|
14
|
+
# - return as class Priority, with #to_i, and #to_s, and appropriate
|
15
|
+
# comparison operators?
|
16
|
+
def priority
|
17
|
+
p = @properties.detect { |f| f.name? 'PRIORITY' }
|
18
|
+
|
19
|
+
if !p
|
20
|
+
p = 0
|
21
|
+
else
|
22
|
+
p = p.value.to_i
|
23
|
+
|
24
|
+
if( p < 0 || p > 9 )
|
25
|
+
raise Vpim::InvalidEncodingError, 'Invalid priority #{@priority} - it must be 0-9!'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
p
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
data/lib/vpim/rfc2425.rb
CHANGED
@@ -190,9 +190,25 @@ module Vpim
|
|
190
190
|
# \n -> NL
|
191
191
|
# \N -> NL
|
192
192
|
# \, -> ,
|
193
|
+
# \; -> ;
|
193
194
|
def Vpim.decode_text(v) # :nodoc:
|
194
|
-
|
195
|
-
|
195
|
+
v.gsub(/\\(.)/) do
|
196
|
+
case $1
|
197
|
+
when '\\', ',', ';'
|
198
|
+
$1
|
199
|
+
when 'n', 'N'
|
200
|
+
"\n"
|
201
|
+
else
|
202
|
+
raise Vpim::InvalidEncodingError, "TEXT #{v.inspect} uses invalid escape sequence '\\#{$1}'"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Convert a +sep+-seperated list of TEXT values into an array of values.
|
208
|
+
def Vpim.decode_text_list(value, sep = ',') # :nodoc:
|
209
|
+
value.scan(/((?:(?:\\.)|[^#{sep}])+)#{sep}?/).map do |v|
|
210
|
+
Vpim.decode_text(v.first)
|
211
|
+
end
|
196
212
|
end
|
197
213
|
|
198
214
|
|
@@ -216,13 +232,13 @@ module Vpim
|
|
216
232
|
current = [ dst ]
|
217
233
|
|
218
234
|
for f in src
|
219
|
-
if f.name? '
|
235
|
+
if f.name? 'BEGIN'
|
220
236
|
e = [ f ]
|
221
237
|
|
222
238
|
current.last.push(e)
|
223
239
|
current.push(e)
|
224
240
|
|
225
|
-
elsif f.name? '
|
241
|
+
elsif f.name? 'END'
|
226
242
|
current.last.push(f)
|
227
243
|
|
228
244
|
unless current.last.first.value? current.last.last.value
|
@@ -243,6 +259,7 @@ module Vpim
|
|
243
259
|
# an array of all the inner arrays of fields. Return the array [outer,
|
244
260
|
# inner].
|
245
261
|
def Vpim.outer_inner(fields) #:nodoc:
|
262
|
+
# FIXME - use Enumerable#partition
|
246
263
|
# seperate into the outer-level fields, and the arrays of component
|
247
264
|
# fields
|
248
265
|
outer = []
|
data/lib/vpim/rrule.rb
CHANGED
@@ -144,7 +144,7 @@ module Vpim
|
|
144
144
|
# Time.to_a => [ sec, min, hour, day, month, year, wday, yday, isdst, zone ]
|
145
145
|
|
146
146
|
# Every event occurs at least once, at its start time, but only if the start
|
147
|
-
# time is earlier than
|
147
|
+
# time is earlier than DOUNTIL...
|
148
148
|
if !@rrule
|
149
149
|
if !dountil || t < dountil
|
150
150
|
yield t
|
data/lib/vpim/vcard.rb
CHANGED
@@ -55,9 +55,9 @@ module Vpim
|
|
55
55
|
# Here's an example of encoding a simple vCard using the low-level API:
|
56
56
|
#
|
57
57
|
# card = Vpim::Vcard.create
|
58
|
-
# card << Vpim::DirectoryInfo::Field.create('
|
59
|
-
# card << Vpim::DirectoryInfo::Field.create('
|
60
|
-
# card << Vpim::DirectoryInfo::Field.create('
|
58
|
+
# card << Vpim::DirectoryInfo::Field.create('EMAIL', 'user.name@example.com', 'TYPE' => 'INTERNET' )
|
59
|
+
# card << Vpim::DirectoryInfo::Field.create('URL', 'http://www.example.com/user' )
|
60
|
+
# card << Vpim::DirectoryInfo::Field.create('FN', 'User Name' )
|
61
61
|
# puts card.to_s
|
62
62
|
class Vcard < DirectoryInfo
|
63
63
|
|
@@ -154,7 +154,7 @@ module Vpim
|
|
154
154
|
|
155
155
|
# The value of the field named +name+, optionally limited to fields of
|
156
156
|
# type +type+. If no match is found, nil is returned, if multiple matches
|
157
|
-
# are found, the first match to have one of its type values be '
|
157
|
+
# are found, the first match to have one of its type values be 'PREF'
|
158
158
|
# (preferred) is returned, otherwise the first match is returned.
|
159
159
|
def [](name, type=nil)
|
160
160
|
fields = enum_by_name(name).find_all { |f| type == nil || f.type?(type) }
|
@@ -226,7 +226,7 @@ module Vpim
|
|
226
226
|
|
227
227
|
# Deprecated.
|
228
228
|
def nickname #:nodoc:
|
229
|
-
nn = self['
|
229
|
+
nn = self['NICKNAME']
|
230
230
|
if nn && nn == ''
|
231
231
|
nn = nil
|
232
232
|
end
|
data/lib/vpim/version.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (C) 2006 Sam Roberts
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or modify it
|
5
|
+
under the same terms as the ruby language itself, see the file COPYING for
|
6
|
+
details.
|
7
|
+
=end
|
8
|
+
|
9
|
+
module Vpim
|
10
|
+
VERSION = "0.323"
|
11
|
+
|
12
|
+
# Return the API version as a string.
|
13
|
+
def Vpim.version
|
14
|
+
VERSION
|
15
|
+
end
|
16
|
+
end
|