vidibus-routing_error 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Andre Pankratz
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.
data/README.rdoc ADDED
@@ -0,0 +1,38 @@
1
+ = vidibus-routing_error
2
+
3
+ This gem is part of the open source SOA framework Vidibus: http://www.vidibus.org
4
+
5
+ Catches ActionController::RoutingError, because this does not work with Rails 3 anymore.
6
+ It basically catches the exception on rack-level and re-raises it on application-level.
7
+
8
+
9
+ == Installation
10
+
11
+ Add the dependency to the Gemfile of your application:
12
+
13
+ gem "vidibus-inheritance"
14
+
15
+ Then call bundle install on your console.
16
+
17
+
18
+ == Usage
19
+
20
+ class ApplicationController < ActionController::Base
21
+ rescue_from ActionController::RoutingError, :with => :rescue_404
22
+
23
+ def rescue_404
24
+ # do something
25
+ # IMPORTANT:
26
+ # If you modify this method, you have to restart the server.
27
+ end
28
+ end
29
+
30
+
31
+ == Copyright
32
+
33
+ Copyright (c) 2010 Andre Pankratz. See LICENSE for details.
34
+
35
+
36
+ == Thank you!
37
+
38
+ The development of this gem was sponsored by Käuferportal: http://www.kaeuferportal.de
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require "rubygems"
2
+ require "rake"
3
+
4
+ begin
5
+ require "jeweler"
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "vidibus-routing_error"
8
+ gem.summary = %Q{Catches ActionController::RoutingError in Rails 3.}
9
+ gem.description = %Q{Catches ActionController::RoutingError and sends it to a custom method.}
10
+ gem.email = "andre@vidibus.com"
11
+ gem.homepage = "http://github.com/vidibus/vidibus-routing_error"
12
+ gem.authors = ["Andre Pankratz"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "relevance-rcov"
15
+ gem.add_development_dependency "rr"
16
+ gem.add_dependency "rails", ">= 3.0.0.rc"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require "spec/rake/spectask"
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << "lib" << "spec"
27
+ spec.spec_files = FileList["spec/**/*_spec.rb"]
28
+ end
29
+
30
+ Spec::Rake::SpecTask.new(:rcov) do |t|
31
+ t.spec_files = FileList["spec/vidibus/**/*_spec.rb"]
32
+ t.rcov = true
33
+ t.rcov_opts = ["--exclude", "^spec,/gems/"]
34
+ end
35
+
36
+ task :spec => :check_dependencies
37
+ task :default => :spec
38
+
39
+ require "rake/rdoctask"
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
42
+ rdoc.rdoc_dir = "rdoc"
43
+ rdoc.title = "vidibus-routing_error #{version}"
44
+ rdoc.rdoc_files.include("README*")
45
+ rdoc.rdoc_files.include("lib/**/*.rb")
46
+ rdoc.options << "--charset=utf-8"
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,15 @@
1
+ class RoutingErrorController < ApplicationController
2
+
3
+ # Re-raise routing_error that has been catched in rack app.
4
+ # To rescue this error, use default actions:
5
+ #
6
+ # rescue_from ActionController::RoutingError, :with => :my_404_rescue
7
+ # def my_404_rescue
8
+ # # do something
9
+ # end
10
+ #
11
+ def rescue
12
+ env["REQUEST_URI"] = env["vidibus-routing_error.request_uri"]
13
+ raise env["vidibus-routing_error.exception"]
14
+ end
15
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do |map|
2
+ match "routing_error" => "routing_error#rescue"
3
+ end
@@ -0,0 +1,10 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib", "vidibus"))
2
+ require "routing_error/rack"
3
+
4
+ module Vidibus::RoutingError
5
+ class Engine < ::Rails::Engine
6
+ unless Rails.env.test?
7
+ config.app_middleware.insert_before("ActionDispatch::ShowExceptions", "Vidibus::RoutingError::Rack")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ module Vidibus
2
+ module RoutingError
3
+ class Rack
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ env["action_dispatch.show_exceptions"] = false
10
+ @app.call(env)
11
+ rescue => exception
12
+ if exception.kind_of?(ActionController::RoutingError)
13
+ env["vidibus-routing_error.exception"] = exception
14
+ env["vidibus-routing_error.request_uri"] = env["REQUEST_URI"]
15
+
16
+ # set routing_error path internally to catch route
17
+ env["PATH_INFO"] = env["REQUEST_URI"] = "/routing_error"
18
+ end
19
+ env["action_dispatch.show_exceptions"] = true
20
+ return @app.call(env)
21
+ end
22
+ end
23
+ end
24
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+
4
+ require "rubygems"
5
+ require "active_support/core_ext"
6
+ require "spec"
7
+ require "rr"
8
+ require "vidibus-routing_error"
9
+
10
+ Spec::Runner.configure do |config|
11
+ config.mock_with RR::Adapters::Rspec
12
+ end
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{vidibus-routing_error}
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andre Pankratz"]
12
+ s.date = %q{2010-08-13}
13
+ s.description = %q{Catches ActionController::RoutingError and sends it to a custom method.}
14
+ s.email = %q{andre@vidibus.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "app/controllers/routing_error_controller.rb",
27
+ "config/routes.rb",
28
+ "lib/vidibus-routing_error.rb",
29
+ "lib/vidibus/routing_error/rack.rb",
30
+ "spec/spec.opts",
31
+ "spec/spec_helper.rb",
32
+ "vidibus-routing_error.gemspec"
33
+ ]
34
+ s.homepage = %q{http://github.com/vidibus/vidibus-routing_error}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.7}
38
+ s.summary = %q{Catches ActionController::RoutingError in Rails 3.}
39
+ s.test_files = [
40
+ "spec/spec_helper.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
49
+ s.add_development_dependency(%q<relevance-rcov>, [">= 0"])
50
+ s.add_development_dependency(%q<rr>, [">= 0"])
51
+ s.add_runtime_dependency(%q<rails>, [">= 3.0.0.rc"])
52
+ else
53
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
54
+ s.add_dependency(%q<relevance-rcov>, [">= 0"])
55
+ s.add_dependency(%q<rr>, [">= 0"])
56
+ s.add_dependency(%q<rails>, [">= 3.0.0.rc"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
60
+ s.add_dependency(%q<relevance-rcov>, [">= 0"])
61
+ s.add_dependency(%q<rr>, [">= 0"])
62
+ s.add_dependency(%q<rails>, [">= 3.0.0.rc"])
63
+ end
64
+ end
65
+
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vidibus-routing_error
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
11
+ platform: ruby
12
+ authors:
13
+ - Andre Pankratz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-13 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: relevance-rcov
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rr
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rails
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 7712042
74
+ segments:
75
+ - 3
76
+ - 0
77
+ - 0
78
+ - rc
79
+ version: 3.0.0.rc
80
+ type: :runtime
81
+ version_requirements: *id004
82
+ description: Catches ActionController::RoutingError and sends it to a custom method.
83
+ email: andre@vidibus.com
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files:
89
+ - LICENSE
90
+ - README.rdoc
91
+ files:
92
+ - .document
93
+ - .gitignore
94
+ - LICENSE
95
+ - README.rdoc
96
+ - Rakefile
97
+ - VERSION
98
+ - app/controllers/routing_error_controller.rb
99
+ - config/routes.rb
100
+ - lib/vidibus-routing_error.rb
101
+ - lib/vidibus/routing_error/rack.rb
102
+ - spec/spec.opts
103
+ - spec/spec_helper.rb
104
+ - vidibus-routing_error.gemspec
105
+ has_rdoc: true
106
+ homepage: http://github.com/vidibus/vidibus-routing_error
107
+ licenses: []
108
+
109
+ post_install_message:
110
+ rdoc_options:
111
+ - --charset=UTF-8
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
131
+ version: "0"
132
+ requirements: []
133
+
134
+ rubyforge_project:
135
+ rubygems_version: 1.3.7
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Catches ActionController::RoutingError in Rails 3.
139
+ test_files:
140
+ - spec/spec_helper.rb