Exception: Licensed::Shell::Error
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Licensed::Shell::Error
- Defined in:
- lib/licensed/shell.rb
Instance Method Summary collapse
- #escape_cmd ⇒ Object
-
#initialize(cmd, status, stderr) ⇒ Error
constructor
A new instance of Error.
- #message ⇒ Object
Constructor Details
#initialize(cmd, status, stderr) ⇒ Error
Returns a new instance of Error.
36 37 38 39 40 41 |
# File 'lib/licensed/shell.rb', line 36 def initialize(cmd, status, stderr) super() @cmd = cmd @exitstatus = status @output = stderr end |
Instance Method Details
#escape_cmd ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/licensed/shell.rb', line 49 def escape_cmd @cmd.map do |arg| if arg =~ /[\s'"]/ escaped = arg.gsub(/([\\"])/, '\\\\\1') %("#{escaped}") else arg end end.join(" ") end |
#message ⇒ Object
43 44 45 46 47 |
# File 'lib/licensed/shell.rb', line 43 def output = @output.to_s.strip extra = output.empty?? "" : "\n#{output.gsub(/^/, " ")}" "command exited with status #{@exitstatus}\n #{escape_cmd}#{extra}" end |