sdague-icalendar 1.1.0.1 → 1.1.0.2
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/Rakefile +1 -1
- data/lib/icalendar/component/freebusy.rb +1 -0
- data/lib/icalendar/component.rb +3 -3
- data/lib/icalendar/parser.rb +0 -94
- data/lib/icalendar.rb +1 -0
- data/test/component_test.rb +10 -0
- metadata +2 -2
- data/docs/api/STUB +0 -0
data/Rakefile
CHANGED
data/lib/icalendar/component.rb
CHANGED
@@ -431,11 +431,11 @@ module Icalendar
|
|
431
431
|
public
|
432
432
|
|
433
433
|
def respond_to?(method_name)
|
434
|
-
|
434
|
+
if method_name.to_s.downcase =~ /x_.*/
|
435
|
+
true
|
436
|
+
else
|
435
437
|
super
|
436
438
|
end
|
437
|
-
|
438
|
-
true
|
439
439
|
end
|
440
440
|
|
441
441
|
end # class Component
|
data/lib/icalendar/parser.rb
CHANGED
@@ -12,100 +12,6 @@ require 'uri'
|
|
12
12
|
require 'stringio'
|
13
13
|
|
14
14
|
module Icalendar
|
15
|
-
class RRule
|
16
|
-
|
17
|
-
class Weekday
|
18
|
-
def initialize(day, position)
|
19
|
-
@day, @position = day, position
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_s
|
23
|
-
"#{@position}#{@day}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def initialize(name, params, value, parser)
|
28
|
-
frequency_match = value.match(/FREQ=(SECONDLY|MINUTELY|HOURLY|DAILY|WEEKLY|MONTHLY|YEARLY)/)
|
29
|
-
raise Icalendar::InvalidPropertyValue.new("FREQ must be specified for RRULE values") unless frequency_match
|
30
|
-
@frequency = frequency_match[1]
|
31
|
-
@until = parse_date_val("UNTIL", value)
|
32
|
-
@count = parse_int_val("COUNT", value)
|
33
|
-
raise Icalendar::InvalidPropertyValue.new("UNTIL and COUNT must not both be specified for RRULE values") if [@until, @count].compact.length > 1
|
34
|
-
@interval = parse_int_val("INTERVAL", value)
|
35
|
-
@by_list = {:bysecond => parse_int_list("BYSECOND", value)}
|
36
|
-
@by_list[:byminute] = parse_int_list("BYMINUTE",value)
|
37
|
-
@by_list[:byhour] = parse_int_list("BYHOUR", value)
|
38
|
-
@by_list[:byday] = parse_weekday_list("BYDAY", value)
|
39
|
-
@by_list[:bymonthday] = parse_int_list("BYMONTHDAY", value)
|
40
|
-
@by_list[:byyearday] = parse_int_list("BYYEARDAY", value)
|
41
|
-
@by_list[:byweekno] = parse_int_list("BYWEEKNO", value)
|
42
|
-
@by_list[:bymonth] = parse_int_list("BYMONTH", value)
|
43
|
-
@by_list[:bysetpos] = parse_int_list("BYSETPOS", value)
|
44
|
-
@wkst = parse_wkstart(value)
|
45
|
-
end
|
46
|
-
|
47
|
-
def to_ical
|
48
|
-
result = ["FREQ=#{@frequency}"]
|
49
|
-
result << ";UNTIL=#{@until.to_ical}" if @until
|
50
|
-
result << ";COUNT=#{@count}" if @count
|
51
|
-
result << ";INTERVAL=#{@interval}" if @interval
|
52
|
-
@by_list.each do |key, value|
|
53
|
-
result << ";#{key.to_s.upcase}=#{value}" if value
|
54
|
-
end
|
55
|
-
result << ";WKST=#{@wkst}" if @wkst
|
56
|
-
result.join
|
57
|
-
end
|
58
|
-
|
59
|
-
def parse_date_val(name, string)
|
60
|
-
match = string.match(/;#{name}=(.*?)(;|$)/)
|
61
|
-
match ? DateTime.parse(match[1]) : nil
|
62
|
-
end
|
63
|
-
|
64
|
-
def parse_int_val(name, string)
|
65
|
-
match = string.match(/;#{name}=(\d+)(;|$)/)
|
66
|
-
match ? match[1].to_i : nil
|
67
|
-
end
|
68
|
-
|
69
|
-
def parse_int_list(name, string)
|
70
|
-
match = string.match(/;#{name}=([+-]?.*?)(;|$)/)
|
71
|
-
if match
|
72
|
-
match[1].split(",").map {|int| int.to_i}
|
73
|
-
else
|
74
|
-
nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def parse_weekday_list(name, string)
|
79
|
-
match = string.match(/;#{name}=(.*?)(;|$)/)
|
80
|
-
if match
|
81
|
-
match[1].split(",").map {|weekday|
|
82
|
-
wd_match = weekday.match(/([+-]?\d*)(SU|MO|TU|WE|TH|FR|SA)/)
|
83
|
-
Weekday.new(wd_match[2], wd_match[1])
|
84
|
-
}
|
85
|
-
else
|
86
|
-
nil
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def parse_wkstart(string)
|
91
|
-
match = string.match(/;WKSTART=(SU|MO|TU|WE|TH|FR|SA)(;|$)/)
|
92
|
-
if match
|
93
|
-
%w{SU MO TU WE TH FR SA}.index(match[1])
|
94
|
-
else
|
95
|
-
nil
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# TODO: Incomplete
|
100
|
-
def occurrences_of_event_starting(event, datetime)
|
101
|
-
initial_start = event.dtstart
|
102
|
-
(0...@count).map {|day_offset|
|
103
|
-
occurrence = event.clone
|
104
|
-
occurrence.dtstart = initial_start + day_offset
|
105
|
-
occurrence.clone
|
106
|
-
}
|
107
|
-
end
|
108
|
-
end
|
109
15
|
|
110
16
|
def Icalendar.parse(src, single = false)
|
111
17
|
cals = Icalendar::Parser.new(src).parse
|
data/lib/icalendar.rb
CHANGED
data/test/component_test.rb
CHANGED
@@ -63,4 +63,14 @@ class TestComponent < Test::Unit::TestCase
|
|
63
63
|
@event.x_foobar = "my-custom-property"
|
64
64
|
assert_equal("my-custom-property", @event.x_foobar)
|
65
65
|
end
|
66
|
+
|
67
|
+
def test_respond_to_missing
|
68
|
+
component = Icalendar::Component.new('name')
|
69
|
+
assert !component.respond_to?(:there_is_no_such_method)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_respond_to_x_property
|
73
|
+
component = Icalendar::Component.new('name')
|
74
|
+
assert component.respond_to?(:x_foobar)
|
75
|
+
end
|
66
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdague-icalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.
|
4
|
+
version: 1.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Dague
|
@@ -9,7 +9,7 @@ autorequire: icalendar
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-21 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
data/docs/api/STUB
DELETED
File without changes
|