Module: RubyPackager::Tools

Included in:
Distributors::RubyGems, Distributors::SourceForge
Defined in:
lib/RubyPackager/Tools.rb

Instance Method Summary collapse

Instance Method Details

#scp(iFileSrc, iFileDst) ⇒ Object

Copy files through SCP.

Parameters
  • iFileSrc (String): Path to local file to copy from

  • iFileDst (String): Path to remote file to copy to



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/RubyPackager/Tools.rb', line 37

def scp(iFileSrc, iFileDst)
  require 'net/scp'
  Net::SCP.start(
    @SSHHost,
    @SSHLogin,
    get_net_ssh_options
  ) do |iSCP|
    iSCP.upload!(iFileSrc, iFileDst) do |iChunk, iName, iSent, iTotal|
      printf "#{iName}: #{iSent}/#{iTotal}\015"
      $stdout.flush
    end
    puts ''
  end
end

#set_ssh_options(iSSHHost, iSSHLogin, iOptions = {}) ⇒ Object

Set options that will be used by SSH calls

Parameters
  • iSSHHost (String): The SSH host

  • iSSHLogin (String): The SSH login

  • iOptions (map<Symbol,Object>): Additional options [optional = {}]:

    • :ask_for_password (Boolean): Do we ask for the user password to give to SSH ?

    • :ask_for_key_passphrase (Boolean): Do we ask for the key passphrase to give to SSH ?



13
14
15
# File 'lib/RubyPackager/Tools.rb', line 13

def set_ssh_options(iSSHHost, iSSHLogin, iOptions = {})
  @SSHHost, @SSHLogin, @SSHOptions = iSSHHost, iSSHLogin, iOptions
end

#ssh(iCmd) ⇒ Object

Execute some SSH command on a remote host protected with password

Parameters
  • iCmd (String): The command to execute



21
22
23
24
25
26
27
28
29
30
# File 'lib/RubyPackager/Tools.rb', line 21

def ssh(iCmd)
  require 'net/ssh'
  Net::SSH.start(
    @SSHHost,
    @SSHLogin,
    get_net_ssh_options
  ) do |iSSH|
    puts(iSSH.exec!(iCmd))
  end
end