Class: SvgConform::TerminalTheme
- Inherits:
-
Object
- Object
- SvgConform::TerminalTheme
- Defined in:
- lib/svg_conform/quality_report.rb
Overview
Terminal theme configuration for colorful output
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#emojis ⇒ Object
readonly
Returns the value of attribute emojis.
Class Method Summary collapse
Instance Method Summary collapse
- #color_for_level(level) ⇒ Object
- #color_for_severity(severity) ⇒ Object
- #header(text) ⇒ Object
-
#initialize(colors: default_colors, emojis: default_emojis) ⇒ TerminalTheme
constructor
A new instance of TerminalTheme.
- #level_emoji(level) ⇒ Object
- #level_name(level) ⇒ Object
- #separator(text) ⇒ Object
- #wrap(text, color) ⇒ Object
- #wrap_with_level(text, level) ⇒ Object
- #wrap_with_severity(text, severity) ⇒ Object
Constructor Details
#initialize(colors: default_colors, emojis: default_emojis) ⇒ TerminalTheme
Returns a new instance of TerminalTheme.
268 269 270 271 |
# File 'lib/svg_conform/quality_report.rb', line 268 def initialize(colors: default_colors, emojis: default_emojis) @colors = colors @emojis = emojis end |
Instance Attribute Details
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
266 267 268 |
# File 'lib/svg_conform/quality_report.rb', line 266 def colors @colors end |
#emojis ⇒ Object (readonly)
Returns the value of attribute emojis.
266 267 268 |
# File 'lib/svg_conform/quality_report.rb', line 266 def emojis @emojis end |
Class Method Details
.default ⇒ Object
273 274 275 |
# File 'lib/svg_conform/quality_report.rb', line 273 def self.default @default ||= new end |
Instance Method Details
#color_for_level(level) ⇒ Object
289 290 291 |
# File 'lib/svg_conform/quality_report.rb', line 289 def color_for_level(level) @colors[level] || :white end |
#color_for_severity(severity) ⇒ Object
293 294 295 296 297 298 299 300 301 302 |
# File 'lib/svg_conform/quality_report.rb', line 293 def color_for_severity(severity) case severity when :critical then :red when :high, :non_remediable then :yellow when :medium then :magenta when :low then :cyan when :remediable then :green else :white end end |
#header(text) ⇒ Object
312 313 314 |
# File 'lib/svg_conform/quality_report.rb', line 312 def header(text) Rainbow(text).color(:blue) end |
#level_emoji(level) ⇒ Object
304 305 306 |
# File 'lib/svg_conform/quality_report.rb', line 304 def level_emoji(level) @emojis[level] || "•" end |
#level_name(level) ⇒ Object
308 309 310 |
# File 'lib/svg_conform/quality_report.rb', line 308 def level_name(level) level.to_s.upcase end |
#separator(text) ⇒ Object
316 317 318 |
# File 'lib/svg_conform/quality_report.rb', line 316 def separator(text) Rainbow(text).faint end |
#wrap(text, color) ⇒ Object
277 278 279 |
# File 'lib/svg_conform/quality_report.rb', line 277 def wrap(text, color) Rainbow(text).color(color) end |
#wrap_with_level(text, level) ⇒ Object
281 282 283 |
# File 'lib/svg_conform/quality_report.rb', line 281 def wrap_with_level(text, level) Rainbow(text).color(color_for_level(level)) end |
#wrap_with_severity(text, severity) ⇒ Object
285 286 287 |
# File 'lib/svg_conform/quality_report.rb', line 285 def wrap_with_severity(text, severity) Rainbow(text).color(color_for_severity(severity)) end |