Sha256: 96243b3636c295eaff0a9bea8a043932ee0421960fe0fd0b59146f5471ee7ed8

Contents?: true

Size: 722 Bytes

Versions: 9

Compression:

Stored size: 722 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, :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

9 entries across 9 versions & 1 rubygems

Version Path
dry-monitor-1.0.1 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-1.0.0 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-0.7.0 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-0.6.3 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-0.6.2 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-0.6.1 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-0.6.0 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-0.5.0 lib/dry/monitor/sql/colorizers/rouge.rb
dry-monitor-0.4.0 lib/dry/monitor/sql/colorizers/rouge.rb