Class: ArchSpec::Formatters::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/archspec/formatters/style.rb

Overview

ANSI styling for terminal output, shared by the formatters. Enabled only when the output is a TTY and NO_COLOR is unset.

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Style

Returns a new instance of Style.



8
9
10
# File 'lib/archspec/formatters/style.rb', line 8

def initialize(output)
  @enabled = output.respond_to?(:tty?) && output.tty? && ENV['NO_COLOR'].to_s.empty?
end

Instance Method Details

#bold(text) ⇒ Object



12
13
14
# File 'lib/archspec/formatters/style.rb', line 12

def bold(text)
  paint(text, '1')
end

#faint(text) ⇒ Object



28
29
30
# File 'lib/archspec/formatters/style.rb', line 28

def faint(text)
  paint(text, '2')
end

#marker(text) ⇒ Object



20
21
22
# File 'lib/archspec/formatters/style.rb', line 20

def marker(text)
  paint(text, '1;31')
end

#note(text) ⇒ Object



24
25
26
# File 'lib/archspec/formatters/style.rb', line 24

def note(text)
  paint(text, '1;36')
end

#severity(text) ⇒ Object



16
17
18
# File 'lib/archspec/formatters/style.rb', line 16

def severity(text)
  paint(text, '1;31')
end