rails_middleware_delegator 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 +4 -4
- data/README.md +29 -24
- data/lib/rails_middleware_delegator.rb +1 -1
- data/lib/rails_middleware_delegator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c6a31a0512e404e6a860dc168bb5e93f204b5d0
|
4
|
+
data.tar.gz: dbd58446d0e5cae0c32fd25f61afce3e89f9dfa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9b6ce821544fb0835f3ef0d151d74f2c2e65b76e9e2136076a5dbc2dd4bfa144ca606831bb5e369c7db9fcaec0b7144ccead13e9314f758012e58a8a7ff92cf
|
7
|
+
data.tar.gz: 889cfc53f78551ba22dd25a8cc8fd342e84175116666b428636fc1bc23c12a97ffa5650c6cf305c885f4707e8ce0ae62db28648eb2ab94a2ddc0c3254bb62f26
|
data/README.md
CHANGED
@@ -1,41 +1,46 @@
|
|
1
|
-
|
1
|
+
RailsMiddlewareDelegator
|
2
|
+
========================
|
2
3
|
|
3
|
-
|
4
|
+
When using Rails middleware, a common problem is that middleware loaded from `lib`
|
5
|
+
does not reload between requests. In order for changes to these middleware classes
|
6
|
+
to be reflected in a running server, the development server process must be
|
7
|
+
killed and restarted.
|
4
8
|
|
5
|
-
|
9
|
+
If one were to drop a middleware class into a subdirectory of `app` and rely on
|
10
|
+
autoloading, however, changing any other autoloaded file and making a new
|
11
|
+
server request results in an error, `A copy of X has been removed from the module
|
12
|
+
tree bus is still active`. Upon starting the server, an instance of the class was
|
13
|
+
loaded into memory. At the end of the request, the class was unloaded. On the
|
14
|
+
second request upon running through the middleware stack, Rails detected that it
|
15
|
+
was executing through an instance of an unloaded class. Boom!
|
6
16
|
|
7
|
-
|
17
|
+
This gem provides a delegator class that can wrap the unloadable middleware. Instead
|
18
|
+
of registering the middleware itself, you can use an instance of the delegator,
|
19
|
+
which being a gem managed by bundler will not be unloaded between requests.
|
8
20
|
|
9
|
-
|
21
|
+
In environments where `cache_classes` is `true`, the delegator steps out of the way
|
22
|
+
and adds the delegated middleware directly onto the stack. When `false`, it holds
|
23
|
+
onto any passed configuration and instantiates a new middleware instance for each
|
24
|
+
request.
|
10
25
|
|
11
|
-
```ruby
|
12
|
-
gem 'rails_middleware_delegator'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install rails_middleware_delegator
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
```
|
30
|
+
Rails.application.config.middleware.use RailsMiddlewareDelegator.new('MyMiddleware')
|
31
|
+
```
|
30
32
|
|
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
|
|
33
34
|
## Contributing
|
34
35
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at
|
36
|
+
Bug reports and pull requests are welcome on GitHub at
|
37
|
+
https://github.com/[USERNAME]/rails_middleware_delegator. This project is intended
|
38
|
+
to be a safe, welcoming space for collaboration, and contributors are expected to
|
39
|
+
adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
40
|
|
37
41
|
|
38
42
|
## License
|
39
43
|
|
40
|
-
The gem is available as open source under the terms of the
|
44
|
+
The gem is available as open source under the terms of the
|
45
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
41
46
|
|