Sha256: 345d777e90e9c9ab3d69625d2da78de903db7a0c24aa75058755c7dcb763ea91

Contents?: true

Size: 712 Bytes

Versions: 2

Compression:

Stored size: 712 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

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