rack-current 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +3 -3
- data/lib/rack-current.rb +2 -0
- data/lib/rack-current/railtie.rb +7 -0
- data/lib/rack-current/version.rb +1 -1
- data/rack-current.gemspec +1 -0
- data/spec/current_request_spec.rb +1 -1
- data/spec/railtie_spec.rb +19 -0
- data/spec/spec_helper.rb +2 -1
- metadata +22 -3
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Rack::Current
|
2
2
|
|
3
3
|
Sometimes, in the coures of human events, you need to access the currently executing http request, and you
|
4
4
|
don't always have the luxury of passing it around, especially when you're working with frameworks that manage
|
5
5
|
the lifecycle of objects for you, or you want to include functionality from a module. That module might not have
|
6
6
|
a clean way of getting a reference to the request object.
|
7
7
|
|
8
|
-
###
|
8
|
+
### Rack::Current can help
|
9
9
|
|
10
10
|
CurrentRequest stores the current request in a thread local so that you can access it from anywhere inside the
|
11
11
|
request stack.
|
@@ -21,7 +21,7 @@ stack, and not, say, like a background job (like sending email) that is fired of
|
|
21
21
|
### Example
|
22
22
|
|
23
23
|
class Foo
|
24
|
-
include
|
24
|
+
include Rack::Curent
|
25
25
|
|
26
26
|
def current_url
|
27
27
|
"#{current_request.protocol}://#{current_request.host}/#{current_request.path}
|
data/lib/rack-current.rb
CHANGED
data/lib/rack-current/version.rb
CHANGED
data/rack-current.gemspec
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rails'
|
4
|
+
require 'action_controller/railtie'
|
5
|
+
require 'rack-current/railtie'
|
6
|
+
|
7
|
+
|
8
|
+
describe "When loaded into a Rails application" do
|
9
|
+
before do
|
10
|
+
@app = Class.new(Rails::Application) do
|
11
|
+
config.active_support.deprecation = :ignore
|
12
|
+
end
|
13
|
+
@app.initialize!
|
14
|
+
end
|
15
|
+
|
16
|
+
it "injects the current request middleware into the application stack" do
|
17
|
+
@app.middleware.should include Rack::Current::Middleware
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
$:.unshift File.expand_path '../../lib', __FILE__
|
1
|
+
$:.unshift File.expand_path '../../lib', __FILE__
|
2
|
+
require 'rack-current'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-current
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.0'
|
62
78
|
description: Get the Currently running Rack::Request from anywhere inside the request-thread
|
63
79
|
email:
|
64
80
|
- info@thefrontside.net
|
@@ -73,9 +89,11 @@ files:
|
|
73
89
|
- Rakefile
|
74
90
|
- lib/rack-current.rb
|
75
91
|
- lib/rack-current/middleware.rb
|
92
|
+
- lib/rack-current/railtie.rb
|
76
93
|
- lib/rack-current/version.rb
|
77
94
|
- rack-current.gemspec
|
78
95
|
- spec/current_request_spec.rb
|
96
|
+
- spec/railtie_spec.rb
|
79
97
|
- spec/spec_helper.rb
|
80
98
|
homepage: https://github.com/thefrontside/rack-current
|
81
99
|
licenses: []
|
@@ -91,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
109
|
version: '0'
|
92
110
|
segments:
|
93
111
|
- 0
|
94
|
-
hash:
|
112
|
+
hash: 1434395879416086802
|
95
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
114
|
none: false
|
97
115
|
requirements:
|
@@ -100,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
118
|
version: '0'
|
101
119
|
segments:
|
102
120
|
- 0
|
103
|
-
hash:
|
121
|
+
hash: 1434395879416086802
|
104
122
|
requirements: []
|
105
123
|
rubyforge_project:
|
106
124
|
rubygems_version: 1.8.24
|
@@ -109,4 +127,5 @@ specification_version: 3
|
|
109
127
|
summary: Reach out and grab the current Rack::Request just by including CurrentRequest
|
110
128
|
test_files:
|
111
129
|
- spec/current_request_spec.rb
|
130
|
+
- spec/railtie_spec.rb
|
112
131
|
- spec/spec_helper.rb
|