Class: Synqa::RemoteContentLocation

Inherits:
ContentLocation show all
Defined in:
lib/synqa.rb

Overview

A directory of files on a remote system

Instance Attribute Summary collapse

Attributes inherited from ContentLocation

#cachedContentFile

Instance Method Summary collapse

Methods inherited from ContentLocation

#clearCachedContentFile, #getCachedContentTree, #getCachedContentTreeMapOfHashes, #getExistingCachedContentTreeFile

Constructor Details

#initialize(host, baseDir, cachedContentFile = nil) ⇒ RemoteContentLocation

Returns a new instance of RemoteContentLocation.



748
749
750
751
752
# File 'lib/synqa.rb', line 748

def initialize(host, baseDir, cachedContentFile = nil)
  super(cachedContentFile)
  @host = host
  @baseDir = normalisedDir(baseDir)
end

Instance Attribute Details

#baseDirObject (readonly)

the base directory on the remote system



746
747
748
# File 'lib/synqa.rb', line 746

def baseDir
  @baseDir
end

#hostObject (readonly)

the remote username@host value



743
744
745
# File 'lib/synqa.rb', line 743

def host
  @host
end

Instance Method Details

#getContentTreeObject

Get the content tree, from the cached content file if it exists, otherwise get if from listing directories and files and hash values thereof on the remote host. And also, if the cached content file name is specified, write the content tree out to that file.



797
798
799
800
801
802
803
804
805
806
807
808
# File 'lib/synqa.rb', line 797

def getContentTree
  if cachedContentFile and File.exists?(cachedContentFile)
    return ContentTree.readFromFile(cachedContentFile)
  else
    contentTree = host.getContentTree(baseDir)
    contentTree.sort!
    if cachedContentFile != nil
      contentTree.writeToFile(cachedContentFile)
    end
    return contentTree
  end
end

#getFullPath(relativePath) ⇒ Object

get the full path of a relative path



765
766
767
# File 'lib/synqa.rb', line 765

def getFullPath(relativePath)
  return baseDir + relativePath
end

#getScpPath(relativePath) ⇒ Object

get the full path of a file as required in an SCP command (i.e. with username@host prepended)



770
771
772
# File 'lib/synqa.rb', line 770

def getScpPath(relativePath)
  return host.getScpPath(getFullPath(relativePath))
end

#listDirectoriesObject

list all sub-directories of the base directory on the remote host



780
781
782
# File 'lib/synqa.rb', line 780

def listDirectories
  return host.listDirectories(baseDir)
end

#listFileHashesObject

list all the file hashes of the files within the base directory



785
786
787
# File 'lib/synqa.rb', line 785

def listFileHashes
  return host.listFileHashes(baseDir)
end

#listFilesObject

list files within the base directory on the remote host



755
756
757
# File 'lib/synqa.rb', line 755

def listFiles()
  host.listFiles(baseDir)
end

#scpCommandStringObject

the command string required to execute SCP (e.g. “scp” or “pscp”, possibly with extra args)



760
761
762
# File 'lib/synqa.rb', line 760

def scpCommandString
  return host.scpCommandString
end

#ssh(commandString, dryRun = false) ⇒ Object

execute an SSH command on the remote host (or just pretend, if dryRun is true)



775
776
777
# File 'lib/synqa.rb', line 775

def ssh(commandString, dryRun = false)
  host.ssh(commandString, dryRun)
end

#to_sObject



789
790
791
# File 'lib/synqa.rb', line 789

def to_s
  return host.locationDescriptor(baseDir)
end