Module: DbAgile::Robustness::FileSystem
- Included in:
- DbAgile::Robustness
- Defined in:
- lib/dbagile/robustness/file_system.rb
Instance Method Summary collapse
-
#unexisting_directory!(dir, msg = "Directory #{dir} already exists, use --force", error_class = IOError) ⇒ Object
Asserts that a directory does not exists.
-
#valid_r_file!(file, msg = "Unable to access #{file} in read", error_class = IOError) ⇒ Object
Asserts that a file exists and is readable.
-
#valid_rw_directory!(dir, msg = "Unable to access #{dir} in read/write", error_class = IOError) ⇒ Object
Asserts that a directory exists, is readable and writable.
-
#valid_rw_file!(file, msg = "Unable to access #{file} in read/write", error_class = IOError) ⇒ Object
Asserts that a file exists, is readable and writable.
Instance Method Details
#unexisting_directory!(dir, msg = "Directory #{dir} already exists, use --force", error_class = IOError) ⇒ Object
Asserts that a directory does not exists
41 42 43 44 45 46 47 48 |
# File 'lib/dbagile/robustness/file_system.rb', line 41 def unexisting_directory!(dir, msg = "Directory #{dir} already exists, use --force", error_class = IOError) if File.exists?(dir) raise error_class, msg, caller end dir end |
#valid_r_file!(file, msg = "Unable to access #{file} in read", error_class = IOError) ⇒ Object
Asserts that a file exists and is readable.
30 31 32 33 34 35 36 37 38 |
# File 'lib/dbagile/robustness/file_system.rb', line 30 def valid_r_file!(file, msg = "Unable to access #{file} in read", error_class = IOError) unless File.file?(file) && File.readable?(file) raise error_class, msg, caller end file end |
#valid_rw_directory!(dir, msg = "Unable to access #{dir} in read/write", error_class = IOError) ⇒ Object
Asserts that a directory exists, is readable and writable
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/dbagile/robustness/file_system.rb', line 6 def valid_rw_directory!(dir, msg = "Unable to access #{dir} in read/write", error_class = IOError) unless File.directory?(dir) && File.readable?(dir) && File.writable?(dir) raise error_class, msg, caller end dir end |
#valid_rw_file!(file, msg = "Unable to access #{file} in read/write", error_class = IOError) ⇒ Object
Asserts that a file exists, is readable and writable
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dbagile/robustness/file_system.rb', line 18 def valid_rw_file!(file, msg = "Unable to access #{file} in read/write", error_class = IOError) unless File.file?(file) && File.readable?(file) && File.writable?(file) raise error_class, msg, caller end file end |