{"id":13879031,"url":"https://github.com/discourse/mini_mime","last_synced_at":"2025-10-23T23:34:03.899Z","repository":{"id":44902142,"uuid":"76334905","full_name":"discourse/mini_mime","owner":"discourse","description":"minimal mime type library","archived":false,"fork":false,"pushed_at":"2024-12-30T06:24:39.000Z","size":122,"stargazers_count":99,"open_issues_count":6,"forks_count":34,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-04-08T04:01:39.449Z","etag":null,"topics":["rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/discourse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-13T07:40:02.000Z","updated_at":"2025-04-01T02:01:47.000Z","dependencies_parsed_at":"2024-06-02T19:30:21.287Z","dependency_job_id":"5ee9d415-e976-4a01-906c-34d566532a83","html_url":"https://github.com/discourse/mini_mime","commit_stats":{"total_commits":71,"total_committers":26,"mean_commits":2.730769230769231,"dds":0.647887323943662,"last_synced_commit":"9e77375f2aad5fb6176f786cf5b64d9be75f319b"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmini_mime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmini_mime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmini_mime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmini_mime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discourse","download_url":"https://codeload.github.com/discourse/mini_mime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247912701,"owners_count":21017037,"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":["rubygem"],"created_at":"2024-08-06T08:02:07.472Z","updated_at":"2025-10-23T23:33:58.867Z","avatar_url":"https://github.com/discourse.png","language":"Ruby","readme":"# MiniMime\n\nMinimal mime type implementation for use with the mail and rest-client gem.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mini_mime'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install mini_mime\n\n## Usage\n\n```\nrequire 'mini_mime'\n\nMiniMime.lookup_by_filename(\"a.txt\").content_type\n# =\u003e \"text/plain\"\n\nMiniMime.lookup_by_extension(\"txt\").content_type\n# =\u003e \"text/plain\"\n\nMiniMime.lookup_by_content_type(\"text/plain\").extension\n# =\u003e \"txt\"\n\nMiniMime.lookup_by_content_type(\"text/plain\").binary?\n# =\u003e false\n\n```\n\n## Configuration\n\nIf you'd like to add your own mime types, try using custom database files:\n\n```\nMiniMime::Configuration.ext_db_path = \"path_to_file_extension_db\"\nMiniMime::Configuration.content_type_db_path = \"path_to_content_type_db\"\n```\n\nCheck out the [default databases](lib/db) for proper formatting and structure hints.\n\n## Performance\n\nMiniMime is optimised to minimize memory usage. It keeps a cache of 100 mime type lookups (and 100 misses). There are benchmarks in the [bench directory](https://github.com/discourse/mini_mime/blob/master/bench/bench.rb)\n\n```\nMemory stats for requiring mime/types/columnar\nTotal allocated: 8712144 bytes (98242 objects)\nTotal retained:  3372545 bytes (33599 objects)\n\nMemory stats for requiring mini_mime\nTotal allocated: 42625 bytes (369 objects)\nTotal retained:  8992 bytes (72 objects)\nWarming up --------------------------------------\ncached content_type lookup MiniMime\n                        85.109k i/100ms\ncontent_type lookup MIME::Types\n                        17.879k i/100ms\nCalculating -------------------------------------\ncached content_type lookup MiniMime\n                          1.105M (± 4.1%) i/s -      5.532M in   5.014895s\ncontent_type lookup MIME::Types\n                        193.528k (± 7.1%) i/s -    965.466k in   5.013925s\nWarming up --------------------------------------\nuncached content_type lookup MiniMime\n                         1.410k i/100ms\ncontent_type lookup MIME::Types\n                        18.012k i/100ms\nCalculating -------------------------------------\nuncached content_type lookup MiniMime\n                         14.689k (± 4.2%) i/s -     73.320k in   5.000779s\ncontent_type lookup MIME::Types\n                        193.459k (± 6.9%) i/s -    972.648k in   5.050731s\n```\n\nAs a general guideline, cached lookups are 6x faster than MIME::Types equivalent. Uncached lookups are 10x slower.\n\nNote: It was run on macOS 10.14.2, and versions of Ruby and gems are below.\n\n- Ruby 3.1.0\n- mini_mime (1.0.1)\n- mime-types (3.2.2)\n- mime-types-data (3.2018.0812)\n\n## Development\n\nMiniMime uses the officially maintained list of mime types at [mime-types-data](https://github.com/mime-types/mime-types-data) repo to build the internal database.\n\nTo update the database run:\n\n```ruby\nbundle exec rake rebuild_db\n```\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/discourse/mini_mime. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Fmini_mime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscourse%2Fmini_mime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Fmini_mime/lists"}