Module: Bovem::ShellMethods::Directories
- Included in:
- Bovem::Shell
- Defined in:
- lib/bovem/shell.rb
Overview
Methods to interact with directories.
Instance Method Summary (collapse)
-
- (Boolean) create_directories(directories, mode = 0755, run = true, show_errors = false, fatal = true)
Creates a list of directories, included missing parent directories.
-
- (Boolean) within_directory(directory, restore = true, show_messages = false)
Executes a block of code in another directory.
Instance Method Details
- (Boolean) create_directories(directories, mode = 0755, run = true, show_errors = false, fatal = true)
Creates a list of directories, included missing parent directories.
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/bovem/shell.rb', line 454 def create_directories(directories, mode = 0755, run = true, show_errors = false, fatal = true) rv = true # Adjust directory directories = directories.ensure_array.compact {|d| File.(d.ensure_string) } if !run then # Just print dry_run_directory_creation(directories) else directories.each do |directory| rv = rv && try_create_directory(directory, mode, fatal, directories, show_errors) break if !rv end end rv end |
- (Boolean) within_directory(directory, restore = true, show_messages = false)
Executes a block of code in another directory.
433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/bovem/shell.rb', line 433 def within_directory(directory, restore = true, = false) locale = i18n.shell directory = File.(directory.ensure_string) original = Dir.pwd rv = enter_directory(directory, , locale.move_in(directory)) yield if rv && block_given? rv = enter_directory(original, , locale.move_out(directory)) if rv && restore rv end |