mongoid_session_store 1.1.2 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Ryan Fitzgerald
1
+ Copyright 2011 YOURNAME
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -3,7 +3,7 @@
3
3
  store rails 3 sessions in mongoDB using mongoid.
4
4
 
5
5
  == Installation
6
- This gem only works with rails 3 and mongoid 2.0
6
+ This gem supports rails 3, rails 3.1 and mongoid 2.0
7
7
 
8
8
  gem install mongoid_session_store
9
9
 
@@ -11,8 +11,8 @@ This gem only works with rails 3 and mongoid 2.0
11
11
 
12
12
  In your Gemfile:
13
13
 
14
- gem "mongoid", :git => "http://github.com/mongoid/mongoid.git"
15
- gem "bson_ext", "1.0.4"
14
+ gem "mongoid", "~> 2.0"
15
+ gem "bson_ext", "~> 1.3"
16
16
  gem "mongoid_session_store"
17
17
 
18
18
  In the session_store initializer (config/initializers/session_store.rb) you can comment out every line as
@@ -39,4 +39,4 @@ Mongoid Session Store comes with a rake task to clear out the sessions it stores
39
39
 
40
40
  == Copyright
41
41
 
42
- Copyright (c) 2010 Ryan Fitzgerald. See LICENSE for details.
42
+ Copyright (c) 2010 Ryan Fitzgerald. See MIT-LICENSE for details.
data/Rakefile CHANGED
@@ -1,55 +1,35 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'bundler'
4
-
1
+ #!/usr/bin/env rake
5
2
  begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "mongoid_session_store"
9
- gem.summary = %Q{store rails 3 sessions in mongoDB}
10
- gem.description = %Q{store rails 3 sessions in mongoDB}
11
- gem.email = "ryan@codebrewstudios.com"
12
- gem.homepage = "https://github.com/codebrew/mongoid_session_store"
13
- gem.authors = ["Ryan Fitzgerald"]
14
- gem.add_bundler_dependencies
15
-
16
- gem.files.exclude 'example/**/*'
17
- end
18
- Jeweler::GemcutterTasks.new
3
+ require 'bundler/setup'
4
+ require 'bundler/gem_tasks'
19
5
  rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
- end
22
-
23
- require 'rake/testtask'
24
- Rake::TestTask.new(:test) do |test|
25
- test.libs << 'lib' << 'test'
26
- test.pattern = 'test/**/test_*.rb'
27
- test.verbose = true
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
28
7
  end
29
-
30
8
  begin
31
- require 'rcov/rcovtask'
32
- Rcov::RcovTask.new do |test|
33
- test.libs << 'test'
34
- test.pattern = 'test/**/test_*.rb'
35
- test.verbose = true
36
- end
9
+ require 'rdoc/task'
37
10
  rescue LoadError
38
- task :rcov do
39
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
- end
11
+ require 'rdoc/rdoc'
12
+ require 'rake/rdoctask'
13
+ RDoc::Task = Rake::RDocTask
41
14
  end
42
15
 
43
- task :test
16
+ RDoc::Task.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'MongoidSessionStore'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README.rdoc')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
44
23
 
45
- task :default => :test
46
24
 
47
- require 'rake/rdoctask'
48
- Rake::RDocTask.new do |rdoc|
49
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
25
+ require 'rake/testtask'
50
26
 
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = "mongoid_session_store #{version}"
53
- rdoc.rdoc_files.include('README*')
54
- rdoc.rdoc_files.include('lib/**/*.rb')
27
+ Rake::TestTask.new(:test) do |t|
28
+ t.libs << 'lib'
29
+ t.libs << 'test'
30
+ t.pattern = 'test/**/*_test.rb'
31
+ t.verbose = false
55
32
  end
33
+
34
+
35
+ task :default => :test
@@ -1,3 +1,16 @@
1
- $:.unshift File.dirname(__FILE__)
1
+ require 'rails'
2
2
 
3
- require "mongoid_session_store/railtie"
3
+ module MongoidSessionStore
4
+
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ load "tasks/mongoid_session_store_tasks.rake"
8
+ end
9
+
10
+ initializer "setup mongoid session store" do |app|
11
+ require 'mongoid_session_store/mongoid_store'
12
+ app.config.session_store :mongoid_store
13
+ end
14
+ end
15
+
16
+ end
@@ -4,22 +4,20 @@ module ActionDispatch
4
4
 
