icalendar 1.4.5 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/README.md +1 -1
- data/lib/icalendar/base.rb +1 -1
- data/lib/icalendar/component.rb +19 -19
- data/test/component/test_event.rb +40 -31
- data/test/test_calendar.rb +28 -9
- data/test/test_component.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f4b5d7252174baceb4b7e37a64286aaa38523ff
|
4
|
+
data.tar.gz: bfa01a3b7d32a7216f82a63f3b216ddfc2bc8745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a79833843dcf6a77bc4d4135e25b1bdaa436db93c4195ef76a40e3e8f00fc01dbf28c24871bac057bf362eea201b066b655a2fe16215da5a32576221d3393658
|
7
|
+
data.tar.gz: a2a2d04e8784be3f057cc9f23adcf45ec365282d035cb8655701fe6d08c531381dc7c0fceb8fb42948f8226042d20b1f7cee56a51e3d0ac46dcf1500cd387cfa
|
data/History.txt
CHANGED
data/README.md
CHANGED
data/lib/icalendar/base.rb
CHANGED
data/lib/icalendar/component.rb
CHANGED
@@ -37,6 +37,8 @@ module Icalendar
|
|
37
37
|
# Freebusy time information, or an Alarm.
|
38
38
|
class Component < Icalendar::Base
|
39
39
|
|
40
|
+
CAL_EXTENSION_REGEX = /\Ax_[a-z_]+=?\Z/
|
41
|
+
|
40
42
|
meta_include HashAttrs
|
41
43
|
|
42
44
|
attr_reader :name
|
@@ -416,32 +418,30 @@ module Icalendar
|
|
416
418
|
end
|
417
419
|
end
|
418
420
|
|
419
|
-
|
420
|
-
@@logger.debug("Inside method_missing...")
|
421
|
-
method_name = method.to_s.downcase
|
422
|
-
|
423
|
-
super unless method_name =~ /x_.*/
|
421
|
+
public
|
424
422
|
|
425
|
-
|
426
|
-
#
|
427
|
-
#
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
else # Or its a getter
|
432
|
-
return @properties[method_name.gsub('x_', 'x-')]
|
433
|
-
end
|
434
|
-
end
|
423
|
+
def method_missing(method_name, *args, &block)
|
424
|
+
# Allow proprietary calendar extensions to be set
|
425
|
+
#
|
426
|
+
# Example:
|
427
|
+
# cal.x_wr_calname = "iCalendar Calendar"
|
428
|
+
if method_name =~ CAL_EXTENSION_REGEX
|
435
429
|
|
436
|
-
|
430
|
+
# Make sure to remove '=' from the end of the method_name so we can
|
431
|
+
# define it
|
432
|
+
name = method_name.to_s.chomp '='
|
437
433
|
|
438
|
-
|
439
|
-
|
440
|
-
|
434
|
+
self.class.class_eval do
|
435
|
+
ical_multiline_property name, name, name
|
436
|
+
end
|
437
|
+
send method_name, *args
|
441
438
|
else
|
442
439
|
super
|
443
440
|
end
|
444
441
|
end
|
445
442
|
|
443
|
+
def respond_to_missing?(method_name, include_private = false)
|
444
|
+
method_name.to_s =~ CAL_EXTENSION_REGEX || super
|
445
|
+
end
|
446
446
|
end # class Component
|
447
447
|
end
|
@@ -23,23 +23,32 @@ class TestEvent < Test::Unit::TestCase
|
|
23
23
|
def test_new
|
24
24
|
assert(@event)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# Properties that can only occur once per event
|
28
28
|
def test_single_properties
|
29
29
|
@event.ip_class = "PRIVATE"
|
30
|
-
|
30
|
+
|
31
31
|
@cal.add_event(@event)
|
32
|
-
|
32
|
+
|
33
33
|
cals = Icalendar::Parser.new(@cal.to_ical).parse
|
34
34
|
cal2 = cals.first
|
35
35
|
event2 = cal2.events.first
|
36
|
-
|
36
|
+
|
37
37
|
assert_equal("PRIVATE", event2.ip_class)
|
38
38
|
end
|
39
|
+
|
40
|
+
def test_proprietary_attributes
|
41
|
+
@cal.add_event @event
|
42
|
+
@event.x_custom_property = 'My Custom Property'
|
43
|
+
|
44
|
+
result = Icalendar::Parser.new(@cal.to_ical).parse.first.events.first
|
45
|
+
|
46
|
+
assert_equal ['My Custom Property'], result.x_custom_property
|
47
|
+
end
|
39
48
|
end
|
40
49
|
|
41
50
|
class TestEventWithSpecifiedTimezone < Test::Unit::TestCase
|
42
|
-
|
51
|
+
|
43
52
|
def setup
|
44
53
|
src = <<EOS
|
45
54
|
BEGIN:VCALENDAR
|
@@ -60,28 +69,28 @@ EOS
|
|
60
69
|
@calendar = Icalendar.parse(src).first
|
61
70
|
@event = @calendar.events.first
|
62
71
|
end
|
63
|
-
|
72
|
+
|
64
73
|
def test_event_is_parsed
|
65
74
|
assert_not_nil(@event)
|
66
75
|
end
|
67
|
-
|
76
|
+
|
68
77
|
def test_dtstart_should_understand_icalendar_tzid
|
69
78
|
assert_respond_to(@event.dtstart, :icalendar_tzid)
|
70
79
|
end
|
71
|
-
|
80
|
+
|
72
81
|
def test_dtstart_tzid_should_be_correct
|
73
82
|
# puts "#{@event.dtstart.icalendar_tzid} #{@event.dtstart}"
|
74
83
|
assert_equal("America/Chicago",@event.dtstart.icalendar_tzid)
|
75
84
|
end
|
76
|
-
|
85
|
+
|
77
86
|
def test_dtend_tzid_should_be_correct
|
78
87
|
assert_equal("America/Chicago",@event.dtend.icalendar_tzid)
|
79
88
|
end
|
80
|
-
|
89
|
+
|
81
90
|
end
|
82
91
|
|
83
92
|
class TestEventWithZuluTimezone < Test::Unit::TestCase
|
84
|
-
|
93
|
+
|
85
94
|
def setup
|
86
95
|
src = <<EOS
|
87
96
|
BEGIN:VCALENDAR
|
@@ -102,24 +111,24 @@ EOS
|
|
102
111
|
@calendar = Icalendar.parse(src).first
|
103
112
|
@event = @calendar.events.first
|
104
113
|
end
|
105
|
-
|
114
|
+
|
106
115
|
def test_event_is_parsed
|
107
116
|
assert_not_nil(@event)
|
108
117
|
end
|
109
|
-
|
118
|
+
|
110
119
|
def test_dtstart_tzid_should_be_correct
|
111
120
|
# puts "#{@event.dtstart.icalendar_tzid} #{@event.dtstart}"
|
112
121
|
assert_equal("UTC",@event.dtstart.icalendar_tzid)
|
113
122
|
end
|
114
|
-
|
123
|
+
|
115
124
|
def test_dtend_tzid_should_be_correct
|
116
125
|
assert_equal("UTC",@event.dtend.icalendar_tzid)
|
117
126
|
end
|
118
|
-
|
127
|
+
|
119
128
|
end
|
120
129
|
|
121
130
|
class TestEventWithFloatingTimezone < Test::Unit::TestCase
|
122
|
-
|
131
|
+
|
123
132
|
def setup
|
124
133
|
src = <<EOS
|
125
134
|
BEGIN:VCALENDAR
|
@@ -140,24 +149,24 @@ EOS
|
|
140
149
|
@calendar = Icalendar.parse(src).first
|
141
150
|
@event = @calendar.events.first
|
142
151
|
end
|
143
|
-
|
152
|
+
|
144
153
|
def test_event_is_parsed
|
145
154
|
assert_not_nil(@event)
|
146
155
|
end
|
147
|
-
|
156
|
+
|
148
157
|
def test_dtstart_tzid_should_be_nil
|
149
158
|
# puts "#{@event.dtstart.icalendar_tzid.inspect} #{@event.dtstart}"
|
150
159
|
assert_nil(@event.dtstart.icalendar_tzid)
|
151
160
|
end
|
152
|
-
|
161
|
+
|
153
162
|
def test_dtend_tzid_should_be_nil
|
154
163
|
assert_nil(@event.dtend.icalendar_tzid)
|
155
164
|
end
|
156
|
-
|
165
|
+
|
157
166
|
end
|
158
167
|
|
159
168
|
class TestAllDayEventWithoutTime < Test::Unit::TestCase
|
160
|
-
|
169
|
+
|
161
170
|
def setup
|
162
171
|
src = <<EOS
|
163
172
|
BEGIN:VCALENDAR
|
@@ -181,22 +190,22 @@ EOS
|
|
181
190
|
@calendar = Icalendar.parse(src).first
|
182
191
|
@event = @calendar.events.first
|
183
192
|
end
|
184
|
-
|
193
|
+
|
185
194
|
def test_event_is_parsed
|
186
195
|
assert_not_nil(@event)
|
187
196
|
end
|
188
|
-
|
197
|
+
|
189
198
|
def test_dtstart_set_correctly
|
190
199
|
assert_equal("20090110", @event.dtstart.to_ical)
|
191
200
|
end
|
192
|
-
|
201
|
+
|
193
202
|
end
|
194
203
|
|
195
|
-
class TestRecurringEventWithCount < Test::Unit::TestCase
|
204
|
+
class TestRecurringEventWithCount < Test::Unit::TestCase
|
196
205
|
# DTSTART;TZID=US-Eastern:19970902T090000
|
197
206
|
# RRULE:FREQ=DAILY;COUNT=10
|
198
207
|
# ==> (1997 9:00 AM EDT)September 2-11
|
199
|
-
|
208
|
+
|
200
209
|
def setup
|
201
210
|
src = <<EOS
|
202
211
|
BEGIN:VCALENDAR
|
@@ -218,24 +227,24 @@ EOS
|
|
218
227
|
@calendar = Icalendar.parse(src).first
|
219
228
|
@event = @calendar.events.first
|
220
229
|
end
|
221
|
-
|
230
|
+
|
222
231
|
def test_event_is_parsed
|
223
232
|
assert_not_nil(@event)
|
224
233
|
end
|
225
|
-
|
234
|
+
|
226
235
|
def test_recurrence_rules_should_return_a_recurrence_rule_array
|
227
236
|
assert_equal 1, @event.recurrence_rules.length
|
228
237
|
assert_kind_of(Icalendar::RRule, @event.recurrence_rules.first)
|
229
238
|
end
|
230
|
-
|
239
|
+
|
231
240
|
def test_occurrences_after_with_start_before_start_at_should_return_count_occurrences
|
232
241
|
assert_equal 10, @event.occurrences_starting(Time.utc(1997, 9, 2, 8, 30, 0, 0)).length
|
233
242
|
end
|
234
|
-
|
243
|
+
|
235
244
|
# def test_occurrences_after_with_start_before_start_at_should_return_an_event_with_the_dtstart_as_the_first_event
|
236
245
|
# assert_equal @event.dtstart.to_s, @event.occurrences_starting(Time.utc(1997, 9, 2, 8, 30, 0, 0)).first.dtstart.to_s
|
237
246
|
# end
|
238
|
-
#
|
247
|
+
#
|
239
248
|
# def test_occurrences_after_with_start_before_start_at_should_return_events_with_the_correct_dtstart_values
|
240
249
|
# expected = (0..9).map {|delta| (@event.dtstart + delta).to_s}
|
241
250
|
# assert_equal expected, @event.occurrences_starting(Time.utc(1997, 9, 2, 8, 30, 0, 0)).map {|occurence| occurence.dtstart.to_s}
|
data/test/test_calendar.rb
CHANGED
@@ -6,7 +6,7 @@ class TestCalendar < Test::Unit::TestCase
|
|
6
6
|
include Icalendar
|
7
7
|
# Generate a calendar using the raw api, and then spit it out
|
8
8
|
# as a string. Parse the string and make sure everything matches up.
|
9
|
-
def test_raw_generation
|
9
|
+
def test_raw_generation
|
10
10
|
# Create a fresh calendar
|
11
11
|
cal = Calendar.new
|
12
12
|
|
@@ -14,7 +14,7 @@ class TestCalendar < Test::Unit::TestCase
|
|
14
14
|
cal.version = "3.2"
|
15
15
|
cal.prodid = "test-prodid"
|
16
16
|
|
17
|
-
# Now generate the string and then parse it so we can verify
|
17
|
+
# Now generate the string and then parse it so we can verify
|
18
18
|
# that everything was set, generated and parsed correctly.
|
19
19
|
calString = cal.to_ical
|
20
20
|
|
@@ -46,29 +46,29 @@ class TestCalendar < Test::Unit::TestCase
|
|
46
46
|
def test_create_multiple_event_calendar
|
47
47
|
# Create a fresh calendar
|
48
48
|
cal = Calendar.new
|
49
|
-
[1,2,3].each do |t|
|
49
|
+
[1,2,3].each do |t|
|
50
50
|
cal.event do
|
51
51
|
self.dtend = "1997090#{t}T190000Z"
|
52
52
|
self.summary = "This is summary #{t}"
|
53
53
|
end
|
54
54
|
end
|
55
|
-
[1,2,3].each do |t|
|
55
|
+
[1,2,3].each do |t|
|
56
56
|
cal.todo do
|
57
57
|
self.summary = "test #{t} todo"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
cal.to_ical
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def test_find
|
64
64
|
cal = Calendar.new
|
65
65
|
|
66
66
|
# add some events so we actually have to search
|
67
|
-
10.times do
|
67
|
+
10.times do
|
68
68
|
cal.event
|
69
|
-
cal.todo
|
69
|
+
cal.todo
|
70
70
|
cal.journal
|
71
|
-
cal.freebusy
|
71
|
+
cal.freebusy
|
72
72
|
end
|
73
73
|
event = cal.events[5]
|
74
74
|
assert_equal(event, cal.find_event(event.uid))
|
@@ -78,8 +78,27 @@ class TestCalendar < Test::Unit::TestCase
|
|
78
78
|
|
79
79
|
journal = cal.journals[5]
|
80
80
|
assert_equal(journal, cal.find_journal(journal.uid))
|
81
|
-
|
81
|
+
|
82
82
|
freebusy = cal.freebusys[5]
|
83
83
|
assert_equal(freebusy, cal.find_freebusy(freebusy.uid))
|
84
84
|
end
|
85
|
+
|
86
|
+
def test_set_and_get_proprietary_attributes
|
87
|
+
cal = Calendar.new
|
88
|
+
|
89
|
+
cal.x_wr_name = 'Icalendar Calendar'
|
90
|
+
|
91
|
+
calString = cal.to_ical
|
92
|
+
|
93
|
+
cals = Parser.new(calString).parse
|
94
|
+
|
95
|
+
cal2 = cals.first
|
96
|
+
assert_equal(["Icalendar Calendar"], cal2.x_wr_name)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_respond_to_proprietary_attributes
|
100
|
+
cal = Calendar.new
|
101
|
+
|
102
|
+
assert_respond_to(cal, 'x_wr_name=')
|
103
|
+
end
|
85
104
|
end
|
data/test/test_component.rb
CHANGED
@@ -64,7 +64,7 @@ class TestComponent < Test::Unit::TestCase
|
|
64
64
|
|
65
65
|
def test_x_property
|
66
66
|
@event.x_foobar = "my-custom-property"
|
67
|
-
assert_equal("my-custom-property", @event.x_foobar)
|
67
|
+
assert_equal(["my-custom-property"], @event.x_foobar)
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_method_missing_no_x
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ahearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
152
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.0.
|
153
|
+
rubygems_version: 2.0.14
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: A ruby implementation of the iCalendar specification (RFC-2445).
|