vpim 0.695 → 13.11.11

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 (52) hide show
  1. checksums.yaml +7 -0
  2. data/{README → README.rdoc} +2 -13
  3. data/lib/vpim.rb +1 -0
  4. data/lib/vpim/address.rb +3 -2
  5. data/lib/vpim/agent/atomize.rb +4 -0
  6. data/lib/vpim/agent/base.rb +74 -0
  7. data/lib/vpim/agent/calendars.rb +1 -0
  8. data/lib/vpim/agent/handler.rb +27 -0
  9. data/lib/vpim/agent/ics.rb +162 -0
  10. data/lib/vpim/attachment.rb +1 -0
  11. data/lib/vpim/date.rb +3 -2
  12. data/lib/vpim/dirinfo.rb +5 -4
  13. data/lib/vpim/duration.rb +1 -0
  14. data/lib/vpim/enumerator.rb +1 -0
  15. data/lib/vpim/field.rb +3 -2
  16. data/lib/vpim/icalendar.rb +9 -5
  17. data/lib/vpim/maker/vcard.rb +1 -0
  18. data/lib/vpim/property/base.rb +1 -0
  19. data/lib/vpim/property/common.rb +1 -0
  20. data/lib/vpim/property/location.rb +10 -0
  21. data/lib/vpim/property/priority.rb +2 -1
  22. data/lib/vpim/property/recurrence.rb +1 -0
  23. data/lib/vpim/property/resources.rb +1 -2
  24. data/lib/vpim/repo.rb +2 -1
  25. data/lib/vpim/rfc2425.rb +32 -24
  26. data/lib/vpim/rrule.rb +9 -8
  27. data/lib/vpim/time.rb +1 -0
  28. data/lib/vpim/vcard.rb +13 -11
  29. data/lib/vpim/version.rb +2 -2
  30. data/lib/vpim/vevent.rb +3 -1
  31. data/lib/vpim/view.rb +3 -2
  32. data/lib/vpim/vjournal.rb +1 -0
  33. data/lib/vpim/vpim.rb +2 -1
  34. data/lib/vpim/vtodo.rb +1 -0
  35. data/samples/agent.ru +10 -0
  36. data/test/test_all.rb +2 -0
  37. data/test/test_date.rb +6 -5
  38. data/test/test_dur.rb +1 -0
  39. data/test/test_field.rb +3 -2
  40. data/test/test_ical.rb +12 -2
  41. data/test/test_misc.rb +13 -0
  42. data/test/test_repo.rb +22 -2
  43. data/test/test_rrule.rb +1 -0
  44. data/test/test_vcard.rb +53 -1
  45. metadata +36 -46
  46. data/lib/vpim/agent/app.rb +0 -194
  47. data/lib/vpim/agent/main.rb +0 -327
  48. data/lib/vpim/agent/scraps.rb +0 -292
  49. data/test/test_agent_app.rb +0 -74
  50. data/test/test_agent_atomize.rb +0 -84
  51. data/test/test_agent_calendars.rb +0 -128
  52. data/test/test_view.rb +0 -79
