shrine-google_cloud_storage 3.0.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/shrine/storage/google_cloud_storage.rb +23 -14
- data/shrine-google_cloud_storage.gemspec +11 -3
- metadata +30 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 021de2771b75b7e440d36788d7d3c45cec306d026c6aa08ed9e8218e69e61c86
|
4
|
+
data.tar.gz: cdbf68b610dca3468ba12095b2cff8fd38460593df573d6e8025c571659d9643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b088638b0c81d49587b2e9919267167c46de45638a661acee1558f7a017365ca25efc39c163a2e3a61ef0a4d494b527b4c1474d6e1b50c39349b017abbb6a6b9
|
7
|
+
data.tar.gz: bd972313c44c20899c4b1dd0b1909051d0b75cfadef0aadc0957c1f54f3741107a8ee3e3425673ae88e55626a4724f64660cbafac876f15cf82e1e4188f0d807
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ gem "shrine-google_cloud_storage"
|
|
12
12
|
|
13
13
|
## Authentication
|
14
14
|
|
15
|
-
The GCS plugin uses the `google-cloud-storage` gem. Please refer to [its documentation for setting up authentication](
|
15
|
+
The GCS plugin uses the `google-cloud-storage` gem. Please refer to [its documentation for setting up authentication](https://googleapis.dev/ruby/google-cloud-storage/latest/file.AUTHENTICATION.html).
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
@@ -65,7 +65,7 @@ cp .env.sample .env
|
|
65
65
|
|
66
66
|
#### Option 2 - manual setup
|
67
67
|
|
68
|
-
Create your own bucket and provide variables that allow for [project and credential lookup](
|
68
|
+
Create your own bucket and provide variables that allow for [project and credential lookup](https://googleapis.dev/ruby/google-cloud-storage/latest/file.AUTHENTICATION.html#project-and-credential-lookup).
|
69
69
|
For example:
|
70
70
|
|
71
71
|
```sh
|
@@ -10,15 +10,22 @@ class Shrine
|
|
10
10
|
# Initialize a Shrine::Storage for GCS allowing for auto-discovery of the Google::Cloud::Storage client.
|
11
11
|
# @param [String] project Provide if not using auto discovery
|
12
12
|
# @see http://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-storage/v1.6.0/guides/authentication#environmentvariables for information on discovery
|
13
|
-
def initialize(project: nil, bucket:, prefix: nil, host: nil, default_acl: nil, object_options: {}, credentials: nil)
|
13
|
+
def initialize(project: nil, bucket:, prefix: nil, host: nil, default_acl: nil, object_options: {}, credentials: nil, public: false)
|
14
14
|
@project = project
|
15
15
|
@bucket = bucket
|
16
16
|
@prefix = prefix
|
17
17
|
@host = host
|
18
|
-
@default_acl = default_acl
|
19
18
|
@object_options = object_options
|
20
19
|
@storage = nil
|
21
20
|
@credentials = credentials
|
21
|
+
|
22
|
+
@default_acl = if public && default_acl && default_acl != "publicRead"
|
23
|
+
raise Shrine::Error, "You can not set both public and default_acl"
|
24
|
+
elsif public
|
25
|
+
"publicRead"
|
26
|
+
else
|
27
|
+
default_acl
|
28
|
+
end
|
22
29
|
end
|
23
30
|
|
24
31
|
# If the file is an UploadFile from GCS, issues a copy command, otherwise it uploads a file.
|
@@ -30,7 +37,7 @@ class Shrine
|
|
30
37
|
file = existing_file.copy(
|
31
38
|
@bucket, # dest_bucket_or_path - the bucket to copy the file to
|
32
39
|
object_name(id), # dest_path - the path to copy the file to in the given bucket
|
33
|
-
acl: @default_acl
|
40
|
+
acl: options.fetch(:acl) { @default_acl }
|
34
41
|
) do |f|
|
35
42
|
# Workaround a bug in File#copy where the content-type is not copied if you provide a block
|
36
43
|
# See https://github.com/renchap/shrine-google_cloud_storage/issues/36
|
@@ -45,14 +52,16 @@ class Shrine
|
|
45
52
|
file
|
46
53
|
else
|
47
54
|
with_file(io) do |file|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
file_options = @object_options.merge(
|
56
|
+
content_type: shrine_metadata["mime_type"],
|
57
|
+
acl: options.fetch(:acl) { @default_acl }
|
58
|
+
).merge(options)
|
59
|
+
|
60
|
+
get_bucket.create_file(
|
61
|
+
file,
|
62
|
+
object_name(id), # path
|
63
|
+
**file_options
|
64
|
+
)
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
@@ -60,12 +69,12 @@ class Shrine
|
|
60
69
|
# URL to the remote file, accepts options for customizing the URL
|
61
70
|
def url(id, **options)
|
62
71
|
if options.key? :expires
|
63
|
-
signed_url = storage.signed_url(@bucket, object_name(id), options)
|
72
|
+
signed_url = storage.signed_url(@bucket, object_name(id), **options)
|
64
73
|
signed_url.gsub!(/storage.googleapis.com\/#{@bucket}/, @host) if @host
|
65
74
|
signed_url
|
66
75
|
else
|
67
76
|
host = @host || "storage.googleapis.com/#{@bucket}"
|
68
|
-
"https://#{host}/#{object_name(id)}"
|
77
|
+
"https://#{host}/#{Addressable::URI.encode_component(object_name(id), Addressable::URI::CharacterClasses::PATH)}"
|
69
78
|
end
|
70
79
|
end
|
71
80
|
|
@@ -157,7 +166,7 @@ class Shrine
|
|
157
166
|
opts[:project] = @project if @project
|
158
167
|
opts[:credentials] = @credentials if @credentials
|
159
168
|
|
160
|
-
@storage = Google::Cloud::Storage.new(opts)
|
169
|
+
@storage = Google::Cloud::Storage.new(**opts)
|
161
170
|
end
|
162
171
|
|
163
172
|
def copyable?(io)
|
@@ -1,23 +1,31 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "shrine-google_cloud_storage"
|
3
|
-
gem.version = "3.0
|
3
|
+
gem.version = "3.3.0"
|
4
4
|
|
5
|
-
gem.required_ruby_version = ">= 2.
|
5
|
+
gem.required_ruby_version = ">= 2.6"
|
6
6
|
|
7
7
|
gem.summary = "Provides Google Cloud Storage storage for Shrine."
|
8
8
|
gem.homepage = "https://github.com/renchap/shrine-google_cloud_storage"
|
9
9
|
gem.authors = ["Renaud Chaput"]
|
10
10
|
gem.email = ["renchap@gmail.com"]
|
11
11
|
gem.license = "MIT"
|
12
|
+
gem.metadata = {
|
13
|
+
"bug_tracker_uri" => "https://github.com/renchap/shrine-google_cloud_storage/issues",
|
14
|
+
"changelog_uri" => "https://github.com/renchap/shrine-google_cloud_storage/blob/main/CHANGELOG.md",
|
15
|
+
"homepage_uri" => "https://github.com/renchap/shrine-google_cloud_storage/",
|
16
|
+
"source_code_uri" => "https://github.com/renchap/shrine-google_cloud_storage/",
|
17
|
+
"rubygems_mfa_required" => "true",
|
18
|
+
}
|
12
19
|
|
13
20
|
gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "shrine-google_cloud_storage.gemspec"]
|
14
21
|
gem.require_path = "lib"
|
15
22
|
|
16
23
|
gem.add_dependency "shrine", "~> 3.0"
|
17
24
|
gem.add_dependency "google-cloud-storage", "~> 1.6"
|
25
|
+
gem.add_dependency "addressable" # no version constraint to use the same as `google-cloud-storage`
|
18
26
|
|
19
27
|
gem.add_development_dependency "rake"
|
20
28
|
gem.add_development_dependency "minitest"
|
21
29
|
gem.add_development_dependency "dotenv"
|
22
|
-
gem.add_development_dependency "http", "~>
|
30
|
+
gem.add_development_dependency "http", "~> 5.0"
|
23
31
|
end
|
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: 3.0
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renaud Chaput
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: addressable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,15 +100,15 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '5.0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
97
|
-
description:
|
110
|
+
version: '5.0'
|
111
|
+
description:
|
98
112
|
email:
|
99
113
|
- renchap@gmail.com
|
100
114
|
executables: []
|
@@ -107,8 +121,13 @@ files:
|
|
107
121
|
homepage: https://github.com/renchap/shrine-google_cloud_storage
|
108
122
|
licenses:
|
109
123
|
- MIT
|
110
|
-
metadata:
|
111
|
-
|
124
|
+
metadata:
|
125
|
+
bug_tracker_uri: https://github.com/renchap/shrine-google_cloud_storage/issues
|
126
|
+
changelog_uri: https://github.com/renchap/shrine-google_cloud_storage/blob/main/CHANGELOG.md
|
127
|
+
homepage_uri: https://github.com/renchap/shrine-google_cloud_storage/
|
128
|
+
source_code_uri: https://github.com/renchap/shrine-google_cloud_storage/
|
129
|
+
rubygems_mfa_required: 'true'
|
130
|
+
post_install_message:
|
112
131
|
rdoc_options: []
|
113
132
|
require_paths:
|
114
133
|
- lib
|
@@ -116,15 +135,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
135
|
requirements:
|
117
136
|
- - ">="
|
118
137
|
- !ruby/object:Gem::Version
|
119
|
-
version: '2.
|
138
|
+
version: '2.6'
|
120
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
140
|
requirements:
|
122
141
|
- - ">="
|
123
142
|
- !ruby/object:Gem::Version
|
124
143
|
version: '0'
|
125
144
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
-
signing_key:
|
145
|
+
rubygems_version: 3.3.7
|
146
|
+
signing_key:
|
128
147
|
specification_version: 4
|
129
148
|
summary: Provides Google Cloud Storage storage for Shrine.
|
130
149
|
test_files: []
|