ruby-filemagic
ruby-filemagic copied to clipboard
Ruby FileMagic Library Bindings
= Ruby FileMagic Library Binding
== Summary
ruby-filemagic provides a ruby binding to GNU libmagic.
== Prerequisites
GNU file package to provide libmagic (tested with 5.04). On Debian-like Linux systems this is provided by package libmagic-dev. For Solaris systems sunfreeware.com provides package SMCfile.
== Build and install
To build either:
rake build
or run:
ruby extconf.rb
make
To install (non-gem) either:
rake install
or run:
make install
== Gem
To create a gem, build as above then either:
rake gem
or run:
gem build ruby-filemagic.gemspec
== Tests
Note that tests may fail if you have a different version of libmagic since the file content descriptive text may vary slightly. For example, a plain file gives these differing results:
libmagic v5.04: text/plain; charset=us-ascii libmagic v4.26: text/plain charset=us-ascii
To run the unit tests:
rake test
or run:
ruby test/regress.rb
== Examples
require 'filemagic'
magic = FileMagic.new
puts magic.file('/tmp/foo')
magic.close
== Copying
The filemagic extension library is copywrited free software by Travis Whitton [email protected]. You can redistribute it under the terms specified in the COPYING file of the Ruby distribution.
== WARRANTY
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.