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



177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/test_bench/output/writer.rb', line 177

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



196
197
198
199
200
201
202
# File 'lib/test_bench/output/writer.rb', line 196

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

  policy.to_sym
end

.default!Object



204
205
206
# File 'lib/test_bench/output/writer.rb', line 204

def self.default!
  :detect
end

.detectObject



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

def self.detect = :detect

.offObject



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

def self.off = :off

.onObject



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

def self.on = :on

.styling?(policy, console) ⇒ Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/test_bench/output/writer.rb', line 173

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