gaffe 1.0.1 → 1.0.2
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 +4 -4
- data/.rubocop.yml +42 -0
- data/.scss-lint.yml +12 -0
- data/.travis.yml +8 -0
- data/README.md +31 -11
- data/app/assets/stylesheets/errors.css +36 -15
- data/app/views/layouts/error.html.erb +8 -0
- data/gaffe.gemspec +4 -0
- data/lib/gaffe.rb +1 -1
- data/lib/gaffe/errors.rb +3 -5
- data/lib/gaffe/version.rb +1 -1
- data/spec/gaffe/errors_spec.rb +2 -2
- data/spec/gaffe/gaffe_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +46 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfa9dc27f05fc2fb90bdb304ae0461451cadd7d4
|
4
|
+
data.tar.gz: 7bd1fb55e1684cacd0a7a488f8ae2b75c8a3b5e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64397092c293a471ccd9022a0fecf91c4b827bbe771d1337f47f34647122fd614953ba29c3f4a744b69e1631fe00ff610b59d04666e9e68dad10c5fe0f1eacb6
|
7
|
+
data.tar.gz: 145f786bf8f153cba5cf7cfd79e773e338f65fd2dc0330beac2ccd4f4ce035c02119d2dd01a62e1af1dd6d98b6760e943e7a0f146cf24ceff9965c0372292bbf
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- Gemfile
|
4
|
+
- Rakefile
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Encoding:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
LineLength:
|
13
|
+
Max: 200
|
14
|
+
|
15
|
+
AccessModifierIndentation:
|
16
|
+
EnforcedStyle: outdent
|
17
|
+
|
18
|
+
IfUnlessModifier:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
CaseIndentation:
|
22
|
+
IndentWhenRelativeTo: case
|
23
|
+
IndentOneStep: true
|
24
|
+
|
25
|
+
MethodLength:
|
26
|
+
CountComments: false
|
27
|
+
Max: 20
|
28
|
+
|
29
|
+
SignalException:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
ColonMethodCall:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
AsciiComments:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
Lambda:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
RegexpLiteral:
|
42
|
+
Enabled: false
|
data/.scss-lint.yml
ADDED
data/.travis.yml
CHANGED
@@ -9,3 +9,11 @@ gemfile:
|
|
9
9
|
- gemfiles/Gemfile.rails-3.2.x
|
10
10
|
|
11
11
|
script: "echo 'DO IT' && bundle exec rake spec"
|
12
|
+
|
13
|
+
notifications:
|
14
|
+
hipchat:
|
15
|
+
rooms:
|
16
|
+
secure: HwIKOZp8SIVCnPseNTJqZgrUBr7/7z5RGczqX7lGWOXK/S6Zwm/YyglC5ueN+HW2Tsc9nQkVLmLb7fH4kctdeanKea3TTfYS1+GmUOZPhFie4nFnywIgz7os//LfNONIF42Ix94HsmuhsQ6yVPMOU+mYnN9L/ZrWML5NH03mIOw=
|
17
|
+
template:
|
18
|
+
- '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} (<a href="%{build_url}">Build</a>/<a href="%{compare_url}">Changes</a>)'
|
19
|
+
format: 'html'
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
It comes with default error pages but makes it very easy to override them (which you should do). The default error pages look like this:
|
18
18
|
|
19
|
-

