https://github.com/przbadu/mimemagicrb
Restored version of mimemagicrb 0.3.0
https://github.com/przbadu/mimemagicrb
Last synced: about 1 month ago
JSON representation
Restored version of mimemagicrb 0.3.0
- Host: GitHub
- URL: https://github.com/przbadu/mimemagicrb
- Owner: przbadu
- License: mit
- Created: 2021-03-29T09:08:46.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-29T10:42:59.000Z (about 4 years ago)
- Last Synced: 2025-02-14T22:47:43.976Z (3 months ago)
- Language: Ruby
- Size: 339 KB
- Stars: 0
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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/).[](http://travis-ci.org/minad/mimemagic) [](https://codeclimate.com/github/minad/mimemagic)
[](https://www.gittip.com/min4d/ "Donate weekly to this project using Gittip")
[](https://flattr.com/submit/auto?user_id=min4d&url=https://github.com/minad/mimemagic&title=MimeMagic&language=&tags=github&category=software)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...Extra magic overlay
=====Microsoft Office 2007+ formats (xlsx, docx, and pptx) are not supported by the mime database at freedesktop.org. These files are all zipped collections of xml files and will be detected as "application/zip". Mimemagic comes with extra magic you can overlay on top of the defaults to correctly detect these file types. Enable it like this:
require 'mimemagic'
require 'mimemagic/overlay'
MimeMagic.by_magic(File.open('test.xlsx'))You can add your own magic with `MimeMagic.add`. See `lib/mimemagic/overlay.rb`.
API
===http://rdoc.info/github/minad/mimemagic/frames/file/README.md
Tests
=====```
bundle installrake test
```Authors
=======Daniel Mendler