• Stars
    star
    146
  • Rank 251,998 (Top 5 %)
  • Language
    Ruby
  • Created about 16 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby bindings to the magic(4) library, revised.
= FileMagic Library Binding

== VERSION

This documentation refers to filemagic version 0.7.3


== 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
  # => "0.7.3"
  p FileMagic::MAGIC_VERSION
  # => "5.39"

  p FileMagic.new.flags
  # => []

  FileMagic.open(:mime) { |fm|
    p fm.flags
    # => [:mime_type, :mime_encoding]
    p fm.file(__FILE__)
    # => "text/plain; charset=us-ascii"
    p fm.file(__FILE__, true)
    # => "text/plain"

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

  fm = FileMagic.new
  p fm.flags
  # => []

  mime = FileMagic.mime
  p mime.flags
  # => [:mime_type, :mime_encoding]

=== 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+
Alpine::        <tt>libmagic file file-dev</tt>
Gentoo::        +sys-libs/libmagic+
OS X::          <tt>brew install libmagic</tt>

=== Build native extension

  rake docker💎native

Requires Docker[https://docker.com] to be installed.

== LINKS

Homepage::      https://www.darwinsys.com/file/
Documentation:: https://blackwinter.github.io/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.

* Pavel Lobashov (@ShockwaveNN) for Dockerfile to build cross-compiled Windows
  extension (pull request #26).


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

More Repositories

1

unicode

Unicode normalization library. (Mirror of Yoshida-san's code base to maintain the RubyGem.)
C
79
star
2

brice

Extra cool IRb goodness for the masses.
Ruby
58
star
3

wadl

Ruby client for the Web Application Description Language.
Ruby
39
star
4

rb-gsl

Ruby interface to the GNU Scientific Library [Ruby 2.x and GSL 1.16 compatible fork of the gsl gem]
C
27
star
5

cmess

Assist with handling messed up encodings.
Ruby
17
star
6

nuggets

Some extensions to the Ruby programming language.
Ruby
16
star
7

libcdb-ruby

Ruby bindings for CDB Constant Databases.
C
12
star
8

dotme

The dotfile manager
Shell
7
star
9

twitter2jabber

Twitter-to-Jabber gateway.
Ruby
7
star
10

imapget

Get IMAP mails.
Ruby
6
star
11

rss2mail

Send RSS feeds as e-mail.
Ruby
6
star
12

athena

Convert database files to various formats.
Ruby
4
star
13

scratch

Scripts & snippets
Ruby
4
star
14

hen

Just another project helper that integrates with Rake.
Ruby
4
star
15

apache_secure_download

Apache module providing secure downloading functionality, just like Mongrel Secure Download does for mongrel.
Ruby
4
star
16

blackwinter.github.com

My GitHub homepage
HTML
3
star
17

apache_image_resizer

Apache module providing image resizing functionality.
Ruby
3
star
18

pms

Poor Man's Search
Ruby
3
star
19

page_rank

PageRank implementation for Ruby.
Ruby
3
star
20

keyword-expansion

Firefox add-on to expand keywords in bookmark URLs.
JavaScript
3
star
21

flattendb

Flatten relational databases.
Ruby
3
star
22

added_methods

Watches for added methods and records them.
Ruby
3
star
23

mediawiki-testwiki

Provides pre-configured MediaWiki wikis as Docker images.
Ruby
2
star
24

ontopia-topicmaps

Query topic maps with Ontopia.
Ruby
2
star
25

libxml-ext

LibXML Ruby extensions
Ruby
2
star
26

ontopia-tldr

Tolog Document Retrieval with Ontopia.
Ruby
1
star
27

cyclops

A command-line option parser.
Ruby
1
star
28

lsi4r

Latent semantic indexing for Ruby.
Ruby
1
star
29

rdk_lab

Tooling for the Semantic MediaWiki implementation of the German art history encyclopedia.
Ruby
1
star
30

midos

A Ruby client for MIDOS databases.
Ruby
1
star
31

birds

Experimental information retrieval system for bibliographic data.
Ruby
1
star
32

current_gem

Gem plugin that maintains symlinks to the most recent versions of installed RubyGems.
Ruby
1
star
33

sinatra-bells

Sinatra with some more bells and whistles.
Ruby
1
star
34

solr-response-digester

Add unique digest to Solr response header.
Java
1
star
35

solr4r

A Ruby client for Apache Solr.
Ruby
1
star
36

bismas

A Ruby client for BISMAS databases.
Ruby
1
star
37

docker_helper

Control the Docker command-line client from Ruby.
Ruby
1
star
38

turtle_reader

A convenience wrapper for reading RDF Turtle data.
Ruby
1
star
39

mysql_parser

A parser for MySQL DDL statements.
Ruby
1
star
40

hal4r

Hyperspace analogue to language for Ruby.
Ruby
1
star