owncloud_caldav 0.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/LICENSE +21 -0
- data/README.md +54 -0
- data/lib/owncloud_caldav/client.rb +225 -0
- data/lib/owncloud_caldav/filter.rb +78 -0
- data/lib/owncloud_caldav/format.rb +54 -0
- data/lib/owncloud_caldav/net.rb +16 -0
- data/lib/owncloud_caldav/query.rb +51 -0
- data/lib/owncloud_caldav/request.rb +76 -0
- data/lib/owncloud_caldav/version.rb +3 -0
- data/lib/owncloud_caldav.rb +13 -0
- data/owncloud_caldav.gemspec +35 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1e634897f4ec9b1057261ce2994fe9f30395e5ab61f8f8410c2a48b9d1237852
|
4
|
+
data.tar.gz: b8c3d5ac7813004cc2c80d454e025e1412d8ba7bd48cea965ba0497b07f9c39c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6aecfab72e20e2c8b184a86846a85737583a1c5ee50e9d7d3742b88334d0b5fcd6237817582e69321e7bacf6ea78cd40387ba8cbfc3c2e06c15c53d9cf8461a9
|
7
|
+
data.tar.gz: a07cca43ee9c154c2ce3efb5c0fb5e119fd75f0bb5bd4ab12a88044565b3f0493152b7ba2b4a6fbf3551232974676afb9515d7be2581512a27ddaec4b337c08d
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Krzysztof Tomczyk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# owncloud_caldav Ruby CalDAV library
|
2
|
+
|
3
|
+
** owncloud_caldav is a CalDAV library based on agilastic/agcaldav **
|
4
|
+
|
5
|
+
##Usage Events
|
6
|
+
|
7
|
+
First, you've to install the gem
|
8
|
+
|
9
|
+
gem install owncloud_caldav
|
10
|
+
|
11
|
+
and require it
|
12
|
+
|
13
|
+
require "owncloud_caldav"
|
14
|
+
|
15
|
+
Next you have to obtain the URI, username and password to a CalDAV-Server.
|
16
|
+
|
17
|
+
|
18
|
+
Now you can e.g. create a new connection:
|
19
|
+
|
20
|
+
cal = OwncloudCalDAV::Client.new(:uri => "http://localhost:5232/user/calendar", :user => "user" , :password => "")
|
21
|
+
|
22
|
+
Alternatively, the proxy parameters can be specified:
|
23
|
+
|
24
|
+
cal = OwncloudCalDAV::Client.new(:uri => "http://localhost:5232/user/calendar",:user => "user" , :password => "password", :proxy_uri => "http://my-proxy.com:8080")
|
25
|
+
|
26
|
+
|
27
|
+
####Create an Event
|
28
|
+
|
29
|
+
result = cal.create_event(:start => "2012-12-29 10:00", :end => "2012-12-30 12:00", :title => "12345", :description => "12345 12345")
|
30
|
+
|
31
|
+
|
32
|
+
####Find Events within time interval
|
33
|
+
|
34
|
+
result = cal.find_events(:start => "2012-10-01 08:00", :end => "2013-01-01")
|
35
|
+
|
36
|
+
|
37
|
+
##Licence
|
38
|
+
|
39
|
+
MIT
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
##Contributors
|
44
|
+
|
45
|
+
|
46
|
+
1. Fork it.
|
47
|
+
2. Create a branch (`git checkout -b my_feature_branch`)
|
48
|
+
3. Commit your changes (`git commit -am "bugfixed abc..."`)
|
49
|
+
4. Push to the branch (`git push origin my_feature_branch`)
|
50
|
+
5. Open a [Pull Request][1]
|
51
|
+
6. Enjoy a refreshing Club Mate and wait
|
52
|
+
|
53
|
+
[1]: https://github.com/czytom/owncloud_caldav/pulls/
|
54
|
+
|
@@ -0,0 +1,225 @@
|
|
1
|
+
module OwncloudCalDAV
|
2
|
+
class Client
|
3
|
+
include Icalendar
|
4
|
+
attr_accessor :host, :port, :url, :user, :password, :ssl
|
5
|
+
|
6
|
+
def format=( fmt )
|
7
|
+
@format = fmt
|
8
|
+
end
|
9
|
+
|
10
|
+
def format
|
11
|
+
@format ||= Format::Debug.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize( data )
|
15
|
+
unless data[:proxy_uri].nil?
|
16
|
+
proxy_uri = URI(data[:proxy_uri])
|
17
|
+
@proxy_host = proxy_uri.host
|
18
|
+
@proxy_port = proxy_uri.port.to_i
|
19
|
+
end
|
20
|
+
uri = URI(data[:uri])
|
21
|
+
@host = uri.host
|
22
|
+
@port = uri.port.to_i
|
23
|
+
@url = uri.path
|
24
|
+
@user = data[:user]
|
25
|
+
@password = data[:password]
|
26
|
+
@ssl = uri.scheme == 'https'
|
27
|
+
end
|
28
|
+
|
29
|
+
def __create_http
|
30
|
+
if @proxy_uri.nil?
|
31
|
+
http = Net::HTTP.new(@host, @port)
|
32
|
+
else
|
33
|
+
http = Net::HTTP.new(@host, @port, @proxy_host, @proxy_port)
|
34
|
+
end
|
35
|
+
if @ssl
|
36
|
+
http.use_ssl = @ssl
|
37
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
38
|
+
end
|
39
|
+
http
|
40
|
+
end
|
41
|
+
|
42
|
+
def find_events data
|
43
|
+
result = ""
|
44
|
+
events = []
|
45
|
+
res = nil
|
46
|
+
__create_http.start do |http|
|
47
|
+
req = Net::HTTP::Report.new(@url, initheader = {'Content-Type'=>'application/xml', 'depth' => '1'} )
|
48
|
+
req.basic_auth @user, @password
|
49
|
+
req.body = OwncloudCalDAV::Request::ReportVEVENT.new(DateTime.parse(data[:start]).strftime("%Y%m%dT%H%M%S"), DateTime.parse(data[:end]).strftime("%Y%m%dT%H%M%S")).to_xml
|
50
|
+
res = http.request(req)
|
51
|
+
end
|
52
|
+
errorhandling res
|
53
|
+
result = ""
|
54
|
+
xml = REXML::Document.new(res.body)
|
55
|
+
REXML::XPath.each( xml, '//d:response/') do |c|
|
56
|
+
event = Icalendar.parse(c.elements['//cal:calendar-data'].text).first.events.first
|
57
|
+
uid = c.elements['d:href'].text.split('/').last.split('.').first
|
58
|
+
event.uid = uid
|
59
|
+
events << event
|
60
|
+
end
|
61
|
+
return events
|
62
|
+
end
|
63
|
+
|
64
|
+
def find_event uuid
|
65
|
+
res = nil
|
66
|
+
__create_http.start {|http|
|
67
|
+
req = Net::HTTP::Get.new("#{@url}/#{uuid}.ics")
|
68
|
+
req.basic_auth @user, @password
|
69
|
+
res = http.request( req )
|
70
|
+
}
|
71
|
+
errorhandling res
|
72
|
+
r = Icalendar.parse(res.body)
|
73
|
+
unless r.empty?
|
74
|
+
r.first.events.first
|
75
|
+
else
|
76
|
+
return false
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def delete_event uuid
|
83
|
+
res = nil
|
84
|
+
__create_http.start {|http|
|
85
|
+
req = Net::HTTP::Delete.new("#{@url}/#{uuid}.ics")
|
86
|
+
req.basic_auth @user, @password
|
87
|
+
res = http.request( req )
|
88
|
+
}
|
89
|
+
errorhandling res
|
90
|
+
if res.code.to_i == 200
|
91
|
+
return true
|
92
|
+
else
|
93
|
+
return false
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def create_event event
|
98
|
+
c = Calendar.new
|
99
|
+
uuid = UUID.new.generate
|
100
|
+
raise DuplicateError if entry_with_uuid_exists?(uuid)
|
101
|
+
c.event do |e|
|
102
|
+
e.uid = uuid
|
103
|
+
e.dtstart = DateTime.parse(event[:start])
|
104
|
+
e.dtend = DateTime.parse(event[:end])
|
105
|
+
e.categories = event[:categories]# Array
|
106
|
+
e.duration = event[:duration]
|
107
|
+
e.summary = event[:title]
|
108
|
+
e.description = event[:description]
|
109
|
+
e.status = event[:status]
|
110
|
+
end
|
111
|
+
cstring = c.to_ical
|
112
|
+
res = nil
|
113
|
+
http = Net::HTTP.new(@host, @port)
|
114
|
+
__create_http.start { |http|
|
115
|
+
req = Net::HTTP::Put.new("#{@url}/#{uuid}.ics")
|
116
|
+
req['Content-Type'] = 'text/calendar'
|
117
|
+
req.basic_auth @user, @password
|
118
|
+
req.body = cstring
|
119
|
+
res = http.request( req )
|
120
|
+
}
|
121
|
+
errorhandling res
|
122
|
+
find_event uuid
|
123
|
+
end
|
124
|
+
|
125
|
+
def update_event event
|
126
|
+
#TODO... fix me
|
127
|
+
if delete_event event[:uid]
|
128
|
+
create_event event
|
129
|
+
else
|
130
|
+
return false
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_alarm tevent, altCal="Calendar"
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
def find_todo uuid
|
139
|
+
res = nil
|
140
|
+
__create_http.start {|http|
|
141
|
+
req = Net::HTTP::Get.new("#{@url}/#{uuid}.ics")
|
142
|
+
req.basic_auth @user, @password
|
143
|
+
res = http.request( req )
|
144
|
+
}
|
145
|
+
errorhandling res
|
146
|
+
r = Icalendar.parse(res.body)
|
147
|
+
r.first.todos.first
|
148
|
+
end
|
149
|
+
|
150
|
+
def create_todo todo
|
151
|
+
c = Calendar.new
|
152
|
+
uuid = UUID.new.generate
|
153
|
+
raise DuplicateError if entry_with_uuid_exists?(uuid)
|
154
|
+
c.todo do
|
155
|
+
uid uuid
|
156
|
+
start DateTime.parse(todo[:start])
|
157
|
+
duration todo[:duration]
|
158
|
+
summary todo[:title]
|
159
|
+
description todo[:description]
|
160
|
+
klass todo[:accessibility] #PUBLIC, PRIVATE, CONFIDENTIAL
|
161
|
+
location todo[:location]
|
162
|
+
percent todo[:percent]
|
163
|
+
priority todo[:priority]
|
164
|
+
url todo[:url]
|
165
|
+
geo todo[:geo_location]
|
166
|
+
status todo[:status]
|
167
|
+
end
|
168
|
+
c.todo.uid = uuid
|
169
|
+
cstring = c.to_ical
|
170
|
+
res = nil
|
171
|
+
http = Net::HTTP.new(@host, @port)
|
172
|
+
__create_http.start { |http|
|
173
|
+
req = Net::HTTP::Put.new("#{@url}/#{uuid}.ics")
|
174
|
+
req['Content-Type'] = 'text/calendar'
|
175
|
+
req.basic_auth @user, @password
|
176
|
+
req.body = cstring
|
177
|
+
res = http.request( req )
|
178
|
+
}
|
179
|
+
errorhandling res
|
180
|
+
find_todo uuid
|
181
|
+
end
|
182
|
+
|
183
|
+
def create_todo
|
184
|
+
res = nil
|
185
|
+
raise DuplicateError if entry_with_uuid_exists?(uuid)
|
186
|
+
|
187
|
+
__create_http.start {|http|
|
188
|
+
req = Net::HTTP::Report.new(@url, initheader = {'Content-Type'=>'application/xml'} )
|
189
|
+
req.basic_auth @user, @password
|
190
|
+
req.body = OwncloudCalDAV::Request::ReportVTODO.new.to_xml
|
191
|
+
res = http.request( req )
|
192
|
+
}
|
193
|
+
errorhandling res
|
194
|
+
format.parse_todo( res.body )
|
195
|
+
end
|
196
|
+
|
197
|
+
private
|
198
|
+
def entry_with_uuid_exists? uuid
|
199
|
+
res = nil
|
200
|
+
__create_http.start {|http|
|
201
|
+
req = Net::HTTP::Get.new("#{@url}/#{uuid}.ics")
|
202
|
+
req.basic_auth @user, @password
|
203
|
+
res = http.request( req )
|
204
|
+
}
|
205
|
+
if res.code.to_i == 404
|
206
|
+
return false
|
207
|
+
else
|
208
|
+
return true
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def errorhandling response
|
213
|
+
raise AuthenticationError if response.code.to_i == 401
|
214
|
+
raise NotExistError if response.code.to_i == 410
|
215
|
+
raise APIError if response.code.to_i >= 500
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
class OwncloudCalDAVError < StandardError
|
220
|
+
end
|
221
|
+
class AuthenticationError < OwncloudCalDAVError; end
|
222
|
+
class DuplicateError < OwncloudCalDAVError; end
|
223
|
+
class APIError < OwncloudCalDAVError; end
|
224
|
+
class NotExistError < OwncloudCalDAVError; end
|
225
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module OwncloudCalDAV
|
2
|
+
module Filter
|
3
|
+
class Base
|
4
|
+
attr_accessor :parent, :child
|
5
|
+
|
6
|
+
def to_xml(xml = Builder::XmlMarkup.new(:indent => 2))
|
7
|
+
if parent
|
8
|
+
parent.to_xml
|
9
|
+
else
|
10
|
+
build_xml(xml)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_xml(xml)
|
15
|
+
#do nothing
|
16
|
+
end
|
17
|
+
|
18
|
+
def child=(child)
|
19
|
+
@child = child
|
20
|
+
child.parent = self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Component < Base
|
25
|
+
attr_accessor :name
|
26
|
+
|
27
|
+
def initialize(name, parent = nil)
|
28
|
+
self.name = name
|
29
|
+
self.parent = parent
|
30
|
+
end
|
31
|
+
|
32
|
+
def time_range(range)
|
33
|
+
self.child = TimeRange.new(range, self)
|
34
|
+
end
|
35
|
+
|
36
|
+
def uid(uid)
|
37
|
+
self.child = Property.new("UID", uid, self)
|
38
|
+
end
|
39
|
+
|
40
|
+
def build_xml(xml)
|
41
|
+
xml.tag! "cal:comp-filter", :name => name do
|
42
|
+
child.build_xml(xml) unless child.nil?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class TimeRange < Base
|
48
|
+
attr_accessor :range
|
49
|
+
|
50
|
+
def initialize(range, parent = nil)
|
51
|
+
self.range = range
|
52
|
+
self.parent = parent
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_xml(xml)
|
56
|
+
xml.tag! "cal:time-range",
|
57
|
+
:start => range.begin.to_ical,
|
58
|
+
:end => range.end.to_ical
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Property < Base
|
63
|
+
attr_accessor :name, :text
|
64
|
+
|
65
|
+
def initialize(name, text, parent = nil)
|
66
|
+
self.name = name
|
67
|
+
self.text = text
|
68
|
+
self.parent = parent
|
69
|
+
end
|
70
|
+
|
71
|
+
def build_xml(xml)
|
72
|
+
xml.tag! "cal:prop-filter", :name => self.name do
|
73
|
+
xml.tag! "cal:text-match", self.text, :collation => "i;octet"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module OwncloudCalDAV
|
2
|
+
module Format
|
3
|
+
class Raw
|
4
|
+
def method_missing(m, *args, &block)
|
5
|
+
return *args
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Debug < Raw
|
10
|
+
end
|
11
|
+
|
12
|
+
class Pretty < Raw
|
13
|
+
def parse_calendar(s)
|
14
|
+
result = ""
|
15
|
+
xml = REXML::Document.new(s)
|
16
|
+
|
17
|
+
REXML::XPath.each( xml, '//c:calendar-data/', {"c"=>"urn:ietf:params:xml:ns:caldav"} ){|c| result << c.text}
|
18
|
+
r = Icalendar.parse(result)
|
19
|
+
r
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse_todo( body )
|
23
|
+
result = []
|
24
|
+
xml = REXML::Document.new( body )
|
25
|
+
REXML::XPath.each( xml, '//c:calendar-data/', { "c"=>"urn:ietf:params:xml:ns:caldav"} ){ |c|
|
26
|
+
p c.text
|
27
|
+
p parse_tasks( c.text )
|
28
|
+
result += parse_tasks( c.text )
|
29
|
+
}
|
30
|
+
return result
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_tasks( vcal )
|
34
|
+
return_tasks = Array.new
|
35
|
+
cals = Icalendar.parse(vcal)
|
36
|
+
cals.each { |tcal|
|
37
|
+
tcal.todos.each { |ttask| # FIXME
|
38
|
+
return_tasks << ttask
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return return_tasks
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse_events( vcal )
|
45
|
+
Icalendar.parse(vcal)
|
46
|
+
end
|
47
|
+
|
48
|
+
def parse_single( body )
|
49
|
+
# FIXME: parse event/todo/vcard
|
50
|
+
parse_events( body )
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Net
|
2
|
+
class HTTP
|
3
|
+
class Report < HTTPRequest
|
4
|
+
METHOD = 'REPORT'
|
5
|
+
REQUEST_HAS_BODY = true
|
6
|
+
RESPONSE_HAS_BODY = true
|
7
|
+
end
|
8
|
+
|
9
|
+
class Mkcalendar < HTTPRequest
|
10
|
+
METHOD = 'MKCALENDAR'
|
11
|
+
REQUEST_HAS_BODY = true
|
12
|
+
RESPONSE_HAS_BODY = true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module OwncloudCalDAV
|
2
|
+
class Query
|
3
|
+
attr_accessor :child
|
4
|
+
|
5
|
+
#TODO: raise error if to_xml is called before child is assigned
|
6
|
+
def to_xml(xml = Builder::XmlMarkup.new(:indent => 2))
|
7
|
+
xml.instruct!
|
8
|
+
xml.tag! "cal:calendar-query", OwncloudCalDAV::NAMESPACES do
|
9
|
+
xml.tag! "dav:prop" do
|
10
|
+
xml.tag! "dav:getetag"
|
11
|
+
xml.tag! "cal:calendar-data"
|
12
|
+
end
|
13
|
+
xml.tag! "cal:filter" do
|
14
|
+
cal = Filter::Component.new("VCALENDAR", self)
|
15
|
+
cal.child = self.child
|
16
|
+
cal.build_xml(xml)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def event(param = nil)
|
22
|
+
self.child = Filter::Component.new("VEVENT")
|
23
|
+
if param.is_a? Range
|
24
|
+
self.child.time_range(param)
|
25
|
+
elsif param.is_a? String
|
26
|
+
self.child.uid(param)
|
27
|
+
else
|
28
|
+
self.child
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def todo(param = nil)
|
33
|
+
self.child = Filter::Component.new("VTODO")
|
34
|
+
self.child
|
35
|
+
end
|
36
|
+
|
37
|
+
def child=(child)
|
38
|
+
child.parent = self
|
39
|
+
@child = child
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.event( param=nil )
|
43
|
+
self.new.event( param )
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def self.todo( param=nil )
|
48
|
+
self.new.todo
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'builder'
|
2
|
+
|
3
|
+
module OwncloudCalDAV
|
4
|
+
NAMESPACES = { "xmlns:d" => 'DAV:', "xmlns:c" => "urn:ietf:params:xml:ns:caldav" }
|
5
|
+
module Request
|
6
|
+
class Base
|
7
|
+
def initialize
|
8
|
+
@xml = Builder::XmlMarkup.new(:indent => 2)
|
9
|
+
@xml.instruct!
|
10
|
+
end
|
11
|
+
attr :xml
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mkcalendar < Base
|
15
|
+
attr_accessor :displayname, :description
|
16
|
+
|
17
|
+
def initialize(displayname = nil, description = nil)
|
18
|
+
@displayname = displayname
|
19
|
+
@description = description
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_xml
|
23
|
+
xml.c :mkcalendar, NAMESPACES do
|
24
|
+
xml.d :set do
|
25
|
+
xml.d :prop do
|
26
|
+
xml.d :displayname, displayname unless displayname.to_s.empty?
|
27
|
+
xml.tag! "c:calendar-description", description, "xml:lang" => "en" unless description.to_s.empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class ReportVEVENT < Base
|
35
|
+
attr_accessor :tstart, :tend
|
36
|
+
|
37
|
+
def initialize( tstart=nil, tend=nil )
|
38
|
+
@tstart = tstart
|
39
|
+
@tend = tend
|
40
|
+
super()
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_xml
|
44
|
+
xml.c 'calendar-query'.intern, NAMESPACES do
|
45
|
+
xml.d :prop do
|
46
|
+
xml.d :getetag
|
47
|
+
xml.c 'calendar-data'.intern
|
48
|
+
end
|
49
|
+
xml.c :filter do
|
50
|
+
xml.c 'comp-filter'.intern, :name=> 'VCALENDAR' do
|
51
|
+
xml.c 'comp-filter'.intern, :name=> 'VEVENT' do
|
52
|
+
xml.c 'time-range'.intern, :start=> "#{tstart}Z", :end=> "#{tend}Z"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class ReportVTODO < Base
|
61
|
+
def to_xml
|
62
|
+
xml.c 'calendar-query'.intern, NAMESPACES do
|
63
|
+
xml.d :prop do
|
64
|
+
xml.d :getetag
|
65
|
+
xml.c 'calendar-data'.intern
|
66
|
+
end
|
67
|
+
xml.c :filter do
|
68
|
+
xml.c 'comp-filter'.intern, :name=> 'VCALENDAR' do
|
69
|
+
xml.c 'comp-filter'.intern, :name=> 'VTODO'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'uuid'
|
3
|
+
require 'rexml/document'
|
4
|
+
require 'rexml/xpath'
|
5
|
+
require 'time'
|
6
|
+
require 'date'
|
7
|
+
require 'active_support'
|
8
|
+
require 'icalendar'
|
9
|
+
|
10
|
+
#['client.rb', 'request.rb', 'net.rb', 'query.rb', 'filter.rb', 'event.rb', 'todo.rb', 'format.rb'].each do |f|
|
11
|
+
['client.rb', 'request.rb', 'net.rb', 'query.rb', 'filter.rb', 'format.rb'].each do |f|
|
12
|
+
require File.join( File.dirname(__FILE__), 'owncloud_caldav', f )
|
13
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require File.expand_path('../lib/owncloud_caldav/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "owncloud_caldav"
|
7
|
+
s.version = OwncloudCalDAV::VERSION
|
8
|
+
s.summary = "Ruby Owncloud CalDAV client"
|
9
|
+
s.description = "yet another great Ruby client for CalDAV calendar and tasks."
|
10
|
+
|
11
|
+
s.required_ruby_version = '>= 1.9.2'
|
12
|
+
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.homepage = %q{https://github.com/agilastic/agcaldav}
|
16
|
+
s.authors = [%q{Krzysztof Tomczyk}]
|
17
|
+
s.email = [%q{czytom@gmail.com}]
|
18
|
+
s.add_runtime_dependency 'icalendar'
|
19
|
+
s.add_runtime_dependency 'uuid'
|
20
|
+
s.add_runtime_dependency 'builder'
|
21
|
+
s.add_runtime_dependency 'net-http-digest_auth'
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "fakeweb"
|
24
|
+
s.description = <<-DESC
|
25
|
+
owncloud_caldav is Ruby client for CalDAV calendar. It is based on the agcaldav gem.
|
26
|
+
DESC
|
27
|
+
s.post_install_message = <<-POSTINSTALL
|
28
|
+
Changelog: https://github.com/czytom/owncloud_caldav/blob/master/CHANGELOG.rdoc
|
29
|
+
Examples: https://github.com/czytom/owncloud_caldav
|
30
|
+
POSTINSTALL
|
31
|
+
|
32
|
+
|
33
|
+
s.files = `git ls-files`.split("\n")
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: owncloud_caldav
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Krzysztof Tomczyk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: icalendar
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: uuid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: builder
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-http-digest_auth
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fakeweb
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: " owncloud_caldav is Ruby client for CalDAV calendar. It is based on
|
98
|
+
the agcaldav gem.\n"
|
99
|
+
email:
|
100
|
+
- czytom@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- LICENSE
|
107
|
+
- README.md
|
108
|
+
- lib/owncloud_caldav.rb
|
109
|
+
- lib/owncloud_caldav/client.rb
|
110
|
+
- lib/owncloud_caldav/filter.rb
|
111
|
+
- lib/owncloud_caldav/format.rb
|
112
|
+
- lib/owncloud_caldav/net.rb
|
113
|
+
- lib/owncloud_caldav/query.rb
|
114
|
+
- lib/owncloud_caldav/request.rb
|
115
|
+
- lib/owncloud_caldav/version.rb
|
116
|
+
- owncloud_caldav.gemspec
|
117
|
+
homepage: https://github.com/agilastic/agcaldav
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message: |2
|
122
|
+
Changelog: https://github.com/czytom/owncloud_caldav/blob/master/CHANGELOG.rdoc
|
123
|
+
Examples: https://github.com/czytom/owncloud_caldav
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.9.2
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubygems_version: 3.0.3.1
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Ruby Owncloud CalDAV client
|
142
|
+
test_files: []
|