rails-footnotes 3.6.6 → 3.6.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,13 @@
1
+ == Footnotes v3.6.7
2
+ * fixed log_note error - long overdue (thanks to many including Moritz Heidkamp)
3
+ * 1.9: ignore more assigns (thanks to justin case)
4
+ * 1.9 fixed test mocking (thanks to lsylvester)
5
+ * sort notes includes (thanks Alexey Smolianiov)
6
+ * handle controller paths in gems / others (thanks ubilabs)
7
+ * more graceful fallback when controller not found
8
+ * fixes for table entries being double encoded
9
+ * moved rpm exclude sql explain logic to config option
10
+
1
11
  == Footnotes v3.6.6
2
12
  * fix for ruby 1.9 compat (thanks to ivanoats)
3
13
  * fix for log note (thanks to tobias)
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  Rails Footnotes
2
2
  License: MIT
3
- Version: 3.6.4
3
+ Version: 3.6.7
4
4
 
5
5
  You can also read this README in pretty html at the GitHub project Wiki page
6
6
 
@@ -58,14 +58,20 @@ Another option is to allow multiple notes to be opened at the same time:
58
58
 
59
59
  Footnotes::Filter.multiple_notes = true
60
60
 
61
+ If you have New Relic RPM installed, you may want to turn off query explains
62
+ (explains can slows things down)
63
+
64
+ Footnotes::Notes::QueriesNote.sql_explain = false
65
+
66
+ If you want to add alternate logic to enable or disable footnotes,
67
+ add something like this to environment.rb:
68
+
69
+ ENABLE_RAILS_FOOTNOTES=(Rails.env.production? == false)
70
+
61
71
  Finally, you can control which notes you want to show. The default are:
62
72
 
63
73
  Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :env, :queries, :log, :general]
64
74
 
65
- The queries note by default will not load if it detects New Relic loaded in the app. If you want to load it
66
- in this case, add the following to an initializer:
67
-
68
- Footnotes::Notes::QueriesNote.include_when_new_relic_installed = true if defined?(Footnotes)
69
75
 
70
76
  Creating your own notes
71
77
  -----------------------
@@ -128,13 +134,18 @@ Colaborators
128
134
  Bugs and Feedback
129
135
  -----------------
130
136
 
131
- If you discover any bugs, please send an e-mail to jose@plataformatec.com.br
137
+ If you discover any bugs, please send an e-mail to keenan@thebrocks.net
132
138
  If you just want to give some positive feedback or drop a line, that's fine too!
133
139
 
140
+
141
+ Version 3.x
142
+ -----------
143
+
144
+ This plugin was maintained until version 3.6 by José Valim
145
+
134
146
  Copyright (c) 2009 José Valim (jose@plataformatec.com.br)
135
147
  http://blog.plataformatec.com.br/
136
148
 
137
-
138
149
  Version 2.0
139
150
  -----------
140
151
 
data/Rakefile CHANGED
@@ -6,19 +6,19 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |s|
8
8
  s.name = "rails-footnotes"
9
- s.version = "3.6.6"
9
+ s.version = "3.6.7"
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
- s.email = "jose@plataformatec.com.br"
12
+ s.email = "keenan@thebrocks.net"
13
13
  s.homepage = "http://github.com/josevalim/rails-footnotes"
14
14
  s.description = "Every Rails page has footnotes that gives information about your application and links back to your editor."
15
- s.authors = ['José Valim']
15
+ s.authors = ['Keenan Brock']
16
16
  s.files = FileList["[A-Z]*", "{lib}/**/*"]
17
17
  end
18
18
 
19
19
  Jeweler::GemcutterTasks.new
20
20
  rescue LoadError
21
- puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
21
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
22
22
  end
23
23
 
24
24
  desc 'Run tests for Footnotes.'
@@ -1,11 +1,14 @@
1
- if RAILS_ENV == 'development'
1
+ unless defined?(ENABLE_RAILS_FOOTNOTES)
2
+ ENABLE_RAILS_FOOTNOTES=(RAILS_ENV == 'development')
3
+ end
4
+ if ENABLE_RAILS_FOOTNOTES
2
5
  dir = File.dirname(__FILE__)
