module SeeAsVee::Helpers
Public Class Methods
file_with_type(whatever)
click to toggle source
# File lib/see_as_vee/helpers.rb, line 5 def file_with_type whatever file = case whatever when IO then whatever when String File.exist?(whatever) ? File.new(whatever) : Privates.tempfile(whatever) else raise SeeAsVee::Exceptions::BadInputError.new(whatever) end [ file, (Privates.handler_name(FileMagic.new.file(file.path)) if Kernel.const_defined?('FileMagic')) || Privates.handler_by_ext(file.path[/(?<=\.).*\z/]) ].tap do |_, handle| raise SeeAsVee::Exceptions::FileFormatError.new(file.path) if handle.nil? end end
harvest_csv(whatever)
click to toggle source
# File lib/see_as_vee/helpers.rb, line 24 def harvest_csv whatever file, type = file_with_type whatever Privates.public_send("#{type}_to_array", file.path) end
Private Instance Methods
file_with_type(whatever)
click to toggle source
# File lib/see_as_vee/helpers.rb, line 5 def file_with_type whatever file = case whatever when IO then whatever when String File.exist?(whatever) ? File.new(whatever) : Privates.tempfile(whatever) else raise SeeAsVee::Exceptions::BadInputError.new(whatever) end [ file, (Privates.handler_name(FileMagic.new.file(file.path)) if Kernel.const_defined?('FileMagic')) || Privates.handler_by_ext(file.path[/(?<=\.).*\z/]) ].tap do |_, handle| raise SeeAsVee::Exceptions::FileFormatError.new(file.path) if handle.nil? end end
harvest_csv(whatever)
click to toggle source
# File lib/see_as_vee/helpers.rb, line 24 def harvest_csv whatever file, type = file_with_type whatever Privates.public_send("#{type}_to_array", file.path) end