Class: Synqa::ContentLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/synqa.rb

Overview

Base class for a content location which consists of a base directory on a local or remote system.

Direct Known Subclasses

LocalContentLocation, RemoteContentLocation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cachedContentFile) ⇒ ContentLocation

Returns a new instance of ContentLocation.



754
755
756
# File 'lib/synqa.rb', line 754

def initialize(cachedContentFile)
  @cachedContentFile = cachedContentFile
end

Instance Attribute Details

#cachedContentFileObject (readonly)

The name of a file used to hold a cached content tree for this location (can optionally be specified)



752
753
754
# File 'lib/synqa.rb', line 752

def cachedContentFile
  @cachedContentFile
end

Instance Method Details

#clearCachedContentFileObject

Delete any existing cached content file



772
773
774
775
776
777
# File 'lib/synqa.rb', line 772

def clearCachedContentFile
  if cachedContentFile and File.exists?(cachedContentFile)
    puts " deleting cached content file #{cachedContentFile} ..."
    File.delete(cachedContentFile)
  end
end

#getCachedContentTreeObject

Get the cached content tree (if any), read from the specified cached content file.



780
781
782
783
784
785
786
787
# File 'lib/synqa.rb', line 780

def getCachedContentTree
  file = getExistingCachedContentTreeFile
  if file
    return ContentTree.readFromFile(file)
  else
    return nil
  end
end

#getCachedContentTreeMapOfHashesObject

Read a map of file hashes (mapping from relative file name to hash value) from the specified cached content file



791
792
793
794
795
796
797
798
799
# File 'lib/synqa.rb', line 791

def getCachedContentTreeMapOfHashes
  file = getExistingCachedContentTreeFile
  if file
    puts "Reading cached file hashes from #{file} ..."
    return ContentTree.readMapOfHashesFromFile(file)
  else
    return [nil, {}]
  end
end

#getExistingCachedContentTreeFileObject

Get the cached content file name, if specified, and if the file exists



759
760
761
762
763
764
765
766
767
768
769
# File 'lib/synqa.rb', line 759

def getExistingCachedContentTreeFile
  if cachedContentFile == nil
    puts "No cached content file specified for location"
    return nil
  elsif File.exists?(cachedContentFile)
    return cachedContentFile
  else
    puts "Cached content file #{cachedContentFile} does not yet exist."
    return nil
  end
end