Module: GitCommands::Prompt
Defined Under Namespace
Classes: AbortError
Constant Summary collapse
- VALID_ANSWERS =
%w[Y y N n]
Instance Method Summary collapse
- #confirm(message) ⇒ Object
- #error(message) ⇒ Object
- #out ⇒ Object
- #success(message) ⇒ Object
- #warning(message) ⇒ Object
Instance Method Details
#confirm(message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/git_commands/prompt.rb', line 23 def confirm() res = begin ask "#{message} (Y/N)?" end until VALID_ANSWERS.include?(res) case res when /y/i yield else fail(AbortError, "Aborted operation!") end end |
#error(message) ⇒ Object
35 36 37 |
# File 'lib/git_commands/prompt.rb', line 35 def error() out.puts .to_s.red end |
#out ⇒ Object
10 11 12 |
# File 'lib/git_commands/prompt.rb', line 10 def out @out ||= STDOUT end |
#success(message) ⇒ Object
18 19 20 21 |
# File 'lib/git_commands/prompt.rb', line 18 def success() out.puts "\n#{message}".green true end |
#warning(message) ⇒ Object
14 15 16 |
# File 'lib/git_commands/prompt.rb', line 14 def warning() out.puts "\n#{message}".yellow end |