Is there a file-type detection script available for Ruby, similar to 
the unix 'file' program? At a minimum, is there a way in Ruby to 
reliably tell the difference between a binary file format and a text 
file format?

I'm working on a script which will run 'tidy' recursively against all 
files in a directory structure -- but it should only run on files 
which are not binary. (I use a Windows-based CMS, City Desk, that 
doesn't do XHTML; I'm going to use Tidy to convert the non-XHTML 
parts to XHTML during the publish process.)

I don't want to make the detection extension-based, as there's 
already a wide variety of possible extensions that could be used 
(most of them outside of my own application, but I plan on making 
this publicly available, possibly with a Ruby-ized Tidy) -- from htm 
and html to cfm and asp to xml and css.

Ideally, I'd be able to come up with a MIME-type for the file and 
create callbacks based on the MIME-type and/or extension (I may wish 
to make an HTML-fragment which calls Tidy with the show-body-only 
option set).

I can get my local version working easily -- it's predictable. I'm 
just looking at doing this in a "larger" way...

-austin
-- Austin Ziegler, austin / halostatue.ca on 2002.10.05 at 01.36.45