Sha256: c86d8a2b2919bc7aaaf967875d5e892da21ce9e37b443d234820d8f3e993a698

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require "#{File.dirname(__FILE__)}/abstract_note"
require "#{File.dirname(__FILE__)}/../view_subscriber"

module Footnotes
  module Notes
    class RenderNote < AbstractNote

      def initialize(controller)
        super
        @controller = controller
        @page = Footnotes.view_subscriber.page
      end

      def title
        "<span style=\"background-color:#{color(@page.duration)}\">Render (#{"%.3f" % @page.duration}ms)</span>"
      end

      def content
        html = ''

        if @page
          view = Footnotes.view_subscriber.view_name
          layout = Footnotes.view_subscriber.layout
          partial_time = Footnotes.view_subscriber.partial_time

          rows = [["View", "Layout", "View Render", "Partial Render", "Total Render"],
                  [escape(view), escape(layout), "#{'%.3f' % (@page.duration - partial_time)}ms",
                   "<a href=\"#\" onclick=\"Footnotes.hideAllAndToggle('partials_debug_info');return false;\">#{'%.3f' % partial_time}ms</a>",
                   "#{'%.3f' % @page.duration}ms"]]
          mount_table(rows)
        end
      end

      def color(value)
        value > 500.0 ? "#f00" : "#aaa"
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails3-footnotes-4.0.0.pre.10 lib/rails-footnotes/notes/render_note.rb
rails3-footnotes-4.0.0.pre.9 lib/rails-footnotes/notes/render_note.rb
rails3-footnotes-4.0.0.pre.8 lib/rails-footnotes/notes/render_note.rb
rails3-footnotes-4.0.0.pre.7 lib/rails-footnotes/notes/render_note.rb
rails3-footnotes-4.0.0.pre.6 lib/rails-footnotes/notes/render_note.rb