No commit activity in last 3 years
No release in over 3 years
new implementation of the ancient ruby-filemagic gem. Uses FFI to talk to native library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme
ffiruby-filemagic
=================

Win32 Support? sorry.

A new implementation of the ancient ruby-filemagic gem (http://grub.ath.cx/filemagic/). 

This version uses FFI to talk to the native library (JRuby friendly).

(Blurb from the original gem site follows)

What is FileMagic?

	FileMagic is a Ruby binding to the magic(4) library, which you may know better as the file(1) command. 
	The file command identifies the type of a file using, among other tests, a test for whether the file 
        begins with a certain magic number.

Install:

Make sure you have the magic(4) library installed. 

> sudo gem sources -a http://gems.github.com
> sudo gem install glongman-ffiruby-filemagic

After Install:

> sudo ffi_file_magic_setup
> irb
>> require 'ffi_file_magic'
=> true
>> fm = FFIFileMagic.new(FFIFileMagic::MAGIC_MIME)
=> #<FFIFileMagic:0x11a4d9c @cookie=#<Native Pointer address=0x13606f0>>
>> fm.file('rails.png') #supply a path to your own image
=> "image/png"
>> 

Install Problems?
 
If the gem complains that it can't find the magic library you can run this tool:

> sudo ffi_file_magic_setup

Without any arguments the tool will look around the filesystem for a magic library and test to see if
that library is compatible. If so a small modification will be made so the gem will work.

You can run the tool more than once. 

you can also tell it exactly where to look for the magic libary

> sudo ffi_file_magic_setup --with-magic-lib=/opt/local/lib

This gem has been tested with the magic library shipped with File 4.26 from ftp://ftp.astron.com/pub/file

On OSX, and at the time of writing this, you can get file using macports (http://www.macports.org/)

> sudo port install file

On other Unix variants, download the source, build and install. then run the tool again

COPYRIGHT
=========

Copyright (c) 2009 Overlay TV. See LICENSE for details.