Sha256: c9804110b67a4b2004223e2d2f9d0bc7035bd003a0e862920cafbfa4efe4b35e

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

require "rouge/util"
require "rouge/token"
require "rouge/theme"
require "rouge/themes/gruvbox"
require "rouge/formatter"
require "rouge/formatters/terminal256"
require "rouge/lexer"
require "rouge/regex_lexer"
require "rouge/lexers/sql"

module Dry
  module Monitor
    module SQL
      module Colorizers
        class Rouge
          attr_reader :formatter
          attr_reader :lexer

          def initialize(theme)
            @formatter = ::Rouge::Formatters::Terminal256.new(theme || ::Rouge::Themes::Gruvbox.new)
            @lexer = ::Rouge::Lexers::SQL.new
          end

          def call(string)
            formatter.format(lexer.lex(string))
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-monitor-0.3.2 lib/dry/monitor/sql/colorizers/rouge.rb