3.1.0.md

doc/release_notes/3.1.0.md
Last Update: 2023-07-30 18:26:06 +0200

title: Shrine 3.1.0

New features

  • The Attacher#create_derivatives method now accepts a :storage option for specifying the storage to which derivatives should be uploaded.

“‘rb # with attachment module photo.image_derivatives!(storage: :other_store)

# with attacher attacher.create_derivatives(storage: :other_store) “‘

  • The Shrine.calculate_signature now accepts a :rewind boolean option for choosing whether the IO object should be rewinded after reading. This is useful if you want to calculate signature from non-rewindable IO objects, such as IO.pipe, Socket, non-rewindable Down::ChunkedIO etc.

rb Shrine.signature(io, rewind: false)

Improvements

  • The derivatives processor can now be registered with Attacher.derivatives, which is just an alias for Attacher.derivatives_processor.

“‘rb class ImageUploader < Shrine Attacher.derivatives_processor do |original| # … end end

# can now be written as

class ImageUploader < Shrine Attacher.derivatives do |original| # … end end “‘

  • The Attacher#cached? and Attacher#stored? methods now work correctly if temporary/permanent storage identifiers were specified as strings.

  • The store_dimensions plugin now properly propagates exceptions when loading the ruby-vips gem in :vips analyzer.

  • The add_metadata plugin now respects inheritance again when defining metadata methods on the Shrine::UploadedFile class. In 2.19.0, the add_metadata plugin was changed to define metadata methods on the internal FileMethods plugin module, which is shared across all uploaders. This change has now been reverted.

Backwards compatibility

  • The Attacher#cache_key and Attacher#store_key methods now always return symbol keys, even if the storage key that was specified was a string key.

rb attacher = Shrine::Attacher.new(cache: "cache", store: "store") attacher.cache_key #=> :cache (previously "cache") attacher.store_key #=> :store (previously "store")

  • The add_metadata plugin now defines metadata methods directly on the UploadedFile class, which means that if you happen to have been overriding these metadata methods and calling super, this won’t work anymore.