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 CHANGED
@@ -12,6 +12,7 @@ lib/bundler/man
12
12
  pkg
13
13
  rdoc
14
14
  spec/reports
15
+ spec/log
15
16
  test/tmp
16
17
  test/version_tmp
17
18
  tmp
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # CurrentRequest
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
- ### CurrentRequest can help
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 CurrentRequest
24
+ include Rack::Curent
25
25
 
26
26
  def current_url
27
27
  "#{current_request.protocol}://#{current_request.host}/#{current_request.path}
@@ -6,3 +6,5 @@ module Rack::Current
6
6
  Thread.current[:_current_request]
7
7
  end
8
8
  end
9
+
10
+ require 'rack-current/railtie' if defined?(Rails)
@@ -0,0 +1,7 @@
1
+ module Rack::Current
2
+ class Railtie < Rails::Railtie
3
+ initializer 'rack-current.inject_middleware' do |app|
4
+ app.middleware.use Rack::Current::Middleware
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module CurrentRequest
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_development_dependency "rake"
21
21
  gem.add_development_dependency "rspec"
22
+ gem.add_development_dependency 'rails', '~> 3.0'
22
23
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'rack-current'
2
+
3
3
  describe Rack::Current::Middleware do
4
4
  describe "inside an application's middleware stack" do
5
5
  include Rack::Current
@@ -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
@@ -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.0.0
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: 4398315886198829610
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: 4398315886198829610
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