3
6
  require File.join(dir, 'rails-footnotes', 'footnotes')
4
7
  require File.join(dir, 'rails-footnotes', 'backtracer')
5
8
 
6
9
  # Load all notes
7
10
  #
8
- Dir[File.join(dir, 'rails-footnotes', 'notes', '*.rb')].each do |note|
11
+ Dir[File.join(dir, 'rails-footnotes', 'notes', '*.rb')].sort.each do |note|
9
12
  require note
10
13
  end
11
14
 
@@ -17,4 +20,4 @@ if RAILS_ENV == 'development'
17
20
  prepend_before_filter Footnotes::Filter
18
21
  after_filter Footnotes::Filter
19
22
  end
20
- end
23
+ end
@@ -145,7 +145,7 @@ module Footnotes
145
145
  return '' if array.empty?
146
146
 
147
147
  header = header.collect{|i| escape(i.to_s.humanize) }
148
- array = array.collect { |a| a.collect { |b| c = b.to_s; escape(c) unless c == ""}}
148
+ # array = array.collect { |a| a.collect { |b| c = b.to_s; escape(c) unless c == ""}}
149
149
  rows = array.collect{|i| "<tr><td>#{i.join('</td><td>')}</td></tr>" }
150
150
 
151
151
  <<-TABLE
@@ -3,7 +3,20 @@ require "#{File.dirname(__FILE__)}/abstract_note"
3
3
  module Footnotes
4
4
  module Notes
5
5
  class AssignsNote < AbstractNote
6
- @@ignored_assigns = %w( @template @_request @db_rt_before_render @db_rt_after_render @view_runtime )
6
+ @@ignored_assigns = [
7
+ :@real_format,
8
+ :@before_filter_chain_aborted,
9
+ :@performed_redirect,
10
+ :@performed_render,
11
+ :@_params,
12
+ :@_response,
13
+ :@url,
14
+ :@template,
15
+ :@_request,
16
+ :@db_rt_before_render,
17
+ :@db_rt_after_render,
18
+ :@view_runtime
19
+ ]
7
20
  cattr_accessor :ignored_assigns, :instance_writter => false
8
21
 
9
22
  def initialize(controller)
@@ -21,7 +34,7 @@ module Footnotes
21
34
  def content
22
35
  rows = []
23
36
  assigns.each do |key|
24
- rows << [ key, assigned_value(key) ]
37
+ rows << [ key, escape(assigned_value(key)) ]
25
38
  end
26
39
  mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values', :summary => "Debug information for #{title}")
27
40
  end
@@ -29,11 +42,14 @@ module Footnotes
29
42
  protected
30
43
 
31
44
  def assigns
32
- return @assigns if @assigns
33
-
34
- @assigns = @controller.instance_variables
35
- @assigns -= @controller.protected_instance_variables if @controller.respond_to? :protected_instance_variables
36
- @assigns -= ignored_assigns
45
+ assign = []
46
+ ignored = @@ignored_assigns
47
+
48
+ @controller.instance_variables.each {|x| assign << x.intern }
49
+ @controller.protected_instance_variables.each {|x| ignored << x.intern } if @controller.respond_to? :protected_instance_variables
50
+
51
+ assign -= ignored
52
+ return assign
37
53
  end
38
54
 
39
55
  def assigned_value(key)
@@ -12,7 +12,9 @@ module Footnotes
12
12
  end
13
13
 
14
14
  def link
15
- escape(Footnotes::Filter.prefix(controller_filename, controller_line_number + 1, 3))
15
+ if controller_filename && controller_line_number
16
+ escape(Footnotes::Filter.prefix(controller_filename, controller_line_number + 1, 3))
17
+ end
16
18
  end
17
19
 
18
20
  def valid?
@@ -23,29 +25,34 @@ module Footnotes
23
25
  # Some controller classes come with the Controller:: module and some don't
24
26
  # (anyone know why? -- Duane)
25
27
  def controller_filename
28
+ return @controller_filename if defined?(@controller_filename)
26
29
  controller_name=@controller.class.to_s.underscore
