Class AutomateIt::ShellManager::BaseDriver
In: lib/automateit/shell_manager.rb
Parent: AutomateIt::Plugin::Driver


Base class for all ShellManager drivers.


Public Instance methods

Returns derived filename to use as a peer given the source and target. This is necessary for differentiating between directory and file targets.

For example:

  # Get the peer for an extant target directory:
  peer_for("foo", "/tmp") # => "/tmp/foo"

  # Get the peer for anything else:
  peer_for("foo", "/bar") # => "/bar"


# File lib/automateit/shell_manager.rb, line 280
  def peer_for(source, target)
    return FileUtils.send(:fu_each_src_dest0, source, target){|a, b| b}

Protected Instance methods

Return array of all the directory‘s top-level contents, including hidden files with "." prefix on UNIX. Directories are returned just as a name, you‘ll need to expand those separately if needed.


# File lib/automateit/shell_manager.rb, line 302
  def _directory_contents(directory)
    return Dir[directory+"/{,.}*"].reject{|t| t =~ /(^|#{File::SEPARATOR})\.{1,2}$/}

Returns hash of verbosity and preview settings for FileUtils commands.


# File lib/automateit/shell_manager.rb, line 292
  def _fileutils_opts
    opts = {}
    opts[:verbose] = false # Generate our own log messages
    opts[:noop] = true if preview?
    return opts


# File lib/automateit/shell_manager.rb, line 285
  def _replace_owner_with_user(opts)
    value = opts.delete(:owner)
    opts[:user] = value  if value and not opts[:user]
    return opts