Class: SSHKit::Backend::Local

### Home Classes Methods

### In Files

- lib/sshkit/backends/local.rb

### Parent

Printer

### Methods

- ::new
- #capture
- #download!
- #execute
- #run
- #test
- #upload!

### 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::Local

### Public Class Methods

new(_ = nil, &block) click to toggle source

    # File lib/sshkit/backends/local.rb, line 9
    def initialize(_ = nil, &block)
      @host = Host.new(:local) # just for logging
      @block = block
    end

### Public Instance Methods

capture(*args) click to toggle source

    # File lib/sshkit/backends/local.rb, line 30
    def capture(*args)
      options = { verbosity: Logger::DEBUG }.merge(args.extract_options!)
      _execute(*[*args, options]).full_stdout
    end

download!(remote, local=nil, options = {}) click to toggle source

    # File lib/sshkit/backends/local.rb, line 45
    def download!(remote, local=nil, options = {})
      if local.nil?
        FileUtils.cp(remote, File.basename(remote))
      else
        File.open(remote, "rb") do |f|
          IO.copy_stream(f, local)
        end
      end
    end

execute(*args) click to toggle source

    # File lib/sshkit/backends/local.rb, line 26
    def execute(*args)
      _execute(*args).success?
    end

run() click to toggle source

    # File lib/sshkit/backends/local.rb, line 14
    def run
      instance_exec(@host, &@block)
    end

test(*args) click to toggle source

    # File lib/sshkit/backends/local.rb, line 18
    def test(*args)
      options = args.extract_options!.merge(
        raise_on_non_zero_exit: false,
        verbosity: Logger::DEBUG
      )
      _execute(*[*args, options]).success?
    end

upload!(local, remote, options = {}) click to toggle source

    # File lib/sshkit/backends/local.rb, line 35
    def upload!(local, remote, options = {})
      if local.is_a?(String)
        FileUtils.cp(local, remote)
      else
        File.open(remote, "wb") do |f|
          IO.copy_stream(local, f)
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.