Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

require 'pathname'
require 'rake'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rubygems/package_task'
require 'rdoc/task'
require 'rake/testtask'

gemspec = eval( File.read('ruby-filemagic.gemspec') )
Expand Down Expand Up @@ -49,7 +49,7 @@ task :install do
end

task :gem
Rake::GemPackageTask.new(gemspec) do |pkg|
Gem::PackageTask.new(gemspec) do |pkg|
pkg.need_tar = true
end

6 changes: 6 additions & 0 deletions filemagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ static VALUE magick_new(int argc, VALUE *argv, VALUE obj)
return obj;
}

static VALUE magick_version() {
return INT2FIX(MAGIC_VERSION);
}


/* Return a string describing file */
static VALUE magick_file(VALUE class, VALUE file)
{
Expand Down Expand Up @@ -142,6 +147,7 @@ void Init_filemagic() {
rb_define_method(cFileMagic, "buffer", magick_buffer, 1);
rb_define_method(cFileMagic, "check", magick_check, 1);
rb_define_method(cFileMagic, "compile", magick_compile, 1);
rb_define_method(cFileMagic, "version", magick_version, 0);
rb_define_attr(cFileMagic, "flags", 1, 1);
rb_define_const(cFileMagic, "MAGIC_NONE", INT2FIX(MAGIC_NONE));
rb_define_const(cFileMagic, "MAGIC_DEBUG", INT2FIX(MAGIC_DEBUG));
Expand Down
2 changes: 2 additions & 0 deletions filemagic.rd
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@
returns the instance flags (see "Constants" above).
: flags=(flags)
set the instance flags (see "Constants" above).
: version()
returns the libmagic version.
: new(flags=MAGIC_NONE)
create a new FileMagic instance.
7 changes: 7 additions & 0 deletions test/regress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,11 @@ def test_flags
fm.flags = FileMagic::MAGIC_NONE
assert_equal(FileMagic::MAGIC_NONE, fm.flags)
end

def test_version
fm = FileMagic.new(FileMagic::MAGIC_SYMLINK | FileMagic::MAGIC_MIME)
fm_version = fm.version
assert_not_nil(fm_version)
assert_equal(fm_version > 400, true)
end
end