Class: Cumulus::Colors

Inherits:
Object
  • Object
show all
Defined in:
lib/util/Colors.rb

Overview

Public: Provides methods for creating strings with different colors in the console.

Constant Summary collapse

@@colors_enabled =
Configuration.instance.colors_enabled
@@color_prefix =
"\033["
@@no_color =
"#{@@color_prefix}0m"
@@red =
"#{@@color_prefix}0;31m"
@@green =
"#{@@color_prefix}0;32m"
@@orange =
"#{@@color_prefix}1;33m"
@@blue =
"#{@@color_prefix}1;34m"

Class Method Summary collapse

Class Method Details

.added(s) ⇒ Object

Public: color format a string that describes an added resource

s - the string to format

Returns the formatted string



20
21
22
# File 'lib/util/Colors.rb', line 20

def self.added(s)
  self.green(s)
end

.aws_changes(s) ⇒ Object

Public: color format a string that describes the changes in AWS

s - the string to format

Returns the formatted string



47
48
49
# File 'lib/util/Colors.rb', line 47

def self.aws_changes(s)
  self.blue(s)
end

.blue(s) ⇒ Object

Public: Create a string that is blue.

s - the string to format

Returns the blue string



98
99
100
# File 'lib/util/Colors.rb', line 98

def self.blue(s)
  Colors.colorize(s, @@blue)
end

.colorize(s, color) ⇒ Object

Public: create a string that has a specific color. Will not output color if ‘colors_enabled` is set to false. This can be set in “configuration.json”

s - the string to format color - the color to use

Returns the formatted string



67
68
69
70
71
72
73
# File 'lib/util/Colors.rb', line 67

def self.colorize(s, color)
  if @@colors_enabled
    "#{color}#{s}#{@@no_color}"
  else
    s
  end
end

.green(s) ⇒ Object

Public: Create a string that is green.

s - the string to format

Returns the green string



89
90
91
# File 'lib/util/Colors.rb', line 89

def self.green(s)
  Colors.colorize(s, @@green)
end

.local_changes(s) ⇒ Object

Public: color format a string that describes the local changes

s - the string to format

Returns the formatted string



56
57
58
# File 'lib/util/Colors.rb', line 56

def self.local_changes(s)
  self.orange(s)
end

.orange(s) ⇒ Object

Public: Create a string that is orange.

s - the string to format

Returns the orange string



107
108
109
# File 'lib/util/Colors.rb', line 107

def self.orange(s)
  Colors.colorize(s, @@orange)
end

.red(s) ⇒ Object

Public: Create a string that is red.

s - the string to format

Returns the red string



80
81
82
# File 'lib/util/Colors.rb', line 80

def self.red(s)
  Colors.colorize(s, @@red)
end

.removed(s) ⇒ Object

Public: color format a string the describes a removed resource

s - the string to format

Returns the formatted string



38
39
40
# File 'lib/util/Colors.rb', line 38

def self.removed(s)
  self.red(s)
end

.unmanaged(s) ⇒ Object

Public: color format a string that describes an unmanaged resource

s - the string to format

Returns the formatted string



29
30
31
# File 'lib/util/Colors.rb', line 29

def self.unmanaged(s)
  self.red(s)
end