Module: Synqa
- Defined in:
- lib/synqa.rb
Defined Under Namespace
Classes: BaseSshScp, ContentLocation, ContentTree, DirContentHost, ExternalSshScp, FileContent, HashCommand, InternalSshScp, LocalContentLocation, RelativePathWithHash, RemoteContentLocation, Sha256Command, Sha256SumCommand, SshContentHost, SyncOperation
Instance Method Summary collapse
-
#checkProcessStatus(description) ⇒ Object
Check if the last executed process exited with status 0, if not, raise an exception.
-
#ensureDirectoryExists(directoryName) ⇒ Object
ensure that a directory exists.
-
#executeCommand(command, dryRun) ⇒ Object
Execute a (local) command, or, if dryRun, just pretend to execute it.
-
#getCommandOutput(command) ⇒ Object
Return the enumerated lines of the command’s output.
-
#normalisedDir(baseDir) ⇒ Object
Put “/” at the end of a directory name if it is not already there.
Instance Method Details
#checkProcessStatus(description) ⇒ Object
Check if the last executed process exited with status 0, if not, raise an exception
26 27 28 29 30 31 32 33 34 35 |
# 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) ⇒ Object
ensure that a directory exists
9 10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
Execute a (local) command, or, if dryRun, just pretend to execute it. Raise an exception if the process exit status is not 0.
189 190 191 192 193 194 195 |
# File 'lib/synqa.rb', line 189 def executeCommand(command, dryRun) puts "EXECUTE: #{command}" if not dryRun system(command) checkProcessStatus(command) end end |
#getCommandOutput(command) ⇒ Object
Return the enumerated lines of the command’s output
20 21 22 23 |
# File 'lib/synqa.rb', line 20 def getCommandOutput(command) puts "#{command.inspect} ..." return IO.popen(command) end |
#normalisedDir(baseDir) ⇒ Object
Put “/” at the end of a directory name if it is not already there.
106 107 108 |
# File 'lib/synqa.rb', line 106 def normalisedDir(baseDir) return baseDir.end_with?("/") ? baseDir : baseDir + "/" end |