Class: Synqa::RemoteContentLocation
- Inherits:
-
ContentLocation
- Object
- ContentLocation
- Synqa::RemoteContentLocation
- Defined in:
- lib/synqa.rb
Overview
A directory of files on a remote system
Instance Attribute Summary collapse
-
#baseDir ⇒ Object
readonly
the base directory on the remote system.
-
#contentHost ⇒ Object
readonly
the remote SshContentHost.
Attributes inherited from ContentLocation
Instance Method Summary collapse
- #closeConnections ⇒ Object
-
#getContentTree ⇒ Object
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.
-
#getFullPath(relativePath) ⇒ Object
get the full path of a relative path.
-
#initialize(contentHost, baseDir, cachedContentFile = nil) ⇒ RemoteContentLocation
constructor
A new instance of RemoteContentLocation.
-
#listDirectories ⇒ Object
list all sub-directories of the base directory on the remote host.
-
#listFileHashes ⇒ Object
list all the file hashes of the files within the base directory.
-
#listFiles ⇒ Object
list files within the base directory on the remote contentHost.
-
#ssh(commandString, dryRun = false) ⇒ Object
execute an SSH command on the remote host (or just pretend, if dryRun is true).
-
#sshAndScp ⇒ Object
object required to execute SCP (e.g. “scp” or “pscp”, possibly with extra args).
- #to_s ⇒ Object
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
#baseDir ⇒ Object (readonly)
the base directory on the remote system
862 863 864 |
# File 'lib/synqa.rb', line 862 def baseDir @baseDir end |
#contentHost ⇒ Object (readonly)
the remote SshContentHost
859 860 861 |
# File 'lib/synqa.rb', line 859 def contentHost @contentHost end |
Instance Method Details
#closeConnections ⇒ Object
870 871 872 |
# File 'lib/synqa.rb', line 870 def closeConnections @contentHost.closeConnections() end |
#getContentTree ⇒ Object
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 |
#listDirectories ⇒ Object
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 |
#listFileHashes ⇒ Object
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 |
#listFiles ⇒ Object
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 |
#sshAndScp ⇒ Object
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_s ⇒ Object
904 905 906 |
# File 'lib/synqa.rb', line 904 def to_s return contentHost.locationDescriptor(baseDir) end |