Giter Club home page Giter Club logo

ruby-filemagic's Introduction

= FileMagic Library Binding

== VERSION

This documentation refers to filemagic version 0.7.0


== DESCRIPTION

FileMagic extension module. See also libmagic(3), file(1) and magic(4).

=== Constants

<tt>MAGIC_NONE</tt>::     No flags
<tt>MAGIC_DEBUG</tt>::    Turn on debugging
<tt>MAGIC_SYMLINK</tt>::  Follow symlinks
<tt>MAGIC_COMPRESS</tt>:: Check inside compressed files
<tt>MAGIC_DEVICES</tt>::  Look at the contents of devices
<tt>MAGIC_MIME</tt>::     Return a mime string
<tt>MAGIC_CONTINUE</tt>:: Return all matches, not just the first
<tt>MAGIC_CHECK</tt>::    Print warnings to stderr

=== Methods

<tt>file(filename)</tt>::    Returns a textual description of the contents
                             of the filename argument
<tt>buffer(string)</tt>::    Returns a textual description of the contents
                             of the string argument
<tt>check(filename)</tt>::   Checks the validity of entries in the database
                             file passed in as filename
<tt>compile(filename)</tt>:: Compiles the database file passed in as filename
<tt>load(filename)</tt>::    Loads the database file passed in as filename
<tt>close()</tt>::           Closes the magic database and frees any memory
                             allocated

=== Synopsis

  require 'filemagic'

  p FileMagic::VERSION
  p FileMagic::MAGIC_VERSION

  p FileMagic.new.flags

  FileMagic.open(:mime) { |fm|
    p fm.flags
    p fm.file(__FILE__)
    p fm.file(__FILE__, true)

    fm.flags = [:raw, :continue]
    p fm.flags
  }

  fm = FileMagic.new
  p fm.flags

  mime = FileMagic.mime
  p mime.flags

=== Environment

The environment variable +MAGIC+ can be used to set the default magic file name.

=== Installation

Install the gem:

  sudo gem install ruby-filemagic

The file(1) library and headers are required:

Debian/Ubuntu:: +libmagic-dev+
Fedora/SuSE::   +file-devel+
Gentoo::        +sys-libs/libmagic+
OS X::          <tt>brew install libmagic</tt>


== LINKS

Homepage::      http://www.darwinsys.com/file/
Documentation:: https://blackwinter.github.com/ruby-filemagic
Source code::   https://github.com/blackwinter/ruby-filemagic
RubyGem::       https://rubygems.org/gems/ruby-filemagic
Travis CI::     https://travis-ci.org/blackwinter/ruby-filemagic


== AUTHORS

* Travis Whitton <mailto:[email protected]> (Original author)
* Jens Wille <mailto:[email protected]>


== CREDITS

* Martin Carpenter <mailto:[email protected]> for Ruby 1.9.2 compatibility
  and other improvements.


== 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.

ruby-filemagic's People

Contributors

blackwinter avatar mcarpenter avatar

Watchers

 avatar Adam Wróbel avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.