shrine-gridfs 0.3.2 → 0.4.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
- SHA1:
3
- metadata.gz: 32f189d0c100716ffe7658f1bf04e84f6ed05415
4
- data.tar.gz: 2ede8fa5db17c83fff263cd33e7d1434cad9da96
2
+ SHA256:
3
+ metadata.gz: 07be2986df88890481783403c520c27e27ea6744c7cdd091b7b454fb8c065dfa
4
+ data.tar.gz: 514a841b237934c1c9c000120d13b5f0da6bdd6946329914cc12a4a2bfb7f35c
5
5
  SHA512:
6
- metadata.gz: e0cd1b8dfbfaaf44644777f45b087b49485dd19528c4a2b1eff61a0fb1e932b891f7e4be4150cc134deea9940045fb4784ed1ca08e13c3ebb437bf28b0378384
7
- data.tar.gz: b8394324dea43b926e78ae961cfaecb949d98983c5afde5a0c0752c8074fd5b1ea3c70be7a6058c44f035cd3cef801af8a0e14aa003a750ab8af75bf17acbb20
6
+ metadata.gz: b83d5c85530b1c84a981232fcb2d57fd011dd4784105f82ea1ab91172c2c57764c486c55eb640647597bef4d84964a4d99922fe132a700e89ab931f14289542b
7
+ data.tar.gz: ca43699b252efab8cc5c0958d3880ec13da945c949f19c779e0a7495a3f890079326a399f1964b7dc4666a1a798838de5f8f4ed664be8254f4a4774c246cc091
data/README.md CHANGED
@@ -25,10 +25,13 @@ Shrine::Storage::Gridfs.new(client: client)
25
25
  ### Prefix
26
26
 
27
27
  The default prefix (bucket name) is "fs", you can change it with the `:prefix`
28
- option:
28
+ option, which is useful if you want to separate temporary and permanent storage.
29
29
 
30
30
  ```rb
31
- Shrine::Storage::Gridfs.new(client: client, prefix: "foo")
31
+ Shrine.storages = {
32
+ cache: Shrine::Storage::Gridfs.new(prefix: "temp", **options),
33
+ store: Shrine::Storage::Gridfs.new(prefix: "fs", **options),
34
+ }
32
35
  ```
33
36
 
34
37
  ### Chunk size
@@ -37,7 +40,7 @@ By default the Gridfs storage will store files in chunks of 256KB, you can
37
40
  change that via `:chunk_size`:
38
41
 
39
42
  ```rb
40
- Shrine::Storage::Gridfs.new(client: client, chunk_size: 1*1024*1024) # 1MB
43
+ Shrine::Storage::Gridfs.new(chunk_size: 1*1024*1024, **options) # 1MB
41
44
  ```
42
45
 
43
46
  ### Batch size
@@ -46,7 +49,7 @@ When Gridfs storage uploads or copies a file, it will ensure that no more
46
49
  than `:batch_size` of data is loaded into memory at once (defaults to 5MB).
47
50
 
48
51
  ```rb
49
- Shrine::Storage::Gridfs.new(client: client, batch_size: 10*1024*1024) # 10MB
52
+ Shrine::Storage::Gridfs.new(batch_size: 10*1024*1024, **options) # 10MB
50
53
  ```
51
54
 
52
55
  ### URLs
@@ -59,7 +62,7 @@ Shrine.plugin :download_endpoint, storages: [:store]
59
62
  ```
60
63
  ```rb
61
64
  Rails.application.routes.draw do
62
- mount Shrine::DownloadEndpoint => "/attachments"
65
+ mount Shrine.download_endpoint => "/attachments"
63
66
  end
64
67
  ```
65
68
  ```rb
