webdav 0.1.0 → 0.1.2

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: 2a68489cf05ff70988c883f17b41a303db682c85346c4aa27dbadf1cf9f8c869
4
- data.tar.gz: a3544d9e0bcdd1b9bbe05720e72a10613ec291280f20d3030521189a68281fb5
3
+ metadata.gz: 282fc0b7d1998d1002ce33a6a590d1b42b352d7918ed41c001a75fac0f473bfa
4
+ data.tar.gz: 3c61685c5a13c143db955a376985b175fa7799efe13e986e8a7044bed8c27f2a
5
5
  SHA512:
6
- metadata.gz: 48e20a5991a5093884a4009ae00c91d807953b158044e413b338aa2cfbccb228257b4128fcb98a128159436ecf541fe8d5cb291816ca9c48e77258589626149d
7
- data.tar.gz: 887a1baac0d7d8592da56894dc1e74b907ccd3ce69a92dbe87f8bef0e10cca9b58ea22e89447ff9682c6a8de09e920989c1d200450fdd2d13e03b358545c3580
6
+ metadata.gz: ec83adb732f914c8786003133ecdc4e9ebbc71a42e3d2e0b59d1b76c1b21e9ab48ffc5af3cea08a193676e71591e5c850da2af57977d3a12c354a7c32cc0b04d
7
+ data.tar.gz: 761abe1872f20ca61c80ba3468709da9dea781116866c7ece0954cd67ddfdb65011981c859ffd15ec7bb79c7a9849be2db36c19e6b8a6ea56c55d7f4cef33993
data/CHANGELOG CHANGED
@@ -1,5 +1,27 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 20260520
4
+
5
+ 0.1.2: Fix Response#success? to return true only for 2xx responses.
6
+
7
+ 1. ~ WebDAV::Response#success?: Was `code < 400` which incorrectly reported 1xx and 3xx as successful. Now `code >= 200 && code < 300`.
8
+ 2. ~ test/WebDAV/Response_test.rb: + tests for 3xx and 5xx behaviour.
9
+ 3. ~ webdav.gemspec: Remove http.rb version constraint (was `>= 0.18.0`; the original rationale, Net::HTTP::Report being in http.rb 0.18.0, was reverted in webdav 0.1.1 and http.rb 0.18.1).
10
+ 4. ~ webdav.gemspec: + rexml runtime dependency (default gem on Ruby 3+; required by WebDAV::MultiStatus).
11
+ 5. ~ webdav.gemspec: Pin minitest development dependency to `~> 5.27` (Minitest 6 split `minitest/mock` into a separate gem).
12
+ 6. ~ WebDAV::VERSION: /0.1.1/0.1.2/
13
+ 7. ~ CHANGELOG: + 0.1.2 entry
14
+
15
+ ## 20260508
16
+
17
+ 0.1.1: Reinstate Net::HTTP::Report.
18
+
19
+ 1. + lib/Net/HTTP/Report.rb: Reinstated after checking after it was incorrectly removed in 0.1.0. REPORT is from RFC 3253 (WebDAV versioning) and is not a core HTTP method.
20
+ 2. ~ lib/webdav.rb: + require_relative './Net/HTTP/Report'
21
+ 3. + test/Net/HTTP/Report_test.rb
22
+ 4. ~ WebDAV::VERSION: /0.1.0/0.1.1/
23
+ 5. ~ CHANGELOG: + 0.1.1
24
+
3
25
  ## 20260508
4
26
 
5
27
  0.1.0: Remove Net::HTTP::Report; now provided by http.rb 0.18.0.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # webdav
2
2
 
3
- A Ruby WebDAV client library.
3
+ A WebDAV client library for Ruby.
4
+
4
5
 
5
6
  ## Installation
6
7
 
@@ -14,6 +15,7 @@ Or in your Gemfile:
14
15
  gem 'webdav'
15
16
  ```
16
17
 
18
+
17
19
  ## Usage
18
20
 
19
21
  ```ruby
@@ -80,7 +82,7 @@ response = dav.lock('/documents/report.txt', body: lock_body)
80
82
  dav.unlock('/documents/report.txt', token: 'urn:uuid:...')
81
83
  ```
82
84
 
83
- ### REPORT
85
+ ### Reporting
84
86
 
85
87
  ```ruby
86
88
  response = dav.report('/calendars/user/', body: report_xml, depth: '1')
@@ -89,18 +91,37 @@ response.resources.each do |resource|
89
91
  end
