Class: SimplecovCovview::CovView::Srcfile::Color
- Inherits:
-
Object
- Object
- SimplecovCovview::CovView::Srcfile::Color
- Defined in:
- lib/simplecov_covview/color.rb
Constant Summary collapse
- COLOR_8 =
8 colors colorscheme
{ covered: { color: :white, background: :green }, missed: { color: :white, background: :red }, }
- COLOR_256 =
256 colors colorscheme
{ covered: { color: :black, background: :lightgreen }, missed: { color: :black, background: :lightpink }, }
Instance Method Summary collapse
- #colorize ⇒ Object
- #covered_background ⇒ Object
- #covered_color ⇒ Object
-
#initialize(status, contents) ⇒ Color
constructor
Colorize the source file detail view.
- #missed_background ⇒ Object
- #missed_color ⇒ Object
- #set_colorscheme ⇒ Object
- #use_256colors? ⇒ Boolean
- #use_8colors? ⇒ Boolean
Constructor Details
#initialize(status, contents) ⇒ Color
Colorize the source file detail view
37 38 39 40 41 42 |
# File 'lib/simplecov_covview/color.rb', line 37 def initialize(status, contents) @status = status @contents = contents @colorscheme = {} set_colorscheme end |
Instance Method Details
#colorize ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/simplecov_covview/color.rb', line 75 def colorize return @contents unless (use_8colors? || use_256colors?) case @status when "covered" out_str = Rainbow(@contents).color(covered_color).bg(covered_background) when "missed" out_str = Rainbow(@contents).color(missed_color).bg(missed_background) else out_str = @contents end out_str end |
#covered_background ⇒ Object
63 64 65 |
# File 'lib/simplecov_covview/color.rb', line 63 def covered_background @colorscheme[:covered][:background] end |
#covered_color ⇒ Object
59 60 61 |
# File 'lib/simplecov_covview/color.rb', line 59 def covered_color @colorscheme[:covered][:color] end |
#missed_background ⇒ Object
71 72 73 |
# File 'lib/simplecov_covview/color.rb', line 71 def missed_background @colorscheme[:missed][:background] end |
#missed_color ⇒ Object
67 68 69 |
# File 'lib/simplecov_covview/color.rb', line 67 def missed_color @colorscheme[:missed][:color] end |
#set_colorscheme ⇒ Object
54 55 56 57 |
# File 'lib/simplecov_covview/color.rb', line 54 def set_colorscheme @colorscheme = COLOR_8 if use_8colors? @colorscheme = COLOR_256 if use_256colors? end |
#use_256colors? ⇒ Boolean
49 50 51 |
# File 'lib/simplecov_covview/color.rb', line 49 def use_256colors? SimpleCov::Formatter::CovView.use_256color ||= false end |
#use_8colors? ⇒ Boolean
45 46 47 |
# File 'lib/simplecov_covview/color.rb', line 45 def use_8colors? SimpleCov::Formatter::CovView.use_8color ||= false end |