shrine-webdav 0.1.3 → 0.1.4
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/lib/shrine/storage/webdav.rb +18 -6
- data/shrine-webdav.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3a70e8dcbd91037acc9693ebc51321b8ff4477
|
4
|
+
data.tar.gz: 40b305052ad5054794f5162ef7289b3c3c8f6aa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed332c4ffa6dd2c0b2b79c0c1a8c58864a0373c355a85f96290b96045e9972721dabc077db776302911949f9e81e23de7c1e6d0a75a067373954e584409a16fb
|
7
|
+
data.tar.gz: cb759c944a2e3e92077cd66251da26455c4ecd16ff8c154109aa70d74b54ca1fb3c6737e10101375f54be7e220d10486e0654591d8d6b4b352e04610abb36cd2
|
@@ -5,18 +5,17 @@ require 'down/http'
|
|
5
5
|
class Shrine
|
6
6
|
module Storage
|
7
7
|
class WebDAV
|
8
|
-
def initialize(host:, prefix: nil)
|
8
|
+
def initialize(host:, prefix: nil, upload_options: {})
|
9
9
|
@host = host
|
10
10
|
@prefix = prefix
|
11
11
|
@prefixed_host = path(@host, @prefix)
|
12
|
+
@upload_options = upload_options
|
12
13
|
end
|
13
14
|
|
14
15
|
def upload(io, id, shrine_metadata: {}, **upload_options)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
return if (200..299).cover?(response.code.to_i)
|
19
|
-
raise Error, "uploading of #{uri} failed, the server response was #{response}"
|
16
|
+
options = current_options(upload_options)
|
17
|
+
mkpath_to_file(id) unless options[:create_full_put_path]
|
18
|
+
put(id, io)
|
20
19
|
end
|
21
20
|
|
22
21
|
def url(id, **options)
|
@@ -38,6 +37,19 @@ class Shrine
|
|
38
37
|
|
39
38
|
private
|
40
39
|
|
40
|
+
def current_options(upload_options)
|
41
|
+
options = {}
|
42
|
+
options.update(@upload_options)
|
43
|
+
options.update(upload_options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def put(id, io)
|
47
|
+
uri = path(@prefixed_host, id)
|
48
|
+
response = HTTP.put(uri, body: io.read)
|
49
|
+
return if (200..299).cover?(response.code.to_i)
|
50
|
+
raise Error, "uploading of #{uri} failed, the server response was #{response}"
|
51
|
+
end
|
52
|
+
|
41
53
|
def path(host, uri)
|
42
54
|
(uri.nil? || uri.empty?) ? host : [host, uri].compact.join('/')
|
43
55
|
end
|
data/shrine-webdav.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-webdav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kushmantsev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|