vpim 0.695 → 13.11.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{README → README.rdoc} +2 -13
- data/lib/vpim.rb +1 -0
- data/lib/vpim/address.rb +3 -2
- data/lib/vpim/agent/atomize.rb +4 -0
- data/lib/vpim/agent/base.rb +74 -0
- data/lib/vpim/agent/calendars.rb +1 -0
- data/lib/vpim/agent/handler.rb +27 -0
- data/lib/vpim/agent/ics.rb +162 -0
- data/lib/vpim/attachment.rb +1 -0
- data/lib/vpim/date.rb +3 -2
- data/lib/vpim/dirinfo.rb +5 -4
- data/lib/vpim/duration.rb +1 -0
- data/lib/vpim/enumerator.rb +1 -0
- data/lib/vpim/field.rb +3 -2
- data/lib/vpim/icalendar.rb +9 -5
- data/lib/vpim/maker/vcard.rb +1 -0
- data/lib/vpim/property/base.rb +1 -0
- data/lib/vpim/property/common.rb +1 -0
- data/lib/vpim/property/location.rb +10 -0
- data/lib/vpim/property/priority.rb +2 -1
- data/lib/vpim/property/recurrence.rb +1 -0
- data/lib/vpim/property/resources.rb +1 -2
- data/lib/vpim/repo.rb +2 -1
- data/lib/vpim/rfc2425.rb +32 -24
- data/lib/vpim/rrule.rb +9 -8
- data/lib/vpim/time.rb +1 -0
- data/lib/vpim/vcard.rb +13 -11
- data/lib/vpim/version.rb +2 -2
- data/lib/vpim/vevent.rb +3 -1
- data/lib/vpim/view.rb +3 -2
- data/lib/vpim/vjournal.rb +1 -0
- data/lib/vpim/vpim.rb +2 -1
- data/lib/vpim/vtodo.rb +1 -0
- data/samples/agent.ru +10 -0
- data/test/test_all.rb +2 -0
- data/test/test_date.rb +6 -5
- data/test/test_dur.rb +1 -0
- data/test/test_field.rb +3 -2
- data/test/test_ical.rb +12 -2
- data/test/test_misc.rb +13 -0
- data/test/test_repo.rb +22 -2
- data/test/test_rrule.rb +1 -0
- data/test/test_vcard.rb +53 -1
- metadata +36 -46
- data/lib/vpim/agent/app.rb +0 -194
- data/lib/vpim/agent/main.rb +0 -327
- data/lib/vpim/agent/scraps.rb +0 -292
- data/test/test_agent_app.rb +0 -74
- data/test/test_agent_atomize.rb +0 -84
- data/test/test_agent_calendars.rb +0 -128
- data/test/test_view.rb +0 -79
data/lib/vpim/icalendar.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -30,15 +31,18 @@ module Vpim
|
|
30
31
|
#
|
31
32
|
# The iCalendar format is specified by a series of IETF documents:
|
32
33
|
#
|
33
|
-
# -
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
34
|
+
# - RFC2445[http://www.ietf.org/rfc/rfc2445.txt]: Internet Calendaring and
|
35
|
+
# Scheduling Core Object Specification
|
36
|
+
# - RFC2446[http://www.ietf.org/rfc/rfc2446.txt]: iCalendar
|
37
|
+
# Transport-Independent Interoperability Protocol (iTIP) Scheduling Events,
|
38
|
+
# BusyTime, To-dos and Journal Entries
|
39
|
+
# - RFC2447[http://www.ietf.org/rfc/rfc2447.txt]: iCalendar Message-Based
|
40
|
+
# Interoperability Protocol
|
37
41
|
#
|
38
42
|
# = iCalendar and vCalendar
|
39
43
|
#
|
40
44
|
# iCalendar files have VERSION:2.0 and vCalendar have VERSION:1.0. iCalendar
|
41
|
-
# (RFC 2445) is based on vCalendar, but
|
45
|
+
# (RFC 2445) is based on vCalendar, but is not very compatible. While
|
42
46
|
# much appears to be similar, the recurrence rule syntax is completely
|
43
47
|
# different.
|
44
48
|
#
|
data/lib/vpim/maker/vcard.rb
CHANGED
data/lib/vpim/property/base.rb
CHANGED
data/lib/vpim/property/common.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -29,9 +30,18 @@ module Vpim
|
|
29
30
|
end
|
30
31
|
prop
|
31
32
|
end
|
33
|
+
end
|
34
|
+
end
|
32
35
|
|
36
|
+
# add a location property to (v)events. This is specified in the RFC 2445
|
37
|
+
module Set
|
38
|
+
module Location
|
39
|
+
def location(value)
|
40
|
+
set_text 'LOCATION', value
|
41
|
+
end
|
33
42
|
end
|
34
43
|
end
|
44
|
+
|
35
45
|
end
|
36
46
|
end
|
37
47
|
|
data/lib/vpim/repo.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -188,7 +189,7 @@ module Vpim
|
|
188
189
|
uri
|
189
190
|
else
|
190
191
|
begin
|
191
|
-
URI.parse(uri)
|
192
|
+
URI.parse(uri.sub(/^webcal:/, "http:"))
|
192
193
|
rescue URI::InvalidURIError => e
|
193
194
|
raise ArgumentError, "Invalid URI for #{uri.inspect} - #{e.to_s}"
|
194
195
|
end
|
data/lib/vpim/rfc2425.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -21,13 +22,13 @@ module Vpim
|
|
21
22
|
|
22
23
|
# <"> <Any character except CTLs, DQUOTE> <">
|
23
24
|
QSTR = '"([^"]*)"'
|
24
|
-
|
25
|
+
|
25
26
|
# *<Any character except CTLs, DQUOTE, ";", ":", ",">
|
26
27
|
PTEXT = '([^";:,]+)'
|
27
|
-
|
28
|
+
|
28
29
|
# param-value = ptext / quoted-string
|
29
30
|
PVALUE = "(?:#{QSTR}|#{PTEXT})"
|
30
|
-
|
31
|
+
|
31
32
|
# param = name "=" param-value *("," param-value)
|
32
33
|
# Note: v2.1 allows a type or encoding param-value to appear without the type=
|
33
34
|
# or the encoding=. This is hideous, but we try and support it, if there
|
@@ -76,29 +77,36 @@ module Vpim
|
|
76
77
|
# This also supports the (invalid) encoding convention of allowing empty
|
77
78
|
# lines to be inserted for readability - it does this by dropping zero-length
|
78
79
|
# lines.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
80
|
+
#
|
81
|
+
# Also supports an the QUOTED-PRINTABLE soft line-break as described here:
|
82
|
+
# http://en.wikipedia.org/wiki/Quoted-printable
|
83
|
+
#
|
84
|
+
def Vpim.unfold(card) # :nodoc:
|
85
|
+
unfolded = []
|
86
|
+
# Ruby 1.9's String can no longer be iterated with #each, so the following
|
87
|
+
# code, which used to work with String, or Array, or File, or anything else
|
88
|
+
# which produced lines when iterated, now just works with String. Sucky.
|
89
|
+
card.each_line do |line|
|
90
|
+
line.chomp!
|
91
|
+
# If it's a continuation line, add it to the last.
|
92
|
+
# If it's an empty line, drop it from the input.
|
93
|
+
if( line =~ /^[ \t]/ )
|
94
|
+
unfolded[-1] << line[1, line.size-1]
|
95
|
+
elsif (unfolded.last && unfolded.last =~ /;ENCODING=QUOTED-PRINTABLE:.*?=$/)
|
96
|
+
unfolded.last << line
|
97
|
+
elsif( line =~ /^$/ )
|
98
|
+
else
|
99
|
+
unfolded << line
|
92
100
|
end
|
93
|
-
|
94
|
-
|
101
|
+
end
|
102
|
+
unfolded
|
95
103
|
end
|
96
104
|
|
97
105
|
# Convert a +sep+-seperated list of values into an array of values.
|
98
106
|
def Vpim.decode_list(value, sep = ',') # :nodoc:
|
99
107
|
list = []
|
100
|
-
|
101
|
-
value.
|
108
|
+
|
109
|
+
value.each_line(sep) do |item|
|
102
110
|
item.chomp!(sep)
|
103
111
|
list << yield(item)
|
104
112
|
end
|
@@ -245,14 +253,14 @@ module Vpim
|
|
245
253
|
# FIXME - I think this should trim leading and trailing space
|
246
254
|
v.gsub(/\\(.)/) do
|
247
255
|
case $1
|
248
|
-
when 'n', 'N'
|
256
|
+
when 'n', 'N'
|
249
257
|
"\n"
|
250
258
|
else
|
251
259
|
$1
|
252
260
|
end
|
253
261
|
end
|
254
262
|
end
|
255
|
-
|
263
|
+
|
256
264
|
def Vpim.encode_text(v) #:nodoc:
|
257
265
|
v.to_str.gsub(/([\\,;\n])/) { $1 == "\n" ? "\\n" : "\\"+$1 }
|
258
266
|
end
|
@@ -286,7 +294,7 @@ module Vpim
|
|
286
294
|
when %r{\A#{Bnf::SAFECHAR}*\z}
|
287
295
|
value
|
288
296
|
else
|
289
|
-
raise Vpim::
|
297
|
+
raise Vpim::Unencodeable, "paramtext #{value.inspect}"
|
290
298
|
end
|
291
299
|
end
|
292
300
|
|
@@ -297,7 +305,7 @@ module Vpim
|
|
297
305
|
when %r{\A#{Bnf::QSAFECHAR}*\z}
|
298
306
|
'"' + value + '"'
|
299
307
|
else
|
300
|
-
raise Vpim::
|
308
|
+
raise Vpim::Unencodeable, "param-value #{value.inspect}"
|
301
309
|
end
|
302
310
|
end
|
303
311
|
|
data/lib/vpim/rrule.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -65,20 +66,20 @@ module Vpim
|
|
65
66
|
|
66
67
|
# Freq is mandatory, but must occur only once.
|
67
68
|
@freq = nil
|
68
|
-
|
69
|
+
|
69
70
|
# Both Until and Count must not occur, neither is OK.
|
70
71
|
@until = nil
|
71
72
|
@count = nil
|
72
|
-
|
73
|
+
|
73
74
|
# Interval is optional, but defaults to 1.
|
74
75
|
@interval = 1
|
75
76
|
|
76
77
|
# WKST defines what day a week begins on, the default is monday.
|
77
78
|
@wkst = 'MO'
|
78
|
-
|
79
|
+
|
79
80
|
# Recurrence can modified by these.
|
80
81
|
@by = {}
|
81
|
-
|
82
|
+
|
82
83
|
if @rrule
|
83
84
|
@rrule.scan(/([^;=]+)=([^;=]+)/) do |key,value|
|
84
85
|
key.upcase!
|
@@ -256,10 +257,10 @@ module Vpim
|
|
256
257
|
end
|
257
258
|
|
258
259
|
# TODO - BYHOUR, BYMINUTE, BYSECOND
|
259
|
-
|
260
|
-
hour = [@dtstart.hour] if !hour
|
261
|
-
min = [@dtstart.min] if !min
|
262
|
-
sec = [@dtstart.sec] if !sec
|
260
|
+
|
261
|
+
hour = [@dtstart.hour] if !hour
|
262
|
+
min = [@dtstart.min] if !min
|
263
|
+
sec = [@dtstart.sec] if !sec
|
263
264
|
|
264
265
|
# debug days
|
265
266
|
|
data/lib/vpim/time.rb
CHANGED
data/lib/vpim/vcard.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : binary -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -17,8 +18,8 @@ module Vpim
|
|
17
18
|
# A vCard, a specialization of a directory info object.
|
18
19
|
#
|
19
20
|
# The vCard format is specified by:
|
20
|
-
# - RFC2426: vCard MIME Directory Profile (vCard 3.0)
|
21
|
-
# - RFC2425: A MIME Content-Type for Directory Information
|
21
|
+
# - RFC2426[http://www.ietf.org/rfc/rfc2426.txt]: vCard MIME Directory Profile (vCard 3.0)
|
22
|
+
# - RFC2425[http://www.ietf.org/rfc/rfc2425.txt]: A MIME Content-Type for Directory Information
|
22
23
|
#
|
23
24
|
# This implements vCard 3.0, but it is also capable of working with vCard 2.1
|
24
25
|
# if used with care.
|
@@ -26,7 +27,7 @@ module Vpim
|
|
26
27
|
# All line values can be accessed with Vcard#value, Vcard#values, or even by
|
27
28
|
# iterating through Vcard#lines. Line types that don't have specific support
|
28
29
|
# and non-standard line types ("X-MY-SPECIAL", for example) will be returned
|
29
|
-
# as a String, with any base64 or quoted-printable encoding removed.
|
30
|
+
# as a String, with any base64 or quoted-printable encoding removed.
|
30
31
|
#
|
31
32
|
# Specific support exists to return more useful values for the standard vCard
|
32
33
|
# types, where appropriate.
|
@@ -41,13 +42,10 @@ module Vpim
|
|
41
42
|
# lines, and both the singular and plural forms will eventually be
|
42
43
|
# implemented.
|
43
44
|
#
|
44
|
-
# If there is sufficient demand, specific support for vCard 2.1 could be
|
45
|
-
# implemented.
|
46
|
-
#
|
47
45
|
# For more information see:
|
48
|
-
# -
|
49
|
-
# -
|
50
|
-
# - http://www.imc.org/pdi/pdiproddev.html: vCard 2.1 Specifications
|
46
|
+
# - RFC2426[http://www.ietf.org/rfc/rfc2426.txt]: vCard MIME Directory Profile (vCard 3.0)
|
47
|
+
# - RFC2425[http://www.ietf.org/rfc/rfc2425.txt]: A MIME Content-Type for Directory Information
|
48
|
+
# - vCard2.1[http://www.imc.org/pdi/pdiproddev.html]: vCard 2.1 Specifications
|
51
49
|
#
|
52
50
|
# vCards are usually transmitted in files with <code>.vcf</code>
|
53
51
|
# extensions.
|
@@ -275,7 +273,7 @@ module Vpim
|
|
275
273
|
end
|
276
274
|
|
277
275
|
# Represents the value of a TEL field.
|
278
|
-
#
|
276
|
+
#
|
279
277
|
# The value is supposed to be a "X.500 Telephone Number" according to RFC
|
280
278
|
# 2426, but that standard is not freely available. Otherwise, anything that
|
281
279
|
# looks like a phone number should be OK.
|
@@ -672,6 +670,8 @@ module Vpim
|
|
672
670
|
raise ArgumentError, "Vcard.decode cannot be called with a #{card.type}"
|
673
671
|
end
|
674
672
|
|
673
|
+
string.force_encoding "BINARY"
|
674
|
+
|
675
675
|
case string
|
676
676
|
when /^\xEF\xBB\xBF/
|
677
677
|
string = string.sub("\xEF\xBB\xBF", '')
|
@@ -689,6 +689,8 @@ module Vpim
|
|
689
689
|
string = string.unpack('v*').pack('U*')
|
690
690
|
end
|
691
691
|
|
692
|
+
string.force_encoding "utf-8"
|
693
|
+
|
692
694
|
entities = Vpim.expand(Vpim.decode(string))
|
693
695
|
|
694
696
|
# Since all vCards must have a begin/end, the top-level should consist
|
@@ -1384,7 +1386,7 @@ module Vpim
|
|
1384
1386
|
# Copy the fields from +card+ into self using #add_field. If a block is
|
1385
1387
|
# provided, each Field from +card+ is yielded. The block should return a
|
1386
1388
|
# Field to add, or nil. The Field doesn't have to be the one yielded,
|
1387
|
-
# allowing the field to be copied and modified (see Field#copy) before adding, or
|
1389
|
+
# allowing the field to be copied and modified (see Field#copy) before adding, or
|
1388
1390
|
# not added at all if the block yields nil.
|
1389
1391
|
#
|
1390
1392
|
# The vCard fields BEGIN and END aren't copied, and VERSION, N, and FN are copied
|
data/lib/vpim/version.rb
CHANGED
data/lib/vpim/vevent.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -103,7 +104,7 @@ module Vpim
|
|
103
104
|
|
104
105
|
# put invitee in as field[1]
|
105
106
|
fields << invitee.encode('ATTENDEE') if i == 1
|
106
|
-
|
107
|
+
|
107
108
|
fields << f unless f.name? 'ATTENDEE'
|
108
109
|
end
|
109
110
|
|
@@ -135,6 +136,7 @@ module Vpim
|
|
135
136
|
class Maker
|
136
137
|
include Vpim::Icalendar::Set::Util #:nodoc:
|
137
138
|
include Vpim::Icalendar::Set::Common
|
139
|
+
include Vpim::Icalendar::Set::Location
|
138
140
|
|
139
141
|
# The event that changes are being made to.
|
140
142
|
attr_reader :event
|
data/lib/vpim/view.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -10,7 +11,7 @@ require "enumerator"
|
|
10
11
|
|
11
12
|
module Vpim
|
12
13
|
module View
|
13
|
-
|
14
|
+
|
14
15
|
SECSPERDAY = 24 * 60 * 60
|
15
16
|
|
16
17
|
# View only events occuring in the next week.
|
@@ -50,7 +51,7 @@ module Vpim
|
|
50
51
|
end
|
51
52
|
__
|
52
53
|
=begin
|
53
|
-
block = lambda do |dountil|
|
54
|
+
block = lambda do |dountil|
|
54
55
|
unless block_given?
|
55
56
|
return Enumerable::Enumerator.new(self, :occurrences, dountil)
|
56
57
|
end
|
data/lib/vpim/vjournal.rb
CHANGED
data/lib/vpim/vpim.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -21,7 +22,7 @@ module Vpim
|
|
21
22
|
# If its unsupported, its likely because I didn't anticipate it being useful
|
22
23
|
# to support this, and it likely it could be supported on request.
|
23
24
|
class UnsupportedError < StandardError; end
|
24
|
-
|
25
|
+
|
25
26
|
# Exception used to indicate that encoding failed, probably because the
|
26
27
|
# object would not result in validly encoded data. The message should
|
27
28
|
# describe what is unsupported.
|
data/lib/vpim/vtodo.rb
CHANGED
data/samples/agent.ru
ADDED
data/test/test_all.rb
CHANGED