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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da9e552ed9264c1c408f43310627ea1a8889a22f515e897f1341aae1609c77ee
4
- data.tar.gz: c469c7ad799bf47cef51a388ea3db1a542e6d58d2eecaecce6dce5b06f816739
3
+ metadata.gz: d3b9a750cdf52cbc0f84641e08b508500fa7443f33505b2736ead57685654c24
4
+ data.tar.gz: 7c49ff4133fd86f38034b260579a98934d4037b53205227d92ec8bb45b57666b
5
5
  SHA512:
6
- metadata.gz: 3b69f870e7136722958f6dbe00f77c8c3ca7306cf45ce1e85f13a100a6b0465559f403bd3e25a0ddd3a0f9a3bdbe46cc29c2e55dfd0b22c2b7b295b9e1f8c325
7
- data.tar.gz: 496281aca3f21f8a0d7d3d03d66ee78b70ee25b5ce72e58ed04a88a5cf9b7179daee2c2ff4d93924fc147d6d72f563890ba006d4c0d8f6c93087b3389c0bb4c2
6
+ metadata.gz: 007c7034718f1ce19fafb0c34ee831b7e6d5ea9b301c09e2a8462b4c80eff3c77d76d38c1ae497525977a67b447243fb31da0dd31a81bade0efbd5f80dfb86f1
7
+ data.tar.gz: 04f5ef1a90889437a86c2bedba87ab124a9bbb3ca05a7d291b60cef05b0c6fd4b7bafce03ee0f98a29ba91f5aeed42bfe5616817e84d54c07c2892c572820c08
data/README.md CHANGED
@@ -5,7 +5,7 @@ Provides tools for integrating [Shrine] with [tus-ruby-server].
5
5
  ## Installation
6
6
 
7
7
  ```rb
8
- gem "shrine-tus", "~> 1.2"
8
+ gem "shrine-tus", "~> 2.0"
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -5,17 +5,19 @@ class Shrine
5
5
  module Plugins
6
6
  module Tus
7
7
  module AttacherMethods
8
- def assign(value, **options)
9
- if value.is_a?(String) && value != ""
10
- data = JSON.parse(value)
11
- data["id"] = tus_url_to_storage_id(data["id"], cache.storage) if URI.regexp =~ data["id"]
12
- super(data.to_json)
13
- else
14
- super
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
- private
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
@@ -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 download_from_tus_storage(uid)
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: Integer(info["Upload-Length"]),
54
- chunks: response.each,
55
- on_close: response.method(: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
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-tus"
3
- gem.version = "1.2.3"
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", "~> 2.0"
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.2"
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: 1.2.3
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-07-12 00:00:00.000000000 Z
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: '2.0'
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: '2.0'
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.2'
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.2'
136
+ version: '1.14'
131
137
  description:
132
138
  email:
133
139
  - janko.marohnic@gmail.com