Skip to content
SixArm.com » Ruby » MagicNumberType infers a data type from the data's leading bytes
Ruby HTML
Failed to load latest commit information.
.yardoc Update help Jul 18, 2015
coverage Update help Jul 19, 2015
doc
lib Set linguist documentation in .gitattributes Jul 19, 2015
test Set linguist documentation in .gitattributes Jul 19, 2015
.codeclimate.yml Configure Code Climate May 25, 2015
.document update for ruby 1.9 Jul 4, 2011
.gemtest add gemtest Mar 7, 2011
.gitattributes Set linguist documentation in .gitattributes Jul 19, 2015
.gitignore Add coveralls configuration Jul 18, 2015
.rspec
.travis.yml
CHANGES.md Set linguist documentation in .gitattributes Jul 19, 2015
CONTRIBUTING.md Add contributing file for GitHub Sep 19, 2012
Gemfile Add Gemfile Jul 18, 2015
Gemfile.lock Add Gemfile Jul 19, 2015
LICENSE.md Refactor license to its own file Jul 7, 2015
README.md Set linguist documentation in .gitattributes Jul 19, 2015
Rakefile
VERSION Set linguist documentation in .gitattributes Jul 19, 2015
sixarm_ruby_magic_number_type-2.0.4-sha512.txt Set linguist documentation in .gitattributes Jul 19, 2015
sixarm_ruby_magic_number_type-2.0.4.gem Set linguist documentation in .gitattributes Jul 19, 2015
sixarm_ruby_magic_number_type.gemspec Set linguist documentation in .gitattributes Jul 19, 2015

README.md

SixArm.com » Ruby »
MagicNumberType infers mime types from leading bits

Gem Version Build Status Code Climate Coverage Status

Introduction

Magic numbers are the first bits of a file or data stream which uniquely identify the type of file or data stream.

For example when the first bits are "BM", this identifies the file as a bitmap image file.

For docs go to http://sixarm.com/sixarm_ruby_magic_number_type/doc

Want to help? We're happy to get pull requests.

Install

To install using a Gemfile, add this:

gem "sixarm_ruby_magic_number_type", ">= 2.0.4", "< 3"

To install using the command line, run this:

gem install sixarm_ruby_magic_number_type -v ">= 2.0.4, < 3"

To install using the command line with high security, run this:

wget http://sixarm.com/sixarm.pem
gem cert --add sixarm.pem && gem sources --add http://sixarm.com
gem install sixarm_ruby_magic_number_type -v ">= 2.0.4, < 3" --trust-policy HighSecurity

To require the gem in your code:

require "sixarm_ruby_magic_number_type"

Details

This gem infers based on widespread programming conventions for data file formats.

These magic numbers are by convention and we are using this guide: http://www.astro.keele.ac.uk/oldusers/rno/Computing/File_magic.html

Typical uses of magic numbers:

  • to quickly identify a file's data type
  • to check if data matches the file's MIME type or extension
  • to check if a web form file upload matches its HTTP content type

Compare:

Contributors

Something went wrong with that request. Please try again.