lib/wand.rb in wand-0.1 vs lib/wand.rb in wand-0.2

- old
+ new

@@ -1,13 +1,14 @@ require 'mime/types' +require 'shellwords' module Wand - Version = '0.1' + Version = '0.2' def self.wave(path) type = MIME::Types.type_for(path)[0].to_s - type = `#{executable} --mime --brief #{path}`.split(';')[0] if type.nil? || type == '' + type = execute_file_cmd(path).split(';')[0].strip if type.nil? || type == '' type = nil if type =~ /cannot\sopen/ type end def self.executable @@ -15,7 +16,11 @@ @executable ||= `which file`.chomp end def self.executable=(path) @executable = path + end + + def self.execute_file_cmd(path) + `#{executable} --mime --brief #{path.shellescape}` end end \ No newline at end of file