Class: Dragonfly::Analysis::FileCommandAnalyser
- Inherits:
-
Object
- Object
- Dragonfly::Analysis::FileCommandAnalyser
- Includes:
- Configurable, Shell
- Defined in:
- lib/dragonfly/analysis/file_command_analyser.rb
Configuration Summary
Configurable attributes
Configurable attributes for an object in generalobject
can be configured either by using something like
object.configure do |c| c.some_configurable_attribute = "some value" c.some_other_configurable_attribute = 42 ... endor
object.some_configurable_attribute = "some value"
Configurable attributes for instances of Dragonfly::Analysis::FileCommandAnalyser
-
file_command
- default"file"
-
use_filesystem
- defaulttrue
-
num_bytes_to_check
- default255
Instance Method Summary (collapse)
Methods included from Configurable
Methods included from Shell
#escape_args, #quote, #raise_shell_command_failed, #run
Instance Method Details
- (Object) mime_type(temp_object)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dragonfly/analysis/file_command_analyser.rb', line 13 def mime_type(temp_object) content_type = if use_filesystem `#{file_command} -b --mime #{quote temp_object.path}` else IO.popen("#{file_command} -b --mime -", 'r+') do |io| if num_bytes_to_check io.write temp_object.data[0, num_bytes_to_check] else io.write temp_object.data end io.close_write io.read end end.split(';').first content_type.strip if content_type end |