Module: Bash
- Included in:
- RoCommands::Base, RoHelpers::SetEnvsHelper::ClassMethods
- Defined in:
- lib/ro_helpers/bash.rb
Class Method Summary collapse
Instance Method Summary collapse
- #_bash(cmd) ⇒ Object
- #add_time(str) ⇒ Object
- #bash(*cmds) ⇒ Object
-
#bash_capture(*cmds) ⇒ Object
(also: #bashc)
bash capture cmds result.
- #bash_capture_array(*cmds) ⇒ Object (also: #basha)
- #bash_lines(cmd) ⇒ Object
- #bash_per(*cmds) ⇒ Object
- #bash_system(*cmds) ⇒ Object (also: #bashs, #guard_bash)
- #bundle_exec(cmd) ⇒ Object (also: #bx)
- #err ⇒ Object
- #handle_path(cmd) ⇒ Object
- #kernel_system(cmd) ⇒ Object
- #out ⇒ Object
- #status ⇒ Object
Class Method Details
.err ⇒ Object
13 14 15 |
# File 'lib/ro_helpers/bash.rb', line 13 def err @@err ||= '' end |
.out ⇒ Object
9 10 11 |
# File 'lib/ro_helpers/bash.rb', line 9 def out @@out ||= '' end |
.status ⇒ Object
5 6 7 |
# File 'lib/ro_helpers/bash.rb', line 5 def status @@status ||= '' end |
Instance Method Details
#_bash(cmd) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/ro_helpers/bash.rb', line 30 def _bash(cmd) cmd = handle_path(cmd) Out.table("Running:", "#{cmd}") @@out, @@err, @@status = Open3.capture3(cmd) Out.out add_time(err) Out.out add_time(out) @@out end |
#add_time(str) ⇒ Object
39 40 41 42 43 |
# File 'lib/ro_helpers/bash.rb', line 39 def add_time(str) unless str.empty? "#{Time.now.strftime("%H:%M:%S")}: #{str}" end end |
#bash(*cmds) ⇒ Object
65 66 67 68 69 |
# File 'lib/ro_helpers/bash.rb', line 65 def bash(*cmds) unless cmds.empty? _bash(cmds.flatten.join(" && ")) end end |
#bash_capture(*cmds) ⇒ Object Also known as: bashc
bash capture cmds result
46 47 48 |
# File 'lib/ro_helpers/bash.rb', line 46 def bash_capture(*cmds) bash(*cmds) end |
#bash_capture_array(*cmds) ⇒ Object Also known as: basha
52 53 54 |
# File 'lib/ro_helpers/bash.rb', line 52 def bash_capture_array(*cmds) bash_capture(*cmds).split("\n") end |
#bash_lines(cmd) ⇒ Object
97 98 99 |
# File 'lib/ro_helpers/bash.rb', line 97 def bash_lines(cmd) bash(cmd).split("\n") end |
#bash_per(*cmds) ⇒ Object
91 92 93 94 95 |
# File 'lib/ro_helpers/bash.rb', line 91 def bash_per(*cmds) cmds.each do |c| bash c end end |
#bash_system(*cmds) ⇒ Object Also known as: bashs, guard_bash
71 72 73 74 75 |
# File 'lib/ro_helpers/bash.rb', line 71 def bash_system(*cmds) unless cmds.empty? kernel_system(cmds.flatten.join(" && ")) end end |
#bundle_exec(cmd) ⇒ Object Also known as: bx
85 86 87 |
# File 'lib/ro_helpers/bash.rb', line 85 def bundle_exec(cmd) kernel_system("bundle exec #{cmd}") end |
#handle_path(cmd) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/ro_helpers/bash.rb', line 58 def handle_path(cmd) path = %r{\w*/(\w|/|-)+} r = cmd.gsub(path) do |m| "\'#{m}\'" end end |