Class: ExecutionContext
Overview
The context that commands get executed within. Used for defining and scoping helper methods.
Instance Method Summary collapse
- #big_message(msg) ⇒ Object
- #failure(msg) ⇒ Object
-
#initialize ⇒ ExecutionContext
constructor
A new instance of ExecutionContext.
- #note(msg) ⇒ Object
- #puts_with_done(msg, &blk) ⇒ Object
- #start(msg) ⇒ Object
- #success(msg) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize ⇒ ExecutionContext
Returns a new instance of ExecutionContext.
4 5 6 |
# File 'lib/git-smart/execution_context.rb', line 4 def initialize require 'colorize' end |
Instance Method Details
#big_message(msg) ⇒ Object
35 36 37 38 |
# File 'lib/git-smart/execution_context.rb', line 35 def msg spacer_line = (" " + "-" * (msg.length + 20) + " ") [spacer_line, "|" + " " * 10 + msg + " " * 10 + "|", spacer_line].join("\n") end |
#failure(msg) ⇒ Object
30 31 32 33 |
# File 'lib/git-smart/execution_context.rb', line 30 def failure msg puts (msg).red raise GitSmart::RunFailed end |
#note(msg) ⇒ Object
12 13 14 |
# File 'lib/git-smart/execution_context.rb', line 12 def note msg puts "* #{msg}" end |
#puts_with_done(msg, &blk) ⇒ Object
20 21 22 23 24 |
# File 'lib/git-smart/execution_context.rb', line 20 def puts_with_done msg, &blk print "#{msg}..." blk.call puts "done." end |
#start(msg) ⇒ Object
8 9 10 |
# File 'lib/git-smart/execution_context.rb', line 8 def start msg puts "- #{msg} -".green end |
#success(msg) ⇒ Object
26 27 28 |
# File 'lib/git-smart/execution_context.rb', line 26 def success msg puts (msg).green end |
#warn(msg) ⇒ Object
16 17 18 |
# File 'lib/git-smart/execution_context.rb', line 16 def warn msg puts msg.red end |