dynamic_error_pages 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45a97320da48fe28a0802c9d68327d321009ccb5
4
- data.tar.gz: 4d25552cdd814ebb289413f9f5c4adb553c4417d
3
+ metadata.gz: 604898ea38f146522bbe987729e9834a93fcf1b7
4
+ data.tar.gz: 41745a7388e9e2f5b822279eb432a562f131089d
5
5
  SHA512:
6
- metadata.gz: 024aeadca90cf9e1c34c661645c1f47ef569e9977b3fe98b83e464458beaad6d0801c6d6cca9b6c3ff6422ab285306e73f2bb43762aa78e554d4208980088e09
7
- data.tar.gz: d4e95d95cd8a6473fae1df2a48b923e1dca04fc8cd03412e464c81b1d667a9499b19faa7eb0930e0b9f5d9e402ee70b7fed84ed8bc84807c7375dbb6798371bc
6
+ metadata.gz: aeb04c6f54ae53372ad23fa8f05614beaf96ea271759584e94f644df81c1027f5627e81e11e7f675e6f50e9fa0160e9332fa82194d594de768ff7ded00697915
7
+ data.tar.gz: ecf60f6b21bed4468f32e02d1280f03059ae7fa1fe90d49246e3dd6f8718c0301bf6d0702eaef06ded9e7140d139cd3fe68791d21f97d532bba28ae7ee22eef0
data/README.md CHANGED
@@ -11,6 +11,13 @@ Engine that helps you to generate dynamic error pages with Rails
11
11
 
12
12
  ```rails >= 3.2```
13
13
 
14
+ ## What and why
15
+
16
+ Normally Rails places some static error pages for special error codes (404, 422 and 500) inside the *public* directory.
17
+ These files are rendered if an error occures. But these templates are rendered without a layout.
18
+ This causes a bad integration into your custom layout.
19
+ The ``` dynamic_error_pages ``` gem let you create your own templates which are rendered inside your application layout.
20
+
14
21
  ## Installation
15
22
 
16
23
  Add this line to your application's Gemfile:
@@ -21,18 +28,58 @@ And then execute:
21
28
 
22
29
  $ bundle
23
30
 
24
- Or install it yourself as:
25
-
26
- $ gem install dynamic_error_pages
27
-
28
31
  ## Usage
29
32
 
33
+ ### Include your templates
34
+
30
35
  Just place your custom error templates inside the ``` app/views/dynamic_error_pages/errors ``` folder. The files need to
31
36
  be named like the returned status code. The ``` 404.html.erb ``` would be used for status code 404 like ```ActiveRecord::RecordNotFound``` would raise for example.
32
37
 
33
38
  If an error is raised and no template for the status code can be found, the engine will fallback to the ```404.html.erb```-template.
34
39
 
35
- That's all!
40
+ ### Include the routing
41
+
42
+ Activate the routes for dynamic error handling in your ```routes.rb```.
43
+
44
+ ```
45
+ YourApp::Application.routes.draw do
46
+ # ....
47
+
48
+ dynamic_error_pages
49
+
50
+ end
51
+ ```
52
+
53
+ ### Custom error handling
54
+
55
+ You may want to handle the incoming errors in a different way the gem handles this. Just create a subclass of
56
+ For example, create a file named ``` errors_controller.rb ``` in ``` app/controllers ```.
57
+
58
+
59
+ class ErrorsController < DynamicErrorPages::ErrorsController
60
+ skip_before_filter :my_fancy_stuff # change your filters...
61
+
62
+ def show
63
+ # do whatever you want...
64
+ super
65
+ end
66
+ end
67
+
68
+ And adjust the routes file to support your custom ```errors_controller```
69
+
70
+ ```
71
+ DeviseDynamicErrorPages::Application.routes.draw do
72
+ # ....
73
+
74
+ dynamic_error_pages :controller => "errors"
75
+
76
+ end
77
+ ```
78
+
79
+ ## Limitations
80
+
81
+ At the moment, the gem will allways force :html format in the response.
82
+ In future versions, this behaviour will be extended.
36
83
 
37
84
  ## TODO
38
85
 
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "appraisal", "~> 0.5.2"
28
28
  spec.add_development_dependency "capybara"
29
29
 
30
- spec.add_dependency "rails", ">= 3.2.0", "<= 4.1"
30
+ spec.add_dependency "rails", ">= 3.2.0"
31
31
  end
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /home/marcus/Work/repos/github/dynamic_error_pages
3
3
  specs:
4
- dynamic_error_pages (0.0.2)
5
- rails (>= 3.2.0, <= 4.1)
4
+ dynamic_error_pages (0.0.3)
5
+ rails (>= 3.2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -58,7 +58,7 @@ GEM
58
58
  method_source (0.8.2)
59
59
  mime-types (1.25)
60
60
  mini_portile (0.5.1)
61
- multi_json (1.8.0)
61
+ multi_json (1.8.1)
62
62
  nokogiri (1.6.0)
63
63
  mini_portile (~> 0.5.0)
64
64
  polyglot (0.3.3)
@@ -116,7 +116,7 @@ GEM
116
116
  treetop (1.4.15)
117
117
  polyglot
118
118
  polyglot (>= 0.3.1)
119
- tzinfo (0.3.37)
119
+ tzinfo (0.3.38)
120
120
  xpath (2.0.0)
121
121
  nokogiri (~> 1.3)
122
122
 
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /home/marcus/Work/repos/github/dynamic_error_pages
3
3
  specs:
4
- dynamic_error_pages (0.0.2)
5
- rails (>= 3.2.0, <= 4.1)
4
+ dynamic_error_pages (0.0.3)
5
+ rails (>= 3.2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -55,7 +55,7 @@ GEM
55
55
  mime-types (1.25)
56
56
  mini_portile (0.5.1)
57
57
  minitest (4.7.5)
58
- multi_json (1.8.0)
58
+ multi_json (1.8.1)
59
59
  nokogiri (1.6.0)
60
60
  mini_portile (~> 0.5.0)
61
61
  polyglot (0.3.3)
@@ -111,7 +111,7 @@ GEM
111
111
  treetop (1.4.15)
112
112
  polyglot
113
113
  polyglot (>= 0.3.1)
114
- tzinfo (0.3.37)
114
+ tzinfo (0.3.38)
115
115
  xpath (2.0.0)
116
116
  nokogiri (~> 1.3)
117
117
 
@@ -1,2 +1,3 @@
1
1
  require "dynamic_error_pages/version"
2
2
  require "dynamic_error_pages/engine"
3
+ require "dynamic_error_pages/routes"
@@ -0,0 +1,12 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def dynamic_error_pages(opts={})
4
+ Rails.application.routes.draw do
5
+ # rails 4 need the :via option
6
+ via = Rails::VERSION::MAJOR > 3 ? {:via => :all} : {}
7
+ controller = opts[:controller] || "dynamic_error_pages/errors"
8
+ match '/:status', {:to => "#{controller}#show", :constraints => { :status => /\d{3}/ }}.merge(via)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module DynamicErrorPages
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -6,4 +6,8 @@ class TestsController < ApplicationController
6
6
  def show
7
7
  raise ActionController::InvalidAuthenticityToken
8
8
  end
9
- end
9
+
10
+ def custom_exception
11
+ raise CustomException.new
12
+ end
13
+ end
@@ -1,3 +1,6 @@
1
1
  Dummy::Application.routes.draw do
2
2
  resources :tests
3
+ get :custom_exception, :to => "tests#custom_exception"
4
+
5
+ dynamic_error_pages
3
6
  end
@@ -0,0 +1,2 @@
1
+ class CustomException < StandardError
2
+ end
@@ -6,4 +6,9 @@ class TestsController < ApplicationController
6
6
  def show
7
7
  raise ActionController::InvalidAuthenticityToken
8
8
  end
9
- end
9
+
10
+ def custom_exception
11
+ raise CustomException.new
12
+ end
13
+
14
+ end
@@ -1,3 +1,6 @@
1
1
  Dummy::Application.routes.draw do
2
2
  resources :tests
3
+ get :custom_exception, :to => "tests#custom_exception"
4
+
5
+ dynamic_error_pages
3
6
  end
@@ -0,0 +1,2 @@
1
+ class CustomException < StandardError
2
+ end
@@ -17,4 +17,9 @@ feature "dynamic exception pages should be delivered with html format" do
17
17
  page.should have_content "my 404" # 404 because 422 is not present
18
18
  end
19
19
 
20
- end
20
+ scenario "custom exception" do
21
+ visit custom_exception_url
22
+ page.should have_content "my 500"
23
+ end
24
+
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_error_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Geißler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-02 00:00:00.000000000 Z
11
+ date: 2013-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,9 +129,6 @@ dependencies:
129
129
  - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: 3.2.0
132
- - - <=
133
- - !ruby/object:Gem::Version
134
- version: '4.1'
135
132
  type: :runtime
136
133
  prerelease: false
137
134
  version_requirements: !ruby/object:Gem::Requirement
@@ -139,9 +136,6 @@ dependencies:
139
136
  - - '>='
140
137
  - !ruby/object:Gem::Version
141
138
  version: 3.2.0
142
- - - <=
143
- - !ruby/object:Gem::Version
144
- version: '4.1'
145
139
  description: Engine that helps you to generate dynamic error pages with Rails
146
140
  email:
147
141
  - marcus3006@gmail.com
@@ -163,7 +157,6 @@ files:
163
157
  - app/controllers/dynamic_error_pages/errors_controller.rb
164
158
  - app/views/.gitkeep
165
159
  - app/views/dynamic_error_pages/errors/404.html.erb
166
- - config/routes.rb
167
160
  - dynamic_error_pages.gemspec
168
161
  - gemfiles/3.2.gemfile
169
162
  - gemfiles/3.2.gemfile.lock
@@ -171,6 +164,7 @@ files:
171
164
  - gemfiles/4.0.gemfile.lock
172
165
  - lib/dynamic_error_pages.rb
173
166
  - lib/dynamic_error_pages/engine.rb
167
+ - lib/dynamic_error_pages/routes.rb
174
168
  - lib/dynamic_error_pages/version.rb
175
169
  - lib/tasks/dynamic_error_pages_tasks.rake
176
170
  - script/rails
@@ -204,6 +198,7 @@ files:
204
198
  - spec/dummy3.2/config/routes.rb
205
199
  - spec/dummy3.2/db/.gitkeep
206
200
  - spec/dummy3.2/lib/assets/.gitkeep
201
+ - spec/dummy3.2/lib/custom_exception.rb
207
202
  - spec/dummy3.2/log/.gitkeep
208
203
  - spec/dummy3.2/public/favicon.ico
209
204
  - spec/dummy3.2/script/rails
@@ -244,6 +239,7 @@ files:
244
239
  - spec/dummy4.0/config/routes.rb
245
240
  - spec/dummy4.0/db/.gitkeep
246
241
  - spec/dummy4.0/lib/assets/.keep
242
+ - spec/dummy4.0/lib/custom_exception.rb
247
243
  - spec/dummy4.0/log/.keep
248
244
  - spec/dummy4.0/public/favicon.ico
249
245
  - spec/features/exception_spec.rb
@@ -268,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
264
  version: '0'
269
265
  requirements: []
270
266
  rubyforge_project:
271
- rubygems_version: 2.0.3
267
+ rubygems_version: 2.1.8
272
268
  signing_key:
273
269
  specification_version: 4
274
270
  summary: Engine that helps you to generate dynamic error pages with Rails
@@ -303,6 +299,7 @@ test_files:
303
299
  - spec/dummy3.2/config/routes.rb
304
300
  - spec/dummy3.2/db/.gitkeep
305
301
  - spec/dummy3.2/lib/assets/.gitkeep
302
+ - spec/dummy3.2/lib/custom_exception.rb
306
303
  - spec/dummy3.2/log/.gitkeep
307
304
  - spec/dummy3.2/public/favicon.ico
308
305
  - spec/dummy3.2/script/rails
@@ -343,6 +340,7 @@ test_files:
343
340
  - spec/dummy4.0/config/routes.rb
344
341
  - spec/dummy4.0/db/.gitkeep
345
342
  - spec/dummy4.0/lib/assets/.keep
343
+ - spec/dummy4.0/lib/custom_exception.rb
346
344
  - spec/dummy4.0/log/.keep
347
345
  - spec/dummy4.0/public/favicon.ico
348
346
  - spec/features/exception_spec.rb
@@ -1,10 +0,0 @@
1
- Rails.application.routes.draw do
2
-
3
- # rails 4 need the :via option
4
- via = Rails::VERSION::MAJOR > 3 ? {:via => :all} : {}
5
-
6
- # if a subclassed errorscontroller exist, route to it
7
- controller = defined?(DynamicErrorPages::PatchedErrorsController) ? 'patched_errors' : 'errors'
8
-
9
- match '/:status', {:to => "dynamic_error_pages/#{controller}#show", :constraints => { :status => /\d{3}/ }}.merge(via)
10
- end