@@ -1,74 +0,0 @@
1
- require 'test/common'
2
- require 'sinatra/test/unit'
3
-
4
- require 'vpim/agent/app'
5
-
6
- class IcsAgent < Test::Unit::TestCase
7
-
8
- def to_str
9
- @caldata
10
- end
11
-
12
- def setup
13
- @thrd = data_on_port(self, 9876)
14
- end
15
- def teardown
16
- @thrd.kill
17
- end
18
-
19
- def test_ics_atom_query
20
- @caldata = open('test/calendars/weather.calendar/Events/1205042405-0-0.ics').read
21
-
22
- get '/ics/atom?http://127.0.0.1:9876'
23
-
24
- #pp @response
25
- assert(@response.body =~ /<\?xml/)
26
- assert_equal(Vpim::Agent::Atomize::MIME, @response['Content-Type'])
27
- assert_equal(200, @response.status)
28
- assert(@response.body =~ Regexp.new(
29
- Regexp.quote(
30
- "<id>http://example.org/ics/atom?http://127.0.0.1:9876</id>"
31
- )), @response.body)
32
- end
33
-
34
- def test_ics
35
- get '/ics'
36
-
37
- assert(@response.body =~ /<html/)
38
- assert_equal('text/html', @response['Content-Type'])
39
- assert_equal(200, @response.status)
40
- assert(@response.body =~ Regexp.new(
41
- Regexp.quote("<title>Subscribe")), @response.body)
42
- end
43
-
44
- def test_ics_query
45
- @caldata = open('test/calendars/weather.calendar/Events/1205042405-0-0.ics').read
46
-
47
- get '/ics?http://127.0.0.1:9876'
48
-
49
- assert(@response.body =~ /<html/)
50
- assert_equal('text/html', @response['Content-Type'])
51
- assert_equal(200, @response.status)
52
-
53
- assert(@response.body =~ Regexp.new(
54
- Regexp.quote("Subscribe to")), @response.body)
55
- end
56
-
57
- def test_ics_atom
58
- get '/ics/atom'
59
- assert_equal(302, @response.status)
60
- end
61
-
62
- =begin
63
-
64
- WTF? Sinatra doesn't run it's error catcher in unit test mode?
65
- def test_ics_atom_query_bad
66
- get '/ics/atom?http://example.com'
67
- assert_equal(500, @response.status)
68
- assert(@response.body =~ Regexp.new(
69
- Regexp.quote("error")), @response.body)
70
- end
71
- =end
72
-
73
- end
74
-
@@ -1,84 +0,0 @@
1
- require 'test/common'
2
-
3
- require 'vpim/agent/atomize'
4
- require 'vpim/icalendar'
5
- require 'vpim/view'
6
-
7
- class TextAgentAtomize < Test::Unit::TestCase
8
-
9
- def atomize(cal, feeduri, caluri, filter=nil)
10
- ical = Vpim::Icalendar.decode(cal).first
11
- if filter
12
- ical = filter.call(ical)
13
- end
14
- feed = Vpim::Agent::Atomize.calendar(ical, feeduri, caluri)
15
- return ical, feed
16
- end
17
-
18
- def test_minimal
19
- ical, feed = atomize(<<'__', "http://example.com/feed", "http://example.com/calendar")
20
- BEGIN:VCALENDAR
21
- BEGIN:VEVENT
22
- DTSTART:20090214T144503
23
- END:VEVENT
24
- END:VCALENDAR
25
- __
26
-
27
- assert_equal(feed.entries.size, 1)
28
- assert_equal("http://example.com/feed", feed.id)
29
- assert_equal("http://example.com/calendar", feed.title)
30
- assert(feed.to_xml.to_str)
31
- assert_equal(nil, feed.entries.first.title)
32
- assert_equal(nil, feed.entries.first.content)
33
- #puts feed.to_xml
34
- end
35
-
36
- def test_small
37
- ical, feed = atomize(<<'__', "http://example.com/feed", "http://example.com/calendar")
38
- BEGIN:VCALENDAR
39
- BEGIN:VEVENT
40
- DTSTART:20090214T144503
41
- SUMMARY:I am summarized
42
- DESCRIPTION:And I am described
43
- UID:very, very, unique
44
- END:VEVENT
45
- END:VCALENDAR
46
- __
47
-
48
- assert_equal(feed.entries.size, 1)
49
- assert_equal("http://example.com/feed", feed.id)
50
- assert_equal("http://example.com/calendar", feed.title)
51
- assert_equal("I am summarized", feed.entries.first.title)
52
- assert_equal("And I am described", feed.entries.first.content)
53
- assert(feed.to_xml.to_str)
54
- #puts feed.to_xml
55
- end
56
-
57
- def test_recurring
58
- filter = proc do |cal|
59
- Vpim::View.week(cal)
60
- end
61
- ical, feed = atomize(<<'__', "http://example.com/feed", "http://example.com/calendar", filter)
62
- BEGIN:VCALENDAR
63
- BEGIN:VEVENT
64
- DTSTART:20090214T144503
65
- RRULE:FREQ=weekly
66
- SUMMARY:I am summarized
67
- DESCRIPTION:And I am described
68
- UID:very, very, unique
69
- END:VEVENT
70
- END:VCALENDAR
71
- __
72
-
73
- puts feed.to_xml
74
- assert_equal(1, feed.entries.size)
75
- assert_equal("http://example.com/feed", feed.id)
76
- assert_equal("http://example.com/calendar", feed.title)
77
- assert_equal("I am summarized", feed.entries.first.title)
78
- assert_equal("And I am described", feed.entries.first.content)
79
- assert(feed.to_xml.to_str)
80
- end
81
-
82
- end
83
-
84
-
@@ -1,128 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'vpim/repo'
4
- require 'vpim/agent/calendars'
5
- require 'test/common'
6
-
7
- class TestAgentCalendars < Test::Unit::TestCase
8
- Apple3 = Vpim::Repo::Apple3
9
- Directory = Vpim::Repo::Directory
10
- Uri = Vpim::Repo::Uri
11
- Agent = Vpim::Agent
12
- Path = Agent::Path
13
- NotFound = Agent::NotFound
14
-
15
- def setup
16
- @testdir = Dir.getwd + "/test" #File.dirname($0) doesn't work with rcov :-(
17
- @caldir = @testdir + "/calendars"
18
- @eventsz = Dir[@caldir + "/**/*.ics"].size
19
- assert(@testdir)
20
- assert(test(?d, @caldir), "no caldir "+@caldir)
21
- end
22
-
23
- def assert_is_text_calendar(text)
24
- lines = text.split("\n")
25
- lines = lines.first, lines.last
26
- assert_equal("BEGIN:VCALENDAR", lines.first.upcase, lines)
27
- assert_equal("END:VCALENDAR", lines.last.upcase, lines)
28
- end
29
-
30
- def test_agent_calendars
31
- repo = Apple3.new(@caldir)
32
- rest = Agent::Calendars.new(repo)
33
-
34
- out1, form = rest.get(Path.new("http://host/here", "/here"))
35
- assert_equal("text/html", form)
36
- #puts(out1)
37
-
38
- out1, form = rest.get(Path.new("http://host/here/weather%2fLeavenworth", "/here"))
39
- assert_equal("text/html", form)
40
- #puts(out1)
41
-
42
- out2, form = rest.get(Path.new("http://host/here/weather%2fLeavenworth/calendar", "/here"))
43
- assert_equal("text/calendar", form)
44
- assert_is_text_calendar(out2)
45
-
46
- #assert_equal(out1, out2)
47
-
48
- assert_raise(Vpim::Agent::NotFound) do
49
- rest.get(Path.new("http://host/here/weather%2fLeavenworth/an_unknown_protocol", "/here"))
50
- end
51
- assert_raise(Vpim::Agent::NotFound) do
52
- rest.get(Path.new("http://host/here/no_such_calendar", "/here"))
53
- end
54
-
55
- assert_equal(["","/","/"], Vpim::Agent::Path.split_path("/%2F/%2F"))
56
- assert_equal(["/","/"], Vpim::Agent::Path.split_path("%2F/%2F"))
57
- assert_equal(["calendars", "weather/Leavenworth"],
58
- Vpim::Agent::Path.split_path("calendars/weather%2FLeavenworth"))
59
- end
60
-
61
- def test_agent_calendar_atom
62
- repo = Apple3.new(@caldir)
63
- rest = Agent::Calendars.new(repo)
64
-
65
- out, form = rest.get(Path.new("http://host/here/weather%2fLeavenworth/atom", "/here"))
66
- assert_equal("application/atom+xml", form)
67
- #pp out
68
- #assert_is_atom(out)
69
- end
70
-
71
- def _test_path_shift(url, shifts)
72
- # last shift should be a nil
73
- shifts << nil
74
-
75
- # presence or absence of a trailing / should not affect shifting
76
- ["", "/"].each do |trailer|
77
- path = Path.new(url + trailer)
78
- shifts.each do |_|
79
- assert_equal(_, path.shift)
80
- end
81
- end
82
- end
83
-
84
- def test_path_shift
85
- _test_path_shift("http://host.ex", [])
86
- _test_path_shift("http://host.ex/a", ["a"])
87
- _test_path_shift("http://host.ex/a/b", ["a", "b"])
88
- _test_path_shift("http://host.ex/a/b/c", ["a", "b", "c"])
89
- end
90
-
91
- def _test_path_prefix(base, parts, shifts, prefix)
92
- path = Path.new(base+parts.join("/"))
93
- shifts.times{ path.shift }
94
- assert_equal(prefix, path.prefix)
95
- end
96
-
97
- def test_path_prefix
98
- _test_path_prefix("http://host.ex/", [], 0, "/")
99
- _test_path_prefix("http://host.ex/", ["a"], 0, "/")
100
- _test_path_prefix("http://host.ex/", ["a"], 1, "/")
101
- _test_path_prefix("http://host.ex/", ["a"], 2, "/a/")
102
- _test_path_prefix("http://host.ex/", ["a"], 3, "/a/")
103
- _test_path_prefix("http://host.ex/", ["a", "b"], 0, "/")
104
- _test_path_prefix("http://host.ex/", ["a", "b"], 1, "/")
105
- _test_path_prefix("http://host.ex/", ["a", "b"], 2, "/a/")
106
- _test_path_prefix("http://host.ex/", ["a", "b"], 3, "/a/b/")
107
- end
108
-
109
- =begin
110
- def test_atomize
111
- repo = Apple3.new(@caldir)
112
- cal = repo.find{true}
113
- a = Vpim::Agent::Atomize.new(cal)
114
- assert( a.get(Path.new("http://example.com/path")))
115
- end
116
-
117
- def x_test_uri_query
118
- uri = "http://example.com/ics/atom?http://localhost:9876"
119
-
120
- repo = Uri.new("http://localhost:9876")
121
- rest = Agent::Calendars.new(repo)
122
- out1, form = rest.get(Path.new("http://example.com/ics", "/ics/atom"))
123
- p [out1, form]
124
- end
125
- =end
126
-
127
- end
128
-
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
-
5
- require 'vpim/repo'
6
- require 'vpim/view'
7
-
8
- class TestView < Test::Unit::TestCase
9
- View = Vpim::View
10
- Icalendar = Vpim::Icalendar
11
-
12
- def _test_week_events(vc, kind)
13
- vc = Icalendar.decode(vc.to_s.gsub("EVENT", kind)).first
14
-
15
- vv = View.week vc
16
-
17
- reader = kind.downcase + "s"
18
-
19
- kind = "check against kind=" + kind + "<\n" + vv.to_s + ">\n"
20
-
21
- assert_no_match(/yesterday/, vv.to_s, kind)
22
- assert_no_match(/nextweek/, vv.to_s, kind)
23
-
24
- assert_equal(["starts tomorrow"], vv.send(reader).map{|ve| ve.summary}, kind)
25
- end
26
-
27
- def test_week_single
28
- now = Time.now
29
- yesterday = now - View::SECSPERDAY
30
- tomorrow = now + View::SECSPERDAY
31
- nextweek = now + View::SECSPERDAY * 8
32
-
33
- vc = Icalendar.create2 do |vc|
34
- %w{yesterday tomorrow nextweek}.each do |dtstart|
35
- vc.add_event do |ve|
36
- ve.dtstart eval(dtstart)
37
- ve.summary "starts #{dtstart}"
38
- end
39
- end
40
- end
41
-
42
- _test_week_events(vc, "EVENT")
43
- _test_week_events(vc, "TODO")
44
- _test_week_events(vc, "JOURNAL")
45
- end
46
-
47
- def test_week_recurring
48
- now = Time.now
49
- ago = now - View::SECSPERDAY * 2
50
-
51
- vc = Icalendar.create2 do |vc|
52
- vc.add_event do |ve|
53
- ve.dtstart ago
54
- ve.dtend ago + View::SECSPERDAY / 2
55
- ve.add_rrule do |r|
56
- r.frequency = "daily"
57
- end
58
- end
59
- end
60
-
61
- vv = View.week vc
62
-
63
- assert_equal(1, vv.events.to_a.size)
64
-
65
- ve = vv.events{|e| break e}
66
-
67
- #p ve
68
-
69
- #puts "now=" + now.to_s
70
-
71
- ve.occurrences() do |t|
72
- p [now, t, t + ve.duration]
73
- end
74
-
75
-
76
-
77
- end
78
- end
79
-