custom_errors_handler 0.2.4 → 0.2.5
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.
- data/CHANGELOG.rdoc +2 -0
- data/Rakefile +1 -1
- data/custom_errors_handler.gemspec +1 -1
- data/lib/custom_errors_handler_controller.rb +23 -8
- metadata +5 -5
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'rake'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new('custom_errors_handler', '0.2.
|
6
|
+
Echoe.new('custom_errors_handler', '0.2.5') do |p|
|
7
7
|
p.description = "Custom Errors Handler is intended as an easy alternative to manage showing/rendering exceptions templates (404, 500) in Rails3"
|
8
8
|
p.url = "https://github.com/mensfeld/Custom-Errors-Handler"
|
9
9
|
p.author = "Maciej Mensfeld"
|
@@ -3,7 +3,8 @@ require 'action_controller'
|
|
3
3
|
|
4
4
|
class CustomErrorsHandlerController < ActionController::Base
|
5
5
|
# Where it should look for error templates
|
6
|
-
|
6
|
+
VALID_ERRORS_DIR_PREFIX = ['', 'layouts', 'shared']
|
7
|
+
VALID_ERRORS_DIR_POSTFIX = ['', 'errors', 'shared']
|
7
8
|
|
8
9
|
ERRORS = [
|
9
10
|
:internal_server_error,
|
@@ -28,18 +29,29 @@ class CustomErrorsHandlerController < ActionController::Base
|
|
28
29
|
# Returns the file from which Rails should render error template
|
29
30
|
def error_layout(path, e)
|
30
31
|
e = translate_error(e)
|
31
|
-
path= path.split('/')
|
32
|
+
path = path.split('/')
|
32
33
|
path.size.downto(0) do |i|
|
33
|
-
|
34
|
-
template_path = File.join(
|
34
|
+
VALID_ERRORS_DIR_POSTFIX.each do |lay_path|
|
35
|
+
template_path = File.join(path[0,i], lay_path, e)
|
35
36
|
return template_path if template?(template_path)
|
36
|
-
template_path = File.join(
|
37
|
+
template_path = File.join(path[0,i], 'errors',e)
|
37
38
|
return template_path if template?(template_path)
|
38
|
-
|
39
|
+
end
|
39
40
|
template_path = File.join(path[0,i], e)
|
40
41
|
return template_path if template?(template_path)
|
41
42
|
end
|
42
|
-
|
43
|
+
|
44
|
+
VALID_ERRORS_DIR_PREFIX.each do |lay_path|
|
45
|
+
path.size.downto(0) do |i|
|
46
|
+
template_path = File.join(lay_path, path[0,i], e)
|
47
|
+
return template_path if template?(template_path)
|
48
|
+
template_path = File.join(lay_path, path[0,i], 'errors',e)
|
49
|
+
return template_path if template?(template_path)
|
50
|
+
end
|
51
|
+
template_path = File.join(path[0,i], e)
|
52
|
+
return template_path if template?(template_path)
|
53
|
+
end
|
54
|
+
template_from_public(e)
|
43
55
|
end
|
44
56
|
|
45
57
|
def template?(template)
|
@@ -61,4 +73,7 @@ class CustomErrorsHandlerController < ActionController::Base
|
|
61
73
|
end
|
62
74
|
end
|
63
75
|
|
64
|
-
|
76
|
+
def template_from_public(e)
|
77
|
+
File.join("#{Rails.root}", 'public', "#{e}.html")
|
78
|
+
end
|
79
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_errors_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-07 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &15968920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15968920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &15968340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15968340
|
36
36
|
description: Custom Errors Handler is intended as an easy alternative to manage showing/rendering
|
37
37
|
exceptions templates (404, 500) in Rails3
|
38
38
|
email: maciej@mensfeld.pl
|