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(contentHost, baseDir, cachedContentFile = nil) ⇒ RemoteContentLocation

Returns a new instance of RemoteContentLocation.



864
865
866
867
868
# File 'lib/synqa.rb', line 864

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

Instance Attribute Details

#baseDirObject (readonly)

the base directory on the remote system



862
863
864
# File 'lib/synqa.rb', line 862

def baseDir
  @baseDir
end

#contentHostObject (readonly)

the remote SshContentHost



859
860
861
# File 'lib/synqa.rb', line 859

def contentHost
  @contentHost
end

Instance Method Details

#closeConnectionsObject



870
871
872
# File 'lib/synqa.rb', line 870

def closeConnections
  @contentHost.closeConnections()
end

#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.



912
913
914
915
916
917
918
919
920
921
922
923
# File 'lib/synqa.rb', line 912

def getContentTree
  if cachedContentFile and File.exists?(cachedContentFile)
    return ContentTree.readFromFile(cachedContentFile)
  else
    contentTree = contentHost.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



885
886
887
# File 'lib/synqa.rb', line 885

def getFullPath(relativePath)
  return baseDir + relativePath
end

#listDirectoriesObject

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



895
896
897
# File 'lib/synqa.rb', line 895

def listDirectories
  return contentHost.listDirectories(baseDir)
end

#listFileHashesObject

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



900
901
902
# File 'lib/synqa.rb', line 900

def listFileHashes
  return contentHost.listFileHashes(baseDir)
end

#listFilesObject

list files within the base directory on the remote contentHost



875
876
877
# File 'lib/synqa.rb', line 875

def listFiles()
  contentHost.listFiles(baseDir)
end

#ssh(commandString, dryRun = false) ⇒ Object

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



890
891
892
# File 'lib/synqa.rb', line 890

def ssh(commandString, dryRun = false)
  contentHost.sshAndScp.ssh(commandString, dryRun)
end

#sshAndScpObject

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



880
881
882
# File 'lib/synqa.rb', line 880

def sshAndScp
  return contentHost.sshAndScp
end

#to_sObject



904
905
906
# File 'lib/synqa.rb', line 904

def to_s
  return contentHost.locationDescriptor(baseDir)
end