dr_dre 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENCE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 tictoc family limited
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ LICENCE
2
+ Manifest
3
+ README
4
+ Rakefile
5
+ lib/dr_dre.rb
6
+ lib/dr_dre/dr_dre.rb
data/README ADDED
@@ -0,0 +1,8 @@
1
+ = dr_dre - diagnose Double Render Errors in Rails apps
2
+
3
+ dr_dre intercepts calls to render and redirect in ActionController and, if it
4
+ detects multiple calls to render or redirect (triggering a DoubleRenderError),
5
+ will drop a couple of lines into the output log identifying where the redirect
6
+ or render calls were made from.
7
+
8
+ Just use the gem and +include DrDre+ in any controllers you want to monitor.
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('dr_dre', '0.1') do |p|
6
+ p.description = "A gem that logs a list of callers to redirect_to and render in a Rails app, and catches DoubleRenderErrors"
7
+ p.url = "http://github.com/tictoc/dr_dre"
8
+ p.author = "Matthew MacLeod"
9
+ p.email = "matthew@tictocfamily.com"
10
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{dr_dre}
5
+ s.version = "0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Matthew MacLeod"]
9
+ s.date = %q{2010-07-15}
10
+ s.description = %q{A gem that logs a list of callers to redirect_to and render in a Rails app, and catches DoubleRenderErrors}
11
+ s.email = %q{matthew@tictocfamily.com}
12
+ s.extra_rdoc_files = ["README", "lib/dr_dre.rb", "lib/dr_dre/dr_dre.rb"]
13
+ s.files = ["LICENCE", "Manifest", "README", "Rakefile", "lib/dr_dre.rb", "lib/dr_dre/dr_dre.rb", "dr_dre.gemspec"]
14
+ s.homepage = %q{http://github.com/tictoc/dr_dre}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Dr_dre", "--main", "README"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{dr_dre}
18
+ s.rubygems_version = %q{1.3.6}
19
+ s.summary = %q{A gem that logs a list of callers to redirect_to and render in a Rails app, and catches DoubleRenderErrors}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
@@ -0,0 +1,2 @@
1
+ require 'action_controller'
2
+ require 'dr_dre/dr_dre'
@@ -0,0 +1,36 @@
1
+ module DrDre
2
+
3
+ def redirect_to(*params)
4
+ log_if_dre
5
+ super(params)
6
+ end
7
+
8
+ def render(*params)
9
+ log_if_dre
10
+ super(params)
11
+ end
12
+
13
+ private
14
+
15
+ def log_if_dre
16
+ @dr_dre_call_log ||= []
17
+ @dr_dre_call_log << caller[1]
18
+ log_dre if @dr_dre_call_log.length > 1
19
+ end
20
+
21
+ def log_dre
22
+
23
+ # Log the error
24
+ error = []
25
+ error << "dr_dre: your application has called render or redirect_to more than once!"
26
+ error += @dr_dre_call_log.map{|c| "Called from: #{c}"}
27
+
28
+ logger.info "\n" + error.join("\n")
29
+
30
+ # Do a custom exception message
31
+ raise ActionController::DoubleRenderError, error.join("\n")
32
+
33
+ end
34
+
35
+ end
36
+
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dr_dre
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Matthew MacLeod
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-07-15 00:00:00 +01:00
17
+ default_executable:
18
+ dependencies: []
19
+
20
+ description: A gem that logs a list of callers to redirect_to and render in a Rails app, and catches DoubleRenderErrors
21
+ email: matthew@tictocfamily.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files:
27
+ - README
28
+ - lib/dr_dre.rb
29
+ - lib/dr_dre/dr_dre.rb
30
+ files:
31
+ - LICENCE
32
+ - Manifest
33
+ - README
34
+ - Rakefile
35
+ - lib/dr_dre.rb
36
+ - lib/dr_dre/dr_dre.rb
37
+ - dr_dre.gemspec
38
+ has_rdoc: true
39
+ homepage: http://github.com/tictoc/dr_dre
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --line-numbers
45
+ - --inline-source
46
+ - --title
47
+ - Dr_dre
48
+ - --main
49
+ - README
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 1
65
+ - 2
66
+ version: "1.2"
67
+ requirements: []
68
+
69
+ rubyforge_project: dr_dre
70
+ rubygems_version: 1.3.6
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: A gem that logs a list of callers to redirect_to and render in a Rails app, and catches DoubleRenderErrors
74
+ test_files: []
75
+