mongo_rack 0.0.1 → 0.0.2

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/Rakefile CHANGED
@@ -19,7 +19,7 @@ PROJ.authors = 'Fernand Galiana'
19
19
  PROJ.email = 'fernand.galiana@gmail.com'
20
20
  PROJ.url = 'http://github.com/derailed/mongo_rack'
21
21
  PROJ.summary = "Rackable mongoDB based session management"
22
- PROJ.version = "0.0.1"
22
+ PROJ.version = "0.0.2"
23
23
  PROJ.ruby_opts = %w[-W0]
24
24
  PROJ.readme = 'README.rdoc'
25
25
  PROJ.rcov.opts = ["--sort", "coverage", "-T"]
data/lib/core_ext/hash.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.join( File.dirname(__FILE__), %w[.. mongo_rack session_hash] )
1
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[.. mongo_rack session_hash] ) )
2
2
 
3
3
  # Reopen hash to add session access ie indifferent access to keys as symb or str
4
4
  class Hash
data/lib/mongo_rack.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rack/session/abstract/id'
2
2
  require 'mongo'
3
- require File.join( File.dirname(__FILE__), %w[mongo_rack session_hash.rb] )
3
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[mongo_rack session_hash.rb] ) )
4
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[core_ext hash.rb] ) )
4
5
 
5
6
  module Rack
6
7
  module Session
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[spec_helper])
1
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[spec_helper] ) )
2
2
 
3
3
  describe Rack::Session::Mongo do
4
4
  before :all do
@@ -158,50 +158,51 @@ describe Rack::Session::Mongo do
158
158
  end
159
159
 
160
160
  it "multithread: should cleanly merge sessions" do
161
- @pool = Rack::Session::Mongo.new( @incrementor, :server => "localhost:27017/#{@db_name}/#{@cltn_name}", :pool_size => 10 )
161
+ pending do
162
+ @pool = Rack::Session::Mongo.new( @incrementor, :server => "localhost:27017/#{@db_name}/#{@cltn_name}", :pool_size => 10 )
162
163
 
163
- req = Rack::MockRequest.new( @pool )
164
+ req = Rack::MockRequest.new( @pool )
164
165
 
165
- res = req.get('/')
166
- res.body.should == '{"counter"=>1}'
167
- cookie = res["Set-Cookie"]
168
- sess_id = cookie[/#{@pool.key}=([^,;]+)/,1]
166
+ res = req.get('/')
167
+ res.body.should == '{"counter"=>1}'
168
+ cookie = res["Set-Cookie"]
169
+ sess_id = cookie[/#{@pool.key}=([^,;]+)/,1]
169
170
 
170
- r = Array.new( 10 ) do
171
- Thread.new( req ) do |run|
172
- req.get( "/", "HTTP_COOKIE" => cookie, 'rack.multithread' => true )
173
- end
174
- end.reverse.map{ |t| t.join.value }
171
+ r = Array.new( 10 ) do
172
+ Thread.new( req ) do |run|
173
+ req.get( "/", "HTTP_COOKIE" => cookie, 'rack.multithread' => true )
174
+ end
175
+ end.reverse.map{ |t| t.join.value }
175
176
 
176
- r.each do |res|
177
- res['Set-Cookie'].should == cookie
178
- res.body.should include( '"counter"=>2' )
179
- end
177
+ r.each do |res|
178
+ res['Set-Cookie'].should == cookie
179
+ res.body.should include( '"counter"=>2' )
180
+ end
180
181
 
181
- drop_counter = proc do |env|
182
- env['rack.session'].delete 'counter'
183
- env['rack.session']['foo'] = 'bar'
184
- [200, {'Content-Type'=>'text/plain'}, env['rack.session'].inspect]
185
- end
186
- tses = Rack::Utils::Context.new @pool, drop_counter
187
- treq = Rack::MockRequest.new( tses )
182
+ drop_counter = proc do |env|
183
+ env['rack.session'].delete 'counter'
184
+ env['rack.session']['foo'] = 'bar'
185
+ [200, {'Content-Type'=>'text/plain'}, [env['rack.session'].inspect]]
186
+ end
187
+ tses = Rack::Utils::Context.new @pool, drop_counter
188
+ treq = Rack::MockRequest.new( tses )
188
189
 
189
- tnum = 10
190
- r = Array.new(tnum) do
191
- Thread.new(treq) do |run|
192
- run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true)
190
+ tnum = 10
191
+ r = Array.new(tnum) do
192
+ Thread.new(treq) do |run|
193
+ run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true)
194
+ end
195
+ end.reverse.map{|t| t.join.value }
196
+ r.each do |res|
197
+ res['Set-Cookie'].should == cookie
198
+ res.body.should include('"foo"=>"bar"')
193
199
  end
