fire_dept 0.0.1

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: 836f6fcbc2fd5fe6b46963c3fa9fffa436ecf00f
4
+ data.tar.gz: c2e24ae6a503272725261ec477d5c495c927571d
5
+ SHA512:
6
+ metadata.gz: 11fadc880c9b56b46a97a634497a195807f3ace79dae550891863dc6837acf281157850bf03db0988a616b138748b28881d859404eb190af0cb5007b10d25bd9
7
+ data.tar.gz: 23fb9276f2b6f572e5ef13ae13293c1baf4d07eae0863ce9549f6987125ed4bb65ce42f3901e366ac9b6940021fe644c9b8454ea6817dfb5ab9660d37a8c1f29
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fire_dept.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alex Reisner
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # FireDept
2
+
3
+ Rescue from routing and controller exceptions in Rails. Provides intelligent, configurable handling of a wide variety of exceptions.
4
+
5
+ Still in early development. Will probably not work in your app.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'fire_dept'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Contributing
22
+
23
+ 1. Fork it
24
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
25
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
26
+ 4. Push to the branch (`git push origin my-new-feature`)
27
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/*_test.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ task :default => [:test]
data/fire_dept.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fire_dept/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fire_dept"
8
+ spec.version = FireDept::VERSION
9
+ spec.authors = ["Alex Reisner"]
10
+ spec.email = ["alex@alexreisner.com"]
11
+ spec.homepage = ""
12
+ spec.summary = "Rescue from routing and controller exceptions in Rails."
13
+ spec.description = "Provides intelligent, configurable handling of a wide variety of exceptions."
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "actionpack"
24
+ end
data/lib/fire_dept.rb ADDED
@@ -0,0 +1,29 @@
1
+ require "fire_dept/version"
2
+ require 'active_support/concern'
3
+
4
+ module FireDept
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ rescue_from(
9
+ ActiveRecord::RecordNotFound,
10
+ ActionController::RoutingError,
11
+ ActionController::UnknownFormat,
12
+ with: :not_found
13
+ )
14
+
15
+ rescue_from(
16
+ ActionController::InvalidAuthenticityToken,
17
+ ActionController::ParameterMissing
18
+ ) do |e|
19
+ head :bad_request
20
+ end
21
+
22
+ rescue_from(
23
+ ActionView::MissingTemplate,
24
+ ActionView::Template::Error
25
+ ) do |e|
26
+ head :not_acceptable
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module FireDept
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+
4
+ class FireDeptTest < ActionDispatch::IntegrationTest
5
+
6
+ setup do
7
+ #@controller = TestController.new
8
+ #@request = ActionController::TestRequest.new
9
+ #@response = ActionController::TestResponse.new
10
+ @routes = ActionDispatch::Routing::RouteSet.new
11
+ ActionDispatch.test_app = @routes
12
+ end
13
+
14
+ test "rescue from ActiveRecord::NotFound" do
15
+ @routes.draw do
16
+ get "index" => "test#raise_active_record_not_found"
17
+ end
18
+ get "/index"
19
+ assert_response :not_found
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'fire_dept'
3
+ require 'test/unit'
4
+ require 'active_support/testing/autorun'
5
+ require 'abstract_controller'
6
+ require 'action_controller'
7
+ require 'action_view'
8
+ require 'action_view/testing/resolvers'
9
+ require 'action_dispatch'
10
+ require 'active_support/dependencies'
11
+ require 'active_record/errors'
12
+
13
+ class TestController < ActionController::Base
14
+ include FireDept
15
+
16
+ def index
17
+ render text: 'OK'
18
+ end
19
+
20
+ def raise_active_record_not_found
21
+ raise ActiveRecord::RecordNotFound
22
+ end
23
+
24
+ private # ------------------------------------------------------------------
25
+
26
+ def not_found
27
+ render status: :not_found, text: "not found"
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fire_dept
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Reisner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-05 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionpack
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
+ description: Provides intelligent, configurable handling of a wide variety of exceptions.
56
+ email:
57
+ - alex@alexreisner.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - fire_dept.gemspec
68
+ - lib/fire_dept.rb
69
+ - lib/fire_dept/version.rb
70
+ - test/fire_dept_test.rb
71
+ - test/test_helper.rb
72
+ homepage: ''
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Rescue from routing and controller exceptions in Rails.
96
+ test_files:
97
+ - test/fire_dept_test.rb
98
+ - test/test_helper.rb