shrine 3.6.0 → 3.7.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/CHANGELOG.md +18 -0
- data/doc/changing_derivatives.md +2 -1
- data/doc/changing_location.md +17 -5
- data/doc/getting_started.md +4 -2
- data/doc/plugins/derivation_endpoint.md +2 -1
- data/doc/plugins/derivatives.md +2 -1
- data/doc/plugins/download_endpoint.md +16 -4
- data/doc/plugins/refresh_metadata.md +20 -0
- data/doc/plugins/signature.md +8 -6
- data/doc/processing.md +5 -3
- data/doc/release_notes/3.7.0.md +75 -0
- data/lib/shrine/attacher.rb +21 -21
- data/lib/shrine/attachment.rb +2 -2
- data/lib/shrine/plugins/_urlsafe_serialization.rb +4 -4
- data/lib/shrine/plugins/add_metadata.rb +2 -4
- data/lib/shrine/plugins/atomic_helpers.rb +7 -7
- data/lib/shrine/plugins/backgrounding.rb +9 -9
- data/lib/shrine/plugins/column.rb +6 -4
- data/lib/shrine/plugins/default_url.rb +4 -4
- data/lib/shrine/plugins/delete_raw.rb +2 -2
- data/lib/shrine/plugins/derivation_endpoint.rb +25 -25
- data/lib/shrine/plugins/derivatives.rb +5 -1
- data/lib/shrine/plugins/download_endpoint.rb +62 -10
- data/lib/shrine/plugins/entity.rb +7 -7
- data/lib/shrine/plugins/infer_extension.rb +1 -1
- data/lib/shrine/plugins/instrumentation.rb +8 -8
- data/lib/shrine/plugins/mirroring.rb +10 -10
- data/lib/shrine/plugins/model.rb +9 -9
- data/lib/shrine/plugins/presign_endpoint.rb +4 -4
- data/lib/shrine/plugins/pretty_location.rb +2 -2
- data/lib/shrine/plugins/processing.rb +3 -3
- data/lib/shrine/plugins/rack_file.rb +2 -2
- data/lib/shrine/plugins/rack_response.rb +4 -4
- data/lib/shrine/plugins/refresh_metadata.rb +6 -6
- data/lib/shrine/plugins/remote_url.rb +3 -3
- data/lib/shrine/plugins/restore_cached_data.rb +3 -3
- data/lib/shrine/plugins/signature.rb +2 -2
- data/lib/shrine/plugins/store_dimensions.rb +2 -2
- data/lib/shrine/plugins/upload_endpoint.rb +4 -4
- data/lib/shrine/plugins/upload_options.rb +1 -1
- data/lib/shrine/plugins/validation.rb +8 -8
- data/lib/shrine/plugins/versions.rb +10 -10
- data/lib/shrine/plugins.rb +6 -14
- data/lib/shrine/storage/file_system.rb +4 -17
- data/lib/shrine/storage/linter.rb +8 -8
- data/lib/shrine/storage/memory.rb +1 -3
- data/lib/shrine/storage/s3.rb +45 -37
- data/lib/shrine/uploaded_file.rb +20 -18
- data/lib/shrine/version.rb +1 -1
- data/lib/shrine.rb +18 -18
- data/shrine.gemspec +6 -6
- metadata +15 -17
data/lib/shrine.rb
CHANGED
|
@@ -68,9 +68,9 @@ class Shrine
|
|
|
68
68
|
#
|
|
69
69
|
# Shrine.plugin MyPlugin
|
|
70
70
|
# Shrine.plugin :my_plugin
|
|
71
|
-
def plugin(plugin,
|
|
71
|
+
def plugin(plugin, ...)
|
|
72
72
|
plugin = Plugins.load_plugin(plugin) if plugin.is_a?(Symbol)
|
|
73
|
-
Plugins.load_dependencies(plugin, self,
|
|
73
|
+
Plugins.load_dependencies(plugin, self, ...)
|
|
74
74
|
self.include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
|
|
75
75
|
self.extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
|
|
76
76
|
self::UploadedFile.include(plugin::FileMethods) if defined?(plugin::FileMethods)
|
|
@@ -79,7 +79,7 @@ class Shrine
|
|
|
79
79
|
self::Attachment.extend(plugin::AttachmentClassMethods) if defined?(plugin::AttachmentClassMethods)
|
|
80
80
|
self::Attacher.include(plugin::AttacherMethods) if defined?(plugin::AttacherMethods)
|
|
81
81
|
self::Attacher.extend(plugin::AttacherClassMethods) if defined?(plugin::AttacherClassMethods)
|
|
82
|
-
Plugins.configure(plugin, self,
|
|
82
|
+
Plugins.configure(plugin, self, ...)
|
|
83
83
|
plugin
|
|
84
84
|
end
|
|
85
85
|
|
|
@@ -95,8 +95,8 @@ class Shrine
|
|
|
95
95
|
# class Photo
|
|
96
96
|
# include Shrine::Attachment(:image) # creates a Shrine::Attachment object
|
|
97
97
|
# end
|
|
98
|
-
def Attachment(name, **
|
|
99
|
-
self::Attachment.new(name, **
|
|
98
|
+
def Attachment(name, **)
|
|
99
|
+
self::Attachment.new(name, **)
|
|
100
100
|
end
|
|
101
101
|
alias attachment Attachment
|
|
102
102
|
alias [] Attachment
|
|
@@ -104,8 +104,8 @@ class Shrine
|
|
|
104
104
|
# Uploads the file to the specified storage. It delegates to `Shrine#upload`.
|
|
105
105
|
#
|
|
106
106
|
# Shrine.upload(io, :store) #=> #<Shrine::UploadedFile>
|
|
107
|
-
def upload(io, storage, **
|
|
108
|
-
new(storage).upload(io, **
|
|
107
|
+
def upload(io, storage, **)
|
|
108
|
+
new(storage).upload(io, **)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
# Instantiates a Shrine::UploadedFile from a hash, and optionally
|
|
@@ -201,13 +201,13 @@ class Shrine
|
|
|
201
201
|
# uploader.upload(io, metadata: { "foo" => "bar" }) # add metadata
|
|
202
202
|
# uploader.upload(io, location: "path/to/file") # specify location
|
|
203
203
|
# uploader.upload(io, upload_options: { acl: "public-read" }) # add upload options
|
|
204
|
-
def upload(io, **
|
|
204
|
+
def upload(io, **)
|
|
205
205
|
_enforce_io(io)
|
|
206
206
|
|
|
207
|
-
metadata = get_metadata(io, **
|
|
208
|
-
location = get_location(io,
|
|
207
|
+
metadata = get_metadata(io, **)
|
|
208
|
+
location = get_location(io, **, metadata:)
|
|
209
209
|
|
|
210
|
-
_upload(io,
|
|
210
|
+
_upload(io, **, location:, metadata:)
|
|
211
211
|
|
|
212
212
|
self.class::UploadedFile.new(
|
|
213
213
|
id: location,
|
|
@@ -219,13 +219,13 @@ class Shrine
|
|
|
219
219
|
# Generates a unique location for the uploaded file, preserving the
|
|
220
220
|
# file extension. Can be overriden in uploaders for generating custom
|
|
221
221
|
# location.
|
|
222
|
-
def generate_location(io, metadata: {}, **
|
|
223
|
-
basic_location(io, metadata:
|
|
222
|
+
def generate_location(io, metadata: {}, **)
|
|
223
|
+
basic_location(io, metadata:)
|
|
224
224
|
end
|
|
225
225
|
|
|
226
226
|
# Extracts filename, size and MIME type from the file, which is later
|
|
227
227
|
# accessible through UploadedFile#metadata.
|
|
228
|
-
def extract_metadata(io, **
|
|
228
|
+
def extract_metadata(io, **)
|
|
229
229
|
{
|
|
230
230
|
"filename" => extract_filename(io),
|
|
231
231
|
"size" => extract_size(io),
|
|
@@ -281,11 +281,11 @@ class Shrine
|
|
|
281
281
|
|
|
282
282
|
# If the IO object is a Shrine::UploadedFile, it simply copies over its
|
|
283
283
|
# metadata, otherwise it calls #extract_metadata.
|
|
284
|
-
def get_metadata(io, metadata: nil, **
|
|
284
|
+
def get_metadata(io, metadata: nil, **)
|
|
285
285
|
if io.is_a?(UploadedFile) && metadata != true
|
|
286
286
|
result = io.metadata.dup
|
|
287
287
|
elsif metadata != false
|
|
288
|
-
result = extract_metadata(io, **
|
|
288
|
+
result = extract_metadata(io, **)
|
|
289
289
|
else
|
|
290
290
|
result = {}
|
|
291
291
|
end
|
|
@@ -296,8 +296,8 @@ class Shrine
|
|
|
296
296
|
|
|
297
297
|
# Retrieves the location for the given IO and context. First it looks
|
|
298
298
|
# for the `:location` option, otherwise it calls #generate_location.
|
|
299
|
-
def get_location(io, location: nil, **
|
|
300
|
-
location ||= generate_location(io, **
|
|
299
|
+
def get_location(io, location: nil, **)
|
|
300
|
+
location ||= generate_location(io, **)
|
|
301
301
|
location or fail Error, "location generated for #{io.inspect} was nil"
|
|
302
302
|
end
|
|
303
303
|
|
data/shrine.gemspec
CHANGED
|
@@ -4,7 +4,7 @@ Gem::Specification.new do |gem|
|
|
|
4
4
|
gem.name = "shrine"
|
|
5
5
|
gem.version = Shrine.version
|
|
6
6
|
|
|
7
|
-
gem.required_ruby_version = ">= 2
|
|
7
|
+
gem.required_ruby_version = ">= 3.2"
|
|
8
8
|
|
|
9
9
|
gem.summary = "Toolkit for file attachments in Ruby applications"
|
|
10
10
|
gem.description = <<-END
|
|
@@ -38,7 +38,7 @@ direct uploads for fully asynchronous user experience.
|
|
|
38
38
|
|
|
39
39
|
# general testing helpers
|
|
40
40
|
gem.add_development_dependency "rake", ">= 11.1"
|
|
41
|
-
gem.add_development_dependency "minitest", "~>
|
|
41
|
+
gem.add_development_dependency "minitest", "~> 6.0"
|
|
42
42
|
gem.add_development_dependency "mocha", "~> 1.11"
|
|
43
43
|
|
|
44
44
|
# for endpoint plugins
|
|
@@ -57,7 +57,7 @@ direct uploads for fully asynchronous user experience.
|
|
|
57
57
|
|
|
58
58
|
# for store_dimensions plugin
|
|
59
59
|
gem.add_development_dependency "fastimage"
|
|
60
|
-
gem.add_development_dependency "mini_magick", "~>
|
|
60
|
+
gem.add_development_dependency "mini_magick", "~> 5.0" unless ENV["CI"]
|
|
61
61
|
gem.add_development_dependency "ruby-vips", "~> 2.0" unless ENV["CI"]
|
|
62
62
|
|
|
63
63
|
# for S3 storage
|
|
@@ -67,10 +67,10 @@ direct uploads for fully asynchronous user experience.
|
|
|
67
67
|
|
|
68
68
|
# for instrumentation plugin
|
|
69
69
|
gem.add_development_dependency "dry-monitor"
|
|
70
|
-
gem.add_development_dependency "activesupport",
|
|
70
|
+
gem.add_development_dependency "activesupport", RUBY_ENGINE == "jruby" ? "~> 7.0.0" : "~> 8.1"
|
|
71
71
|
|
|
72
72
|
# for ORM plugins
|
|
73
73
|
gem.add_development_dependency "sequel"
|
|
74
|
-
gem.add_development_dependency "activerecord", RUBY_ENGINE == "jruby" ? "~> 7.0.0" :
|
|
75
|
-
gem.add_development_dependency "sqlite3", "~> 1
|
|
74
|
+
gem.add_development_dependency "activerecord", RUBY_ENGINE == "jruby" ? "~> 7.0.0" : "~> 8.1"
|
|
75
|
+
gem.add_development_dependency "sqlite3", "~> 2.1" unless RUBY_ENGINE == "jruby"
|
|
76
76
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shrine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janko Marohnić
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: down
|
|
@@ -58,14 +57,14 @@ dependencies:
|
|
|
58
57
|
requirements:
|
|
59
58
|
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
60
|
+
version: '6.0'
|
|
62
61
|
type: :development
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
65
|
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
67
|
+
version: '6.0'
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
70
69
|
name: mocha
|
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -218,14 +217,14 @@ dependencies:
|
|
|
218
217
|
requirements:
|
|
219
218
|
- - "~>"
|
|
220
219
|
- !ruby/object:Gem::Version
|
|
221
|
-
version: '
|
|
220
|
+
version: '5.0'
|
|
222
221
|
type: :development
|
|
223
222
|
prerelease: false
|
|
224
223
|
version_requirements: !ruby/object:Gem::Requirement
|
|
225
224
|
requirements:
|
|
226
225
|
- - "~>"
|
|
227
226
|
- !ruby/object:Gem::Version
|
|
228
|
-
version: '
|
|
227
|
+
version: '5.0'
|
|
229
228
|
- !ruby/object:Gem::Dependency
|
|
230
229
|
name: ruby-vips
|
|
231
230
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -302,14 +301,14 @@ dependencies:
|
|
|
302
301
|
requirements:
|
|
303
302
|
- - "~>"
|
|
304
303
|
- !ruby/object:Gem::Version
|
|
305
|
-
version: '
|
|
304
|
+
version: '8.1'
|
|
306
305
|
type: :development
|
|
307
306
|
prerelease: false
|
|
308
307
|
version_requirements: !ruby/object:Gem::Requirement
|
|
309
308
|
requirements:
|
|
310
309
|
- - "~>"
|
|
311
310
|
- !ruby/object:Gem::Version
|
|
312
|
-
version: '
|
|
311
|
+
version: '8.1'
|
|
313
312
|
- !ruby/object:Gem::Dependency
|
|
314
313
|
name: sequel
|
|
315
314
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -330,28 +329,28 @@ dependencies:
|
|
|
330
329
|
requirements:
|
|
331
330
|
- - "~>"
|
|
332
331
|
- !ruby/object:Gem::Version
|
|
333
|
-
version: '
|
|
332
|
+
version: '8.1'
|
|
334
333
|
type: :development
|
|
335
334
|
prerelease: false
|
|
336
335
|
version_requirements: !ruby/object:Gem::Requirement
|
|
337
336
|
requirements:
|
|
338
337
|
- - "~>"
|
|
339
338
|
- !ruby/object:Gem::Version
|
|
340
|
-
version: '
|
|
339
|
+
version: '8.1'
|
|
341
340
|
- !ruby/object:Gem::Dependency
|
|
342
341
|
name: sqlite3
|
|
343
342
|
requirement: !ruby/object:Gem::Requirement
|
|
344
343
|
requirements:
|
|
345
344
|
- - "~>"
|
|
346
345
|
- !ruby/object:Gem::Version
|
|
347
|
-
version: '1
|
|
346
|
+
version: '2.1'
|
|
348
347
|
type: :development
|
|
349
348
|
prerelease: false
|
|
350
349
|
version_requirements: !ruby/object:Gem::Requirement
|
|
351
350
|
requirements:
|
|
352
351
|
- - "~>"
|
|
353
352
|
- !ruby/object:Gem::Version
|
|
354
|
-
version: '1
|
|
353
|
+
version: '2.1'
|
|
355
354
|
description: |
|
|
356
355
|
Shrine is a toolkit for file attachments in Ruby applications. It supports
|
|
357
356
|
uploading, downloading, processing and deleting IO objects, backed by various
|
|
@@ -482,6 +481,7 @@ files:
|
|
|
482
481
|
- doc/release_notes/3.4.0.md
|
|
483
482
|
- doc/release_notes/3.5.0.md
|
|
484
483
|
- doc/release_notes/3.6.0.md
|
|
484
|
+
- doc/release_notes/3.7.0.md
|
|
485
485
|
- doc/retrieving_uploads.md
|
|
486
486
|
- doc/securing_uploads.md
|
|
487
487
|
- doc/storage/file_system.md
|
|
@@ -561,7 +561,6 @@ metadata:
|
|
|
561
561
|
documentation_uri: https://shrinerb.com
|
|
562
562
|
mailing_list_uri: https://discourse.shrinerb.com
|
|
563
563
|
source_code_uri: https://github.com/shrinerb/shrine
|
|
564
|
-
post_install_message:
|
|
565
564
|
rdoc_options: []
|
|
566
565
|
require_paths:
|
|
567
566
|
- lib
|
|
@@ -569,15 +568,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
569
568
|
requirements:
|
|
570
569
|
- - ">="
|
|
571
570
|
- !ruby/object:Gem::Version
|
|
572
|
-
version: '2
|
|
571
|
+
version: '3.2'
|
|
573
572
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
574
573
|
requirements:
|
|
575
574
|
- - ">="
|
|
576
575
|
- !ruby/object:Gem::Version
|
|
577
576
|
version: '0'
|
|
578
577
|
requirements: []
|
|
579
|
-
rubygems_version:
|
|
580
|
-
signing_key:
|
|
578
|
+
rubygems_version: 4.0.3
|
|
581
579
|
specification_version: 4
|
|
582
580
|
summary: Toolkit for file attachments in Ruby applications
|
|
583
581
|
test_files: []
|