Module: Bash
- Included in:
- RoCommands::Base, RoHelpers::SetEnvsHelper::ClassMethods
- Defined in:
- lib/ro_commands/helpers/bash.rb
Class Method Summary collapse
Instance Method Summary collapse
- #_bash(cmd) ⇒ Object
- #bash(*cmds) ⇒ Object
- #bash_lines(cmd) ⇒ Object
- #bash_per(*cmds) ⇒ Object
-
#bashc(*cmds) ⇒ Object
bash capture cmds result.
- #handle_path(cmd) ⇒ Object
Class Method Details
.err ⇒ Object
13 14 15 |
# File 'lib/ro_commands/helpers/bash.rb', line 13 def err @@err ||= nil end |
.out ⇒ Object
9 10 11 |
# File 'lib/ro_commands/helpers/bash.rb', line 9 def out @@out ||= nil end |
.status ⇒ Object
5 6 7 |
# File 'lib/ro_commands/helpers/bash.rb', line 5 def status @@status ||= nil end |
Instance Method Details
#_bash(cmd) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/ro_commands/helpers/bash.rb', line 18 def _bash(cmd) cmd = handle_path(cmd) Out.out("Running: #{cmd}") @@out, @@err, @@status = Open3.capture3(cmd) Out.out @@out Out.out @@err @@status end |
#bash(*cmds) ⇒ Object
44 45 46 47 48 |
# File 'lib/ro_commands/helpers/bash.rb', line 44 def bash(*cmds) unless cmds.empty? _bash(cmds.flatten.join(" && ")) end end |
#bash_lines(cmd) ⇒ Object
56 57 58 |
# File 'lib/ro_commands/helpers/bash.rb', line 56 def bash_lines(cmd) bash(cmd).split("\n") end |
#bash_per(*cmds) ⇒ Object
50 51 52 53 54 |
# File 'lib/ro_commands/helpers/bash.rb', line 50 def bash_per(*cmds) cmds.each do |c| bash c end end |
#bashc(*cmds) ⇒ Object
bash capture cmds result
28 29 30 31 32 33 34 35 |
# File 'lib/ro_commands/helpers/bash.rb', line 28 def bashc(*cmds) bash(*cmds) if @@status.success? @@out else @@err end end |
#handle_path(cmd) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/ro_commands/helpers/bash.rb', line 37 def handle_path(cmd) path = %r{\w*/(\w|/|-)+} r = cmd.gsub(path) do |m| "\'#{m}\'" end end |