Path: | README.rdoc |
Last Update: | Sat Apr 20 14:56:34 +0000 2013 |
home : | mime-types.rubyforge.org/ |
code : | github.com/halostatue/mime-types/ |
bugs : | github.com/halostatue/mime-types/issues |
rdoc : | mime-types.rubyforge.org/ |
This library allows for the identification of a file‘s likely MIME content type. This is release 1.21 with new MIME types. The identification of MIME content type is based on a file‘s filename extensions.
MIME types are used in MIME-compliant communications, as in e-mail or HTTP traffic, to indicate the type of content which is transmitted. MIME::Types provides the ability for detailed information about MIME entities (provided as a set of MIME::Type objects) to be determined and used programmatically. There are many types defined by RFCs and vendors, so the list is long but not complete; don‘t hesitate to ask to add additional information. This library follows the IANA collection of MIME types (see below for reference).
MIME::Types for Ruby was originally based on and synchronized with MIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. As of version 1.15, the data format for the MIME::Type list has changed and the synchronization will no longer happen.
MIME::Types is built to conform to the MIME types of RFCs 2045 and 2231. It follows the official IANA registry (ftp) with some unofficial types added from the the LTSW collection.
MIME types are used in MIME entities, as in email or HTTP traffic. It is useful at times to have information available about MIME types (or, inversely, about files). A MIME::Type stores the known information about one MIME type.
require 'mime/types' plaintext = MIME::Types['text/plain'] print plaintext.media_type # => 'text' print plaintext.sub_type # => 'plain' puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp' puts plaintext.encoding # => 8bit puts plaintext.binary? # => false puts plaintext.ascii? # => true puts plaintext.obsolete? # => false puts plaintext.registered? # => true puts plaintext == 'text/plain' # => true puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
I value any contribution to MIME::Types you can provide: a bug report, a feature request, or code contributions.
Code contributions to MIME::Types are especially <del>welcome</del>encouraged. Because MIME::Types is a complex codebase, there are a few guidelines:
To run the test suite, you will need to install the development dependencies for MIME::Types. If you have Bundler, you can accomplish this easily:
$ bundle install
MIME::Types uses Ryan Davis’s excellent Hoe to manage the release process, and it adds a number of rake tasks. You will mostly be interested in:
$ rake
which runs the tests the same way that:
$ rake test $ rake travis
will do.
Here‘s the most direct way to get your work merged into the project:
Thanks to everyone else who has contributed to MIME::Types:
This software is available under three licenses: the GNU GPL version 2 (or at your option, a later version), the Perl Artistic license, or the MIT license. Note that my preference for licensing is the MIT license, but the original Perl MIME::Types was dually originally licensed with the Perl Artistic and the GNU GPL ("the same terms as Perl itself") and given that the Ruby implementation hewed pretty closely to the Perl version, I must maintain the additional licensing terms.
this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See the file docs/artistic.txt in the main distribution.
See the file docs/COPYING.txt in the main distribution.