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!, #has_fieldset?, included?, #javascript, #legend, #link, #onclick, #row, start!, #stylesheet, title, #to_sym, to_sym, #valid?

Constructor Details

#initialize(controller) ⇒ LogNote

Returns a new instance of LogNote.



12
13
14
# File 'lib/rails-footnotes/notes/log_note.rb', line 12

def initialize(controller)
  @controller = controller
end

Class Method Details

.log(message) ⇒ Object



8
9
10
# File 'lib/rails-footnotes/notes/log_note.rb', line 8

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

Instance Method Details

#contentObject



20
21
22
# File 'lib/rails-footnotes/notes/log_note.rb', line 20

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

#logObject



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

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



16
17
18
# File 'lib/rails-footnotes/notes/log_note.rb', line 16

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