async-caldav 1.2.4 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d7c0fb4e8401d178d2d34ed20d3b2581d03abe4faa7e91d1d7daca09a2b4747
4
- data.tar.gz: 854dab74930bc90b545748eb1ec4c7e5ddd8cbca0971d473e6df5d7c852fc2f8
3
+ metadata.gz: 971fb69146a93d8657e1c629d81ea95faf49749d0cecffaef4b05338d7cf44b2
4
+ data.tar.gz: bcfd995444a48137f9de0d7d1b1fa9e60f6a161bb8b84b0da8a30368d67ce1e1
5
5
  SHA512:
6
- metadata.gz: f6d336add0343d5ac74da5f26ad5d3c7c8ce13ad1c43e34358d84b2add094b3dfc67faa22a382924c24cb8849101a9254542a17c77c94122742357da9c131505
7
- data.tar.gz: f408de6047fd41a3980dd3fe15ffcb998b3a05159809ea74ca6ba50ffea6192f774a9e76d293160947bfd5ef289b633939b0e3cbec264609d6bd303dd74a5828
6
+ metadata.gz: b7b37b620996b985bbc5052dcfe3e9124bc0377dc924ccdae9e638de8cdda943eae064a39246294bb0e8e139daa410d68531057cf39dab0cc75482efeb4605a8
7
+ data.tar.gz: e023fd085b489d0d45ee3c8cdc3a5d8bfa4c068ee5a6129381f51a6994fdb980f4b4d0d935be01383ab99518fe56207759189724b9b4c48dc019ed0d86bf6162
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/setup"
4
- require "scampi"
5
3
  require "builder"
6
4
 
7
5
  module Async
@@ -21,20 +19,28 @@ module Async
21
19
  x.instruct! :xml, version: "1.0", encoding: "UTF-8"
22
20
  x.tag!("cr:addressbook-query", "xmlns:d" => "DAV:", "xmlns:cr" => "urn:ietf:params:xml:ns:carddav") do
23
21
  x.tag!("d:prop") { x.tag!("d:getetag"); x.tag!("cr:address-data") }
24
- x << filter if filter
22
+ if filter
23
+ x << filter
24
+ end
25
25
  end
26
26
  body = x.target!
27
27
 
28
28
  status, _, resp_body = @client.request('REPORT', @path, body: body, headers: { 'Content-Type' => 'text/xml' })
29
- raise Error, "REPORT failed: #{status}" unless status == 207
29
+ unless status == 207
30
+ raise Error, "REPORT failed: #{status}"
31
+ end
30
32
 
31
33
  @client.parse_multistatus_items(resp_body, data_tag: 'address-data')
32
34
  end
33
35
 
34
36
  def put_contact(filename, body, if_match: nil, if_none_match: nil)
35
37
  headers = { 'Content-Type' => 'text/vcard' }
36
- headers['If-Match'] = if_match if if_match
37
- headers['If-None-Match'] = if_none_match if if_none_match
38
+ if if_match
39
+ headers['If-Match'] = if_match
40
+ end
41
+ if if_none_match
42
+ headers['If-None-Match'] = if_none_match
43
+ end
38
44
 
39
45
  path = "#{@path}#{filename}"
40
46
  status, resp_headers, = @client.request('PUT', path, body: body, headers: headers)
@@ -92,15 +98,21 @@ module Async
92
98
  x.tag!("d:propertyupdate", "xmlns:d" => "DAV:") do
93
99
  x.tag!("d:set") do
94
100
  x.tag!("d:prop") do
95
- x.tag!("d:displayname", displayname) if displayname
101
+ if displayname
102
+ x.tag!("d:displayname", displayname)
103
+ end
96
104
  end
97
105
  end
98
106
  end
99
107
 
100
108
  status, = @client.request('PROPPATCH', @path, body: x.target!, headers: { 'Content-Type' => 'text/xml' })
101
- raise Error, "PROPPATCH failed: #{status}" unless status == 207
109
+ unless status == 207
110
+ raise Error, "PROPPATCH failed: #{status}"
111
+ end
102
112
 
103
- @displayname = displayname if displayname
113
+ if displayname
114
+ @displayname = displayname
115
+ end
104
116
  self
105
117
  end
