Module: Stamina::Command::Robustness

Included in:
Adl2dot, Run
Defined in:
lib/stamina-core/stamina/command/robustness.rb

Instance Method Summary collapse

Instance Method Details

#assert_readable_file(file) ⇒ Object

Checks that a given file is readable or raises a Quickl::IOAccessError

Raises:

  • (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

Raises:

  • (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