From 741bbebe28a1512a6f78cea174e75731de4382fe Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 18 May 2021 18:03:26 +0200 Subject: [PATCH 1/2] Deprecate image format methods This deprecates `landscape_format?`, `portrait_format?` and `square_format` as well as their aliases `landscape?`, `portrait?` and `square?` in favor of the same methods on the `image_file` object Dragonfly provides us. --- app/models/alchemy/picture/transformations.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/alchemy/picture/transformations.rb b/app/models/alchemy/picture/transformations.rb index cdfc416cf7..fcabb0b164 100644 --- a/app/models/alchemy/picture/transformations.rb +++ b/app/models/alchemy/picture/transformations.rb @@ -75,21 +75,30 @@ def resize(size, upsample = false) def landscape_format? image_file.landscape? end + alias_method :landscape?, :landscape_format? + deprecate landscape_format?: "Use image_file.landscape? instead", deprecator: Alchemy::Deprecation + deprecate landscape?: "Use image_file.landscape? instead", deprecator: Alchemy::Deprecation # Returns true if picture's width is smaller than it's height # def portrait_format? image_file.portrait? end + alias_method :portrait?, :portrait_format? + deprecate portrait_format?: "Use image_file.portrait? instead", deprecator: Alchemy::Deprecation + deprecate portrait?: "Use image_file.portrait? instead", deprecator: Alchemy::Deprecation # Returns true if picture's width and height is equal # def square_format? image_file.aspect_ratio == 1.0 end + alias_method :square?, :square_format? + deprecate square_format?: "Use image_file.aspect_ratio instead", deprecator: Alchemy::Deprecation + deprecate square?: "Use image_file.aspect_ratio instead", deprecator: Alchemy::Deprecation # Returns true if the class we're included in has a meaningful render_size attribute # From d6888eca30656be11d27aecdefbc4540292bc97e Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 18 May 2021 18:05:02 +0200 Subject: [PATCH 2/2] Set 6.1 as next deprecation target We want to remove methods earlier. --- lib/alchemy/deprecation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/alchemy/deprecation.rb b/lib/alchemy/deprecation.rb index 9dccf17fbc..344759ab3f 100644 --- a/lib/alchemy/deprecation.rb +++ b/lib/alchemy/deprecation.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Alchemy - Deprecation = ActiveSupport::Deprecation.new("7.0", "Alchemy") + Deprecation = ActiveSupport::Deprecation.new("6.1", "Alchemy") end