Class Uttk::Dumpers::Html
In: lib/uttk/dumpers/Html.rb
Parent: Dumper

Use me at least with the Compact filter:

 Compact: [NodeCut: [!skip ^contents$, [Html: [log.html]]]]

Methods

clean_js_str   close   id_of   new   new_id   new_leaf   new_node   reset  

Included Modules

Concrete

Public Class methods

[Source]

# File lib/uttk/dumpers/Html.rb, line 260
      def self.clean_js_str ( str )
        res = str.to_s.html_encode.dump
        res.gsub!(/([^\\])\\n/, '\1<BR>\n')
        res
      end

[Source]

# File lib/uttk/dumpers/Html.rb, line 142
      def initialize ( *a, &b )
        @uttk_js = base_url + 'javascripts/uttk.js'
        @uttk_css = base_url + 'stylesheets/uttk.css'
        super
        reset
      end

Protected Instance methods

[Source]

# File lib/uttk/dumpers/Html.rb, line 209
      def close
        super
        x = XmlMarkup.new(:indent => 2, :target => self)
        x.html do
          x.head do
            x.script '', :language => 'javascript', :src => @uttk_js
            x.style :type => 'text/css' do
              x.itext! "@import url('#@uttk_css');"
            end
            x.script :language => 'javascript' do
              @elts.each do |elt|
                x << elt.to_html_uttk_js(@status) << "\n"
              end
            end
          end
          x.body :onLoad => 'uttk_main()' do
            x.table :class => 'uttk_infos' do
              x.tr :class => 'uttk_infos_box' do
                x.expand_and_collapse 'null', ''
                x.expand_and_collapse "'node'", 'nodes'
                x.expand_and_collapse "'leaf'", 'leaves'
              end
            end
            x.div '', :id => 'uttk_contents'
          end
        end
        reset
      end

[Source]

# File lib/uttk/dumpers/Html.rb, line 240
      def id_of ( prefix, path )
        path = path.inspect
        @ids[prefix] ||= {}
        result = @ids[prefix][path]
        if result.nil?
          result = @ids[prefix][path] = new_id(prefix)
        end
        result
      end

[Source]

# File lib/uttk/dumpers/Html.rb, line 252
      def new_id ( prefix )
        id = "#{prefix}#{@current_ids[prefix]}"
        @current_ids[prefix] += 1
        id.dump
      end

[Source]

# File lib/uttk/dumpers/Html.rb, line 177
      def new_leaf ( path, leaf )
        super
        if path.last.segment == :status
          @status[id_of(:status, path)] = leaf
          @elts.pop
        else
          father = id_of :node, path
          path << leaf
          id = id_of :leaf, path
          contents = leaf
          n = @elts.pop
          father, leaf, id, status = n.father, n.name, n.id, n.status
          state, status = 0, ''
          if contents.is_a? Hash
            status = contents[:status]
            [:status].each do |k|
              contents.delete k if contents.has_key? k
            end
          else
            state = 2
          end
          @elts << Leaf.new(:father   => father,
                            :id       => id,
                            :name     => leaf,
                            :status   => status,
                            :state    => state,
                            :contents => contents)
        end
      end

[Source]

# File lib/uttk/dumpers/Html.rb, line 161
      def new_node ( path, node )
        super
        father = id_of :node, path
        path << node
        id = id_of :node, path
        path << :status
        status = id_of :status, path
        @elts << Node.new(:father => father,
                          :name   => node.segment,
                          :id     => id,
                          :status => status,
                          :state  => 1)
      end

[Source]

# File lib/uttk/dumpers/Html.rb, line 150
      def reset
        @current_ids = Hash.new(0)
        @ids = {}
        @ids[:node] = { '/' => 'null' }
        @elts = []
        @status = Hash.new('"NONE"')
        @x = Builder::XmlMarkup.new(:target => self, :indent => 2)
      end

[Validate]