Sha256: 5eefb5a7731c091121cb875aab7db716342911d55d5cb895d05247fbd67e5139

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 Bytes

Contents

require 'mime/types'

module Wand
  Version = '0.2.1'
  
  def self.wave(path)
    type = MIME::Types.type_for(path)[0].to_s
    type = execute_file_cmd(path).split(';')[0].strip if type.nil? || type == ''
    type = nil if type =~ /cannot\sopen/
    type
  end

  def self.executable
    @executable ||= `which file`.chomp
  end

  def self.executable=(path)
    @executable = path
  end
  
  def self.execute_file_cmd(path)
    `#{executable} --mime --brief #{path}`
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wand-0.2.1 lib/wand.rb