Class: Naginata::UI::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/naginata/ui/shell.rb

Constant Summary collapse

LEVELS =
%w(error warn info debug)

Instance Method Summary collapse

Constructor Details

#initializeShell

Returns a new instance of Shell.



8
9
10
11
# File 'lib/naginata/ui/shell.rb', line 8

def initialize
  @shell = Thor::Base.shell.new
  @level = ENV['DEBUG'] ? "debug" : "info"
end

Instance Method Details

#debug(msg, newline = nil) ⇒ Object



25
26
27
# File 'lib/naginata/ui/shell.rb', line 25

def debug(msg, newline = nil)
  tell_me(msg, nil, newline) if level("debug")
end

#error(msg, newline = nil) ⇒ Object



21
22
23
# File 'lib/naginata/ui/shell.rb', line 21

def error(msg, newline = nil)
  tell_me(msg, :red, newline) if level("error")
end

#info(msg, newline = nil) ⇒ Object



13
14
15
# File 'lib/naginata/ui/shell.rb', line 13

def info(msg, newline = nil)
  tell_me(msg, nil, newline) if level("info")
end

#level(name = nil) ⇒ Object



29
30
31
# File 'lib/naginata/ui/shell.rb', line 29

def level(name = nil)
  name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
end


37
38
39
# File 'lib/naginata/ui/shell.rb', line 37

def print_table(array, options = {})
  @shell.print_table(array, options)
end

#warn(msg, newline = nil) ⇒ Object



17
18
19
# File 'lib/naginata/ui/shell.rb', line 17

def warn(msg, newline = nil)
  tell_me(msg, :yellow, newline) if level("warn")
end

#yes?(msg) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/naginata/ui/shell.rb', line 33

def yes?(msg)
  @shell.yes?(msg)
end