shrine-gridfs 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shrine/storage/gridfs.rb +19 -11
- data/shrine-gridfs.gemspec +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0c54bce081cf7e9ddfb91319ea7c7f2b87dce4d
|
4
|
+
data.tar.gz: 218dee27bac26e562c22ceaf8e1694dc221a90c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4246aab41aa653b47c554990252302e94998e530390bffe9dacce31d2d7cfc9a5520babd5c0fb5bc4947bf400311920de9c9c4e4453c1f2cbc2471401871fb4
|
7
|
+
data.tar.gz: f61d44f87bbd1aa65da985d90964924a81a50d6c9e819113a645d353738c86abf851f0f217b80b066c86f81a5334d453f0c6cc682a3c4122e5c4cbbb54b6a7d4
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "shrine"
|
2
2
|
require "mongo"
|
3
|
+
require "down"
|
3
4
|
|
4
5
|
require "stringio"
|
5
6
|
|
@@ -23,21 +24,18 @@ class Shrine
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def download(id)
|
26
|
-
|
27
|
-
bucket.download_to_stream(bson_id(id), tempfile)
|
28
|
-
tempfile.open
|
29
|
-
tempfile
|
27
|
+
Down.copy_to_tempfile(id, open(id))
|
30
28
|
end
|
31
29
|
|
32
|
-
def
|
30
|
+
def open(id)
|
33
31
|
content_length = bucket.find(_id: bson_id(id)).first["length"]
|
34
|
-
bucket.open_download_stream(bson_id(id))
|
35
|
-
stream.each { |chunk| yield chunk, content_length }
|
36
|
-
end
|
37
|
-
end
|
32
|
+
stream = bucket.open_download_stream(bson_id(id))
|
38
33
|
|
39
|
-
|
40
|
-
|
34
|
+
Down::ChunkedIO.new(
|
35
|
+
size: content_length,
|
36
|
+
chunks: stream.enum_for(:each),
|
37
|
+
on_close: -> { stream.close },
|
38
|
+
)
|
41
39
|
end
|
42
40
|
|
43
41
|
def read(id)
|
@@ -68,6 +66,16 @@ class Shrine
|
|
68
66
|
bucket.chunks_collection.find.delete_many
|
69
67
|
end
|
70
68
|
|
69
|
+
def method_missing(name, *args)
|
70
|
+
if name == :stream
|
71
|
+
warn "Shrine::Storage::Gridfs#stream is deprecated over calling #each_chunk on result of Gridfs#open."
|
72
|
+
content_length = bucket.find(_id: bson_id(*args)).first["length"]
|
73
|
+
bucket.open_download_stream(bson_id(*args)) do |stream|
|
74
|
+
stream.each { |chunk| yield chunk, content_length }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
71
79
|
private
|
72
80
|
|
73
81
|
def bson_id(id)
|
data/shrine-gridfs.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "shrine-gridfs"
|
3
|
-
gem.version = "0.2.
|
3
|
+
gem.version = "0.2.1"
|
4
4
|
|
5
5
|
gem.required_ruby_version = ">= 2.1"
|
6
6
|
|
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
|
16
16
|
gem.add_dependency "shrine", "~> 2.0"
|
17
17
|
gem.add_dependency "mongo", ">= 2.2.2", "< 3"
|
18
|
+
gem.add_dependency "down", ">= 2.3.3"
|
18
19
|
|
19
20
|
gem.add_development_dependency "rake"
|
20
21
|
gem.add_development_dependency "minitest"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-gridfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '3'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: down
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.3.3
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.3.3
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: rake
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|