rails-annoying 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.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Matthew Riley MacPherson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,19 @@
1
+ = rails-annoying
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to rails-annoying
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Matthew Riley MacPherson. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,9 @@
1
+ module RailsAnnoying
2
+ PATH = File.join(File.dirname(__FILE__), 'rails-annoying')
3
+ end
4
+
5
+ [
6
+ 'action_controller/base'
7
+ ].each do |f|
8
+ require File.join(RailsAnnoying::PATH, *f.split('/')) if defined?(Rails)
9
+ end
@@ -0,0 +1,56 @@
1
+ module RailsAnnoying
2
+ module ActionController
3
+ # :nodoc:
4
+ def self.included(klass)
5
+ klass.class_eval do
6
+ extend Base
7
+ end
8
+ end
9
+
10
+ module Base
11
+ def dont_be_annoying
12
+ ::ActionController::Base.send :include, ClassMethods
13
+ end
14
+ end
15
+
16
+ module ClassMethods
17
+ # :nodoc:
18
+ def self.included(klass)
19
+ klass.class_eval do
20
+ # Rescue exceptions with custom error pages in production
21
+ unless Rails.application.config.consider_all_requests_local
22
+ rescue_from ::Exception, :with => :render_error # Generic error (500, etc.)
23
+
24
+ rescue_from ::ActionController::InvalidAuthenticityToken, :with => :render_csrf
25
+ rescue_from ::ActiveRecord::RecordNotFound, :with => :render_not_found
26
+ rescue_from ::ActionController::RoutingError, :with => :render_not_found
27
+ rescue_from ::ActionController::UnknownController, :with => :render_not_found
28
+ rescue_from ::ActionController::UnknownAction, :with => :render_not_found
29
+ end
30
+
31
+ extend ClassMethods
32
+ end
33
+ end
34
+
35
+ def render_csrf(exception)
36
+ logger.info(exception)
37
+
38
+ render "/errors/csrf", :status => 403
39
+ end
40
+
41
+ def render_error(exception)
42
+ logger.error(exception)
43
+
44
+ render "/errors/500", :status => 500
45
+ end
46
+
47
+ def render_not_found(exception)
48
+ logger.info(exception)
49
+
50
+ render "/errors/404", :status => 404
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ ::ActionController::Base.send :include, RailsAnnoying::ActionController
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-annoying
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matthew Riley MacPherson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: &70313406232700 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70313406232700
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70313406231960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70313406231960
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &70313406231140 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70313406231140
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &70313406230280 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70313406230280
58
+ description: rails-annoying removes some common, minor annoyances from Rails.
59
+ email: matt@lonelyvegan.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files:
63
+ - LICENSE.txt
64
+ - README.markdown
65
+ files:
66
+ - lib/rails-annoying.rb
67
+ - lib/rails-annoying/action_controller/base.rb
68
+ - LICENSE.txt
69
+ - README.markdown
70
+ homepage: http://github.com/tofumatt/rails-annoying
71
+ licenses:
72
+ - MIT
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ segments:
84
+ - 0
85
+ hash: 3482709993777998400
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.11
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: rails-annoying removes some common, minor annoyances from Rails.
98
+ test_files: []