Module: Acclimate::Output

Defined in:
lib/acclimate/output.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/acclimate/output.rb', line 6

def self.included( base )
  base.send( :include, Thor::Shell )
end

Instance Method Details

#confirm(msg, color = :white, &block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/acclimate/output.rb', line 38

def confirm( msg, color=:white, &block )
  write "#{msg}... ", color
  block.call
  say_ok
rescue ConfirmationError => e
  say_error
  say_stderr( e.message, :red )
  e.finish
  raise Acclimate::Error.new( nil, handled: true, exit_code: e.exit_code )
rescue
  say_error
  raise
end

#header(msg) ⇒ Object



22
23
24
# File 'lib/acclimate/output.rb', line 22

def header( msg )
  say msg, :cyan
end

#say(msg, color = :white) ⇒ Object



14
15
16
# File 'lib/acclimate/output.rb', line 14

def say( msg, color=:white )
  $stdout.puts( Rainbow( msg ).color( color ))
end

#say_errorObject



30
31
32
# File 'lib/acclimate/output.rb', line 30

def say_error
  say_stderr 'ERROR', :red
end

#say_okObject



26
27
28
# File 'lib/acclimate/output.rb', line 26

def say_ok
  say 'OK', :green
end

#say_skippingObject



34
35
36
# File 'lib/acclimate/output.rb', line 34

def say_skipping
  say 'SKIPPING', :yellow
end

#say_stderr(msg, color = :white) ⇒ Object



18
19
20
# File 'lib/acclimate/output.rb', line 18

def say_stderr( msg, color=:white )
  $stdout.puts( Rainbow( msg ).color( color ))
end

#write(msg, color = :white) ⇒ Object



10
11
12
# File 'lib/acclimate/output.rb', line 10

def write( msg, color=:white )
  $stdout.write( Rainbow( msg ).color( color ))
end