vpim 0.695 → 24.2.20
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/bin/reminder +1 -1
- 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 +2 -1
- data/lib/vpim/field.rb +3 -2
- data/lib/vpim/icalendar.rb +18 -7
- 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 +2 -1
- data/lib/vpim/property/resources.rb +1 -2
- data/lib/vpim/repo.rb +3 -2
- 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 +14 -12
- data/lib/vpim/version.rb +2 -2
- data/lib/vpim/vevent.rb +4 -2
- data/lib/vpim/view.rb +4 -3
- data/lib/vpim/vjournal.rb +1 -0
- data/lib/vpim/vpim.rb +2 -1
- data/lib/vpim/vtodo.rb +47 -0
- data/lib/vpim.rb +1 -0
- data/samples/agent.ru +10 -0
- data/samples/reminder.rb +1 -1
- 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 +23 -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 +42 -53
- 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/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.
|
@@ -155,7 +153,7 @@ module Vpim
|
|
155
153
|
def Address.decode(card, field) #:nodoc:
|
156
154
|
adr = new
|
157
155
|
|
158
|
-
parts = Vpim.decode_text_list(field.
|
156
|
+
parts = Vpim.decode_text_list(field.value, ';')
|
159
157
|
|
160
158
|
@@adr_parts.each_with_index do |part,i|
|
161
159
|
adr.instance_variable_set(part, parts[i] || '')
|
@@ -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
|
@@ -162,7 +164,7 @@ module Vpim
|
|
162
164
|
set_date_or_datetime 'DTEND', 'DATE-TIME', dtend
|
163
165
|
end
|
164
166
|
|
165
|
-
# Add a RRULE to this event. The rule can be provided as a pre-
|
167
|
+
# Add a RRULE to this event. The rule can be provided as a pre-built
|
166
168
|
# RRULE value, or the RRULE maker can be used.
|
167
169
|
def add_rrule(rule = nil, &block) #:yield: Rrule::Maker
|
168
170
|
# TODO - should be in Property::Reccurrence::Set
|
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
|
|
@@ -6,11 +7,11 @@
|
|
6
7
|
details.
|
7
8
|
=end
|
8
9
|
|
9
|
-
require "enumerator"
|
10
|
+
require "vpim/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
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
=begin
|
2
3
|
Copyright (C) 2008 Sam Roberts
|
3
4
|
|
@@ -96,6 +97,52 @@ module Vpim
|
|
96
97
|
propinteger 'PERCENT-COMPLETE'
|
97
98
|
end
|
98
99
|
|
100
|
+
# Make a new Vtodo, or make changes to an existing Vtodo.
|
101
|
+
class Maker
|
102
|
+
include Vpim::Icalendar::Set::Util #:nodoc:
|
103
|
+
include Vpim::Icalendar::Set::Common
|
104
|
+
include Vpim::Icalendar::Set::Location
|
105
|
+
|
106
|
+
# The todo that changes are being made to.
|
107
|
+
attr_reader :todo
|
108
|
+
|
109
|
+
def initialize(todo) #:nodoc:
|
110
|
+
@todo = todo
|
111
|
+
@comp = todo
|
112
|
+
end
|
113
|
+
|
114
|
+
# Make changes to +todo+. If +todo+ is not specified, creates a new
|
115
|
+
# todo. Yields a Vtodo::Maker, and returns +todo+.
|
116
|
+
def self.make(todo = Vpim::Icalendar::Vtodo.create) #:yield:maker
|
117
|
+
m = self.new(todo)
|
118
|
+
yield m
|
119
|
+
m.todo
|
120
|
+
end
|
121
|
+
|
122
|
+
# Set transparency to "OPAQUE" or "TRANSPARENT", see Vpim::Vtodo#transparency.
|
123
|
+
def transparency(token)
|
124
|
+
set_token 'TRANSP', ["OPAQUE", "TRANSPARENT"], "OPAQUE", token
|
125
|
+
end
|
126
|
+
|
127
|
+
# Add a RRULE to this todo. The rule can be provided as a pre-built
|
128
|
+
# RRULE value, or the RRULE maker can be used.
|
129
|
+
def add_rrule(rule = nil, &block) #:yield: Rrule::Maker
|
130
|
+
# TODO - should be in Property::Reccurrence::Set
|
131
|
+
unless rule
|
132
|
+
rule = Rrule::Maker.new(&block).encode
|
133
|
+
end
|
134
|
+
@comp.properties.push(Vpim::DirectoryInfo::Field.create("RRULE", rule))
|
135
|
+
self
|
136
|
+
end
|
137
|
+
|
138
|
+
# Set the RRULE for this todo. See #add_rrule
|
139
|
+
def set_rrule(rule = nil, &block) #:yield: Rrule::Maker
|
140
|
+
rm_all("RRULE")
|
141
|
+
add_rrule(rule, &block)
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
99
146
|
end
|
100
147
|
|
101
148
|
end
|
data/lib/vpim.rb
CHANGED
data/samples/agent.ru
ADDED
data/samples/reminder.rb
CHANGED
data/test/test_all.rb
CHANGED
data/test/test_date.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
#!/usr/bin/env ruby
|
2
3
|
|
3
4
|
require 'vpim/date'
|
@@ -38,16 +39,16 @@ class TestVpimDate < Test::Unit::TestCase
|
|
38
39
|
|
39
40
|
def test_bywday
|
40
41
|
|
41
|
-
# 2004
|
42
|
-
#
|
43
|
-
# January February March
|
42
|
+
# 2004
|
43
|
+
#
|
44
|
+
# January February March
|
44
45
|
# S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
|
45
46
|
# 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6
|
46
47
|
# 4 5 6 7 8 9 10 8 9 10 11 12 13 14 7 8 9 10 11 12 13
|
47
48
|
# 11 12 13 14 15 16 17 15 16 17 18 19 20 21 14 15 16 17 18 19 20
|
48
49
|
# 18 19 20 21 22 23 24 22 23 24 25 26 27 28 21 22 23 24 25 26 27
|
49
50
|
# 25 26 27 28 29 30 31 29 28 29 30 31
|
50
|
-
#
|
51
|
+
#
|
51
52
|
do_bywday([2004, 1, 4, 1], [2004, 1, 1])
|
52
53
|
do_bywday([2004, 1, 4, 2], [2004, 1, 8])
|
53
54
|
do_bywday([2004, 1, 4, -1], [2004, 1, 29])
|
@@ -74,7 +75,7 @@ class TestVpimDate < Test::Unit::TestCase
|
|
74
75
|
do_bywday([2004,-12, "th", -2], [2004, 1, 22])
|
75
76
|
do_bywday([2004,-12, "th", -5], [2004, 1, 1])
|
76
77
|
|
77
|
-
# October November December
|
78
|
+
# October November December
|
78
79
|
# S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
|
79
80
|
# 1 2 1 2 3 4 5 6 1 2 3 4
|
80
81
|
# 3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11
|
data/test/test_dur.rb
CHANGED
data/test/test_field.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
#!/usr/bin/env ruby
|
2
3
|
|
3
4
|
require 'test/unit'
|
@@ -15,7 +16,7 @@ class TestField < Test::Unit::TestCase
|
|
15
16
|
assert_equal("+\\+\n+\n+,+;+a+b+c+", dec)
|
16
17
|
enc_out = Vpim.encode_text(dec)
|
17
18
|
should_be = "+\\\\+\\n+\\n+\\,+\\;+a+b+c+"
|
18
|
-
# Note a, b, and c are allowed to be escaped, but shouldn't be and
|
19
|
+
# Note a, b, and c are allowed to be escaped, but shouldn't be and
|
19
20
|
# aren't in output
|
20
21
|
#puts("<#{dec}> => <#{enc_out}>")
|
21
22
|
assert_equal(should_be, enc_out)
|
@@ -134,7 +135,7 @@ class TestField < Test::Unit::TestCase
|
|
134
135
|
assert_equal('Z.B', f.group)
|
135
136
|
|
136
137
|
f.value = 'some text'
|
137
|
-
|
138
|
+
|
138
139
|
assert_equal('some text', f.value)
|
139
140
|
assert_equal('some text', f.value_raw)
|
140
141
|
|
data/test/test_ical.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
#!/usr/bin/env ruby
|
2
3
|
|
3
4
|
require 'vpim/icalendar'
|
@@ -170,7 +171,7 @@ ___
|
|
170
171
|
# Hal was encoding raw strings, here's how to do it with the API.
|
171
172
|
|
172
173
|
cal = Icalendar.create
|
173
|
-
|
174
|
+
|
174
175
|
start = Time.now
|
175
176
|
|
176
177
|
event = Icalendar::Vevent.create(start,
|
@@ -329,7 +330,7 @@ __
|
|
329
330
|
assert_equal(1, vc.events.to_a.size)
|
330
331
|
assert_equal(1, vc.todos.to_a.size)
|
331
332
|
assert_equal(1, vc.journals.to_a.size)
|
332
|
-
|
333
|
+
|
333
334
|
vc.to_s # Shouldn't raise...
|
334
335
|
# TODO - encode isn't round-tripping, unknown components are lost, which is
|
335
336
|
# not good.
|
@@ -421,6 +422,15 @@ __
|
|
421
422
|
assert_equal(cal.events.last.location, nil)
|
422
423
|
end
|
423
424
|
|
425
|
+
def test_set_location
|
426
|
+
vc = Icalendar.create2 do |vc|
|
427
|
+
vc.add_event do |m|
|
428
|
+
m.location("bien located")
|
429
|
+
end
|
430
|
+
end
|
431
|
+
assert_match(/LOCATION:bien located/, vc.to_s)
|
432
|
+
end
|
433
|
+
|
424
434
|
|
425
435
|
def test_event_maker_w_rrule
|
426
436
|
vc = Icalendar.create2 do |vc|
|
@@ -433,5 +443,16 @@ __
|
|
433
443
|
assert_match(/RRULE:FREQ=DAILY/, vc.to_s)
|
434
444
|
end
|
435
445
|
|
446
|
+
def test_todo_maker_w_rrule
|
447
|
+
vc = Icalendar.create2 do |vc|
|
448
|
+
vc.add_todo do |m|
|
449
|
+
m.add_rrule("freq=monthly")
|
450
|
+
m.set_rrule do |_| _.frequency = "daily" end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
assert_no_match(/RRULE:FREQ=MONTHLY/, vc.to_s)
|
454
|
+
assert_match(/RRULE:FREQ=DAILY/, vc.to_s)
|
455
|
+
end
|
456
|
+
|
436
457
|
end
|
437
458
|
|
data/test/test_misc.rb
ADDED
data/test/test_repo.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
#!/usr/bin/env ruby
|
2
3
|
|
3
4
|
require 'vpim/repo'
|
4
|
-
require '
|
5
|
+
require File.expand_path('../common', __FILE__)
|
5
6
|
|
6
7
|
class TestRepo < Test::Unit::TestCase
|
7
8
|
Apple3 = Vpim::Repo::Apple3
|
@@ -50,7 +51,7 @@ class TestRepo < Test::Unit::TestCase
|
|
50
51
|
_test_each(repo, 1)
|
51
52
|
end
|
52
53
|
|
53
|
-
def
|
54
|
+
def test_uri_http
|
54
55
|
caldata = open('test/calendars/weather.calendar/Events/1205042405-0-0.ics').read
|
55
56
|
|
56
57
|
server = data_on_port(caldata, 9876)
|
@@ -68,6 +69,25 @@ class TestRepo < Test::Unit::TestCase
|
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
72
|
+
def test_uri_webcal
|
73
|
+
caldata = open('test/calendars/weather.calendar/Events/1205042405-0-0.ics').read
|
74
|
+
|
75
|
+
server = data_on_port(caldata, 9876)
|
76
|
+
begin
|
77
|
+
c = Uri::Calendar.new("webcal://localhost:9876")
|
78
|
+
assert_equal(caldata, c.encode)
|
79
|
+
|
80
|
+
repo = Uri.new("webcal://localhost:9876")
|
81
|
+
|
82
|
+
assert_equal(1, repo.count)
|
83
|
+
|
84
|
+
_test_each(repo, 1)
|
85
|
+
ensure
|
86
|
+
server.kill
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
71
91
|
def test_uri_invalid
|
72
92
|
assert_raises(ArgumentError) do
|
73
93
|
Uri.new("url")
|
data/test/test_rrule.rb
CHANGED