class Synqa::HashCommand

A command to be executed on the remote system which calculates a hash value for a file (of a given length), in the format: hexadecimal-hash a-fixed-number-of-characters file-name

Attributes

command[R]

The command - a string or array of strings e.g. “sha256sum” or [“sha256”, “-r”]

length[R]

The length of the calculated hash value e.g. 64 for sha256

spacerLen[R]

The number of characters between the hash value and the file name (usually 1 or 2)

Public Class Methods

new(command, length, spacerLen) click to toggle source
# File lib/synqa.rb, line 67
def initialize(command, length, spacerLen)
  @command = command
  @length = length
  @spacerLen = spacerLen
end

Public Instance Methods

parseFileHashLine(baseDir, fileHashLine) click to toggle source

Parse a hash line relative to a base directory, returning a RelativePathWithHash

# File lib/synqa.rb, line 74
def parseFileHashLine(baseDir, fileHashLine)
  hash = fileHashLine[0...length]
  fullPath = fileHashLine[(length + spacerLen)..-1]
  if fullPath.start_with?(baseDir)
    return RelativePathWithHash.new(fullPath[baseDir.length..-1], hash)
  else
    raise "File #{fullPath} from hash line is not in base dir #{baseDir}"
  end
end
to_s() click to toggle source
# File lib/synqa.rb, line 84
def to_s
  return command.join(" ")
end