Sha256: 34610af47d18779d9eda4bc6e9f14d96fe531146a787fd78eccad3a30b4e3a89

Contents?: true

Size: 841 Bytes

Versions: 4

Compression:

Stored size: 841 Bytes

Contents

require "action_view"
require "awesome_print"

module DebugExtras
  class Dumper
    include ::ActionView::Context
    include ::ActionView::Helpers::TagHelper

    def initialize(dump, css_class)
      @dump = dump
      @css_class = "debug-extras #{css_class}"
      $debug_extras_add_styles = true
    end

    def render
      message = content_tag(:div, class: @css_class) do
        render_object_names(@dump.ai(Settings.options)).html_safe
      end
      yield message if block_given?
      message
    end

    def render_object_names(dump)
      output = ""
      dump.split("<").map.with_index do |v, k|
        if v.include? ":0x" and not (v.include? "kbd" or v.include? "pre")
          v.sub!(">", "")
        else
          output << "<" unless k.zero?
        end
        output << v
      end
      output
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
debug-extras-0.4.3 lib/debug_extras/dumper.rb
debug-extras-0.4.2 lib/debug_extras/dumper.rb
debug-extras-0.4.1 lib/debug_extras/dumper.rb
debug-extras-0.4.0 lib/debug_extras/dumper.rb