Sha256: 682848e1f3ef01311b52e2d0482edb3856b8440f47466b9b7989479f85a8355b
Contents?: true
Size: 712 Bytes
Versions: 3
Compression:
Stored size: 712 Bytes
Contents
# frozen_string_literal: true module Lograge module Formatters class KeyValue def call(data) fields_to_display(data) .map { |key| format(key, data[key]) } .join(' ') end protected def fields_to_display(data) data.keys end def format(key, value) "#{key}=#{parse_value(key, value)}" end def parse_value(key, value) # Exactly preserve the previous output # Parsing this can be ambigious if the error messages contains # a single quote return "'#{value}'" if key == :error return Kernel.format('%.2f', value) if value.is_a? Float value end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lograge-0.14.0 | lib/lograge/formatters/key_value.rb |
lograge-0.13.0 | lib/lograge/formatters/key_value.rb |
lograge-0.12.0 | lib/lograge/formatters/key_value.rb |