Class URI::Ssh
In: lib/uri/ssh.rb
Parent: GenericEx

Methods

Constants

SCHEME = 'ssh'.freeze
DEFAULT_HOST = 'localhost'.freeze
DEFAULT_PORT = 22
DEFAULT_QUERY = ''.freeze
COMPONENT = [ :scheme, :userinfo, :host, :path, :query

Public Instance methods

[Source]

# File lib/uri/ssh.rb, line 39
    def checkout
      out = TempPath.new('checkout', pathname.basename.to_s)
      [out, shell.scp!(mk_opts, mk_scp_arg, out)]
    end

[Source]

# File lib/uri/ssh.rb, line 48
    def commit ( aPath )
      shell.scp! mk_opts, aPath, mk_scp_arg
    end

[Source]

# File lib/uri/ssh.rb, line 52
    def jump_and_eval ( aString, ruby='ruby', ruby_opts=[], &block )
      tag = "=== RESULT ===\n"
      TempPath.new do |tmp|
        tmp.open('w') do |f|
          f.print "
            aProc = proc { #{aString} }
            result =
              begin
                [true, aProc[]]
              rescue Exception => ex
                [false, ex]
              end
            STDERR.print '#{tag}'
            STDERR.print Marshal.dump(result)
          "
        end
        cmd = shell.ssh(mk_opts, mk_ssh_arg, ruby, *ruby_opts) < tmp
        data = cmd.popen
        block[data.output]
        data.waitpid
        if data.status.success?
          err = data.error.read
          err, result = err.split(tag)
          STDERR.print err
          st, obj = Marshal.load(result)
          if st
            return obj
          else
            raise obj
          end
        else
          data.display
          raise "Command failed #{cmd}"
        end
      end
    end

[Source]

# File lib/uri/ssh.rb, line 23
    def mk_opts
      opts = ['-q']
      opts << '-P' << @port if @port != DEFAULT_PORT
      opts + mk_custom_opts
    end

[Source]

# File lib/uri/ssh.rb, line 29
    def mk_scp_arg
      "#{mk_ssh_arg}:#{@path.gsub(/^\//, '')}"
    end

[Source]

# File lib/uri/ssh.rb, line 33
    def mk_ssh_arg
      result = ''
      result << @user << '@' if @user
      result + @host
    end
remote_eval( aString, ruby='ruby', ruby_opts=[], &block )

Alias for jump_and_eval

[Source]

# File lib/uri/ssh.rb, line 44
    def save
      checkout.first.save
    end

[Validate]