magic 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -57
- data/VERSION +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,66 +1,16 @@
|
|
1
1
|
= magic
|
2
2
|
|
3
|
-
Ruby FFI
|
4
|
-
and encoding of files and strings.
|
5
|
-
|
6
|
-
|
7
|
-
be printed.
|
3
|
+
Ruby FFI wrapper to the "magic" library, that determines content type
|
4
|
+
and encoding of files and strings. The library does three types of
|
5
|
+
tests: filesystem tests, magic number tests, and language tests. The
|
6
|
+
first test that succeeds causes the file type to be returned.
|
8
7
|
|
9
|
-
== Usage
|
8
|
+
== Installation and Usage
|
10
9
|
|
11
|
-
|
12
|
-
Magic.guess_file_mime("public/images/rails.png")
|
13
|
-
# => "image/png; charset=binary"
|
14
|
-
Magic.guess_file_mime_encoding("public/images/rails.png")
|
15
|
-
# => "binary"
|
16
|
-
Magic.guess_file_mime_type("public/images/rails.png")
|
17
|
-
# => "image/png"
|
18
|
-
Magic.guess_string_mime("Magic® File™")
|
19
|
-
# => "text/plain; charset=utf-8"
|
20
|
-
Magic.guess_string_mime_encoding("Magic® File™")
|
21
|
-
# => "utf-8"
|
22
|
-
Magic.guess_string_mime_type("Magic® File™")
|
23
|
-
# => "text/plain"
|
24
|
-
Magic.guess(:mime_type, :database => "/etc/magic") { |db| db.buffer("Magic® File™") }
|
25
|
-
# => "text/plain"
|
26
|
-
|
27
|
-
== Installation
|
28
|
-
|
29
|
-
gem install magic --source=http://gemcutter.org
|
30
|
-
|
31
|
-
=== Linux
|
32
|
-
|
33
|
-
Install magic library using your package manager, e.g.:
|
34
|
-
|
35
|
-
sudo apt-get install file
|
36
|
-
|
37
|
-
=== Mac OS
|
38
|
-
|
39
|
-
If you don't have <tt>libmagic.1.dylib</tt> file in your system, you need to
|
40
|
-
install it via port command:
|
41
|
-
|
42
|
-
sudo port install file
|
43
|
-
|
44
|
-
Sometimes you also need to set your
|
45
|
-
<tt>DYLD_FALLBACK_LIBRARY_PATH</tt> environment variable to the
|
46
|
-
directory of the <tt>libmagic.1.dylib</tt>:
|
47
|
-
|
48
|
-
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
|
49
|
-
|
50
|
-
=== Windows
|
51
|
-
|
52
|
-
Install {File for
|
53
|
-
Windows}[http://gnuwin32.sourceforge.net/packages/file.htm]. You also
|
54
|
-
need to set your <tt>PATH</tt> environment variable to the directory of the
|
55
|
-
<tt>magic1.dll</tt> file:
|
56
|
-
|
57
|
-
set PATH=C:\Program Files\GnuWin32\bin;%PATH%
|
58
|
-
|
59
|
-
It might be also required to add <tt>database</tt> option explicitely:
|
60
|
-
|
61
|
-
Magic.guess_string_mime("Magic® File™", :database => 'C:\Program Files\GnuWin32\share\misc\magic.mgc')
|
10
|
+
See {project page}[http://jah.pl/projects/magic.html] for details.
|
62
11
|
|
63
12
|
== Links
|
13
|
+
* {project page}[http://jah.pl/projects/magic.html]
|
64
14
|
* gemcutter[http://gemcutter.org/gems/magic]
|
65
15
|
* repository[http://github.com/qoobaa/magic]
|
66
16
|
* {issue tracker}[http://github.com/qoobaa/magic/issues]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|