Module: Wagemage::Helpers
Instance Method Summary collapse
- #ask ⇒ Object
- #command(cmd, chdir: Dir.pwd, error: false) ⇒ Object
- #say(message, space: false, color: :white) ⇒ Object
- #warning(message) ⇒ Object
Instance Method Details
#ask ⇒ Object
8 9 10 |
# File 'lib/wagemage/helpers.rb', line 8 def ask STDIN.gets.chomp end |
#command(cmd, chdir: Dir.pwd, error: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/wagemage/helpers.rb', line 16 def command(cmd, chdir: Dir.pwd, error: false) stdout, stderr, status = Open3.capture3(cmd, chdir: chdir) unless status.success? error ? (raise Error, stderr) : warning(stderr) end { stdout: stdout, stderr: stderr, status: status } end |
#say(message, space: false, color: :white) ⇒ Object
3 4 5 6 |
# File 'lib/wagemage/helpers.rb', line 3 def say(, space: false, color: :white) puts if space puts .colorize(color.to_sym) end |
#warning(message) ⇒ Object
12 13 14 |
# File 'lib/wagemage/helpers.rb', line 12 def warning() say(, color: :red) end |