rails3-footnotes 4.0.0.pre.4 → 4.0.0.pre.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == Footnotes v4.0.0.pre.5 (April 4, 2011)
2
+ * fix Pathname error in Ruby 1.9
3
+ * add view note that links to edit the view
4
+ * fix assigns note to work again
5
+ * add FIXMEs for remaining broken notes
6
+
1
7
  == Footnotes v4.0.0.pre.4 (April 2, 2011)
2
8
  * fix event[:duration] to event.duration in query note
3
9
  * fix layout note to work again
data/README.md CHANGED
@@ -4,22 +4,21 @@
4
4
 
5
5
  ## Rails 3
6
6
 
7
- Rails 3 compatibility was started by mperham, but was dropped when he discovered rack-bug. I happen to have a
8
- soft spot for rails-footnotes, so I'm keeping this around for myself.
7
+ Rails 3 compatibility was started by mperham, but dropped when he discovered rack-bug. I haven't been able to get rack-bug to do what I want with Rails 3, and I happen to have a soft spot for rails-footnotes, so I'm keeping this around for myself.
9
8
 
10
9
  ## Description
11
10
 
12
- If you are developing in Rails you should know the plugin! It displays footnotes in your application for easy
13
- debugging, such as sessions, request parameters, cookies, filter chain, routes, queries, etc.
14
-
15
- Even more, it contains links to open files directly in your editor including your backtrace lines.
16
-
11
+ This gem plugin for Rails 3 displays footnotes for easy debugging, such as sessions, request parameters, cookies, filter chain, routes, queries, etc. It also contains links to open files directly in your editor.
17
12
 
18
13
  ## Installation
19
14
 
20
15
  In your Gemfile:
21
16
 
22
- gem 'rails-footnotes', :git => 'git://github.com/indirect/rails-footnotes.git'
17
+ gem 'rails3-footnotes', '~>4.0.0.pre'
18
+
19
+ or if you prefer the absolute cutting edge:
20
+
21
+ gem 'rails3-footnotes', :git => 'git://github.com/indirect/rails-footnotes.git'
23
22
 
24
23
  ## Configuration
25
24
 
@@ -25,7 +25,7 @@ module Footnotes
25
25
  @@prefix = 'txmt://open?url=file://%s&line=%d&column=%d'.html_safe
26
26
 
27
27
  # Edit notes
28
- @@notes = [ :controller, :layout, :partials, :stylesheets, :javascripts ]
28
+ @@notes = [ :view, :controller, :layout, :partials, :stylesheets, :javascripts ]
29
29
  # Show notes
30
30
  @@notes += [ :render, :assigns, :session, :cookies, :params, :filters, :routes, :env, :queries, :log ]
31
31
 
@@ -3,68 +3,39 @@ require "#{File.dirname(__FILE__)}/abstract_note"
3
3
  module Footnotes
4
4
  module Notes
5
5
  class AssignsNote < AbstractNote
6
- @@ignored_assigns = [
7
- :@action_has_layout,
8
- :@before_filter_chain_aborted,
9
- :@db_rt_after_render,
10
- :@db_rt_before_render,
11
- :@devise_mapping,
12
- :@lookup_context,
13
- :@performed_redirect,
14
- :@performed_render,
15
- :@real_format,
16
- :@template,
17
- :@url,
18
- :@view_context_class,
19
- :@_action_name,
20
- :@_config,
21
- :@_db_runtime,
22
- :@_env,
23
- :@_params,
24
- :@_request,
25
- :@_response,
26
- :@_response_body,
27
- :@_status,
28
- :@_view_runtime,
29
- ]
30
- cattr_accessor :ignored_assigns, :instance_writter => false
31
6
 
32
7
  def initialize(controller)
33
- @controller = controller
8
+ @assigns = controller.send(:view_assigns)
34
9
  end
35
10
 
36
11
  def title
37
- "Assigns (#{assigns.size})"
12
+ "Assigns (#{assign_keys.size})"
38
13
  end
39
14
 
40
15
  def valid?
41
- assigns
16
+ assign_keys.any?
42
17
  end
43
18
 
44
19
  def content
45
20
  rows = []
46
- assigns.each do |key|
47
- rows << [ key, escape(assigned_value(key)) ]
21
+ assign_keys.each do |key|
22
+ rows << [ key, escape(@assigns[key].inspect) ]
48
23
  end
49
24
  mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values', :summary => "Debug information for #{title}")
50
25
  end
51
26
 
52
- protected
27
+ protected
53
28
 
54
- def assigns
55
- assign = []
56
- ignored = @@ignored_assigns
57
-
58
- @controller.instance_variables.each {|x| assign << x.intern }
59
- @controller.protected_instance_variables.each {|x| ignored << x.intern } if @controller.respond_to? :protected_instance_variables
29
+ def assign_keys
30
+ @assign_keys ||= (@assigns.keys.reject{|k| k[0] == ?_ } - ignored_assigns)
31
+ end
60
32
 
61
- assign -= ignored
62
- return assign
63
- end
33
+ def ignored_assigns
34
+ [ "action_has_layout",
35
+ "lookup_context",
36
+ "view_context_class" ]
37
+ end
64
38
 
65
- def assigned_value(key)
66
- @controller.instance_variable_get(key).inspect
67
- end
68
39
  end
69
40
  end
70
41
  end
