Class: Bundler::Thor::Shell::HTML
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Basic
|
|
|
Instance Chain:
self,
Basic
|
|
| Inherits: |
Bundler::Thor::Shell::Basic
|
| Defined in: | lib/bundler/vendor/thor/lib/thor/shell/html.rb |
Overview
Constant Summary
-
BLACK =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 13
Set the terminal’s foreground
HTMLcolor to black."color: black" -
BLUE =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 21
Set the terminal’s foreground
HTMLcolor to blue."color: blue" -
BOLD =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 10
The start of an
HTMLbold sequence."font-weight: bold" -
CYAN =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 25
Set the terminal’s foreground
HTMLcolor to cyan."color: cyan" -
GREEN =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 17
Set the terminal’s foreground
HTMLcolor to green."color: green" -
MAGENTA =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 23
Set the terminal’s foreground
HTMLcolor to magenta."color: magenta" -
ON_BLACK =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 30
Set the terminal’s background
HTMLcolor to black."background-color: black" -
ON_BLUE =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 38
Set the terminal’s background
HTMLcolor to blue."background-color: blue" -
ON_CYAN =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 42
Set the terminal’s background
HTMLcolor to cyan."background-color: cyan" -
ON_GREEN =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 34
Set the terminal’s background
HTMLcolor to green."background-color: green" -
ON_MAGENTA =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 40
Set the terminal’s background
HTMLcolor to magenta."background-color: magenta" -
ON_RED =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 32
Set the terminal’s background
HTMLcolor to red."background-color: red" -
ON_WHITE =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 44
Set the terminal’s background
HTMLcolor to white."background-color: white" -
ON_YELLOW =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 36
Set the terminal’s background
HTMLcolor to yellow."background-color: yellow" -
RED =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 15
Set the terminal’s foreground
HTMLcolor to red."color: red" -
WHITE =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 27
Set the terminal’s foreground
HTMLcolor to white."color: white" -
YELLOW =
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 19
Set the terminal’s foreground
HTMLcolor to yellow."color: yellow"
Class Method Summary
Instance Attribute Summary
- #can_display_colors? ⇒ Boolean readonly protected
Basic - Inherited
Instance Method Summary
-
#ask(statement, color = nil)
Ask something to the user and receives a response.
-
#set_color(string, *colors)
Set color by using a string or one of the defined constants.
Basic - Inherited
| #ask | Asks something to the user and receives a response. |
| #error | Called if something goes wrong during the execution. |
| #file_collision | Deals with file collision and returns true if the file should be overwritten and false otherwise. |
| #indent | Sets the output padding while executing a block and resets it. |
| #no? | Asks the user a question and returns true if the user replies “n” or “no”. |
| #print_in_columns | Prints values in columns. |
| #print_table | Prints a table. |
| #print_wrapped | Prints a long string, word-wrapping the text to the current width of the terminal display. |
| #say | Say (print) something to the user. |
| #say_error | Say (print) an error to the user. |
| #say_status | Say a status with the given color and appends the message. |
| #yes? | Asks the user a question and returns true if the user replies “y” or “yes”. |
| #answer_match, #ask_filtered, #ask_simply, #lookup_color, #prepare_message, #stderr, #stdout, | |
| #set_color | Apply color to the given string with optional bold. |
| #file_collision_help, #is?, #merge, #merge_tool, #show_diff | |
Constructor Details
This class inherits a constructor from Bundler::Thor::Shell::Basic
Instance Attribute Details
#can_display_colors? ⇒ Boolean (readonly, protected)
[ GitHub ]
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 76
def can_display_colors? true end
Instance Method Details
#ask(statement, color = nil)
Ask something to the user and receives a response.
Example
ask("What is your name?")
TODO: Implement #ask for HTML
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 70
def ask(statement, color = nil) raise NotImplementedError, "Implement #ask for Bundler::Thor::Shell::HTML" end
#set_color(string, *colors)
Set color by using a string or one of the defined constants. If a third option is set to true, it also adds bold to the string. This is based on Highline implementation and it automatically appends CLEAR to the end of the returned String.
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 51
def set_color(string, *colors) if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) } html_colors = colors.map { |color| lookup_color(color) } "<span style=\"#{html_colors.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>" else color, bold = colors html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) styles = [html_color] styles << BOLD if bold "<span style=\"#{styles.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>" end end