90
92
  ```
91
93
 
92
- ## Verbs
93
94
 
94
- ### WebDAV (RFC 4918 / RFC 3253)
95
+ ## Methods
96
+
97
+ WebDAV extends HTTP with additional methods for distributed authoring. This gem provides all the methods defined in RFC 4918 ("HTTP Extensions for Web Distributed Authoring and Versioning") and the REPORT method from RFC 3253 ("Versioning Extensions to WebDAV"), which is essential for CalDAV and CardDAV queries.
98
+
99
+ Ruby's standard library includes request classes for the RFC 4918 methods (Propfind, Proppatch, Mkcol, Copy, Move, Lock, Unlock) but not for REPORT. This gem defines `Net::HTTP::Report` to fill that gap.
100
+
101
+ These methods are not provided by the `http.rb` gem, which deliberately limits itself to the core HTTP methods defined in RFC 9110 ("HTTP Semantics") and RFC 5789 ("PATCH Method for HTTP").
102
+
103
+ ### Properties (RFC 4918)
104
+
105
+ - `propfind(path, body:, depth:)` — retrieve properties from a resource
106
+ - `proppatch(path, body:)` — set or remove properties on a resource
107
+
108
+ ### Versioning (RFC 3253)
109
+
110
+ - `report(path, body:, depth:)` — query for information about a resource; used by CalDAV and CardDAV
111
+
112
+ ### Collections (RFC 4918)
113
+
114
+ - `mkcol(path)` — create a new collection (directory)
95
115
 
96
- - `propfind(path, body:, depth:)` — Retrieve properties
97
- - `proppatch(path, body:)` — Modify properties
98
- - `report(path, body:, depth:)` — Run a report query
99
- - `mkcol(path)` — Create a collection
100
- - `copy(path, to:, depth:, overwrite:)` — Copy a resource
101
- - `move(path, to:, overwrite:)` — Move a resource
102
- - `lock(path, body:)` — Lock a resource
103
- - `unlock(path, token:)` — Unlock a resource
116
+ ### Namespace (RFC 4918)
117
+
118
+ - `copy(path, to:, depth:, overwrite:)` — copy a resource
119
+ - `move(path, to:, overwrite:)` — move a resource
120
+
121
+ ### Locking (RFC 4918)
122
+
123
+ - `lock(path, body:)` — lock a resource
124
+ - `unlock(path, token:)` — unlock a resource
104
125
 
105
126
  ### Standard HTTP
106
127
 
@@ -113,6 +134,7 @@ end
113
134
  - `options(path)`
114
135
  - `trace(path)`
115
136
 
137
+
116
138
  ## Responses
117
139
 
118
140
  All methods return either a `WebDAV::Response` or a `WebDAV::MultiStatus`.
@@ -129,20 +151,31 @@ All methods return either a `WebDAV::Response` or a `WebDAV::MultiStatus`.
129
151
 
130
152
  `WebDAV::MultiStatus` additionally provides:
131
153
 
132
- - `resources`
133
- — an array of hashes, each with:
154
+ - `resources` — an array of hashes, each with:
134
155
  - `href`
135
156
  - `properties`
136
157
  - `status`
137
158
 
159
+
138
160
  ## Errors
139
161
 
140
162
  Responses with status >= 400 raise `WebDAV::Error`, which has `code`, `message`, and `body`.
141
163
 
164
+
142
165
  ## Dependencies
143
166
 
144
167
  - [http.rb](https://github.com/thoran/http.rb)
145
168
 
169
+
170
+ ## Contributing
171
+
172
+ 1. Fork it [https://github.com/thoran/webdav/fork](https://github.com/thoran/webdav/fork)
173
+ 2. Create your feature branch (git checkout -b my-new-feature)
174
+ 3. Commit your changes (git commit -am 'Add some feature')
175
+ 4. Push to the branch (git push origin my-new-feature)
176
+ 5. Create a new pull request
177
+
178
+
146
179
  ## Licence
147
180
 
148
181
  MIT
@@ -0,0 +1,16 @@
1
+ # Net/HTTP/Report.rb
2
+ # Net::HTTP::Report
3
+
4
+ require 'net/http'
5
+
6
+ module Net
7
+ class HTTP
8
+ class Report < Net::HTTPRequest
9
+
10
+ METHOD = 'REPORT'
11
+ REQUEST_HAS_BODY = true
12
+ RESPONSE_HAS_BODY = true
13
+
14
+ end
15
+ end
16
+ end
@@ -6,7 +6,7 @@ class WebDAV
6
6
  attr_reader :code, :message, :headers, :body
7
7
 
8
8
  def success?
9
- code < 400
9
+ code >= 200 && code < 300
10
10
  end
11
11
 
12
12
  def etag
@@ -2,5 +2,5 @@
2
2
  # WebDAV::VERSION
3
3
 
4
4
  class WebDAV
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.2'
6
6
  end
data/lib/webdav.rb CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  gem 'http.rb'; require 'http.rb'
5
5
  require 'net/http'
6
- require 'rexml/document'
7
6
  require 'uri'
8
7
 
8
+ require_relative './Net/HTTP/Report'
9
9
  require_relative './String/to_const'
10
10
  require_relative './WebDAV/Error'
11
11
  require_relative './WebDAV/MultiStatus'
@@ -25,7 +25,7 @@ class WebDAV
25
25
  handle_response(response)
26
26
  end
27
27
 
28
- # Reports
28
+ # Versioning
29
29
 
30
30
  def report(path, body:, depth: '1')
31
31
  response = request(:report, path, body: body, headers: {'Depth' => depth})
@@ -0,0 +1,21 @@
1
+ # test/Net/HTTP/Report_test.rb
2
+
3
+ require_relative '../../helper'
4
+
5
+ describe Net::HTTP::Report do
6
+ it "is a subclass of Net::HTTPRequest" do
7
+ _(Net::HTTP::Report < Net::HTTPRequest).must_equal(true)
8
+ end
9
+
10
+ it "has the correct METHOD" do
11
+ _(Net::HTTP::Report::METHOD).must_equal('REPORT')
12
+ end
13
+
14
+ it "accepts a body" do
15
+ _(Net::HTTP::Report::REQUEST_HAS_BODY).must_equal(true)
16
+ end
17
+
18
+ it "expects a response body" do
19
+ _(Net::HTTP::Report::RESPONSE_HAS_BODY).must_equal(true)
20
+ end
21
+ end
@@ -39,11 +39,23 @@ describe WebDAV::Response do
39
39
  _(response.success?).must_equal true
40
40
  end
41
41
 
42
+ it "returns false for 3xx responses" do
43
+ redirect_response = MockResponse.new(code: '302', message: 'Found', body: '')
44
+ r = WebDAV::Response.new(redirect_response)
45
+ _(r.success?).must_equal false
46
+ end
47
+
42
48
  it "returns false for 4xx responses" do
43
49
  error_response = MockResponse.new(code: '404', message: 'Not Found', body: '')
44
50
  r = WebDAV::Response.new(error_response)
45
51
  _(r.success?).must_equal false
46
52
  end
53
+
54
+ it "returns false for 5xx responses" do
55
+ error_response = MockResponse.new(code: '500', message: 'Internal Server Error', body: '')
56
+ r = WebDAV::Response.new(error_response)
57
+ _(r.success?).must_equal false
58
+ end
47
59
  end
48
60
 
49
61
  describe "#etag" do
data/webdav.gemspec CHANGED
@@ -37,11 +37,12 @@ Gem::Specification.new do |spec|
37
37
  ].flatten
38
38
 
39
39
  spec.dependencies = [
40
- ['http.rb', '>= 0.18.0']
40
+ ['http.rb'],
41
+ ['rexml']
41
42
  ]
42
43
 
43
- spec.development_dependencies = %w{
44
- minitest
45
- rake
46
- }
44
+ spec.development_dependencies = [
45
+ ['minitest', '~> 5.27'],
46
+ ['rake']
47
+ ]
47
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -15,28 +15,42 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.18.0
18
+ version: '0'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.18.0
25
+ version: '0'
26
26
  - !ruby/object:Gem::Dependency
27
- name: minitest
27
+ name: rexml
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
- type: :development
33
+ type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: minitest
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '5.27'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.27'
40
54
  - !ruby/object:Gem::Dependency
41
55
  name: rake
42
56
  requirement: !ruby/object:Gem::Requirement
@@ -62,6 +76,7 @@ files:
62
76
  - LICENSE
63
77
  - README.md
64
78
  - Rakefile
79
+ - lib/Net/HTTP/Report.rb
65
80
  - lib/String/to_const.rb
66
81
  - lib/Thoran/Array/AllButFirst/all_but_first.rb
67
82
  - lib/Thoran/Array/FirstX/firstX.rb
@@ -71,6 +86,7 @@ files:
71
86
  - lib/WebDAV/Response.rb
72
87
  - lib/WebDAV/VERSION.rb
73
88
  - lib/webdav.rb
89
+ - test/Net/HTTP/Report_test.rb
74
90
  - test/WebDAV/Error_test.rb
75
91
  - test/WebDAV/MultiStatus_test.rb
76
92
  - test/WebDAV/Response_test.rb
@@ -95,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
111
  - !ruby/object:Gem::Version
96
112
  version: '0'
97
113
  requirements: []
98
- rubygems_version: 4.0.11
114
+ rubygems_version: 4.0.12
99
115
  specification_version: 4
100
116
  summary: A Ruby WebDAV client library.
101
117
  test_files: []