@@ -20,7 +20,7 @@ module Footnotes
20
20
  # Get controller filter chain
21
21
  #
22
22
  def parse_filters
23
- return [] # TODO @controller.class.filter_chain.collect do |filter|
23
+ return [] # FIXME @controller.class.filter_chain.collect do |filter|
24
24
  # [parse_method(filter.method), filter.type.inspect, controller_filtered_actions(filter).inspect]
25
25
  # end
26
26
  end
@@ -35,12 +35,12 @@ module Footnotes
35
35
  mock_controller.action_name = action
36
36
 
37
37
  #remove conditions (this would call a Proc on the mock_controller)
38
- filter.options.merge!(:if => nil, :unless => nil)
38
+ filter.options.merge!(:if => nil, :unless => nil)
39
39
 
40
- filter.__send__(:should_run_callback?, mock_controller)
40
+ filter.__send__(:should_run_callback?, mock_controller)
41
41
  }.map(&:to_sym)
42
42
  end
43
-
43
+
44
44
  def parse_method(method = '')
45
45
  escape(method.inspect.gsub(RAILS_ROOT, ''))
46
46
  end
@@ -4,11 +4,11 @@ module Footnotes
4
4
  module Notes
5
5
  class LogNote < AbstractNote
6
6
  @@log = []
7
-
7
+
8
8
  def self.log(message)
9
9
  @@log << message
10
10
  end
11
-
11
+
12
12
  def initialize(controller)
13
13
  @controller = controller
14
14
  end
@@ -20,7 +20,7 @@ module Footnotes
20
20
  def content
21
21
  escape(log.gsub(/\e\[.+?m/, '')).gsub("\n", '<br />')
22
22
  end
23
-
23
+
24
24
  def log
25
25
  unless @log
26
26
  @log = @@log.join('')
@@ -32,6 +32,7 @@ module Footnotes
32
32
  @log
33
33
  end
34
34
 
35
+ # FIXME (andre 2011-04-04) Fix this to collect Rails 3 logs
35
36
  module LoggingExtensions
36
37
  def add(*args, &block)
37
38
  logged_message = super
@@ -39,7 +40,7 @@ module Footnotes
39
40
  logged_message
40
41
  end
41
42
  end
42
-
43
+
43
44
  Rails.logger.extend LoggingExtensions
44
45
  end
45
46
  end
@@ -20,7 +20,7 @@ module Footnotes
20
20
  def content
21
21
  rows = partials.map do |filename|
22
22
  href = Footnotes::Filter.prefix(filename,1,1)
23
- name = filename.gsub(Rails.root.join("app/views/"),"")
23
+ name = filename.gsub(Rails.root.join("app/views/").to_s, '')
24
24
  [%{<a href="#{href}">#{name}</a>},"#{@partial_times[filename].sum}ms", @partial_counts[filename]]
25
25
  end
26
26
  mount_table(rows.unshift(%w(Partial Time Count)), :summary => "Partials for #{title}")
@@ -50,6 +50,7 @@ module Footnotes
50
50
  STYLESHEET
51
51
  end
52
52
 
53
+ # FIXME (andre 2011-04-04) This should look like the old query log, preferably with links to trace the queries.
53
54
  def content
54
55
  html = ''
55
56
 
@@ -12,7 +12,7 @@ module Footnotes
12
12
  end
13
13
 
14
14
  def title
15
- "<span style=\"background-color:#{color(@page.duration)}\">Rendered (#{"%.3f" % @page.duration}ms)</span>"
15
+ "<span style=\"background-color:#{color(@page.duration)}\">Render (#{"%.3f" % @page.duration}ms)</span>"
16
16
  end
17
17
 
18
18
  def content
@@ -0,0 +1,27 @@
1
+ require "#{File.dirname(__FILE__)}/abstract_note"
2
+ require "#{File.dirname(__FILE__)}/../view_subscriber"
3
+
4
+ module Footnotes
5
+ module Notes
6
+ class ViewNote < AbstractNote
7
+
8
+ def row
9
+ :edit
10
+ end
11
+
12
+ def link
13
+ escape(Footnotes::Filter.prefix(filename, 1, 1))
14
+ end
15
+
16
+ def valid?
17
+ prefix? && filename
18
+ end
19
+
20
+ protected
21
+ def filename
22
+ Footnotes.view_subscriber.view
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Footnotes
2
- VERSION = "4.0.0.pre.4"
2
+ VERSION = "4.0.0.pre.5"
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: 1923831841
4
+ hash: 1923831843
5
5
  prerelease: true
6
6
  segments:
7
7
  - 4
8
8
  - 0
9
9
  - 0
10
10
  - pre
11
- - 4
12
- version: 4.0.0.pre.4
11
+ - 5
12
+ version: 4.0.0.pre.5
13
13
  platform: ruby
14
14
  authors:
15
15
  - "Andr\xC3\xA9 Arko"
@@ -83,6 +83,7 @@ files:
83
83
  - lib/rails-footnotes/notes/rpm_note.rb
84
84
  - lib/rails-footnotes/notes/session_note.rb
85
85
  - lib/rails-footnotes/notes/stylesheets_note.rb
86
+ - lib/rails-footnotes/notes/view_note.rb
86
87
  - lib/rails-footnotes/version.rb
87
88
  - lib/rails-footnotes/view_subscriber.rb
88
89
  - lib/rails-footnotes.rb