shrine-tus 1.2.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/shrine/plugins/tus.rb +11 -9
- data/lib/shrine/storage/tus.rb +6 -27
- data/shrine-tus.gemspec +3 -3
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b9a750cdf52cbc0f84641e08b508500fa7443f33505b2736ead57685654c24
|
4
|
+
data.tar.gz: 7c49ff4133fd86f38034b260579a98934d4037b53205227d92ec8bb45b57666b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 007c7034718f1ce19fafb0c34ee831b7e6d5ea9b301c09e2a8462b4c80eff3c77d76d38c1ae497525977a67b447243fb31da0dd31a81bade0efbd5f80dfb86f1
|
7
|
+
data.tar.gz: 04f5ef1a90889437a86c2bedba87ab124a9bbb3ca05a7d291b60cef05b0c6fd4b7bafce03ee0f98a29ba91f5aeed42bfe5616817e84d54c07c2892c572820c08
|
data/README.md
CHANGED
data/lib/shrine/plugins/tus.rb
CHANGED
@@ -5,17 +5,19 @@ class Shrine
|
|
5
5
|
module Plugins
|
6
6
|
module Tus
|
7
7
|
module AttacherMethods
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
private
|
9
|
+
|
10
|
+
def cached(data)
|
11
|
+
data = data.dup
|
12
|
+
data = JSON.parse(data) if data.is_a?(String)
|
13
|
+
|
14
|
+
if URI.regexp =~ (data["id"] || data[:id])
|
15
|
+
id = data.delete("id") || data.delete(:id)
|
16
|
+
data["id"] = tus_url_to_storage_id(id, cache.storage)
|
15
17
|
end
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
+
super(data)
|
20
|
+
end
|
19
21
|
|
20
22
|
def tus_url_to_storage_id(tus_url, storage)
|
21
23
|
tus_uid = tus_url.split("/").last
|
data/lib/shrine/storage/tus.rb
CHANGED
@@ -13,17 +13,9 @@ class Shrine
|
|
13
13
|
super(delete: true, **options)
|
14
14
|
end
|
15
15
|
|
16
|
-
def download(id, **options)
|
17
|
-
if tus_storage
|
18
|
-
download_from_tus_storage(tus_uid(id))
|
19
|
-
else
|
20
|
-
super
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
16
|
def open(id, **options)
|
25
17
|
if tus_storage
|
26
|
-
open_from_tus_storage(tus_uid(id))
|
18
|
+
open_from_tus_storage(tus_uid(id), **options)
|
27
19
|
else
|
28
20
|
super
|
29
21
|
end
|
@@ -31,28 +23,15 @@ class Shrine
|
|
31
23
|
|
32
24
|
private
|
33
25
|
|
34
|
-
def
|
35
|
-
tempfile = Tempfile.new("shrine-tus", binmode: true)
|
36
|
-
|
37
|
-
response = get_tus_file(uid)
|
38
|
-
response.each do |chunk|
|
39
|
-
tempfile << chunk
|
40
|
-
chunk.clear # deallocate string
|
41
|
-
end
|
42
|
-
response.close
|
43
|
-
|
44
|
-
tempfile.open
|
45
|
-
tempfile
|
46
|
-
end
|
47
|
-
|
48
|
-
def open_from_tus_storage(uid)
|
26
|
+
def open_from_tus_storage(uid, rewindable: true, **)
|
49
27
|
response = get_tus_file(uid)
|
50
28
|
info = get_tus_info(uid)
|
51
29
|
|
52
30
|
Down::ChunkedIO.new(
|
53
|
-
size:
|
54
|
-
chunks:
|
55
|
-
on_close:
|
31
|
+
size: Integer(info["Upload-Length"]),
|
32
|
+
chunks: response.each,
|
33
|
+
on_close: response.method(:close),
|
34
|
+
rewindable: rewindable
|
56
35
|
)
|
57
36
|
end
|
58
37
|
|
data/shrine-tus.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "shrine-tus"
|
3
|
-
gem.version = "
|
3
|
+
gem.version = "2.0.0"
|
4
4
|
|
5
5
|
gem.required_ruby_version = ">= 2.1"
|
6
6
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "*.gemspec"]
|
14
14
|
gem.require_path = "lib"
|
15
15
|
|
16
|
-
gem.add_dependency "shrine", "
|
16
|
+
gem.add_dependency "shrine", ">= 3.0.0.beta3", "< 4"
|
17
17
|
gem.add_dependency "tus-server", "~> 2.0"
|
18
18
|
gem.add_dependency "shrine-url", ">= 2.2.1", "< 3"
|
19
19
|
|
@@ -21,5 +21,5 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_development_dependency "minitest"
|
22
22
|
gem.add_development_dependency "webmock"
|
23
23
|
gem.add_development_dependency "shrine-gridfs"
|
24
|
-
gem.add_development_dependency "aws-sdk-s3", "~> 1.
|
24
|
+
gem.add_development_dependency "aws-sdk-s3", "~> 1.14"
|
25
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-tus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0.beta3
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 3.0.0.beta3
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: tus-server
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,14 +126,14 @@ dependencies:
|
|
120
126
|
requirements:
|
121
127
|
- - "~>"
|
122
128
|
- !ruby/object:Gem::Version
|
123
|
-
version: '1.
|
129
|
+
version: '1.14'
|
124
130
|
type: :development
|
125
131
|
prerelease: false
|
126
132
|
version_requirements: !ruby/object:Gem::Requirement
|
127
133
|
requirements:
|
128
134
|
- - "~>"
|
129
135
|
- !ruby/object:Gem::Version
|
130
|
-
version: '1.
|
136
|
+
version: '1.14'
|
131
137
|
description:
|
132
138
|
email:
|
133
139
|
- janko.marohnic@gmail.com
|