Module: Bovem::ShellMethods::Write

Included in:
Bovem::Shell
Defined in:
lib/bovem/shell.rb

Overview

Methods to copy or move entries.

Instance Method Summary collapse

Instance Method Details

#copy(src, dst, run = true, show_errors = false, fatal = true) ⇒ Boolean

Copies a set of files or directory to another location.



163
164
165
# File 'lib/bovem/shell.rb', line 163

def copy(src, dst, run = true, show_errors = false, fatal = true)
  self.copy_or_move(src, dst, :copy, run, show_errors, fatal)
end

#copy_or_move(src, dst, operation, run = true, show_errors = false, fatal = true) ⇒ Boolean

Copies or moves a set of files or directory to another location.



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/bovem/shell.rb', line 188

def copy_or_move(src, dst, operation, run = true, show_errors = false, fatal = true)        
  rv = true
  locale = self.i18n.shell
  operation, operation_s, single, src, dst = sanitize_copy_or_move_arguments(operation, src, dst)

  if !run then
    dry_run_copy_or_move(single, operation_s, src, dst)
  else
    rv = catch(:rv) do
      dst_dir = prepare_destination(single, src, dst, operation_s, show_errors, fatal)
      check_sources(src, operation_s, fatal)
      execute_copy_or_move(src, dst, dst_dir, single, operation, operation_s, show_errors, fatal)
      true
    end
  end

  rv
end

#move(src, dst, run = true, show_errors = false, fatal = true) ⇒ Boolean

Moves a set of files or directory to another location.



175
176
177
# File 'lib/bovem/shell.rb', line 175

def move(src, dst, run = true, show_errors = false, fatal = true)
  self.copy_or_move(src, dst, :move, run, show_errors, fatal)
end