-
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
Read Content type from cached and uploaded file. #1245
Conversation
I like this solution. |
What about deprecating the old behavior? At this point anyone using the existing module will get a |
We can re-add the MimeTypes module and puts a Deprecation warning but it seems useless… |
Yes, we definitely need to deprecate for one 0.x release. We're not yet held to sem-ver in pre-1.0, but I don't want to needlessly break stuff. This should be in addition to upgrade notes in the readme/wiki. |
I'm with @bensie for the deprecation warning. |
I rewrote my commit to keep MimeTypes module and puts a deprecation warning if someone use it. |
@@ -27,6 +27,7 @@ module MimeTypes | |||
extend ActiveSupport::Concern | |||
|
|||
included do | |||
puts "WARNING: Carrierwave::MimeTypes is deprecated" |
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.
Let's use ActiveSupport::Deprecation
for this.
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.
Ok, but i don't know the "deprecation horizon" version.
I've set the Mime::Types deprecation to 1.0, but feel free to update the version. |
@@ -27,6 +27,7 @@ module MimeTypes | |||
extend ActiveSupport::Concern | |||
|
|||
included do | |||
ActiveSupport::Deprecation.new "1.0", "Carrierwave::MimeTypes" |
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.
Add the missing require 'activesupport/deprecation'
and set the horizon to 0.11.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.
Done, s/activesupport/active_support
@bensie thanks for the review 😘 |
Thanks for cranking out the changes so quick! |
# [String] content type of the file | ||
# | ||
def content_type | ||
file.try(: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.
Probably should just use respond_to?
here -- if you really want Object#try
you need to require "active_support/core_ext/object"
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.
Is Object#try
used in another place in carrierwave ? If not, using respond_to?
seems better.
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.
Nope, it's not.
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.
ok, let's use respond_to?
Read Content type from cached and uploaded file.
Good to go -- thanks! |
😤 |
So nice. 💎 |
Uh oh -- we might not be there just yet... |
@bensie we should use warn method for activesupport < 4.0 |
Thanks for stepping in and making this happen @bensie! |
Since carrierwaveuploader#1245, CarrierWave::MimeTypes module is redundant as `mime-types` gem is a runtime dependency now, and `SanitizedFile` gets it's content_type using it. The module was deprecated since 0.10 and warned developers when used it.
Since carrierwaveuploader#1245, CarrierWave::MimeTypes module is redundant as `mime-types` gem is a runtime dependency now, and `SanitizedFile` gets it's content_type using it. The module was deprecated since 0.10 and warned developers when used it.
Since carrierwaveuploader#1245 (*), CarrierWave::MimeTypes module is redundant as `mime-types` gem is a runtime dependency now, and `SanitizedFile` gets it's content_type using it. The module was deprecated since 0.10 and warned developers when used it. (*) I discovered this when tried to fix specs marked as pending. I looked at commits history and PRs to understand what happened. It started with carrierwaveuploader#372 that added `CarrierWave::MimeTypes` processor (Jun 2011), then carrierwaveuploader#1216 and carrierwaveuploader#1245 that made `mime-types` a runtime dependency and deprecated `CarrierWave::MimeTypes` module (2013), and finally carrierwaveuploader#1584 `CarrierWave::MagicMimeTypes` (2015)
Since carrierwaveuploader#1245 (*), CarrierWave::MimeTypes module is redundant as `mime-types` gem is a runtime dependency now, and `SanitizedFile` gets it's content_type using it. The module was deprecated since 0.10 and warned developers when used it. (*) I discovered this when tried to fix specs marked as pending. I looked at commits history and PRs to understand what happened. It started with carrierwaveuploader#372 that added `CarrierWave::MimeTypes` processor (Jun 2011), then carrierwaveuploader#1216 and carrierwaveuploader#1245 that made `mime-types` a runtime dependency and deprecated `CarrierWave::MimeTypes` module (2013), and finally carrierwaveuploader#1584 `CarrierWave::MagicMimeTypes` (2015)
Since carrierwaveuploader#1245 (*), CarrierWave::MimeTypes module is redundant as `mime-types` gem is a runtime dependency now, and `SanitizedFile` gets it's content_type using it. The module was deprecated since 0.10 and warned developers when used it. (*) I discovered this when tried to fix specs marked as pending. I looked at commits history and PRs to understand what happened. It started with carrierwaveuploader#372 that added `CarrierWave::MimeTypes` processor (Jun 2011), then carrierwaveuploader#1216 and carrierwaveuploader#1245 that made `mime-types` a runtime dependency and deprecated `CarrierWave::MimeTypes` module (2013), and finally carrierwaveuploader#1584 `CarrierWave::MagicMimeTypes` (2015)
Since carrierwaveuploader#1245 (*), CarrierWave::MimeTypes module is redundant as `mime-types` gem is a runtime dependency now, and `SanitizedFile` gets it's content_type using it. The module was deprecated since 0.10 and warned developers when used it. (*) I discovered this when tried to fix specs marked as pending. I looked at commits history and PRs to understand what happened. It started with carrierwaveuploader#372 that added `CarrierWave::MimeTypes` processor (Jun 2011), then carrierwaveuploader#1216 and carrierwaveuploader#1245 that made `mime-types` a runtime dependency and deprecated `CarrierWave::MimeTypes` module (2013), and finally carrierwaveuploader#1584 `CarrierWave::MagicMimeTypes` (2015)
Rework Pull Request #1216 into a single commit.