halt 1.0.0.beta
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 +15 -0
- data/.codeclimate.yml +17 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -0
- data/.travis.yml +21 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/Rakefile +21 -0
- data/app/views/application/error.html.erb +4 -0
- data/bin/console +14 -0
- data/bin/rails +12 -0
- data/bin/rake +16 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +11 -0
- data/config/routes.rb +2 -0
- data/lib/halt.rb +52 -0
- data/lib/halt/engine.rb +6 -0
- data/lib/halt/error.rb +58 -0
- data/lib/halt/version.rb +3 -0
- data/lib/tasks/halt_tasks.rake +4 -0
- metadata +221 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
ZWQzZGVjZjQ0NTAzMzQ4MGY0N2FjYjI0NDY0YmM5MjdiMGEyYzQyZg==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
YzZiYzk0NjFlNjdjNjBmZGM0YTQwYmY0NWNmZThkMDc4NjY1NDUxNQ==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
ZTY3NGM3NDJhMTczYmViYTQ5ZGExZjNiYTFiNjMzNGMyNjkxZGYyOTM1ZTBl
|
|
10
|
+
NWNlMmJmOTY4OTVkMWRjYjdkOWNiNzAyNDM2MTg3YmQ0ZGIxNDNmZjgzMDhk
|
|
11
|
+
NWU2ZTQ4MTA4NGIxMTVjMTE4NzIwMGI4ZjZlYzc2YjQxYTI3YTI=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
YjFmMzQ0OWM1MzdhY2U4ZGVlNDZkYzQ1N2QwNDY4ODc1ZjBhZDc2NGJhNTVj
|
|
14
|
+
OTY0MWZlOTJlOTAyNjc5NTNmYzExNWQ3NThiZjU5NWExNWU2MGFkYzc2NWEy
|
|
15
|
+
ZDAwZDY1MTY3ODg3ZTVkMzY3OTc3ZjZmYzIwZGZhNmVjZGE2YjI=
|
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.3.0
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 2.3.0
|
|
4
|
+
cache: bundler
|
|
5
|
+
sudo: false
|
|
6
|
+
env:
|
|
7
|
+
- RAILS_ENV=test
|
|
8
|
+
before_install: gem install bundler -v 1.11.2
|
|
9
|
+
before_script: bin/rake db:migrate
|
|
10
|
+
addons:
|
|
11
|
+
code_climate:
|
|
12
|
+
repo_token:
|
|
13
|
+
secure: S/pEX6D4Egp05FnqtQ2deCHM3wQ3G+xyv5gYoaDRLF2LkFBXA9fV7X+OFfg+ybFxaD9xQfdWhstQhUgz2qmEjujf9q+gjwECfbtPXtLK0/Sg/TOl0qJhQPRz/8Ww4qV0F8QD59OlQw/20J+7Ta5FLdXNN54dwYn/+7Hv7jiFQHsWByTcMNg+71vW4swhd+8aPO4fL/V4Q5seqZVuFCZFX9EnoqZmS2U8vWbj5aGEVJInEOylKdt3nGjrFY8/g2dibHPTY7dDkL2Xs0zIVAKKxJylLxLixS4HrwDMkNx+n3tuxGguASfY5BtTOMER5bQyGS2V/GWBQVls2+kzbJPLGSC7KYO9pddf/YPZNZsf1pKqkCDq4P+wL9d4E3H+OzQDca2HhppluFqUMfemMRNhUVnnwtqwOuhE/inzvf5n5/ibrMGN7oi7Pvr0jvEoJUqiqh8TYXr81oOUBZcdJs1skt5LuL9FfP0Bkcr8D5pnAp+/KklO4F9HQGvHs7nSZy41p3wepooxaDIJwxOWwa0wtVTQ1AozzAsbc3NvSQyyvgHyX7XtsRA91dlIWaCfUIty2EgxnUNHFjB2ahBZq4gZ2Cin7/erAYRsdGniy0ItN1nuXhrjhfUEgoyzcsKK1fs7E4AWLotgkvdZtF9DOtjbf4ZxjIdjD8iyw5iDOs1s57U=
|
|
14
|
+
deploy:
|
|
15
|
+
provider: rubygems
|
|
16
|
+
api_key:
|
|
17
|
+
secure: uWgUbc6bOwkfxh9t/V4Epw7OHvA69A3EGlVV63DX3kX1l8MaNqbxo3BO1RJHNSZH8TgBZdUosWpBur3SI8Fi+FL22KWaJ/Q4pz0XEqbeq9L6iDa8ww3L6HD9efa0EhrPvju+pIi5wXCk9jCsdnzoo2wzwKapd9fSBoF5u606sU1mlX/n0OCh6/M2+0XhryaLiIAVyyNVRBm4PGveZqdzPrxLijuMvvEwxynSADt2R1LZVqe0xi+oCvIl+KmTWfRyVCffpn7G3kerJzHfgH1lccngDFMLJqqRpWhDSthkH9OwjQh9CYtcnkBayXhTIP7vg8V7ZlOzyvo2T//poXP1AMmggFhd/ISYjm4n93wCucV6tIE0dBNoYHlS16G0Qx+W87fv1g9fwL4ryVh+CgowgoIxMXdvplbSbuFK6aZ9AUeYJ7fZaxMVh664yxeAHrsUarwBUSpZqDK05pxNZnQYjSVbQ4XbiPsKX8Q4ud8iUMJe+8f9wFr0OqYVBZqcv5BlSzoCo5p1DEQ2groEh4vWcFmEfn5O3qFSIoOzDNTlgOqa5tvUO5FPVG7r2AkFY/M5WpwbCH1ndJ28VBydAtlAtgLCxjze9Dk7l0WgOnXd1XQ9btge1xz4lMM78W/25WjBM2Gtpgu8PC2U5K5s2hE7nsk9mKzTm4dbNoNNWmNhKac=
|
|
18
|
+
gem: halt
|
|
19
|
+
on:
|
|
20
|
+
tags: true
|
|
21
|
+
repo: tubbo/halt
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at tscott@weblinc.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Declare your gem's dependencies in halt.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/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Tom Scott
|
|
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,82 @@
|
|
|
1
|
+
# Halt
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/tubbo/halt)
|
|
4
|
+
[](https://codeclimate.com/github/tubbo/halt)
|
|
5
|
+
[](https://codeclimate.com/github/tubbo/halt)
|
|
6
|
+
|
|
7
|
+
Standard error handling for [ActionController][].
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'halt'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install halt
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Include `Halt` in your `ApplicationController`, and use the `halt` macro
|
|
28
|
+
to rescue from exceptions.
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
class ApplicatioNController < ActionController::Base
|
|
32
|
+
include Halt
|
|
33
|
+
|
|
34
|
+
halt ActiveRecord::RecordNotFound, with: :not_found
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or, you can `halt` from within an action:
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
class PostsController < ApplicationController
|
|
41
|
+
def create
|
|
42
|
+
halt :unauthorized unless current_user.present?
|
|
43
|
+
@post = Post.new post_params
|
|
44
|
+
|
|
45
|
+
if @post.save
|
|
46
|
+
redirect_to @post
|
|
47
|
+
else
|
|
48
|
+
render :new
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def post_params
|
|
55
|
+
params.require(:post).permit :title, :body
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
|
63
|
+
run `rake spec` to run the tests. You can also run `bin/console` for an
|
|
64
|
+
interactive prompt that will allow you to experiment.
|
|
65
|
+
|
|
66
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
67
|
+
To release a new version, update the version number in `version.rb`, and then
|
|
68
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
|
69
|
+
push git commits and tags, and push the `.gem` file to
|
|
70
|
+
[rubygems.org](https://rubygems.org) via [travis-ci](http://travis-ci.org).
|
|
71
|
+
|
|
72
|
+
## Contributing
|
|
73
|
+
|
|
74
|
+
Bug reports and pull requests are welcome on GitHub at
|
|
75
|
+
https://github.com/tubbo/halt. This project is intended to be a safe,
|
|
76
|
+
welcoming space for collaboration, and contributors are expected to adhere
|
|
77
|
+
to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
The gem is available as open source under the terms of the
|
|
82
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'bundler/setup'
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
require 'rubocop/rake_task'
|
|
4
|
+
require 'yard'
|
|
5
|
+
require 'travis/release/task'
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new :test
|
|
8
|
+
|
|
9
|
+
RuboCop::RakeTask.new :lint
|
|
10
|
+
|
|
11
|
+
YARD::Rake::YardocTask.new :doc
|
|
12
|
+
|
|
13
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
|
14
|
+
load 'rails/tasks/engine.rake'
|
|
15
|
+
load 'rails/tasks/statistics.rake'
|
|
16
|
+
|
|
17
|
+
Bundler::GemHelper.install_tasks
|
|
18
|
+
|
|
19
|
+
Travis::Release::Task.new
|
|
20
|
+
|
|
21
|
+
task default: %w(test build doc)
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'halt'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require 'irb'
|
|
14
|
+
IRB.start
|
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/halt/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'
|
data/bin/rake
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/setup
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
en:
|
|
2
|
+
halt:
|
|
3
|
+
errors:
|
|
4
|
+
messages:
|
|
5
|
+
not_found: File Not Found
|
|
6
|
+
server_error: Internal Server Error
|
|
7
|
+
forbidden: Forbidden
|
|
8
|
+
descriptions:
|
|
9
|
+
not_found: The file or resource you requested could not be found.
|
|
10
|
+
server_error: The server encountered an error and could not complete your request.
|
|
11
|
+
forbidden: No one has access to view this page.
|
data/config/routes.rb
ADDED
data/lib/halt.rb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'active_support/all'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'i18n'
|
|
4
|
+
|
|
5
|
+
require 'halt/version'
|
|
6
|
+
require 'halt/engine'
|
|
7
|
+
require 'halt/error'
|
|
8
|
+
|
|
9
|
+
# An extension to +ActionController+ which enables standard error
|
|
10
|
+
# handling using +ActionView+ and translations.
|
|
11
|
+
#
|
|
12
|
+
# @api public
|
|
13
|
+
# @example
|
|
14
|
+
# class ApplicationController < ActionController::Base
|
|
15
|
+
# include Pundit
|
|
16
|
+
# include Halt
|
|
17
|
+
#
|
|
18
|
+
# halt ActiveRecord::RecordNotFound, with: :not_found
|
|
19
|
+
# halt Pundit::NotAuthorizedError, with: :unauthorized
|
|
20
|
+
# end
|
|
21
|
+
module Halt
|
|
22
|
+
extend ActiveSupport::Concern
|
|
23
|
+
|
|
24
|
+
included do
|
|
25
|
+
class_attribute :halted
|
|
26
|
+
self.halted ||= {}
|
|
27
|
+
alias_method :halt!, :halt
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class_methods do
|
|
31
|
+
def halt(exception, with: :server_error)
|
|
32
|
+
halted[exception] = with
|
|
33
|
+
rescue_from exception, with: :_handle_exception
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def halt(status, **options)
|
|
38
|
+
@error = Error.new(status, **options)
|
|
39
|
+
|
|
40
|
+
respond_to do |format|
|
|
41
|
+
format.html { render 'error', status: @error.status, error: @error }
|
|
42
|
+
format.json { render json: @error, status: @error.status }
|
|
43
|
+
end && return
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def _handle_exception(exception)
|
|
49
|
+
Rails.logger.debug exception.message
|
|
50
|
+
halt halted[exception.class], exception: exception
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/halt/engine.rb
ADDED
data/lib/halt/error.rb
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module Halt
|
|
2
|
+
# Error object to house the translation logic and exception/status
|
|
3
|
+
# information passed in when +halt+ has been called or an exception is
|
|
4
|
+
# being rescued.
|
|
5
|
+
#
|
|
6
|
+
# @api private
|
|
7
|
+
class Error
|
|
8
|
+
MESSAGES = 'halt.errors.messages'.freeze
|
|
9
|
+
DESCRIPTIONS = 'halt.errors.descriptions'.freeze
|
|
10
|
+
|
|
11
|
+
delegate :to_json, to: :attributes
|
|
12
|
+
delegate :message, to: :exception, prefix: true, allow_nil: true
|
|
13
|
+
|
|
14
|
+
attr_accessor :status
|
|
15
|
+
attr_accessor :exception
|
|
16
|
+
|
|
17
|
+
attr_writer :message
|
|
18
|
+
attr_writer :description
|
|
19
|
+
|
|
20
|
+
# @param [Symbol] status
|
|
21
|
+
# @keyword [Exception] exception
|
|
22
|
+
# @keyword [String] message
|
|
23
|
+
# @keyword [String] description
|
|
24
|
+
def initialize(status, exception: nil, message: nil, description: nil)
|
|
25
|
+
@status = status
|
|
26
|
+
@exception = exception
|
|
27
|
+
@message = message
|
|
28
|
+
@description = description
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @return [String]
|
|
32
|
+
def message
|
|
33
|
+
@message ||= translate MESSAGES
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @return [String]
|
|
37
|
+
def description
|
|
38
|
+
@description ||= translate DESCRIPTIONS
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @return [Hash]
|
|
42
|
+
def attributes
|
|
43
|
+
{
|
|
44
|
+
status: status,
|
|
45
|
+
message: message,
|
|
46
|
+
description: description
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
# @private
|
|
53
|
+
# @param [String] key
|
|
54
|
+
def translate(scope)
|
|
55
|
+
I18n.translate status, scope: scope
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/halt/version.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: halt
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0.beta
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tom Scott
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-02-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec-rails
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ~>
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ~>
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: yard
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ~>
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ~>
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: capybara
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ~>
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ~>
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rails
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ~>
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '4.2'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ~>
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '4.2'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: sqlite3
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ~>
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '1'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ~>
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '1'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: travis-release
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ~>
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ~>
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: codeclimate-test-reporter
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ~>
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ~>
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: actionpack
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ~>
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '4'
|
|
160
|
+
type: :runtime
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ~>
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '4'
|
|
167
|
+
description: Standard error handling for Rails applications. Inspired by a little
|
|
168
|
+
method in Sinatra.
|
|
169
|
+
email:
|
|
170
|
+
- tubbo@psychedeli.ca
|
|
171
|
+
executables: []
|
|
172
|
+
extensions: []
|
|
173
|
+
extra_rdoc_files: []
|
|
174
|
+
files:
|
|
175
|
+
- .codeclimate.yml
|
|
176
|
+
- .gitignore
|
|
177
|
+
- .rubocop.yml
|
|
178
|
+
- .ruby-version
|
|
179
|
+
- .travis.yml
|
|
180
|
+
- CODE_OF_CONDUCT.md
|
|
181
|
+
- Gemfile
|
|
182
|
+
- LICENSE.txt
|
|
183
|
+
- README.md
|
|
184
|
+
- Rakefile
|
|
185
|
+
- app/views/application/error.html.erb
|
|
186
|
+
- bin/console
|
|
187
|
+
- bin/rails
|
|
188
|
+
- bin/rake
|
|
189
|
+
- bin/setup
|
|
190
|
+
- config/locales/en.yml
|
|
191
|
+
- config/routes.rb
|
|
192
|
+
- lib/halt.rb
|
|
193
|
+
- lib/halt/engine.rb
|
|
194
|
+
- lib/halt/error.rb
|
|
195
|
+
- lib/halt/version.rb
|
|
196
|
+
- lib/tasks/halt_tasks.rake
|
|
197
|
+
homepage: https://github.com/tubbo/halt
|
|
198
|
+
licenses:
|
|
199
|
+
- MIT
|
|
200
|
+
metadata: {}
|
|
201
|
+
post_install_message:
|
|
202
|
+
rdoc_options: []
|
|
203
|
+
require_paths:
|
|
204
|
+
- lib
|
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
206
|
+
requirements:
|
|
207
|
+
- - ! '>='
|
|
208
|
+
- !ruby/object:Gem::Version
|
|
209
|
+
version: '0'
|
|
210
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
|
+
requirements:
|
|
212
|
+
- - ! '>'
|
|
213
|
+
- !ruby/object:Gem::Version
|
|
214
|
+
version: 1.3.1
|
|
215
|
+
requirements: []
|
|
216
|
+
rubyforge_project:
|
|
217
|
+
rubygems_version: 2.4.5
|
|
218
|
+
signing_key:
|
|
219
|
+
specification_version: 4
|
|
220
|
+
summary: Standard error handling for Rails applications.
|
|
221
|
+
test_files: []
|