icalendar2 0.1.4 → 0.1.5
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/lib/icalendar2.rb +7 -0
- data/lib/icalendar2/calendar.rb +12 -0
- data/lib/icalendar2/component/alarm.rb +18 -0
- data/lib/icalendar2/component/base.rb +11 -0
- data/lib/icalendar2/component/event.rb +24 -2
- data/lib/icalendar2/component/timezone.rb +53 -0
- data/lib/icalendar2/property/action.rb +9 -0
- data/lib/icalendar2/property/duration.rb +9 -0
- data/lib/icalendar2/property/repeat.rb +9 -0
- data/lib/icalendar2/property/trigger.rb +9 -0
- data/lib/icalendar2/property/tzid.rb +9 -0
- data/lib/icalendar2/version.rb +1 -1
- metadata +12 -10
data/lib/icalendar2.rb
CHANGED
@@ -7,7 +7,9 @@ module Icalendar2
|
|
7
7
|
autoload :Tokens, "icalendar2/tokens"
|
8
8
|
|
9
9
|
autoload :Component, "icalendar2/component"
|
10
|
+
autoload :Alarm, "icalendar2/component/alarm"
|
10
11
|
autoload :Event, "icalendar2/component/event"
|
12
|
+
autoload :Timezone, "icalendar2/component/timezone"
|
11
13
|
module Component
|
12
14
|
autoload :Base, "icalendar2/component/base"
|
13
15
|
end
|
@@ -44,6 +46,7 @@ module Icalendar2
|
|
44
46
|
|
45
47
|
autoload :Property, "icalendar2/property"
|
46
48
|
module Property
|
49
|
+
autoload :Action, "icalendar2/property/action"
|
47
50
|
autoload :Base, "icalendar2/property/base"
|
48
51
|
autoload :Nil, "icalendar2/property/nil"
|
49
52
|
autoload :Attach, "icalendar2/property/attach"
|
@@ -57,6 +60,7 @@ module Icalendar2
|
|
57
60
|
autoload :Dtend, "icalendar2/property/dtend"
|
58
61
|
autoload :Dtstamp, "icalendar2/property/dtstamp"
|
59
62
|
autoload :Dtstart, "icalendar2/property/dtstart"
|
63
|
+
autoload :Duration, "icalendar2/property/duration"
|
60
64
|
autoload :Exdate, "icalendar2/property/exdate"
|
61
65
|
autoload :Geo, "icalendar2/property/geo"
|
62
66
|
autoload :LastMod, "icalendar2/property/last_mod"
|
@@ -64,12 +68,15 @@ module Icalendar2
|
|
64
68
|
autoload :Organizer, "icalendar2/property/organizer"
|
65
69
|
autoload :Priority, "icalendar2/property/priority"
|
66
70
|
autoload :Rdate, "icalendar2/property/rdate"
|
71
|
+
autoload :Repeat, "icalendar2/property/repeat"
|
67
72
|
autoload :Resources, "icalendar2/property/resources"
|
68
73
|
autoload :RelatedTo, "icalendar2/property/related_to"
|
69
74
|
autoload :Rrule, "icalendar2/property/rrule"
|
70
75
|
autoload :Rstatus, "icalendar2/property/rstatus"
|
71
76
|
autoload :Sequence, "icalendar2/property/sequence"
|
72
77
|
autoload :Summary, "icalendar2/property/summary"
|
78
|
+
autoload :Trigger, "icalendar2/property/trigger"
|
79
|
+
autoload :Tzid, "icalendar2/property/tzid"
|
73
80
|
autoload :Uid, "icalendar2/property/uid"
|
74
81
|
end
|
75
82
|
end
|
data/lib/icalendar2/calendar.rb
CHANGED
@@ -60,6 +60,18 @@ module Icalendar2
|
|
60
60
|
events << event
|
61
61
|
end
|
62
62
|
|
63
|
+
def timezones
|
64
|
+
@components[Timezone::VALUE]
|
65
|
+
end
|
66
|
+
|
67
|
+
def timezone(&block)
|
68
|
+
e = Timezone.new
|
69
|
+
e.instance_eval(&block)
|
70
|
+
timezones << e
|
71
|
+
|
72
|
+
e
|
73
|
+
end
|
74
|
+
|
63
75
|
def to_ical
|
64
76
|
str = "#{Tokens::COMPONENT_BEGIN}:#{VALUE}#{Tokens::CRLF}"
|
65
77
|
str << body_to_ical
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Icalendar2
|
2
|
+
class Alarm < Component::Base
|
3
|
+
VALUE = "VALARM"
|
4
|
+
|
5
|
+
requires :exactly_one => [:action, :trigger]
|
6
|
+
accepts :exactly_one => [:description, :duration, :repeat]
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_ical
|
13
|
+
str = "#{Tokens::COMPONENT_BEGIN}:#{VALUE}#{Tokens::CRLF}"
|
14
|
+
str << properties_to_ical
|
15
|
+
str << "#{Tokens::COMPONENT_END}:#{VALUE}#{Tokens::CRLF}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -17,9 +17,20 @@ module Icalendar2
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def initialize
|
20
|
+
@components = {}
|
20
21
|
@properties = {}
|
21
22
|
end
|
22
23
|
|
24
|
+
def add_component(component)
|
25
|
+
key = (component.class.to_s.downcase + 's').gsub('icalendar2::', '').to_sym
|
26
|
+
|
27
|
+
unless @components.has_key? key
|
28
|
+
@components[key] = []
|
29
|
+
end
|
30
|
+
|
31
|
+
@components[key] << component
|
32
|
+
end
|
33
|
+
|
23
34
|
def new_uid
|
24
35
|
"#{DateTime.now}_#{rand(999999999)}@#{Socket.gethostname}"
|
25
36
|
end
|
@@ -16,17 +16,39 @@ module Icalendar2
|
|
16
16
|
self.dtstamp = new_timestamp
|
17
17
|
end
|
18
18
|
|
19
|
+
# Add a new alarm(s) in a block
|
20
|
+
def alarm(&block)
|
21
|
+
a = Alarm.new
|
22
|
+
self.add_component a
|
23
|
+
a.instance_eval(&block)
|
24
|
+
|
25
|
+
a
|
26
|
+
end
|
27
|
+
|
28
|
+
def alarms
|
29
|
+
@components[:alarms]
|
30
|
+
end
|
31
|
+
|
19
32
|
def to_ical
|
20
33
|
str = "#{Tokens::COMPONENT_BEGIN}:#{VALUE}#{Tokens::CRLF}"
|
21
34
|
str << properties_to_ical
|
22
|
-
|
35
|
+
str << alarm_to_ical
|
23
36
|
str << "#{Tokens::COMPONENT_END}:#{VALUE}#{Tokens::CRLF}"
|
24
37
|
end
|
25
38
|
|
39
|
+
def valid?
|
40
|
+
alarms ? alarms.all?(&:valid?) : true
|
41
|
+
end
|
42
|
+
|
26
43
|
private
|
27
44
|
|
28
45
|
def alarm_to_ical
|
29
|
-
|
46
|
+
str = ""
|
47
|
+
alarms.each do |a|
|
48
|
+
str << a.to_ical
|
49
|
+
end if alarms
|
50
|
+
|
51
|
+
str
|
30
52
|
end
|
31
53
|
end
|
32
54
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Icalendar2
|
2
|
+
class Timezone < Component::Base
|
3
|
+
VALUE = "VTIMEZONE"
|
4
|
+
|
5
|
+
requires :exactly_one => [:tzid]
|
6
|
+
accepts :exactly_one => [:last_mod, :created]
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
@components = {
|
11
|
+
Daylight::VALUE => [],
|
12
|
+
Standard::VALUE => []
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_ical
|
17
|
+
str = "#{Tokens::COMPONENT_BEGIN}:#{VALUE}#{Tokens::CRLF}"
|
18
|
+
str << properties_to_ical
|
19
|
+
str << "#{Tokens::COMPONENT_END}:#{VALUE}#{Tokens::CRLF}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_component(component)
|
23
|
+
key = component.class.to_s.downcase.gsub('icalendar::', '').to_sym
|
24
|
+
@components[key] = component
|
25
|
+
end
|
26
|
+
|
27
|
+
def standard(&block)
|
28
|
+
standard_time_c = Standard.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def daylight(&block)
|
32
|
+
daylight_time_c = Daylight.new
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
class Daylight < Timezone
|
38
|
+
VALUE = "DAYLIGHT"
|
39
|
+
|
40
|
+
def initialize
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Standard < Timezone
|
46
|
+
VALUE = "STANDARD"
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/lib/icalendar2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icalendar2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-22 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2153728980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,12 +21,7 @@ dependencies:
|
|
21
21
|
version: '2'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2'
|
24
|
+
version_requirements: *2153728980
|
30
25
|
description: Borrows fromt the API used by the icalendar Ruby gem. Outputs iCalendar
|
31
26
|
(RFC 5545) formatted text.
|
32
27
|
email:
|
@@ -43,8 +38,10 @@ files:
|
|
43
38
|
- lib/icalendar2/calendar_property/prodid.rb
|
44
39
|
- lib/icalendar2/calendar_property/version.rb
|
45
40
|
- lib/icalendar2/calendar_property.rb
|
41
|
+
- lib/icalendar2/component/alarm.rb
|
46
42
|
- lib/icalendar2/component/base.rb
|
47
43
|
- lib/icalendar2/component/event.rb
|
44
|
+
- lib/icalendar2/component/timezone.rb
|
48
45
|
- lib/icalendar2/component.rb
|
49
46
|
- lib/icalendar2/parameter/altrep.rb
|
50
47
|
- lib/icalendar2/parameter/base.rb
|
@@ -57,6 +54,7 @@ files:
|
|
57
54
|
- lib/icalendar2/parameter/fmttype.rb
|
58
55
|
- lib/icalendar2/parameter.rb
|
59
56
|
- lib/icalendar2/parser.rb
|
57
|
+
- lib/icalendar2/property/action.rb
|
60
58
|
- lib/icalendar2/property/attach.rb
|
61
59
|
- lib/icalendar2/property/attendee.rb
|
62
60
|
- lib/icalendar2/property/base.rb
|
@@ -69,6 +67,7 @@ files:
|
|
69
67
|
- lib/icalendar2/property/dtend.rb
|
70
68
|
- lib/icalendar2/property/dtstamp.rb
|
71
69
|
- lib/icalendar2/property/dtstart.rb
|
70
|
+
- lib/icalendar2/property/duration.rb
|
72
71
|
- lib/icalendar2/property/exdate.rb
|
73
72
|
- lib/icalendar2/property/geo.rb
|
74
73
|
- lib/icalendar2/property/last_mod.rb
|
@@ -78,11 +77,14 @@ files:
|
|
78
77
|
- lib/icalendar2/property/priority.rb
|
79
78
|
- lib/icalendar2/property/rdate.rb
|
80
79
|
- lib/icalendar2/property/related_to.rb
|
80
|
+
- lib/icalendar2/property/repeat.rb
|
81
81
|
- lib/icalendar2/property/resources.rb
|
82
82
|
- lib/icalendar2/property/rrule.rb
|
83
83
|
- lib/icalendar2/property/rstatus.rb
|
84
84
|
- lib/icalendar2/property/sequence.rb
|
85
85
|
- lib/icalendar2/property/summary.rb
|
86
|
+
- lib/icalendar2/property/trigger.rb
|
87
|
+
- lib/icalendar2/property/tzid.rb
|
86
88
|
- lib/icalendar2/property/uid.rb
|
87
89
|
- lib/icalendar2/property.rb
|
88
90
|
- lib/icalendar2/tokens.rb
|
@@ -125,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
127
|
version: '0'
|
126
128
|
requirements: []
|
127
129
|
rubyforge_project:
|
128
|
-
rubygems_version: 1.8.
|
130
|
+
rubygems_version: 1.8.10
|
129
131
|
signing_key:
|
130
132
|
specification_version: 3
|
131
133
|
summary: iCalendar (RFC 5545) Ruby library
|