err_merchant 0.2.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 06cd48be71775b09c9aa0f4e428f4df30d532bdfcf72434853fcf6dbced355ba
4
+ data.tar.gz: 756d2bed2eb493f17edc1c862f5f7c33842a26a88144947a8d88e9a1cc14a162
5
+ SHA512:
6
+ metadata.gz: afcb515aeaca4ba0ccd2cb0edd827fbfcefaebaba4f3a302249910707277cd18ad7a8d58c621a650d62d0f49ba5ffa85979dc0f41695f29c3fb2486ca1f425d0
7
+ data.tar.gz: 7b354a0e0d581fb512589df9d8c207f2bba06e3a3850618624b0ff377e7a6487aed73f89c7d2aaa0fd00d53d11260e091b66da39646163968422fdbfd899aedb
@@ -0,0 +1,30 @@
1
+ name: RSpec
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ include:
15
+ - rails-version: 5.2.0
16
+ - rails-version: 6.0.0
17
+ - rails-version: 6.1.0
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: 2.5
24
+ - run: bundle install
25
+ env:
26
+ RAILS_VERSION: ${{ matrix.rails-version }}
27
+ - run: bundle exec rspec spec
28
+ env:
29
+ RAILS_VERSION: ${{ matrix.rails-version }}
30
+
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ Gemfile.lock
11
+ spec/internal/db/combustion_test.sqlite
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ if ENV["RAILS_VERSION"]
6
+ gem "rails", "~> #{ENV['RAILS_VERSION']}"
7
+ end
@@ -1,8 +1,6 @@
1
1
  = err_merchant
2
2
 
