-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Marcel::Magic.new(content_type).extensions instead of Marcel::TYPES[content_type] #2728
Conversation
Not sure why, but this PR is getting the following failure in the ruby-head tests for
Doesn't seem to be related to these changes, but flagging anyway. |
@schinery the test failure in ruby-head is because of https://bugs.ruby-lang.org/issues/16495 In spec/processing/rmagick_spec.rb line 258, change: /private method `foo=' called/ to: /private method .foo=. called/ That will handle the quoting change. |
@BrianHawley that did the trick 👍🏻 |
I would vote not not move from one private constant to another |
mime_type = Marcel::TYPES[content_type] | ||
unless File.extname(filename).present? || mime_type.blank? | ||
extension = mime_type[0].first | ||
extensions = Marcel::TYPE_EXTS[content_type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extensions = Marcel::TYPE_EXTS[content_type] | |
extensions = Marcel::Magic.new(content_type).extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is much nicer 😄
carrierwave.gemspec
Outdated
@@ -23,7 +23,7 @@ Gem::Specification.new do |s| | |||
s.add_dependency "activesupport", ">= 6.0.0" | |||
s.add_dependency "activemodel", ">= 6.0.0" | |||
s.add_dependency "image_processing", "~> 1.1" | |||
s.add_dependency "marcel", "~> 1.0.0" | |||
s.add_dependency "marcel", "~> 1.0.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new code change, you don't need to make this version change, because the code is supported as far back as version 1.0.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted this change 👍🏻
Nice work everyone! |
Thank you for the fix! |
Use Marcel::Magic.new(content_type).extensions instead of Marcel::TYPES[content_type]
@mshibuya any chance for a new release soon? |
This commit of the Marcel gem, which has just shipped in version 1.0.3, breaks Carrierwave as the
Marcel::TYPES
constant used here has been removed.This PR is to switch to using
Marcel::Magic.new(content_type).extensions
to return the extensions and not use constants.