Sha256: bb7e1e47b6b930200e1e4e061557f1debb7e866b94f4e349fddeac78bed8c1c0

Contents?: true

Size: 867 Bytes

Versions: 10

Compression:

Stored size: 867 Bytes

Contents

module ActiveTracker
  module OutputHelper
    def escape_ansi(data)
      { 1 => :nothing,
        2 => :nothing,
        4 => :nothing,
        5 => :nothing,
        7 => :nothing,
        30 => :black,
        31 => :red,
        32 => :green,
        33 => :yellow,
        34 => :blue,
        35 => :magenta,
        36 => :cyan,
        37 => :white,
        40 => :nothing,
        41 => :nothing,
        43 => :nothing,
        44 => :nothing,
        45 => :nothing,
        46 => :nothing,
        47 => :nothing,
      }.each do |key, value|
        if value != :nothing
          data.gsub!(/\e\[#{key}m/,"<span style=\"color:#{value}\">")
        else
          data.gsub!(/\e\[#{key}m/,"<span>")
        end
      end
      data.gsub!(/\e\[0m/,'</span>')
      return sanitize(data, tags: %w{span}, attributes: %w{style}).html_safe
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activetracker-0.4.9 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.8 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.7 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.6 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.5 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.4 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.3 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.2 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.1 app/helpers/active_tracker/output_helper.rb
activetracker-0.4.0 app/helpers/active_tracker/output_helper.rb