Class: KamalBackup::Command
- Inherits:
-
Object
- Object
- KamalBackup::Command
- Defined in:
- lib/kamal_backup/command.rb
Class Method Summary collapse
Class Method Details
.available?(name) ⇒ Boolean
29 30 31 32 33 34 |
# File 'lib/kamal_backup/command.rb', line 29 def available?(name) ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).any? do |dir| path = File.join(dir, name) File.executable?(path) && !File.directory?(path) end end |
.capture(spec, input: nil, redactor:) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kamal_backup/command.rb', line 36 def capture(spec, input: nil, redactor:) stdout, stderr, status = Open3.capture3(spec.env, *spec.argv, stdin_data: input) result = CommandResult.new(stdout: stdout, stderr: stderr, status: status.exitstatus) if status.success? result else raise command_failure(spec, status.exitstatus, stdout, stderr, redactor) end rescue Errno::ENOENT => e raise command_not_found(spec, e) end |