@@ -83,5 +86,5 @@ This gem was inspired by [refile-gridfs].
83
86
  [MIT](http://opensource.org/licenses/MIT)
84
87
 
85
88
  [GridFS]: https://docs.mongodb.org/v3.0/core/gridfs/
86
- [Shrine]: https://github.com/janko-m/shrine
89
+ [Shrine]: https://github.com/shrinerb/shrine
87
90
  [refile-gridfs]: https://github.com/Titinux/refile-gridfs
@@ -26,14 +26,15 @@ class Shrine
26
26
  end
27
27
  end
28
28
 
29
- def open(id)
29
+ def open(id, rewindable: true, **)
30
30
  content_length = file_info(id)[:length]
31
31
  stream = bucket.open_download_stream(bson_id(id))
32
32
 
33
33
  Down::ChunkedIO.new(
34
- size: content_length,
35
- chunks: stream.enum_for(:each),
36
- on_close: -> { stream.close },
34
+ size: content_length,
35
+ chunks: stream.enum_for(:each),
36
+ on_close: -> { stream.close },
37
+ rewindable: rewindable,
37
38
  )
38
39
  end
39
40
 
@@ -46,12 +47,6 @@ class Shrine
46
47
  rescue Mongo::Error::FileNotFound
47
48
  end
48
49
 
49
- def multi_delete(ids)
50
- ids = ids.map { |id| bson_id(id) }
51
- files_collection.find(_id: {"$in" => ids}).delete_many
52
- chunks_collection.find(files_id: {"$in" => ids}).delete_many
53
- end
54
-
55
50
  def url(id, **)
56
51
  end
57
52
 
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-gridfs"
3
- gem.version = "0.3.2"
3
+ gem.version = "0.4.0"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
7
7
  gem.summary = "Provides MongoDB's GridFS storage for Shrine."
8
- gem.homepage = "https://github.com/janko-m/shrine-gridfs"
8
+ gem.homepage = "https://github.com/shrinerb/shrine-gridfs"
9
9
  gem.authors = ["Janko Marohnić"]
10
10
  gem.email = ["janko.marohnic@gmail.com"]
11
11
  gem.license = "MIT"
@@ -13,9 +13,9 @@ Gem::Specification.new do |gem|
13
13
  gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "shrine-gridfs.gemspec"]
14
14
  gem.require_path = "lib"
15
15
 
16
- gem.add_dependency "shrine", "~> 2.2"
16
+ gem.add_dependency "shrine", "~> 2.2", "< 4"
17
17
  gem.add_dependency "mongo", ">= 2.2.2", "< 3"
18
- gem.add_dependency "down", ">= 2.3.3"
18
+ gem.add_dependency "down", "~> 4.0"
19
19
 
20
20
  gem.add_development_dependency "rake"
21
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.3.2
4
+ version: 0.4.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: 2017-03-27 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
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.2'
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
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '2.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: mongo
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -48,16 +54,16 @@ dependencies:
48
54
  name: down
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
- - - ">="
57
+ - - "~>"
52
58
  - !ruby/object:Gem::Version
53
- version: 2.3.3
59
+ version: '4.0'
54
60
  type: :runtime
55
61
  prerelease: false
56
62
  version_requirements: !ruby/object:Gem::Requirement
57
63
  requirements:
58
- - - ">="
64
+ - - "~>"
59
65
  - !ruby/object:Gem::Version
60
- version: 2.3.3
66
+ version: '4.0'
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: rake
63
69
  requirement: !ruby/object:Gem::Requirement
@@ -111,7 +117,7 @@ files:
111
117
  - README.md
112
118
  - lib/shrine/storage/gridfs.rb
113
119
  - shrine-gridfs.gemspec
114
- homepage: https://github.com/janko-m/shrine-gridfs
120
+ homepage: https://github.com/shrinerb/shrine-gridfs
115
121
  licenses:
116
122
  - MIT
117
123
  metadata: {}
@@ -130,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
136
  - !ruby/object:Gem::Version
131
137
  version: '0'
132
138
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.5.1
139
+ rubygems_version: 3.0.3
135
140
  signing_key:
136
141
  specification_version: 4
137
142
  summary: Provides MongoDB's GridFS storage for Shrine.