Module: SystemCommandHelper
- Defined in:
- lib/system_command_helper.rb,
lib/system_command_helper/version.rb
Constant Summary collapse
- VERSION =
"0.2.1"
Instance Attribute Summary collapse
-
#no_exec ⇒ Object
Returns the value of attribute no_exec.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
Instance Method Summary collapse
Instance Attribute Details
#no_exec ⇒ Object
Returns the value of attribute no_exec.
4 5 6 |
# File 'lib/system_command_helper.rb', line 4 def no_exec @no_exec end |
#quiet ⇒ Object
Returns the value of attribute quiet.
4 5 6 |
# File 'lib/system_command_helper.rb', line 4 def quiet @quiet end |
Instance Method Details
#cap(cmd) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/system_command_helper.rb', line 19 def cap(cmd) unless @quiet puts "\e[35m#{Dir.pwd}$\e[0m `#{cmd}`" end unless @no_exec `#{cmd}` end end |
#on_error(&block) ⇒ Object
28 29 30 |
# File 'lib/system_command_helper.rb', line 28 def on_error(&block) @on_error = block end |
#sys(cmd) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/system_command_helper.rb', line 6 def sys(cmd) unless @quiet puts "\e[35m#{Dir.pwd}$\e[0m #{cmd}" end unless @no_exec result = system cmd if result != 0 && @on_error @on_error.call(cmd, result) end result end end |