Module: Stamina::Command::Robustness
Instance Method Summary collapse
-
#assert_readable_file(file) ⇒ Object
Checks that a given file is readable or raises a Quickl::IOAccessError.
-
#assert_writable_file(file) ⇒ Object
Checks that a given file is writable or raises a Quickl::IOAccessError.
Instance Method Details
#assert_readable_file(file) ⇒ Object
Checks that a given file is readable or raises a Quickl::IOAccessError
6 7 8 9 10 |
# File 'lib/stamina-core/stamina/command/robustness.rb', line 6 def assert_readable_file(file) raise Quickl::IOAccessError, "File #{file} does not exists" unless File.exists?(file) raise Quickl::IOAccessError, "File #{file} cannot be read" unless File.readable?(file) file end |
#assert_writable_file(file) ⇒ Object
Checks that a given file is writable or raises a Quickl::IOAccessError
13 14 15 16 17 |
# File 'lib/stamina-core/stamina/command/robustness.rb', line 13 def assert_writable_file(file) raise Quickl::IOAccessError, "File #{file} cannot be written" \ unless not(File.exists?(file)) or File.writable?(file) file end |