|
20
20
|
|
21
21
|
## Installation
|
22
22
|
|
@@ -75,25 +75,39 @@ You might also want to get rid of filters and other stuff to make sure that erro
|
|
75
75
|
```ruby
|
76
76
|
class ErrorsController < ApplicationController
|
77
77
|
include Gaffe::Errors
|
78
|
-
skip_before_filter :ensure_current_user
|
79
78
|
|
79
|
+
# Make sure anonymous users can see the page
|
80
|
+
skip_before_filter :authenticate_user!
|
81
|
+
|
82
|
+
# Override 'error' layout
|
83
|
+
layout 'application'
|
84
|
+
|
85
|
+
# Render the correct template based on the exception “standard” code.
|
86
|
+
# Eg. For a 404 error, the `errors/not_found` template will be rendered.
|
80
87
|
def show
|
81
|
-
#
|
82
|
-
@
|
83
|
-
@status_code # The status code we should return (Eg. `404`)
|
84
|
-
@rescue_response # The "standard" name for the status code (Eg. `:not_found`)
|
88
|
+
# Here, the `@exception` variable contains the original raised error
|
89
|
+
render "errors/#{@rescue_response}", status: @status_code
|
85
90
|
end
|
86
91
|
end
|
87
92
|
```
|
88
93
|
|
89
|
-
For example, you might want your `
|
94
|
+
For example, you might want your `API::ErrorsController` to return a standard JSON response:
|
90
95
|
|
91
96
|
```ruby
|
92
|
-
class
|
97
|
+
class API::ErrorsController < API::ApplicationController
|
93
98
|
include Gaffe::Errors
|
94
|
-
skip_before_filter :ensure_current_user
|
95
99
|
|
100
|
+
# Make sure anonymous users can see the page
|
101
|
+
skip_before_filter :authenticate_user!
|
102
|
+
|
103
|
+
# Disable layout (your `API::ApplicationController` probably does this already)
|
104
|
+
layout false
|
105
|
+
|
106
|
+
# Render a simple JSON response containing the error “standard” code
|
107
|
+
# plus the exception name and backtrace if we’re in development.
|
96
108
|
def show
|
109
|
+
output = { error: @rescue_response }
|
110
|
+
output.merge! exception: @exception.inspect, backtrace: @exception.backtrace.first(10) if Rails.env.development?
|
97
111
|
render json: { error: @rescue_response }, status: @status_code
|
98
112
|
end
|
99
113
|
end
|
@@ -139,6 +153,12 @@ you’ll have to edit the `config/environments/development.rb` file.
|
|
139
153
|
config.consider_all_requests_local = false
|
140
154
|
```
|
141
155
|
|
156
|
+
## Contributors
|
157
|
+
|
158
|
+
* [@remiprev](https://github.com/remiprev)
|
159
|
+
* [@simonprev](https://github.com/simonprev)
|
160
|
+
* [@jmuheim](https://github.com/jmuheim)
|
161
|
+
|
142
162
|
## License
|
143
163
|
|
144
164
|
`Gaffe` is © 2013 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/gaffe/blob/master/LICENSE.md) file.
|
@@ -147,6 +167,6 @@ The mushroom cloud logo is based on [this lovely icon](http://thenounproject.com
|
|
147
167
|
|
148
168
|
## About Mirego
|
149
169
|
|
150
|
-
Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We
|
170
|
+
[Mirego](http://mirego.com) is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of [talented people](http://life.mirego.com) who imagine and build beautiful Web and mobile applications. We come together to share ideas and [change the world](http://mirego.org).
|
151
171
|
|
152
|
-
We also love
|
172
|
+
We also [love open-source software](http://open.mirego.com) and we try to give back to the community as much as we can.
|
@@ -1,12 +1,21 @@
|
|
1
|
-
html {
|
2
|
-
|
1
|
+
html {
|
2
|
+
font-size: 62.5%;
|
3
|
+
}
|
4
|
+
|
5
|
+
* {
|
6
|
+
margin: 0;
|
7
|
+
padding: 0;
|
8
|
+
font-size: 100%;
|
9
|
+
-moz-box-sizing: border-box;
|
10
|
+
box-sizing: border-box;
|
11
|
+
}
|
3
12
|
|
4
13
|
body {
|
14
|
+
padding: 60px;
|
15
|
+
background: #fafafa;
|
5
16
|
font-size: 150%;
|
6
17
|
font-family: Helvetica, Arial, sans-serif;
|
7
|
-
background: #fafafa;
|
8
18
|
font-weight: 300;
|
9
|
-
padding: 60px;
|
10
19
|
line-height: 1.5;
|
11
20
|
}
|
12
21
|
|
@@ -14,10 +23,11 @@ body {
|
|
14
23
|
width: 100%;
|
15
24
|
max-width: 700px;
|
16
25
|
margin: 0 auto;
|
17
|
-
background: #fff;
|
18
26
|
padding: 30px;
|
19
|
-
|
27
|
+
background: #fff;
|
28
|
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
|
20
29
|
border-radius: 3px;
|
30
|
+
border-top: 3px solid #b00f08;
|
21
31
|
}
|
22
32
|
|
23
33
|
hr {
|
@@ -29,34 +39,45 @@ p {
|
|
29
39
|
}
|
30
40
|
|
31
41
|
a {
|
32
|
-
color: #
|
42
|
+
color: #731217;
|
43
|
+
}
|
44
|
+
|
45
|
+
a:hover {
|
46
|
+
color: #b00f08;
|
33
47
|
}
|
34
48
|
|
35
49
|
h1 {
|
36
|
-
font-size: 240%;
|
37
50
|
margin: 0 0 15px;
|
51
|
+
font-size: 240%;
|
38
52
|
font-weight: 300;
|
53
|
+
color: #731217;
|
39
54
|
}
|
40
55
|
|
41
56
|
.content {
|
42
|
-
background: #FFFCE1;
|
43
57
|
padding: 15px;
|
44
58
|
margin: 15px 0;
|
45
|
-
|
59
|
+
background: #eee;
|
60
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
61
|
+
font-weight: bold;
|
62
|
+
color: #666;
|
46
63
|
}
|
47
64
|
|
48
65
|
pre {
|
49
|
-
|
66
|
+
overflow: auto;
|
50
67
|
padding: 15px;
|
68
|
+
background: #fafafa;
|
69
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
51
70
|
line-height: 1.8;
|
52
|
-
color: rgba(0,0,0,0.8);
|
53
|
-
|
54
|
-
|
71
|
+
color: rgba(0, 0, 0, 0.8);
|
72
|
+
}
|
73
|
+
|
74
|
+
pre.exception {
|
75
|
+
background-color: #ffeded;
|
55
76
|
}
|
56
77
|
|
57
78
|
pre em {
|
58
79
|
font-style: normal;
|
59
|
-
color: rgba(0,0,0,0.5);
|
80
|
+
color: rgba(0, 0, 0, 0.5);
|
60
81
|
border-bottom: 1px dotted;
|
61
82
|
cursor: help;
|
62
83
|
}
|
@@ -18,6 +18,14 @@
|
|
18
18
|
<hr>
|
19
19
|
</div>
|
20
20
|
|
21
|
+
<% if Rails.env.development? || Rails.env.test? %>
|
22
|
+
<p>Original exception (only displayed in <strong>development</strong> and <strong>test</strong> environment):</p>
|
23
|
+
|
24
|
+
<pre>
|
25
|
+
<code><%= @exception.inspect %></code>
|
26
|
+
</pre>
|
27
|
+
<% end %>
|
28
|
+
|
21
29
|
<p>You can overwrite this page by creating these files:</p>
|
22
30
|
|
23
31
|
<% handlers = ActionView::Template::Handlers.extensions.map(&:to_s).join(', ') %>
|
data/gaffe.gemspec
CHANGED
@@ -23,5 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
24
24
|
spec.add_development_dependency 'coveralls'
|
25
25
|
|
26
|
+
spec.add_development_dependency 'rubocop'
|
27
|
+
spec.add_development_dependency 'scss-lint'
|
28
|
+
spec.add_development_dependency 'phare'
|
29
|
+
|
26
30
|
spec.add_dependency 'rails', '>= 3.2.0'
|
27
31
|
end
|
data/lib/gaffe.rb
CHANGED
@@ -36,7 +36,7 @@ module Gaffe
|
|
36
36
|
controller = configuration.errors_controller
|
37
37
|
|
38
38
|
if controller.is_a?(Hash)
|
39
|
-
controller = controller.
|
39
|
+
controller = controller.find { |pattern, _| env['REQUEST_URI'] =~ pattern }.try(:last)
|
40
40
|
end
|
41
41
|
|
42
42
|
controller ||= builtin_errors_controller
|
data/lib/gaffe/errors.rb
CHANGED
@@ -9,11 +9,9 @@ module Gaffe
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def show
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
render "errors/internal_server_error", status: 500
|
16
|
-
end
|
12
|
+
render "errors/#{@rescue_response}", status: @status_code
|
13
|
+
rescue ActionView::MissingTemplate
|
14
|
+
render 'errors/internal_server_error', status: 500
|
17
15
|
end
|
18
16
|
|
19
17
|
protected
|
data/lib/gaffe/version.rb
CHANGED
data/spec/gaffe/errors_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Gaffe::Errors do
|
|
12
12
|
context 'with builtin exception' do
|
13
13
|
let(:exception) { ActionController::RoutingError.new(:foo) }
|
14
14
|
its(:status) { should eql 404 }
|
15
|
-
its(:body) { should match
|
15
|
+
its(:body) { should match(/Not Found/) }
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'with custom exception and missing view' do
|
@@ -25,7 +25,7 @@ describe Gaffe::Errors do
|
|
25
25
|
|
26
26
|
let(:exception) { exception_class.new }
|
27
27
|
its(:status) { should eql 500 }
|
28
|
-
its(:body) { should match
|
28
|
+
its(:body) { should match(/Internal Server Error/) }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/spec/gaffe/gaffe_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
2
|
|
3
3
|
require 'coveralls'
|
4
4
|
Coveralls.wear!
|
5
5
|
|
6
6
|
require 'rspec'
|
7
|
-
require
|
7
|
+
require 'action_controller/railtie'
|
8
8
|
require 'gaffe'
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaffe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Prévost
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -67,6 +67,48 @@ dependencies:
|
|
67
67
|
- - '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: scss-lint
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: phare
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
70
112
|
- !ruby/object:Gem::Dependency
|
71
113
|
name: rails
|
72
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +133,8 @@ extra_rdoc_files: []
|
|
91
133
|
files:
|
92
134
|
- .gitignore
|
93
135
|
- .rspec
|
136
|
+
- .rubocop.yml
|
137
|
+
- .scss-lint.yml
|
94
138
|
- .travis.yml
|
95
139
|
- Gemfile
|
96
140
|
- LICENSE.md
|