106
118
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/setup"
4
- require "scampi"
5
3
  require "builder"
6
4
 
7
5
  module Async
@@ -24,20 +22,28 @@ module Async
24
22
  x.instruct! :xml, version: "1.0", encoding: "UTF-8"
25
23
  x.tag!("c:calendar-query", "xmlns:d" => "DAV:", "xmlns:c" => "urn:ietf:params:xml:ns:caldav") do
26
24
  x.tag!("d:prop") { x.tag!("d:getetag"); x.tag!("c:calendar-data") }
27
- x << filter if filter
25
+ if filter
26
+ x << filter
27
+ end
28
28
  end
29
29
  body = x.target!
30
30
 
31
31
  status, _, resp_body = @client.request('REPORT', @path, body: body, headers: { 'Content-Type' => 'text/xml' })
32
- raise Error, "REPORT failed: #{status}" unless status == 207
32
+ unless status == 207
33
+ raise Error, "REPORT failed: #{status}"
34
+ end
33
35
 
34
36
  @client.parse_multistatus_items(resp_body, data_tag: 'calendar-data')
35
37
  end
36
38
 
37
39
  def put_event(filename, body, if_match: nil, if_none_match: nil)
38
40
  headers = { 'Content-Type' => 'text/calendar' }
39
- headers['If-Match'] = if_match if if_match
40
- headers['If-None-Match'] = if_none_match if if_none_match
41
+ if if_match
42
+ headers['If-Match'] = if_match
43
+ end
44
+ if if_none_match
45
+ headers['If-None-Match'] = if_none_match
46
+ end
41
47
 
42
48
  path = "#{@path}#{filename}"
43
49
  status, resp_headers, = @client.request('PUT', path, body: body, headers: headers)
@@ -91,7 +97,9 @@ module Async
91
97
 
92
98
  def propfind
93
99
  status, _, body = @client.request('PROPFIND', @path, headers: { 'Depth' => '0' })
94
- raise Error, "PROPFIND failed: #{status}" unless status == 207
100
+ unless status == 207
101
+ raise Error, "PROPFIND failed: #{status}"
102
+ end
95
103
  @client.parse_collection_props(body)
96
104
  end
97
105
 
@@ -101,19 +109,33 @@ module Async
101
109
  x.tag!("d:propertyupdate", "xmlns:d" => "DAV:", "xmlns:c" => "urn:ietf:params:xml:ns:caldav", "xmlns:x" => "http://apple.com/ns/ical/") do
102
110
  x.tag!("d:set") do
103
111
  x.tag!("d:prop") do
104
- x.tag!("d:displayname", displayname) if displayname
105
- x.tag!("c:calendar-description", description) if description
106
- x.tag!("x:calendar-color", color) if color
112
+ if displayname
113
+ x.tag!("d:displayname", displayname)
114
+ end
115
+ if description
116
+ x.tag!("c:calendar-description", description)
117
+ end
118
+ if color
119
+ x.tag!("x:calendar-color", color)
120
+ end
107
121
  end
108
122
  end
109
123
  end
110
124
 
111
125
  status, = @client.request('PROPPATCH', @path, body: x.target!, headers: { 'Content-Type' => 'text/xml' })
112
- raise Error, "PROPPATCH failed: #{status}" unless status == 207
126
+ unless status == 207
127
+ raise Error, "PROPPATCH failed: #{status}"
128
+ end
113
129
 
114
- @displayname = displayname if displayname
115
- @description = description if description
116
- @color = color if color
130
+ if displayname
131
+ @displayname = displayname
132
+ end
133
+ if description
134
+ @description = description
135
+ end
136
+ if color
137
+ @color = color
138
+ end
117
139
  self
118
140
  end
119
141
 
@@ -135,7 +157,9 @@ module Async
135
157
  if status == 403
136
158
  raise InvalidSyncToken, "Invalid sync token"
137
159
  end
138
- raise Error, "REPORT failed: #{status}" unless status == 207
160
+ unless status == 207
161
+ raise Error, "REPORT failed: #{status}"
162
+ end
139
163
 
140
164
  new_token = resp_body.match(/<[^>]*sync-token[^>]*>([^<]+)</)[1] rescue nil
141
165
  items = @client.parse_sync_items(resp_body)