Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 3d11f8b59b
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (26 sloc) 0.65 kb
require 'mime/types'
require 'safe_shell'
module Wand
def self.wave(path, options={})
type = MIME::Types.type_for(options[:original_filename] || path)[0].to_s
type = parse_type(execute_file_cmd(path)) if blank?(type)
type = nil if type =~ /^cannot/i
type
end
def self.executable
@executable ||= `which file`.chomp
end
def self.executable=(path)
@executable = path
end
private
def self.parse_type(output)
output.split(';')[0].strip
end
def self.execute_file_cmd(path)
SafeShell.execute("#{executable}", "--mime", "--brief", path)
end
def self.blank?(str)
str.nil? || str == ''
end
end
Jump to Line
Something went wrong with that request. Please try again.