class Longleaf::FilesystemStorageLocation

A storage location in a local filesystem

Public Class Methods

new(name, config, md_loc) click to toggle source

@param name [String] the name of this storage location @param config [Hash] hash containing the configuration options for this location @param md_loc [MetadataLocation] metadata location associated with this storage location

Calls superclass method
# File lib/longleaf/models/filesystem_storage_location.rb, line 10
def initialize(name, config, md_loc)
  super(name, config, md_loc)
  @path += File::SEPARATOR unless @path.end_with?(File::SEPARATOR)
end

Public Instance Methods

available?() click to toggle source

Checks that the path and metadata path defined in this location are available @raise [StorageLocationUnavailableError] if the storage location is not available

# File lib/longleaf/models/filesystem_storage_location.rb, line 34
def available?
  raise StorageLocationUnavailableError.new("Path does not exist or is not a directory: #{@path}")\
      unless Dir.exist?(@path)
  @metadata_location.available?
end
get_path_from_metadata_path(md_path) click to toggle source

Get that absolute path to the file associated with the provided metadata path @param md_path [String] metadata file path @raise [ArgumentError] if the md_path is not in this storage location @return [String] the path for the file associated with this metadata

# File lib/longleaf/models/filesystem_storage_location.rb, line 24
def get_path_from_metadata_path(md_path)
  raise ArgumentError.new("A file_path parameter is required") if md_path.nil? || md_path.empty?

  rel_path = @metadata_location.relative_file_path_for(md_path)

  File.join(@path, rel_path)
end
relativize(file_path) click to toggle source

Get the file path relative to this location @param file_path [String] file path @return the file path relative to this location @raise [ArgumentError] if the file path is not contained by this location

# File lib/longleaf/models/filesystem_storage_location.rb, line 44
def relativize(file_path)
  return file_path if Pathname.new(file_path).relative?

  raise ArgumentError.new("Metadata path must be contained by this location") if !file_path.start_with?(@path)

  file_path.sub(@path, "")
end
type() click to toggle source

@return the storage type for this location

# File lib/longleaf/models/filesystem_storage_location.rb, line 16
def type
  StorageTypes::FILESYSTEM_STORAGE_TYPE
end