5
5
  class Session
6
6
  include Mongoid::Document
7
- include Mongoid::Timestamps
8
-
7
+
9
8
  store_in :sessions
10
9
 
11
10
  identity :type => String
12
11
 
13
12
  field :data, :type => String, :default => [Marshal.dump({})].pack("m*")
14
-
15
- index :updated_at
16
13
  end
17
14
 
18
15
  # The class used for session storage.
19
16
  cattr_accessor :session_class
20
17
  self.session_class = Session
21
-
22
- SESSION_RECORD_KEY = 'rack.session.record'.freeze
18
+
19
+ SESSION_RECORD_KEY = 'rack.session.record'
20
+ ENV_SESSION_OPTIONS_KEY = Rack::Session::Abstract::ENV_SESSION_OPTIONS_KEY
23
21
 
24
22
  private
25
23
 
@@ -30,7 +28,7 @@ module ActionDispatch
30
28
  [sid, unpack(session.data)]
31
29
  end
32
30
 
33
- def set_session(env, sid, session_data)
31
+ def set_session(env, sid, session_data, options = nil)
34
32
  record = get_session_model(env, sid)
35
33
  record.data = pack(session_data)
36
34
 
@@ -44,10 +42,19 @@ module ActionDispatch
44
42
  @@session_class.find_or_create_by(:id => id)
45
43
  end
46
44
 
47
- def destroy(env)
45
+ # def destroy(env)
46
+ # if sid = current_session_id(env)
47
+ # find_session(sid).destroy
48
+ # end
49
+ # end
50
+
51
+ def destroy_session(env, session_id, options)
48
52
  if sid = current_session_id(env)
49
- find_session(sid).destroy
53
+ get_session_model(env, sid).destroy
54
+ env[SESSION_RECORD_KEY] = nil
50
55
  end
56
+
57
+ generate_sid unless options[:drop]
51
58
  end
52
59
 
53
60
  def get_session_model(env, sid)
metadata CHANGED
@@ -1,133 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_session_store
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.2
4
+ prerelease: 6
5
+ version: 2.0.0.beta1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Fitzgerald
9
+ - Code Brew Studios
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2011-03-25 00:00:00 -04:00
14
+ date: 2011-06-21 00:00:00 -04:00
14
15
  default_executable:
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
- name: actionpack
18
+ name: rails
18
19
  requirement: &id001 !ruby/object:Gem::Requirement
19
20
  none: false
20
21
  requirements:
21
- - - ~>
22
+ - - ">="
22
23
  - !ruby/object:Gem::Version
23
24
  version: 3.0.0
24
25
  type: :runtime
25
26
  prerelease: false
26
27
  version_requirements: *id001
27
28
  - !ruby/object:Gem::Dependency
28
- name: activemodel
29
+ name: mongoid
29
30
  requirement: &id002 !ruby/object:Gem::Requirement
30
31
  none: false
31
32
  requirements:
32
33
  - - ~>
33
34
  - !ruby/object:Gem::Version
34
- version: 3.0.0
35
+ version: 2.0.0
35
36
  type: :runtime
36
37
  prerelease: false
37
38
  version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: mongoid
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 2.0.0.pre
46
- type: :runtime
47
- prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
57
- type: :development
58
- prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: actionpack
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 3.0.0
68
- type: :runtime
69
- prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: activemodel
73
- requirement: &id006 !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 3.0.0
79
- type: :runtime
80
- prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: mongoid
84
- requirement: &id007 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: 2.0.0.pre
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: jeweler
95
- requirement: &id008 !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
101
- type: :development
102
- prerelease: false
103
- version_requirements: *id008
104
- description: store rails 3 sessions in mongoDB
105
- email: ryan@codebrewstudios.com
39
+ description: Store rails 3 sessions in mongoDB.
40
+ email:
41
+ - ryan@codebrewstudios.com
106
42
  executables: []
107
43
 
108
44
  extensions: []
109
45
 
110
- extra_rdoc_files:
111
- - LICENSE
112
- - README.rdoc
46
+ extra_rdoc_files: []
47
+
113
48
  files:
