rails_disable_dependency_loading 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/lib/rails_disable_dependency_loading.rb +2 -0
- data/lib/rails_disable_dependency_loading/railtie.rb +13 -0
- data/lib/rails_disable_dependency_loading/version.rb +3 -0
- data/rails_disable_dependency_loading.gemspec +24 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 228c6aebb19b16de0badb248f56bec5b7466fac0
|
4
|
+
data.tar.gz: 164de6a6824d6807b588c78ab25c2571dd7d7e99
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53c356ed5435ad2d38b27c2801ec65427df3d215dc304e181518466a976caa49941f6f995cba88c13a72484fcf97723a407be50cafbcb9c0c4abc83f2168bdfd
|
7
|
+
data.tar.gz: 48ad87a167093158a4384992093adb3cacf752304972aa5b0c32f390e4fd72029da9649c2abe0a7f03c0f6dbcf87b68dbddefec8a45195b947c6a4afdcfb3f35
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Case Taintor
|
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,46 @@
|
|
1
|
+
# RailsDisableDependencyLoading
|
2
|
+
|
3
|
+
This gem adds back the `disable_dependency_loading` initializer to Rails, which was removed with [this commit](https://github.com/rails/rails/commit/a8bf12979e5fa15282b39c8cfa315e663f613539).
|
4
|
+
The purpose of this initializer is to remove Rails auto-loading capabilities in production environments after the
|
5
|
+
initialization sequence has completed. This is because auto-loading is not threadsafe and thus you want to avoid auto-loading
|
6
|
+
during request processing because you *will* have problems if using a threaded web server like Puma and you have a reasonable amount of load.
|
7
|
+
Read Aaron Patterson's [writeup](http://tenderlovemaking.com/2012/06/18/removing-config-threadsafe.html),
|
8
|
+
on thread safety if you want more information. (Note that his writeup was done when the ability to disable dependency
|
9
|
+
loading was supported natively in Rails.)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'rails_disable_dependency_loading'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install rails_disable_dependency_loading
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
If you have both `config.eager_load` \& `config.cache_classes` set to `true` (the default for RAILS_ENV=production),
|
30
|
+
then the Rails auto-dependency-loading will be disabled. This will mean that you will get runtime errors if you fail to
|
31
|
+
have your dependencies loaded during initialization. You can fix that by explicitly requiring your dependencies from
|
32
|
+
a file that is loaded during initialization, or you can add directories to the `eager_load_paths` configuration - it is
|
33
|
+
probably a good idea to read [this issue](https://github.com/rails/rails/issues/13142) to understand more.
|
34
|
+
|
35
|
+
It is highly likely that including this gem will cause your servive to break,
|
36
|
+
so you should test thoroughly after including the gem. After fixing all the issues,
|
37
|
+
you will be able to sleep better at night knowing that your users aren't
|
38
|
+
experiencing random, hard-to-reproduce bugs in your code.
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it ( https://github.com/[my-github-username]/rails_disable_dependency_loading/fork )
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module RailsDisableDependencyLoading
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
# Disable dependency loading during request cycle so you see thread-unsafe dependency loading
|
4
|
+
# immediately & consistently. Ideally, I'd like for this to happen *last*, but it's very hard to do that
|
5
|
+
# since the Rails standard initializers aren't in place when the gem is loaded. after_initialize is probably
|
6
|
+
# good enough...
|
7
|
+
config.after_initialize do |app|
|
8
|
+
if app.config.eager_load && app.config.cache_classes
|
9
|
+
ActiveSupport::Dependencies.unhook!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -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 'rails_disable_dependency_loading/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_disable_dependency_loading"
|
8
|
+
spec.version = RailsDisableDependencyLoading::VERSION
|
9
|
+
spec.authors = ["Case Taintor"]
|
10
|
+
spec.email = ["casetaintor@gmail.com"]
|
11
|
+
spec.summary = %q{Adds a rails initializer to make it easier to catch thread-safety issues in your code.}
|
12
|
+
spec.homepage = "https://github.com/ctaintor/rails_disable_dependency_loading"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "rails", "~> 4.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_disable_dependency_loading
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Case Taintor
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-16 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- casetaintor@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/rails_disable_dependency_loading.rb
|
68
|
+
- lib/rails_disable_dependency_loading/railtie.rb
|
69
|
+
- lib/rails_disable_dependency_loading/version.rb
|
70
|
+
- rails_disable_dependency_loading.gemspec
|
71
|
+
homepage: https://github.com/ctaintor/rails_disable_dependency_loading
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.4.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Adds a rails initializer to make it easier to catch thread-safety issues
|
95
|
+
in your code.
|
96
|
+
test_files: []
|