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.



716
717
718
# File 'lib/synqa.rb', line 716

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)



714
715
716
# File 'lib/synqa.rb', line 714

def cachedContentFile
  @cachedContentFile
end

Instance Method Details

#clearCachedContentFileObject

Delete any existing cached content file



734
735
736
737
738
739
# File 'lib/synqa.rb', line 734

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.



742
743
744
745
746
747
748
749
# File 'lib/synqa.rb', line 742

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



753
754
755
756
757
758
759
760
761
# File 'lib/synqa.rb', line 753

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



721
722
723
724
725
726
727
728
729
730
731
# File 'lib/synqa.rb', line 721

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