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.
-
#userAtHost ⇒ Object
readonly
the remote username@host value.
Attributes inherited from ContentLocation
Instance Method Summary collapse
-
#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(userAtHost, 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 userAtHost.
-
#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(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
#baseDir ⇒ Object (readonly)
the base directory on the remote system
824 825 826 |
# File 'lib/synqa.rb', line 824 def baseDir @baseDir end |
#userAtHost ⇒ Object (readonly)
the remote username@host value
821 822 823 |
# File 'lib/synqa.rb', line 821 def userAtHost @userAtHost end |
Instance Method Details
#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.
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 |
#listDirectories ⇒ Object
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 |
#listFileHashes ⇒ Object
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 |
#listFiles ⇒ Object
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 |
#sshAndScp ⇒ Object
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_s ⇒ Object
862 863 864 |
# File 'lib/synqa.rb', line 862 def to_s return userAtHost.locationDescriptor(baseDir) end |