Sha256: fc125630ff80736c59247f82c79de179f5e9325f472af1166b1b77bfb15f5459

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

module Footnotes
  module Notes
    class PartialsNote < AbstractNote

      cattr_accessor :partials

      def self.start!(controller)
        self.partials = []
        @subscriber ||= ActiveSupport::Notifications.subscribe('render_partial.action_view') do |*args|
          event = ActiveSupport::Notifications::Event.new *args
          self.partials << {:file => event.payload[:identifier], :duration => event.duration}
        end
      end

      def initialize(controller)
        @controller = controller
      end

      def row
        :edit
      end

      def title
        "Partials (#{partials.size})"
      end

      def content
        rows = self.class.partials.map do |partial|
          href = Footnotes::Filter.prefix(partial[:file],1,1)
          shortened_name = partial[:file].gsub(File.join(Rails.root,"app/views/"),"")
          [%{<a href="#{href}">#{shortened_name}</a>},"#{partial[:duration]}ms"]
        end
        mount_table(rows.unshift(%w(Partial Time)), :summary => "Partials for #{title}")
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
rails-footnotes-7.0.0 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-5.0.0 lib/rails-footnotes/notes/partials_note.rb
rails6-footnotes-5.0.2 lib/rails-footnotes/notes/partials_note.rb
rails6-footnotes-5.0.1 lib/rails-footnotes/notes/partials_note.rb
rails6-footnotes-5.0.0 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.8 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.7 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.6 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.5 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.4 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.3 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.2 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.1 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.1.0 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.0.2 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.0.1 lib/rails-footnotes/notes/partials_note.rb
rails-footnotes-4.0.0 lib/rails-footnotes/notes/partials_note.rb