Module: Synqa
- Defined in:
- lib/synqa.rb
Defined Under Namespace
Classes: ContentLocation, ContentTree, DirContentHost, FileContent, HashCommand, 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.
-
#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
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/synqa.rb', line 17 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
6 7 8 9 10 11 12 13 14 |
# File 'lib/synqa.rb', line 6 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 |
#normalisedDir(baseDir) ⇒ Object
Put “/” at the end of a directory name if it is not already there.
97 98 99 |
# File 'lib/synqa.rb', line 97 def normalisedDir(baseDir) return baseDir.end_with?("/") ? baseDir : baseDir + "/" end |