Module: RSpecTelemetry::Formatting

Defined in:
lib/rspec_telemetry/formatting.rb

Overview

Single source of truth for how telemetry numbers are rendered, so the decimal places, sign convention, and ms/s threshold stay consistent across the console report, the comparison table, and the live summary.

Class Method Summary collapse

Class Method Details

.duration(ms) ⇒ Object

Human-friendly duration: seconds past 1000ms, otherwise milliseconds.



11
12
13
14
# File 'lib/rspec_telemetry/formatting.rb', line 11

def duration(ms)
  ms = ms.to_f
  ms >= 1000 ? format("%.2fs", ms / 1000.0) : format("%.1fms", ms)
end

.fixed(value) ⇒ Object



16
# File 'lib/rspec_telemetry/formatting.rb', line 16

def fixed(value) = format("%.1f", value.to_f)

.percent(value) ⇒ Object



22
# File 'lib/rspec_telemetry/formatting.rb', line 22

def percent(value) = format("%.1f%%", value.to_f)

.signed_fixed(value) ⇒ Object



18
# File 'lib/rspec_telemetry/formatting.rb', line 18

def signed_fixed(value) = format("%+.1f", value.to_f)

.signed_integer(value) ⇒ Object



20
# File 'lib/rspec_telemetry/formatting.rb', line 20

def signed_integer(value) = format("%+d", value.to_i)

.signed_percent(value) ⇒ Object



24
# File 'lib/rspec_telemetry/formatting.rb', line 24

def signed_percent(value) = format("%+.1f%%", value.to_f)