From 42642151c55017c8b7850aef16c649c56d5a059c Mon Sep 17 00:00:00 2001 From: Thomas von Deyen <thomas@vondeyen.com> Date: Mon, 15 Jun 2020 15:25:04 +0200 Subject: [PATCH 1/2] Extract picture thumbnail sizes in a constant We want to read those value from other classes and it makes sense to have them formalized in a constant anyway. --- app/helpers/alchemy/admin/pictures_helper.rb | 10 ++++------ app/models/alchemy/picture.rb | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/helpers/alchemy/admin/pictures_helper.rb b/app/helpers/alchemy/admin/pictures_helper.rb index a920f17ecc..d2c5f47cc4 100644 --- a/app/helpers/alchemy/admin/pictures_helper.rb +++ b/app/helpers/alchemy/admin/pictures_helper.rb @@ -4,12 +4,10 @@ module Alchemy module Admin module PicturesHelper def preview_size(size) - case size - when "small" then "80x60" - when "large" then "240x180" - else - "160x120" - end + Alchemy::Picture::THUMBNAIL_SIZES.fetch( + size, + Alchemy::Picture::THUMBNAIL_SIZES[:medium] + ) end end end diff --git a/app/models/alchemy/picture.rb b/app/models/alchemy/picture.rb index c9d5b26d8d..961f14805f 100644 --- a/app/models/alchemy/picture.rb +++ b/app/models/alchemy/picture.rb @@ -22,6 +22,12 @@ module Alchemy class Picture < BaseRecord + THUMBNAIL_SIZES = { + small: "80x60", + medium: "160x120", + large: "240x180", + }.with_indifferent_access.freeze + CONVERTIBLE_FILE_FORMATS = %w(gif jpg jpeg png).freeze include Alchemy::NameConversions From ee69d49c9d2245fcfc032d428a6e856706000024 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen <thomas@vondeyen.com> Date: Tue, 16 Jun 2020 12:25:05 +0200 Subject: [PATCH 2/2] Disable Style/TrailingCommaInArguments check This is conflicting with Rufo --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index f1ea14e8cc..05dd2cc324 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -227,7 +227,7 @@ Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes Style/TrailingCommaInArguments: - EnforcedStyleForMultiline: comma + Enabled: false Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: comma