class DSNode::DSResource::RecognizedFileTypeValidator
Public Instance Methods
validate_each(record, attr, values)
click to toggle source
# File lib/ds_node/ds_resource.rb, line 9 def validate_each record, attr, values [values].flatten.each do |value| if value and !image?(value) and !video?(value) record.errors.add attr, "must be a recognized file type." return end end end
Private Instance Methods
image?(value)
click to toggle source
# File lib/ds_node/ds_resource.rb, line 20 def image? value `identify -format '%w %h' #{value.path} 2>&1` && $?.success? end
video?(value)
click to toggle source
# File lib/ds_node/ds_resource.rb, line 24 def video? value `mplayer -vc null -vo null -ao null -identify #{value.path} 2>&1 | grep 'VIDEO: [[]'` && $?.success? end