Class: Kdep::UI
- Inherits:
-
Object
- Object
- Kdep::UI
- Defined in:
- lib/kdep/ui.rb
Constant Summary collapse
- COLORS =
{ :red => "\e[31m", :green => "\e[32m", :yellow => "\e[33m", :blue => "\e[34m", :bold => "\e[1m", :reset => "\e[0m", }.freeze
Instance Method Summary collapse
- #error(msg) ⇒ Object
- #file_written(path) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(color: $stdout.tty?) ⇒ UI
constructor
A new instance of UI.
- #success(msg) ⇒ Object
- #summary(files_count, errors_count) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize(color: $stdout.tty?) ⇒ UI
Returns a new instance of UI.
12 13 14 |
# File 'lib/kdep/ui.rb', line 12 def initialize(color: $stdout.tty?) @color = color end |
Instance Method Details
#error(msg) ⇒ Object
20 21 22 |
# File 'lib/kdep/ui.rb', line 20 def error(msg) $stderr.puts colorize(:red, "error: #{msg}") end |
#file_written(path) ⇒ Object
32 33 34 |
# File 'lib/kdep/ui.rb', line 32 def file_written(path) puts " #{colorize(:green, 'create')} #{path}" end |
#info(msg) ⇒ Object
28 29 30 |
# File 'lib/kdep/ui.rb', line 28 def info(msg) puts msg end |
#success(msg) ⇒ Object
16 17 18 |
# File 'lib/kdep/ui.rb', line 16 def success(msg) puts colorize(:green, msg) end |
#summary(files_count, errors_count) ⇒ Object
36 37 38 39 |
# File 'lib/kdep/ui.rb', line 36 def summary(files_count, errors_count) status = errors_count > 0 ? :red : :green puts colorize(status, "#{files_count} files rendered, #{errors_count} errors") end |
#warn(msg) ⇒ Object
24 25 26 |
# File 'lib/kdep/ui.rb', line 24 def warn(msg) $stderr.puts colorize(:yellow, "warning: #{msg}") end |