magic 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -20,4 +20,3 @@ pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
22
  *.gem
23
- *.gemspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/lib/magic/api.rb CHANGED
@@ -2,7 +2,7 @@ module Magic
2
2
  module Api #:nodoc:
3
3
  extend FFI::Library
4
4
 
5
- ffi_lib "libmagic.so.1", "libmagic.1.dylib", "magic1.dll"
5
+ ffi_lib "/opt/local/lib/libmagic.1.dylib", "libmagic.so.1", "libmagic.1.dylib", "magic1.dll"
6
6
 
7
7
  attach_function :magic_open, [:int], :pointer
8
8
  attach_function :magic_close, [:pointer], :void
data/magic.gemspec ADDED
@@ -0,0 +1,99 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{magic}
8
+ s.version = "0.2.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jakub Kuźma"]
12
+ s.date = %q{2010-02-08}
13
+ s.description = %q{Ruby FFI bindings to libmagic}
14
+ s.email = %q{qoobaa@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/magic.rb",
27
+ "lib/magic/api.rb",
28
+ "lib/magic/constants.rb",
29
+ "lib/magic/database.rb",
30
+ "lib/magic/errors.rb",
31
+ "magic.gemspec",
32
+ "test/fixtures/filelogo.jpg",
33
+ "test/fixtures/magic.txt",
34
+ "test/fixtures/magic_empty",
35
+ "test/fixtures/magic_jpeg",
36
+ "test/helper.rb",
37
+ "test/test_magic.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/qoobaa/magic}
40
+ s.post_install_message = %q{+-NOTE FOR LINUX USERS----------------------------------------------+
41
+ | |
42
+ | Install libmagic using your package manager, e.g. |
43
+ | |
44
+ | sudo apt-get install file |
45
+ | |
46
+ +-NOTE FOR WINDOWS USERS -------------------------------------------+
47
+ | |
48
+ | Install File for Windows from |
49
+ | |
50
+ | http://gnuwin32.sourceforge.net/packages/file.htm |
51
+ | |
52
+ | You'll also need to set your PATH environment variable to the |
53
+ | directory of the magic1.dll file |
54
+ | |
55
+ | set PATH=C:\Program Files\GnuWin32\bin;%PATH% |
56
+ | |
57
+ +-NOTE FOR MAC OS USERS --------------------------------------------+
58
+ | |
59
+ | If you don't have libmagic.1.dylib file in your system |
60
+ | |
61
+ | find / -name libmagic.1.dylib |
62
+ | |
63
+ | You need to install it via port command |
64
+ | |
65
+ | sudo port install file |
66
+ | |
67
+ | Sometimes you'll also need to set your DYLD_FALLBACK_LIBRARY_PATH |
68
+ | environment variable to the directory of the libmagic.1.dylib |
69
+ | |
70
+ | export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib |
71
+ | |
72
+ +-------------------------------------------------------------------+
73
+ }
74
+ s.rdoc_options = ["--charset=UTF-8"]
75
+ s.require_paths = ["lib"]
76
+ s.rubygems_version = %q{1.3.5}
77
+ s.summary = %q{Determine file type and encoding using "magic" numbers}
78
+ s.test_files = [
79
+ "test/test_magic.rb",
80
+ "test/helper.rb"
81
+ ]
82
+
83
+ if s.respond_to? :specification_version then
84
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
85
+ s.specification_version = 3
86
+
87
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
88
+ s.add_runtime_dependency(%q<ffi>, [">= 0.5.1"])
89
+ s.add_development_dependency(%q<test-unit>, [">= 2.0"])
90
+ else
91
+ s.add_dependency(%q<ffi>, [">= 0.5.1"])
92
+ s.add_dependency(%q<test-unit>, [">= 2.0"])
93
+ end
94
+ else
95
+ s.add_dependency(%q<ffi>, [">= 0.5.1"])
96
+ s.add_dependency(%q<test-unit>, [">= 2.0"])
97
+ end
98
+ end
99
+
data/test/test_magic.rb CHANGED
@@ -1,57 +1,45 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestMagic < Test::Unit::TestCase
4
- def test_guess_magic_text_mime
4
+ test "guess magic.txt mime" do
5
5
  assert_equal "text/plain; charset=utf-8", Magic.guess_file_mime(fixture("magic.txt"))
6
6
  end
7
7
 
8
- def test_guess_magic_text_mime_type
8
+ test "guess magic.txt mime type" do
9
9
  assert_equal "text/plain", Magic.guess_file_mime_type(fixture("magic.txt"))
10
10
  end
11
11
 
12
- def test_guess_magic_text_mime_encoding
12
+ test "guess magic.txt mime encoding" do
13
13
  assert_equal "utf-8", Magic.guess_file_mime_encoding(fixture("magic.txt"))
14
14
  end
15
15
 
16
- def test_guess_magic_logo_mime
16
+ test "guess filelogo.jpg mime" do
17
17
  assert_equal "image/jpeg; charset=binary", Magic.guess_file_mime(fixture("filelogo.jpg"))
18
18
  end
19
19
 
20
- def test_guess_magic_logo_mime_type
20
+ test "guess filelogo.jpg mime type" do
21
21
  assert_equal "image/jpeg", Magic.guess_file_mime_type(fixture("filelogo.jpg"))
22
22
  end
23
23
 
24
- def test_guess_magic_logo_mime_encoding
24
+ test "guess filelogo.jpg mime encoding" do
25
25
  assert_equal "binary", Magic.guess_file_mime_encoding(fixture("filelogo.jpg"))
26
26
  end
27
27
 
28
- def test_guess_non_existing_file_mime
28
+ test "guess non-existing file mime" do
29
29
  assert_raises Magic::Exception do
30
30
  Magic.guess_file_mime(fixture("non-existing.file"))
31
31
  end
32
32
  end
33
33
 
34
- def test_guess_non_existing_file_mime_type
35
- assert_raises Magic::Exception do
36
- Magic.guess_file_mime_type(fixture("non-existing.file"))
37
- end
38
- end
39
-
40
- def test_guess_non_existing_file_mime_encoding
41
- assert_raises Magic::Exception do
42
- Magic.guess_file_mime_encoding(fixture("non-existing.file"))
43
- end
44
- end
45
-
46
- def test_guess_magic_logo_mime_with_jpeg_database
34
+ test "guess filelogo.jpg mime with magic_jpeg database" do
47
35
  assert_equal "image/jpeg; charset=binary", Magic.guess_file_mime(fixture("filelogo.jpg"), :database => fixture("magic_jpeg"))
48
36
  end
49
37
 
50
- def test_guess_magic_logo_mime_with_empty_database
38
+ test "guess filelogo.jpg mime with empty database" do
51
39
  assert_equal "application/octet-stream; charset=binary", Magic.guess_file_mime(fixture("filelogo.jpg"), :database => fixture("magic_empty"))
52
40
  end
53
41
 
54
- def test_guess_with_block
42
+ test "guess with block" do
55
43
  result = nil
56
44
  Magic.guess(:mime) { |db| result = db.file(fixture("filelogo.jpg")) }
57
45
  assert_equal "image/jpeg; charset=binary", result
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.1
4
+ version: 0.2.2
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-01-11 00:00:00 +01:00
12
+ date: 2010-02-08 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,7 @@ files:
53
53
  - lib/magic/constants.rb
54
54
  - lib/magic/database.rb
55
55
  - lib/magic/errors.rb
56
+ - magic.gemspec
56
57
  - test/fixtures/filelogo.jpg
57
58
  - test/fixtures/magic.txt
58
59
  - test/fixtures/magic_empty