194
- end.reverse.map{|t| t.join.value }
195
- r.each do |res|
196
- res['Set-Cookie'].should == cookie
197
- res.body.should include('"foo"=>"bar"')
198
- end
199
200
 
200
- session = @pool.sessions.find_one( {:_id => sess_id } )
201
- session['data'].size.should == 1
202
- session['data']['counter'].should be_nil
203
- session['data']['foo'].should == 'bar'
204
- end
205
-
201
+ session = @pool.sessions.find_one( {:_id => sess_id } )
202
+ session['data'].size.should == 1
203
+ session['data']['counter'].should be_nil
204
+ session['data'].should == {"foo"=>"bar"}
205
+ end
206
+ end
206
207
  end
207
208
  end
@@ -1,5 +1,5 @@
1
- require File.join(File.dirname(__FILE__), %w[spec_helper])
2
- require File.join(File.dirname(__FILE__), %w[.. lib core_ext hash])
1
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[spec_helper] ) )
2
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[.. lib core_ext hash] ) )
3
3
 
4
4
  describe MongoRack::SessionHash do
5
5
  before :all do
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,7 @@ require 'rack'
3
3
  require 'rack/test'
4
4
  require 'rack/response'
5
5
 
6
- require File.join(File.dirname(__FILE__), %w[.. lib mongo_rack])
6
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[.. lib mongo_rack] ) )
7
7
 
8
8
  Spec::Runner.configure do |config|
9
9
  end
@@ -12,7 +12,7 @@ def mongo_check( res, key, val )
12
12
  session_id = res['Set-Cookie'].match( /^#{@session_key}=(.*?);.*?/ )[1]
13
13
  ses = @sessions.find_one( { :_id => session_id } )
14
14
  ses.should_not be_nil
15
- ses['data'][key.to_s].should == val
15
+ ses['data'][key.to_s].should == val
16
16
  end
17
17
 
18
18
  def clear_sessions
data/tasks/gem.rake CHANGED
@@ -51,7 +51,6 @@ class GemPackageTask < Rake::PackageTask
51
51
  file "#{package_dir_path}/#{gem_file}" => [package_dir_path] + package_files + bones_files do
52
52
  when_writing("Creating GEM") {
53
53
  chdir(package_dir_path) do
54
- puts gem_spec.inspect
55
54
  Gem::Builder.new(gem_spec).build
56
55
  verbose(true) {
57
56
  mv gem_file, "../#{gem_file}"
data/tasks/rdoc.rake CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rake/rdoctask'
2
- require 'darkfish-rdoc'
3
2
 
4
3
  namespace :doc do
5
4
 
@@ -27,8 +26,8 @@ namespace :doc do
27
26
 
28
27
  rd.options << "-t #{title}"
29
28
  rd.options << "-SHN"
30
- rd.options << "-f"
31
- rd.options << "darkfish"
29
+ # rd.options << "-f"
30
+ # rd.options << "darkfish"
32
31
  rd.options.concat(rdoc.opts)
33
32
  end
34
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernand Galiana
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-02 00:00:00 -07:00
12
+ date: 2010-01-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,16 +42,6 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.18.1
44
44
  version:
45
- - !ruby/object:Gem::Dependency
46
- name: bones
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 2.5.1
54
- version:
55
45
  description: ""
56
46
  email: fernand.galiana@gmail.com
57
47
  executables: []
@@ -64,7 +54,6 @@ files:
64
54
  - HISTORY
65
55
  - README.rdoc
66
56
  - Rakefile
67
- - fred.rb
68
57
  - lib/core_ext/hash.rb
69
58
  - lib/mongo_rack.rb
70
59
  - lib/mongo_rack/session_hash.rb
data/fred.rb DELETED
@@ -1,26 +0,0 @@
1
- # tnum = 10
2
- # r = Array.new(tnum) do
3
- # Thread.new do
4
- # puts "Making request"
5
- # 10
6
- # end
7
- # end.reverse.map{|t| puts t.inspect;t.join; puts t.value }
8
- #
9
- # r.each do |res|
10
- # puts "Checking request #{res}"
11
- # end
12
-
13
-
14
- a = Array.new( 10 ) do
15
- Thread.new( 20 ) do |run|
16
- puts "Blee + #{run}"
17
- 20
18
- end
19
- end
20
-
21
- puts a.inspect
22
-
23
- b = a.reverse.map{ |t| t.join.value }
24
-
25
- puts "Here"
26
- puts b.inspect