114
- - .document
115
- - Gemfile
116
- - Gemfile.lock
117
- - LICENSE
118
- - README.rdoc
119
- - Rakefile
120
- - VERSION
121
- - example/.gitignore
122
- - lib/mongoid_session_store.rb
123
49
  - lib/mongoid_session_store/mongoid_store.rb
124
- - lib/mongoid_session_store/railtie.rb
125
- - lib/mongoid_session_store/railties/sessions.rake
126
- - mongoid_session_store.gemspec
127
- - test/helper.rb
128
- - test/test_mongoid_session_store.rb
50
+ - lib/mongoid_session_store.rb
51
+ - lib/tasks/mongoid_session_store_tasks.rake
52
+ - MIT-LICENSE
53
+ - Rakefile
54
+ - README.rdoc
129
55
  has_rdoc: true
130
- homepage: https://github.com/codebrew/mongoid_session_store
56
+ homepage: http://github.com/codebrew/mongoid_session_store
131
57
  licenses: []
132
58
 
133
59
  post_install_message:
@@ -140,20 +66,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
66
  requirements:
141
67
  - - ">="
142
68
  - !ruby/object:Gem::Version
69
+ hash: 545154848138212417
70
+ segments:
71
+ - 0
143
72
  version: "0"
144
73
  required_rubygems_version: !ruby/object:Gem::Requirement
145
74
  none: false
146
75
  requirements:
147
- - - ">="
76
+ - - ">"
148
77
  - !ruby/object:Gem::Version
149
- version: "0"
78
+ version: 1.3.1
150
79
  requirements: []
151
80
 
152
81
  rubyforge_project:
153
82
  rubygems_version: 1.6.2
154
83
  signing_key:
155
84
  specification_version: 3
