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,104 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
-
3
- require 'test/unit'
4
- require 'icalendar'
5
-
6
- require 'date'
7
-
8
- class TestConversions < Test::Unit::TestCase
9
- include Icalendar
10
-
11
- RESULT = <<EOS.gsub("\n", "\r\n")
12
- BEGIN:VCALENDAR
13
- VERSION:2.0
14
- CALSCALE:GREGORIAN
15
- PRODID:iCalendar-Ruby
16
- BEGIN:VEVENT
17
- CATEGORIES:foo,bar,baz
18
- DESCRIPTION:desc
19
- DTSTAMP:20060720T174052
20
- DTSTART;VALUE=DATE:20060720
21
- EXDATE;TZID=America/New_York:20121012T170000,20121102T170000
22
- GEO:46.01;8.57
23
- LAST-MODIFIED:19960817T133000
24
- ORGANIZER:mailto:joe@example.com?subject=Ruby
25
- RRULE:FREQ=WEEKLY;UNTIL=20130220T180000Z;BYDAY=FR
26
- SEQUENCE:2
27
- UID:foobar
28
- X-TIME-OF-DAY:101736
29
- END:VEVENT
30
- END:VCALENDAR
31
- EOS
32
-
33
- def setup
34
- @cal = Calendar.new
35
- end
36
-
37
- def test_to_ical_conversions
38
- @cal.event do
39
- # String
40
- description "desc"
41
-
42
- # Fixnum
43
- sequence 2
44
-
45
- # Float by way of Geo class
46
- geo(Geo.new(46.01, 8.57))
47
-
48
- # Array
49
- categories ["foo", "bar"]
50
- add_category "baz"
51
-
52
- # Last Modified
53
- last_modified DateTime.parse("1996-08-17T13:30:00")
54
-
55
- # URI
56
- organizer(URI::MailTo.build(['joe@example.com', 'subject=Ruby']))
57
-
58
- # Date
59
- start Date.parse("2006-07-20"), {'VALUE' => 'DATE'}
60
-
61
- # DateTime
62
- timestamp DateTime.parse("2006-07-20T17:40:52+0200")
63
-
64
- # Time
65
- x_time_of_day Time.at(123456).utc
66
-
67
- uid "foobar"
68
-
69
- add_rrule "FREQ=WEEKLY;UNTIL=20130220T180000Z;BYDAY=FR"
70
- exception_dates %w(20121012T170000 20121102T170000), {'TZID' => 'America/New_York'}
71
- end
72
-
73
- assert_equal(RESULT, @cal.to_ical)
74
- # test round-trip
75
- assert_equal(@cal.to_ical, Icalendar.parse(RESULT).to_ical)
76
- end
77
-
78
- def test_to_ical_folding
79
- @cal.x_wr_calname = 'Test Long Description'
80
-
81
- @cal.event do
82
- url 'http://test.com/events/644'
83
- dtend DateTime.parse('20061215T180000')
84
- dtstart DateTime.parse('20061215T160000')
85
- timestamp DateTime.parse('20061215T114034')
86
- seq 1001
87
- uid 'foobar'
88
- summary 'DigiWorld 2006'
89
-
90
- description "FULL DETAILS:\nhttp://test.com/events/570\n\n" +
91
- "Cary Brothers walks the same musical ground as Pete Yorn, Nick Drake, " +
92
- "Jeff Buckley and others; crafting emotional melodies, with strong vocals " +
93
- "and thoughtful lyrics. Brett Dennen has &quot;that thing.&quot; " +
94
- "Inspired fans describe it: &quot;lush shimmering vocals, an intricately " +
95
- "groovin&#39; guitar style, a lyrical beauty rare in a young songwriter," +
96
- "&quot; and &quot;this soulful blend of everything that feels good.&quot; " +
97
- "Rising up around him is music; transcending genres, genders and generations."
98
- end
99
-
100
- folded = File.read(File.join(File.dirname(__FILE__), 'fixtures/folding.ics')).gsub("\n", "\r\n")
101
- assert_equal(folded, @cal.to_ical)
102
- end
103
-
104
- end
data/test/test_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- if ENV['UNDER_HUDSON']
4
- require 'rubygems'
5
- require 'ci/reporter/rake/test_unit_loader'
6
- end
7
- require File.dirname(__FILE__) + '/../lib/icalendar'
@@ -1,91 +0,0 @@
1
- # Test out property parameter functionality
2
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
3
-
4
- require 'pp'
5
- require 'date'
6
- require 'test/unit'
7
- require 'icalendar'
8
-
9
- class TestParameter < Test::Unit::TestCase
10
-
11
- # Create a calendar with an event for each test.
12
- def setup
13
- @cal = Icalendar::Calendar.new
14
- @event = Icalendar::Event.new
15
- end
16
-
17
- def test_property_parameters
18
- tests = [
19
- {"ALTREP" =>['"http://my.language.net"'],
20
- "LANGUAGE" => ["SPANISH"]},
21
- {"ALTREP" =>['"http://my.language.net"'],
22
- "LANGUAGE" => ['"SPANISH:CATILLAN"']},
23
- {"ALTREP" =>["foo"],
24
- "LANGUAGE" => ["SPANISH"]}
25
- ]
26
-
27
- tests.each do |params|
28
- @event.summary("This is a test summary.", params)
29
-
30
- assert_equal params, @event.summary.ical_params
31
-
32
- @cal.add_event @event
33
- cal_str = @cal.to_ical
34
-
35
- cals = Icalendar::Parser.new(cal_str).parse
36
- event = cals.first.events.first
37
- assert_equal params, event.summary.ical_params
38
- end
39
- end
40
-
41
- def test_attachment_parameters
42
- params = {
43
- 'ENCODING' => ['BASE64'],
44
- 'FMTYPE' => ['text/directory'],
45
- 'VALUE' => ['BINARY'],
46
- 'X-APPLE-FILENAME' => ['1234.vcf']
47
- }
48
- @event.add_attachment 'binarystring', params
49
-
50
- assert_equal params, @event.attachments[0].ical_params
51
- @cal.add_event @event
52
- cal_str = @cal.to_ical
53
-
54
- cals = Icalendar::Parser.new(cal_str).parse
55
- event = cals.first.events.first
56
- assert_equal params, event.attachments[0].ical_params
57
- end
58
-
59
- def test_unquoted_property_parameters
60
- params = {'ALTREP' => ['"http://my.language.net"'],
61
- 'LANGUAGE' => ['SPANISH:CATILLAN'],
62
- 'CN' => ['Joe "The Man" Tester']}
63
- expected_params = {'ALTREP' => ['"http://my.language.net"'],
64
- 'LANGUAGE' => ['"SPANISH:CATILLAN"'],
65
- 'CN' => ["Joe 'The Man' Tester"]}
66
- @event.summary('This is a test summary.', params)
67
-
68
- assert_equal params, @event.summary.ical_params
69
-
70
- @cal.add_event @event
71
- cal_str = @cal.to_ical
72
-
73
- cals = Icalendar::Parser.new(cal_str).parse
74
- event = cals.first.events.first
75
- assert_equal expected_params, event.summary.ical_params
76
- end
77
-
78
- def test_nonstandard_property_parameters
79
- params = {'CUSTOM' => ['yours']}
80
- @event.priority(2, params)
81
-
82
- assert_equal params, @event.priority.ical_params
83
-
84
- @cal.add_event @event
85
- cal_str = @cal.to_ical
86
-
87
- cals = Icalendar::Parser.new(cal_str).parse
88
- event = cals.first.events.first
89
- assert_equal params, event.priority.ical_params
90
- end
91
- end
data/test/test_parser.rb DELETED
@@ -1,100 +0,0 @@
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
- NONSTANDARD = File.join(File.dirname(__FILE__), 'fixtures', 'nonstandard.ics')
11
-
12
- # First make sure that we can run the parser and get back objects.
13
- def test_new
14
- # Make sure we don't take invalid object types.
15
- assert_raise(ArgumentError) { Icalendar::Parser.new(nil) }
16
-
17
- # Make sure we get an object back from parsing a file
18
- calFile = File.open(TEST_CAL)
19
- cals = Icalendar::Parser.new(calFile).parse
20
- assert(cals)
21
- calFile.close
22
-
23
- # Make sure we get an object back from parsing a string
24
- calString = File.open(TEST_CAL).read
25
- cals = Icalendar::Parser.new(calString).parse
26
- assert(cals)
27
- end
28
-
29
- # Now go through and make sure the object is correct using the
30
- # dynamically generated raw interfaces.
31
- def test_zzfile_parse
32
- calFile = File.open(TEST_CAL)
33
- cals = Icalendar.parse(calFile)
34
- calFile.close
35
- do_asserts(cals)
36
-
37
- Icalendar::Base.quiet
38
- end
39
-
40
- def test_string_parse
41
- # Make sure we get an object back from parsing a string
42
- calString = File.open(TEST_CAL).read
43
- cals = Icalendar::Parser.new(calString).parse
44
- do_asserts(cals)
45
- end
46
-
47
- def test_strict_parser
48
- File.open(NONSTANDARD) do |cal_file|
49
- assert_raise(Icalendar::UnknownPropertyMethod) do
50
- Icalendar::Parser.new(cal_file).parse
51
- end
52
- end
53
- end
54
-
55
- def test_lenient_parser
56
- File.open(NONSTANDARD) do |cal_file|
57
- do_asserts Icalendar::Parser.new(cal_file, false).parse
58
- end
59
- end
60
-
61
- # Just a helper method so we don't have to repeat the same tests.
62
- def do_asserts(cals)
63
- # Should just get one calendar back.
64
- assert_equal(1, cals.size)
65
-
66
- cal = cals.first
67
-
68
- # Calendar properties
69
- assert_equal("2.0", cal.version)
70
- assert_equal("bsprodidfortestabc123", cal.prodid)
71
-
72
- # Now the event
73
- assert_equal(1, cal.events.size)
74
-
75
- event = cal.events.first
76
- assert_equal("bsuidfortestabc123", event.uid)
77
- assert_equal("SomeName", event.ip_name)
78
-
79
- 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."
80
-
81
- assert_equal(summary, event.summary)
82
-
83
- start = DateTime.parse("20050120T170000")
84
- daend = DateTime.parse("20050120T184500")
85
- stamp = DateTime.parse("20050118T211523Z")
86
- assert_equal(start, event.dtstart)
87
- assert_equal(daend, event.dtend)
88
- assert_equal(stamp, event.dtstamp)
89
-
90
- organizer = URI.parse("mailto:joebob@random.net")
91
- assert_equal(organizer, event.organizer)
92
-
93
- ats = event.attachments
94
- assert_equal(2, ats.size)
95
- attachment = URI.parse("http://bush.sucks.org/impeach/him.rhtml")
96
- assert_equal(attachment, ats[0])
97
- attachment = URI.parse("http://corporations-dominate.existence.net/why.rhtml")
98
- assert_equal(attachment, ats[1])
99
- end
100
- end
data/test/test_tzinfo.rb DELETED
@@ -1,83 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
-
3
- require 'test/unit'
4
- require 'icalendar'
5
- require 'tzinfo'
6
- require 'icalendar/tzinfo'
7
- require 'timecop'
8
-
9
- class TestTZInfoExt < Test::Unit::TestCase
10
- def setup
11
- tz = TZInfo::Timezone.get 'Europe/Copenhagen'
12
- @timezone = tz.ical_timezone DateTime.new(1970)
13
- end
14
-
15
- def test_daylight_offset
16
- tz_offset_from = @timezone.instance_variable_get("@components")[:daylights][0].properties["tzoffsetfrom"]
17
- tz_offset_to = @timezone.instance_variable_get("@components")[:daylights][0].properties["tzoffsetto"]
18
- assert_equal "+0100", tz_offset_from
19
- assert_equal "+0200", tz_offset_to
20
- end
21
-
22
- def test_standard_offset
23
- tz_offset_from = @timezone.instance_variable_get("@components")[:standards][0].properties["tzoffsetfrom"]
24
- tz_offset_to = @timezone.instance_variable_get("@components")[:standards][0].properties["tzoffsetto"]
25
- assert_equal "+0200", tz_offset_from
26
- assert_equal "+0100", tz_offset_to
27
- end
28
-
29
- def test_no_end_transition
30
- tz = TZInfo::Timezone.get('America/Cayman').ical_timezone DateTime.now
31
- assert_equal <<-EXPECTED.gsub("\n", "\r\n"), tz.to_ical
32
- BEGIN:VTIMEZONE
33
- TZID:America/Cayman
34
- BEGIN:STANDARD
35
- DTSTART:19120201T000711
36
- TZNAME:EST
37
- TZOFFSETFROM:-0652
38
- TZOFFSETTO:-0500
39
- END:STANDARD
40
- END:VTIMEZONE
41
- EXPECTED
42
- end
43
-
44
- def test_no_transition
45
- tz = TZInfo::Timezone.get('UTC').ical_timezone DateTime.now
46
- assert_equal <<-EXPECTED.gsub("\n", "\r\n"), tz.to_ical
47
- BEGIN:VTIMEZONE
48
- TZID:UTC
49
- BEGIN:STANDARD
50
- DTSTART:19700101T000000
51
- TZNAME:UTC
52
- TZOFFSETFROM:+0000
53
- TZOFFSETTO:+0000
54
- END:STANDARD
55
- END:VTIMEZONE
56
- EXPECTED
57
- end
58
-
59
- def test_dst_transition
60
- tz = TZInfo::Timezone.get "America/Los_Angeles"
61
-
62
- # DST transition in America/Los_Angeles
63
- Timecop.freeze('2013-11-03T01:30:00-08:00') do
64
- assert_raises(TZInfo::AmbiguousTime) { tz.ical_timezone( tz.now ) }
65
- assert_raises(TZInfo::AmbiguousTime) { tz.ical_timezone( tz.now, nil ) }
66
- assert_raises(TZInfo::AmbiguousTime) do
67
- TZInfo::Timezone.default_dst = nil
68
- tz.ical_timezone( tz.now )
69
- end
70
-
71
- assert_nothing_raised { tz.ical_timezone( tz.now, true ) }
72
- assert_nothing_raised { tz.ical_timezone( tz.now, false ) }
73
- assert_nothing_raised do
74
- TZInfo::Timezone.default_dst = true
75
- tz.ical_timezone( tz.now )
76
- end
77
- assert_nothing_raised do
78
- TZInfo::Timezone.default_dst = false
79
- tz.ical_timezone( tz.now )
80
- end
81
- end
82
- end
83
- end
data/website/index.html DELETED
@@ -1,70 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
- <title>
8
- icalendar
9
- </title>
10
- <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
- <style>
12
-
13
- </style>
14
- <script type="text/javascript">
15
- window.onload = function() {
16
- settings = {
17
- tl: { radius: 10 },
18
- tr: { radius: 10 },
19
- bl: { radius: 10 },
20
- br: { radius: 10 },
21
- antiAlias: true,
22
- autoPad: true,
23
- validTags: ["div"]
24
- }
25
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
26
- versionBox.applyCornersToAll();
27
- }
28
- </script>
29
- </head>
30
- <body>
31
- <div id="main">
32
-
33
- <h1>icalendar</h1>
34
- <div class="sidebar">
35
- <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/icalendar"; return false'>
36
- <p>Get Version</p>
37
- <a href="http://rubyforge.org/projects/icalendar" class="numbers">1.2.3</a>
38
- </div>
39
- </div>
40
- <h2>What</h2>
41
- <p>This gem implements the iCalendar specification (<span class="caps">RFC</span>-2445) in Ruby. This allows for the generation and parsing of .ics files, which are used by a variety of calendaring applications.</p>
42
- <h2>How</h2>
43
- <p>Please see <a href="https://github.com/icalendar/icalendar/blob/master/README.rdoc">the <span class="caps">README</span></a> for more information.</p>
44
- <h2>Docs</h2>
45
- <p>The best documents are the code, but we&#8217;ll attempt to keep the <a href="http://icalendar.rubyforge.org/rdoc">rdoc</a> up to date.</p>
46
- <h2>Installing</h2>
47
- <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">icalendar</span></pre></p>
48
- <h2>How to submit patches</h2>
49
- <p>Please submit pull requests on github from a rebased topic branch</p>
50
- <ul>
51
- <li><a href="http://github.com/icalendar/icalendar/">http://github.com/icalendar/icalendar/</a></li>
52
- </ul>
53
- <pre>git clone git://github.com/sdague/icalendar.git</pre>
54
- <h3>Build and test instructions</h3>
55
- <pre>cd icalendar
56
- rake test
57
- rake install_gem</pre>
58
- <h2>License</h2>
59
- <p>This code is free to use under the terms of the <span class="caps">GPL</span> or <span class="caps">BSD</span> licenses.</p>
60
- <p>Please see the <a href="https://github.com/icalendar/icalendar/blob/master/COPYING"><span class="caps">COPYING</span></a> file for more information.</p>
61
- <p class="coda">
62
- <a href="mailto:ryan@coshx.com">Ryan Ahearn</a>, 9th March 2013<br>
63
- Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
64
- </p>
65
- </div>
66
-
67
- <!-- insert site tracking codes here, like Google Urchin -->
68
-
69
- </body>
70
- </html>