paulsm-icalendar 1.1.0.4
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/COPYING +56 -0
- data/GPL +340 -0
- data/README +266 -0
- data/Rakefile +109 -0
- data/docs/rfcs/itip_notes.txt +69 -0
- data/docs/rfcs/rfc2425.pdf +0 -0
- data/docs/rfcs/rfc2426.pdf +0 -0
- data/docs/rfcs/rfc2445.pdf +0 -0
- data/docs/rfcs/rfc2446.pdf +0 -0
- data/docs/rfcs/rfc2447.pdf +0 -0
- data/docs/rfcs/rfc3283.txt +738 -0
- data/examples/create_cal.rb +45 -0
- data/examples/parse_cal.rb +20 -0
- data/examples/single_event.ics +18 -0
- data/lib/hash_attrs.rb +34 -0
- data/lib/icalendar.rb +39 -0
- data/lib/icalendar/base.rb +43 -0
- data/lib/icalendar/calendar.rb +113 -0
- data/lib/icalendar/component.rb +442 -0
- data/lib/icalendar/component/alarm.rb +44 -0
- data/lib/icalendar/component/event.rb +129 -0
- data/lib/icalendar/component/freebusy.rb +38 -0
- data/lib/icalendar/component/journal.rb +61 -0
- data/lib/icalendar/component/timezone.rb +105 -0
- data/lib/icalendar/component/todo.rb +64 -0
- data/lib/icalendar/conversions.rb +150 -0
- data/lib/icalendar/helpers.rb +109 -0
- data/lib/icalendar/parameter.rb +33 -0
- data/lib/icalendar/parser.rb +396 -0
- data/lib/icalendar/rrule.rb +126 -0
- data/lib/icalendar/tzinfo.rb +121 -0
- data/lib/meta.rb +32 -0
- data/test/calendar_test.rb +71 -0
- data/test/component/event_test.rb +256 -0
- data/test/component/timezone_test.rb +67 -0
- data/test/component/todo_test.rb +13 -0
- data/test/component_test.rb +76 -0
- data/test/conversions_test.rb +97 -0
- data/test/coverage/STUB +0 -0
- data/test/fixtures/folding.ics +23 -0
- data/test/fixtures/life.ics +46 -0
- data/test/fixtures/simplecal.ics +119 -0
- data/test/fixtures/single_event.ics +23 -0
- data/test/interactive.rb +17 -0
- data/test/parameter_test.rb +29 -0
- data/test/parser_test.rb +84 -0
- data/test/read_write.rb +23 -0
- metadata +108 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
BEGIN:VCALENDAR
|
2
|
+
VERSION:2.0
|
3
|
+
PRODID:bsprodidfortestabc123
|
4
|
+
BEGIN:VEVENT
|
5
|
+
UID:bsuidfortestabc123
|
6
|
+
ORGANIZER:mailto:joebob@random.net
|
7
|
+
ATTACH:http://bush.sucks.org/impeach/him.rhtml
|
8
|
+
ATTACH:http://corporations-dominate.existence.net/why.rhtml
|
9
|
+
SUMMARY:This is a really long summary
|
10
|
+
to test the method of unfolding lines\,
|
11
|
+
so I'm just going to ma
|
12
|
+
ke it
|
13
|
+
a whol
|
14
|
+
e
|
15
|
+
bunch of lines.
|
16
|
+
CLASS:PRIVATE
|
17
|
+
PRIORITY:2
|
18
|
+
GEO:37.386013;-122.0829322
|
19
|
+
DTSTART;TZID=US-Mountain:20050120T170000
|
20
|
+
DTEND:20050120T184500
|
21
|
+
DTSTAMP:20050118T211523Z
|
22
|
+
END:VEVENT
|
23
|
+
END:VCALENDAR
|
data/test/interactive.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# NOTE: you must have installed ruby-breakpoint in order to use this script.
|
4
|
+
# Grab it using gem with "gem install ruby-breakpoint --remote" or download
|
5
|
+
# from the website (http://ruby-breakpoint.rubyforge.org/) then run setup.rb
|
6
|
+
|
7
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'breakpoint'
|
11
|
+
|
12
|
+
require 'icalendar'
|
13
|
+
|
14
|
+
cal = Icalendar::Parser.new(File.new("life.ics")).parse
|
15
|
+
#cal = Icalendar::Calendar.new
|
16
|
+
|
17
|
+
breakpoint
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Test out property parameter functionality
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
3
|
+
|
4
|
+
require 'date'
|
5
|
+
require 'test/unit'
|
6
|
+
require 'icalendar'
|
7
|
+
|
8
|
+
class TestComponent < Test::Unit::TestCase
|
9
|
+
|
10
|
+
# Create a calendar with an event for each test.
|
11
|
+
def setup
|
12
|
+
@cal = Icalendar::Calendar.new
|
13
|
+
@event = Icalendar::Event.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_property_parameters
|
17
|
+
params = {"ALTREP" =>['"http://my.language.net"'], "LANGUAGE" => ["SPANISH"]}
|
18
|
+
@event.summary("This is a test summary.", params)
|
19
|
+
|
20
|
+
assert_equal params, @event.summary.ical_params
|
21
|
+
|
22
|
+
@cal.add_event @event
|
23
|
+
cal_str = @cal.to_ical
|
24
|
+
|
25
|
+
cals = Icalendar::Parser.new(cal_str).parse
|
26
|
+
event = cals.first.events.first
|
27
|
+
assert_equal params, event.summary.ical_params
|
28
|
+
end
|
29
|
+
end
|
data/test/parser_test.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'icalendar'
|
5
|
+
|
6
|
+
# This is a test class for the calendar parser.
|
7
|
+
class TestIcalendarParser < Test::Unit::TestCase
|
8
|
+
|
9
|
+
TEST_CAL = File.join(File.dirname(__FILE__), 'fixtures', 'single_event.ics')
|
10
|
+
|
11
|
+
# First make sure that we can run the parser and get back objects.
|
12
|
+
def test_new
|
13
|
+
# Make sure we don't take invalid object types.
|
14
|
+
assert_raise(ArgumentError) { Icalendar::Parser.new(nil) }
|
15
|
+
|
16
|
+
# Make sure we get an object back from parsing a file
|
17
|
+
calFile = File.open(TEST_CAL)
|
18
|
+
cals = Icalendar::Parser.new(calFile).parse
|
19
|
+
assert(cals)
|
20
|
+
calFile.close
|
21
|
+
|
22
|
+
# Make sure we get an object back from parsing a string
|
23
|
+
calString = File.open(TEST_CAL).read
|
24
|
+
cals = Icalendar::Parser.new(calString).parse
|
25
|
+
assert(cals)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Now go through and make sure the object is correct using the
|
29
|
+
# dynamically generated raw interfaces.
|
30
|
+
def test_zzfile_parse
|
31
|
+
calFile = File.open(TEST_CAL)
|
32
|
+
cals = Icalendar.parse(calFile)
|
33
|
+
calFile.close
|
34
|
+
do_asserts(cals)
|
35
|
+
|
36
|
+
Icalendar::Base.quiet
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_string_parse
|
40
|
+
# Make sure we get an object back from parsing a string
|
41
|
+
calString = File.open(TEST_CAL).read
|
42
|
+
cals = Icalendar::Parser.new(calString).parse
|
43
|
+
do_asserts(cals)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Just a helper method so we don't have to repeat the same tests.
|
47
|
+
def do_asserts(cals)
|
48
|
+
# Should just get one calendar back.
|
49
|
+
assert_equal(1, cals.size)
|
50
|
+
|
51
|
+
cal = cals.first
|
52
|
+
|
53
|
+
# Calendar properties
|
54
|
+
assert_equal("2.0", cal.version)
|
55
|
+
assert_equal("bsprodidfortestabc123", cal.prodid)
|
56
|
+
|
57
|
+
# Now the event
|
58
|
+
assert_equal(1, cal.events.size)
|
59
|
+
|
60
|
+
event = cal.events.first
|
61
|
+
assert_equal("bsuidfortestabc123", event.uid)
|
62
|
+
|
63
|
+
summary = "This is a really long summary to test the method of unfolding lines, so I'm just going to make it a whole bunch of lines."
|
64
|
+
|
65
|
+
assert_equal(summary, event.summary)
|
66
|
+
|
67
|
+
start = DateTime.parse("20050120T170000")
|
68
|
+
daend = DateTime.parse("20050120T184500")
|
69
|
+
stamp = DateTime.parse("20050118T211523Z")
|
70
|
+
assert_equal(start, event.dtstart)
|
71
|
+
assert_equal(daend, event.dtend)
|
72
|
+
assert_equal(stamp, event.dtstamp)
|
73
|
+
|
74
|
+
organizer = URI.parse("mailto:joebob@random.net")
|
75
|
+
assert_equal(organizer, event.organizer)
|
76
|
+
|
77
|
+
ats = event.attachments
|
78
|
+
assert_equal(2, ats.size)
|
79
|
+
attachment = URI.parse("http://bush.sucks.org/impeach/him.rhtml")
|
80
|
+
assert_equal(attachment, ats[0])
|
81
|
+
attachment = URI.parse("http://corporations-dominate.existence.net/why.rhtml")
|
82
|
+
assert_equal(attachment, ats[1])
|
83
|
+
end
|
84
|
+
end
|
data/test/read_write.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# NOTE: you must have installed ruby-breakpoint in order to use this script.
|
4
|
+
# Grab it using gem with "gem install ruby-breakpoint --remote" or download
|
5
|
+
# from the website (http://ruby-breakpoint.rubyforge.org/) then run setup.rb
|
6
|
+
|
7
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
8
|
+
|
9
|
+
require 'breakpoint'
|
10
|
+
require 'icalendar'
|
11
|
+
|
12
|
+
cals = Icalendar::Parser.new(File.new(ARGV[0])).parse
|
13
|
+
puts "Parsed #{cals.size} calendars"
|
14
|
+
|
15
|
+
cal = cals.first
|
16
|
+
puts "First calendar has:"
|
17
|
+
puts "#{cal.events.size} events"
|
18
|
+
puts "#{cal.todos.size} todos"
|
19
|
+
puts "#{cal.journals.size} journals"
|
20
|
+
|
21
|
+
test = File.new("rw.ics", "w")
|
22
|
+
test.write(cal.to_ical)
|
23
|
+
test.close
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paulsm-icalendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Scott-Murphy
|
8
|
+
autorequire: icalendar
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-08 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Implements the iCalendar specification (RFC-2445) in Ruby. This allows for the generation and parsing of .ics files, which are used by a variety of calendaring applications.
|
17
|
+
email: paul@scott-murphy.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- COPYING
|
25
|
+
- GPL
|
26
|
+
files:
|
27
|
+
- test/calendar_test.rb
|
28
|
+
- test/parameter_test.rb
|
29
|
+
- test/interactive.rb
|
30
|
+
- test/conversions_test.rb
|
31
|
+
- test/component_test.rb
|
32
|
+
- test/parser_test.rb
|
33
|
+
- test/read_write.rb
|
34
|
+
- test/fixtures
|
35
|
+
- test/fixtures/single_event.ics
|
36
|
+
- test/fixtures/folding.ics
|
37
|
+
- test/fixtures/simplecal.ics
|
38
|
+
- test/fixtures/life.ics
|
39
|
+
- test/component
|
40
|
+
- test/component/timezone_test.rb
|
41
|
+
- test/component/todo_test.rb
|
42
|
+
- test/component/event_test.rb
|
43
|
+
- test/coverage
|
44
|
+
- test/coverage/STUB
|
45
|
+
- lib/icalendar
|
46
|
+
- lib/icalendar/parameter.rb
|
47
|
+
- lib/icalendar/component.rb
|
48
|
+
- lib/icalendar/base.rb
|
49
|
+
- lib/icalendar/parser.rb
|
50
|
+
- lib/icalendar/calendar.rb
|
51
|
+
- lib/icalendar/component
|
52
|
+
- lib/icalendar/component/alarm.rb
|
53
|
+
- lib/icalendar/component/todo.rb
|
54
|
+
- lib/icalendar/component/event.rb
|
55
|
+
- lib/icalendar/component/journal.rb
|
56
|
+
- lib/icalendar/component/timezone.rb
|
57
|
+
- lib/icalendar/component/freebusy.rb
|
58
|
+
- lib/icalendar/conversions.rb
|
59
|
+
- lib/icalendar/rrule.rb
|
60
|
+
- lib/icalendar/tzinfo.rb
|
61
|
+
- lib/icalendar/helpers.rb
|
62
|
+
- lib/meta.rb
|
63
|
+
- lib/icalendar.rb
|
64
|
+
- lib/hash_attrs.rb
|
65
|
+
- docs/rfcs
|
66
|
+
- docs/rfcs/rfc2446.pdf
|
67
|
+
- docs/rfcs/rfc2426.pdf
|
68
|
+
- docs/rfcs/itip_notes.txt
|
69
|
+
- docs/rfcs/rfc2447.pdf
|
70
|
+
- docs/rfcs/rfc2425.pdf
|
71
|
+
- docs/rfcs/rfc2445.pdf
|
72
|
+
- docs/rfcs/rfc3283.txt
|
73
|
+
- examples/single_event.ics
|
74
|
+
- examples/parse_cal.rb
|
75
|
+
- examples/create_cal.rb
|
76
|
+
- Rakefile
|
77
|
+
- README
|
78
|
+
- COPYING
|
79
|
+
- GPL
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://icalendar.rubyforge.org/
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options:
|
84
|
+
- --main
|
85
|
+
- README
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
93
|
+
version:
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: "0"
|
99
|
+
version:
|
100
|
+
requirements: []
|
101
|
+
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.2.0
|
104
|
+
signing_key:
|
105
|
+
specification_version: 2
|
106
|
+
summary: A ruby implementation of the iCalendar specification (RFC-2445).
|
107
|
+
test_files: []
|
108
|
+
|