156
- summary: store rails 3 sessions in mongoDB
157
- test_files:
158
- - test/helper.rb
159
- - test/test_mongoid_session_store.rb
85
+ summary: Store rails 3 sessions in mongoDB.
86
+ test_files: []
87
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/Gemfile DELETED
@@ -1,19 +0,0 @@
1
- # A sample Gemfile
2
- source :gemcutter
3
-
4
- #
5
- # gem "rails"
6
-
7
- gem 'actionpack', "~> 3.0.0"
8
- gem 'activemodel', "~> 3.0.0"
9
-
10
- gem "mongoid", "~> 2.0.0.pre"
11
- # gem "mongoid", :git => "http://github.com/mongoid/mongoid.git"
12
-
13
- group :test do
14
- gem 'shoulda'
15
- end
16
-
17
- group :development do
18
- gem 'jeweler'
19
- end
data/Gemfile.lock DELETED
@@ -1,55 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- abstract (1.0.0)
5
- actionpack (3.0.4)
6
- activemodel (= 3.0.4)
7
- activesupport (= 3.0.4)
8
- builder (~> 2.1.2)
9
- erubis (~> 2.6.6)
10
- i18n (~> 0.4)
11
- rack (~> 1.2.1)
12
- rack-mount (~> 0.6.13)
13
- rack-test (~> 0.5.7)
14
- tzinfo (~> 0.3.23)
15
- activemodel (3.0.4)
16
- activesupport (= 3.0.4)
17
- builder (~> 2.1.2)
18
- i18n (~> 0.4)
19
- activesupport (3.0.4)
20
- bson (1.2.1)
21
- builder (2.1.2)
22
- erubis (2.6.6)
23
- abstract (>= 1.0.0)
24
- git (1.2.5)
25
- i18n (0.5.0)
26
- jeweler (1.5.2)
27
- bundler (~> 1.0.0)
28
- git (>= 1.2.5)
29
- rake
30
- mongo (1.2.1)
31
- bson (>= 1.2.1)
32
- mongoid (2.0.0.rc.7)
33
- activemodel (~> 3.0)
34
- mongo (~> 1.2)
35
- tzinfo (~> 0.3.22)
36
- will_paginate (~> 3.0.pre)
37
- rack (1.2.1)
38
- rack-mount (0.6.13)
39
- rack (>= 1.0.0)
40
- rack-test (0.5.7)
41
- rack (>= 1.0)
42
- rake (0.8.7)
43
- shoulda (2.11.3)
44
- tzinfo (0.3.24)
45
- will_paginate (3.0.pre2)
46
-
47
- PLATFORMS
48
- ruby
49
-
50
- DEPENDENCIES
51
- actionpack (~> 3.0.0)
52
- activemodel (~> 3.0.0)
53
- jeweler
54
- mongoid (~> 2.0.0.pre)
55
- shoulda
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.2
data/example/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- .bundle
2
- db/*.sqlite3
3
- log/*.log
4
- tmp/**/*
@@ -1,17 +0,0 @@
1
- require 'mongoid_session_store'
2
- require "rails"
3
-
4
- module MongoidSessionStore
5
-
6
- class Railtie < Rails::Railtie
7
- rake_tasks do
8
- load "mongoid_session_store/railties/sessions.rake"
9
- end
10
-
11
- initializer "setup mongoid session store" do |app|
12
- require 'mongoid_session_store/mongoid_store'
13
- app.config.session_store :mongoid_store
14
- end
15
- end
16
-
17
- end
@@ -1,78 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{mongoid_session_store}
8
- s.version = "1.1.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Ryan Fitzgerald"]
12
- s.date = %q{2011-03-25}
13
- s.description = %q{store rails 3 sessions in mongoDB}
14
- s.email = %q{ryan@codebrewstudios.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "example/.gitignore",
28
- "lib/mongoid_session_store.rb",
29
- "lib/mongoid_session_store/mongoid_store.rb",
30
- "lib/mongoid_session_store/railtie.rb",
31
- "lib/mongoid_session_store/railties/sessions.rake",
32
- "mongoid_session_store.gemspec",
33
- "test/helper.rb",
34
- "test/test_mongoid_session_store.rb"
35
- ]
36
- s.homepage = %q{https://github.com/codebrew/mongoid_session_store}
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.6.2}
39
- s.summary = %q{store rails 3 sessions in mongoDB}
40
- s.test_files = [
41
- "test/helper.rb",
42
- "test/test_mongoid_session_store.rb"
43
- ]
44
-
45
- if s.respond_to? :specification_version then
46
- s.specification_version = 3
47
-
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0"])
50
- s.add_runtime_dependency(%q<activemodel>, ["~> 3.0.0"])
51
- s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.0.pre"])
52
- s.add_development_dependency(%q<jeweler>, [">= 0"])
53
- s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0"])
54
- s.add_runtime_dependency(%q<activemodel>, ["~> 3.0.0"])
55
- s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.0.pre"])
56
- s.add_development_dependency(%q<jeweler>, [">= 0"])
57
- else
58
- s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
59
- s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
60
- s.add_dependency(%q<mongoid>, ["~> 2.0.0.pre"])
61
- s.add_dependency(%q<jeweler>, [">= 0"])
62
- s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
63
- s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
64
- s.add_dependency(%q<mongoid>, ["~> 2.0.0.pre"])
65
- s.add_dependency(%q<jeweler>, [">= 0"])
66
- end
67
- else
68
- s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
69
- s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
70
- s.add_dependency(%q<mongoid>, ["~> 2.0.0.pre"])
71
- s.add_dependency(%q<jeweler>, [">= 0"])
72
- s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
73
- s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
74
- s.add_dependency(%q<mongoid>, ["~> 2.0.0.pre"])
75
- s.add_dependency(%q<jeweler>, [">= 0"])
76
- end
77
- end
78
-
data/test/helper.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- require 'mongoid'
6
-
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
- $LOAD_PATH.unshift(File.dirname(__FILE__))
9
-
10
- Mongoid.configure do |config|
11
- name = "mongoid_test"
12
- host = "localhost"
13
- config.master = Mongo::Connection.new.db(name)
14
- # config.logger = nil
15
- # config.slaves = [
16
- # Mongo::Connection.new(host, 27018, :slave_ok => true).db(name)
17
- # ]
18
- end
19
-
20
- require 'mongoid_session_store'
21
-
22
- class Test::Unit::TestCase
23
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
2
-
3
- class TestMongoidSessionStore < Test::Unit::TestCase
4
- def setup
5
- Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
6
- end
7
-
8
- should "probably rename this file and start testing for real" do
9
- flunk "hey buddy, you should probably rename this file and start testing for real"
10
- end
11
- end