Sha256: 8d954624b7767cee2633c35b1ff9d747507b2ce32dbcfe4a3f1b2d52444e5446
Contents?: true
Size: 572 Bytes
Versions: 4
Compression:
Stored size: 572 Bytes
Contents
# This module contains formatting functions to help make text more readable. module Sumo::Formatter include Sumo::Error # Given a sumo response (string) def format_json(response) JSON.parse(response) .sort_by { |hash| hash['_messagetime'] } .map { |hash| hash['_raw'] } rescue raise ParseError, 'Could not parse the response.' end def extract_key(key, logs) logs.map { |log| JSON.parse(log)[key] } rescue raise ParseError, "Error extracting the #{key} from the hash." end module_function :format_json, :extract_key end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sumo-search-0.1.1 | lib/sumo/formatter.rb |
sumo-search-0.1.0 | lib/sumo/formatter.rb |
sumo-search-0.0.2 | lib/sumo/formatter.rb |
sumo-search-0.0.1 | lib/sumo/formatter.rb |