Class: Footnotes::Notes::LogNote

Inherits:
AbstractNote show all
Extended by:
LoggingExtensions
Defined in:
lib/rails-footnotes/notes/log_note.rb

Direct Known Subclasses

PartialsNote

Defined Under Namespace

Modules: LoggingExtensions

Constant Summary collapse

@@log =
[]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LoggingExtensions

add

Methods inherited from AbstractNote

close!, #escape, #has_fieldset?, #hash_to_xml_attributes, included?, #javascript, #legend, #link, #mount_table, #mount_table_for_hash, #onclick, #prefix?, #row, start!, #stylesheet, title, #to_sym, to_sym, #valid?

Constructor Details

#initialize(controller) ⇒ LogNote

Returns a new instance of LogNote.



10
11
12
# File 'lib/rails-footnotes/notes/log_note.rb', line 10

def initialize(controller)
  @controller = controller
end

Class Method Details

.log(message) ⇒ Object



6
7
8
# File 'lib/rails-footnotes/notes/log_note.rb', line 6

def self.log(message)
  @@log << message
end

Instance Method Details

#contentObject



18
19
20
# File 'lib/rails-footnotes/notes/log_note.rb', line 18

def content
  escape(log.gsub(/\e\[.+?m/, '')).gsub("\n", '<br />')
end

#logObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/rails-footnotes/notes/log_note.rb', line 22

def log
  unless @log
    @log = @@log.join('')
    @@log = []
    if rindex = @log.rindex('Processing '+@controller.class.name+'#'+@controller.action_name)
      @log = @log[rindex..-1]
    end
  end
  @log
end

#titleObject



14
15
16
# File 'lib/rails-footnotes/notes/log_note.rb', line 14

def title
  "Log (#{log.count("\n")})"
end