shrine 3.7.0 → 3.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01c1404cab9882d16a6795c41467591b4083cbef76b5d42b91626a4306b33584
4
- data.tar.gz: bec484b8594573db2056eabeda97ae5c22fb170a35f984802cd200085611e556
3
+ metadata.gz: 29a02d25cd1180c4f0170434edd185b3b1ab0bd2be060fa53e58fcd32c50d4ae
4
+ data.tar.gz: 56e50d961ef88e0d3cae4d295b6996c52cd2021b923d9b453f401f10b04021b3
5
5
  SHA512:
6
- metadata.gz: 298e5065ba40638cee54dc4b74be98e466974502f56b5bff956fb2d7cc4d73028ec8a9d79dae7c073306c4512145cfef082ec4beeeb60a0eddef5497bbcf8174
7
- data.tar.gz: 3413b070afe6315133342ab3faf7c41d97bb9767a3aa13f62bf4ba339246fb4f1b3d1ebc91036b37942b8893c20b652edf4603f2b710bd66647caed6b9cddc48
6
+ metadata.gz: cb06f261af63f09ba767556d65f8b99e5204c1162ce7d8e28e5355148539a02c486fa088819884cf38dee4bf0683e8167b6582c4a028271a5145bd8661f64765
7
+ data.tar.gz: ec5cd4f04fe90ada87cd594bf78e61c2de9fcbebe8d51cb9e49b0bec566614be5ea5826382a8f25608888c84a951f25ad80442a6af2d641a37bae0e8fe184d7e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
+ ## 3.7.1 (2026-06-03)
2
+
3
+ * Update method signatures of some plugins to work around a Bootsnap bug causing a `wrong number of arguments` error.
4
+
1
5
  ## 3.7.0 (2026-05-27)
2
6
 
7
+ * `rack_response` - Add `:etag` option for setting a custom `ETag` header (@janko)
8
+
3
9
  * `download_endpoint` - Add support for expiring URLs (@davidwessman)
4
10
 
5
11
  * `s3` - Use `TransferManager` where available instead of deprecated `upload_steam` (@danieldevlewis)
@@ -309,6 +309,19 @@ uploaded_file.derivation_url(:thumbnail, prefix: "transformations/image")
309
309
  #=> ".../transformations/image/thumbnail/eyJpZCI6ImZvbyIsInN?signature=..."
310
310
  ```
311
311
 
312
+ ## Format
313
+
314
+ Some HTTP clients and CDNs use the URL path extension to determine the content
315
+ type of the response. You can append a file extension to the derivation URL
316
+ path with the `:format` option:
317
+
318
+ ```rb
319
+ uploaded_file.derivation_url(:thumbnail, format: "jpg")
320
+ #=> ".../thumbnail/eyJpZCI6ImZvbyIsInN.jpg?signature=..."
321
+ ```
322
+
323
+ The extension is included in the URL signature, so it cannot be tampered with.
324
+
312
325
  ## Expiration
313
326
 
314
327
  By default derivation URLs are valid indefinitely. If you want URLs to expire
@@ -95,6 +95,15 @@ headers["Content-Range"] #=> "bytes 100-200/1000"
95
95
  body # partial content
96
96
  ```
97
97
 
98
+ ## ETag
99
+
100
+ A custom ETag value can be provided via the `:etag` option:
101
+
102
+ ```rb
103
+ response = uploaded_file.to_rack_response(etag: "my-custom-etag")
104
+ response[1]["ETag"] #=> "my-custom-etag"
105
+ ```
106
+
98
107
  ## Download options
99
108
 
100
109
  The `#to_rack_response` method will automatically open the `UploadedFile` if it
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: Shrine 3.7.1
3
+ ---
4
+
5
+ ## Bug fixes
6
+
7
+ * When initializing Shrine with the `activerecord` plugin, under Bootsnap 1.24.5 and Ruby 3.4.5 this would raise an error:
8
+
9
+ ```
10
+ ArgumentError: wrong number of arguments (given 2, expected 1; required keyword: plugin)
11
+ ```
12
+
13
+ The seems to be triggered by a special combination of method signatures, where keyword arguments get converted into positional arguments under Bootsnap. To work around this issue, method signatures of some plugin methods have been updated.
@@ -7,7 +7,7 @@ class Shrine
7
7
  #
8
8
  # plugin :_persistence, plugin: MyPlugin
9
9
  module Persistence
10
- def self.load_dependencies(uploader, *)
10
+ def self.load_dependencies(uploader, **)
11
11
  uploader.plugin :atomic_helpers
12
12
  uploader.plugin :entity
13
13
  end
@@ -24,7 +24,7 @@ class Shrine
24
24
  }.inspect}"
25
25
  end
26
26
 
27
- def self.load_dependencies(uploader, *)
27
+ def self.load_dependencies(uploader, **)
28
28
  uploader.plugin :validation
29
29
  end
30
30
 
@@ -303,9 +303,9 @@ class Shrine
303
303
  class Derivation::Url < Derivation::Command
