lib/filemagic/ext.rb in ruby-filemagic-0.2.1 vs lib/filemagic/ext.rb in ruby-filemagic-0.2.2

- old
+ new

@@ -1,9 +1,16 @@ require 'filemagic' module FileMagic::Ext + def self.included(base) + base.class_eval { + extend ClassMethods + include InstanceMethods + } + end + module ClassMethods def file_type(file, *flags) raise NotImplementedError, 'must be implemented by including class' end @@ -45,12 +52,11 @@ end class File - include FileMagic::Ext::InstanceMethods - extend FileMagic::Ext::ClassMethods + include FileMagic::Ext def self.file_type(file, *flags) FileMagic.fm(*flags).file(file.respond_to?(:path) ? file.path : file) rescue FileMagic::FileMagicError nil @@ -58,11 +64,10 @@ end class String - include FileMagic::Ext::InstanceMethods - extend FileMagic::Ext::ClassMethods + include FileMagic::Ext def self.file_type(string, *flags) FileMagic.fm(*flags).buffer(string) rescue FileMagic::FileMagicError nil