icalendar 1.5.4 → 2.0.0.beta.1

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.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -1
  3. data/.rspec +2 -0
  4. data/.travis.yml +1 -2
  5. data/History.txt +2 -7
  6. data/README.md +82 -107
  7. data/Rakefile +6 -7
  8. data/icalendar.gemspec +10 -9
  9. data/lib/icalendar.rb +17 -33
  10. data/lib/icalendar/alarm.rb +35 -0
  11. data/lib/icalendar/calendar.rb +17 -100
  12. data/lib/icalendar/component.rb +41 -403
  13. data/lib/icalendar/event.rb +51 -0
  14. data/lib/icalendar/freebusy.rb +27 -0
  15. data/lib/icalendar/has_components.rb +83 -0
  16. data/lib/icalendar/has_properties.rb +156 -0
  17. data/lib/icalendar/journal.rb +39 -0
  18. data/lib/icalendar/parser.rb +75 -403
  19. data/lib/icalendar/timezone.rb +53 -0
  20. data/lib/icalendar/todo.rb +52 -0
  21. data/lib/icalendar/tzinfo.rb +30 -30
  22. data/lib/icalendar/value.rb +80 -0
  23. data/lib/icalendar/values/array.rb +43 -0
  24. data/lib/icalendar/values/binary.rb +31 -0
  25. data/lib/icalendar/values/boolean.rb +17 -0
  26. data/lib/icalendar/values/cal_address.rb +8 -0
  27. data/lib/icalendar/values/date.rb +26 -0
  28. data/lib/icalendar/values/date_time.rb +34 -0
  29. data/lib/icalendar/values/duration.rb +48 -0
  30. data/lib/icalendar/values/float.rb +17 -0
  31. data/lib/icalendar/values/integer.rb +17 -0
  32. data/lib/icalendar/values/period.rb +46 -0
  33. data/lib/icalendar/values/recur.rb +63 -0
  34. data/lib/icalendar/values/text.rb +26 -0
  35. data/lib/icalendar/values/time.rb +34 -0
  36. data/lib/icalendar/values/time_with_zone.rb +31 -0
  37. data/lib/icalendar/values/uri.rb +19 -0
  38. data/lib/icalendar/values/utc_offset.rb +39 -0
  39. data/lib/icalendar/version.rb +5 -0
  40. data/spec/alarm_spec.rb +108 -0
  41. data/spec/calendar_spec.rb +167 -0
  42. data/spec/event_spec.rb +108 -0
  43. data/{test/fixtures/folding.ics → spec/fixtures/nondefault_values.ics} +2 -2
  44. data/{test → spec}/fixtures/single_event.ics +11 -14
  45. data/spec/fixtures/timezone.ics +35 -0
  46. data/spec/freebusy_spec.rb +7 -0
  47. data/spec/journal_spec.rb +7 -0
  48. data/spec/parser_spec.rb +26 -0
  49. data/spec/roundtrip_spec.rb +40 -0
  50. data/spec/spec_helper.rb +25 -0
  51. data/spec/timezone_spec.rb +31 -0
  52. data/spec/todo_spec.rb +24 -0
  53. data/spec/tzinfo_spec.rb +85 -0
  54. data/spec/values/date_time_spec.rb +80 -0
  55. data/spec/values/duration_spec.rb +67 -0
  56. data/spec/values/period_spec.rb +47 -0
  57. data/spec/values/recur_spec.rb +47 -0
  58. data/spec/values/text_spec.rb +72 -0
  59. data/spec/values/utc_offset_spec.rb +41 -0
  60. metadata +129 -88
  61. data/GPL +0 -340
  62. data/examples/create_cal.rb +0 -45
  63. data/examples/parse_cal.rb +0 -20
  64. data/examples/single_event.ics +0 -18
  65. data/lib/hash_attrs.rb +0 -34
  66. data/lib/icalendar/base.rb +0 -47
  67. data/lib/icalendar/component/alarm.rb +0 -47
  68. data/lib/icalendar/component/event.rb +0 -131
  69. data/lib/icalendar/component/freebusy.rb +0 -38
  70. data/lib/icalendar/component/journal.rb +0 -60
  71. data/lib/icalendar/component/timezone.rb +0 -91
  72. data/lib/icalendar/component/todo.rb +0 -64
  73. data/lib/icalendar/conversions.rb +0 -107
  74. data/lib/icalendar/helpers.rb +0 -109
  75. data/lib/icalendar/parameter.rb +0 -33
  76. data/lib/icalendar/rrule.rb +0 -133
  77. data/lib/meta.rb +0 -32
  78. data/script/console +0 -10
  79. data/script/recur1.ics +0 -38
  80. data/script/tryit.rb +0 -13
  81. data/test/component/test_event.rb +0 -253
  82. data/test/component/test_timezone.rb +0 -74
  83. data/test/component/test_todo.rb +0 -31
  84. data/test/fixtures/life.ics +0 -46
  85. data/test/fixtures/nonstandard.ics +0 -25
  86. data/test/fixtures/simplecal.ics +0 -119
  87. data/test/interactive.rb +0 -17
  88. data/test/read_write.rb +0 -23
  89. data/test/test_calendar.rb +0 -167
  90. data/test/test_component.rb +0 -102
  91. data/test/test_conversions.rb +0 -104
  92. data/test/test_helper.rb +0 -7
  93. data/test/test_parameter.rb +0 -91
  94. data/test/test_parser.rb +0 -100
  95. data/test/test_tzinfo.rb +0 -83
  96. data/website/index.html +0 -70
  97. data/website/index.txt +0 -38
  98. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  99. data/website/stylesheets/screen.css +0 -159
  100. data/website/template.html.erb +0 -50
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ## Need this so we can require the library from the samples directory
3
- $:.unshift(File.dirname(__FILE__) + '/../lib')
4
-
5
- require 'rubygems' # Unless you install from the tarball or zip.
6
- require 'icalendar'
7
- require 'date'
8
-
9
- include Icalendar # Probably do this in your class to limit namespace overlap
10
-
11
- ## Creating calendars and events is easy.
12
-
13
- # Create a calendar with an event (standard method)
14
- cal = Calendar.new
15
- cal.event do
16
- dtstart Date.new(2005, 04, 29)
17
- dtend Date.new(2005, 04, 28)
18
- summary "Meeting with the man."
19
- description "Have a long lunch meeting and decide nothing..."
20
- klass "PRIVATE"
21
- end
22
-
23
- ## Or you can make events like this
24
- event = Event.new
25
- event.start = DateTime.civil(2006, 6, 23, 8, 30)
26
- event.summary = "A great event!"
27
- cal.add_event(event)
28
-
29
- event2 = cal.event # This automatically adds the event to the calendar
30
- event2.start = DateTime.civil(2006, 6, 24, 8, 30)
31
- event2.summary = "Another great event!"
32
-
33
- # Now with support for property parameters
34
- params = {"ALTREP" =>['"http://my.language.net"'], "LANGUAGE" => ["SPANISH"]}
35
-
36
- cal.event do
37
- dtstart Date.new(2005, 04, 29)
38
- dtend Date.new(2005, 04, 28)
39
- summary "This is a summary with params.", params
40
- end
41
-
42
- # We can output the calendar as a string to write to a file,
43
- # network port, database etc.
44
- cal_string = cal.to_ical
45
- puts cal_string
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ## Need this so we can require the library from the samples directory
3
- $:.unshift(File.dirname(__FILE__) + '/../lib')
4
-
5
- require 'icalendar'
6
- require 'date'
7
-
8
- # Open a file or string to parse
9
- cal_file = File.open("../test/life.ics")
10
-
11
- # Parser returns an array of calendars because a single file
12
- # can have multiple calendar objects.
13
- cals = Icalendar::parse(cal_file)
14
- cal = cals.first
15
-
16
- # Now you can access the cal object in just the same way I created it
17
- event = cal.events.first
18
-
19
- puts "start date-time: " + event.dtstart.to_s
20
- puts "summary: " + event.summary
@@ -1,18 +0,0 @@
1
- BEGIN:VCALENDAR
2
- VERSION:2.0
3
- PRODID:bsprodidfortestabc123
4
- BEGIN:VEVENT
5
- UID:bsuidfortestabc123
6
- SUMMARY:This is a really long summary
7
- to test the method of unfolding lines
8
- so I'm just going to ma
9
- ke it
10
- a whol
11
- e
12
- bunch of lines.
13
- CLASS:PRIVATE
14
- DTSTART;TZID=US-Mountain:20050120T170000
15
- DTEND:20050120T184500
16
- DTSTAMP:20050118T211523Z
17
- END:VEVENT
18
- END:VCALENDAR
data/lib/hash_attrs.rb DELETED
@@ -1,34 +0,0 @@
1
- # A module which adds some generators for hash based accessors.
2
- module HashAttrs
3
-
4
- def hash_reader(hash_sym, syms)
5
- syms.each do |id|
6
- id = id.to_s.downcase
7
- func = Proc.new do
8
- hash = instance_variable_get(hash_sym)
9
- hash[id.to_sym]
10
- end
11
-
12
- self.send(:define_method, id, func)
13
- end
14
- end
15
-
16
- def hash_writer(hash_sym, syms)
17
- syms.each do |id|
18
- id = id.to_s.downcase
19
-
20
- func = Proc.new do |val|
21
- hash = instance_variable_get(hash_sym)
22
- hash[id.to_sym] = val
23
- end
24
-
25
- self.send(:define_method, id+'=', func)
26
- end
27
- end
28
-
29
- def hash_accessor(hash, *syms)
30
- hash_reader(hash, syms)
31
- hash_writer(hash, syms)
32
- end
33
- end
34
-
@@ -1,47 +0,0 @@
1
- =begin
2
- Copyright (C) 2005 Jeff Rose
3
- Copyright (C) 2009-2010 Sean Dague
4
- Copyright (C) 2013- Ryan Ahearn
5
-
6
- This library is free software; you can redistribute it and/or modify it
7
- under the same terms as the ruby language itself, see the file COPYING for
8
- details.
9
- =end
10
- require 'logger'
11
-
12
- module Icalendar #:nodoc:
13
-
14
- VERSION = '1.5.4'
15
-
16
- # A simple error class to differentiate iCalendar library exceptions
17
- # from ruby language exceptions or others.
18
- class IcalendarError < StandardError #:nodoc:
19
- end
20
-
21
- # Exception used when the library encounters a bogus calendar component.
22
- class UnknownComponentClass < IcalendarError
23
- end
24
-
25
- # Exception used when the library encounters a bogus property type.
26
- class UnknownPropertyMethod< IcalendarError
27
- end
28
-
29
- # Exception used when the library encounters a bogus property value.
30
- class InvalidPropertyValue < IcalendarError
31
- end
32
-
33
- # This class serves as the base class for just about everything in
34
- # the library so that the logging system can be configured in one place.
35
- class Base
36
- @@logger = Logger.new(STDERR)
37
- @@logger.level = Logger::FATAL
38
-
39
- def self.debug
40
- @@logger.level = Logger::DEBUG
41
- end
42
-
43
- def self.quiet
44
- @@logger.level = Logger::FATAL
45
- end
46
- end
47
- end
@@ -1,47 +0,0 @@
1
- =begin
2
- Copyright (C) 2005 Jeff Rose
3
-
4
- This library is free software; you can redistribute it and/or modify it
5
- under the same terms as the ruby language itself, see the file COPYING for
6
- details.
7
- =end
8
- module Icalendar
9
- # An Alarm calendar component is a grouping of component
10
- # properties that is a reminder or alarm for an event or a
11
- # to-do. For example, it may be used to define a reminder for a
12
- # pending Event or an overdue Todo.
13
- class Alarm < Component
14
-
15
- # Single properties
16
- ical_property :action
17
- ical_property :description
18
- ical_property :trigger
19
- ical_property :summary
20
- ical_property :uid
21
-
22
- # Single but must appear together
23
- ical_property :duration
24
- ical_property :repeat
25
-
26
- # Single and only occurring once
27
-
28
- ical_property :created
29
- ical_property :last_modified
30
- ical_property :timestamp
31
- ical_property :sequence
32
- ical_property :acknowledged
33
-
34
- # Multi properties
35
- ical_multiline_property :attendee, :attendee, :attendees
36
- ical_multiline_property :attach, :attachment, :attachments
37
- ical_multiline_property :related_to, :related_to, :related_to
38
-
39
- def initialize()
40
- super("VALARM")
41
-
42
- # Almost everyone just wants to display so I make it the
43
- # default so it works for most people right away...
44
- action "DISPLAY"
45
- end
46
- end
47
- end
@@ -1,131 +0,0 @@
1
- =begin
2
- Copyright (C) 2005 Jeff Rose
3
-
4
- This library is free software; you can redistribute it and/or modify it
5
- under the same terms as the ruby language itself, see the file COPYING for
6
- details.
7
- =end
8
-
9
- module Icalendar
10
- # A Event calendar component is a grouping of component
11
- # properties, and possibly including Alarm calendar components, that
12
- # represents a scheduled amount of time on a calendar. For example, it
13
- # can be an activity; such as a one-hour long, department meeting from
14
- # 8:00 AM to 9:00 AM, tomorrow. Generally, an event will take up time
15
- # on an individual calendar.
16
- class Event < Component
17
- ical_component :alarms
18
-
19
- ## Single instance properties
20
-
21
- # Access classification (PUBLIC, PRIVATE, CONFIDENTIAL...)
22
- ical_property :ip_class, :klass
23
-
24
- ical_property :ip_name
25
-
26
- # Date & time of creation
27
- ical_property :created
28
-
29
- # Complete description of the calendar component
30
- ical_property :description
31
-
32
- # Specifies the timezone for the event
33
- attr_accessor :tzid
34
-
35
- # Specifies date-time when calendar component begins
36
- ical_property :dtstart, :start
37
-
38
- # Latitude & longitude for specified activity
39
- ical_property :geo, :geo_location
40
-
41
- # Date & time this item was last modified
42
- ical_property :last_modified
43
-
44
- # Specifies the intended venue for this activity
45
- ical_property :location
46
-
47
- # Defines organizer of this item
48
- ical_property :organizer
49
-
50
- # Defines relative priority for this item (1-9... 1 = best)
51
- ical_property :priority
52
-
53
- # Indicate date & time when this item was created
54
- ical_property :dtstamp, :timestamp
55
-
56
- # Revision sequence number for this item
57
- ical_property :sequence, :seq
58
-
59
- # Defines overall status or confirmation of this item
60
- ical_property :status
61
- ical_property :summary
62
- ical_property :transp, :transparency
63
-
64
- # Defines a persistent, globally unique id for this item
65
- ical_property :uid, :unique_id
66
-
67
- # Defines a URL associated with this item
68
- ical_property :url
69
- ical_property :recurrence_id, :recurid
70
-
71
- ## Single but mutually exclusive properties (Not testing though)
72
-
73
- # Specifies a date and time that this item ends
74
- ical_property :dtend, :end
75
-
76
- # Specifies a positive duration time
77
- ical_property :duration
78
-
79
- ## Multi-instance properties
80
-
81
- # Associates a URI or binary blob with this item
82
- ical_multiline_property :attach, :attachment, :attachments
83
-
84
- # Defines an attendee for this calendar item
85
- ical_multiline_property :attendee, :attendee, :attendees
86
-
87
- # Defines the categories for a calendar component (school, work...)
88
- ical_multi_property :categories, :category, :categories
89
-
90
- # Simple comment for the calendar user.
91
- ical_multi_property :comment, :comment, :comments
92
-
93
- # Contact information associated with this item.
94
- ical_multi_property :contact, :contact, :contacts
95
- ical_multi_property :exdate, :exception_date, :exception_dates
96
- ical_multi_property :exrule, :exception_rule, :exception_rules
97
- ical_multi_property :rstatus, :request_status, :request_statuses
98
-
99
- # Used to represent a relationship between two calendar items
100
- ical_multi_property :related_to, :related_to, :related_tos
101
- ical_multi_property :resources, :resource, :resources
102
-
103
- # Used with the UID & SEQUENCE to identify a specific instance of a
104
- # recurring calendar item.
105
- ical_multi_property :rdate, :recurrence_date, :recurrence_dates
106
- ical_multi_property :rrule, :recurrence_rule, :recurrence_rules
107
-
108
- def initialize()
109
- super("VEVENT")
110
-
111
- # Now doing some basic initialization
112
- sequence 0
113
- timestamp Time.now.utc.to_datetime.tap { |t| t.icalendar_tzid = 'UTC' }
114
- uid new_uid
115
- end
116
-
117
- def alarm(&block)
118
- a = Alarm.new
119
- self.add a
120
-
121
- a.instance_eval(&block) if block
122
-
123
- a
124
- end
125
-
126
- def occurrences_starting(time)
127
- recurrence_rules.first.occurrences_of_event_starting(self, time)
128
- end
129
-
130
- end
131
- end
@@ -1,38 +0,0 @@
1
- =begin
2
- Copyright (C) 2005 Jeff Rose
3
-
4
- This library is free software; you can redistribute it and/or modify it
5
- under the same terms as the ruby language itself, see the file COPYING for
6
- details.
7
- =end
8
- module Icalendar
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
- # Single properties
15
- ical_property :contact
16
- ical_property :dtstart, :start
17
- ical_property :dtend, :end
18
- ical_property :dtstamp, :timestamp
19
- ical_property :duration
20
- ical_property :organizer
21
- ical_property :uid, :user_id
22
- ical_property :url
23
- ical_property :summary
24
-
25
- # Multi-properties
26
- ical_multiline_property :attendee, :attendee, :attendees
27
- ical_multi_property :comment, :comment, :comments
28
- ical_multiline_property :freebusy, :freebusy, :freebusys
29
- ical_multi_property :rstatus, :request_status, :request_statuses
30
-
31
- def initialize()
32
- super("VFREEBUSY")
33
-
34
- timestamp Time.now.utc.to_datetime.tap { |t| t.icalendar_tzid = 'UTC' }
35
- uid new_uid
36
- end
37
- end
38
- end
@@ -1,60 +0,0 @@
1
- =begin
2
- Copyright (C) 2005 Jeff Rose
3
-
4
- This library is free software; you can redistribute it and/or modify it
5
- under the same terms as the ruby language itself, see the file COPYING for
6
- details.
7
- =end
8
- module Icalendar
9
- # A Journal calendar component is a grouping of
10
- # component properties that represent one or more descriptive text
11
- # notes associated with a particular calendar date. The "DTSTART"
12
- # property is used to specify the calendar date that the journal entry
13
- # is associated with. Generally, it will have a DATE value data type,
14
- # but it can also be used to specify a DATE-TIME value data type.
15
- # Examples of a journal entry include a daily record of a legislative
16
- # body or a journal entry of individual telephone contacts for the day
17
- # or an ordered list of accomplishments for the day. The Journal
18
- # calendar component can also be used to associate a document with a
19
- # calendar date.
20
- class Journal < Component
21
-
22
- # Single properties
23
- ical_property :ip_class
24
- ical_property :created
25
- ical_property :description
26
- ical_property :dtstart, :start
27
- ical_property :last_modified
28
- ical_property :organizer
29
- ical_property :dtstamp, :timestamp
30
- ical_property :sequence, :seq
31
- ical_property :status
32
- ical_property :summary
33
- ical_property :uid, :user_id
34
- ical_property :url
35
- ical_property :recurid, :recurrence_id
36
-
37
- # Multi-properties
38
- ical_multiline_property :attach, :attachment, :attachments
39
- ical_multiline_property :attendee, :attendee, :attendees
40
- ical_multi_property :categories, :category, :categories
41
- ical_multi_property :comment, :comment, :comments
42
- ical_multi_property :contact, :contact, :contacts
43
- ical_multi_property :exdate, :exception_date, :exception_dates
44
- ical_multi_property :exrule, :exception_rule, :exception_rules
45
- ical_multi_property :rstatus, :request_status, :request_statuses
46
- ical_multi_property :related_to, :related_to, :related_tos
47
- ical_multi_property :resources, :resource, :resources
48
- ical_multi_property :rdate, :recurrence_date, :recurrence_dates
49
- ical_multi_property :rrule, :recurrence_rule, :recurrence_rules
50
-
51
- def initialize()
52
- super("VJOURNAL")
53
-
54
- sequence 0
55
- timestamp Time.now.utc.to_datetime.tap { |t| t.icalendar_tzid = 'UTC' }
56
- uid new_uid
57
- end
58
-
59
- end
60
- end