https://github.com/mimemagicrb/mimemagic
Mime type detection in ruby via file extension or file content
https://github.com/mimemagicrb/mimemagic
Keywords from Contributors
activejob activerecord mvc rubygems crash-reporting sinatra rspec static-code-analysis code-formatter rubocop
Last synced: about 21 hours ago
JSON representation
Repository metadata
Mime type detection in ruby via file extension or file content
- Host: GitHub
- URL: https://github.com/mimemagicrb/mimemagic
- Owner: mimemagicrb
- License: mit
- Created: 2009-05-09T21:00:15.000Z (almost 17 years ago)
- Default Branch: master
- Last Pushed: 2023-11-20T14:52:17.000Z (over 2 years ago)
- Last Synced: 2026-02-27T04:34:41.463Z (5 days ago)
- Language: Ruby
- Homepage: https://github.com/mimemagicrb/mimemagic
- Size: 1.24 MB
- Stars: 424
- Watchers: 14
- Forks: 438
- Open Issues: 32
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
README.md
MimeMagic is a library to detect the mime type of a file by extension or by content. It uses the mime database
provided by freedesktop.org (see http://freedesktop.org/wiki/Software/shared-mime-info/).
Dependencies
You will require a copy of the Freedesktop.org shared-mime-info database to be available. If you're on Linux,
it's probably available via your package manager, and will probably be in the location it's being looked for
when the gem is installed.
macOS users can install the database via Homebrew with brew install shared-mime-info.
Should you be unable to use a package manager you can obtain a copy of the needed file by extracting it from
the Debian package. This process will also work on a Windows machine.
- Download the package from https://packages.debian.org/sid/amd64/shared-mime-info/download
- Ensure the command line version of 7-Zip is installed
7z x -so shared-mime-info_2.0-1_amd64.deb data.tar | 7z e -sidata.tar "./usr/share/mime/packages/freedesktop.org.xml"
Place the file freedesktop.org.xml in an appropriate location, and then set the environment variable
FREEDESKTOP_MIME_TYPES_PATH to that path. Once that has been done the gem should install successfully. Please
note that the gem will depend upon the file remaining in that location at run time.
Usage
require 'mimemagic'
MimeMagic.by_extension('html').text?
MimeMagic.by_extension('.html').child_of? 'text/plain'
MimeMagic.by_path('filename.txt')
MimeMagic.by_magic(File.open('test.html'))
# etc...
You can add your own magic with MimeMagic.add.
API
http://www.rubydoc.info/github/mimemagicrb/mimemagic
Tests
$ bundle install
$ bundle exec rake test
Authors
- Daniel Mendler
- Jon Wood
- MimeMagic Contributors
LICENSE
{file:LICENSE MIT}
Owner metadata
- Name: MimeMagic
- Login: mimemagicrb
- Email:
- Kind: organization
- Description: Fast mime detection by extension or content in pure ruby (Uses freedesktop.org.xml shared-mime-info database)
- Website: https://rubygems.org/gems/mimemagic
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/81365835?v=4
- Repositories: 1
- Last ynced at: 2024-03-25T18:39:32.526Z
- Profile URL: https://github.com/mimemagicrb
GitHub Events
Total
- Pull request event: 1
- Fork event: 2
- Watch event: 7
- Issue comment event: 1
Last Year
- Pull request event: 1
- Fork event: 1
- Watch event: 3
- Issue comment event: 1
Committers metadata
Last synced: 3 days ago
Total Commits: 143
Total Committers: 32
Avg Commits per committer: 4.469
Development Distribution Score (DDS): 0.594
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Daniel Mendler | m****l@d****e | 58 |
| Jon Wood | j****n@b****t | 29 |
| Daniel Mendler | m****d@s****e | 5 |
| minad | d****r@w****e | 5 |
| Janko Marohnić | j****c@g****m | 4 |
| Olle Jonsson | o****n@g****m | 4 |
| Ian Young | i****f@g****m | 3 |
| Jun Aruga | j****a@r****m | 3 |
| Rob Cherry | r****y@r****m | 3 |
| Ali Ismayilov | a****i@i****o | 2 |
| Kenichi Kamiya | k****1@g****m | 2 |
| Oleg | o****g@k****a | 2 |
| Stephen Pike | s****e@s****t | 2 |
| wbond | w****l@w****t | 2 |
| f****t@p****m | 2 | |
| Jacques Crocker | r****i@g****m | 1 |
| Andrew Haines | a****w@h****z | 1 |
| Christopher Pfohl | C****l@g****m | 1 |
| Cédric Boutillier | b****l@d****g | 1 |
| Gurusamy Sarathy | g****2@g****m | 1 |
| Jared Beck | j****d@j****m | 1 |
| Jordan Thoms | j****n@t****z | 1 |
| Justin Coyne | j****e@j****m | 1 |
| Larry Kyrala | l****a@g****m | 1 |
| Masataka Pocke Kuwabara | k****a@p****e | 1 |
| Mathieu Mahé | m****e@g****m | 1 |
| Nick LaMuro | n****o@g****m | 1 |
| Rosa Gutierrez | r****a@r****t | 1 |
| Scott Bronson | b****t@r****m | 1 |
| Stanisław Pitucha | s****a@e****m | 1 |
| and 2 more... | ||
Committer domains:
- ill-logic.com: 1
- envato.com: 1
- rinspin.com: 1
- rosapolis.net: 1
- pocke.me: 1
- justincoyne.com: 1
- thoms.net.nz: 1
- jaredbeck.com: 1
- debian.org: 1
- haines.org.nz: 1
- praslov.com: 1
- wbond.net: 1
- scpike.net: 1
- khabarov.ca: 1
- ismailov.info: 1
- reverbnation.com: 1
- redhat.com: 1
- wurzelteiler.de: 1
- slizer.hadiko.de: 1
- blankpad.net: 1
- daniel-mendler.de: 1
Issue and Pull Request metadata
Last synced: 9 days ago
Total issues: 57
Total pull requests: 50
Average time to close issues: 7 months
Average time to close pull requests: 2 months
Total issue authors: 56
Total pull request authors: 36
Average comments per issue: 3.3
Average comments per pull request: 2.12
Merged pull request: 20
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 2
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 2
Past year average comments per issue: 0
Past year average comments per pull request: 0.0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- doriantaylor (2)
- toastal (1)
- gmcquistin (1)
- bjnord (1)
- junaruga (1)
- HoneyryderChuck (1)
- errm (1)
- gr8bit (1)
- akiko-pusu (1)
- keeguon (1)
- elliotcm (1)
- makyen (1)
- nflorentin (1)
- codeface (1)
- Silex (1)
Top Pull Request Authors
- olleolleolle (5)
- haines (3)
- junaruga (3)
- GBH (2)
- raphox (2)
- aliismayilov (2)
- joshheinrichs-shopify (2)
- dillonwelch (2)
- benkoshy (2)
- kachick (2)
- epitron (2)
- brlanier (1)
- coldnebo (1)
- atambo (1)
- jcoyne (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 6
-
Total downloads:
- rubygems: 373,571,410 total
- Total docker downloads: 159,339,034
- Total dependent packages: 194 (may contain duplicates)
- Total dependent repositories: 210,567 (may contain duplicates)
- Total versions: 24
- Total maintainers: 2
gem.coop: mimemagic
Fast mime detection by extension or content (Uses freedesktop.org.xml shared-mime-info database)
- Homepage: https://github.com/mimemagicrb/mimemagic
- Documentation: http://www.rubydoc.info/gems/mimemagic/
- Licenses: MIT
- Latest release: 0.4.3 (published almost 5 years ago)
- Last Synced: 2026-03-01T13:33:04.172Z (2 days ago)
- Versions: 7
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 186,786,360 Total
- Docker Downloads: 79,669,517
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Downloads: 0.128%
- Average: 0.172%
- Docker downloads count: 0.561%
- Maintainers (2)
rubygems.org: mimemagic
Fast mime detection by extension or content (Uses freedesktop.org.xml shared-mime-info database)
- Homepage: https://github.com/mimemagicrb/mimemagic
- Documentation: http://www.rubydoc.info/gems/mimemagic/
- Licenses: MIT
- Latest release: 0.4.3 (published almost 5 years ago)
- Last Synced: 2026-03-01T12:01:42.556Z (2 days ago)
- Versions: 7
- Dependent Packages: 194
- Dependent Repositories: 210,567
- Downloads: 186,785,050 Total
- Docker Downloads: 79,669,517
-
Rankings:
- Dependent repos count: 0.095%
- Downloads: 0.104%
- Dependent packages count: 0.193%
- Docker downloads count: 0.766%
- Average: 0.87%
- Forks count: 1.275%
- Stargazers count: 2.787%
- Maintainers (2)
proxy.golang.org: github.com/mimemagicrb/mimemagic
- Homepage:
- Documentation: https://pkg.go.dev/github.com/mimemagicrb/mimemagic#section-documentation
- Licenses: mit
- Latest release: v0.4.3 (published almost 5 years ago)
- Last Synced: 2026-02-27T22:03:16.178Z (4 days ago)
- Versions: 7
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Forks count: 1.39%
- Stargazers count: 2.831%
- Average: 6.15%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
debian-13: ruby-mimemagic
- Homepage: https://github.com/mimemagicrb/mimemagic
- Documentation: https://packages.debian.org/trixie/ruby-mimemagic
- Licenses:
- Latest release: 0.4.3-2 (published 19 days ago)
- Last Synced: 2026-02-13T13:17:28.717Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- github-markup >= 0
- redcarpet >= 0
- yard >= 0
- minitest ~> 5.14 development
- nokogiri ~> 1
- rake >= 0
Score: 29.682489859553506