/
README
84 lines (45 loc) · 1.46 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
= 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 <whitton@atlantic.net>. 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.