sinatra-errorcodes 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ff7346c4583085d7fcde50a569991a8dcb463424
4
+ data.tar.gz: fc7b15860f0a864d4e00670602907132542dc520
5
+ SHA512:
6
+ metadata.gz: 53713a04008d321cb54c29b3f27f9fae1e16d234b621c5566d020251b50d59fc2002d7ed52e3a8f182faf95168df8fdc30affecbcf4d709b44e35fef6827f6a6
7
+ data.tar.gz: 82b2632978faf829487a3218003a41bf2c59c86f2b50cdb4009ac07e34dfa2dfbe99d21bb444f94dfeaff8a514b3a4c4afc51e45456cf5ec30084268bd4a74ed
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.gem
2
+ Gemfile.lock
3
+
4
+ /.bundle/
5
+ /.yardoc
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -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 beetle-noise@gmx.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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sinatra-errorcodes.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 IzumiSy
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,25 @@
1
+ # Sinatra::Errorcodes
2
+ Gem of HTTP error status code class pack
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'sinatra-errorcodes'
10
+ ```
11
+
12
+ Or install it yourself as:
13
+ ```bash
14
+ $ gem install sinatra-errorcodes
15
+ ```
16
+
17
+ ## Contributing
18
+
19
+ Bug reports and pull requests are welcome on GitHub at https://github.com/IzumiSy/sinatra-errorcodes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
20
+
21
+
22
+ ## License
23
+
24
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
25
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sinatra/errorcodes"
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/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/4xx_errors.rb ADDED
@@ -0,0 +1,108 @@
1
+ require_relative "./error_base"
2
+
3
+ module HTTPError
4
+ class BadRequest < ErrorBase
5
+ CODE = 400
6
+ MESSAGE = "Bad Request"
7
+ end
8
+
9
+ class Unauthorized < ErrorBase
10
+ CODE = 401
11
+ MESSAGE = "Unauthorized"
12
+ end
13
+
14
+ class PaymentRequired < ErrorBase
15
+ CODE = 402
16
+ MESSAGE = "Payment Required"
17
+ end
18
+
19
+ class Forbidden < ErrorBase
20
+ CODE = 403
21
+ MESSAGE = "Forbidden"
22
+ end
23
+
24
+ class NotFound < ErrorBase
25
+ CODE = 404
26
+ MESSAGE = "Not Found"
27
+ end
28
+
29
+ class MethodNotAllows < ErrorBase
30
+ CODE = 405
31
+ MESSAGE = "Method Not Allowed"
32
+ end
33
+
34
+ class NotAccpetable < ErrorBase
35
+ CODE = 406
36
+ MESSAGE = "Not Acceptable"
37
+ end
38
+
39
+ class ProxyAuthenticationRequired < ErrorBase
40
+ CODE = 407
41
+ MESSAGE = "Proxy Authentication Required"
42
+ end
43
+
44
+ class RequestTimeout < ErrorBase
45
+ CODE = 408
46
+ MESSAGE = "Request Timeout"
47
+ end
48
+
49
+ class Conflict < ErrorBase
50
+ CODE = 409
51
+ MESSAGE = "Conflict"
52
+ end
53
+
54
+ class Gone < ErrorBase
55
+ CODE = 410
56
+ MESSAGE = "Gone"
57
+ end
58
+
59
+ class LengthRequired < ErrorBase
60
+ CODE = 411
61
+ MESSAGE = "Length Required"
62
+ end
63
+
64
+ class PreconditionFailed < ErrorBase
65
+ CODE = 412
66
+ MESSAGE = "Precondition Failed"
67
+ end
68
+
69
+ class PayloadTooLarge < ErrorBase
70
+ CODE = 413
71
+ MESSAGE = "Payload Too Large"
72
+ end
73
+
74
+ class UriTooLong < ErrorBase
75
+ CODE = 414
76
+ MESSAGE = "URI Too Long"
77
+ end
78
+
79
+ class UnsupportedMediaType < ErrorBase
80
+ CODE = 415
81
+ MESSAGE = "Unsupported Media Type"
82
+ end
83
+
84
+ class RangeNotSatisfiable < ErrorBase
85
+ CODE = 416
86
+ MESSAGE = "Range Not Satisfiable"
87
+ end
88
+
89
+ class ExpectationFailed < ErrorBase
90
+ CODE = 417
91
+ MESSAGE = "Expectation Failed"
92
+ end
93
+
94
+ class MisdirectedRequest < ErrorBase
95
+ CODE = 421
96
+ MESSAGE = "Misdirected Request"
97
+ end
98
+
99
+ class UpgradeRequired < ErrorBase
100
+ CODE = 426
101
+ MESSAGE = "Upgrade Required"
102
+ end
103
+
104
+ class UnavailableForLegalReasons < ErrorBase
105
+ CODE = 451
106
+ MESSAGE = "Unavailable For Legal Reasons"
107
+ end
108
+ end
data/lib/5xx_errors.rb ADDED
@@ -0,0 +1,33 @@
1
+ require_relative "./error_base"
2
+
3
+ module HTTPError
4
+ class InternalServerError < ErrorBase
5
+ CODE = 500
6
+ MESSAGE = "Internal Server Error"
7
+ end
8
+
9
+ class NotImplemented < ErrorBase
10
+ CODE = 501
11
+ MESSAGE = "Not Impemented"
12
+ end
13
+
14
+ class BadGateway < ErrorBase
15
+ CODE = 502
16
+ MESSAGE = "Bad Gateway"
17
+ end
18
+
19
+ class ServiceUnavailable < ErrorBase
20
+ CODE = 503
21
+ MESSAGE = "Service Unavailable"
22
+ end
23
+
24
+ class GatewayTimeout < ErrorBase
25
+ CODE = 504
26
+ MESSAGE = "Gateway Timeout"
27
+ end
28
+
29
+ class HTTPVersionNotSupported < ErrorBase
30
+ CODE = 505
31
+ MESSAGE = "HTTP Version Not Supported"
32
+ end
33
+ end
data/lib/error_base.rb ADDED
@@ -0,0 +1,15 @@
1
+ class ErrorBase < StandardError
2
+ def initialize( *message )
3
+ _v = message.join(' ')
4
+ @_msg = !_v.empty? ? _v : self.class::MESSAGE
5
+ @_code = self.class::CODE
6
+ end
7
+
8
+ def code
9
+ @_code
10
+ end
11
+
12
+ def message
13
+ @_msg
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'sinatra/base'
2
+ require 'sinatra/errorcodes/version'
3
+
4
+ require_relative '../4xx_errors.rb'
5
+ require_relative '../5xx_errors.rb'
6
+
7
+ module Sinatra
8
+ include HTTPError
9
+
10
+ module Errorcodes
11
+ def self.registered(app)
12
+ # TODO: Here overrides error do ... end section
13
+ # in order to set up exception handlings.
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Sinatra
2
+ module Errorcodes
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/sinatra/errorcodes/version', __FILE__)
3
+
4
+ lib = File.expand_path('../lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+
7
+ summary = %q{ "Sinatra Extension of HTTP error status code pack" }
8
+ description = %q{ "sinatra-errorcodes is the sinatra extension that contains a pack of HTTP error status code and message" }
9
+ ignores = %r{ ^(test|spec|features)/ }
10
+ homepage = "https://github.com/IzumiSy/sinatra-errorcodes"
11
+
12
+ Gem::Specification.new do |spec|
13
+ spec.name = 'sinatra-errorcodes'
14
+ spec.version = Sinatra::Errorcodes::VERSION
15
+ spec.authors = ['IzumiSy']
16
+ spec.email = ['beetle-noise@gmx.com']
17
+
18
+ spec.summary = summary
19
+ spec.description = description
20
+ spec.homepage = homepage
21
+ spec.license = 'MIT'
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(ignores) }
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{ ^exe /}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_dependency 'sinatra'
29
+
30
+ spec.add_development_dependency 'bundler', '~> 1.12'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
33
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sinatra::Errorcodes do
4
+ it 'has a version number' do
5
+ expect(Sinatra::Errorcodes::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'sinatra/errorcodes'
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-errorcodes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - IzumiSy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: ' "sinatra-errorcodes is the sinatra extension that contains a pack of
70
+ HTTP error status code and message" '
71
+ email:
72
+ - beetle-noise@gmx.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/4xx_errors.rb
87
+ - lib/5xx_errors.rb
88
+ - lib/error_base.rb
89
+ - lib/sinatra/errorcodes.rb
90
+ - lib/sinatra/errorcodes/version.rb
91
+ - sinatra-errorcodes.gemspec
92
+ - spec/sinatra/errorcodes_spec.rb
93
+ - spec/spec_helper.rb
94
+ homepage: https://github.com/IzumiSy/sinatra-errorcodes
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.6.4
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: '"Sinatra Extension of HTTP error status code pack"'
118
+ test_files: []