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

Returns a new instance of RemoteContentLocation.



826
827
828
829
830
# File 'lib/synqa.rb', line 826

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

Instance Attribute Details

#baseDirObject (readonly)

the base directory on the remote system



824
825
826
# File 'lib/synqa.rb', line 824

def baseDir
  @baseDir
end

#userAtHostObject (readonly)

the remote username@host value



821
822
823
# File 'lib/synqa.rb', line 821

def userAtHost
  @userAtHost
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.



870
871
872
873
874
875
876
877
878
879
880
881
# File 'lib/synqa.rb', line 870

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



843
844
845
# File 'lib/synqa.rb', line 843

def getFullPath(relativePath)
  return baseDir + relativePath
end

#listDirectoriesObject

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



853
854
855
# File 'lib/synqa.rb', line 853

def listDirectories
  return userAtHost.listDirectories(baseDir)
end

#listFileHashesObject

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



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

def listFileHashes
  return userAtHost.listFileHashes(baseDir)
end

#listFilesObject

list files within the base directory on the remote userAtHost



833
834
835
# File 'lib/synqa.rb', line 833

def listFiles()
  userAtHost.listFiles(baseDir)
end

#ssh(commandString, dryRun = false) ⇒ Object

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



848
849
850
# File 'lib/synqa.rb', line 848

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

#sshAndScpObject

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



838
839
840
# File 'lib/synqa.rb', line 838

def sshAndScp
  return userAtHost.sshAndScp
end

#to_sObject



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

def to_s
  return userAtHost.locationDescriptor(baseDir)
end