Module: Backup::Utilities::Helpers
- Included in:
- Archive, Compressor::Base, Compressor::Gzip, Config, Database::Base, Encryptor::Base, Notifier::Base, Packager, Pipeline, RemoteArchive, RemoteData, Splitter, Storage::RSync, Syncer::Base
- Defined in:
- lib/backup/utilities.rb
Overview
Allows these utility methods to be included in other classes, while allowing them to be stubbed in spec_helper for all specs.
Instance Method Summary collapse
-
#utility_remote(name) ⇒ Object
Returns the full path to the specified utility.
Instance Method Details
#utility_remote(name) ⇒ Object
Returns the full path to the specified utility. Raises an error if utility can not be found in the system’s $PATH
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/backup/utilities.rb', line 229 def utility_remote(name) name = name.to_s.strip raise Error, 'Utility Name Empty' if name.empty? req = Backup::Remote::Command.new cmd = %Q(which '#{ name }' 2>/dev/null) res = req.run_ssh_cmd(server_host, , cmd) output = res[:output].chomp raise Error, " Could not locate '\#{ name }'.\n Reason: \#{output}, \#{res[:error]}.\n EOS\n\n\n UTILITY[name] ||= output\n\n\n UTILITY[name].dup\nend\n" if res[:res]==0 || output.empty? |