class Synqa::SshContentHost

Representation of a remote system accessible via SSH

Attributes

sshAndScp[R]

The remote SSH/SCP login, e.g. SSH via “username@host.example.com”

Public Class Methods

new(userAtHost, hashCommand, sshAndScp = nil) click to toggle source
Calls superclass method Synqa::DirContentHost::new
# File lib/synqa.rb, line 330
def initialize(userAtHost, hashCommand, sshAndScp = nil)
  super(hashCommand)
  @sshAndScp = sshAndScp != nil ?  sshAndScp : InternalSshScp.new()
  @sshAndScp.setUserAtHost(userAtHost)
end

Public Instance Methods

closeConnections() click to toggle source
# File lib/synqa.rb, line 340
def closeConnections()
  @sshAndScp.close()
end
copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun) click to toggle source

copy a local file to a remote directory, if dryRun is false

# File lib/synqa.rb, line 374
def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)
  sshAndScp.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)
end
copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun) click to toggle source

copy a local directory to a remote directory, if dryRun is false

# File lib/synqa.rb, line 369
def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)
  sshAndScp.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)
end
deleteDirectory(dirPath, dryRun) click to toggle source

delete a remote directory, if dryRun is false

# File lib/synqa.rb, line 359
def deleteDirectory(dirPath, dryRun)
  sshAndScp.deleteDirectory(dirPath, dryRun)
end
deleteFile(filePath, dryRun) click to toggle source

delete a remote file, if dryRun is false

# File lib/synqa.rb, line 364
def deleteFile(filePath, dryRun)
  sshAndScp.deleteFile(filePath, dryRun)
end
listDirectories(baseDir) click to toggle source

Return a list of all subdirectories of the base directory (as paths relative to the base directory)

# File lib/synqa.rb, line 379
def listDirectories(baseDir)
  baseDir = normalisedDir(baseDir)
  puts "Listing directories ..."
  directories = []
  baseDirLen = baseDir.length
  ssh(findDirectoriesCommand(baseDir).join(" ")) do |line|
    puts " #{line}"
    if line.start_with?(baseDir)
      directories << line[baseDirLen..-1]
    else
      raise "Directory #{line} is not a sub-directory of base directory #{baseDir}"
    end
  end
  return directories
end
listFileHashLines(baseDir) { |line| ... } click to toggle source

Yield lines of output from the command to display hash values and file names of all files within the base directory

# File lib/synqa.rb, line 397
def listFileHashLines(baseDir)
  baseDir = normalisedDir(baseDir)
  remoteFileHashLinesCommand = findFilesCommand(baseDir) + ["|", "xargs", "-r"] + @hashCommand.command
  ssh(remoteFileHashLinesCommand.join(" ")) do |line| 
    puts " #{line}"
    yield line 
  end
end
listFiles(baseDir) click to toggle source

List all files within the base directory to stdout

# File lib/synqa.rb, line 407
def listFiles(baseDir)
  baseDir = normalisedDir(baseDir)
  ssh(findFilesCommand(baseDir).join(" ")) do |line| 
    puts " #{line}"
  end
end
locationDescriptor(baseDir) click to toggle source

Return readable description of base directory on remote system

# File lib/synqa.rb, line 345
def locationDescriptor(baseDir)
  baseDir = normalisedDir(baseDir)
  return "#{userAtHost}:#{baseDir} (connect = #{shell}/#{scpProgram}, hashCommand = #{hashCommand})"
end
ssh(commandString, dryRun = false) { |line| ... } click to toggle source

execute an SSH command on the remote system, yielding lines of output (or don't actually execute, if dryRun is false)

# File lib/synqa.rb, line 352
def ssh(commandString, dryRun = false)
  sshAndScp.ssh(commandString, dryRun) do |line|
    yield line
  end
end
userAtHost() click to toggle source
# File lib/synqa.rb, line 336
def userAtHost
  return @sshAndScp.userAtHost
end