{"id":13747556,"url":"https://github.com/mime-types/ruby-mime-types","last_synced_at":"2025-05-09T09:30:24.642Z","repository":{"id":455982,"uuid":"79712","full_name":"mime-types/ruby-mime-types","owner":"mime-types","description":"Ruby MIME type registry library","archived":false,"fork":false,"pushed_at":"2025-05-07T03:54:05.000Z","size":1895,"stargazers_count":327,"open_issues_count":5,"forks_count":125,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-07T10:04:22.463Z","etag":null,"topics":["mime-types","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mime-types.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"support/benchmarks/load.rb","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"halostatue","buy_me_a_coffee":"halostatue","ko_fi":"halostatue","tidelift":"rubygems/mime-types"}},"created_at":"2008-11-23T01:34:40.000Z","updated_at":"2025-05-07T03:52:44.000Z","dependencies_parsed_at":"2023-07-05T14:56:12.432Z","dependency_job_id":"18123ab4-2009-4231-9c0e-fbaa00d98a55","html_url":"https://github.com/mime-types/ruby-mime-types","commit_stats":{"total_commits":361,"total_committers":59,"mean_commits":6.11864406779661,"dds":"0.46537396121883656","last_synced_commit":"5dc1b9117e53cef93b5b46c19fbb4dd00bf80bab"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mime-types%2Fruby-mime-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mime-types%2Fruby-mime-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mime-types%2Fruby-mime-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mime-types%2Fruby-mime-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mime-types","download_url":"https://codeload.github.com/mime-types/ruby-mime-types/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253056116,"owners_count":21846695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mime-types","ruby"],"created_at":"2024-08-03T06:01:33.423Z","updated_at":"2025-05-09T09:30:24.628Z","avatar_url":"https://github.com/mime-types.png","language":"Ruby","funding_links":["https://github.com/sponsors/halostatue","https://buymeacoffee.com/halostatue","https://ko-fi.com/halostatue","https://tidelift.com/funding/github/rubygems/mime-types"],"categories":["Ruby"],"sub_categories":[],"readme":"# mime-types for Ruby\n\n- home :: https://github.com/mime-types/ruby-mime-types/\n- issues :: https://github.com/mime-types/ruby-mime-types/issues\n- code :: https://github.com/mime-types/ruby-mime-types/\n- rdoc :: http://rdoc.info/gems/mime-types/\n- changelog ::\n  https://github.com/mime-types/ruby-mime-types/blob/main/CHANGELOG.md\n- continuous integration :: [![Build Status][ci-badge]][ci-workflow]\n- test coverage :: [![Coverage][coveralls-badge]][coveralls]\n\n## Description\n\nThe mime-types library provides a library and registry for information about\nMIME content type definitions. It can be used to determine defined filename\nextensions for MIME types, or to use filename extensions to look up the likely\nMIME type definitions.\n\nVersion 3.0 is a major release that requires Ruby 2.0 compatibility and removes\ndeprecated functions. The columnar registry format introduced in 2.6 has been\nmade the primary format; the registry data has been extracted from this library\nand put into [mime-types-data][data]. Additionally, mime-types is now licensed\nexclusively under the MIT licence and there is a code of conduct in effect.\nThere are a number of other smaller changes described in the History file.\n\n### About MIME Media Types\n\nMIME content types are used in MIME-compliant communications, as in e-mail or\nHTTP traffic, to indicate the type of content which is transmitted. The\nmime-types library provides the ability for detailed information about MIME\nentities (provided as an enumerable collection of MIME::Type objects) to be\ndetermined and used. There are many types defined by RFCs and vendors, so the\nlist is long but by definition incomplete; don't hesitate to add additional type\ndefinitions. MIME type definitions found in mime-types are from RFCs, W3C\nrecommendations, the [IANA Media Types registry][registry], and user\ncontributions. It conforms to RFCs 2045 and 2231.\n\n### mime-types 3.x\n\nUsers are encouraged to upgrade to mime-types 3.x as soon as is practical.\nmime-types 3.x requires Ruby 2.0 compatibility and a simpler licensing scheme.\n\n## Synopsis\n\nMIME types are used in MIME entities, as in email or HTTP traffic. It is useful\nat times to have information available about MIME types (or, inversely, about\nfiles). A MIME::Type stores the known information about one MIME type.\n\n```ruby\nrequire 'mime/types'\n\nplaintext = MIME::Types['text/plain'] # =\u003e [ text/plain ]\ntext = plaintext.first\nputs text.media_type            # =\u003e 'text'\nputs text.sub_type              # =\u003e 'plain'\n\nputs text.extensions.join(' ')  # =\u003e 'txt asc c cc h hh cpp hpp dat hlp'\nputs text.preferred_extension   # =\u003e 'txt'\nputs text.friendly              # =\u003e 'Text Document'\nputs text.i18n_key              # =\u003e 'text.plain'\n\nputs text.encoding              # =\u003e quoted-printable\nputs text.default_encoding      # =\u003e quoted-printable\nputs text.binary?               # =\u003e false\nputs text.ascii?                # =\u003e true\nputs text.obsolete?             # =\u003e false\nputs text.registered?           # =\u003e true\nputs text.provisional?          # =\u003e false\nputs text.complete?             # =\u003e true\n\nputs text                       # =\u003e 'text/plain'\n\nputs text == 'text/plain'       # =\u003e true\nputs 'text/plain' == text       # =\u003e true\nputs text == 'text/x-plain'     # =\u003e false\nputs 'text/x-plain' == text     # =\u003e false\n\nputs MIME::Type.simplified('x-appl/x-zip') # =\u003e 'x-appl/x-zip'\nputs MIME::Type.i18n_key('x-appl/x-zip') # =\u003e 'x-appl.x-zip'\n\nputs text.like?('text/x-plain') # =\u003e true\nputs text.like?(MIME::Type.new('x-text/x-plain')) # =\u003e true\n\nputs text.xrefs.inspect # =\u003e { \"rfc\" =\u003e [ \"rfc2046\", \"rfc3676\", \"rfc5147\" ] }\nputs text.xref_urls # =\u003e [ \"http://www.iana.org/go/rfc2046\",\n                    #      \"http://www.iana.org/go/rfc3676\",\n                    #      \"http://www.iana.org/go/rfc5147\" ]\n\nxtext = MIME::Type.new('x-text/x-plain')\nputs xtext.media_type # =\u003e 'text'\nputs xtext.raw_media_type # =\u003e 'x-text'\nputs xtext.sub_type # =\u003e 'plain'\nputs xtext.raw_sub_type # =\u003e 'x-plain'\nputs xtext.complete? # =\u003e false\n\nputs MIME::Types.any? { |type| type.content_type == 'text/plain' } # =\u003e true\nputs MIME::Types.all?(\u0026:registered?) # =\u003e false\n\n# Various string representations of MIME types\nqcelp = MIME::Types['audio/QCELP'].first # =\u003e audio/QCELP\nputs qcelp.content_type         # =\u003e 'audio/QCELP'\nputs qcelp.simplified           # =\u003e 'audio/qcelp'\n\nxwingz = MIME::Types['application/x-Wingz'].first # =\u003e application/x-Wingz\nputs xwingz.content_type        # =\u003e 'application/x-Wingz'\nputs xwingz.simplified          # =\u003e 'application/x-wingz'\n```\n\n### Columnar Store\n\nmime-types uses as its primary registry storage format a columnar storage format\nreducing the default memory footprint. This is done by selectively loading the\ndata on a per-attribute basis. When the registry is first loaded from the\ncolumnar store, only the canonical MIME content type and known extensions and\nthe MIME type will be connected to its loading registry. When other data about\nthe type is required (including `preferred_extension`, `obsolete?`, and\n`registered?`) that data is loaded from its own column file for all types in the\nregistry.\n\nThe load of any column data is performed with a Mutex to ensure that types are\nupdated safely in a multithreaded environment. Benchmarks show that while\ncolumnar data loading is slower than the JSON store, it cuts the memory use by a\nthird over the JSON store.\n\nIf you prefer to load all the data at once, this can be specified in your\napplication Gemfile as:\n\n```ruby\ngem 'mime-types', require: 'mime/types/full'\n```\n\nProjects that do not use Bundler should `require` the same:\n\n```ruby\nrequire 'mime/types/full'\n```\n\nLibraries that use mime-types are discouraged from choosing the JSON store.\n\nFor applications and clients that used mime-types 2.6 when the columnar store\nwas introduced, the require used previously will still work through at least\n[version 4][pull-96-comment] and possibly beyond; it is effectively an empty\noperation. You are recommended to change your Gemfile as soon as is practical.\n\n```ruby\nrequire 'mime/types/columnar'\n```\n\nNote that MIME::Type::Columnar and MIME::Types::Columnar are considered private\nvariant implementations of MIME::Type and MIME::Types and the specific\nimplementation should not be relied upon by consumers of the mime-types library.\nInstead, depend on the public implementations (MIME::Type and MIME::Types) only.\n\n### Cached Storage\n\nmime-types supports a cache of MIME types using `Marshal.dump`. The cache is\ninvalidated for each version of the mime-types-data gem so that data version\n3.2015.1201 will not be reused with data version 3.2016.0101. If the environment\nvariable `RUBY_MIME_TYPES_CACHE` is set to a cache file, mime-types will attempt\nto load the MIME type registry from the cache file. If it cannot, it will load\nthe types normally and then saves the registry to the cache file.\n\nThe caching works with both full stores and columnar stores. Only the data that\nhas been loaded prior to saving the cache will be stored.\n\n## mime-types Modified Semantic Versioning\n\nThe mime-types library has one version number, but this single version number\ntracks both API changes and registry data changes; this is not wholly compatible\nwith all aspects of [Semantic Versioning][semver]; removing a MIME type from the\nregistry _could_ be considered a breaking change under some interpretations of\nsemantic versioning (as lookups for that particular type would no longer work by\ndefault).\n\nmime-types itself uses a modified semantic versioning scheme. Given the version\n`MAJOR.MINOR`:\n\n1. If an incompatible API (code) change is made, the `MAJOR` version will be\n   incremented and both `MINOR` and `PATCH` will be set to zero. Major version\n   updates will also generally break Ruby version compatibility guarantees.\n\n2. If an API (code) feature is added that does not break compatibility, the\n   `MINOR` version will be incremented and `PATCH` will be set to zero.\n\n3. If there is a bug fix to a feature added in the most recent `MAJOR.MINOR`\n   release, the `PATCH` value will be incremented.\n\nIn practical terms, there will be fewer releases of mime-types focussing on\nfeatures because of the existence of the [mime-types-data][data] gem, and if\nfeatures are marked deprecated in the course of mime-types 3.x, they will not be\nremoved until mime-types 4.x or possibly later.\n\n[pull-96-comment]: https://github.com/mime-types/ruby-mime-types/pull/96#issuecomment-100725400\n[semver]: https://semver.org\n[data]: https://github.com/mime-types/mime-types-data\n[ci-badge]: https://github.com/mime-types/ruby-mime-types/actions/workflows/ci.yml/badge.svg\n[ci-workflow]: https://github.com/mime-types/ruby-mime-types/actions/workflows/ci.yml\n[coveralls-badge]: https://coveralls.io/repos/mime-types/ruby-mime-types/badge.svg?branch=main\u0026service=github\n[coveralls]: https://coveralls.io/github/mime-types/ruby-mime-types?branch=main\n[registry]: https://www.iana.org/assignments/media-types/media-types.xhtml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmime-types%2Fruby-mime-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmime-types%2Fruby-mime-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmime-types%2Fruby-mime-types/lists"}