exceptionally_beautiful 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +39 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +199 -0
- data/Guardfile +12 -0
- data/LICENSE +21 -0
- data/README.md +63 -0
- data/Rakefile +33 -0
- data/app/controllers/concerns/exceptionally_beautiful/error_handler.rb +16 -0
- data/app/controllers/exceptionally_beautiful/application_controller.rb +4 -0
- data/app/controllers/exceptionally_beautiful/errors_controller.rb +7 -0
- data/app/models/exceptionally_beautiful/error.rb +41 -0
- data/app/views/exceptionally_beautiful/errors/show.html.erb +2 -0
- data/app/views/layouts/exceptionally_beautiful/errors.html.erb +9 -0
- data/bin/rails +12 -0
- data/config/locales/en.yml +20 -0
- data/config/routes.rb +2 -0
- data/exceptionally_beautiful.gemspec +32 -0
- data/lib/exceptionally_beautiful/engine.rb +11 -0
- data/lib/exceptionally_beautiful/routes.rb +8 -0
- data/lib/exceptionally_beautiful/version.rb +3 -0
- data/lib/exceptionally_beautiful.rb +28 -0
- data/lib/generators/exceptionally_beautiful/install_generator.rb +22 -0
- data/lib/generators/templates/exceptionally_beautiful.rb +10 -0
- data/spec/features/exceptionally_beautiful_engine_spec.rb +22 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/test_app/README.rdoc +28 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/controllers/application_controller.rb +5 -0
- data/spec/test_app/app/controllers/tests_controller.rb +9 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/views/layouts/application.html.erb +13 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +4 -0
- data/spec/test_app/bin/rake +4 -0
- data/spec/test_app/bin/setup +29 -0
- data/spec/test_app/config/application.rb +33 -0
- data/spec/test_app/config/boot.rb +3 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +24 -0
- data/spec/test_app/config/environments/production.rb +63 -0
- data/spec/test_app/config/environments/test.rb +42 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/session_store.rb +3 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/test_app/config/locales/en.yml +23 -0
- data/spec/test_app/config/routes.rb +4 -0
- data/spec/test_app/config/secrets.yml +22 -0
- data/spec/test_app/config.ru +4 -0
- data/spec/test_app/db/seeds.rb +7 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/favicon.ico +0 -0
- data/spec/test_app/public/robots.txt +5 -0
- metadata +312 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e301a2ab30d46bc251af2279514d3ae5e049588d
|
|
4
|
+
data.tar.gz: 2cff911c52eb068ea3bfb348286be44e22c69692
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6325b1a75e0d48b99a586b3a50c4bdb5310f52da9185f5e49983067e25da2490d1de5a697bbf86e54ab91f40c8bde9eda3e0ab39b8284849d9e8375c6dafb3a6
|
|
7
|
+
data.tar.gz: 82b14af374b6089a24d685f5f4ef42307c3f9e390a5e2937faf244ac314162c0ba6b947a092e37db52f04a1caeac61bded42ce3735afc6d839a41cc16d183d32
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
RunRailsCops: false
|
|
3
|
+
Excludes:
|
|
4
|
+
- spec/test_app/**
|
|
5
|
+
- bin/**
|
|
6
|
+
|
|
7
|
+
LineLength:
|
|
8
|
+
Max: 120
|
|
9
|
+
|
|
10
|
+
ClassLength:
|
|
11
|
+
CountComments: false # count full line comments?
|
|
12
|
+
Max: 175
|
|
13
|
+
|
|
14
|
+
MethodLength:
|
|
15
|
+
CountComments: false # count full line comments?
|
|
16
|
+
Max: 10
|
|
17
|
+
|
|
18
|
+
HashSyntax:
|
|
19
|
+
EnforcedStyle: hash_rockets
|
|
20
|
+
|
|
21
|
+
Documentation:
|
|
22
|
+
Enabled: false
|
|
23
|
+
|
|
24
|
+
DefaultScope:
|
|
25
|
+
Enabled: false
|
|
26
|
+
|
|
27
|
+
CollectionMethods:
|
|
28
|
+
PreferredMethods:
|
|
29
|
+
map: 'collect'
|
|
30
|
+
map!: 'collect!'
|
|
31
|
+
reduce: 'inject'
|
|
32
|
+
find: 'detect'
|
|
33
|
+
find_all: 'select'
|
|
34
|
+
|
|
35
|
+
Output:
|
|
36
|
+
Enabled: false
|
|
37
|
+
|
|
38
|
+
HasAndBelongsToMany:
|
|
39
|
+
Enabled: false
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.1.3
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Declare your gem's dependencies in exceptionally_beautiful.gemspec.
|
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
|
5
|
+
# development dependencies will be added by default to the :development group.
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
|
11
|
+
# your gem to rubygems.org.
|
|
12
|
+
|
|
13
|
+
# To use a debugger
|
|
14
|
+
# gem 'byebug', group: [:development, :test]
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
exceptionally_beautiful (0.0.1)
|
|
5
|
+
rails (~> 4.2.0.beta1)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
actionmailer (4.2.0)
|
|
11
|
+
actionpack (= 4.2.0)
|
|
12
|
+
actionview (= 4.2.0)
|
|
13
|
+
activejob (= 4.2.0)
|
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
16
|
+
actionpack (4.2.0)
|
|
17
|
+
actionview (= 4.2.0)
|
|
18
|
+
activesupport (= 4.2.0)
|
|
19
|
+
rack (~> 1.6.0)
|
|
20
|
+
rack-test (~> 0.6.2)
|
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
|
23
|
+
actionview (4.2.0)
|
|
24
|
+
activesupport (= 4.2.0)
|
|
25
|
+
builder (~> 3.1)
|
|
26
|
+
erubis (~> 2.7.0)
|
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
|
29
|
+
activejob (4.2.0)
|
|
30
|
+
activesupport (= 4.2.0)
|
|
31
|
+
globalid (>= 0.3.0)
|
|
32
|
+
activemodel (4.2.0)
|
|
33
|
+
activesupport (= 4.2.0)
|
|
34
|
+
builder (~> 3.1)
|
|
35
|
+
activerecord (4.2.0)
|
|
36
|
+
activemodel (= 4.2.0)
|
|
37
|
+
activesupport (= 4.2.0)
|
|
38
|
+
arel (~> 6.0)
|
|
39
|
+
activesupport (4.2.0)
|
|
40
|
+
i18n (~> 0.7)
|
|
41
|
+
json (~> 1.7, >= 1.7.7)
|
|
42
|
+
minitest (~> 5.1)
|
|
43
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
44
|
+
tzinfo (~> 1.1)
|
|
45
|
+
arel (6.0.0)
|
|
46
|
+
ast (1.1.0)
|
|
47
|
+
builder (3.2.2)
|
|
48
|
+
capybara (2.2.1)
|
|
49
|
+
mime-types (>= 1.16)
|
|
50
|
+
nokogiri (>= 1.3.3)
|
|
51
|
+
rack (>= 1.0.0)
|
|
52
|
+
rack-test (>= 0.5.4)
|
|
53
|
+
xpath (~> 2.0)
|
|
54
|
+
celluloid (0.15.2)
|
|
55
|
+
timers (~> 1.1.0)
|
|
56
|
+
celluloid-io (0.15.0)
|
|
57
|
+
celluloid (>= 0.15.0)
|
|
58
|
+
nio4r (>= 0.5.0)
|
|
59
|
+
codeclimate-test-reporter (0.1.1)
|
|
60
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
|
61
|
+
coderay (1.1.0)
|
|
62
|
+
diff-lcs (1.2.5)
|
|
63
|
+
erubis (2.7.0)
|
|
64
|
+
ffi (1.9.6)
|
|
65
|
+
formatador (0.2.4)
|
|
66
|
+
globalid (0.3.0)
|
|
67
|
+
activesupport (>= 4.1.0)
|
|
68
|
+
guard (2.5.1)
|
|
69
|
+
formatador (>= 0.2.4)
|
|
70
|
+
listen (~> 2.6)
|
|
71
|
+
lumberjack (~> 1.0)
|
|
72
|
+
pry (>= 0.9.12)
|
|
73
|
+
thor (>= 0.18.1)
|
|
74
|
+
guard-rspec (4.2.7)
|
|
75
|
+
guard (~> 2.1)
|
|
76
|
+
rspec (>= 2.14, < 4.0)
|
|
77
|
+
guard-rubocop (1.0.2)
|
|
78
|
+
guard (~> 2.0)
|
|
79
|
+
rubocop (~> 0.10)
|
|
80
|
+
hike (1.2.3)
|
|
81
|
+
i18n (0.7.0)
|
|
82
|
+
json (1.8.2)
|
|
83
|
+
listen (2.7.0)
|
|
84
|
+
celluloid (>= 0.15.2)
|
|
85
|
+
celluloid-io (>= 0.15.0)
|
|
86
|
+
rb-fsevent (>= 0.9.3)
|
|
87
|
+
rb-inotify (>= 0.9)
|
|
88
|
+
loofah (2.0.1)
|
|
89
|
+
nokogiri (>= 1.5.9)
|
|
90
|
+
lumberjack (1.0.4)
|
|
91
|
+
mail (2.6.3)
|
|
92
|
+
mime-types (>= 1.16, < 3)
|
|
93
|
+
method_source (0.8.2)
|
|
94
|
+
mime-types (2.4.3)
|
|
95
|
+
mini_portile (0.6.2)
|
|
96
|
+
minitest (5.5.1)
|
|
97
|
+
multi_json (1.10.1)
|
|
98
|
+
nio4r (1.0.0)
|
|
99
|
+
nokogiri (1.6.5)
|
|
100
|
+
mini_portile (~> 0.6.0)
|
|
101
|
+
parser (2.1.4)
|
|
102
|
+
ast (~> 1.1)
|
|
103
|
+
slop (~> 3.4, >= 3.4.5)
|
|
104
|
+
powerpack (0.0.9)
|
|
105
|
+
pry (0.9.12.6)
|
|
106
|
+
coderay (~> 1.0)
|
|
107
|
+
method_source (~> 0.8)
|
|
108
|
+
slop (~> 3.4)
|
|
109
|
+
rack (1.6.0)
|
|
110
|
+
rack-test (0.6.3)
|
|
111
|
+
rack (>= 1.0)
|
|
112
|
+
rails (4.2.0)
|
|
113
|
+
actionmailer (= 4.2.0)
|
|
114
|
+
actionpack (= 4.2.0)
|
|
115
|
+
actionview (= 4.2.0)
|
|
116
|
+
activejob (= 4.2.0)
|
|
117
|
+
activemodel (= 4.2.0)
|
|
118
|
+
activerecord (= 4.2.0)
|
|
119
|
+
activesupport (= 4.2.0)
|
|
120
|
+
bundler (>= 1.3.0, < 2.0)
|
|
121
|
+
railties (= 4.2.0)
|
|
122
|
+
sprockets-rails
|
|
123
|
+
rails-deprecated_sanitizer (1.0.3)
|
|
124
|
+
activesupport (>= 4.2.0.alpha)
|
|
125
|
+
rails-dom-testing (1.0.5)
|
|
126
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
|
127
|
+
nokogiri (~> 1.6.0)
|
|
128
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
|
129
|
+
rails-html-sanitizer (1.0.1)
|
|
130
|
+
loofah (~> 2.0)
|
|
131
|
+
railties (4.2.0)
|
|
132
|
+
actionpack (= 4.2.0)
|
|
133
|
+
activesupport (= 4.2.0)
|
|
134
|
+
rake (>= 0.8.7)
|
|
135
|
+
thor (>= 0.18.1, < 2.0)
|
|
136
|
+
rainbow (1.1.4)
|
|
137
|
+
rake (10.4.2)
|
|
138
|
+
rb-fsevent (0.9.4)
|
|
139
|
+
rb-inotify (0.9.5)
|
|
140
|
+
ffi (>= 0.5.0)
|
|
141
|
+
rspec (2.14.1)
|
|
142
|
+
rspec-core (~> 2.14.0)
|
|
143
|
+
rspec-expectations (~> 2.14.0)
|
|
144
|
+
rspec-mocks (~> 2.14.0)
|
|
145
|
+
rspec-core (2.14.8)
|
|
146
|
+
rspec-expectations (2.14.5)
|
|
147
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
148
|
+
rspec-mocks (2.14.6)
|
|
149
|
+
rspec-rails (2.14.1)
|
|
150
|
+
actionpack (>= 3.0)
|
|
151
|
+
activemodel (>= 3.0)
|
|
152
|
+
activesupport (>= 3.0)
|
|
153
|
+
railties (>= 3.0)
|
|
154
|
+
rspec-core (~> 2.14.0)
|
|
155
|
+
rspec-expectations (~> 2.14.0)
|
|
156
|
+
rspec-mocks (~> 2.14.0)
|
|
157
|
+
rubocop (0.16.0)
|
|
158
|
+
parser (~> 2.1)
|
|
159
|
+
powerpack (~> 0.0.6)
|
|
160
|
+
rainbow (>= 1.1.4)
|
|
161
|
+
simplecov (0.7.1)
|
|
162
|
+
multi_json (~> 1.0)
|
|
163
|
+
simplecov-html (~> 0.7.1)
|
|
164
|
+
simplecov-html (0.7.1)
|
|
165
|
+
slop (3.4.7)
|
|
166
|
+
sprockets (2.12.3)
|
|
167
|
+
hike (~> 1.2)
|
|
168
|
+
multi_json (~> 1.0)
|
|
169
|
+
rack (~> 1.0)
|
|
170
|
+
tilt (~> 1.1, != 1.3.0)
|
|
171
|
+
sprockets-rails (2.2.2)
|
|
172
|
+
actionpack (>= 3.0)
|
|
173
|
+
activesupport (>= 3.0)
|
|
174
|
+
sprockets (>= 2.8, < 4.0)
|
|
175
|
+
thor (0.19.1)
|
|
176
|
+
thread_safe (0.3.4)
|
|
177
|
+
tilt (1.4.1)
|
|
178
|
+
timers (1.1.0)
|
|
179
|
+
tzinfo (1.2.2)
|
|
180
|
+
thread_safe (~> 0.1)
|
|
181
|
+
xpath (2.0.0)
|
|
182
|
+
nokogiri (~> 1.3)
|
|
183
|
+
|
|
184
|
+
PLATFORMS
|
|
185
|
+
ruby
|
|
186
|
+
|
|
187
|
+
DEPENDENCIES
|
|
188
|
+
bundler (~> 1.3)
|
|
189
|
+
capybara
|
|
190
|
+
codeclimate-test-reporter
|
|
191
|
+
exceptionally_beautiful!
|
|
192
|
+
guard
|
|
193
|
+
guard-rspec
|
|
194
|
+
guard-rubocop
|
|
195
|
+
pry
|
|
196
|
+
rake
|
|
197
|
+
rspec
|
|
198
|
+
rspec-rails
|
|
199
|
+
rubocop
|
data/Guardfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
guard 'rspec', :cmd => 'bundle exec rspec --colour', :all_on_start => false, :all_after_pass => false do
|
|
2
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
3
|
+
watch(%r{^spec/.+_spec\.rb})
|
|
4
|
+
watch(%r{^app/(.+)\.rb}) { |m| "spec/app/#{m[1]}_spec.rb" }
|
|
5
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
guard :rubocop do
|
|
9
|
+
watch(%r{.+\.gemspec$})
|
|
10
|
+
watch(%r{.+\.rb$})
|
|
11
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
|
12
|
+
end
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 PJ Kelly (Crush & Lovely)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Exceptionally Beautiful
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/exceptionally_beautiful)
|
|
4
|
+
[](https://gemnasium.com/crushlovely/exceptionally_beautiful)
|
|
5
|
+
[](https://travis-ci.org/crushlovely/exceptionally_beautiful)
|
|
6
|
+
[](https://codeclimate.com/github/crushlovely/exceptionally_beautiful)
|
|
7
|
+
[](https://codeclimate.com/github/crushlovely/exceptionally_beautiful)
|
|
8
|
+
|
|
9
|
+
A Rails engine for handling error pages.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Getting up-and-running is simple. Just use the built-in generator:
|
|
14
|
+
|
|
15
|
+
``` bash
|
|
16
|
+
bundle exec rails g exceptionally_beautiful:install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The generator will:
|
|
20
|
+
|
|
21
|
+
* Add the route helper to `config/routes.rb`
|
|
22
|
+
* Add an initializer that you can customize in `config/initializers/exceptionally_beautiful.rb`
|
|
23
|
+
* Copy over the translation data to `config/locales/exceptionally_beautiful.en.yml`
|
|
24
|
+
|
|
25
|
+
## What You Get
|
|
26
|
+
|
|
27
|
+
Exceptionally Beautiful will handle any three-digit status code you throw at it. It comes with translation data for the following common errors:
|
|
28
|
+
|
|
29
|
+
| Error | Code |
|
|
30
|
+
|:---------------------:|------|
|
|
31
|
+
| Forbidden | 403 |
|
|
32
|
+
| Not Found | 404 |
|
|
33
|
+
| Unprocessable Entity | 422 |
|
|
34
|
+
| Internal Server Error | 500 |
|
|
35
|
+
| Bad Gateway | 502 |
|
|
36
|
+
|
|
37
|
+
Any status code that is either unrecognized or missing translation data will fall back to default messaging.
|
|
38
|
+
|
|
39
|
+
## Customizing
|
|
40
|
+
|
|
41
|
+
If the default controller, action, and/or layout don't suit your fancy, you can override any of them:
|
|
42
|
+
|
|
43
|
+
``` ruby
|
|
44
|
+
ExceptionallyBeautiful.setup do |config|
|
|
45
|
+
config.layout = 'errors'
|
|
46
|
+
config.controller = 'exceptionally_beautiful/errors'
|
|
47
|
+
config.action = 'show'
|
|
48
|
+
end
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage With `rescue_from`
|
|
52
|
+
|
|
53
|
+
If you're using Rails' `rescue_from` functionality, you can still use Exceptionally Beautiful:
|
|
54
|
+
|
|
55
|
+
``` ruby
|
|
56
|
+
class ApplicationController < ActionController::Base
|
|
57
|
+
include ExceptionallyBeautiful::ErrorHandler
|
|
58
|
+
|
|
59
|
+
rescue_from Mongoid::Errors::DocumentNotFound do |exception|
|
|
60
|
+
error_handler(404)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
```
|
data/Rakefile
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'ExceptionallyBeautiful'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
load 'rails/tasks/statistics.rake'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Bundler::GemHelper.install_tasks
|
|
24
|
+
|
|
25
|
+
require 'rspec/core/rake_task'
|
|
26
|
+
|
|
27
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
29
|
+
spec.rspec_opts = ['--backtrace']
|
|
30
|
+
# spec.ruby_opts = ['-w']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
task :default => :spec
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module ExceptionallyBeautiful
|
|
2
|
+
module ErrorHandler
|
|
3
|
+
def error_handler(status_code)
|
|
4
|
+
@error = ExceptionallyBeautiful::Error.new(status_code)
|
|
5
|
+
|
|
6
|
+
respond_to do |format|
|
|
7
|
+
format.html do
|
|
8
|
+
render :template => "#{ExceptionallyBeautiful.controller}/#{ExceptionallyBeautiful.action}",
|
|
9
|
+
:status => @error.status_code,
|
|
10
|
+
:layout => ExceptionallyBeautiful.layout
|
|
11
|
+
end
|
|
12
|
+
format.json { render :json => { :status => @error.status_code, :error => @error.message } }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module ExceptionallyBeautiful
|
|
2
|
+
class Error
|
|
3
|
+
attr_reader :status_code, :status
|
|
4
|
+
|
|
5
|
+
def initialize(status_code)
|
|
6
|
+
@status_code = status_code.to_i
|
|
7
|
+
determine_status
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def title
|
|
11
|
+
@title ||= pretty_error_translation(:title)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def message
|
|
15
|
+
@message ||= pretty_error_translation(:message)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def determine_status
|
|
21
|
+
match = Rack::Utils::SYMBOL_TO_STATUS_CODE.detect { |k, v| v == status_code }
|
|
22
|
+
if match
|
|
23
|
+
@status = match.first
|
|
24
|
+
else
|
|
25
|
+
log('The status code passed in is not recognized by Rack.')
|
|
26
|
+
@status = 'default'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def pretty_error_translation(key)
|
|
31
|
+
I18n.t(key, :scope => ExceptionallyBeautiful.translation_scope(status), :raise => true)
|
|
32
|
+
rescue I18n::MissingTranslationData
|
|
33
|
+
log("Translation missing: #{ExceptionallyBeautiful.translation_scope(status)}.#{key}. Falling back to defaults.")
|
|
34
|
+
I18n.t(key, :scope => ExceptionallyBeautiful.translation_scope('default'))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def log(message)
|
|
38
|
+
ExceptionallyBeautiful.log(message)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/bin/rails
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/exceptionally_beautiful/engine', __FILE__)
|
|
6
|
+
|
|
7
|
+
# Set up gems listed in the Gemfile.
|
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
10
|
+
|
|
11
|
+
require 'rails/all'
|
|
12
|
+
require 'rails/engine/commands'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
en:
|
|
2
|
+
exceptionally_beautiful:
|
|
3
|
+
default:
|
|
4
|
+
title: "There's been an error"
|
|
5
|
+
message: "Something has gone wrong. Please try again shortly."
|
|
6
|
+
forbidden:
|
|
7
|
+
title: "Sorry, but you don't have access."
|
|
8
|
+
message: "Please try a different request."
|
|
9
|
+
not_found:
|
|
10
|
+
title: "The page you requested could not be found."
|
|
11
|
+
message: "It may have moved."
|
|
12
|
+
unprocessable_entity:
|
|
13
|
+
title: "The change you requested was rejected."
|
|
14
|
+
message: "Please try a different request."
|
|
15
|
+
internal_server_error:
|
|
16
|
+
title: "A fatal error has occurred."
|
|
17
|
+
message: "Please try a different request."
|
|
18
|
+
bad_gateway:
|
|
19
|
+
title: "The site is currently unavailable."
|
|
20
|
+
message: "Please try again in a few moments!"
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
2
|
+
|
|
3
|
+
# Maintain your gem's version:
|
|
4
|
+
require "exceptionally_beautiful/version"
|
|
5
|
+
|
|
6
|
+
# Describe your gem and declare its dependencies:
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "exceptionally_beautiful"
|
|
9
|
+
spec.version = ExceptionallyBeautiful::VERSION
|
|
10
|
+
spec.authors = ["PJ Kelly"]
|
|
11
|
+
spec.email = ["pj@crushlovely.com"]
|
|
12
|
+
spec.homepage = "https://github.com/crushlovely/exceptionally_beautiful"
|
|
13
|
+
spec.summary = "A Rails engine for handling error pages."
|
|
14
|
+
spec.description = "A Rails engine for handling error pages."
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files`.split("\n")
|
|
18
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
|
|
20
|
+
spec.add_dependency "rails", "~> 4.2.0.beta1"
|
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
22
|
+
spec.add_development_dependency('pry')
|
|
23
|
+
spec.add_development_dependency('rake')
|
|
24
|
+
spec.add_development_dependency('rspec')
|
|
25
|
+
spec.add_development_dependency('rspec-rails')
|
|
26
|
+
spec.add_development_dependency('capybara')
|
|
27
|
+
spec.add_development_dependency('rubocop')
|
|
28
|
+
spec.add_development_dependency('guard')
|
|
29
|
+
spec.add_development_dependency('guard-rspec')
|
|
30
|
+
spec.add_development_dependency('guard-rubocop')
|
|
31
|
+
spec.add_development_dependency('codeclimate-test-reporter')
|
|
32
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module ExceptionallyBeautiful
|
|
2
|
+
class Engine < ::Rails::Engine
|
|
3
|
+
isolate_namespace ExceptionallyBeautiful
|
|
4
|
+
|
|
5
|
+
config.autoload_paths += Dir["#{config.root}/app/**/"]
|
|
6
|
+
|
|
7
|
+
initializer 'exceptionally_beautiful.update_exceptions_app' do |app|
|
|
8
|
+
app.config.exceptions_app = app.routes
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'exceptionally_beautiful/engine'
|
|
2
|
+
require 'exceptionally_beautiful/routes'
|
|
3
|
+
|
|
4
|
+
module ExceptionallyBeautiful
|
|
5
|
+
mattr_accessor :controller
|
|
6
|
+
self.controller = 'exceptionally_beautiful/errors'
|
|
7
|
+
|
|
8
|
+
mattr_accessor :action
|
|
9
|
+
self.action = 'show'
|
|
10
|
+
|
|
11
|
+
mattr_accessor :layout
|
|
12
|
+
self.layout = 'exceptionally_beautiful/errors'
|
|
13
|
+
|
|
14
|
+
mattr_accessor :translation_namespace
|
|
15
|
+
self.translation_namespace = 'exceptionally_beautiful'
|
|
16
|
+
|
|
17
|
+
def self.setup(&block)
|
|
18
|
+
yield self
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.translation_scope(error_code)
|
|
22
|
+
[translation_namespace, error_code].join('.')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.log(message)
|
|
26
|
+
Rails.logger.warn("[Exceptionally Beautiful] #{message}")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rails/generators/base'
|
|
2
|
+
require 'securerandom'
|
|
3
|
+
|
|
4
|
+
module ExceptionallyBeautiful
|
|
5
|
+
module Generators
|
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
|
7
|
+
source_root File.expand_path("../../templates", __FILE__)
|
|
8
|
+
|
|
9
|
+
def copy_initializer
|
|
10
|
+
template "exceptionally_beautiful.rb", "config/initializers/exceptionally_beautiful.rb"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def copy_locale
|
|
14
|
+
copy_file "../../../config/locales/en.yml", "config/locales/exceptionally_beautiful.en.yml"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def add_exceptionally_beautiful_route
|
|
18
|
+
route "exceptionally_beautiful_routes"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
ExceptionallyBeautiful.setup do |config|
|
|
2
|
+
# The controller to use when rendering errors
|
|
3
|
+
# config.controller = 'exceptionally_beautiful/errors'
|
|
4
|
+
|
|
5
|
+
# The action to use when rendering errors
|
|
6
|
+
# config.action = 'show'
|
|
7
|
+
|
|
8
|
+
# The layout to use when rendering errors
|
|
9
|
+
# config.layout = 'exceptionally_beautiful/errors'
|
|
10
|
+
end
|