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 +4 -0
- data/lib/rails-footnotes.rb +6 -0
- data/lib/rails-footnotes/notes/log_note.rb +25 -24
- data/lib/rails-footnotes/notes/view_note.rb +6 -2
- data/lib/rails-footnotes/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
data/lib/rails-footnotes.rb
CHANGED
@@ -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
|
-
|
6
|
+
|
7
|
+
def self.logs
|
8
|
+
@@logs ||= []
|
9
|
+
end
|
7
10
|
|
8
11
|
def self.log(message)
|
9
|
-
|
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
|
17
|
-
|
23
|
+
def start!
|
24
|
+
self.class.clear_logs
|
18
25
|
end
|
19
26
|
|
20
|
-
def
|
21
|
-
|
27
|
+
def title
|
28
|
+
"Log (#{self.class.logs.size})"
|
22
29
|
end
|
23
30
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
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(
|
13
|
+
escape(Footnotes::Filter.prefix(view, 1, 1))
|
14
14
|
end
|
15
15
|
|
16
16
|
def valid?
|
17
|
-
prefix? &&
|
17
|
+
prefix? && view
|
18
|
+
end
|
19
|
+
|
20
|
+
def view
|
21
|
+
@view ||= Footnotes.view_subscriber.view
|
18
22
|
end
|
19
23
|
|
20
24
|
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:
|
4
|
+
hash: 1923831847
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 4
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 4.0.0.pre.
|
11
|
+
- 7
|
12
|
+
version: 4.0.0.pre.7
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- "Andr\xC3\xA9 Arko"
|