Sha256: 5c615134f36cc793ebe23383c0cc95f9cf08592f403c3a5f6197a712fd13c160

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

require "json"

module Whoop
  module Formatters
    module JsonFormatter
      # Format the SQL query
      # @param [String] message The SQL query
      # @param [Boolean] colorize - colorize the SQL query (default: false)
      # @return [String] The formatted SQL query
      def self.format(message, colorize: false)
        pretty_json = JSON.pretty_generate(message)
        return pretty_json unless colorize

        formatter = Rouge::Formatters::TerminalTruecolor.new
        lexer = Rouge::Lexers::JSON.new
        formatter.format(lexer.lex(pretty_json))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whoop-1.0.0 lib/whoop/formatters/json_formatter.rb