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

.defaultObject



252
253
254
255
256
257
258
# File 'lib/test_bench/output/writer.rb', line 252

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

  policy.to_sym
end

.default!Object



260
261
262
# File 'lib/test_bench/output/writer.rb', line 260

def self.default!
  :detect
end

.detectObject



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

def self.detect = :detect

.offObject



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

def self.off = :off

.onObject



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

def self.on = :on

.styling?(policy, console) ⇒ Boolean

Returns:

  • (Boolean)


235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/test_bench/output/writer.rb', line 235

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