module Miniflow::FileCheck
Public Instance Methods
check_file(path, extnames)
click to toggle source
Checks that the file exists and that the extension is correct. @params path [String] The path to the file to check if it exists @params extnames [Array, String] File extensions to check. Multiple extensions can be specified in an array.
# File lib/miniflow/filecheck.rb, line 13 def check_file(path, extnames) check_file_extname(path, extnames) check_file_exist(path) end
check_file_exist(path)
click to toggle source
Checks if the file exists in the specified path. @params path [String] The path to the file to check if it exists.
# File lib/miniflow/filecheck.rb, line 20 def check_file_exist(path) raise "Cannot find: #{path}" unless File.exist?(path) end
check_file_extname(path, extnames)
click to toggle source
Make sure that the file has the specified extension. @params path [String] The path to the file. @params extnames [Array, String] File extensions to check.
# File lib/miniflow/filecheck.rb, line 27 def check_file_extname(path, extnames) case extnames when Array raise "Extension is not #{extnames}: #{path}" unless extnames.include?(File.extname(path)) when File.extname(path) true else raise "Extension is not #{extnames}: #{path}" end end
mkdir_p(*arg)
click to toggle source
Creates a directory and all its parent directories.
# File lib/miniflow/filecheck.rb, line 39 def mkdir_p(*arg) FileUtils.mkdir_p(*arg) end