Module: Miniflow::FileCheck
Class Method Summary collapse
-
.check_file(path, extnames) ⇒ Object
Checks that the file exists and that the extension is correct.
-
.check_file_exist(path) ⇒ Object
Checks if the file exists in the specified path.
-
.check_file_extname(path, extnames) ⇒ Object
Make sure that the file has the specified extension.
-
.mkdir_p(*arg) ⇒ Object
Creates a directory and all its parent directories.
Class Method Details
.check_file(path, extnames) ⇒ Object
Checks that the file exists and that the extension is correct. Multiple extensions can be specified in an array.
13 14 15 16 |
# 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) ⇒ Object
Checks if the file exists in the specified path.
20 21 22 |
# 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) ⇒ Object
Make sure that the file has the specified extension.
27 28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
Creates a directory and all its parent directories.
39 40 41 |
# File 'lib/miniflow/filecheck.rb', line 39 def mkdir_p(*arg) FileUtils.mkdir_p(*arg) end |