rails3-footnotes 4.0.0.pre.6 → 4.0.0.pre.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == Footnotes v4.0.0.pre.7 (April 5, 2011)
2
+ * rewrite the log note so it actually works! yay!
3
+ * fix the view note to work again (oops)
4
+
1
5
  == Footnotes v4.0.0.pre.6 (April 5, 2011)
2
6
  * fix another Pathname error in Ruby 1.9
3
7
 
@@ -20,6 +20,12 @@ module Footnotes
20
20
  ActionController::Base.after_filter Footnotes::AfterFilter
21
21
  end
22
22
  end
23
+
24
+ # Hook into the logger so we can collect logs
25
+ initializer "rails3-footnotes.hook_logger" do
26
+ raise ArgumentError, "We need a logger to get logs" unless Rails.logger
27
+ Rails.logger.extend Footnotes::LoggingExtensions
28
+ end
23
29
  end
24
30
 
25
31
  end
@@ -3,46 +3,47 @@ require "#{File.dirname(__FILE__)}/abstract_note"
3
3
  module Footnotes
4
4
  module Notes
5
5
  class LogNote < AbstractNote
6
- @@log = []
6
+
7
+ def self.logs
8
+ @@logs ||= []
9
+ end
7
10
 
8
11
  def self.log(message)
9
- @@log << message
12
+ logs << message unless message =~ /SQL|SELECT/
13
+ end
14
+
15
+ def self.clear_logs
16
+ @@logs = []
10
17
  end
11
18
 
12
19
  def initialize(controller)
13
20
  @controller = controller
14
21
  end
15
22
 
16
- def title
17
- "Log (#{log.count("\n")})"
23
+ def start!
24
+ self.class.clear_logs
18
25
  end
19
26
 
20
- def content
21
- escape(log.gsub(/\e\[.+?m/, '')).gsub("\n", '<br />')
27
+ def title
28
+ "Log (#{self.class.logs.size})"
22
29
  end
23
30
 
24
- def log
25
- unless @log
26
- @log = @@log.join('')
27
- @@log = []
28
- if rindex = @log.rindex('Processing '+@controller.class.name+'#'+@controller.action_name)
29
- @log = @log[rindex..-1]
30
- end
31
- end
32
- @log
31
+ def content
32
+ self.class.logs.map do |l|
33
+ escape(l.gsub(/\e\[.+?m/, ''))
34
+ end.join('<br />')
33
35
  end
34
36
 
35
- # FIXME (andre 2011-04-04) Fix this to collect Rails 3 logs
36
- module LoggingExtensions
37
- def add(*args, &block)
38
- logged_message = super
39
- Footnotes::Notes::LogNote.log(logged_message)
40
- logged_message
41
- end
42
- end
37
+ end
38
+ end
43
39
 
44
- Rails.logger.extend LoggingExtensions
40
+ module LoggingExtensions
41
+ def add(*args, &block)
42
+ message = super
43
+ Footnotes::Notes::LogNote.log(message)
44
+ message
45
45
  end
46
46
  end
47
+
47
48
  end
48
49
 
@@ -10,11 +10,15 @@ module Footnotes
10
10
  end
11
11
 
12
12
  def link
13
- escape(Footnotes::Filter.prefix(Footnotes.view_subscriber.view, 1, 1))
13
+ escape(Footnotes::Filter.prefix(view, 1, 1))
14
14
  end
15
15
 
16
16
  def valid?
17
- prefix? && filename
17
+ prefix? && view
18
+ end
19
+
20
+ def view
21
+ @view ||= Footnotes.view_subscriber.view
18
22
  end
19
23
 
20
24
  end
@@ -1,3 +1,3 @@
1
1
  module Footnotes
2
- VERSION = "4.0.0.pre.6"
2
+ VERSION = "4.0.0.pre.7"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails3-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1923831845
4
+ hash: 1923831847
5
5
  prerelease: true
6
6
  segments:
7
7
  - 4
8
8
  - 0
9
9
  - 0
10
10
  - pre
11
- - 6
12
- version: 4.0.0.pre.6
11
+ - 7
12
+ version: 4.0.0.pre.7
13
13
  platform: ruby
14
14
  authors:
15
15
  - "Andr\xC3\xA9 Arko"