rails3-footnotes 4.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,81 @@
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
+
11
+ == Footnotes v3.6.6
12
+ * fix for ruby 1.9 compat (thanks to ivanoats)
13
+ * fix for log note (thanks to tobias)
14
+ * pre rails 2.3 support fixes (thanks to tobias)
15
+ * better disabling of query notes (thanks to tobias)
16
+ * fixed variable assignment escaping (thanks to gdelvino)
17
+ * fixed cookie value escaping (thanks to indirect)
18
+ * Turn off footnotes with a parameter footnotes=false (thanks to indirect)
19
+
20
+ == Footnotes v3.6
21
+ * Cookies, sessions and params notes now use table;
22
+ * Old components note removed;
23
+ * Added assigns notes (thanks to scorpio);
24
+ * Improve query note, count query time and display it with several configurable
25
+ options (:alert_db_time and :alert_sql_number) (thanks to scorpio);
26
+ * Fixed bugs of layout link and route note related (thanks to scorpio).
27
+
28
+ == Footnotes v3.5
29
+ * Added NewRelic RPM footnote (thanks to kbrock);
30
+ * Several bug fixes (thanks to kbrock, ivanoats and kristopher).
31
+
32
+ == Footnotes v3.4
33
+ * Rails 2.3 compatible.
34
+
35
+ == Footnotes v3.3.1
36
+ * Changed prefix to support %s and %d;
37
+ * Created gemspec;
38
+ * Some code refactoring (called eval just once instead of three times).
39
+
40
+ == Footnotes v3.3
41
+ * Rails Edge (aka 2.2) compatibility;
42
+ * Initial Ruby 1.9 compatibility.
43
+
44
+ == Footnotes v3.2.2
45
+ * Added trace to QueriesNote;
46
+ * Fixed incompatibility with Ultrasphinx (thanks to mhartl);
47
+ * Added W3C compatibility (thanks to tapajos);
48
+ * Added support to other log mechanisms in LogNote.
49
+
50
+ == Footnotes v3.2.1
51
+ * Added some tests;
52
+ * Redefined Footnotes CSS and Javascripts to use concise names.
53
+
54
+ == Footnotes v3.2
55
+ * Now you can easily add your own notes;
56
+ * Added numbers to tabs;
57
+ * Added Queries note;
58
+ * Added MySQL Query Analyzer.
59
+
60
+ == Footnotes v3.1
61
+ * Code refactoring (using modules, except backtracer);
62
+ * Ability to cherry pick notes;
63
+ * Working on Rails 2.1.
64
+
65
+ == Footnotes v3.0
66
+ * Some code refactoring;
67
+ * Stylesheets bug fixed: was showing not only css in Stylesheets div;
68
+ * Logtail fix: working with Rails 2.0 logger and in all OS, since it's Regexp based;
69
+ * Rails 1.2 (except backtrace) and 2.0 compatible;
70
+ * RoutingNavigator (based on Rick Olson plugin);
71
+ * FilterChain.
72
+
73
+ == Textmate Footnotes v2.0
74
+ Copyright (c) 2006 InquiryLabs, Inc.
75
+ http://inquirylabs.com/
76
+
77
+ Description:
78
+ Creates clickable footnotes on each rendered page, as well as clickable
79
+ links in the backtrace should an error occur in your Rails app. Links take
80
+ you to the right place inside TextMate.
81
+ Enable only the TextMate on Macs in development mode
data/MIT-LICENSE ADDED
@@ -0,0 +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.
data/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # Rails Footnotes
2
+ #### Version 4.0.0.pre (The Rails 3 Edition™)
3
+ #### MIT License
4
+
5
+ ## Rails 3
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.
9
+
10
+ ## Description
11
+
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
+
17
+
18
+ ## Installation
19
+
20
+ In your Gemfile:
21
+
22
+ gem 'rails-footnotes', :git => 'git://github.com/indirect/rails-footnotes.git'
23
+
24
+ ## Configuration
25
+
26
+ By default, footnotes will only be activated when your Rails app is in development mode. If you want to add alternate logic to enable or disable footnotes, add something like this to config/initializers/footnotes.rb:
27
+
28
+ if defined?(Footnotes) & Rails.env.development?
29
+ Footnotes.run! # first of all
30
+
31
+ # ... other init code
32
+ end
33
+
34
+ If you are using MacVim as your editor, add this line to your initializer:
35
+
36
+ Footnotes::Filter.prefix = 'mvim://open?url=file://%s&line=%d&column=%d'
37
+
38
+ If you have another editor, simply create a prefix that will result in a link your editor understands. The %s
39
+ is replaced by the name of the file, the first %d is replaced by the line number and the second %d is replaced
40
+ by the column.
41
+
42
+ By default, footnotes are appended at the end of the page with default stylesheet. If you want to change their
43
+ position, you can define a div with id "footnotes_holder" or define your own stylesheet by turning footnotes
44
+ stylesheet off:
45
+
46
+ Footnotes::Filter.no_style = true
47
+
48
+ Another option is to allow multiple notes to be opened at the same time:
49
+
50
+ Footnotes::Filter.multiple_notes = true
51
+
52
+ If you have New Relic RPM installed, you may want to turn off query explains
53
+ (explains can slows things down)
54
+
55
+ Footnotes::Notes::QueriesNote.sql_explain = false
56
+
57
+ Finally, you can control which notes you want to show. The default are:
58
+
59
+ Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :env, :queries, :log, :general]
60
+
61
+
62
+ ## Creating your own notes
63
+
64
+ Create your notes to integrate with Footnotes is easy.
65
+
66
+ 1. Create a Footnotes::Notes::YourExampleNote class
67
+
68
+ 2. Implement the necessary methods (check abstract_note.rb file in lib/notes)
69
+
70
+ 3. Append your example note in Footnotes::Filter.notes array (usually at the end of your environment file or in an initializer):
71
+
72
+ For example, to create a note that shows info about the user logged in your application you just have to do:
73
+
74
+ module Footnotes
75
+ module Notes
76
+ class CurrentUserNote < AbstractNote
77
+ # This method always receives a controller
78
+ #
79
+ def initialize(controller)
80
+ @current_user = controller.instance_variable_get("@current_user")
81
+ end
82
+
83
+ # Returns the title that represents this note.
84
+ #
85
+ def title
86
+ "Current user: #{@current_user.name}"
87
+ end
88
+
89
+ # This Note is only valid if we actually found an user
90
+ # If it's not valid, it won't be displayed
91
+ #
92
+ def valid?
93
+ @current_user
94
+ end
95
+
96
+ # The fieldset content
97
+ #
98
+ def content
99
+ escape(@current_user.inspect)
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ Then put in your environment:
106
+
107
+ Footnotes::Filter.notes += [:current_user]
108
+
109
+
110
+
111
+ #### Version 3.6.7
112
+
113
+ This plugin was maintained until version 3.6.7 by [Keenan Brock][kb] (keenan@thebrocks.net), along with contributors [Leon Li][ll], [Ivan Storck][is], and [Kris Chamber][kc].
114
+
115
+ [kb]: http://github.com/kbrock
116
+ [ll]: http://github.com/scorpio
117
+ [is]: http://github.com/ivanoats
118
+ [kc]: http://github.com/kristopher
119
+
120
+ #### Version 3.6
121
+
122
+ This plugin was maintained until version 3.6 by [José Valim][jv] (jose@plataformatec.com.br).
123
+ Copyright (c) 2009 José Valim.
124
+
125
+ [jv]: http://blog.plataformatec.com.br/
126
+
127
+ #### Version 2.0
128
+
129
+ This plugin was created and maintained until version 2.0 by Duane Johnson. Copyright (c) 2006 [InquiryLabs](http://blog.inquirylabs.com/), Inc.
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Run tests for Footnotes.'
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.pattern = 'test/**/*_test.rb'
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => :test
13
+
14
+ desc 'Generate documentation for Footnotes.'
15
+ Rake::RDocTask.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Footnotes'
18
+ rdoc.options << '--line-numbers' << '--inline-source'
19
+ rdoc.rdoc_files.include('README')
20
+ rdoc.rdoc_files.include('MIT-LICENSE')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ begin
25
+ require 'metric_fu'
26
+ MetricFu::Configuration.run do |config|
27
+ #skipping: churn, :stats
28
+ config.metrics = [:saikuro, :flog, :flay, :reek, :roodi, :rcov]
29
+ # config.graphs = [:flog, :flay, :reek, :roodi, :rcov]
30
+ config.rcov[:rcov_opts] << "-Itest"
31
+ end
32
+ rescue LoadError
33
+ end
@@ -0,0 +1,36 @@
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
+ if Rails.version < '3.0'
35
+ Exception.send :include, Footnotes::Extensions::Exception
36
+ end
@@ -0,0 +1,365 @@
1
+ module Footnotes
2
+ class BeforeFilter
3
+ # Method called to start the notes
4
+ # It's a before filter prepend in the controller
5
+ def self.filter(controller)
6
+ Footnotes::Filter.start!(controller)
7
+ end
8
+ end
9
+
10
+ class AfterFilter
11
+ # Method that calls Footnotes to attach its contents
12
+ def self.filter(controller)
13
+ filter = Footnotes::Filter.new(controller)
14
+ filter.add_footnotes!
15
+ filter.close!(controller)
16
+ end
17
+ end
18
+
19
+ class Filter
20
+ @@no_style = false
21
+ @@multiple_notes = false
22
+ @@klasses = []
23
+
24
+ # Default link prefix is textmate
25
+ @@prefix = 'txmt://open?url=file://%s&amp;line=%d&amp;column=%d'
26
+
27
+ # Edit notes
28
+ @@notes = [ :controller, :view, :layout, :partials, :stylesheets, :javascripts ]
29
+ # Show notes
30
+ @@notes += [ :assigns, :session, :cookies, :params, :filters, :routes, :env, :queries, :log, :general ]
31
+
32
+ # Change queries for rpm note when available
33
+ # if defined?(NewRelic)
34
+ # @@notes.delete(:queries)
35
+ # @@notes << :rpm
36
+ # end
37
+
38
+ # :no_style => If you don't want the style to be appended to your pages
39
+ # :notes => Class variable that holds the notes to be processed
40
+ # :prefix => Prefix appended to FootnotesLinks
41
+ # :multiple_notes => Set to true if you want to open several notes at the same time
42
+ cattr_accessor :no_style, :notes, :prefix, :multiple_notes
43
+
44
+ class << self
45
+
46
+ # Calls the class method start! in each note
47
+ # Sometimes notes need to set variables or clean the environment to work properly
48
+ # This method allows this kind of setup
49
+ #
50
+ def start!(controller)
51
+ @@klasses = []
52
+
53
+ each_with_rescue(@@notes.flatten) do |note|
54
+ klass = "Footnotes::Notes::#{note.to_s.camelize}Note".constantize
55
+ klass.start!(controller) if klass.respond_to?(:start!)
56
+ @@klasses << klass
57
+ end
58
+ end
59
+
60
+ # Process notes, discarding only the note if any problem occurs
61
+ #
62
+ def each_with_rescue(notes)
63
+ delete_me = []
64
+
65
+ notes.each do |note|
66
+ begin
67
+ yield note
68
+ rescue Exception => e
69
+ # Discard note if it has a problem
70
+ log_error("Footnotes #{note.to_s.camelize}Note Exception", e)
71
+ delete_me << note
72
+ next
73
+ end
74
+ end
75
+
76
+ delete_me.each{ |note| notes.delete(note) }
77
+ return notes
78
+ end
79
+
80
+ # Logs the error using specified title and format
81
+ #
82
+ def log_error(title, exception)
83
+ Rails.logger.error "#{title}: #{exception}\n#{exception.backtrace.join("\n")}"
84
+ end
85
+
86
+ # If none argument is sent, simply return the prefix.
87
+ # Otherwise, replace the args in the prefix.
88
+ #
89
+ def prefix(*args)
90
+ if args.empty?
91
+ @@prefix
92
+ else
93
+ format(@@prefix, *args)
94
+ end
95
+ end
96
+
97
+ end
98
+
99
+ def initialize(controller)
100
+ @controller = controller
101
+ @template = controller.instance_variable_get(:@template)
102
+ @body = controller.response.body
103
+ @notes = []
104
+ end
105
+
106
+ def add_footnotes!
107
+ add_footnotes_without_validation! if valid?
108
+ rescue Exception => e
109
+ # Discard footnotes if there are any problems
110
+ self.class.log_error("Footnotes Exception", e)
111
+ end
112
+
113
+ # Calls the class method close! in each note
114
+ # Sometimes notes need to finish their work even after being read
115
+ # This method allows this kind of work
116
+ #
117
+ def close!(controller)
118
+ each_with_rescue(@@klasses) do |klass|
119
+ klass.close!(controller)
120
+ end
121
+ end
122
+
123
+ protected
124
+ def valid?
125
+ performed_render? && valid_format? && valid_content_type? &&
126
+ @body.is_a?(String) && !component_request? && !xhr? &&
127
+ !footnotes_disabled?
128
+ end
129
+
130
+ def add_footnotes_without_validation!
131
+ initialize_notes!
132
+ insert_styles unless @@no_style
133
+ insert_footnotes
134
+ end
135
+
136
+ def initialize_notes!
137
+ each_with_rescue(@@klasses) do |klass|
138
+ note = klass.new(@controller)
139
+ @notes << note if note.respond_to?(:valid?) && note.valid?
140
+ end
141
+ end
142
+
143
+ def performed_render?
144
+ @controller.instance_variable_get(:@performed_render) || # rails 2.x
145
+ (@controller.respond_to?(:performed?) && @controller.performed?) # rails3, will break on redirect??
146
+ end
147
+
148
+ def valid_format?
149
+ if @template # Rails 2.x
150
+ [:html,:rhtml,:xhtml,:rxhtml].include?(@template.send(template_format_method.to_sym).to_sym)
151
+ else # Rails 3
152
+ @controller.response.content_type == 'text/html'
153
+ end
154
+ end
155
+
156
+ def template_format_method
157
+ if @template.respond_to?(:template_format)
158
+ return 'template_format'
159
+ else
160
+ return 'format'
161
+ end
162
+ end
163
+
164
+ def valid_content_type?
165
+ c = @controller.response.headers['Content-Type'].to_s
166
+ (c.empty? || c =~ /html/)
167
+ end
168
+
169
+ def component_request?
170
+ @controller.instance_variable_get(:@parent_controller)
171
+ end
172
+
173
+ def xhr?
174
+ @controller.request.xhr?
175
+ end
176
+
177
+ def footnotes_disabled?
178
+ @controller.params[:footnotes] == "false"
179
+ end
180
+
181
+ #
182
+ # Insertion methods
183
+ #
184
+
185
+ def insert_styles
186
+ #TODO More customizable(reset.css, from file etc.)
187
+ insert_text :before, /<\/head>/i, <<-HTML
188
+ <!-- Footnotes Style -->
189
+ <style type="text/css">
190
+ #footnotes_debug {font-size: 11px; font-weight: normal; margin: 2em 0 1em 0; text-align: center; color: #444; line-height: 16px;}
191
+ #footnotes_debug th, #footnotes_debug td {color: #444; line-height: 18px;}
192
+ #footnotes_debug a {color: #9b1b1b; font-weight: inherit; text-decoration: none; line-height: 18px;}
193
+ #footnotes_debug table {text-align: center;}
194
+ #footnotes_debug table td {padding: 0 5px;}
195
+ #footnotes_debug tbody {text-align: left;}
196
+ #footnotes_debug .name_values td {vertical-align: top;}
197
+ #footnotes_debug legend {background-color: #fff;}
198
+ #footnotes_debug fieldset {text-align: left; border: 1px dashed #aaa; padding: 0.5em 1em 1em 1em; margin: 1em 2em; color: #444; background-color: #FFF;}
199
+ /* Aditional Stylesheets */
200
+ #{@notes.map(&:stylesheet).compact.join("\n")}
201
+ </style>
202
+ <!-- End Footnotes Style -->
203
+ HTML
204
+ end
205
+
206
+ def insert_footnotes
207
+ # Fieldsets method should be called first
208
+ content = fieldsets
209
+
210
+ footnotes_html = <<-HTML
211
+ <!-- Footnotes -->
212
+ <div style="clear:both"></div>
213
+ <div id="footnotes_debug">
214
+ #{links}
215
+ #{content}
216
+ <script type="text/javascript">
217
+ var Footnotes = function() {
218
+
219
+ function hideAll(){
220
+ #{close unless @@multiple_notes}
221
+ }
222
+
223
+ function hideAllAndToggle(id) {
224
+ hideAll();
225
+ toggle(id)
226
+
227
+ location.href = '#footnotes_debug';
228
+ }
229
+
230
+ function toggle(id){
231
+ var el = document.getElementById(id);
232
+ if (el.style.display == 'none') {
233
+ Footnotes.show(el);
234
+ } else {
235
+ Footnotes.hide(el);
236
+ }
237
+ }
238
+
239
+ function show(element) {
240
+ element.style.display = 'block'
241
+ }
242
+
243
+ function hide(element) {
244
+ element.style.display = 'none'
245
+ }
246
+
247
+ return {
248
+ show: show,
249
+ hide: hide,
250
+ toggle: toggle,
251
+ hideAllAndToggle: hideAllAndToggle
252
+ }
253
+ }();
254
+ /* Additional Javascript */
255
+ #{@notes.map(&:javascript).compact.join("\n")}
256
+ </script>
257
+ </div>
258
+ <!-- End Footnotes -->
259
+ HTML
260
+
261
+ placeholder = /<div[^>]+id=['"]footnotes_holder['"][^>]*>/i
262
+ if @controller.response.body =~ placeholder
263
+ insert_text :after, placeholder, footnotes_html
264
+ else
265
+ insert_text :before, /<\/body>/i, footnotes_html
266
+ end
267
+ end
268
+
269
+ # Process notes to gets their links in their equivalent row
270
+ #
271
+ def links
272
+ links = Hash.new([])
273
+ order = []
274
+ each_with_rescue(@notes) do |note|
275
+ order << note.row
276
+ links[note.row] += [link_helper(note)]
277
+ end
278
+
279
+ html = ''
280
+ order.uniq!
281
+ order.each do |row|
282
+ html << "#{row.is_a?(String) ? row : row.to_s.camelize}: #{links[row].join(" | \n")}<br />"
283
+ end
284
+ html
285
+ end
286
+
287
+ # Process notes to get their content
288
+ #
289
+ def fieldsets
290
+ content = ''
291
+ each_with_rescue(@notes) do |note|
292
+ next unless note.has_fieldset?
293
+ content << <<-HTML
294
+ <fieldset id="#{note.to_sym}_debug_info" style="display: none">
295
+ <legend>#{note.legend}</legend>
296
+ <div>#{note.content}</div>
297
+ </fieldset>
298
+ HTML
299
+ end
300
+ content
301
+ end
302
+
303
+ # Process notes to get javascript code to close them.
304
+ # This method is only used when multiple_notes is false.
305
+ #
306
+ def close
307
+ javascript = ''
308
+ each_with_rescue(@notes) do |note|
309
+ next unless note.has_fieldset?
310
+ javascript << close_helper(note)
311
+ end
312
+ javascript
313
+ end
314
+
315
+ #
316
+ # Helpers
317
+ #
318
+
319
+ # Helper that creates the javascript code to close the note
320
+ #
321
+ def close_helper(note)
322
+ "Footnotes.hide(document.getElementById('#{note.to_sym}_debug_info'));\n"
323
+ end
324
+
325
+ # Helper that creates the link and javascript code when note is clicked
326
+ #
327
+ def link_helper(note)
328
+ onclick = note.onclick
329
+ unless href = note.link
330
+ href = '#'
331
+ onclick ||= "Footnotes.hideAllAndToggle('#{note.to_sym}_debug_info');return false;" if note.has_fieldset?
332
+ end
333
+
334
+ "<a href=\"#{href}\" onclick=\"#{onclick}\">#{note.title}</a>"
335
+ end
336
+
337
+ # Inserts text in to the body of the document
338
+ # +pattern+ is a Regular expression which, when matched, will cause +new_text+
339
+ # to be inserted before or after the match. If no match is found, +new_text+ is appended
340
+ # to the body instead. +position+ may be either :before or :after
341
+ #
342
+ def insert_text(position, pattern, new_text)
343
+ index = case pattern
344
+ when Regexp
345
+ if match = @controller.response.body.match(pattern)
346
+ match.offset(0)[position == :before ? 0 : 1]
347
+ else
348
+ @controller.response.body.size
349
+ end
350
+ else
351
+ pattern
352
+ end
353
+ newbody = @controller.response.body
354
+ newbody.insert index, new_text
355
+ @controller.response.body = newbody
356
+ end
357
+
358
+ # Instance each_with_rescue method
359
+ #
360
+ def each_with_rescue(*args, &block)
361
+ self.class.each_with_rescue(*args, &block)
362
+ end
363
+
364
+ end
365
+ end