304
304
  delegate :name, :args, :source, :secret_key, :signer
305
305
 
306
- def call(host: nil, prefix: nil, metadata: [], **)
306
+ def call(host: nil, prefix: nil, metadata: [], format: nil, **)
307
307
  base_url = [host, *prefix].join("/")
308
- path = path_identifier(metadata:)
308
+ path = path_identifier(metadata:, format:)
309
309
 
310
310
  if signer
311
311
  url = [base_url, path].join("/")
@@ -318,12 +318,13 @@ class Shrine
318
318
 
319
319
  private
320
320
 
321
- def path_identifier(metadata: [])
322
- [
321
+ def path_identifier(metadata: [], format: nil)
322
+ path = [
323
323
  name,
324
324
  *args,
325
325
  source.urlsafe_dump(metadata:)
326
326
  ].map{|component| Rack::Utils.escape_path(component.to_s)}.join('/')
327
+ format ? "#{path}.#{format}" : path
327
328
  end
328
329
 
329
330
  def query(expires_in: nil,
@@ -386,6 +387,7 @@ class Shrine
386
387
  check_expiry!(request)
387
388
 
388
389
  name, *args, serialized_file = request.path_info.split("/")[1..-1]
390
+ serialized_file = serialized_file.sub(/\.\w+$/, "")
389
391
 
390
392
  name = name.to_sym
391
393
  uploaded_file = shrine_class::UploadedFile.urlsafe_load(serialized_file)
@@ -4,7 +4,7 @@ class Shrine
4
4
  module Plugins
5
5
  # Documentation can be found on https://shrinerb.com/docs/plugins/metadata_attributes
6
6
  module MetadataAttributes
7
- def self.load_dependencies(uploader, *)
7
+ def self.load_dependencies(uploader, **)
8
8
  uploader.plugin :entity
9
9
  end
10
10
 
@@ -49,14 +49,14 @@ class Shrine
49
49
  # "Content-Disposition" headers, whose values are extracted from
50
50
  # metadata. Also returns the correct "Content-Range" header on ranged
51
51
  # requests.
52
- def rack_headers(filename: nil, type: nil, disposition: "inline", range: false)
52
+ def rack_headers(filename: nil, type: nil, disposition: "inline", range: false, etag: nil)
53
53
  {
54
54
  "Content-Length" => content_length(range),
55
55
  "Content-Type" => content_type(type),
56
56
  "Content-Disposition" => content_disposition(disposition, filename),
57
57
  "Content-Range" => content_range(range),
58
58
  "Accept-Ranges" => accept_ranges(range),
59
- "ETag" => etag,
59
+ "ETag" => etag || self.etag,
60
60
  }.compact
61
61
  end
62
62
 
@@ -18,7 +18,7 @@ class Shrine
18
18
 
19
19
  DOWNLOADER = -> (url, **options) { Down.download(url, **options) }
20
20
 
21
- def self.load_dependencies(uploader, *)
21
+ def self.load_dependencies(uploader, **)
22
22
  uploader.plugin :validation
23
23
  end
24
24
 
@@ -32,7 +32,7 @@ class Shrine
32
32
  "%.1f %s" % [bytes.to_f / 1024 ** exp, FILESIZE_UNITS[exp]]
33
33
  end
34
34
 
35
- def self.load_dependencies(uploader, *)
35
+ def self.load_dependencies(uploader, **)
36
36
  uploader.plugin :validation
37
37
  end
38
38
 
@@ -8,7 +8,7 @@ class Shrine
8
8
  module VERSION
9
9
  MAJOR = 3
10
10
  MINOR = 7
11
- TINY = 0
11
+ TINY = 1
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
data/shrine.gemspec CHANGED
@@ -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", RUBY_ENGINE == "jruby" ? "~> 7.0.0" : "~> 8.1"
70
+ gem.add_development_dependency "activesupport", RUBY_ENGINE == "jruby" ? "~> 7.2" : "~> 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" : "~> 8.1"
74
+ gem.add_development_dependency "activerecord", RUBY_ENGINE == "jruby" ? "~> 7.2" : "~> 8.1"
75
75
  gem.add_development_dependency "sqlite3", "~> 2.1" unless RUBY_ENGINE == "jruby"
76
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
@@ -482,6 +482,7 @@ files:
482
482
  - doc/release_notes/3.5.0.md
483
483
  - doc/release_notes/3.6.0.md
484
484
  - doc/release_notes/3.7.0.md
485
+ - doc/release_notes/3.7.1.md
485
486
  - doc/retrieving_uploads.md
486
487
  - doc/securing_uploads.md
487
488
  - doc/storage/file_system.md
@@ -575,7 +576,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
575
576
  - !ruby/object:Gem::Version
576
577
  version: '0'
577
578
  requirements: []
578
- rubygems_version: 4.0.3
579
+ rubygems_version: 3.6.9
579
580
  specification_version: 4
580
581
  summary: Toolkit for file attachments in Ruby applications
581
582
  test_files: []