sinatra-errorcodes 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff7346c4583085d7fcde50a569991a8dcb463424
4
- data.tar.gz: fc7b15860f0a864d4e00670602907132542dc520
3
+ metadata.gz: 73fd3195d815e79e8b533b13e88192ed9bc80a45
4
+ data.tar.gz: 80aa76c52909abb1c72704426c750962bbff5704
5
5
  SHA512:
6
- metadata.gz: 53713a04008d321cb54c29b3f27f9fae1e16d234b621c5566d020251b50d59fc2002d7ed52e3a8f182faf95168df8fdc30affecbcf4d709b44e35fef6827f6a6
7
- data.tar.gz: 82b2632978faf829487a3218003a41bf2c59c86f2b50cdb4009ac07e34dfa2dfbe99d21bb444f94dfeaff8a514b3a4c4afc51e45456cf5ec30084268bd4a74ed
6
+ metadata.gz: aefe182ef6d17d69ed764fb8fef79923d3645b965d9318660ba58616ece701fcbf5bf5330005ca3367f04238461de2cf7ce65964b33498e55d3d83b07748d2a5
7
+ data.tar.gz: 775606957fbe5f45ed8033aaa5866c6247bf73fb7f40eb81757188cc71956e5a1df7d76f6899492dba10de8e0bc24ba20cd1aa77a699d1cf43a38d524b7b4418
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
1
  *.gem
2
2
  Gemfile.lock
3
3
 
4
+ .byebug_history
5
+
4
6
  /.bundle/
5
7
  /.yardoc
6
8
  /_yardoc/
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
+ ruby '2.2.3'
2
3
 
3
- # Specify your gem's dependencies in sinatra-errorcodes.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Sinatra::Errorcodes
2
- Gem of HTTP error status code class pack
2
+ [![Gem Version](https://badge.fury.io/rb/sinatra-errorcodes.svg)](https://badge.fury.io/rb/sinatra-errorcodes)
3
+ [![CircleCI](https://circleci.com/gh/IzumiSy/sinatra-errorcodes.svg?style=shield)](https://circleci.com/gh/IzumiSy/sinatra-errorcodes)
4
+ > Gem of HTTP error status code class pack
3
5
 
4
6
  ## Installation
5
7
 
@@ -14,6 +16,17 @@ Or install it yourself as:
14
16
  $ gem install sinatra-errorcodes
15
17
  ```
16
18
 
19
+ ## Example
20
+
21
+ Install gems
22
+ ```bash
23
+ $ bundle install
24
+ ```
25
+ and run it
26
+ ```bash
27
+ $ rackup -p 3000
28
+ ```
29
+
17
30
  ## Contributing
18
31
 
19
32
  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.
data/circleci.yml ADDED
@@ -0,0 +1,3 @@
1
+ test:
2
+ override:
3
+ - bundle exec rake spec
data/example/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ ruby '2.2.3'
2
+ source "https://rubygems.org"
3
+
4
+ gem "sinatra"
5
+ gem "sinatra-errorcodes", path: File.join(__FILE__, "../..")
data/example/app.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'sinatra'
2
+ require 'sinatra/base'
3
+ require 'sinatra/errorcodes'
4
+
5
+ require_relative './controller.rb'
6
+
7
+ class Application < Sinatra::Base
8
+ use MainController
9
+ end
data/example/base.rb ADDED
@@ -0,0 +1,11 @@
1
+ class BaseController < Sinatra::Base
2
+ configure do
3
+ set :raise_errors, false
4
+ set :show_exceptions, false
5
+ end
6
+
7
+ error do |e|
8
+ body e.message
9
+ status e.code
10
+ end
11
+ end
data/example/config.ru ADDED
@@ -0,0 +1,2 @@
1
+ require_relative './app'
2
+ run Application
@@ -0,0 +1,11 @@
1
+ require_relative './base'
2
+
3
+ class MainController < BaseController
4
+ get '/badrequest' do
5
+ raise HTTPError::BadRequest
6
+ end
7
+
8
+ get '/error' do
9
+ raise HTTPError::InternalServerError
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module Errorcodes
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -26,8 +26,10 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ['lib']
27
27
 
28
28
  spec.add_dependency 'sinatra'
29
+ spec.add_dependency 'sinatra-contrib'
29
30
 
30
- spec.add_development_dependency 'bundler', '~> 1.12'
31
+ spec.add_development_dependency 'bundler'
31
32
  spec.add_development_dependency 'rake', '~> 10.0'
32
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
+ spec.add_development_dependency 'rack-test'
33
35
  end
@@ -4,4 +4,26 @@ describe Sinatra::Errorcodes do
4
4
  it 'has a version number' do
5
5
  expect(Sinatra::Errorcodes::VERSION).not_to be nil
6
6
  end
7
+
8
+ it 'provides status 500' do
9
+ expect(HTTPError::InternalServerError::CODE).to be 500
10
+ expect(HTTPError::InternalServerError::MESSAGE).to eq 'Internal Server Error'
11
+ end
12
+
13
+ it 'provides status 400' do
14
+ expect(HTTPError::BadRequest::CODE).to be 400
15
+ expect(HTTPError::BadRequest::MESSAGE).to eq 'Bad Request'
16
+ end
17
+
18
+ it 'returns status 500 ' do
19
+ get '/error'
20
+ expect(last_response.status).to be 500
21
+ expect(last_response.body).to eq 'Internal Server Error'
22
+ end
23
+
24
+ it 'returns status 400' do
25
+ get '/badrequest'
26
+ expect(last_response.status).to be 400
27
+ expect(last_response.body).to eq 'Bad Request'
28
+ end
7
29
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,15 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'rspec'
4
+ require 'rack/test'
2
5
  require 'sinatra/errorcodes'
6
+
7
+ require_relative '../example/app.rb'
8
+
9
+ RSpec.configure do |config|
10
+ include Rack::Test::Methods
11
+
12
+ def app()
13
+ Application.new
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-errorcodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - IzumiSy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-25 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -24,20 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-contrib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '1.12'
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '1.12'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: ' "sinatra-errorcodes is the sinatra extension that contains a pack of
70
98
  HTTP error status code and message" '
71
99
  email:
@@ -83,6 +111,12 @@ files:
83
111
  - Rakefile
84
112
  - bin/console
85
113
  - bin/setup
114
+ - circleci.yml
115
+ - example/Gemfile
116
+ - example/app.rb
117
+ - example/base.rb
118
+ - example/config.ru
119
+ - example/controller.rb
86
120
  - lib/4xx_errors.rb
87
121
  - lib/5xx_errors.rb
88
122
  - lib/error_base.rb
@@ -116,3 +150,4 @@ signing_key:
116
150
  specification_version: 4
117
151
  summary: '"Sinatra Extension of HTTP error status code pack"'
118
152
  test_files: []
153
+ has_rdoc: