Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use rake-compiler (via hen).

  • Loading branch information...
commit d6c33d54cee21fffe8f9519770852344db24e675 1 parent eb1033f
@blackwinter authored
View
1  .gitignore
@@ -1,6 +1,7 @@
doc
doc.local
pkg
+tmp
.gh-pages
ext/Makefile
ext/filemagic.o
View
8 README
@@ -43,10 +43,10 @@ Travis
== LINKS
<b></b>
-Homepage:: <http://grub.ath.cx/filemagic/>
-Documentation:: <http://ruby-filemagic.rubyforge.org/>
-Source code:: <http://github.com/blackwinter/ruby-filemagic>
-Rubyforge project:: <http://rubyforge.org/projects/ruby-filemagic>
+Homepage:: http://grub.ath.cx/filemagic/
+Documentation:: http://ruby-filemagic.rubyforge.org/
+Source code:: http://github.com/blackwinter/ruby-filemagic
+RubyForge project:: http://rubyforge.org/projects/ruby-filemagic
== AUTHORS
View
8 Rakefile
@@ -13,7 +13,13 @@ begin
:summary => 'Ruby bindings to the magic(4) library',
:authors => ['Travis Whitton', 'Jens Wille'],
:email => ['tinymountain@gmail.com', 'jens.wille@uni-koeln.de'],
- :extra_files => FileList['info/*'].to_a
+ :extra_files => FileList['info/*'].to_a,
+ :extension => {
+ :name => 'filemagic',
+ :ext_dir => 'ext',
+ :lib_dir => 'lib',
+ :cross_compile => false
+ }
}
}}
rescue LoadError => err
View
4 ext/filemagic.c
@@ -33,6 +33,7 @@ rb_magic_new(int argc, VALUE *argv, VALUE class) {
}
args[0] = rb_magic_flags_to_int(argc, argv);
+
if ((cookie = magic_open(NUM2INT(args[0]))) == NULL) {
rb_fatal("out of memory");
}
@@ -222,7 +223,8 @@ rb_magic_flags_to_int(int argc, VALUE *argv) {
else {
f = rb_funcall(f, rb_intern("inspect"), 0);
rb_raise(rb_eArgError,
- "%s: %s", NIL_P(g) ? "no such flag" : "flag not available",
+ "%s: %s",
+ NIL_P(g) ? "no such flag" : "flag not available",
StringValueCStr(f)
);
break;
View
7 ext/filemagic.h
@@ -23,9 +23,12 @@
#endif
#define GetMagicCookie(obj, cookie) {\
- if (RTEST(rb_magic_closed_p(obj)))\
+ if (RTEST(rb_magic_closed_p(obj))) {\
rb_raise(rb_eRuntimeError, "closed stream");\
- Data_Get_Struct(obj, struct magic_set, cookie);\
+ }\
+ else {\
+ Data_Get_Struct((obj), struct magic_set, (cookie));\
+ }\
}
static VALUE cFileMagic, rb_FileMagicError;
View
2  lib/filemagic.rb
@@ -39,7 +39,7 @@ class FileMagic
# Map flag values to their names (Integer => :name).
FLAGS_BY_INT = FLAGS_BY_SYM.invert.update(0 => :none)
- # Extract "simple" MIME type
+ # Extract "simple" MIME type.
SIMPLE_RE = %r{([.\w\/-]+)}
@fm = Hash.new { |fm, flags|
View
2  lib/filemagic/ext.rb
@@ -62,7 +62,6 @@ class File
def self.file_type(file, *flags)
FileMagic.fm(*flags).file(file.respond_to?(:path) ? file.path : file)
rescue FileMagic::FileMagicError
- nil
end
end
@@ -74,7 +73,6 @@ class String
def self.file_type(string, *flags)
FileMagic.fm(*flags).buffer(string)
rescue FileMagic::FileMagicError
- nil
end
end
View
3  test/filemagic_test.rb
@@ -1,7 +1,4 @@
require 'test/unit'
-
-top_dir = File.join(File.dirname(__FILE__), '..')
-$:.unshift(File.join(top_dir, 'lib'), File.join(top_dir, 'ext'))
require 'filemagic'
class TestFileMagic < Test::Unit::TestCase
Please sign in to comment.
Something went wrong with that request. Please try again.