magic 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/magic.rb +10 -3
- data/lib/magic/api.rb +3 -4
- data/magic.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/magic.rb
CHANGED
@@ -10,6 +10,7 @@ require "magic/database"
|
|
10
10
|
module Magic
|
11
11
|
class << self
|
12
12
|
# Guesses mime of given file
|
13
|
+
#
|
13
14
|
# ====== Example
|
14
15
|
# Magic.guess_file_mime("public/images/rails.png")
|
15
16
|
# # => "image/png; charset=binary"
|
@@ -18,6 +19,7 @@ module Magic
|
|
18
19
|
end
|
19
20
|
|
20
21
|
# Guesses mime encoding of given file
|
22
|
+
#
|
21
23
|
# ===== Example
|
22
24
|
# Magic.guess_file_mime_encoding("public/images/rails.png")
|
23
25
|
# # => "binary"
|
@@ -26,6 +28,7 @@ module Magic
|
|
26
28
|
end
|
27
29
|
|
28
30
|
# Guesses mime type of given file
|
31
|
+
#
|
29
32
|
# ===== Example
|
30
33
|
# Magic.guess_file_mime_type("public/images/rails.png")
|
31
34
|
# # => "image/png"
|
@@ -34,6 +37,7 @@ module Magic
|
|
34
37
|
end
|
35
38
|
|
36
39
|
# Guesses mime type of given string
|
40
|
+
#
|
37
41
|
# ===== Example
|
38
42
|
# Magic.guess_string_mime("Magic® File™")
|
39
43
|
# # => "text/plain; charset=utf-8"
|
@@ -42,6 +46,7 @@ module Magic
|
|
42
46
|
end
|
43
47
|
|
44
48
|
# Guesses mime type of given string
|
49
|
+
#
|
45
50
|
# ===== Example
|
46
51
|
# Magic.guess_string_mime_encoding("Magic® File™")
|
47
52
|
# # => "utf-8"
|
@@ -50,6 +55,7 @@ module Magic
|
|
50
55
|
end
|
51
56
|
|
52
57
|
# Guesses mime type of given string
|
58
|
+
#
|
53
59
|
# ===== Example
|
54
60
|
# Magic.guess_string_mime_type("Magic® File™")
|
55
61
|
# # => "text/plain"
|
@@ -58,14 +64,15 @@ module Magic
|
|
58
64
|
end
|
59
65
|
|
60
66
|
# Creates magic database and yields it to the given block
|
67
|
+
#
|
61
68
|
# ===== Example
|
62
69
|
# Magic.guess(:mime) { |db| db.buffer("Magic® File™") }
|
63
70
|
# # => "text/plain; charset=utf-8"
|
64
71
|
def guess(*args)
|
65
72
|
db = Database.new(*args)
|
66
|
-
yield(db)
|
67
|
-
|
68
|
-
|
73
|
+
result = yield(db)
|
74
|
+
db.close
|
75
|
+
result
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
data/lib/magic/api.rb
CHANGED
@@ -2,10 +2,9 @@ module Magic
|
|
2
2
|
module Api #:nodoc:
|
3
3
|
extend FFI::Library
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
"magic1.dll"]
|
5
|
+
lib_paths = Array(ENV["MAGIC_LIB"] || Dir["/{opt,usr}/{,local/}lib{,64}/libmagic.{1.dylib,so.1*}"])
|
6
|
+
fallback_names = %w(libmagic.1.dylib libmagic.so.1 magic1.dll)
|
7
|
+
ffi_lib(lib_paths + fallback_names)
|
9
8
|
|
10
9
|
attach_function :magic_open, [:int], :pointer
|
11
10
|
attach_function :magic_close, [:pointer], :void
|
data/magic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{magic}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jakub Kuźma"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-10}
|
13
13
|
s.description = %q{Ruby FFI bindings to libmagic}
|
14
14
|
s.email = %q{qoobaa@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jakub Ku\xC5\xBAma"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-10 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|