27
30
  controller_name='application' if controller_name=='application_controller'
28
31
  if ActionController::Routing.respond_to? :controller_paths
32
+ @controller_filename=nil
29
33
  ActionController::Routing.controller_paths.each do |controller_path|
30
34
  full_controller_path = File.join(File.expand_path(controller_path), "#{controller_name}.rb")
31
- return full_controller_path if File.exists?(full_controller_path)
35
+ @controller_filename=full_controller_path if File.exists?(full_controller_path)
32
36
  end
33
- raise "File not found"
37
+ #raise "File not found"
34
38
  else
35
- File.join(File.expand_path(RAILS_ROOT), 'app', 'controllers', "#{controller_name}.rb").sub('/controllers/controllers/', '/controllers/')
39
+ @controller_filename=File.join(File.expand_path(RAILS_ROOT), 'app', 'controllers', "#{controller_name}.rb").sub('/controllers/controllers/', '/controllers/')
36
40
  end
41
+ @controller_filename
37
42
  end
38
43
 
39
44
  def controller_text
40
- @controller_text ||= IO.read(controller_filename)
45
+ if controller_filename
46
+ @controller_text ||= IO.read(controller_filename)
47
+ end
41
48
  end
42
49
 
43
50
  def action_index
44
- (controller_text =~ /def\s+#{@controller.action_name}[\s\(]/)
51
+ (controller_text =~ /def\s+#{@controller.action_name}[\s\(]/) if controller_text
45
52
  end
46
53
 
47
54
  def controller_line_number
48
- lines_from_index(controller_text, action_index) || 0
55
+ lines_from_index(controller_text, action_index) || 0 if controller_text
49
56
  end
50
57
 
51
58
  def lines_from_index(string, index)
@@ -1,3 +1,5 @@
1
+ require "#{File.dirname(__FILE__)}/log_note"
2
+
1
3
  module Footnotes
2
4
  module Notes
3
5
  class PartialsNote < LogNote
@@ -12,11 +14,12 @@ module Footnotes
12
14
  "Partials (#{partials.size})"
13
15
  end
14
16
  def content
15
- links = partials.map do |file|
16
- href = Footnotes::Filter.prefix(file,1,1)
17
- "<tr><td><a href=\"#{href}\">#{file.gsub(File.join(Rails.root,"app/views/"),"")}</td><td>#{@partial_times[file].sum}ms</a></td><td>#{@partial_counts[file]}</td></tr>"
17
+ rows = partials.map do |filename|
18
+ href = Footnotes::Filter.prefix(filename,1,1)
19
+ shortened_name=filename.gsub(File.join(RAILS_ROOT,"app/views/"),"")
20
+ [%{<a href="#{href}">#{shortened_name}</a>},"#{@partial_times[filename].sum}ms",@partial_counts[filename]]
18
21
  end
19
- "<table><thead><tr><th>Partial</th><th>Time</th><th>Count</th></tr></thead><tbody>#{links.join}</tbody></table>"
22
+ mount_table(rows.unshift(%w(Partial Time Count)), :summary => "Partials for #{title}")
20
23
  end
21
24
 
22
25
  protected
@@ -31,14 +34,17 @@ module Footnotes
31
34
  log_lines.split("\n").each do |line|
32
35
  if line =~ /Rendered (\S*) \(([\d\.]+)\S*?\)/
33
36
  partial = $1
34
- files = Dir.glob("#{Rails.root}/app/views/#{partial}*")
35
- for file in files
36
- #TODO figure out what format got rendered if theres multiple
37
- @partial_times[file] ||= []
38
- @partial_times[file] << $2.to_f
39
- @partial_counts[file] ||= 0
40
- @partial_counts[file] += 1
41
- partials << file unless partials.include?(file)
37
+ @controller.view_paths.each do |view_path|
38
+ path = File.join(view_path, "#{partial}*")
39
+ files = Dir.glob(path)
40
+ for file in files
41
+ #TODO figure out what format got rendered if theres multiple
42
+ @partial_times[file] ||= []
43
+ @partial_times[file] << $2.to_f
44
+ @partial_counts[file] ||= 0
45
+ @partial_counts[file] += 1
46
+ partials << file unless partials.include?(file)
47
+ end
42
48
  end
43
49
  end
44
50
  end
@@ -9,7 +9,7 @@ module Footnotes
9
9
  @@include_when_new_relic_installed = false
10
10
  @@loaded = false
11
11
 
12
- cattr_accessor :sql, :alert_db_time, :alert_sql_number, :alert_explain, :loaded, :instance_writter => false
12
+ cattr_accessor :sql, :alert_db_time, :alert_sql_number, :alert_explain, :loaded, :sql_explain, :instance_writter => false
13
13
  cattr_reader :include_when_new_relic_installed
14
14
 
15
15
  def self.include_when_new_relic_installed=(include_me)
@@ -67,11 +67,7 @@ module Footnotes
67
67
 
68
68
  def self.load
69
69
  #only include when NewRelic is installed if configured to do so
70
- if !loaded and
71
- included? and
72
- defined?(ActiveRecord) and
73
- (!defined?(NewRelic) or
74
- include_when_new_relic_installed)
70
+ if !loaded and included? and defined?(ActiveRecord)
75
71
  ActiveRecord::ConnectionAdapters::AbstractAdapter.send :include, Footnotes::Extensions::AbstractAdapter
76
72
  ActiveRecord::ConnectionAdapters.local_constants.each do |adapter|
77
73
  next unless adapter =~ /.*[^Abstract]Adapter$/
@@ -159,7 +155,7 @@ module Footnotes
159
155
  type = $&.downcase.to_sym
160
156
  explain = nil
161
157
 
162
- if adapter_name == 'MySQL' && type == :select
158
+ if adapter_name == 'MySQL' && type == :select && Footnotes::Notes::QueriesNote.sql_explain
163
159
  log_silence do
164
160
  explain = execute_without_analyzer("EXPLAIN #{query}", name)
165
161
  end
@@ -16,6 +16,7 @@ end
16
16
  class FootnotesTest < Test::Unit::TestCase
17
17
  def setup
18
18
  @controller = FootnotesController.new
19
+ @controller.template = Object.new
19
20
  @controller.request = ActionController::TestRequest.new
20
21
  @controller.response = ActionController::TestResponse.new
21
22
  @controller.response.body = $html.dup
metadata CHANGED
@@ -1,20 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.6
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 3
8
+ - 6
9
+ - 7
10
+ version: 3.6.7
5
11
  platform: ruby
6
12
  authors:
7
- - "Jos\xC3\xA9 Valim"
13
+ - Keenan Brock
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-31 00:00:00 -05:00
18
+ date: 2010-07-20 00:00:00 -04:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
16
22
  description: Every Rails page has footnotes that gives information about your application and links back to your editor.
17
- email: jose@plataformatec.com.br
23
+ email: keenan@thebrocks.net
18
24
  executables: []
19
25
 
20
26
  extensions: []
@@ -48,6 +54,9 @@ files:
48
54
  - lib/rails-footnotes/notes/session_note.rb
49
55
  - lib/rails-footnotes/notes/stylesheets_note.rb
50
56
  - lib/rails-footnotes/notes/view_note.rb
57
+ - test/footnotes_test.rb
58
+ - test/notes/abstract_note_test.rb
59
+ - test/test_helper.rb
51
60
  has_rdoc: true
52
61
  homepage: http://github.com/josevalim/rails-footnotes
53
62
  licenses: []
@@ -58,21 +67,27 @@ rdoc_options:
58
67
  require_paths:
59
68
  - lib
60
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
61
71
  requirements:
62
72
  - - ">="
63
73
  - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
64
77
  version: "0"
65
- version:
66
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
67
80
  requirements:
68
81
  - - ">="
69
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
70
86
  version: "0"
71
- version:
72
87
  requirements: []
73
88
 
74
89
  rubyforge_project: rails-footnotes
75
- rubygems_version: 1.3.5
90
+ rubygems_version: 1.3.7
76
91
  signing_key:
77
92
  specification_version: 3
78
93
  summary: Every Rails page has footnotes that gives information about your application and links back to your editor.