Exception: Licensed::Shell::Error
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Licensed::Shell::Error
- Defined in:
- lib/licensed/shell.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
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 @stderr = stderr.to_s.strip end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
35 36 37 |
# File 'lib/licensed/shell.rb', line 35 def cmd @cmd end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
35 36 37 |
# File 'lib/licensed/shell.rb', line 35 def status @status end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
35 36 37 |
# File 'lib/licensed/shell.rb', line 35 def stderr @stderr end |
Instance Method Details
#escape_cmd ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/licensed/shell.rb', line 48 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 |
# File 'lib/licensed/shell.rb', line 43 def extra = @stderr.empty?? "" : "#{@stderr.gsub(/^/, " ")}" "'#{escape_cmd}' exited with status #{@exitstatus}\n#{extra}" end |