3
- {<img src="https://secure.travis-ci.org/fschwahn/err_merchant.png" />}[http://travis-ci.org/fschwahn/err_merchant]
4
-
5
- This is a very simple Rails Engine for replacing the standard (ugly) Rails exception pages with pages which are rendered in your layout. There are several gems out there that do the same, but this one takes the approach proposed by AccUser[http://accuser.cc/posts/1-rails-3-0-exception-handling]. I just made a gem out of it because I use it in every project. This solution works seamlessly with Airbrake[http://airbrake.io/].
3
+ This is a very simple Rails Engine for replacing the standard (ugly) Rails exception pages with pages which are rendered in your layout.
6
4
 
7
5
  == Installation
8
6
  Add the gem to your Gemfile, run `bundle install` and restart your server:
@@ -16,6 +14,7 @@ Yes, these files are used as a fallback if +err_merchant+ itself raises an excep
16
14
 
17
15
  == Configuration
18
16
  * +ErrMerchant.layout+: Can be used to set the layout for the error pages. By default the application-layout is used.
17
+ * +ErrMerchant.skip_filters+: Can be used to skip certain filters when rendering errors. Most common are filters by authorization gems like `cancan` or `pundit` which ensure that authorization happens. These have to be skipped when rendering error pages. (example: `ErrMerchant.skip_filters[:after] = [:verify_authorized]` for pundit)
19
18
 
20
19
  == I18n
21
20
  You can translate the error messages, by default they are the same as the standard Rails errors:
@@ -34,6 +33,28 @@ You can translate the error messages, by default they are the same as the standa
34
33
  Please note that there are translations missing in development mode if you don't supply translations for your locale. In production however, +config.i18n.fallbacks+ is usually set to +true+, so the error messages for the default locale will be shown if the lookup is not successful.
35
34
 
36
35
  == Changelog
36
+ === 0.7.0 (2021-01-05)
37
+ * Disable CSRF in ErrorsController
38
+ * Drop support for rails < 5.2
39
+
40
+ === 0.6.0 (2019-06-07)
41
+ * Relax version requirement for rails
42
+ * Drop support for rails < 5
43
+
44
+ === 0.5.0 (2018-08-09)
45
+ * ErrorsController inherits from ApplicationController again (so helpers etc. defined there are available). Added ErrMerchant.skip_filters for previously hardcoded behavior.
46
+
47
+ === 0.4.0 (2018-08-09)
48
+ * Relax rails requirements
49
+ * Remove special cases for CanCan / Pundit, instead inherit from ActionController::Base (so we don't get any before_action we don't like)
50
+
51
+ === 0.3.1 (2014-11-08)
52
+ * works with `pundit` now
53
+ * show error messages raw
54
+
55
+ === 0.3.0 (2014-10-24)
56
+ * compatible with rails 4
57
+
37
58
  === 0.2.0 (2012-01-30)
38
59
  * only supports rails 3.2 (code cleanup)
39
60
 
@@ -49,4 +70,4 @@ Please note that there are translations missing in development mode if you don't
49
70
  * Initial release
50
71
 
51
72
  == License
52
- This project rocks and uses MIT-LICENSE.
73
+ This project rocks and uses MIT-LICENSE.
data/Rakefile CHANGED
@@ -1,28 +1,5 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'ErrMerchant'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
22
-
23
- Bundler::GemHelper.install_tasks
24
-
25
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
26
3
  RSpec::Core::RakeTask.new
27
4
 
28
- task :default => :spec
5
+ task :default => :spec
@@ -1,19 +1,22 @@
1
- class ErrMerchant::ErrorsController < ApplicationController
2
- skip_authorization_check if defined?(::CanCan)
3
-
1
+ class ErrMerchant::ErrorsController < ::ApplicationController
2
+ ErrMerchant.skip_filters.each do |filter_type, filters|
3
+ send(:"skip_#{filter_type}_action", *filters) if filters.any?
4
+ end
5
+ skip_forgery_protection(raise: false)
6
+
4
7
  ERRORS = {
5
- :internal_server_error => 500,
6
- :not_found => 404,
7
- :conflict => 409,
8
- :unprocessable_entity => 422,
9
- :method_not_allowed => 405,
10
- :not_implemented => 501
8
+ internal_server_error: 500,
9
+ not_found: 404,
10
+ conflict: 409,
11
+ unprocessable_entity: 422,
12
+ method_not_allowed: 405,
13
+ not_implemented: 501
11
14
  }.freeze
12
15
 
13
16
  ERRORS.each do |e, status_code|
14
17
  define_method e do
15
18
  respond_to do |format|
16
- format.html { render 'template', :locals => {:status_code => status_code}, :layout => ErrMerchant.layout, :status => e }
19
+ format.html { render "template", locals: { status_code: status_code }, layout: ErrMerchant.layout, status: e }
17
20
  format.any { head e }
18
21
  end
19
22
  end
@@ -1,4 +1,4 @@
1
1
  <div class='err_merchant'>
2
- <h2><%= I18n.t(:"err_merchant.#{status_code}.title", :default => :"err_merchant.500.title") %></h2>
3
- <p><%= I18n.t(:"err_merchant.#{status_code}.description", :default => :"err_merchant.500.description") %></p>
4
- </div>
2
+ <h2><%= raw I18n.t(:"err_merchant.#{status_code}.title", :default => :"err_merchant.500.title") %></h2>
3
+ <p><%= raw I18n.t(:"err_merchant.#{status_code}.description", :default => :"err_merchant.500.description") %></p>
4
+ </div>
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize!
7
+ run Combustion::Application
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "err_merchant/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "err_merchant"
8
+ spec.version = ErrMerchant::VERSION
9
+ spec.authors = ["Fabian Schwahn"]
10
+ spec.email = ["fabian.schwahn@gmail.com"]
11
+
12
+ spec.summary = "Rails Engine for rendering error pages"
13
+ spec.homepage = "https://github.com/fschwahn/err_merchant"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency 'rails', '>= 5.2', '< 6.2'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'combustion'
26
+ spec.add_development_dependency 'sqlite3'
27
+ spec.add_development_dependency 'rspec-rails', '~> 3.0'
28
+ spec.add_development_dependency 'capybara', '>= 2.2'
29
+ end
@@ -3,6 +3,9 @@ require 'active_support/core_ext/module/attribute_accessors'
3
3
  module ErrMerchant
4
4
  mattr_accessor :layout
5
5
  @@layout = 'application'
6
+
7
+ mattr_accessor :skip_filters
8
+ @@skip_filters = { before: [], after: [], around: [] }
6
9
  end
7
10
 
8
- require 'err_merchant/engine'
11
+ require 'err_merchant/engine'
@@ -8,6 +8,5 @@ module ErrMerchant
8
8
  rescue
9
9
  ActionDispatch::PublicExceptions.new(Rails.root.join('public')).call(env)
10
10
  end
11
-
12
11
  end
13
- end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module ErrMerchant
2
- VERSION = "0.2.0"
2
+ VERSION = "0.7.0".freeze
3
3
  end
metadata CHANGED
@@ -1,157 +1,148 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: err_merchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fabian Schwahn
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-01-30 00:00:00.000000000 Z
11
+ date: 2021-01-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
- requirement: &2153532640 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '3.2'
19
+ version: '5.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.2'
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *2153532640
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.2'
25
33
  - !ruby/object:Gem::Dependency
26
- name: combustion
27
- requirement: &2153532100 !ruby/object:Gem::Requirement
28
- none: false
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
29
36
  requirements:
30
- - - ~>
37
+ - - ">="
31
38
  - !ruby/object:Gem::Version
32
- version: 0.3.1
39
+ version: '0'
33
40
  type: :development
34
41
  prerelease: false
35
- version_requirements: *2153532100
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
36
47
  - !ruby/object:Gem::Dependency
37
- name: sqlite3
38
- requirement: &2153531700 !ruby/object:Gem::Requirement
39
- none: false
48
+ name: combustion
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  requirements:
41
- - - ! '>='
51
+ - - ">="
42
52
  - !ruby/object:Gem::Version
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *2153531700
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
47
61
  - !ruby/object:Gem::Dependency
48
- name: airbrake
49
- requirement: &2153531120 !ruby/object:Gem::Requirement
50
- none: false
62
+ name: sqlite3
63
+ requirement: !ruby/object:Gem::Requirement
51
64
  requirements:
52
- - - ! '>='
65
+ - - ">="
53
66
  - !ruby/object:Gem::Version
54
67
  version: '0'
55
68
  type: :development
56
69
  prerelease: false
57
- version_requirements: *2153531120
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
58
75
  - !ruby/object:Gem::Dependency
59
76
  name: rspec-rails
60
- requirement: &2153530480 !ruby/object:Gem::Requirement
61
- none: false
77
+ requirement: !ruby/object:Gem::Requirement
62
78
  requirements:
63
- - - ~>
79
+ - - "~>"
64
80
  - !ruby/object:Gem::Version
65
- version: '2.0'
81
+ version: '3.0'
66
82
  type: :development
67
83
  prerelease: false
68
- version_requirements: *2153530480
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
69
89
  - !ruby/object:Gem::Dependency
70
90
  name: capybara
71
- requirement: &2153529800 !ruby/object:Gem::Requirement
72
- none: false
91
+ requirement: !ruby/object:Gem::Requirement
73
92
  requirements:
74
- - - ~>
93
+ - - ">="
75
94
  - !ruby/object:Gem::Version
76
- version: '1.0'
95
+ version: '2.2'
77
96
  type: :development
78
97
  prerelease: false
79
- version_requirements: *2153529800
80
- description: Rails Engine for rendering error pages
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '2.2'
103
+ description:
81
104
  email:
82
105
  - fabian.schwahn@gmail.com
83
106
  executables: []
84
107
  extensions: []
85
108
  extra_rdoc_files: []
86
109
  files:
87
- - lib/err_merchant/engine.rb
88
- - lib/err_merchant/exceptions_app.rb
89
- - lib/err_merchant/version.rb
90
- - lib/err_merchant.rb
110
+ - ".github/workflows/ruby.yml"
111
+ - ".gitignore"
112
+ - Gemfile
113
+ - MIT-LICENSE
114
+ - README.rdoc
115
+ - Rakefile
91
116
  - app/controllers/err_merchant/errors_controller.rb
92
117
  - app/views/err_merchant/errors/template.html.erb
118
+ - config.ru
93
119
  - config/locales/en.yml
94
- - MIT-LICENSE
95
- - Rakefile
96
- - README.rdoc
97
- - spec/err_merchant_spec.rb
98
- - spec/internal/app/controllers/application_controller.rb
99
- - spec/internal/app/controllers/failures_controller.rb
100
- - spec/internal/app/views/failures/usual_action.html.erb
101
- - spec/internal/app/views/layouts/application.html.erb
102
- - spec/internal/app/views/layouts/erroneous.html.erb
103
- - spec/internal/config/database.yml
104
- - spec/internal/config/locales/de.yml
105
- - spec/internal/config/routes.rb
106
- - spec/internal/db/combustion_test.sqlite
107
- - spec/internal/db/schema.rb
108
- - spec/internal/log/test.log
109
- - spec/internal/public/500.html
110
- - spec/internal/public/favicon.ico
111
- - spec/spec_helper.rb
120
+ - err_merchant.gemspec
121
+ - lib/err_merchant.rb
122
+ - lib/err_merchant/engine.rb
123
+ - lib/err_merchant/exceptions_app.rb
124
+ - lib/err_merchant/version.rb
112
125
  homepage: https://github.com/fschwahn/err_merchant
113
- licenses: []
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
114
129
  post_install_message:
115
130
  rdoc_options: []
116
131
  require_paths:
117
132
  - lib
118
133
  required_ruby_version: !ruby/object:Gem::Requirement
119
- none: false
120
134
  requirements:
121
- - - ! '>='
135
+ - - ">="
122
136
  - !ruby/object:Gem::Version
123
137
  version: '0'
124
- segments:
125
- - 0
126
- hash: -1955459898448739955
127
138
  required_rubygems_version: !ruby/object:Gem::Requirement
128
- none: false
129
139
  requirements:
130
- - - ! '>='
140
+ - - ">="
131
141
  - !ruby/object:Gem::Version
132
142
  version: '0'
133
- segments:
134
- - 0
135
- hash: -1955459898448739955
136
143
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 1.8.15
144
+ rubygems_version: 3.1.2
139
145
  signing_key:
140
- specification_version: 3
146
+ specification_version: 4
141
147
  summary: Rails Engine for rendering error pages
142
- test_files:
143
- - spec/err_merchant_spec.rb
144
- - spec/internal/app/controllers/application_controller.rb
145
- - spec/internal/app/controllers/failures_controller.rb
146
- - spec/internal/app/views/failures/usual_action.html.erb
147
- - spec/internal/app/views/layouts/application.html.erb
148
- - spec/internal/app/views/layouts/erroneous.html.erb
149
- - spec/internal/config/database.yml
150
- - spec/internal/config/locales/de.yml
151
- - spec/internal/config/routes.rb
152
- - spec/internal/db/combustion_test.sqlite
153
- - spec/internal/db/schema.rb
154
- - spec/internal/log/test.log
155
- - spec/internal/public/500.html
156
- - spec/internal/public/favicon.ico
157
- - spec/spec_helper.rb
148
+ test_files: []