icalendar 0.96 → 0.96.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -3
- data/Rakefile +3 -4
- data/docs/api/classes/Array.html +148 -0
- data/docs/api/classes/Date.html +159 -0
- data/docs/api/classes/DateTime.html +180 -0
- data/docs/api/classes/Fixnum.html +148 -0
- data/docs/api/classes/Float.html +148 -0
- data/docs/api/classes/HashAttrs.html +199 -0
- data/docs/api/classes/Icalendar/Alarm.html +228 -0
- data/docs/api/classes/Icalendar/Base.html +120 -0
- data/docs/api/classes/Icalendar/Calendar.html +365 -0
- data/docs/api/classes/Icalendar/Component.html +689 -0
- data/docs/api/classes/Icalendar/DateProp.html +187 -0
- data/docs/api/classes/Icalendar/DateProp/ClassMethods.html +195 -0
- data/docs/api/classes/Icalendar/Daylight.html +156 -0
- data/docs/api/classes/Icalendar/Event.html +650 -0
- data/docs/api/classes/Icalendar/Freebusy.html +297 -0
- data/docs/api/classes/Icalendar/InvalidPropertyValue.html +117 -0
- data/docs/api/classes/Icalendar/Journal.html +459 -0
- data/docs/api/classes/Icalendar/Parameter.html +166 -0
- data/docs/api/classes/Icalendar/Parser.html +447 -0
- data/docs/api/classes/Icalendar/Standard.html +156 -0
- data/docs/api/classes/Icalendar/Timezone.html +351 -0
- data/docs/api/classes/Icalendar/Todo.html +496 -0
- data/docs/api/classes/Icalendar/UnknownComponentClass.html +117 -0
- data/docs/api/classes/Icalendar/UnknownPropertyMethod.html +117 -0
- data/docs/api/classes/Object.html +270 -0
- data/docs/api/classes/String.html +148 -0
- data/docs/api/classes/Time.html +163 -0
- data/docs/api/classes/URI.html +111 -0
- data/docs/api/classes/URI/Generic.html +148 -0
- data/docs/api/created.rid +1 -0
- data/docs/api/files/COPYING.html +163 -0
- data/docs/api/files/GPL.html +531 -0
- data/docs/api/files/README.html +254 -0
- data/docs/api/files/lib/hash_attrs_rb.html +107 -0
- data/docs/api/files/lib/icalendar/base_rb.html +108 -0
- data/docs/api/files/lib/icalendar/calendar_rb.html +101 -0
- data/docs/api/files/lib/icalendar/component/alarm_rb.html +101 -0
- data/docs/api/files/lib/icalendar/component/event_rb.html +101 -0
- data/docs/api/files/lib/icalendar/component/freebusy_rb.html +101 -0
- data/docs/api/files/lib/icalendar/component/journal_rb.html +101 -0
- data/docs/api/files/lib/icalendar/component/timezone_rb.html +101 -0
- data/docs/api/files/lib/icalendar/component/todo_rb.html +101 -0
- data/docs/api/files/lib/icalendar/component_rb.html +101 -0
- data/docs/api/files/lib/icalendar/conversions_rb.html +109 -0
- data/docs/api/files/lib/icalendar/helpers_rb.html +101 -0
- data/docs/api/files/lib/icalendar/parameter_rb.html +101 -0
- data/docs/api/files/lib/icalendar/parser_rb.html +109 -0
- data/docs/api/files/lib/icalendar_rb.html +120 -0
- data/docs/api/files/lib/meta_rb.html +107 -0
- data/docs/api/fr_class_index.html +55 -0
- data/docs/api/fr_file_index.html +45 -0
- data/docs/api/fr_method_index.html +79 -0
- data/docs/api/index.html +24 -0
- data/docs/api/rdoc-style.css +208 -0
- data/{docs/examples → examples}/create_cal.rb +6 -2
- data/{docs/examples → examples}/parse_cal.rb +3 -2
- data/{docs/examples → examples}/single_event.ics +0 -0
- data/lib/hash_attrs.rb +29 -0
- data/lib/icalendar.rb +11 -2
- data/lib/icalendar/base.rb +6 -2
- data/lib/icalendar/calendar.rb +1 -1
- data/lib/icalendar/component.rb +98 -71
- data/lib/icalendar/component/alarm.rb +5 -3
- data/lib/icalendar/component/event.rb +1 -1
- data/lib/icalendar/component/freebusy.rb +23 -23
- data/lib/icalendar/component/journal.rb +1 -5
- data/lib/icalendar/component/timezone.rb +7 -0
- data/lib/icalendar/component/todo.rb +1 -6
- data/lib/icalendar/conversions.rb +10 -0
- data/lib/icalendar/parser.rb +82 -85
- data/lib/meta.rb +32 -0
- data/test/component_test.rb +69 -64
- metadata +74 -12
- data/lib/icalendar/foo.rb +0 -394
- data/test/property_helpers.rb +0 -35
data/lib/icalendar/base.rb
CHANGED
@@ -15,7 +15,11 @@ module Icalendar #:nodoc:
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Exception used when the library encounters a bogus calendar component.
|
18
|
-
class
|
18
|
+
class UnknownComponentClass < IcalendarError
|
19
|
+
end
|
20
|
+
|
21
|
+
# Exception used when the library encounters a bogus property type.
|
22
|
+
class UnknownPropertyMethod< IcalendarError
|
19
23
|
end
|
20
24
|
|
21
25
|
# Exception used when the library encounters a bogus property value.
|
@@ -26,6 +30,6 @@ module Icalendar #:nodoc:
|
|
26
30
|
# the library so that the logging system can be configured in one place.
|
27
31
|
class Base
|
28
32
|
@@logger = Logger.new(STDERR)
|
29
|
-
@@logger.level = Logger::
|
33
|
+
@@logger.level = Logger::FATAL
|
30
34
|
end
|
31
35
|
end
|
data/lib/icalendar/calendar.rb
CHANGED
data/lib/icalendar/component.rb
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
details.
|
7
7
|
=end
|
8
8
|
|
9
|
-
require 'breakpoint'
|
10
|
-
|
11
9
|
module Icalendar
|
12
10
|
# The body of the iCalendar object consists of a sequence of calendar
|
13
11
|
# properties and one or more calendar components. The calendar
|
@@ -17,6 +15,9 @@ module Icalendar
|
|
17
15
|
# specify an Event, a Todo, a Journal entry, Timezone information, or
|
18
16
|
# Freebusy time information, or an Alarm.
|
19
17
|
class Component < Icalendar::Base
|
18
|
+
|
19
|
+
meta_include HashAttrs
|
20
|
+
|
20
21
|
attr_reader :name
|
21
22
|
attr_accessor :properties, :property_params
|
22
23
|
|
@@ -42,56 +43,75 @@ module Icalendar
|
|
42
43
|
@components[key] << component
|
43
44
|
end
|
44
45
|
|
46
|
+
alias add add_component
|
47
|
+
|
45
48
|
def to_ical
|
46
|
-
|
49
|
+
print_component do |s|
|
47
50
|
@components.each_value do |comps|
|
48
51
|
comps.each { |component| s << component.to_ical }
|
49
52
|
end
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
53
|
-
|
56
|
+
# Print this icalendar component
|
57
|
+
def print_component
|
54
58
|
s = ""
|
55
59
|
|
56
60
|
# Begin a new component
|
57
61
|
s << "BEGIN:#{@name.upcase}\r\n"
|
58
62
|
|
59
|
-
# Then
|
60
|
-
|
63
|
+
# Then the properties
|
64
|
+
print_properties(s)
|
65
|
+
|
66
|
+
# Any custom body of the derived component
|
67
|
+
yield(s)
|
68
|
+
|
69
|
+
# End of this component
|
70
|
+
s << "END:#{@name.upcase}\r\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Print this components properties
|
74
|
+
def print_properties(s)
|
61
75
|
@properties.each do |key,value|
|
76
|
+
# Take out underscore for property names that conflicted
|
77
|
+
# with built-in words.
|
78
|
+
if key =~ /ip_.*/
|
79
|
+
key = key[3..-1]
|
80
|
+
end
|
81
|
+
|
62
82
|
# Property name
|
63
83
|
s << "#{key.upcase}"
|
64
84
|
|
65
85
|
# Possible parameters
|
66
|
-
|
67
|
-
params = @property_params[key]
|
68
|
-
params.each do |key,val|
|
69
|
-
s << ";#{key}"
|
70
|
-
val = [ val ] unless val.respond_to?(:to_ary)
|
71
|
-
|
72
|
-
# Possible parameter values
|
73
|
-
unless val.empty?
|
74
|
-
s << "="
|
75
|
-
sep = "" # First entry comes after = sign, but then we need commas
|
76
|
-
val.each do |pval|
|
77
|
-
if pval.respond_to? :to_ical
|
78
|
-
s << sep << pval.to_ical
|
79
|
-
sep = ","
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
86
|
+
print_parameter(s, key, value)
|
85
87
|
|
86
88
|
# Property value
|
87
89
|
s << ":#{value.to_ical}\r\n"
|
88
90
|
end
|
91
|
+
end
|
89
92
|
|
90
|
-
|
91
|
-
|
93
|
+
# Print the parameters for a specific property
|
94
|
+
def print_parameter(s, key, value)
|
95
|
+
if @property_params.has_key?(key)
|
96
|
+
params = @property_params[key]
|
97
|
+
params.each do |key,val|
|
98
|
+
s << ";#{key}"
|
99
|
+
val = [ val ] unless val.respond_to?(:to_ary)
|
100
|
+
|
101
|
+
# Possible parameter values
|
102
|
+
unless val.empty?
|
103
|
+
s << "="
|
104
|
+
sep = "" # First entry comes after = sign, but then we need commas
|
105
|
+
val.each do |pval|
|
106
|
+
if pval.respond_to? :to_ical
|
107
|
+
s << sep << pval.to_ical
|
108
|
+
sep = ","
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
92
112
|
|
93
|
-
|
94
|
-
|
113
|
+
end
|
114
|
+
end
|
95
115
|
end
|
96
116
|
|
97
117
|
# TODO: Look into the x-property, x-param stuff...
|
@@ -100,46 +120,19 @@ module Icalendar
|
|
100
120
|
end
|
101
121
|
|
102
122
|
def multi_property?(name)
|
103
|
-
@@multi_properties.has_key?(name)
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
def Component.hash_reader(hash, syms)
|
109
|
-
syms.each do |id|
|
110
|
-
class_eval <<-"stop"
|
111
|
-
def #{id.to_s.downcase}
|
112
|
-
return @#{hash.to_s}[:#{id.to_s.downcase}]
|
113
|
-
end
|
114
|
-
stop
|
115
|
-
puts "Creating method: #{id.to_s.downcase}"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def Component.hash_writer(hash, syms)
|
120
|
-
syms.each do |id|
|
121
|
-
class_eval <<-"stop"
|
122
|
-
def #{id.to_s.downcase}=(val)
|
123
|
-
return @#{hash.to_s}[:#{id.to_s.downcase}] = val
|
124
|
-
end
|
125
|
-
stop
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def Component.hash_attr(hash, syms)
|
130
|
-
hash_reader(hash, syms)
|
131
|
-
hash_writer(hash, syms)
|
123
|
+
@@multi_properties.has_key?(name.upcase)
|
132
124
|
end
|
133
125
|
|
134
126
|
# Make it protected so we can monitor usage...
|
135
127
|
protected
|
136
128
|
|
137
129
|
def Component.ical_component(*syms)
|
138
|
-
|
130
|
+
hash_accessor :components, syms
|
139
131
|
end
|
140
|
-
|
132
|
+
|
141
133
|
# Define a set of methods supporting a new property
|
142
134
|
def Component.ical_property(property, alias_name = nil, prop_name = nil)
|
135
|
+
|
143
136
|
property = "#{property}".strip.downcase
|
144
137
|
getter = "#{property}"
|
145
138
|
setter = "#{property}="
|
@@ -157,17 +150,17 @@ module Icalendar
|
|
157
150
|
|
158
151
|
unless instance_methods.include? getter
|
159
152
|
code = <<-code
|
160
|
-
def #{getter}(
|
161
|
-
if
|
153
|
+
def #{getter}(val = nil, params = {})
|
154
|
+
if val.nil?
|
162
155
|
@properties["#{property}"]
|
163
156
|
else
|
164
|
-
|
157
|
+
# Set the value just like normal
|
158
|
+
self.#{setter}(val)
|
165
159
|
end
|
166
160
|
end
|
167
161
|
code
|
168
162
|
|
169
163
|
class_eval code, "component.rb", 155
|
170
|
-
|
171
164
|
alias_method("#{alias_name}", "#{getter}") unless alias_name.nil?
|
172
165
|
end
|
173
166
|
|
@@ -175,7 +168,7 @@ module Icalendar
|
|
175
168
|
code = <<-code
|
176
169
|
def #{setter}(val)
|
177
170
|
unless val.respond_to?(:to_ical)
|
178
|
-
raise(NotImplementedError, "
|
171
|
+
raise(NotImplementedError, "Value of type (" + val.class.to_s + ") does not support to_ical method!")
|
179
172
|
end
|
180
173
|
|
181
174
|
@properties["#{property}"] = val
|
@@ -249,7 +242,6 @@ module Icalendar
|
|
249
242
|
|
250
243
|
@properties["#{property}"] = a.to_ary
|
251
244
|
|
252
|
-
|
253
245
|
else
|
254
246
|
raise ArgumentError, "#{getter} is a multi-property that must be an array! Use the #{adder} method to add single entries."
|
255
247
|
end
|
@@ -273,20 +265,21 @@ module Icalendar
|
|
273
265
|
# Add another item to this properties array
|
274
266
|
unless instance_methods.include? adder
|
275
267
|
code = <<-code
|
276
|
-
def #{adder}(
|
277
|
-
unless
|
268
|
+
def #{adder}(val, params = {})
|
269
|
+
unless val.respond_to?(:to_ical)
|
278
270
|
raise(NotImplementedError, "Property value object does not support to_ical method!")
|
279
271
|
end
|
280
272
|
|
281
273
|
if @properties.has_key?("#{property}")
|
282
|
-
@properties["#{property}"] <<
|
274
|
+
@properties["#{property}"] << val
|
283
275
|
else
|
284
|
-
@properties["#{property}"] = [
|
276
|
+
@properties["#{property}"] = [val]
|
285
277
|
end
|
286
278
|
end
|
287
279
|
code
|
288
280
|
|
289
281
|
class_eval code, "component.rb", 228
|
282
|
+
alias_method("add_#{property.downcase}", "#{adder}")
|
290
283
|
end
|
291
284
|
|
292
285
|
# Remove an item from this properties array
|
@@ -300,8 +293,42 @@ module Icalendar
|
|
300
293
|
code
|
301
294
|
|
302
295
|
class_eval code, "component.rb", 241
|
296
|
+
alias_method("remove_#{property.downcase}", "#{remover}")
|
303
297
|
end
|
304
298
|
|
305
299
|
end
|
306
|
-
|
300
|
+
|
301
|
+
def method_missing(method_name, *args)
|
302
|
+
method_name = method_name.to_s.downcase
|
303
|
+
|
304
|
+
unless method_name =~ /x_.*/
|
305
|
+
raise NoMethodError
|
306
|
+
end
|
307
|
+
|
308
|
+
val = args.first
|
309
|
+
|
310
|
+
unless val.respond_to?(:to_ical)
|
311
|
+
raise(NotImplementedError, "Value of type (" + val.class.to_s + ") does not support to_ical method!")
|
312
|
+
end
|
313
|
+
|
314
|
+
if method_name =~ /(.*)(=)/ # Its a setter
|
315
|
+
@properties[$1] = val
|
316
|
+
@@logger.debug("Setting #{$1} => #{val}")
|
317
|
+
else # Or its a getter
|
318
|
+
@@logger.debug("Getting #{method_name} => #{@properties[method_name]}")
|
319
|
+
return @properties[method_name]
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
public
|
324
|
+
|
325
|
+
def respond_to?(method_name)
|
326
|
+
unless method_name.to_s.downcase =~ /x-.*/
|
327
|
+
super
|
328
|
+
end
|
329
|
+
|
330
|
+
true
|
331
|
+
end
|
332
|
+
|
333
|
+
end # class Component
|
307
334
|
end
|
@@ -23,13 +23,15 @@ module Icalendar
|
|
23
23
|
# Single and only occurring once
|
24
24
|
ical_property :attach, :attachment
|
25
25
|
|
26
|
+
ical_property :created
|
27
|
+
ical_property :last_modified
|
28
|
+
ical_property :timestamp
|
29
|
+
ical_property :sequence
|
30
|
+
|
26
31
|
def initialize()
|
27
32
|
super("VALARM")
|
28
33
|
|
29
34
|
end
|
30
35
|
|
31
|
-
def to_ical
|
32
|
-
print_string {}
|
33
|
-
end
|
34
36
|
end
|
35
37
|
end
|
@@ -6,30 +6,30 @@
|
|
6
6
|
details.
|
7
7
|
=end
|
8
8
|
module Icalendar
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# A Freebusy calendar component is a grouping of
|
10
|
+
# component properties that represents either a request for, a reply to
|
11
|
+
# a request for free or busy time information or a published set of
|
12
|
+
# busy time information.
|
13
|
+
class Freebusy < Component
|
14
|
+
|
15
|
+
# Single properties
|
16
16
|
ical_property :contact
|
17
17
|
ical_property :dtstart, :start
|
18
18
|
ical_property :dtend, :end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
19
|
+
ical_property :dtstamp, :timestamp
|
20
|
+
ical_property :duration
|
21
|
+
ical_property :organizer
|
22
|
+
ical_property :uid, :user_id
|
23
|
+
ical_property :url
|
24
|
+
|
25
|
+
# Multi-properties
|
26
|
+
ical_multi_property :attendee, :attendee, :attendees
|
27
|
+
ical_multi_property :comment, :comment, :comments
|
28
|
+
ical_multi_property :freebusy, :freebusy, :freebusys
|
29
|
+
ical_multi_property :rstatus, :request_status, :request_statuses
|
30
|
+
|
31
|
+
def initialize()
|
32
|
+
super("VFREEBUSY")
|
33
|
+
end
|
35
34
|
end
|
35
|
+
end
|
@@ -20,7 +20,7 @@ module Icalendar
|
|
20
20
|
class Journal < Component
|
21
21
|
|
22
22
|
# Single properties
|
23
|
-
ical_property :
|
23
|
+
ical_property :ip_class
|
24
24
|
ical_property :created
|
25
25
|
ical_property :description
|
26
26
|
ical_property :dtstart, :start
|
@@ -52,10 +52,6 @@ module Icalendar
|
|
52
52
|
super("VJOURNAL")
|
53
53
|
end
|
54
54
|
|
55
|
-
def to_ical
|
56
|
-
print_string { }
|
57
|
-
end
|
58
|
-
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
@@ -26,6 +26,13 @@ module Icalendar
|
|
26
26
|
ical_property :dtstart, :start
|
27
27
|
ical_property :tzoffsetto, :timezone_offset_to
|
28
28
|
ical_property :tzoffsetfrom, :timezone_offset_from
|
29
|
+
ical_property :tzid, :timezone_id
|
30
|
+
ical_property :tzname, :timezone_name
|
31
|
+
|
32
|
+
ical_property :created
|
33
|
+
ical_property :last_modified
|
34
|
+
ical_property :timestamp
|
35
|
+
ical_property :sequence
|
29
36
|
|
30
37
|
# Multi-properties
|
31
38
|
ical_multi_property :comment, :comment, :comments
|
@@ -15,7 +15,7 @@ module Icalendar
|
|
15
15
|
ical_component :alarms
|
16
16
|
|
17
17
|
# Single properties
|
18
|
-
ical_property :
|
18
|
+
ical_property :ip_class
|
19
19
|
ical_property :completed
|
20
20
|
ical_property :created
|
21
21
|
ical_property :description
|
@@ -54,12 +54,7 @@ module Icalendar
|
|
54
54
|
|
55
55
|
def initialize()
|
56
56
|
super("VTODO")
|
57
|
-
|
58
|
-
@alarms = alarms
|
59
57
|
end
|
60
58
|
|
61
|
-
def to_ical
|
62
|
-
print_string { |s| @alarms.each { |alarm| alarm.to_s } }
|
63
|
-
end
|
64
59
|
end
|
65
60
|
end
|