custom_errors_handler 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ = Version 0.2.5
2
+ * Searching with prefix and postfix paths
1
3
  = Version 0.2.4
2
4
  * Added support for haml
3
5
  * Added searching in 'shared' by default
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.4') do |p|
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"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{custom_errors_handler}
5
- s.version = "0.2.4"
5
+ s.version = "0.2.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{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
- VALID_ERRORS_SUBDIRS = ['layouts', 'shared']
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
- VALID_ERRORS_SUBDIRS.each { |lay_path|
34
- template_path = File.join(lay_path, (path[0,i]).join('/'), e)
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(lay_path, (path[0,i]).join('/'), 'errors',e)
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
- e
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
- end
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
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: &25664000 !ruby/object:Gem::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: *25664000
24
+ version_requirements: *15968920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &25663400 !ruby/object:Gem::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: *25663400
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