Sha256: dc5a77a28fa59dc2cf1aed0a06b88911486f900c63efa5324c080f5d8f26a913

Contents?: true

Size: 582 Bytes

Versions: 3

Compression:

Stored size: 582 Bytes

Contents

module Dragonfly
  module Analysis
    
    class FileCommandAnalyser < Base
      
      include Configurable
      
      configurable_attr :file_command, "file"
      configurable_attr :use_filesystem, false
      
      def mime_type(temp_object)
        if use_filesystem
          `#{file_command} -b --mime '#{temp_object.path}'`
        else
          IO.popen("#{file_command} -b --mime -", 'r+') do |io|
            io.write temp_object.data
            io.close_write
            io.read
          end
        end.split(';').first
      end
      
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dragonfly-0.5.0 lib/dragonfly/analysis/file_command_analyser.rb
dragonfly-0.4.4 lib/dragonfly/analysis/file_command_analyser.rb
dragonfly-0.4.3 lib/dragonfly/analysis/file_command_analyser.rb