Module: Pangolin::Output::Formatting
- Included in:
- JavacCommon, JunitCommon
- Defined in:
- lib/pangolin/output/formatting.rb
Constant Summary collapse
- FORMATTING =
{ # colors :black => "\e[30m", :red => "\e[31m", :green => "\e[32m", :yellow => "\e[33m", :blue => "\e[34m", :magenta => "\e[35m", :cyan => "\e[36m", :white => "\e[37m", # text styles :bold => "\e[1m", :underline => "\e[4m", :blink => "\e[5m", :reverse => "\e[7m", :concealed => "\e[8m", # backgrounds :black_bg => "\e[40m", :red_bg => "\e[41m", :green_bg => "\e[42m", :yellow_bg => "\e[43m", :blue_bg => "\e[44m", :magenta_bg => "\e[45m", :cyan_bg => "\e[46m", :white_bg => "\e[47m" }
- FORMATTING_OFF =
"\e[0m"
Instance Method Summary collapse
- #format_error(text) ⇒ Object
- #format_error_header(text) ⇒ Object
- #format_header(text) ⇒ Object
- #format_stack_trace(text) ⇒ Object
- #format_text(text, formatting) ⇒ Object
- #format_warning_header(text) ⇒ Object
Instance Method Details
#format_error(text) ⇒ Object
61 62 63 |
# File 'lib/pangolin/output/formatting.rb', line 61 def format_error(text) format_text(text, :red) end |
#format_error_header(text) ⇒ Object
53 54 55 |
# File 'lib/pangolin/output/formatting.rb', line 53 def format_error_header(text) format_text(text, [:red, :bold]) end |
#format_header(text) ⇒ Object
49 50 51 |
# File 'lib/pangolin/output/formatting.rb', line 49 def format_header(text) format_text(text, :bold) end |
#format_stack_trace(text) ⇒ Object
65 66 67 |
# File 'lib/pangolin/output/formatting.rb', line 65 def format_stack_trace(text) text end |
#format_text(text, formatting) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pangolin/output/formatting.rb', line 38 def format_text(text, formatting) if @colorize format_codes = [formatting].flatten format_codes.reject! { |f| FORMATTING[f].nil? } format_codes.map! { |f| FORMATTING[f] } format_codes.join + text + FORMATTING_OFF else text end end |
#format_warning_header(text) ⇒ Object
57 58 59 |
# File 'lib/pangolin/output/formatting.rb', line 57 def format_warning_header(text) format_text(text, [:yellow, :bold]) end |