module Synqa
Public Instance Methods
checkProcessStatus(description)
click to toggle source
Check if the last executed process exited with status 0, if not, raise an exception
# File lib/synqa.rb, line 26 def checkProcessStatus(description) processStatus = $? if not processStatus.exited? raise "#{description}: process did not exit normally" end exitStatus = processStatus.exitstatus if exitStatus != 0 raise "#{description}: exit status = #{exitStatus}" end end
ensureDirectoryExists(directoryName)
click to toggle source
ensure that a directory exists
# File lib/synqa.rb, line 9 def ensureDirectoryExists(directoryName) if File.exist? directoryName if not File.directory? directoryName raise "#{directoryName} is a non-directory file" end else FileUtils.makedirs(directoryName) end end
executeCommand(command, dryRun)
click to toggle source
Execute a (local) command, or, if dryRun, just pretend to execute it. Raise an exception if the process exit status is not 0.
# File lib/synqa.rb, line 189 def executeCommand(command, dryRun) puts "EXECUTE: #{command}" if not dryRun system(command) checkProcessStatus(command) end end
getCommandOutput(command)
click to toggle source
Return the enumerated lines of the command's output
# File lib/synqa.rb, line 20 def getCommandOutput(command) puts "#{command.inspect} ..." return IO.popen(command) end
normalisedDir(baseDir)
click to toggle source
Put “/” at the end of a directory name if it is not already there.
# File lib/synqa.rb, line 106 def normalisedDir(baseDir) return baseDir.end_with?("/") ? baseDir : baseDir + "/" end