rails-footnotes 3.6.3 → 3.6.4

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.
@@ -199,6 +199,8 @@ module Footnotes
199
199
  function hideAllAndToggle(id) {
200
200
  hideAll();
201
201
  toggle(id)
202
+
203
+ location.href = '#footnotes_debug';
202
204
  }
203
205
 
204
206
  function toggle(id){
@@ -208,8 +210,6 @@ module Footnotes
208
210
  } else {
209
211
  Footnotes.hide(el);
210
212
  }
211
-
212
- location.href = '#footnotes_debug';
213
213
  }
214
214
 
215
215
  function show(element) {
@@ -1,17 +1,17 @@
1
- require "#{File.dirname(__FILE__)}/abstract_note"
2
-
3
- module Footnotes
4
- module Notes
1
+ require "#{File.dirname(__FILE__)}/abstract_note"
2
+
3
+ module Footnotes
4
+ module Notes
5
5
  class AssignsNote < AbstractNote
6
6
  @@ignored_assigns = %w( @template @_request @db_rt_before_render @db_rt_after_render @view_runtime )
7
7
  cattr_accessor :ignored_assigns, :instance_writter => false
8
-
8
+
9
9
  def initialize(controller)
10
- @controller = controller
11
- end
12
-
13
- def title
14
- "Assigns (#{assigns.size})"
10
+ @controller = controller
11
+ end
12
+
13
+ def title
14
+ "Assigns (#{assigns.size})"
15
15
  end
16
16
 
17
17
  def valid?
@@ -23,7 +23,7 @@ module Footnotes
23
23
  assigns.each do |key|
24
24
  rows << [ key, assigned_value(key) ]
25
25
  end
26
- mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values')
26
+ mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values')
27
27
  end
28
28
 
29
29
  protected
@@ -38,7 +38,7 @@ module Footnotes
38
38
 
39
39
  def assigned_value(key)
40
40
  escape(@controller.instance_variable_get(key).inspect)
41
- end
42
- end
43
- end
44
- end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,65 +1,65 @@
1
- require "#{File.dirname(__FILE__)}/abstract_note"
2
-
3
- module Footnotes
4
- module Notes
5
- class ControllerNote < AbstractNote
6
- def initialize(controller)
7
- @controller = controller
8
- end
9
-
10
- def row
11
- :edit
12
- end
13
-
14
- def link
15
- escape(Footnotes::Filter.prefix(controller_filename, controller_line_number + 1, 3))
16
- end
17
-
18
- def valid?
19
- prefix?
20
- end
21
-
22
- protected
23
- # Some controller classes come with the Controller:: module and some don't
24
- # (anyone know why? -- Duane)
25
- def controller_filename
26
- controller_name=@controller.class.to_s.underscore
27
- controller_name='application' if controller_name=='application_controller'
28
- if ActionController::Routing.respond_to? :controller_paths
29
- ActionController::Routing.controller_paths.each do |controller_path|
30
- full_controller_path = File.join(File.expand_path(controller_path), "#{controller_name}.rb")
31
- return full_controller_path if File.exists?(full_controller_path)
32
- end
33
- raise "File not found"
34
- else
35
- File.join(File.expand_path(RAILS_ROOT), 'app', 'controllers', "#{controller_name}.rb").sub('/controllers/controllers/', '/controllers/')
36
- end
37
- end
38
-
39
- def controller_text
40
- @controller_text ||= IO.read(controller_filename)
41
- end
42
-
43
- def action_index
44
- (controller_text =~ /def\s+#{@controller.action_name}[\s\(]/)
45
- end
46
-
47
- def controller_line_number
48
- lines_from_index(controller_text, action_index) || 0
49
- end
50
-
51
- def lines_from_index(string, index)
52
- return nil if string.blank? || index.blank?
53
-
54
- lines = string.to_a
55
- running_length = 0
56
- lines.each_with_index do |line, i|
57
- running_length += line.length
58
- if running_length > index
59
- return i
60
- end
61
- end
62
- end
63
- end
64
- end
1
+ require "#{File.dirname(__FILE__)}/abstract_note"
2
+
3
+ module Footnotes
4
+ module Notes
5
+ class ControllerNote < AbstractNote
6
+ def initialize(controller)
7
+ @controller = controller
8
+ end
9
+
10
+ def row
11
+ :edit
12
+ end
13
+
14
+ def link
15
+ escape(Footnotes::Filter.prefix(controller_filename, controller_line_number + 1, 3))
16
+ end
17
+
18
+ def valid?
19
+ prefix?
20
+ end
21
+
22
+ protected
23
+ # Some controller classes come with the Controller:: module and some don't
24
+ # (anyone know why? -- Duane)
25
+ def controller_filename
26
+ controller_name=@controller.class.to_s.underscore
27
+ controller_name='application' if controller_name=='application_controller'
28
+ if ActionController::Routing.respond_to? :controller_paths
29
+ ActionController::Routing.controller_paths.each do |controller_path|
30
+ full_controller_path = File.join(File.expand_path(controller_path), "#{controller_name}.rb")
31
+ return full_controller_path if File.exists?(full_controller_path)
32
+ end
33
+ raise "File not found"
34
+ else
35
+ File.join(File.expand_path(RAILS_ROOT), 'app', 'controllers', "#{controller_name}.rb").sub('/controllers/controllers/', '/controllers/')
36
+ end
37
+ end
38
+
39
+ def controller_text
40
+ @controller_text ||= IO.read(controller_filename)
41
+ end
42
+
43
+ def action_index
44
+ (controller_text =~ /def\s+#{@controller.action_name}[\s\(]/)
45
+ end
46
+
47
+ def controller_line_number
48
+ lines_from_index(controller_text, action_index) || 0
49
+ end
50
+
51
+ def lines_from_index(string, index)
52
+ return nil if string.blank? || index.blank?
53
+
54
+ lines = string.to_a
55
+ running_length = 0
56
+ lines.each_with_index do |line, i|
57
+ running_length += line.length
58
+ if running_length > index
59
+ return i
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
65
  end
@@ -1,19 +1,19 @@
1
- require "#{File.dirname(__FILE__)}/abstract_note"
2
-
3
- module Footnotes
4
- module Notes
5
- class CookiesNote < AbstractNote
6
- def initialize(controller)
7
- @cookies = (controller.__send__(:cookies) || {}).symbolize_keys
8
- end
9
-
10
- def title
11
- "Cookies (#{@cookies.length})"
12
- end
13
-
1
+ require "#{File.dirname(__FILE__)}/abstract_note"
2
+
3
+ module Footnotes
4
+ module Notes
5
+ class CookiesNote < AbstractNote
6
+ def initialize(controller)
7
+ @cookies = (controller.__send__(:cookies) || {}).symbolize_keys
8
+ end
9
+
10
+ def title
11
+ "Cookies (#{@cookies.length})"
12
+ end
13
+
14
14
  def content
15
- mount_table_for_hash(@cookies)
16
- end
17
- end
18
- end
15
+ mount_table_for_hash(@cookies)
16
+ end
17
+ end
18
+ end
19
19
  end
@@ -1,19 +1,19 @@
1
- require "#{File.dirname(__FILE__)}/abstract_note"
2
-
3
- module Footnotes
4
- module Notes
5
- class EnvNote < AbstractNote
6
- def initialize(controller)
7
- @env = controller.request.env.dup
8
- end
9
-
10
- def content
11
- # Replace HTTP_COOKIE for a link
12
- @env['HTTP_COOKIE'] = '<a href="#" style="color:#009" onclick="Footnotes.hideAllAndToggle(\'cookies_debug_info\');return false;">See cookies on its tab</a>'
13
-
14
- # Create the env table
15
- mount_table(@env.to_a.sort.unshift([:key, :value]))
16
- end
17
- end
18
- end
19
- end
1
+ require "#{File.dirname(__FILE__)}/abstract_note"
2
+
3
+ module Footnotes
4
+ module Notes
5
+ class EnvNote < AbstractNote
6
+ def initialize(controller)
7
+ @env = controller.request.env.dup
8
+ end
9
+
10
+ def content
11
+ # Replace HTTP_COOKIE for a link
12
+ @env['HTTP_COOKIE'] = '<a href="#" style="color:#009" onclick="Footnotes.hideAllAndToggle(\'cookies_debug_info\');return false;">See cookies on its tab</a>'
13
+
14
+ # Create the env table
15
+ mount_table(@env.to_a.sort.unshift([:key, :value]))
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,44 +1,44 @@
1
- require "#{File.dirname(__FILE__)}/abstract_note"
2
-
3
- module Footnotes
4
- module Notes
5
- class FilesNote < AbstractNote
6
- def initialize(controller)
7
- @files = scan_text(controller.response.body)
8
- parse_files!
9
- end
10
-
11
- def row
12
- :edit
13
- end
14
-
15
- def content
16
- if @files.empty?
17
- ""
18
- else
19
- "<ul><li>#{@files.join("</li><li>")}</li></ul>"
20
- end
21
- end
22
-
23
- def valid?
24
- prefix?
25
- end
26
-
27
- protected
28
- def scan_text(text)
29
- []
30
- end
31
-
32
- def parse_files!
33
- @files.collect! do |filename|
34
- if filename =~ %r{^/}
35
- full_filename = File.join(File.expand_path(RAILS_ROOT), 'public', filename)
36
- %[<a href="#{Footnotes::Filter.prefix(full_filename, 1, 1)}">#{filename}</a>]
37
- else
38
- %[<a href="#{filename}">#{filename}</a>]
39
- end
40
- end
41
- end
42
- end
43
- end
1
+ require "#{File.dirname(__FILE__)}/abstract_note"
2
+
3
+ module Footnotes
4
+ module Notes
5
+ class FilesNote < AbstractNote
6
+ def initialize(controller)
7
+ @files = scan_text(controller.response.body)
8
+ parse_files!
9
+ end
10
+
11
+ def row
12
+ :edit
13
+ end
14
+
15
+ def content
16
+ if @files.empty?
17
+ ""
18
+ else
19
+ "<ul><li>#{@files.join("</li><li>")}</li></ul>"
20
+ end
21
+ end
22
+
23
+ def valid?
24
+ prefix?
25
+ end
26
+
27
+ protected
28
+ def scan_text(text)
29
+ []
30
+ end
31
+
32
+ def parse_files!
33
+ @files.collect! do |filename|
34
+ if filename =~ %r{^/}
35
+ full_filename = File.join(File.expand_path(RAILS_ROOT), 'public', filename)
36
+ %[<a href="#{Footnotes::Filter.prefix(full_filename, 1, 1)}">#{filename}</a>]
37
+ else
38
+ %[<a href="#{filename}">#{filename}</a>]
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
44
  end
@@ -1,53 +1,53 @@
1
- require "#{File.dirname(__FILE__)}/abstract_note"
2
-
3
- module Footnotes
4
- module Notes
5
- class FiltersNote < AbstractNote
6
- def initialize(controller)
7
- @controller = controller
8
- @parsed_filters = parse_filters
9
- end
10
-
11
- def legend
12
- "Filter chain for #{@controller.class.to_s}"
13
- end
14
-
15
- def content
16
- mount_table(@parsed_filters.unshift([:name, :type, :actions]))
17
- end
18
-
19
- protected
20
- # Get controller filter chain
21
- #
22
- def parse_filters
23
- return @controller.class.filter_chain.collect do |filter|
24
- [parse_method(filter.method), filter.type.inspect, controller_filtered_actions(filter).inspect]
25
- end
26
- end
27
-
28
- # This receives a filter, creates a mock controller and check in which
29
- # actions the filter is performed
30
- #
31
- def controller_filtered_actions(filter)
32
- mock_controller = Footnotes::Extensions::MockController.new
33
-
34
- return @controller.class.action_methods.select { |action|
35
- mock_controller.action_name = action
36
-
37
- #remove conditions (this would call a Proc on the mock_controller)
38
- filter.options.merge!(:if => nil, :unless => nil)
39
-
40
- filter.__send__(:should_run_callback?, mock_controller)
41
- }.map(&:to_sym)
42
- end
43
-
44
- def parse_method(method = '')
45
- escape(method.inspect.gsub(RAILS_ROOT, ''))
46
- end
47
- end
48
- end
49
-
50
- module Extensions
51
- class MockController < Struct.new(:action_name); end
52
- end
1
+ require "#{File.dirname(__FILE__)}/abstract_note"
2
+
3
+ module Footnotes
4
+ module Notes
5
+ class FiltersNote < AbstractNote
6
+ def initialize(controller)
7
+ @controller = controller
8
+ @parsed_filters = parse_filters
9
+ end
10
+
11
+ def legend
12
+ "Filter chain for #{@controller.class.to_s}"
13
+ end
14
+
15
+ def content
16
+ mount_table(@parsed_filters.unshift([:name, :type, :actions]))
17
+ end
18
+
19
+ protected
20
+ # Get controller filter chain
21
+ #
22
+ def parse_filters
23
+ return @controller.class.filter_chain.collect do |filter|
24
+ [parse_method(filter.method), filter.type.inspect, controller_filtered_actions(filter).inspect]
25
+ end
26
+ end
27
+
28
+ # This receives a filter, creates a mock controller and check in which
29
+ # actions the filter is performed
30
+ #
31
+ def controller_filtered_actions(filter)
32
+ mock_controller = Footnotes::Extensions::MockController.new
33
+
34
+ return @controller.class.action_methods.select { |action|
35
+ mock_controller.action_name = action
36
+
37
+ #remove conditions (this would call a Proc on the mock_controller)
38
+ filter.options.merge!(:if => nil, :unless => nil)
39
+
40
+ filter.__send__(:should_run_callback?, mock_controller)
41
+ }.map(&:to_sym)
42
+ end
43
+
44
+ def parse_method(method = '')
45
+ escape(method.inspect.gsub(RAILS_ROOT, ''))
46
+ end
47
+ end
48
+ end
49
+
50
+ module Extensions
51
+ class MockController < Struct.new(:action_name); end
52
+ end
53
53
  end