Sha256: f425e16df22e85d72c34698e3aac936b4024ca9631a1fa316c9e85ada593c72c

Contents?: true

Size: 1.31 KB

Versions: 18

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

module Backup
  module CLI

    ##
    # Wrapper method for %x[] to run CL commands
    # through a ruby method. This helps with test coverage and
    # improves readability
    def run(command)
      %x[#{command}]
    end

    ##
    # Wrapper method for FileUtils.mkdir_p to create directories
    # through a ruby method. This helps with test coverage and
    # improves readability
    def mkdir(path)
      FileUtils.mkdir_p(path)
    end

    ##
    # Wrapper for the FileUtils.rm_rf to remove files and folders
    # through a ruby method. This helps with test coverage and
    # improves readability
    def rm(path)
      FileUtils.rm_rf(path)
    end

    ##
    # Tries to find the full path of the specified utility. If the full
    # path is found, it'll return that. Otherwise it'll just return the
    # name of the utility. If the 'utility_path' is defined, it'll check
    # to see if it isn't an empty string, and if it isn't, it'll go ahead and
    # always use that path rather than auto-detecting it
    def utility(name)
      if respond_to?(:utility_path)
        if utility_path.is_a?(String) and not utility_path.empty?
          return utility_path
        end
      end

      if path = %x[which #{name}].chomp and not path.empty?
        return path
      end
      name
    end

  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
backup-3.0.13 lib/backup/cli.rb
backup-3.0.12 lib/backup/cli.rb
backup-3.0.11 lib/backup/cli.rb
alg-backup-3.0.10 lib/backup/cli.rb
backup-3.0.10 lib/backup/cli.rb
backup-3.0.9 lib/backup/cli.rb
backup-3.0.8 lib/backup/cli.rb
backup-3.0.7 lib/backup/cli.rb
backup-3.0.6 lib/backup/cli.rb
backup-3.0.5 lib/backup/cli.rb
backup-3.0.4 lib/backup/cli.rb
backup-3.0.3 lib/backup/cli.rb
backup-3.0.2.build.0 lib/backup/cli.rb
backup-3.0.2 lib/backup/cli.rb
backup-3.0.1.build.0 lib/backup/cli.rb
backup-3.0.1 lib/backup/cli.rb
backup-3.0.0.build.0 lib/backup/cli.rb
backup-3.0.0 lib/backup/cli.rb