Module: TestBench::Output::Writer::Styling

Defined in:
lib/test_bench/output/writer.rb

Constant Summary collapse

Error =
Class.new(RuntimeError)

Class Method Summary collapse

Class Method Details

.assure_styling(policy, console = nil) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/test_bench/output/writer.rb', line 165

def self.assure_styling(policy, console=nil)
  console ||= false

  case policy
  when on
    true
  when off
    false
  when detect
    console ? true : false
  else
    raise Error, "Unknown styling policy #{policy.inspect}"
  end
end

.defaultObject



184
185
186
187
188
189
190
# File 'lib/test_bench/output/writer.rb', line 184

def self.default
  policy = ENV.fetch('TEST_BENCH_OUTPUT_STYLING') do
    return default!
  end

  policy.to_sym
end

.default!Object



192
193
194
# File 'lib/test_bench/output/writer.rb', line 192

def self.default!
  :detect
end

.detectObject



182
# File 'lib/test_bench/output/writer.rb', line 182

def self.detect = :detect

.offObject



181
# File 'lib/test_bench/output/writer.rb', line 181

def self.off = :off

.onObject



180
# File 'lib/test_bench/output/writer.rb', line 180

def self.on = :on

.styling?(policy, console) ⇒ Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/test_bench/output/writer.rb', line 161

def self.styling?(policy, console)
  assure_styling(policy, console)
end