Class: DevArchive::Shell
- Inherits:
-
Object
- Object
- DevArchive::Shell
- Defined in:
- lib/dev_archive/shell.rb
Constant Summary collapse
- CODES =
{ red: 31, green: 32, yellow: 33, pink: 35, }.freeze
- CommandFailureError =
Class.new(StandardError)
Instance Method Summary collapse
Instance Method Details
#notify(msg) ⇒ Object
24 25 26 |
# File 'lib/dev_archive/shell.rb', line 24 def notify(msg) print "#{colorize(msg, :yellow)}\n" end |
#puts(msg) ⇒ Object
28 29 30 |
# File 'lib/dev_archive/shell.rb', line 28 def puts(msg) print "#{msg}\n" end |
#run(cmd) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/dev_archive/shell.rb', line 12 def run(cmd) puts(cmd) `#{cmd}` .split("\n") .tap { raise CommandFailureError.new(cmd) unless $? == 0 } end |
#warn(msg) ⇒ Object
20 21 22 |
# File 'lib/dev_archive/shell.rb', line 20 def warn(msg) print "#{colorize(msg, :red)}\n" end |