-
Notifications
You must be signed in to change notification settings - Fork 7
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
Hand duplicate of mime type array to MIME::Types.from_array #12
Conversation
Since from_array uses the array destructively, give it its own private copy to do with it as it pleases.
Please tell me that you're the only project using MIME::Type.from_array. I'm deprecating it in mime-types 2.0 to kill it later. It isn't rich enough to use properly. |
@halostatue Looks like there are a few more that use it: https://github.com/search?l=ruby&q=+MIME%3A%3AType.from_array&ref=cmdform&search_target=global&type=Code I'm happy to switch to whatever method you suggest for adding mime types. Would you prefer us to use |
Yeah, I was seeing that as I was searching. I'm working on getting halostatue/mime-type#41 integrated which puts a lot more emphasis on the richness of the data as part of the 2.0 release I'm prepping. I found this repo because it's marked as depending on mime-types—you have the dependency right with A couple of things that I'll point out looking at
As far as needing to create new types is concerned: MIME::Type.new(content_type) { |t| t.extensions = extensions } would be canonical, but with 2.0 you will also be able to do: MIME::Type.new('content-type' => 'text/plainer', 'extensions' => %w(rb rhtml md markdown)) This is because the default registry data format is now JSON and I serialize to a hash and initialize from the JSON hash. I also support YAML initialization: ---
- ! ruby/object:MIME::Type:
content-type: text/plainer
extensions:
- rb
- rhtml
- md
- markdown I'm deprecating |
Sounds good, I'll update to use |
With respect to the other, mime-types/ruby-mime-types#43 covers what you pointed out. If you have a suggestion for a quick case that matches your use-case and the search you pointed out, I think I can add that (maybe a case where MIME::Types.new(content_type, extensions = nil) does what you expect). |
You've also suggested, without realizing it, mime-types/ruby-mime-types#44. Any other APIs you want? |
@halostatue Nope, that's all I use right now, adding new mime types and extensions to existing ones. Thanks for your work 🤘 |
Version 3.1.2 of heel released. |
## Version 3.1.3 - 2013-11-26 * URL encode the links to files [#14](copiousfreetime/heel#14) * Fix pid file cleanup on ruby 2.0 [#15](copiousfreetime/heel#15) ## Version 3.1.2 - 2013-10-16 * Fix usage of Mime::Types [#12](copiousfreetime/heel#12) [#13](copiousfreetime/heel#13) ## Version 3.1.1 - 2013-09-29 * Fix request logging [#10](copiousfreetime/heel#10)
## Version 3.1.3 - 2013-11-26 * URL encode the links to files [#14](copiousfreetime/heel#14) * Fix pid file cleanup on ruby 2.0 [#15](copiousfreetime/heel#15) ## Version 3.1.2 - 2013-10-16 * Fix usage of Mime::Types [#12](copiousfreetime/heel#12) [#13](copiousfreetime/heel#13) ## Version 3.1.1 - 2013-09-29 * Fix request logging [#10](copiousfreetime/heel#10)
## Version 3.1.3 - 2013-11-26 * URL encode the links to files [#14](copiousfreetime/heel#14) * Fix pid file cleanup on ruby 2.0 [#15](copiousfreetime/heel#15) ## Version 3.1.2 - 2013-10-16 * Fix usage of Mime::Types [#12](copiousfreetime/heel#12) [#13](copiousfreetime/heel#13) ## Version 3.1.1 - 2013-09-29 * Fix request logging [#10](copiousfreetime/heel#10)
Since from_array uses the array destructively, give it its own private
copy to do with it as it pleases.
This fixes #11