rails-footnotes 3.6.3 → 3.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +21 -21
- data/README +140 -141
- data/Rakefile +20 -20
- data/lib/rails-footnotes.rb +19 -19
- data/lib/rails-footnotes/backtracer.rb +33 -33
- data/lib/rails-footnotes/footnotes.rb +2 -2
- data/lib/rails-footnotes/notes/assigns_note.rb +15 -15
- data/lib/rails-footnotes/notes/controller_note.rb +64 -64
- data/lib/rails-footnotes/notes/cookies_note.rb +17 -17
- data/lib/rails-footnotes/notes/env_note.rb +19 -19
- data/lib/rails-footnotes/notes/files_note.rb +43 -43
- data/lib/rails-footnotes/notes/filters_note.rb +52 -52
- data/lib/rails-footnotes/notes/general_note.rb +18 -18
- data/lib/rails-footnotes/notes/javascripts_note.rb +15 -15
- data/lib/rails-footnotes/notes/layout_note.rb +28 -28
- data/lib/rails-footnotes/notes/log_note.rb +47 -36
- data/lib/rails-footnotes/notes/params_note.rb +16 -16
- data/lib/rails-footnotes/notes/queries_note.rb +152 -152
- data/lib/rails-footnotes/notes/routes_note.rb +59 -59
- data/lib/rails-footnotes/notes/rpm_note.rb +24 -24
- data/lib/rails-footnotes/notes/session_note.rb +15 -15
- data/lib/rails-footnotes/notes/stylesheets_note.rb +15 -15
- data/lib/rails-footnotes/notes/view_note.rb +35 -35
- data/test/footnotes_test.rb +198 -198
- data/test/notes/abstract_note_test.rb +106 -106
- data/test/test_helper.rb +8 -8
- metadata +3 -3
data/MIT-LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
Copyright (c) 2006 Coda Hale
|
2
|
-
Copyright (c) 2008 José Valim (jose.valim at gmail dot com)
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2006 Coda Hale
|
2
|
+
Copyright (c) 2008 José Valim (jose.valim at gmail dot com)
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
CHANGED
@@ -1,141 +1,140 @@
|
|
1
|
-
Rails Footnotes
|
2
|
-
License: MIT
|
3
|
-
Version: 3.6.
|
4
|
-
|
5
|
-
You can also read this README in pretty html at the GitHub project Wiki page
|
6
|
-
|
7
|
-
http://wiki.github.com/josevalim/rails-footnotes
|
8
|
-
|
9
|
-
|
10
|
-
Description
|
11
|
-
-----------
|
12
|
-
|
13
|
-
If you are developing in Rails you should know the plugin! It displays
|
14
|
-
footnotes in your application for easy debugging, such as sessions,
|
15
|
-
request parameters, cookies, filter chain, routes, queries, etc.
|
16
|
-
|
17
|
-
Even more, it contains links to open files directly in your editor including
|
18
|
-
your backtrace lines.
|
19
|
-
|
20
|
-
|
21
|
-
Installation
|
22
|
-
------------
|
23
|
-
|
24
|
-
Install Rails Footnotes is very easy. If you are running on Rails 2.3 just run
|
25
|
-
the following:
|
26
|
-
|
27
|
-
gem
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
#
|
96
|
-
#
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
#
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
If you
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
http://blog.inquirylabs.com/
|
1
|
+
Rails Footnotes
|
2
|
+
License: MIT
|
3
|
+
Version: 3.6.4
|
4
|
+
|
5
|
+
You can also read this README in pretty html at the GitHub project Wiki page
|
6
|
+
|
7
|
+
http://wiki.github.com/josevalim/rails-footnotes
|
8
|
+
|
9
|
+
|
10
|
+
Description
|
11
|
+
-----------
|
12
|
+
|
13
|
+
If you are developing in Rails you should know the plugin! It displays
|
14
|
+
footnotes in your application for easy debugging, such as sessions,
|
15
|
+
request parameters, cookies, filter chain, routes, queries, etc.
|
16
|
+
|
17
|
+
Even more, it contains links to open files directly in your editor including
|
18
|
+
your backtrace lines.
|
19
|
+
|
20
|
+
|
21
|
+
Installation
|
22
|
+
------------
|
23
|
+
|
24
|
+
Install Rails Footnotes is very easy. If you are running on Rails 2.3 just run
|
25
|
+
the following:
|
26
|
+
|
27
|
+
sudo gem install rails-footnotes
|
28
|
+
|
29
|
+
In RAILS_ROOT/config/environments/development.rb (yes, you want it only in development):
|
30
|
+
|
31
|
+
config.gem "rails-footnotes"
|
32
|
+
|
33
|
+
If you want it as plugin, just do:
|
34
|
+
|
35
|
+
script/plugin install git://github.com/josevalim/rails-footnotes.git
|
36
|
+
|
37
|
+
Configuration
|
38
|
+
-------------
|
39
|
+
|
40
|
+
If you are not using Textmate as text editor, in your environment.rb or
|
41
|
+
in an initializer do:
|
42
|
+
|
43
|
+
if defined?(Footnotes)
|
44
|
+
Footnotes::Filter.prefix = 'txmt://open?url=file://%s&line=%d&column=%d'
|
45
|
+
end
|
46
|
+
|
47
|
+
Where you are going to choose a prefix compatible with your text editor. The %s is
|
48
|
+
replaced by the name of the file, the first %d is replaced by the line number and
|
49
|
+
the second %d is replaced by the column.
|
50
|
+
|
51
|
+
By default, footnotes are appended at the end of the page with default stylesheet. If you want
|
52
|
+
to change their position, you can define a div with id "footnotes_holder" or define your own stylesheet
|
53
|
+
by turning footnotes stylesheet off:
|
54
|
+
|
55
|
+
Footnotes::Filter.no_style = true
|
56
|
+
|
57
|
+
Another option is to allow multiple notes to be opened at the same time:
|
58
|
+
|
59
|
+
Footnotes::Filter.multiple_notes = true
|
60
|
+
|
61
|
+
Finally, you can control which notes you want to show. The default are:
|
62
|
+
|
63
|
+
Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :env, :queries, :log, :general]
|
64
|
+
|
65
|
+
|
66
|
+
Creating your own notes
|
67
|
+
-----------------------
|
68
|
+
|
69
|
+
Create your notes to integrate with Footnotes is easy.
|
70
|
+
|
71
|
+
1. Create a Footnotes::Notes::YourExampleNote class
|
72
|
+
|
73
|
+
2. Implement the necessary methods (check abstract_note.rb file in lib/notes)
|
74
|
+
|
75
|
+
3. Append your example note in Footnotes::Filter.notes array (usually at the end of your environment file or in an initializer):
|
76
|
+
|
77
|
+
For example, to create a note that shows info about the user logged in your application you just have to do:
|
78
|
+
|
79
|
+
module Footnotes
|
80
|
+
module Notes
|
81
|
+
class CurrentUserNote < AbstractNote
|
82
|
+
# This method always receives a controller
|
83
|
+
#
|
84
|
+
def initialize(controller)
|
85
|
+
@current_user = controller.instance_variable_get("@current_user")
|
86
|
+
end
|
87
|
+
|
88
|
+
# The name that will appear as legend in fieldsets
|
89
|
+
#
|
90
|
+
def legend
|
91
|
+
"Current user: #{@current_user.name}"
|
92
|
+
end
|
93
|
+
|
94
|
+
# This Note is only valid if we actually found an user
|
95
|
+
# If it's not valid, it won't be displayed
|
96
|
+
#
|
97
|
+
def valid?
|
98
|
+
@current_user
|
99
|
+
end
|
100
|
+
|
101
|
+
# The fieldset content
|
102
|
+
#
|
103
|
+
def content
|
104
|
+
escape(@current_user.inspect)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
Then put in your environment:
|
111
|
+
|
112
|
+
Footnotes::Filter.notes += [:current_user]
|
113
|
+
|
114
|
+
|
115
|
+
Colaborators
|
116
|
+
------------
|
117
|
+
|
118
|
+
* Leon Li - http://github.com/scorpio
|
119
|
+
* Keenan Brock - http://github.com/kbrock
|
120
|
+
* Ivan Storck - http://github.com/ivanoats
|
121
|
+
* Kris Chamber - http://github.com/kristopher
|
122
|
+
|
123
|
+
|
124
|
+
Bugs and Feedback
|
125
|
+
-----------------
|
126
|
+
|
127
|
+
If you discover any bugs, please send an e-mail to jose@plataformatec.com.br
|
128
|
+
If you just want to give some positive feedback or drop a line, that's fine too!
|
129
|
+
|
130
|
+
Copyright (c) 2009 José Valim (jose@plataformatec.com.br)
|
131
|
+
http://blog.plataformatec.com.br/
|
132
|
+
|
133
|
+
|
134
|
+
Version 2.0
|
135
|
+
-----------
|
136
|
+
|
137
|
+
This plugin was created and maintained until version 2.0 by Duane Johnson:
|
138
|
+
|
139
|
+
Copyright (c) 2006 InquiryLabs, Inc.
|
140
|
+
http://blog.inquirylabs.com/
|
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rake/rdoctask'
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'jeweler'
|
7
7
|
Jeweler::Tasks.new do |s|
|
8
8
|
s.name = "rails-footnotes"
|
9
|
-
s.version = "3.6.
|
9
|
+
s.version = "3.6.4"
|
10
10
|
s.rubyforge_project = "rails-footnotes"
|
11
11
|
s.summary = "Every Rails page has footnotes that gives information about your application and links back to your editor."
|
12
12
|
s.email = "jose@plataformatec.com.br"
|
@@ -20,19 +20,19 @@ begin
|
|
20
20
|
rescue LoadError
|
21
21
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
22
22
|
end
|
23
|
-
|
24
|
-
desc 'Run tests for Footnotes.'
|
25
|
-
Rake::TestTask.new(:test) do |t|
|
26
|
-
t.pattern = 'test/**/*_test.rb'
|
27
|
-
t.verbose = true
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'Generate documentation for Footnotes.'
|
31
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
32
|
-
rdoc.rdoc_dir = 'rdoc'
|
33
|
-
rdoc.title = 'Footnotes'
|
34
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
35
|
-
rdoc.rdoc_files.include('README')
|
36
|
-
rdoc.rdoc_files.include('MIT-LICENSE')
|
37
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
-
end
|
23
|
+
|
24
|
+
desc 'Run tests for Footnotes.'
|
25
|
+
Rake::TestTask.new(:test) do |t|
|
26
|
+
t.pattern = 'test/**/*_test.rb'
|
27
|
+
t.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Generate documentation for Footnotes.'
|
31
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
32
|
+
rdoc.rdoc_dir = 'rdoc'
|
33
|
+
rdoc.title = 'Footnotes'
|
34
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
35
|
+
rdoc.rdoc_files.include('README')
|
36
|
+
rdoc.rdoc_files.include('MIT-LICENSE')
|
37
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
+
end
|
data/lib/rails-footnotes.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
if RAILS_ENV == 'development'
|
2
|
-
dir = File.dirname(__FILE__)
|
3
|
-
require File.join(dir, 'rails-footnotes', 'footnotes')
|
4
|
-
require File.join(dir, 'rails-footnotes', 'backtracer')
|
5
|
-
|
6
|
-
# Load all notes
|
7
|
-
#
|
8
|
-
Dir[File.join(dir, 'rails-footnotes', 'notes', '*.rb')].each do |note|
|
9
|
-
require note unless note =~ /queries/ && !defined?(ActiveRecord)
|
10
|
-
end
|
11
|
-
|
12
|
-
# The footnotes are applied by default to all actions. You can change this
|
13
|
-
# behavior commenting the after_filter line below and putting it in Your
|
14
|
-
# application. Then you can cherrypick in which actions it will appear.
|
15
|
-
#
|
16
|
-
class ActionController::Base
|
17
|
-
prepend_before_filter Footnotes::Filter
|
18
|
-
after_filter Footnotes::Filter
|
19
|
-
end
|
1
|
+
if RAILS_ENV == 'development'
|
2
|
+
dir = File.dirname(__FILE__)
|
3
|
+
require File.join(dir, 'rails-footnotes', 'footnotes')
|
4
|
+
require File.join(dir, 'rails-footnotes', 'backtracer')
|
5
|
+
|
6
|
+
# Load all notes
|
7
|
+
#
|
8
|
+
Dir[File.join(dir, 'rails-footnotes', 'notes', '*.rb')].each do |note|
|
9
|
+
require note unless note =~ /queries/ && !defined?(ActiveRecord)
|
10
|
+
end
|
11
|
+
|
12
|
+
# The footnotes are applied by default to all actions. You can change this
|
13
|
+
# behavior commenting the after_filter line below and putting it in Your
|
14
|
+
# application. Then you can cherrypick in which actions it will appear.
|
15
|
+
#
|
16
|
+
class ActionController::Base
|
17
|
+
prepend_before_filter Footnotes::Filter
|
18
|
+
after_filter Footnotes::Filter
|
19
|
+
end
|
20
20
|
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
module Footnotes
|
2
|
-
module Extensions
|
3
|
-
module Exception
|
4
|
-
def self.included(base)
|
5
|
-
base.class_eval do
|
6
|
-
alias_method_chain :clean_backtrace, :links
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_links_to_backtrace(lines)
|
11
|
-
lines.collect do |line|
|
12
|
-
expanded = line.gsub('#{RAILS_ROOT}', RAILS_ROOT)
|
13
|
-
if match = expanded.match(/^(.+):(\d+):in/) || match = expanded.match(/^(.+):(\d+)\s*$/)
|
14
|
-
file = File.expand_path(match[1])
|
15
|
-
line_number = match[2]
|
16
|
-
html = %[<a href="#{Footnotes::Filter.prefix(file, line_number, 1)}">#{line}</a>]
|
17
|
-
else
|
18
|
-
line
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def clean_backtrace_with_links
|
24
|
-
unless ::Footnotes::Filter.prefix.blank?
|
25
|
-
add_links_to_backtrace(clean_backtrace_without_links)
|
26
|
-
else
|
27
|
-
clean_backtrace_without_links
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
1
|
+
module Footnotes
|
2
|
+
module Extensions
|
3
|
+
module Exception
|
4
|
+
def self.included(base)
|
5
|
+
base.class_eval do
|
6
|
+
alias_method_chain :clean_backtrace, :links
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_links_to_backtrace(lines)
|
11
|
+
lines.collect do |line|
|
12
|
+
expanded = line.gsub('#{RAILS_ROOT}', RAILS_ROOT)
|
13
|
+
if match = expanded.match(/^(.+):(\d+):in/) || match = expanded.match(/^(.+):(\d+)\s*$/)
|
14
|
+
file = File.expand_path(match[1])
|
15
|
+
line_number = match[2]
|
16
|
+
html = %[<a href="#{Footnotes::Filter.prefix(file, line_number, 1)}">#{line}</a>]
|
17
|
+
else
|
18
|
+
line
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def clean_backtrace_with_links
|
24
|
+
unless ::Footnotes::Filter.prefix.blank?
|
25
|
+
add_links_to_backtrace(clean_backtrace_without_links)
|
26
|
+
else
|
27
|
+
clean_backtrace_without_links
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
34
|
Exception.send :include, Footnotes::Extensions::Exception
|