calendav 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile +4 -0
- data/lib/calendav/client.rb +4 -3
- data/lib/calendav/clients/calendars_client.rb +1 -1
- data/lib/calendav/endpoint.rb +4 -2
- data/lib/calendav/event.rb +4 -0
- data/lib/calendav.rb +2 -2
- data/spec/acceptance/apple_spec.rb +6 -2
- data/spec/acceptance/google_spec.rb +3 -3
- data/spec/acceptance/radicale_spec.rb +1 -1
- data/spec/acceptance/shared.rb +7 -7
- data/spec/spec_helper.rb +1 -0
- data/spec/support/event_helpers.rb +1 -4
- data/spec/support/vcr.rb +26 -0
- metadata +62 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bae509ffc0254b00db9e4380a76278770a0868093ff69b597b6b10fcf9ecd01
|
4
|
+
data.tar.gz: 26cfe5ccbc19dba770cf2d255cbb36bc3529039903af8d28281536f70cb55c49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56fd5c731ad0d4b05d29a68df6624bad4809a6a146806c8190ba765b233e39598572711ff6f5f61a59df09a8d919090b45641bfbc2214a1ad746f4a7f5bf8662
|
7
|
+
data.tar.gz: fa897448f63e9c5a04f8c97acebb950d0213fbc8aa10eb8d4069aaaafbe9849148dafe526de9c78a6d947c4a43eaaa78260665dfd05d66b429c21d5e1caf5a7e
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/lib/calendav/client.rb
CHANGED
@@ -8,8 +8,9 @@ require_relative "./requests/current_user_principal"
|
|
8
8
|
|
9
9
|
module Calendav
|
10
10
|
class Client
|
11
|
-
def initialize(credentials)
|
11
|
+
def initialize(credentials, timeout: nil)
|
12
12
|
@credentials = credentials
|
13
|
+
@timeout = timeout
|
13
14
|
end
|
14
15
|
|
15
16
|
def calendars
|
@@ -34,10 +35,10 @@ module Calendav
|
|
34
35
|
|
35
36
|
private
|
36
37
|
|
37
|
-
attr_reader :credentials
|
38
|
+
attr_reader :credentials, :timeout
|
38
39
|
|
39
40
|
def endpoint
|
40
|
-
@endpoint ||= Endpoint.new(credentials)
|
41
|
+
@endpoint ||= Endpoint.new(credentials, timeout: timeout)
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
@@ -64,7 +64,7 @@ module Calendav
|
|
64
64
|
endpoint
|
65
65
|
.propfind(request.to_xml, url: url, depth: depth)
|
66
66
|
.select { |node| node.xpath(calendar_xpath).any? }
|
67
|
-
.collect { |node| Calendar.from_xml(
|
67
|
+
.collect { |node| Calendar.from_xml(url, node) }
|
68
68
|
end
|
69
69
|
|
70
70
|
def options
|
data/lib/calendav/endpoint.rb
CHANGED
@@ -11,8 +11,9 @@ module Calendav
|
|
11
11
|
xml: "application/xml; charset=utf-8"
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
def initialize(credentials)
|
14
|
+
def initialize(credentials, timeout: nil)
|
15
15
|
@credentials = credentials
|
16
|
+
@timeout = timeout
|
16
17
|
end
|
17
18
|
|
18
19
|
def delete(url:, etag: nil)
|
@@ -76,7 +77,7 @@ module Calendav
|
|
76
77
|
|
77
78
|
private
|
78
79
|
|
79
|
-
attr_reader :credentials
|
80
|
+
attr_reader :credentials, :timeout
|
80
81
|
|
81
82
|
def authenticated
|
82
83
|
case credentials.authentication
|
@@ -93,6 +94,7 @@ module Calendav
|
|
93
94
|
def with_headers(content_type: nil, depth: nil, etag: nil)
|
94
95
|
http = authenticated
|
95
96
|
|
97
|
+
http = http.timeout(timeout) if timeout
|
96
98
|
http = http.headers(depth: depth) if depth
|
97
99
|
http = http.headers("If-Match" => etag) if etag
|
98
100
|
if content_type
|
data/lib/calendav/event.rb
CHANGED
data/lib/calendav.rb
CHANGED
@@ -16,7 +16,7 @@ module Calendav
|
|
16
16
|
PROVIDERS.fetch(provider).new(username: username, password: password)
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.client(credentials)
|
20
|
-
Client.new(credentials)
|
19
|
+
def self.client(credentials, timeout: nil)
|
20
|
+
Client.new(credentials, timeout: timeout)
|
21
21
|
end
|
22
22
|
end
|
@@ -4,7 +4,7 @@ require "securerandom"
|
|
4
4
|
|
5
5
|
require_relative "./shared"
|
6
6
|
|
7
|
-
RSpec.describe "Apple" do
|
7
|
+
RSpec.describe "Apple", :vcr do
|
8
8
|
let(:provider) { :apple }
|
9
9
|
let(:username) { ENV.fetch("APPLE_USERNAME") }
|
10
10
|
let(:password) { ENV.fetch("APPLE_PASSWORD") }
|
@@ -27,10 +27,14 @@ RSpec.describe "Apple" do
|
|
27
27
|
|
28
28
|
context "with a calendar" do
|
29
29
|
let(:calendar_url) do
|
30
|
-
subject.calendars.create(
|
30
|
+
subject.calendars.create(@name, display_name: "Calendav Test")
|
31
31
|
end
|
32
32
|
let(:calendar) { subject.calendars.find(calendar_url) }
|
33
33
|
|
34
|
+
before :each do |example|
|
35
|
+
@name = Digest::MD5.hexdigest(example.metadata[:full_description])
|
36
|
+
end
|
37
|
+
|
34
38
|
after :each do
|
35
39
|
subject.calendars.delete(calendar.url)
|
36
40
|
end
|
@@ -8,7 +8,7 @@ require "uri"
|
|
8
8
|
|
9
9
|
require_relative "./shared"
|
10
10
|
|
11
|
-
RSpec.describe "Google" do
|
11
|
+
RSpec.describe "Google", :vcr do
|
12
12
|
let(:provider) { :google }
|
13
13
|
let(:username) { ENV.fetch("GOOGLE_USERNAME") }
|
14
14
|
let(:access_token) { @access_token }
|
@@ -17,7 +17,7 @@ RSpec.describe "Google" do
|
|
17
17
|
|
18
18
|
subject { Calendav.client(credentials) }
|
19
19
|
|
20
|
-
before :
|
20
|
+
before :each do
|
21
21
|
@google_auth = Google::Auth::UserRefreshCredentials.new(
|
22
22
|
client_id: ENV.fetch("GOOGLE_CLIENT_ID"),
|
23
23
|
scope: [],
|
@@ -84,7 +84,7 @@ RSpec.describe "Google" do
|
|
84
84
|
|
85
85
|
it "does not respect etag conditions for deletions" do
|
86
86
|
event_url = subject.events.create(
|
87
|
-
calendar.url,
|
87
|
+
calendar.url, "calendav-event.ics", ical_event("Brunch", 10, 30)
|
88
88
|
)
|
89
89
|
event = subject.events.find(event_url)
|
90
90
|
|
@@ -34,7 +34,7 @@ RSpec.describe "Radicale" do
|
|
34
34
|
|
35
35
|
context "with a calendar" do
|
36
36
|
let(:calendar_url) do
|
37
|
-
subject.calendars.create(
|
37
|
+
subject.calendars.create("calendav-test", display_name: "Calendav Test")
|
38
38
|
end
|
39
39
|
let(:calendar) { subject.calendars.find(calendar_url) }
|
40
40
|
|
data/spec/acceptance/shared.rb
CHANGED
@@ -11,7 +11,7 @@ RSpec.shared_examples "supporting calendar management" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can create, find, update and delete calendars" do
|
14
|
-
identifier =
|
14
|
+
identifier = "calendav-test"
|
15
15
|
time_zone = TZInfo::Timezone.get "UTC"
|
16
16
|
ical_time_zone = time_zone.ical_timezone Time.now.utc
|
17
17
|
|
@@ -51,7 +51,7 @@ RSpec.shared_examples "supporting event management" do
|
|
51
51
|
it "can create, find, update and delete events" do
|
52
52
|
# Create an event
|
53
53
|
event_url = subject.events.create(
|
54
|
-
calendar.url,
|
54
|
+
calendar.url, "calendav-event-1.ics", ical_event("Brunch", 10, 30)
|
55
55
|
)
|
56
56
|
expect(event_url).to include(URI.decode_www_form_component(calendar.url))
|
57
57
|
event = subject.events.find(event_url)
|
@@ -79,7 +79,7 @@ RSpec.shared_examples "supporting event management" do
|
|
79
79
|
|
80
80
|
# Create another event
|
81
81
|
another_url = subject.events.create(
|
82
|
-
calendar.url,
|
82
|
+
calendar.url, "calendav-event-2.ics", ical_event("Brunch", 10, 30)
|
83
83
|
)
|
84
84
|
|
85
85
|
# Search for all events
|
@@ -93,7 +93,7 @@ RSpec.shared_examples "supporting event management" do
|
|
93
93
|
|
94
94
|
it "respects etag conditions with updates" do
|
95
95
|
event_url = subject.events.create(
|
96
|
-
calendar.url,
|
96
|
+
calendar.url, "calendav-event.ics", ical_event("Brunch", 10, 30)
|
97
97
|
)
|
98
98
|
event = subject.events.find(event_url)
|
99
99
|
|
@@ -122,7 +122,7 @@ RSpec.shared_examples "supporting event management" do
|
|
122
122
|
|
123
123
|
it "handles synchronisation requests" do
|
124
124
|
first_url = subject.events.create(
|
125
|
-
calendar.url,
|
125
|
+
calendar.url, "calendav-event-1.ics", ical_event("Brunch", 10, 30)
|
126
126
|
)
|
127
127
|
first = subject.events.find(first_url)
|
128
128
|
token = subject.calendars.find(calendar.url, sync: true).sync_token
|
@@ -131,7 +131,7 @@ RSpec.shared_examples "supporting event management" do
|
|
131
131
|
expect(events.length).to eq(1)
|
132
132
|
|
133
133
|
second_url = subject.events.create(
|
134
|
-
calendar.url,
|
134
|
+
calendar.url, "calendav-event-2.ics", ical_event("Brunch Again", 11, 30)
|
135
135
|
)
|
136
136
|
|
137
137
|
subject.events.update(first_url, update_summary(first, "Coffee"))
|
@@ -163,7 +163,7 @@ end
|
|
163
163
|
RSpec.shared_examples "supporting event deletion with etags" do
|
164
164
|
it "respects etag conditions with deletions" do
|
165
165
|
event_url = subject.events.create(
|
166
|
-
calendar.url,
|
166
|
+
calendar.url, "calendav-event.ics", ical_event("Brunch", 10, 30)
|
167
167
|
)
|
168
168
|
event = subject.events.find(event_url)
|
169
169
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# require "active_support"
|
3
4
|
require "icalendar"
|
4
5
|
require "securerandom"
|
5
6
|
|
6
7
|
module EventHelpers
|
7
|
-
def event_identifier
|
8
|
-
"#{SecureRandom.uuid}.ics"
|
9
|
-
end
|
10
|
-
|
11
8
|
def ical_event(summary, hour, minute)
|
12
9
|
start = time_at(hour, minute)
|
13
10
|
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "timecop"
|
4
|
+
require "webmock/rspec"
|
5
|
+
require "vcr"
|
6
|
+
require "vcr_assistant/rspec"
|
7
|
+
|
8
|
+
VCR.configure do |config|
|
9
|
+
config.cassette_library_dir = File.expand_path(
|
10
|
+
File.join(__dir__, "../cassettes")
|
11
|
+
)
|
12
|
+
config.hook_into :webmock
|
13
|
+
config.ignore_hosts "127.0.0.1"
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.around(:each, :vcr) do |example|
|
18
|
+
assisted_cassette(example) do |_assistant|
|
19
|
+
Timecop.freeze(Time.gm(2022))
|
20
|
+
|
21
|
+
example.run
|
22
|
+
|
23
|
+
Timecop.return
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: timecop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: tzinfo
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +164,48 @@ dependencies:
|
|
150
164
|
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: vcr
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: vcr_assistant
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: webmock
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
153
209
|
description:
|
154
210
|
email:
|
155
211
|
- pat@freelancing-gods.com
|
@@ -199,6 +255,7 @@ files:
|
|
199
255
|
- spec/spec_helper.rb
|
200
256
|
- spec/support/encoded_matchers.rb
|
201
257
|
- spec/support/event_helpers.rb
|
258
|
+
- spec/support/vcr.rb
|
202
259
|
homepage: https://github.com/pat/calendav
|
203
260
|
licenses:
|
204
261
|
- Hippocratic-2.1
|
@@ -206,6 +263,7 @@ metadata:
|
|
206
263
|
homepage_uri: https://github.com/pat/calendav
|
207
264
|
source_code_uri: https://github.com/pat/calendav
|
208
265
|
changelog_uri: https://github.com/pat/calendav/blob/main/CHANGELOG.md
|
266
|
+
rubygems_mfa_required: 'true'
|
209
267
|
post_install_message:
|
210
268
|
rdoc_options: []
|
211
269
|
require_paths:
|
@@ -221,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
279
|
- !ruby/object:Gem::Version
|
222
280
|
version: '0'
|
223
281
|
requirements: []
|
224
|
-
rubygems_version: 3.2.
|
282
|
+
rubygems_version: 3.2.32
|
225
283
|
signing_key:
|
226
284
|
specification_version: 4
|
227
285
|
summary: CalDAV client
|
@@ -235,6 +293,7 @@ test_files:
|
|
235
293
|
- spec/spec_helper.rb
|
236
294
|
- spec/support/encoded_matchers.rb
|
237
295
|
- spec/support/event_helpers.rb
|
296
|
+
- spec/support/vcr.rb
|
238
297
|
- ".rspec"
|
239
298
|
- Gemfile
|
240
299
|
- Rakefile
|