dynamic_errors 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/app/views/errors/404.html.erb +29 -0
- data/app/views/errors/422.html.erb +29 -0
- data/app/views/errors/500.html.erb +29 -0
- data/lib/dynamic_errors/engine.rb +4 -0
- data/lib/dynamic_errors.rb +36 -0
- data/test/helper.rb +18 -0
- data/test/test_dynamic_errors.rb +7 -0
- metadata +139 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.0"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Kyle Bock
|
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,19 @@
|
|
1
|
+
= dynamic_errors
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to dynamic_errors
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Kyle Bock. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "dynamic_errors"
|
18
|
+
gem.homepage = "http://github.com/kwbock/dynamic_errors"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{TODO: one-line summary of your gem}
|
21
|
+
gem.description = %Q{TODO: longer description of your gem}
|
22
|
+
gem.email = "kylewbock@gmail.com"
|
23
|
+
gem.authors = ["Kyle Bock"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "dynamic_errors #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
body {
|
3
|
+
background-color: #fff;
|
4
|
+
color: #666;
|
5
|
+
text-align: center;
|
6
|
+
font-family: arial, sans-serif;
|
7
|
+
}
|
8
|
+
|
9
|
+
div.dialog {
|
10
|
+
width: 25em;
|
11
|
+
padding: 0 4em;
|
12
|
+
margin: 4em auto 0 auto;
|
13
|
+
border: 1px solid #ccc;
|
14
|
+
border-right-color: #999;
|
15
|
+
border-bottom-color: #999;
|
16
|
+
}
|
17
|
+
|
18
|
+
h1 {
|
19
|
+
font-size: 100%;
|
20
|
+
color: #f00;
|
21
|
+
line-height: 1.5em;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
<div class="dialog">
|
25
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
26
|
+
<p>
|
27
|
+
You may have mistyped the address or the page may have moved.
|
28
|
+
</p>
|
29
|
+
</div>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
body {
|
3
|
+
background-color: #fff;
|
4
|
+
color: #666;
|
5
|
+
text-align: center;
|
6
|
+
font-family: arial, sans-serif;
|
7
|
+
}
|
8
|
+
|
9
|
+
div.dialog {
|
10
|
+
width: 25em;
|
11
|
+
padding: 0 4em;
|
12
|
+
margin: 4em auto 0 auto;
|
13
|
+
border: 1px solid #ccc;
|
14
|
+
border-right-color: #999;
|
15
|
+
border-bottom-color: #999;
|
16
|
+
}
|
17
|
+
|
18
|
+
h1 {
|
19
|
+
font-size: 100%;
|
20
|
+
color: #f00;
|
21
|
+
line-height: 1.5em;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
<div class="dialog">
|
25
|
+
<h1>The change you wanted was rejected.</h1>
|
26
|
+
<p>
|
27
|
+
Maybe you tried to change something you didn't have access to.
|
28
|
+
</p>
|
29
|
+
</div>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
body {
|
3
|
+
background-color: #fff;
|
4
|
+
color: #666;
|
5
|
+
text-align: center;
|
6
|
+
font-family: arial, sans-serif;
|
7
|
+
}
|
8
|
+
|
9
|
+
div.dialog {
|
10
|
+
width: 25em;
|
11
|
+
padding: 0 4em;
|
12
|
+
margin: 4em auto 0 auto;
|
13
|
+
border: 1px solid #ccc;
|
14
|
+
border-right-color: #999;
|
15
|
+
border-bottom-color: #999;
|
16
|
+
}
|
17
|
+
|
18
|
+
h1 {
|
19
|
+
font-size: 100%;
|
20
|
+
color: #f00;
|
21
|
+
line-height: 1.5em;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
<div class="dialog">
|
25
|
+
<h1>We're sorry, but something went wrong.</h1>
|
26
|
+
<p>
|
27
|
+
We've been notified about this issue and we'll take a look at it shortly.
|
28
|
+
</p>
|
29
|
+
</div>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_record'
|
3
|
+
require 'active_record/errors'
|
4
|
+
|
5
|
+
require 'dynamic_errors/engine'
|
6
|
+
|
7
|
+
module DynamicErrors
|
8
|
+
puts "Hell Yes"
|
9
|
+
class ActionController::Base
|
10
|
+
# the following is for dynamic errors
|
11
|
+
# consider moving this to lib/dynamic_errors.rb to create mixin module that can be reused
|
12
|
+
# in Tapestry Adjustments case we want to redirect to the root path (search page)
|
13
|
+
unless config.consider_all_requests_local
|
14
|
+
rescue_from Exception, :with => :render_error
|
15
|
+
rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found
|
16
|
+
rescue_from ActionController::RoutingError, :with => :render_not_found
|
17
|
+
rescue_from ActionController::UnknownController, :with => :render_not_found
|
18
|
+
# customize these as much as you want, ie, different for every error or all the same
|
19
|
+
rescue_from ActionController::UnknownAction, :with => :render_not_found
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def render_not_found(exception)
|
25
|
+
# uncomment the following line land make sure that view exists for customized 404 error page
|
26
|
+
render :template => "app/views/errors/404.html.erb", :status => 404
|
27
|
+
#redirect_to :root
|
28
|
+
end
|
29
|
+
|
30
|
+
def render_error(exception)
|
31
|
+
# uncomment the following line and make sure that view exists for customized 500 error page
|
32
|
+
render :template => "/errors/500.html.erb", :status => 500
|
33
|
+
#redirect_to :root
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'dynamic_errors'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynamic_errors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Kyle Bock
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-25 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bundler
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 0
|
48
|
+
version: 1.0.0
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: jeweler
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 15
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 6
|
63
|
+
- 0
|
64
|
+
version: 1.6.0
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rcov
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id004
|
81
|
+
description: A gem to allow dynamic error pages in Rails
|
82
|
+
email: kylewbock@gmail.com
|
83
|
+
executables: []
|
84
|
+
|
85
|
+
extensions: []
|
86
|
+
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.rdoc
|
90
|
+
files:
|
91
|
+
- .document
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.rdoc
|
95
|
+
- Rakefile
|
96
|
+
- VERSION
|
97
|
+
- lib/dynamic_errors.rb
|
98
|
+
- lib/dynamic_errors/engine.rb
|
99
|
+
- app/views/errors/500.html.erb
|
100
|
+
- app/views/errors/404.html.erb
|
101
|
+
- app/views/errors/422.html.erb
|
102
|
+
- test/helper.rb
|
103
|
+
- test/test_dynamic_errors.rb
|
104
|
+
has_rdoc: true
|
105
|
+
homepage: http://github.com/kwbock/dynamic_errors
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
hash: 3
|
119
|
+
segments:
|
120
|
+
- 0
|
121
|
+
version: "0"
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.3.7
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Adds dynamic error pages to Rails
|
138
|
+
test_files: []
|
139
|
+
|