we_bridge-exceptions 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72d827730814659d7d7cefe526b42d20e5ea28d3
4
+ data.tar.gz: 4a0a5dcf91547e5070a0203fe09aac9dbbeef80f
5
+ SHA512:
6
+ metadata.gz: 8597597e7ac6259158fb1b3a251cee1ba096e1b79a2f9f7ce45255fb328bb5c3fd838392ca5a13c6b35c2b45ca4b1e71eaa1e75638d2162ac2be074ac9373d78
7
+ data.tar.gz: f3a0ffebeab725ad0a750705afe9ecb70f796501928ca6385a12ea562d21a31a08d7f1eeebcffb78d2f2c5ebdc2c479bd26d724bc081c319eeaa30fd1ae38e9c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in we_bridge-exceptions.gemspec
4
+ gemspec
5
+
6
+ gem 'rails', '>= 3'
7
+ gem 'rspec-rails', '>= 3'
8
+ gem 'sqlite3'
data/Gemfile.lock ADDED
@@ -0,0 +1,136 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ we_bridge-exceptions (0.1.0)
5
+ rails (>= 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.2.3)
11
+ actionpack (= 4.2.3)
12
+ actionview (= 4.2.3)
13
+ activejob (= 4.2.3)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.3)
17
+ actionview (= 4.2.3)
18
+ activesupport (= 4.2.3)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.3)
24
+ activesupport (= 4.2.3)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ activejob (4.2.3)
30
+ activesupport (= 4.2.3)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.3)
33
+ activesupport (= 4.2.3)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.3)
36
+ activemodel (= 4.2.3)
37
+ activesupport (= 4.2.3)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.3)
40
+ i18n (~> 0.7)
41
+ json (~> 1.7, >= 1.7.7)
42
+ minitest (~> 5.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
44
+ tzinfo (~> 1.1)
45
+ arel (6.0.3)
46
+ builder (3.2.2)
47
+ diff-lcs (1.2.5)
48
+ erubis (2.7.0)
49
+ globalid (0.3.6)
50
+ activesupport (>= 4.1.0)
51
+ i18n (0.7.0)
52
+ json (1.8.3)
53
+ loofah (2.0.2)
54
+ nokogiri (>= 1.5.9)
55
+ mail (2.6.3)
56
+ mime-types (>= 1.16, < 3)
57
+ mime-types (2.6.1)
58
+ mini_portile (0.6.2)
59
+ minitest (5.8.0)
60
+ nokogiri (1.6.6.2)
61
+ mini_portile (~> 0.6.0)
62
+ rack (1.6.4)
63
+ rack-test (0.6.3)
64
+ rack (>= 1.0)
65
+ rails (4.2.3)
66
+ actionmailer (= 4.2.3)
67
+ actionpack (= 4.2.3)
68
+ actionview (= 4.2.3)
69
+ activejob (= 4.2.3)
70
+ activemodel (= 4.2.3)
71
+ activerecord (= 4.2.3)
72
+ activesupport (= 4.2.3)
73
+ bundler (>= 1.3.0, < 2.0)
74
+ railties (= 4.2.3)
75
+ sprockets-rails
76
+ rails-deprecated_sanitizer (1.0.3)
77
+ activesupport (>= 4.2.0.alpha)
78
+ rails-dom-testing (1.0.6)
79
+ activesupport (>= 4.2.0.beta, < 5.0)
80
+ nokogiri (~> 1.6.0)
81
+ rails-deprecated_sanitizer (>= 1.0.1)
82
+ rails-html-sanitizer (1.0.2)
83
+ loofah (~> 2.0)
84
+ railties (4.2.3)
85
+ actionpack (= 4.2.3)
86
+ activesupport (= 4.2.3)
87
+ rake (>= 0.8.7)
88
+ thor (>= 0.18.1, < 2.0)
89
+ rake (10.4.2)
90
+ rspec (3.3.0)
91
+ rspec-core (~> 3.3.0)
92
+ rspec-expectations (~> 3.3.0)
93
+ rspec-mocks (~> 3.3.0)
94
+ rspec-core (3.3.2)
95
+ rspec-support (~> 3.3.0)
96
+ rspec-expectations (3.3.1)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.3.0)
99
+ rspec-mocks (3.3.2)
100
+ diff-lcs (>= 1.2.0, < 2.0)
101
+ rspec-support (~> 3.3.0)
102
+ rspec-rails (3.3.3)
103
+ actionpack (>= 3.0, < 4.3)
104
+ activesupport (>= 3.0, < 4.3)
105
+ railties (>= 3.0, < 4.3)
106
+ rspec-core (~> 3.3.0)
107
+ rspec-expectations (~> 3.3.0)
108
+ rspec-mocks (~> 3.3.0)
109
+ rspec-support (~> 3.3.0)
110
+ rspec-support (3.3.0)
111
+ sprockets (3.2.0)
112
+ rack (~> 1.0)
113
+ sprockets-rails (2.3.2)
114
+ actionpack (>= 3.0)
115
+ activesupport (>= 3.0)
116
+ sprockets (>= 2.8, < 4.0)
117
+ sqlite3 (1.3.10)
118
+ thor (0.19.1)
119
+ thread_safe (0.3.5)
120
+ tzinfo (1.2.2)
121
+ thread_safe (~> 0.1)
122
+
123
+ PLATFORMS
124
+ ruby
125
+
126
+ DEPENDENCIES
127
+ bundler (~> 1.10)
128
+ rails (>= 3)
129
+ rake (~> 10.0)
130
+ rspec
131
+ rspec-rails (>= 3)
132
+ sqlite3
133
+ we_bridge-exceptions!
134
+
135
+ BUNDLED WITH
136
+ 1.10.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Shinjiro Itagaki
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,41 @@
1
+ # WeBridge::Exceptions
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/we_bridge/exceptions`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'we_bridge-exceptions'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install we_bridge-exceptions
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/we_bridge-exceptions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
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 "we_bridge/exceptions"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ module WeBridge
2
+ module Exceptions
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,68 @@
1
+ require "we_bridge/exceptions/version"
2
+ require 'active_record/errors'
3
+ require 'action_controller'
4
+ require 'action_controller/metal/exceptions'
5
+
6
+ module WeBridge
7
+ module Exceptions
8
+
9
+ # 401
10
+ class UnauthorizedError < ActionController::ActionControllerError; end
11
+
12
+ # 403
13
+ class ForbiddenError < ActionController::ActionControllerError; end
14
+
15
+ # 406
16
+ class NotAcceptableError < ActionController::ActionControllerError; end
17
+
18
+ def self.included(c)
19
+ if c.respond_to? :rescue_from
20
+ c.rescue_from Exception, with: :render_500
21
+ c.rescue_from ActiveRecord::RecordNotUnique, with: :render_409
22
+ c.rescue_from NotAcceptableError, with: :render_406
23
+ c.rescue_from ActionController::RoutingError, with: :render_404
24
+ c.rescue_from ActiveRecord::RecordNotFound, with: :render_404
25
+ c.rescue_from ForbiddenError, with: :render_403
26
+ c.rescue_from UnauthorizedError, with: :render_401
27
+ c.rescue_from ActionController::BadRequest, with: :render_400
28
+ end
29
+ end
30
+
31
+ def render_500(exception = nil)
32
+ handle_error(exception , 500)
33
+ end
34
+
35
+ def render_409(exception = nil)
36
+ handle_error(exception , 409)
37
+ end
38
+
39
+ def render_406(exception = nil)
40
+ handle_error(exception , 406)
41
+ end
42
+
43
+ def render_404(exception = nil)
44
+ handle_error(exception , 404)
45
+ end
46
+
47
+ def render_403(exception = nil)
48
+ handle_error(exception , 403)
49
+ end
50
+
51
+ def render_401(exception = nil)
52
+ handle_error(exception , 401)
53
+ end
54
+
55
+ def render_400(exception = nil)
56
+ handle_error(exception , 400)
57
+ end
58
+
59
+ def handle_error(exception , status_code)
60
+ logger.info "Rendering #{status_code} with exception: #{exception.message}" if exception
61
+ render file: WeBridge::Exceptions.error_template_file_path(status_code), status: status_code, content_type: 'text/html'
62
+ end
63
+
64
+ def self.error_template_file_path(status_code)
65
+ File.expand_path("../views/#{status_code}.html.erb",__FILE__)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'we_bridge/exceptions/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "we_bridge-exceptions"
8
+ spec.version = WeBridge::Exceptions::VERSION
9
+ spec.authors = ["Shinjiro Itagaki"]
10
+ spec.email = ["ishinjiroster@gmail.com"]
11
+
12
+ spec.summary = "Exceptions used in we_bridge"
13
+ spec.description = "Define common exceptions and exception handlings used in we_bridge."
14
+ spec.homepage = "https://github.com/baseball-bridge/we_bridge-exceptions"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ spec.add_development_dependency "rspec-rails"
34
+ spec.add_development_dependency "sqlite3"
35
+ spec.add_dependency "rails", ">= 3"
36
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: we_bridge-exceptions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shinjiro Itagaki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-09 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
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: sqlite3
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: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '3'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '3'
97
+ description: Define common exceptions and exception handlings used in we_bridge.
98
+ email:
99
+ - ishinjiroster@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - lib/we_bridge/exceptions.rb
116
+ - lib/we_bridge/exceptions/version.rb
117
+ - lib/we_bridge/views/400.html.erb
118
+ - lib/we_bridge/views/401.html.erb
119
+ - lib/we_bridge/views/403.html.erb
120
+ - lib/we_bridge/views/404.html.erb
121
+ - lib/we_bridge/views/406.html.erb
122
+ - lib/we_bridge/views/409.html.erb
123
+ - lib/we_bridge/views/500.html.erb
124
+ - we_bridge-exceptions.gemspec
125
+ homepage: https://github.com/baseball-bridge/we_bridge-exceptions
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.4.5
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Exceptions used in we_bridge
149
+ test_files: []