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.
-
#host ⇒ 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.
-
#getScpPath(relativePath) ⇒ Object
get the full path of a file as required in an SCP command (i.e. with username@host prepended).
-
#initialize(host, 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 host.
-
#scpCommandString ⇒ Object
the command string required to execute SCP (e.g. “scp” or “pscp”, possibly with extra args).
-
#ssh(commandString, dryRun = false) ⇒ Object
execute an SSH command on the remote host (or just pretend, if dryRun is true).
- #to_s ⇒ Object
Methods inherited from ContentLocation
#clearCachedContentFile, #getCachedContentTree, #getCachedContentTreeMapOfHashes, #getExistingCachedContentTreeFile
Constructor Details
#initialize(host, baseDir, cachedContentFile = nil) ⇒ RemoteContentLocation
Returns a new instance of RemoteContentLocation.
730 731 732 733 734 |
# File 'lib/synqa.rb', line 730 def initialize(host, baseDir, cachedContentFile = nil) super(cachedContentFile) @host = host @baseDir = normalisedDir(baseDir) end |
Instance Attribute Details
#baseDir ⇒ Object (readonly)
the base directory on the remote system
728 729 730 |
# File 'lib/synqa.rb', line 728 def baseDir @baseDir end |
#host ⇒ Object (readonly)
the remote username@host value
725 726 727 |
# File 'lib/synqa.rb', line 725 def host @host 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.
779 780 781 782 783 784 785 786 787 788 789 790 |
# File 'lib/synqa.rb', line 779 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
747 748 749 |
# File 'lib/synqa.rb', line 747 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)
752 753 754 |
# File 'lib/synqa.rb', line 752 def getScpPath(relativePath) return host.getScpPath(getFullPath(relativePath)) end |
#listDirectories ⇒ Object
list all sub-directories of the base directory on the remote host
762 763 764 |
# File 'lib/synqa.rb', line 762 def listDirectories return host.listDirectories(baseDir) end |
#listFileHashes ⇒ Object
list all the file hashes of the files within the base directory
767 768 769 |
# File 'lib/synqa.rb', line 767 def listFileHashes return host.listFileHashes(baseDir) end |
#listFiles ⇒ Object
list files within the base directory on the remote host
737 738 739 |
# File 'lib/synqa.rb', line 737 def listFiles() host.listFiles(baseDir) end |
#scpCommandString ⇒ Object
the command string required to execute SCP (e.g. “scp” or “pscp”, possibly with extra args)
742 743 744 |
# File 'lib/synqa.rb', line 742 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)
757 758 759 |
# File 'lib/synqa.rb', line 757 def ssh(commandString, dryRun = false) host.ssh(commandString, dryRun) end |
#to_s ⇒ Object
771 772 773 |
# File 'lib/synqa.rb', line 771 def to_s return host.locationDescriptor(baseDir) end |