agcaldav 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/lib/agcaldav/client.rb +7 -2
- data/lib/agcaldav/version.rb +1 -1
- data/spec/agcaldav/client_spec.rb +26 -4
- metadata +3 -2
data/.gitignore
CHANGED
data/lib/agcaldav/client.rb
CHANGED
@@ -41,6 +41,7 @@ module AgCalDAV
|
|
41
41
|
|
42
42
|
def find_events data
|
43
43
|
result = ""
|
44
|
+
events = []
|
44
45
|
res = nil
|
45
46
|
__create_http.start {|http|
|
46
47
|
req = Net::HTTP::Report.new(@url, initheader = {'Content-Type'=>'application/xml'} )
|
@@ -55,8 +56,12 @@ module AgCalDAV
|
|
55
56
|
REXML::XPath.each( xml, '//c:calendar-data/', {"c"=>"urn:ietf:params:xml:ns:caldav"} ){|c| result << c.text}
|
56
57
|
r = Icalendar.parse(result)
|
57
58
|
unless r.empty?
|
58
|
-
|
59
|
-
|
59
|
+
r.each do |calendar|
|
60
|
+
calendar.events.each do |event|
|
61
|
+
events << event
|
62
|
+
end
|
63
|
+
end
|
64
|
+
events
|
60
65
|
else
|
61
66
|
return false
|
62
67
|
end
|
data/lib/agcaldav/version.rb
CHANGED
@@ -14,10 +14,32 @@ describe AgCalDAV::Client do
|
|
14
14
|
@c.class.to_s.should == "AgCalDAV::Client"
|
15
15
|
end
|
16
16
|
|
17
|
+
it "create one event" do
|
18
|
+
uid = "5385e2d0-3707-0130-9e49-0019996389cc"
|
19
|
+
FakeWeb.register_uri(:any, %r{http://user@localhost:5232/user/calendar/(.*).ics}, :body => "")
|
20
|
+
r = @c.create_event(:start => "2012-12-29 10:00", :end => "2012-12-30 12:00", :title => "12345", :description => "12345 12345")
|
21
|
+
r.should_not be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "failed create one event DuplicateError" do
|
25
|
+
uid = "5385e2d0-3707-0130-9e49-0019996389cc"
|
26
|
+
FakeWeb.register_uri(:any, %r{http://user@localhost:5232/user/calendar/(.*).ics}, :body => "BEGIN:VCALENDAR\nPRODID:.....")
|
27
|
+
lambda{@c.create_event(:start => "2012-12-29 10:00", :end => "2012-12-30 12:00", :title => "12345", :description => "12345 12345")}.should raise_error(AgCalDAV::DuplicateError)
|
28
|
+
end
|
29
|
+
|
17
30
|
it "find one event" do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
31
|
+
uid = "5385e2d0-3707-0130-9e49-001999638982"
|
32
|
+
FakeWeb.register_uri(:get, "http://user@localhost:5232/user/calendar/#{uid}.ics", :body => "BEGIN:VCALENDAR\nPRODID:-//Radicale//NONSGML Radicale Server//EN\nVERSION:2.0\nBEGIN:VEVENT\nDESCRIPTION:12345 12ss345\nDTEND:20130101T110000\nDTSTAMP:20130101T161708\nDTSTART:20130101T100000\nSEQUENCE:0\nSUMMARY:123ss45\nUID:#{uid}\nX-RADICALE-NAME:#{uid}.ics\nEND:VEVENT\nEND:VCALENDAR")
|
33
|
+
r = @c.find_event(uid)
|
34
|
+
r.should_not be_nil
|
35
|
+
r.uid.should == uid
|
22
36
|
end
|
37
|
+
|
38
|
+
|
39
|
+
# it "find 2 events" do
|
40
|
+
# FakeWeb.register_uri(:any, "http://user@10.100.12.111:5232/(.*)", :body => "BEGIN:VCALENDAR\nPRODID:-//Radicale//NONSGML Radicale Server//EN\nVERSION:2.0\nBEGIN:VEVENT\nDESCRIPTION:12345 12345\nDTEND:20010202T120000\nDTSTAMP:20130102T161119\nDTSTART:20010202T080000\nSEQUENCE:0\nSUMMARY:6789\nUID:960232b0-371c-0130-9e6b-001999638982\nX-RADICALE-NAME:960232b0-371c-0130-9e6b-001999638982.ics\nEND:VEVENT\nBEGIN:VEVENT\nDESCRIPTION:12345 12345\nDTEND:20010203T120000\nDTSTAMP:20130102T161124\nDTSTART:20010203T080000\nSEQUENCE:0\nSUMMARY:6789\nUID:98f067a0-371c-0130-9e6c-001999638982\nX-RADICALE-NAME:98f067a0-371c-0130-9e6c-001999638982.ics\nEND:VEVENT\nEND:VCALENDAR")
|
41
|
+
# r = @c.find_events(:start => "2001-02-02 07:00", :end => "2000-02-03 23:59")
|
42
|
+
# r.should_not be_nil
|
43
|
+
# r.length.should == 2
|
44
|
+
# end
|
23
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agcaldav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: icalendar
|
@@ -141,3 +141,4 @@ signing_key:
|
|
141
141
|
specification_version: 3
|
142
142
|
summary: Ruby CalDAV client
|
143
143
|
test_files: []
|
144
|
+
has_rdoc:
|