caldav.rb 0.0.0 → 0.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +24 -0
- data/README.md +7 -1
- data/caldav.rb.gemspec +1 -1
- data/lib/CalDAV/Resource.rb +24 -0
- data/lib/CalDAV/VERSION.rb +1 -1
- data/lib/{CalDAV.rb → caldav.rb} +2 -1
- data/test/CalDAV/MultiStatus_test.rb +61 -0
- data/test/CalDAV/Resource_test.rb +30 -0
- metadata +5 -4
- /data/test/{CalDAV_test.rb → caldav_test.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1bade6bf8d4171a511851eab788d9a4e0c6926ee1cfa8811ce61ba1a8b4e61ba
|
|
4
|
+
data.tar.gz: 428761e5e9978cab9cae7ae1e15a38cbec9dade3b3547b2be5168851abc46645
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f43dad1403215dc884edd5ad4cd54e7f5d1ef30f72926c949be39c30ddc141fde805b895f057533e6a7acd5b2a2fe822de29557f47971ba1e308b147650fa70
|
|
7
|
+
data.tar.gz: 96ce0a9f7c0894180276d7d33e22b4b5df287ddd1fdbfc9bdbfed589021cb14e650bc10d77a6ce33e46d0b9a84684363f4c21d63a5deb8cc87ca7b5a9b20c55c
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20260623
|
|
4
|
+
|
|
5
|
+
0.1.0: Complete the RFC 4791 §5.2 navigation surface.
|
|
6
|
+
|
|
7
|
+
1. + CalDAV::Resource#supported_calendar_data (§5.2.4)
|
|
8
|
+
2. + CalDAV::Resource#max_resource_size (§5.2.5)
|
|
9
|
+
3. + CalDAV::Resource#min_date_time (§5.2.6)
|
|
10
|
+
4. + CalDAV::Resource#max_date_time (§5.2.7)
|
|
11
|
+
5. + CalDAV::Resource#max_instances (§5.2.8)
|
|
12
|
+
6. + CalDAV::Resource#max_attendees_per_instance (§5.2.9)
|
|
13
|
+
7. + CalDAV::Resource unit tests for the six accessors. supported-calendar-data is an empty-element-with-attributes property, so it falls through MultiStatus#parse_properties to its serialised markup (like supported-calendar-component-set); the other five are plain text-valued. All return raw strings — no Integer/time coercion, which stays Layer 2's job.
|
|
14
|
+
8. ~ README navigation-accessor list.
|
|
15
|
+
9. ~ VERSION: /0.0.1/0.1.0/
|
|
16
|
+
|
|
17
|
+
## 20260621
|
|
18
|
+
|
|
19
|
+
0.0.1: Lowercase load file; require VERSION; MultiStatus tests.
|
|
20
|
+
|
|
21
|
+
1. /CalDAV.rb/caldav.rb/
|
|
22
|
+
2. ~ lib/caldav.rb: + require_relative './CalDAV/VERSION'
|
|
23
|
+
3. ~ caldav.rb.gemspec description
|
|
24
|
+
4. + CalDAV::MultiStatus unit test, covering the two overrides over WebDAV::MultiStatus: parse_response (wraps each response as a CalDAV::Resource, in order) and parse_properties (a pretty-printed nested property is kept as serialised markup rather than collapsing to inter-tag whitespace).
|
|
25
|
+
5. ~ VERSION: /0.0.0/0.0.1/
|
|
26
|
+
|
|
3
27
|
## 20260620
|
|
4
28
|
|
|
5
29
|
0.0.0: Initial release.
|
data/README.md
CHANGED
|
@@ -28,7 +28,7 @@ caldav.rb is designed in three layers, each a strict superset of the one below.
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
30
|
```ruby
|
|
31
|
-
require 'caldav'
|
|
31
|
+
require 'caldav.rb'
|
|
32
32
|
|
|
33
33
|
caldav = CalDAV.new('https://caldav.example.com/dav/', username: 'user', password: 'pass')
|
|
34
34
|
```
|
|
@@ -99,7 +99,13 @@ The REPORT verbs return `CalDAV::MultiStatus`, a type-preserving subclass of `We
|
|
|
99
99
|
- `calendar_data` — the iCalendar string from `<c:calendar-data>`
|
|
100
100
|
- `calendar_description` — `<c:calendar-description>`
|
|
101
101
|
- `supported_calendar_component_set` — `<c:supported-calendar-component-set>`
|
|
102
|
+
- `supported_calendar_data` — `<c:supported-calendar-data>`
|
|
102
103
|
- `calendar_timezone` — the VTIMEZONE string from `<c:calendar-timezone>`
|
|
104
|
+
- `max_resource_size` — `<c:max-resource-size>`
|
|
105
|
+
- `min_date_time` — `<c:min-date-time>`
|
|
106
|
+
- `max_date_time` — `<c:max-date-time>`
|
|
107
|
+
- `max_instances` — `<c:max-instances>`
|
|
108
|
+
- `max_attendees_per_instance` — `<c:max-attendees-per-instance>`
|
|
103
109
|
- `is_calendar?` — true when `<d:resourcetype>` includes `<c:calendar/>`
|
|
104
110
|
|
|
105
111
|
These are strictly navigation: they return raw strings and values, never parsed iCalendar objects. Parsing is Layer 2's job.
|
data/caldav.rb.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
spec.version = CalDAV::VERSION
|
|
16
16
|
|
|
17
17
|
spec.summary = "A Ruby CalDAV client library."
|
|
18
|
-
spec.description = "A Ruby CalDAV client library
|
|
18
|
+
spec.description = "A Ruby CalDAV client library (RFC 4791)."
|
|
19
19
|
|
|
20
20
|
spec.author = 'thoran'
|
|
21
21
|
spec.email = 'code@thoran.com'
|
data/lib/CalDAV/Resource.rb
CHANGED
|
@@ -34,10 +34,34 @@ class CalDAV < WebDAV
|
|
|
34
34
|
property(NAMESPACE, 'supported-calendar-component-set')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def supported_calendar_data
|
|
38
|
+
property(NAMESPACE, 'supported-calendar-data')
|
|
39
|
+
end
|
|
40
|
+
|
|
37
41
|
def calendar_timezone
|
|
38
42
|
property(NAMESPACE, 'calendar-timezone')
|
|
39
43
|
end
|
|
40
44
|
|
|
45
|
+
def max_resource_size
|
|
46
|
+
property(NAMESPACE, 'max-resource-size')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def min_date_time
|
|
50
|
+
property(NAMESPACE, 'min-date-time')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def max_date_time
|
|
54
|
+
property(NAMESPACE, 'max-date-time')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def max_instances
|
|
58
|
+
property(NAMESPACE, 'max-instances')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def max_attendees_per_instance
|
|
62
|
+
property(NAMESPACE, 'max-attendees-per-instance')
|
|
63
|
+
end
|
|
64
|
+
|
|
41
65
|
# Matches a <calendar> element (under any namespace prefix) in the serialised
|
|
42
66
|
# resourcetype, rather than a bare 'calendar' substring: the substring also
|
|
43
67
|
# matches calendar-proxy-read/write collections, which are not calendars.
|
data/lib/CalDAV/VERSION.rb
CHANGED
data/lib/{CalDAV.rb → caldav.rb}
RENAMED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# test/CalDAV/MultiStatus_test.rb
|
|
2
|
+
|
|
3
|
+
require_relative '../helper'
|
|
4
|
+
|
|
5
|
+
describe CalDAV::MultiStatus do
|
|
6
|
+
let(:body) do
|
|
7
|
+
<<~XML
|
|
8
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
9
|
+
<d:multistatus xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
|
|
10
|
+
<d:response>
|
|
11
|
+
<d:href>/calendars/user/work/</d:href>
|
|
12
|
+
<d:propstat>
|
|
13
|
+
<d:prop>
|
|
14
|
+
<d:resourcetype>
|
|
15
|
+
<d:collection/>
|
|
16
|
+
<c:calendar/>
|
|
17
|
+
</d:resourcetype>
|
|
18
|
+
<c:calendar-description>Work calendar</c:calendar-description>
|
|
19
|
+
</d:prop>
|
|
20
|
+
<d:status>HTTP/1.1 200 OK</d:status>
|
|
21
|
+
</d:propstat>
|
|
22
|
+
</d:response>
|
|
23
|
+
<d:response>
|
|
24
|
+
<d:href>/calendars/user/home/</d:href>
|
|
25
|
+
<d:propstat>
|
|
26
|
+
<d:prop>
|
|
27
|
+
<d:resourcetype>
|
|
28
|
+
<d:collection/>
|
|
29
|
+
<c:calendar/>
|
|
30
|
+
</d:resourcetype>
|
|
31
|
+
</d:prop>
|
|
32
|
+
<d:status>HTTP/1.1 200 OK</d:status>
|
|
33
|
+
</d:propstat>
|
|
34
|
+
</d:response>
|
|
35
|
+
</d:multistatus>
|
|
36
|
+
XML
|
|
37
|
+
end
|
|
38
|
+
let(:multistatus){CalDAV::MultiStatus.new(MockResponse.new(code: '207', message: 'Multi-Status', body: body))}
|
|
39
|
+
let(:work){multistatus.resources[0]}
|
|
40
|
+
let(:work_properties){work.propstats.first[:properties]}
|
|
41
|
+
|
|
42
|
+
it "parses one resource per response element" do
|
|
43
|
+
_(multistatus.resources.size).must_equal 2
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "wraps every response as a CalDAV::Resource" do
|
|
47
|
+
_(multistatus.resources.map(&:class).uniq).must_equal [CalDAV::Resource]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "preserves response order" do
|
|
51
|
+
_(multistatus.resources.collect(&:href)).must_equal ['/calendars/user/work/', '/calendars/user/home/']
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "keeps a pretty-printed nested property as serialised markup, not whitespace" do
|
|
55
|
+
_(work_properties[CalDAV::DAV_NAMESPACE]['resourcetype']).must_match(%r{<(?:\w+:)?calendar})
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "keeps a flat property's text" do
|
|
59
|
+
_(work_properties[CalDAV::NAMESPACE]['calendar-description']).must_equal 'Work calendar'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -13,6 +13,12 @@ describe CalDAV::Resource do
|
|
|
13
13
|
<d:prop>
|
|
14
14
|
<d:resourcetype><d:collection/><c:calendar/></d:resourcetype>
|
|
15
15
|
<c:calendar-description>Work calendar</c:calendar-description>
|
|
16
|
+
<c:supported-calendar-data><c:calendar-data content-type="text/calendar" version="2.0"/></c:supported-calendar-data>
|
|
17
|
+
<c:max-resource-size>10485760</c:max-resource-size>
|
|
18
|
+
<c:min-date-time>19000101T000000Z</c:min-date-time>
|
|
19
|
+
<c:max-date-time>20491231T235959Z</c:max-date-time>
|
|
20
|
+
<c:max-instances>100</c:max-instances>
|
|
21
|
+
<c:max-attendees-per-instance>25</c:max-attendees-per-instance>
|
|
16
22
|
</d:prop>
|
|
17
23
|
<d:status>HTTP/1.1 200 OK</d:status>
|
|
18
24
|
</d:propstat>
|
|
@@ -61,6 +67,30 @@ describe CalDAV::Resource do
|
|
|
61
67
|
_(event_resource.calendar_data).must_equal 'BEGIN:VCALENDAR'
|
|
62
68
|
end
|
|
63
69
|
|
|
70
|
+
it "reads supported-calendar-data as serialised markup" do
|
|
71
|
+
_(calendar_resource.supported_calendar_data).must_match %r{<(?:\w+:)?calendar-data\b[^>]*content-type=['"]text/calendar['"][^>]*version=['"]2\.0['"]}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "reads max-resource-size" do
|
|
75
|
+
_(calendar_resource.max_resource_size).must_equal '10485760'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "reads min-date-time" do
|
|
79
|
+
_(calendar_resource.min_date_time).must_equal '19000101T000000Z'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "reads max-date-time" do
|
|
83
|
+
_(calendar_resource.max_date_time).must_equal '20491231T235959Z'
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "reads max-instances" do
|
|
87
|
+
_(calendar_resource.max_instances).must_equal '100'
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "reads max-attendees-per-instance" do
|
|
91
|
+
_(calendar_resource.max_attendees_per_instance).must_equal '25'
|
|
92
|
+
end
|
|
93
|
+
|
|
64
94
|
it "identifies a calendar collection" do
|
|
65
95
|
_(calendar_resource.is_calendar?).must_equal true
|
|
66
96
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: caldav.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -93,7 +93,7 @@ dependencies:
|
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '3.0'
|
|
96
|
-
description: A Ruby CalDAV client library
|
|
96
|
+
description: A Ruby CalDAV client library (RFC 4791).
|
|
97
97
|
email: code@thoran.com
|
|
98
98
|
executables: []
|
|
99
99
|
extensions: []
|
|
@@ -105,14 +105,15 @@ files:
|
|
|
105
105
|
- README.md
|
|
106
106
|
- Rakefile
|
|
107
107
|
- caldav.rb.gemspec
|
|
108
|
-
- lib/CalDAV.rb
|
|
109
108
|
- lib/CalDAV/MultiStatus.rb
|
|
110
109
|
- lib/CalDAV/Resource.rb
|
|
111
110
|
- lib/CalDAV/VERSION.rb
|
|
112
111
|
- lib/Net/HTTP/Mkcalendar.rb
|
|
112
|
+
- lib/caldav.rb
|
|
113
|
+
- test/CalDAV/MultiStatus_test.rb
|
|
113
114
|
- test/CalDAV/Resource_test.rb
|
|
114
|
-
- test/CalDAV_test.rb
|
|
115
115
|
- test/Net/HTTP/Mkcalendar_test.rb
|
|
116
|
+
- test/caldav_test.rb
|
|
116
117
|
- test/helper.rb
|
|
117
118
|
- test/integration_test.rb
|
|
118
119
|
- test/vcr_helper.rb
|
|
File without changes
|