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(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

#baseDirObject (readonly)

the base directory on the remote system



728
729
730
# File 'lib/synqa.rb', line 728

def baseDir
  @baseDir
end

#hostObject (readonly)

the remote username@host value



725
726
727
# File 'lib/synqa.rb', line 725

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



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

#listDirectoriesObject

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

#listFileHashesObject

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

#listFilesObject

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

#scpCommandStringObject

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_sObject



771
772
773
# File 'lib/synqa.rb', line 771

def to_s
  return host.locationDescriptor(baseDir)
end