shrine-google_cloud_storage 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: 900ee63b1a59397ff36fe30add0c7efbca93e07f
4
- data.tar.gz: 8fcf629cbd6f125ad18c30c5d135f4b39d20c771
3
+ metadata.gz: '08d6183e134fdb573cb7a432c55489f17a59d05a'
4
+ data.tar.gz: 4c0604286ce8695f96509d6f332f5b6045c408c4
5
5
  SHA512:
6
- metadata.gz: d8e8f6e0b56adf09b010edfcaedac63769a9e6c5d3d096e7e78cfd6f71faee1e1774604e847d7360f29b365b80ac41d8d20f55cd0ec464adc1e4b8c31261dad9
7
- data.tar.gz: 58f5b6adabf36e897ab6f475aa589744ff4aaf5031d961296a2407d17c41770220bb9ef2a0e65f79f98db9ffc04c40a4be9e011ddd8ef4426fec3439561355b7
6
+ metadata.gz: fa358fd9e4a7a53ba56da9612860eee38998f544858e3010103b492c6fa9ee1ebb8937e39e42e42572daf29aea0e8a9a1d799ac39ebdf5b31248536e07ba8f1d
7
+ data.tar.gz: 963493555038ef7918db7b129a1b5e837edb59212570ae936cc8fa78db4fd99fe9082d7395d87c47b9f6553297f976575523e3a82cbe5d5d4dcfecfa14ad7c0f
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/shrine-google_cloud_storage.svg)](https://badge.fury.io/rb/shrine-google_cloud_storage)
2
+
1
3
  # Shrine::Storage::GoogleCloudStorage
2
4
 
3
5
  Provides [Google Cloud Storage] (GCS) storage for [Shrine].
@@ -92,9 +92,7 @@ class Shrine
92
92
  end
93
93
 
94
94
  def clear!
95
- ids = []
96
-
97
- storage_api.fetch_all do |token, s|
95
+ all_objects = storage_api.fetch_all do |token, s|
98
96
  prefix = "#{@prefix}/" if @prefix
99
97
  s.list_objects(
100
98
  @bucket,
@@ -102,18 +100,9 @@ class Shrine
102
100
  fields: "items/name",
103
101
  page_token: token,
104
102
  )
105
- end.each do |object|
106
- ids << object.name
107
-
108
- if ids.size >= 100
109
- # Batches are limited to 100, so we execute it and reset the ids
110
- batch_delete(ids)
111
- ids = []
112
- end
113
103
  end
114
104
 
115
- # We delete the remaining ones
116
- batch_delete(ids) unless ids.empty?
105
+ batch_delete(all_objects.lazy.map(&:name))
117
106
  end
118
107
 
119
108
  def presign(id, **options)
@@ -152,9 +141,12 @@ class Shrine
152
141
  end
153
142
 
154
143
  def batch_delete(object_names)
155
- storage_api.batch do |storage|
156
- object_names.each do |name|
157
- storage.delete_object(@bucket, name)
144
+ # Batches are limited to 100 operations
145
+ object_names.each_slice(100) do |names|
146
+ storage_api.batch do |storage|
147
+ names.each do |name|
148
+ storage.delete_object(@bucket, name)
149
+ end
158
150
  end
159
151
  end
160
152
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-google_cloud_storage"
3
- gem.version = "0.1.0"
3
+ gem.version = "0.2.0"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.require_path = "lib"
15
15
 
16
16
  gem.add_dependency "shrine", "~> 2.0"
17
- gem.add_dependency "google-api-client", "~> 0.11.0"
17
+ gem.add_dependency "google-api-client", "~> 0.13.0"
18
18
 
19
19
  gem.add_development_dependency "rake"
20
20
  gem.add_development_dependency "minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-google_cloud_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renaud Chaput
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.11.0
33
+ version: 0.13.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.11.0
40
+ version: 0.13.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement