Class: SSHKit::Backend::Abstract

### Home Classes Methods

### In Files

- lib/sshkit/backends/abstract.rb

### Parent

Object

### Methods

- ::config
- ::configure
- ::new
- #as
- #capture
- #debug
- #error
- #execute
- #fatal
- #info
- #log
- #make
- #rake
- #run
- #test
- #trace
- #warn
- #with
- #within

### Class/Module Index

Quicksearch

- SSHKit
- SSHKit::Backend
- SSHKit::Backend::Abstract
- SSHKit::Backend::ConnectionPool
- SSHKit::Backend::Local
- SSHKit::Backend::Netssh
- SSHKit::Backend::Netssh::Configuration
- SSHKit::Backend::Printer
- SSHKit::Backend::Skipper
- SSHKit::CommandMap
- SSHKit::CommandMap::CommandHash
- SSHKit::CommandMap::PrefixProvider
- SSHKit::Configuration
- SSHKit::Coordinator
- SSHKit::DSL
- SSHKit::Formatter
- SSHKit::Formatter::Abstract
- SSHKit::Formatter::BlackHole
- SSHKit::Formatter::Dot
- SSHKit::Formatter::Pretty
- SSHKit::Formatter::SimpleText
- SSHKit::Host
- SSHKit::HostWithPortParser
- SSHKit::HostWithUsernameAndPortParser
- SSHKit::HostWithUsernameParser
- SSHKit::IPv6HostWithPortParser
- SSHKit::LogMessage
- SSHKit::Logger
- SSHKit::Logger::SSHKit
- SSHKit::Logger::SSHKit::Logger
- SSHKit::Logger::SSHKit::Logger::Net
- SSHKit::Logger::SSHKit::Logger::Net::SSH
- SSHKit::Logger::SSHKit::Logger::Net::SSH::LogLevelShim
- SSHKit::Runner
- SSHKit::Runner::Abstract
- SSHKit::Runner::ExecuteError
- SSHKit::Runner::Group
- SSHKit::Runner::Null
- SSHKit::Runner::Parallel
- SSHKit::Runner::Sequential
- SSHKit::SimpleHostParser
- SSHKit::Utils
- SSHKit::Utils::CaptureOutputMethods
- Net
- Net::SSH
- Net::SSH::Config
- Array
- Color
- Hash
- Object

No matching classes.

# SSHKit::Backend::Abstract

### Attributes

host[R]

### Public Class Methods

config() click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 112
    def config
      @config ||= OpenStruct.new
    end

configure() click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 116
    def configure
      yield config
    end

new(host, &block) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 15
    def initialize(host, &block)
      raise "Must pass a Host object" unless host.is_a? Host
      @host  = host
      @block = block
    end

### Public Instance Methods

as(who, &block) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 91
    def as(who, &block)
      if who.is_a? Hash
        @user  = who[:user]  || who["user"]
        @group = who[:group] || who["group"]
      else
        @user  = who
        @group = nil
      end
      execute           if ! sudo -u #{@user} whoami > /dev/null            then echo "You cannot switch to user '#{@user}' using sudo, please check the sudoers file" 1>&2            false          fi, verbosity: Logger::DEBUG
      yield
    ensure
      remove_instance_variable(:@user)
      remove_instance_variable(:@group)
    end

capture(command, args=[]) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 65
    def capture(command, args=[])
      raise MethodUnavailableError
    end

debug(messages) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 41
    def debug(messages)
      output << LogMessage.new(Logger::DEBUG, messages)
    end

error(messages) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 29
    def error(messages)
      output << LogMessage.new(Logger::ERROR, messages)
    end

execute(command, args=[]) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 61
    def execute(command, args=[])
      raise MethodUnavailableError
    end

fatal(messages) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 25
    def fatal(messages)
      output << LogMessage.new(Logger::FATAL, messages)
    end

info(messages) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 37
    def info(messages)
      output << LogMessage.new(Logger::INFO, messages)
    end

log(messages) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 21
    def log(messages)
      info(messages)
    end

make(commands=[]) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 49
    def make(commands=[])
      raise MethodUnavailableError
    end

rake(commands=[]) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 53
    def rake(commands=[])
      raise MethodUnavailableError
    end

run() click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 11
    def run
      # Nothing to do
    end

test(command, args=[]) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 57
    def test(command, args=[])
      raise MethodUnavailableError
    end

trace(messages) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 45
    def trace(messages)
      output << LogMessage.new(Logger::TRACE, messages)
    end

warn(messages) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 33
    def warn(messages)
      output << LogMessage.new(Logger::WARN, messages)
    end

with(environment, &block) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 82
    def with(environment, &block)
      @_env = (@env ||= {})
      @env = @_env.merge environment
      yield
    ensure
      @env = @_env
      remove_instance_variable(:@_env)
    end

within(directory, &block) click to toggle source

    # File lib/sshkit/backends/abstract.rb, line 69
    def within(directory, &block)
      (@pwd ||= []).push directory.to_s
      execute           if test ! -d #{File.join(@pwd)}            then echo "Directory does not exist '#{File.join(@pwd)}'" 1>&2            false          fi, verbosity: Logger::DEBUG
        yield
    ensure
      @pwd.pop
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.