Class: SystemCommand
- Inherits:
-
Object
- Object
- SystemCommand
- Defined in:
- lib/helper/system_command.rb
Overview
class to call system command
Class Method Summary collapse
Class Method Details
.exec_command(command) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/helper/system_command.rb', line 14 def exec_command(command) output, error, status = Open3.capture3(command) raise " can not execute command: '\#{command}'\n Output: \#{output}\n Error: \#{error}\n EOS\nend\n".unindent unless status.exitstatus.zero? |
.exists?(command_name) ⇒ Boolean
7 8 9 10 11 12 |
# File 'lib/helper/system_command.rb', line 7 def exists?(command_name) exec_command("which #{Shellwords.escape(command_name)}") true rescue false end |