mongo_session_store 2.0.0 → 3.0.0.beta.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 +7 -0
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/.rubocop.yml +43 -0
- data/.travis.yml +37 -0
- data/CHANGELOG.md +49 -0
- data/Dangerfile +1 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/README.md +106 -43
- data/Rakefile +90 -0
- data/gemfiles/rails-4.0-mongo.gemfile +9 -0
- data/gemfiles/rails-4.0-mongoid.gemfile +9 -0
- data/gemfiles/rails-4.1-mongo.gemfile +9 -0
- data/gemfiles/rails-4.1-mongoid.gemfile +9 -0
- data/gemfiles/rails-4.2-mongo.gemfile +9 -0
- data/gemfiles/rails-4.2-mongoid.gemfile +9 -0
- data/lib/mongo_session_store.rb +27 -1
- data/lib/mongo_session_store/mongo_store.rb +102 -0
- data/lib/mongo_session_store/mongo_store_base.rb +65 -0
- data/lib/mongo_session_store/mongoid_store.rb +52 -0
- data/lib/mongo_session_store/version.rb +3 -0
- data/mongo_session_store.gemspec +25 -0
- data/perf/benchmark.rb +101 -0
- data/spec/.rubocop.yml +4 -0
- data/spec/integrations/devise_spec.rb +109 -0
- data/spec/lib/mongo_session_store/mongo_store/session_spec.rb +247 -0
- data/spec/lib/mongo_session_store/mongo_store_base_spec.rb +269 -0
- data/spec/lib/mongo_session_store/mongo_store_spec.rb +13 -0
- data/spec/lib/mongo_session_store/mongoid_store/session_spec.rb +82 -0
- data/spec/lib/mongo_session_store/mongoid_store_spec.rb +13 -0
- data/spec/lib/mongo_session_store_spec.rb +64 -0
- data/spec/rails_helper.rb +19 -0
- data/spec/spec_helper.rb +53 -0
- data/spec/support/apps/rails_4.0_app/Rakefile +6 -0
- data/spec/support/apps/rails_4.0_app/app/controllers/application_controller.rb +5 -0
- data/spec/support/apps/rails_4.0_app/app/controllers/home_controller.rb +4 -0
- data/spec/support/apps/rails_4.0_app/app/models/user.rb +5 -0
- data/spec/support/apps/rails_4.0_app/app/views/home/index.html.erb +10 -0
- data/spec/support/apps/rails_4.0_app/app/views/layouts/application.html.erb +17 -0
- data/spec/support/apps/rails_4.0_app/bin/bundle +3 -0
- data/spec/support/apps/rails_4.0_app/bin/rails +4 -0
- data/spec/support/apps/rails_4.0_app/bin/rake +4 -0
- data/spec/support/apps/rails_4.0_app/config.ru +4 -0
- data/spec/support/apps/rails_4.0_app/config/application.rb +11 -0
- data/spec/support/apps/rails_4.0_app/config/boot.rb +4 -0
- data/spec/support/apps/rails_4.0_app/config/database.yml +11 -0
- data/spec/support/apps/rails_4.0_app/config/environment.rb +5 -0
- data/spec/support/apps/rails_4.0_app/config/environments/development.rb +12 -0
- data/spec/support/apps/rails_4.0_app/config/environments/test.rb +19 -0
- data/spec/support/apps/rails_4.0_app/config/initializers/devise.rb +254 -0
- data/spec/support/apps/rails_4.0_app/config/initializers/secret_token.rb +12 -0
- data/spec/support/apps/rails_4.0_app/config/initializers/session_store.rb +1 -0
- data/spec/support/apps/rails_4.0_app/config/locales/devise.en.yml +59 -0
- data/spec/support/apps/rails_4.0_app/config/locales/en.yml +23 -0
- data/spec/support/apps/rails_4.0_app/config/mongo.yml +11 -0
- data/spec/support/apps/rails_4.0_app/config/mongoid.yml +13 -0
- data/spec/support/apps/rails_4.0_app/config/routes.rb +4 -0
- data/spec/support/apps/rails_4.0_app/db/migrate/20140301171212_add_devise_users.rb +11 -0
- data/spec/support/apps/rails_4.0_app/db/schema.rb +25 -0
- data/spec/support/apps/rails_4.0_app/db/seeds.rb +7 -0
- data/spec/support/apps/rails_4.0_app/lib/assets/.keep +0 -0
- data/spec/support/apps/rails_4.0_app/lib/tasks/.keep +0 -0
- data/spec/support/apps/rails_4.0_app/log/.keep +0 -0
- data/spec/support/apps/rails_4.0_app/public/404.html +58 -0
- data/spec/support/apps/rails_4.0_app/public/422.html +58 -0
- data/spec/support/apps/rails_4.0_app/public/500.html +57 -0
- data/spec/support/apps/rails_4.0_app/public/favicon.ico +0 -0
- data/spec/support/apps/rails_4.0_app/public/robots.txt +5 -0
- data/spec/support/apps/rails_4.1_app/Rakefile +3 -0
- data/spec/support/apps/rails_4.1_app/app/controllers/application_controller.rb +5 -0
- data/spec/support/apps/rails_4.1_app/app/controllers/home_controller.rb +4 -0
- data/spec/support/apps/rails_4.1_app/app/models/user.rb +5 -0
- data/spec/support/apps/rails_4.1_app/app/views/home/index.html.erb +10 -0
- data/spec/support/apps/rails_4.1_app/app/views/layouts/application.html.erb +17 -0
- data/spec/support/apps/rails_4.1_app/bin/bundle +3 -0
- data/spec/support/apps/rails_4.1_app/bin/rails +4 -0
- data/spec/support/apps/rails_4.1_app/bin/rake +4 -0
- data/spec/support/apps/rails_4.1_app/config.ru +2 -0
- data/spec/support/apps/rails_4.1_app/config/application.rb +11 -0
- data/spec/support/apps/rails_4.1_app/config/boot.rb +4 -0
- data/spec/support/apps/rails_4.1_app/config/database.yml +11 -0
- data/spec/support/apps/rails_4.1_app/config/environment.rb +5 -0
- data/spec/support/apps/rails_4.1_app/config/environments/development.rb +12 -0
- data/spec/support/apps/rails_4.1_app/config/environments/test.rb +19 -0
- data/spec/support/apps/rails_4.1_app/config/initializers/devise.rb +254 -0
- data/spec/support/apps/rails_4.1_app/config/initializers/session_store.rb +1 -0
- data/spec/support/apps/rails_4.1_app/config/locales/devise.en.yml +59 -0
- data/spec/support/apps/rails_4.1_app/config/locales/en.yml +23 -0
- data/spec/support/apps/rails_4.1_app/config/mongo.yml +11 -0
- data/spec/support/apps/rails_4.1_app/config/mongoid.yml +13 -0
- data/spec/support/apps/rails_4.1_app/config/routes.rb +4 -0
- data/spec/support/apps/rails_4.1_app/config/secrets.yml +22 -0
- data/spec/support/apps/rails_4.1_app/db/migrate/20140301171212_add_devise_users.rb +11 -0
- data/spec/support/apps/rails_4.1_app/db/schema.rb +25 -0
- data/spec/support/apps/rails_4.1_app/db/seeds.rb +7 -0
- data/spec/support/apps/rails_4.1_app/lib/assets/.keep +0 -0
- data/spec/support/apps/rails_4.1_app/lib/tasks/.keep +0 -0
- data/spec/support/apps/rails_4.1_app/log/.keep +0 -0
- data/spec/support/apps/rails_4.1_app/public/404.html +67 -0
- data/spec/support/apps/rails_4.1_app/public/422.html +67 -0
- data/spec/support/apps/rails_4.1_app/public/500.html +66 -0
- data/spec/support/apps/rails_4.1_app/public/favicon.ico +0 -0
- data/spec/support/apps/rails_4.1_app/public/robots.txt +5 -0
- data/spec/support/apps/rails_4.2_app/Rakefile +2 -0
- data/spec/support/apps/rails_4.2_app/app/controllers/application_controller.rb +5 -0
- data/spec/support/apps/rails_4.2_app/app/controllers/home_controller.rb +4 -0
- data/spec/support/apps/rails_4.2_app/app/models/user.rb +5 -0
- data/spec/support/apps/rails_4.2_app/app/views/home/index.html.erb +10 -0
- data/spec/support/apps/rails_4.2_app/app/views/layouts/application.html.erb +15 -0
- data/spec/support/apps/rails_4.2_app/bin/bundle +3 -0
- data/spec/support/apps/rails_4.2_app/bin/rails +8 -0
- data/spec/support/apps/rails_4.2_app/bin/rake +4 -0
- data/spec/support/apps/rails_4.2_app/config.ru +4 -0
- data/spec/support/apps/rails_4.2_app/config/application.rb +11 -0
- data/spec/support/apps/rails_4.2_app/config/boot.rb +3 -0
- data/spec/support/apps/rails_4.2_app/config/database.yml +11 -0
- data/spec/support/apps/rails_4.2_app/config/environment.rb +5 -0
- data/spec/support/apps/rails_4.2_app/config/environments/development.rb +12 -0
- data/spec/support/apps/rails_4.2_app/config/environments/test.rb +19 -0
- data/spec/support/apps/rails_4.2_app/config/initializers/devise.rb +254 -0
- data/spec/support/apps/rails_4.2_app/config/initializers/session_store.rb +1 -0
- data/spec/support/apps/rails_4.2_app/config/locales/en.yml +23 -0
- data/spec/support/apps/rails_4.2_app/config/mongo.yml +11 -0
- data/spec/support/apps/rails_4.2_app/config/mongoid.yml +13 -0
- data/spec/support/apps/rails_4.2_app/config/routes.rb +4 -0
- data/spec/support/apps/rails_4.2_app/config/secrets.yml +22 -0
- data/spec/support/apps/rails_4.2_app/db/migrate/20140301171212_add_devise_users.rb +11 -0
- data/spec/support/apps/rails_4.2_app/db/schema.rb +25 -0
- data/spec/support/apps/rails_4.2_app/db/seeds.rb +7 -0
- data/spec/support/helpers/session_id_helper.rb +5 -0
- data/spec/support/helpers/test_database_helper.rb +22 -0
- metadata +360 -92
- data/lib/mongo_session_store/mongo_mapper.rb +0 -60
- data/lib/mongo_session_store/mongoid.rb +0 -59
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 51de0786fae5ce817ce7a6560c1c1e7155bb6e61
|
4
|
+
data.tar.gz: 755e1e50213bd4dd4920f606e1b900cab0fe4aba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1112e027b5b5591b44fdbad4e19c216c71aad8aa5657d018384cd69c90a1ec3860181f66fac6c1182c10f63cac2d91086effba229df907a2178f8005682644a5
|
7
|
+
data.tar.gz: c34f5a35cc48c92e385d8ead77fa875b7a345a3752d64d409206bb2080cff74c71cf4d18247dfa1b8ac6a9942bd4b81dbe6f37c532f9b1b99a690df89fe814c3
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.0
|
3
|
+
Include:
|
4
|
+
- "Gemfile"
|
5
|
+
Exclude:
|
6
|
+
- "gemfiles/vendor/**/*"
|
7
|
+
- "perf/benchmark.rb"
|
8
|
+
- "spec/support/apps/**/*"
|
9
|
+
- "tmp/**/*"
|
10
|
+
- "vendor/**/*"
|
11
|
+
DisplayCopNames: true
|
12
|
+
UseCache: true
|
13
|
+
CacheRootDirectory: ./tmp
|
14
|
+
|
15
|
+
Style/Documentation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/StringLiterals:
|
19
|
+
EnforcedStyle: double_quotes
|
20
|
+
|
21
|
+
Style/StringLiteralsInInterpolation:
|
22
|
+
EnforcedStyle: double_quotes
|
23
|
+
|
24
|
+
Style/AlignParameters:
|
25
|
+
EnforcedStyle: with_fixed_indentation
|
26
|
+
|
27
|
+
Style/MultilineOperationIndentation:
|
28
|
+
EnforcedStyle: indented
|
29
|
+
|
30
|
+
Style/AlignHash:
|
31
|
+
EnforcedLastArgumentHashStyle: ignore_implicit
|
32
|
+
|
33
|
+
Style/HashSyntax:
|
34
|
+
EnforcedStyle: hash_rockets
|
35
|
+
|
36
|
+
Style/IndentArray:
|
37
|
+
EnforcedStyle: consistent
|
38
|
+
|
39
|
+
Style/FormatString:
|
40
|
+
EnforcedStyle: sprintf
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
Max: 15
|
data/.travis.yml
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
cache: bundler
|
4
|
+
|
5
|
+
rvm:
|
6
|
+
- 2.3.1
|
7
|
+
- 2.1.10
|
8
|
+
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/rails-4.0-mongo.gemfile
|
11
|
+
- gemfiles/rails-4.0-mongoid.gemfile
|
12
|
+
- gemfiles/rails-4.1-mongo.gemfile
|
13
|
+
- gemfiles/rails-4.1-mongoid.gemfile
|
14
|
+
- gemfiles/rails-4.2-mongo.gemfile
|
15
|
+
- gemfiles/rails-4.2-mongoid.gemfile
|
16
|
+
|
17
|
+
matrix:
|
18
|
+
fast_finish: true
|
19
|
+
include:
|
20
|
+
- rvm: 2.3.1
|
21
|
+
gemfile: gemfiles/rails-4.2-mongo.gemfile
|
22
|
+
script: bundle exec rubocop
|
23
|
+
- rvm: 2.3.1
|
24
|
+
gemfile: gemfiles/rails-4.2-mongo.gemfile
|
25
|
+
script: bundle exec danger
|
26
|
+
|
27
|
+
services: mongodb
|
28
|
+
|
29
|
+
addons:
|
30
|
+
apt:
|
31
|
+
sources:
|
32
|
+
- mongodb-3.2-precise
|
33
|
+
packages:
|
34
|
+
- mongodb-org-server
|
35
|
+
|
36
|
+
script:
|
37
|
+
- bundle exec rake test
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 3.0.0 (unreleased)
|
4
|
+
|
5
|
+
* Drop Ruby 1.8, 1.9 and 2.0 support - [@tombruijn](https://github.com/tombruijn).
|
6
|
+
* Drop explicit MongoMapper support - [@tombruijn](https://github.com/tombruijn).
|
7
|
+
* Drop MongoDB version 2 support - [@brianhempel](https://github.com/brianhempel).
|
8
|
+
* Support MongoDB version 3 - [@brianhempel](https://github.com/brianhempel).
|
9
|
+
* Update Mongo Ruby driver support for more recent versions - [@brianhempel](https://github.com/brianhempel), [@tombruijn](https://github.com/tombruijn).
|
10
|
+
* Update Mongoid support for more recent versions - [@brianhempel](https://github.com/brianhempel), [@tombruijn](https://github.com/tombruijn).
|
11
|
+
* Add Mongo Ruby driver session store support - [@brianhempel](https://github.com/brianhempel).
|
12
|
+
* Add Rails 4 support - [@brianhempel](https://github.com/brianhempel).
|
13
|
+
* Remove explicit Rails 3 support - [@tombruijn](https://github.com/tombruijn).
|
14
|
+
* Move session data packing and unpacking to session models. This allows queried documents to unpack session data themselves - [@tombruijn](https://github.com/tombruijn).
|
15
|
+
* Test more internal code - [@tombruijn](https://github.com/tombruijn).
|
16
|
+
* Allow for easier custom classes and expanded behavior of Mongoid and Mongo session stores - [@tombruijn](https://github.com/tombruijn).
|
17
|
+
* [#24](https://github.com/mongoid/mongo_session_store/pull/24): Add Danger, PR linter - [@tombruijn](https://github.com/tombruijn), [@dblock](https://github.com/dblock).
|
18
|
+
* [#27](https://github.com/mongoid/mongo_session_store/pull/27): Run tests against Ruby 2.3.1 and MongoDB 3.2 only - [@dblock](https://github.com/dblock).
|
19
|
+
* [#29](https://github.com/mongoid/mongo_session_store/pull/29): Use rails default session id generation - [@tombruijn](https://github.com/tombruijn).
|
20
|
+
* Your contribution here.
|
21
|
+
|
22
|
+
## 2.0.0
|
23
|
+
|
24
|
+
* Fix MongoMapper indexes - [@nmerouze](https://github.com/nmerouze).
|
25
|
+
* Add Rails 3 support for Mongoid - [@nmerouze](https://github.com/nmerouze).
|
26
|
+
* Add Rails 3 support for MongoMapper - [@nmerouze](https://github.com/nmerouze).
|
27
|
+
* Support MongoMapper 0.7.5 - [@hsbt](https://github.com/hsbt).
|
28
|
+
* Fix issue where ActionPack expects `set_session` to return the (new) session_id when session is created successfully - [@memuller](https://github.com/memuller).
|
29
|
+
|
30
|
+
## 1.1.2
|
31
|
+
|
32
|
+
* Generate a new session document if the current session document doesn't exist - [@shingara](https://github.com/shingara).
|
33
|
+
|
34
|
+
## 1.1.1
|
35
|
+
|
36
|
+
* Fix `updated_at` index for MongoMapper session documents - [@nmerouze](https://github.com/nmerouze).
|
37
|
+
|
38
|
+
## 1.1.0
|
39
|
+
|
40
|
+
* Add Mongoid support - [@nmerouze](https://github.com/nmerouze).
|
41
|
+
|
42
|
+
## 1.0.1
|
43
|
+
|
44
|
+
* Add gemspec and specify actionpack dependency - [@nmerouze](https://github.com/nmerouze).
|
45
|
+
|
46
|
+
## 1.0.0
|
47
|
+
|
48
|
+
* Initial version of the gem - [@tpitale](https://github.com/tpitale), [@compressed](https://github.com/compressed).
|
49
|
+
* MongoMapper session store support - [@tpitale](https://github.com/tpitale), [@compressed](https://github.com/compressed).
|
data/Dangerfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
danger.import_dangerfile(gem: "mongoid-danger")
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2016 Tom de Bruijn
|
2
|
+
Copyright (c) 2011-2015 Brian Hempel
|
3
|
+
Copyright (c) 2010 Nicolas Mérouze
|
4
|
+
Copyright (c) 2009 Chris Brickley
|
5
|
+
Copyright (c) 2009 Tony Pitale
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
8
|
+
this software and associated documentation files (the "Software"), to deal in
|
9
|
+
the Software without restriction, including without limitation the rights to
|
10
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
11
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
12
|
+
so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
15
|
+
copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,74 +1,137 @@
|
|
1
1
|
# MongoSessionStore
|
2
2
|
|
3
|
+
[](https://travis-ci.org/mongoid/mongo_session_store)
|
4
|
+
[](http://badge.fury.io/rb/mongo_session_store)
|
5
|
+
[](https://codeclimate.com/github/mongoid/mongo_session_store)
|
6
|
+
|
3
7
|
## Description
|
4
8
|
|
5
|
-
|
9
|
+
MongoSessionStore is a [Rails][rails]-compatible session store for
|
10
|
+
[MongoDB][mongodb] using either [Mongoid][mongoid] or the [MongoDB Ruby
|
11
|
+
Driver][mongo]. It also allows for custom Mongo session store that works with
|
12
|
+
any (or no!) Mongo ODM.
|
13
|
+
|
14
|
+
MongoSessionStore version 3 is compatible with Rails 4.0 through 4.2. For Rails
|
15
|
+
3 support please check out issue [#17][issue-rails3] for options and let us
|
16
|
+
know if you need support.
|
6
17
|
|
7
18
|
## Installation
|
8
19
|
|
9
|
-
|
20
|
+
Add the `mongo_session_store` gem to your `Gemfile`.
|
21
|
+
Use either the `mongo` or `mongoid` gems in combination with this gem.
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# Gemfile
|
25
|
+
|
26
|
+
gem "mongoid"
|
27
|
+
# or gem "mongo"
|
28
|
+
gem "mongo_session_store"
|
29
|
+
```
|
30
|
+
|
31
|
+
Configure the session store in the session_store initializer in your Rails
|
32
|
+
project.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
# config/initializers/session_store.rb
|
36
|
+
|
37
|
+
# Mongoid
|
38
|
+
MyApp::Application.config.session_store :mongoid_store
|
39
|
+
|
40
|
+
# MongoDB Ruby Driver/anything else
|
41
|
+
MongoStore::Session.database = Mongo::Client.new(["127.0.0.1:27017"], database: "my_app_development")
|
42
|
+
MyApp::Application.config.session_store :mongo_store
|
43
|
+
```
|
44
|
+
|
45
|
+
## Configuration
|
46
|
+
|
47
|
+
By default, the sessions will be stored in the "sessions" collection in
|
48
|
+
MongoDB. If you want to use a different collection, you can set that in the
|
49
|
+
session_store initializer.
|
10
50
|
|
11
|
-
|
51
|
+
```ruby
|
52
|
+
# config/initializers/session_store.rb
|
53
|
+
MongoSessionStore.collection_name = "client_sessions"
|
54
|
+
```
|
12
55
|
|
13
|
-
|
56
|
+
## Usage
|
14
57
|
|
15
|
-
|
58
|
+
By default nothing has to be done outside the [installation](#installation) of
|
59
|
+
the gem.
|
16
60
|
|
17
|
-
|
61
|
+
It's possible to query your sessions.
|
18
62
|
|
19
|
-
|
63
|
+
```ruby
|
64
|
+
# Mongoid
|
65
|
+
MongoidStore::Session.where(:updated_at.gt => 2.days.ago)
|
20
66
|
|
21
|
-
|
22
|
-
|
67
|
+
# MongoDB Ruby Driver
|
68
|
+
MongoStore::Session.where("updated_at" => { "$gt" => 2.days.ago })
|
69
|
+
```
|
23
70
|
|
24
|
-
|
71
|
+
## Development
|
25
72
|
|
26
|
-
|
27
|
-
ActionController::Base.session_store = :mongo_mapper_store
|
73
|
+
### Testing
|
28
74
|
|
29
|
-
|
75
|
+
To run the tests for a specific store. You must first set a `BUNDLE_GEMFILE` in
|
76
|
+
the environment.
|
30
77
|
|
31
|
-
|
78
|
+
```sh
|
79
|
+
bundle exec rake
|
80
|
+
```
|
32
81
|
|
33
|
-
|
34
|
-
gem "mongo_session_store"
|
82
|
+
Examples:
|
35
83
|
|
36
|
-
|
84
|
+
```sh
|
85
|
+
BUNDLE_GEMFILE=gemfiles/rails-4.0-mongo.gemfile bundle exec rake
|
86
|
+
BUNDLE_GEMFILE=gemfiles/rails-4.0-mongoid.gemfile bundle exec rake
|
87
|
+
BUNDLE_GEMFILE=gemfiles/rails-4.1-mongo.gemfile bundle exec rake
|
88
|
+
BUNDLE_GEMFILE=gemfiles/rails-4.1-mongoid.gemfile bundle exec rake
|
89
|
+
BUNDLE_GEMFILE=gemfiles/rails-4.2-mongo.gemfile bundle exec rake
|
90
|
+
BUNDLE_GEMFILE=gemfiles/rails-4.2-mongoid.gemfile bundle exec rake
|
91
|
+
```
|
37
92
|
|
38
|
-
|
39
|
-
|
93
|
+
### Performance benchmark
|
94
|
+
|
95
|
+
The repository includes a performance benchmark. It runs against all available
|
96
|
+
included stores and outputs the results.
|
97
|
+
|
98
|
+
```
|
99
|
+
bundle exec ruby perf/benchmark.rb
|
100
|
+
```
|
101
|
+
|
102
|
+
### Releases
|
103
|
+
|
104
|
+
To create a new release checkout the `master` branch and make sure it's in the
|
105
|
+
right state to release. Run the `release` Rake task and follow the
|
106
|
+
instructions.
|
107
|
+
|
108
|
+
```
|
109
|
+
bundle exec rake release
|
110
|
+
```
|
40
111
|
|
41
112
|
## Contributors
|
42
113
|
|
114
|
+
MongoSessionStore started as a fork of the DataMapper session store, modified
|
115
|
+
to work with MongoMapper, Mongoid and the Mongo Ruby Driver.
|
116
|
+
|
117
|
+
Much thanks to all contributors:
|
118
|
+
|
43
119
|
* Nicolas Mérouze
|
44
120
|
* Chris Brickley
|
45
121
|
* Tony Pitale
|
46
122
|
* Nicola Racco
|
47
123
|
* Matt Powell
|
124
|
+
* Ryan Fitzgerald
|
125
|
+
* Brian Hempel
|
126
|
+
* Tom de Bruijn
|
48
127
|
|
49
128
|
## License
|
50
129
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
60
|
-
copies of the Software, and to permit persons to whom the
|
61
|
-
Software is furnished to do so, subject to the following
|
62
|
-
conditions:
|
63
|
-
|
64
|
-
The above copyright notice and this permission notice shall be
|
65
|
-
included in all copies or substantial portions of the Software.
|
66
|
-
|
67
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
68
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
69
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
70
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
71
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
72
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
73
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
74
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
130
|
+
Released under the MIT license. See the [LICENSE](LICENSE) file.
|
131
|
+
|
132
|
+
[mongodb]: https://www.mongodb.com/
|
133
|
+
[mongo]: https://github.com/mongodb/mongo-ruby-driver
|
134
|
+
[mongoid]: http://mongoid.org/
|
135
|
+
[rails]: http://rubyonrails.org/
|
136
|
+
|
137
|
+
[issue-rails3]: https://github.com/mongoid/mongo_session_store/issues/17
|
data/Rakefile
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require "rspec/core/rake_task"
|
2
|
+
|
3
|
+
desc "Prepare MongoDB connection"
|
4
|
+
task :mongo_prepare do
|
5
|
+
# Wait for mongod to start on Travis.
|
6
|
+
# From the Mongo Ruby Driver gem.
|
7
|
+
if ENV["TRAVIS"]
|
8
|
+
require "mongo"
|
9
|
+
client = Mongo::Client.new(["127.0.0.1:27017"])
|
10
|
+
begin
|
11
|
+
puts "Waiting for MongoDB..."
|
12
|
+
client.command("ismaster" => 1)
|
13
|
+
rescue Mongo::Error::NoServerAvailable
|
14
|
+
sleep 2
|
15
|
+
# 1 Retry
|
16
|
+
puts "Waiting for MongoDB..."
|
17
|
+
client.cluster.scan!
|
18
|
+
client.command(Mongo::Error::NoServerAvailable)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Run the mongo_session_store gem test suite."
|
24
|
+
RSpec::Core::RakeTask.new :test => :mongo_prepare
|
25
|
+
|
26
|
+
desc "Release a new version of the mongo_session_store gem"
|
27
|
+
task :release do
|
28
|
+
GEMSPEC_NAME = "mongo_session_store"
|
29
|
+
GEM_NAME = "mongo_session_store"
|
30
|
+
VERSION_FILE = "lib/mongo_session_store/version.rb"
|
31
|
+
|
32
|
+
def reload_version
|
33
|
+
if defined?(MongoSessionStore::VERSION)
|
34
|
+
MongoSessionStore.send(:remove_const, :VERSION)
|
35
|
+
end
|
36
|
+
load File.expand_path(VERSION_FILE)
|
37
|
+
end
|
38
|
+
|
39
|
+
raise "$EDITOR should be set" unless ENV["EDITOR"]
|
40
|
+
|
41
|
+
def build_and_push_gem
|
42
|
+
puts '# Building gem'
|
43
|
+
puts `gem build #{GEMSPEC_NAME}.gemspec`
|
44
|
+
puts '# Publishing Gem'
|
45
|
+
puts `gem push #{GEM_NAME}-#{gem_version}.gem`
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_repo
|
49
|
+
puts `git commit -am "Bump to #{version} [ci skip]"`
|
50
|
+
begin
|
51
|
+
puts `git tag #{version}`
|
52
|
+
puts `git push origin #{version}`
|
53
|
+
puts `git push origin master`
|
54
|
+
rescue
|
55
|
+
raise %(Tag: "#{version}" already exists)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def changes
|
60
|
+
git_status_to_array(`git status -s -u`)
|
61
|
+
end
|
62
|
+
|
63
|
+
def gem_version
|
64
|
+
MongoSessionStore::VERSION
|
65
|
+
end
|
66
|
+
|
67
|
+
def version
|
68
|
+
@version ||= "v" << gem_version
|
69
|
+
end
|
70
|
+
|
71
|
+
def git_status_to_array(changes)
|
72
|
+
changes.split("\n").map { |change| change.gsub(/^.. /, "") }
|
73
|
+
end
|
74
|
+
|
75
|
+
raise "Branch should hold no uncommitted file change)" unless changes.empty?
|
76
|
+
|
77
|
+
reload_version
|
78
|
+
|
79
|
+
system("$EDITOR #{VERSION_FILE}")
|
80
|
+
if changes.include?(VERSION_FILE)
|
81
|
+
reload_version
|
82
|
+
build_and_push_gem
|
83
|
+
update_repo
|
84
|
+
else
|
85
|
+
raise "Actually change the version in: #{VERSION_FILE}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Default task for Rake. Runs test suite."
|
90
|
+
task :default => :test
|