mongo_session_store 3.3.0 → 3.3.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.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,80 @@
1
+ # Contributing to MongoSessionStore
2
+
3
+ ## Test Environment
4
+
5
+ Start MongoDB with this script:
6
+
7
+ ```text
8
+ script/testenv
9
+ ```
10
+
11
+ ## Testing
12
+
13
+ To run the tests for a specific store. You must first set a `BUNDLE_GEMFILE` in the environment.
14
+
15
+ You can also use Docker, see the section below this one.
16
+
17
+ ```sh
18
+ bundle exec rake
19
+ ```
20
+
21
+ Examples:
22
+
23
+ ```sh
24
+ BUNDLE_GEMFILE=gemfiles/rails-5.0-mongo.gemfile bundle exec rake
25
+ BUNDLE_GEMFILE=gemfiles/rails-5.0-mongoid.gemfile bundle exec rake
26
+ BUNDLE_GEMFILE=gemfiles/rails-5.1-mongo.gemfile bundle exec rake
27
+ BUNDLE_GEMFILE=gemfiles/rails-5.1-mongoid.gemfile bundle exec rake
28
+ BUNDLE_GEMFILE=gemfiles/rails-5.2-mongo.gemfile bundle exec rake
29
+ BUNDLE_GEMFILE=gemfiles/rails-5.2-mongoid.gemfile bundle exec rake
30
+ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile bundle exec rake
31
+ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongoid.gemfile bundle exec rake
32
+ ```
33
+
34
+ For Rails 6.1 and newer, use `gemfiles/rails-current-mongo.gemfile` or `gemfiles/rails-current-mongoid.gemfile` with `RAILS_VERSION` and, for Mongoid, `MONGOID_VERSION` constraints:
35
+
36
+ ```sh
37
+ RAILS_VERSION='~> 7.2.0' MONGOID_VERSION='~> 9.0' BUNDLE_GEMFILE=gemfiles/rails-current-mongoid.gemfile bundle exec rake test
38
+ ```
39
+
40
+ For Rails 8.0, also set `SQLITE_VERSION='~> 2.1'`; the dedicated Rails 8.1 Gemfiles already select SQLite 2.
41
+
42
+ Set `MONGODB_HOST` and `MONGODB_PORT` to use a non-default test server. The default is `127.0.0.1:27017`.
43
+
44
+ ### Docker Testing
45
+
46
+ To run tests in a Docker container with a specific Ruby version and gemfile:
47
+
48
+ ```sh
49
+ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
50
+ ```
51
+
52
+ The `BUNDLE_GEMFILE` environment variable is required. Ruby version defaults to 3.4 but can be customized:
53
+
54
+ ```sh
55
+ RUBY_VERSION=2.7 BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
56
+ ```
57
+
58
+ ## Performance Benchmark
59
+
60
+ The repository includes a performance benchmark. It runs against all available included stores and outputs the results.
61
+
62
+ ```sh
63
+ bundle exec ruby perf/benchmark.rb
64
+ ```
65
+
66
+ ## Releases
67
+
68
+ To create a new release checkout the `master` branch and make sure it's in the right state to release. Run the `release` Rake task and follow the instructions.
69
+
70
+ ```sh
71
+ bundle exec rake release
72
+ ```
73
+
74
+ Run `bundle exec rake lint` on MRI Ruby 3.3 or newer to check Ruby, Markdown, YAML, and spelling, and add reviewed project vocabulary to `.spellcheck.txt`.
75
+
76
+ [mongodb]: https://www.mongodb.com/
77
+ [mongo]: https://github.com/mongodb/mongo-ruby-driver
78
+ [mongoid]: https://www.mongodb.com/docs/mongoid/current/
79
+ [rails]: https://rubyonrails.org/
80
+ [issue-rails3]: https://github.com/mongoid/mongo_session_store/issues/17
data/Gemfile CHANGED
@@ -2,4 +2,13 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rubocop", "1.92.0"
5
+ group :development, :test do
6
+ if RUBY_ENGINE == "ruby" && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3")
7
+ gem "rubocop", "~> 1.92"
8
+ gem "rubocop-md", "~> 3.0", :require => false
9
+ gem "rubocop-prose", "~> 0.2", :require => false
10
+ gem "rubocop-rake", "~> 0.7", :require => false
11
+ gem "rubocop-spellcheck", "~> 0.2", :require => false
12
+ gem "rubocop-yaml", "~> 0.1.0", :require => false
13
+ end
14
+ end
data/Gemfile.danger CHANGED
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "danger"
4
- gem "danger-changelog"
5
- gem "danger-pr-comment"
3
+ gem "danger", "~> 9.6", ">= 9.6.2", require: false
4
+ gem "danger-changelog", "~> 0.10", require: false
5
+ gem "danger-pr-comment", "~> 0.3", require: false
data/README.md CHANGED
@@ -1,24 +1,17 @@
1
1
  # MongoSessionStore
2
2
 
3
- [![CI](https://github.com/mongoid/mongo_session_store/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mongoid/mongo_session_store/actions/workflows/ci.yml?query=branch%3Amain)
4
- [![Gem Version](https://badge.fury.io/rb/mongo_session_store.svg)](http://badge.fury.io/rb/mongo_session_store)
5
- [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongo_session_store/badge.svg?branch=main)](https://coveralls.io/github/mongoid/mongo_session_store?branch=main)
3
+ [![CI](https://github.com/mongoid/mongo_session_store/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mongoid/mongo_session_store/actions/workflows/ci.yml?query=branch%3Amain) [![Gem Version](https://badge.fury.io/rb/mongo_session_store.svg)](https://badge.fury.io/rb/mongo_session_store) [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongo_session_store/badge.svg?branch=main)](https://coveralls.io/github/mongoid/mongo_session_store?branch=main)
6
4
 
7
5
  ## Description
8
6
 
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.
7
+ MongoSessionStore is a [Rails][rails]-compatible session store for [MongoDB][mongodb] using either [Mongoid][mongoid] or the [MongoDB Ruby
8
+ Driver][mongo]. It also allows for custom Mongo session store that works with any (or no!) Mongo ODM.
13
9
 
14
- MongoSessionStore version 3 is compatible with Rails 5.0+. For Rails
15
- 3 support please check out issue [#17][issue-rails3] for options and let us
16
- know if you need support.
10
+ MongoSessionStore version 3 is compatible with Rails 5.0+. For Rails 3 support please check out issue [#17][issue-rails3] for options and let us know if you need support.
17
11
 
18
12
  ## Installation
19
13
 
20
- Add the `mongo_session_store` gem to your `Gemfile`.
21
- Use either the `mongo` or `mongoid` gems in combination with this gem.
14
+ Add the `mongo_session_store` gem to your `Gemfile`. Use either the `mongo` or `mongoid` gems in combination with this gem.
22
15
 
23
16
  ```ruby
24
17
  # Gemfile
@@ -28,8 +21,7 @@ gem "mongoid"
28
21
  gem "mongo_session_store"
29
22
  ```
30
23
 
31
- Configure the session store in the session_store initializer in your Rails
32
- project.
24
+ Configure the session store in the session_store initializer in your Rails project.
33
25
 
34
26
  ```ruby
35
27
  # config/initializers/session_store.rb
@@ -38,15 +30,13 @@ project.
38
30
  MyApp::Application.config.session_store :mongoid_store
39
31
 
40
32
  # MongoDB Ruby Driver/anything else
41
- MongoStore::Session.database = Mongo::Client.new(["127.0.0.1:27017"], database: "my_app_development")
33
+ MongoStore::Session.database = Mongo::Client.new(["127.0.0.1:27017"], :database => "my_app_development")
42
34
  MyApp::Application.config.session_store :mongo_store
43
35
  ```
44
36
 
45
37
  ## Configuration
46
38
 
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.
39
+ By default, the sessions will be stored in the "sessions" collection in MongoDB. If you want to use a different collection, you can set that in the session_store initializer.
50
40
 
51
41
  ```ruby
52
42
  # config/initializers/session_store.rb
@@ -55,8 +45,7 @@ MongoSessionStore.collection_name = "client_sessions"
55
45
 
56
46
  ## Usage
57
47
 
58
- By default nothing has to be done outside the [installation](#installation) of
59
- the gem.
48
+ By default nothing has to be done outside the [installation](#installation) of the gem.
60
49
 
61
50
  It's possible to query your sessions.
62
51
 
@@ -68,7 +57,7 @@ MongoidStore::Session.where(:updated_at.gt => 2.days.ago)
68
57
  MongoStore::Session.where("updated_at" => { "$gt" => 2.days.ago })
69
58
  ```
70
59
 
71
- ### Serializable session values
60
+ ### Serializable Session Values
72
61
 
73
62
  Both adapters serialize session data with Ruby's `Marshal`. Store serializable values such as strings, numbers, arrays, and hashes, not requests, input streams, or uploaded files. Serialization errors are raised rather than silently discarding data.
74
63
 
@@ -80,16 +69,16 @@ session[:search] = params.require(:search).permit(:query, :sort).to_h
80
69
 
81
70
  This stores the permitted values without the request context. It does not make uploaded files or other non-serializable values serializable; store a durable identifier for those instead.
82
71
 
83
- ### Deleting stale sessions
72
+ ### Deleting Stale Sessions
84
73
 
85
74
  Sessions are not automatically expired or deleted. To opt in to cleanup, call the store's `delete_stale_sessions` method with an explicit `Time` cutoff:
86
75
 
87
76
  ```ruby
88
77
  # Mongoid
89
- MongoidStore.delete_stale_sessions(before: 1.week.ago)
78
+ MongoidStore.delete_stale_sessions(:before => 1.week.ago)
90
79
 
91
80
  # MongoDB Ruby Driver
92
- MongoStore.delete_stale_sessions(before: 1.week.ago)
81
+ MongoStore.delete_stale_sessions(:before => 1.week.ago)
93
82
  ```
94
83
 
95
84
  The method returns the number deleted and uses the configured session collection. It performs a bulk database deletion without loading session data or running model callbacks. Only records whose `updated_at` is strictly earlier than the cutoff are deleted; records at the cutoff or without a timestamp are retained. Invalid cutoffs raise `ArgumentError`, and database errors propagate to the caller.
@@ -102,87 +91,13 @@ bin/rails runner 'MongoidStore.delete_stale_sessions(before: 1.week.ago)'
102
91
 
103
92
  Deleting a session signs that session out on its next request. Cleanup is not cookie expiration or a guarantee of inactivity-based logout: `updated_at` tracks session saves, and a request that does not save the session may not refresh it. No default maximum age, background job, or TTL index is installed. For large collections, consider creating an ordinary index on `updated_at` as part of your database setup.
104
93
 
105
- ## Development
94
+ ## Contributing
106
95
 
107
- ### Test environment
108
-
109
- Start MongoDB with this script:
110
-
111
- ```
112
- script/testenv
113
- ```
114
-
115
- ### Testing
116
-
117
- To run the tests for a specific store. You must first set a `BUNDLE_GEMFILE` in
118
- the environment.
119
-
120
- You can also use Docker, see the section below this one.
121
-
122
- ```sh
123
- bundle exec rake
124
- ```
125
-
126
- Examples:
127
-
128
- ```sh
129
- BUNDLE_GEMFILE=gemfiles/rails-5.0-mongo.gemfile bundle exec rake
130
- BUNDLE_GEMFILE=gemfiles/rails-5.0-mongoid.gemfile bundle exec rake
131
- BUNDLE_GEMFILE=gemfiles/rails-5.1-mongo.gemfile bundle exec rake
132
- BUNDLE_GEMFILE=gemfiles/rails-5.1-mongoid.gemfile bundle exec rake
133
- BUNDLE_GEMFILE=gemfiles/rails-5.2-mongo.gemfile bundle exec rake
134
- BUNDLE_GEMFILE=gemfiles/rails-5.2-mongoid.gemfile bundle exec rake
135
- BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile bundle exec rake
136
- BUNDLE_GEMFILE=gemfiles/rails-6.0-mongoid.gemfile bundle exec rake
137
- ```
138
-
139
- For Rails 6.1 and newer, use `gemfiles/rails-current-mongo.gemfile` or `gemfiles/rails-current-mongoid.gemfile` with `RAILS_VERSION` and, for Mongoid, `MONGOID_VERSION` constraints:
140
-
141
- ```sh
142
- RAILS_VERSION='~> 7.2.0' MONGOID_VERSION='~> 9.0' BUNDLE_GEMFILE=gemfiles/rails-current-mongoid.gemfile bundle exec rake test
143
- ```
144
-
145
- For Rails 8.0, also set `SQLITE_VERSION='~> 2.1'`; the dedicated Rails 8.1 Gemfiles already select SQLite 2.
146
-
147
- Set `MONGODB_HOST` and `MONGODB_PORT` to use a non-default test server. The default is `127.0.0.1:27017`.
148
-
149
- #### Docker testing
150
-
151
- To run tests in a Docker container with a specific Ruby version and gemfile:
152
-
153
- ```sh
154
- BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
155
- ```
156
-
157
- The `BUNDLE_GEMFILE` environment variable is required. Ruby version defaults to 3.4 but can be customized:
158
-
159
- ```sh
160
- RUBY_VERSION=2.7 BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
161
- ```
162
-
163
- ### Performance benchmark
164
-
165
- The repository includes a performance benchmark. It runs against all available
166
- included stores and outputs the results.
167
-
168
- ```
169
- bundle exec ruby perf/benchmark.rb
170
- ```
171
-
172
- ### Releases
173
-
174
- To create a new release checkout the `master` branch and make sure it's in the
175
- right state to release. Run the `release` Rake task and follow the
176
- instructions.
177
-
178
- ```
179
- bundle exec rake release
180
- ```
96
+ See [CONTRIBUTING.md](CONTRIBUTING.md), [CHANGELOG.md](CHANGELOG.md), and [RELEASING.md](RELEASING.md).
181
97
 
182
98
  ## Contributors
183
99
 
184
- MongoSessionStore started as a fork of the DataMapper session store, modified
185
- to work with MongoMapper, Mongoid and the Mongo Ruby Driver.
100
+ MongoSessionStore started as a fork of the DataMapper session store, modified to work with MongoMapper, Mongoid and the Mongo Ruby Driver.
186
101
 
187
102
  Much thanks to all contributors:
188
103
 
@@ -201,7 +116,7 @@ Released under the MIT license. See the [LICENSE](LICENSE) file.
201
116
 
202
117
  [mongodb]: https://www.mongodb.com/
203
118
  [mongo]: https://github.com/mongodb/mongo-ruby-driver
204
- [mongoid]: http://mongoid.org/
205
- [rails]: http://rubyonrails.org/
119
+ [mongoid]: https://www.mongodb.com/docs/mongoid/current/
120
+ [rails]: https://rubyonrails.org/
206
121
 
207
122
  [issue-rails3]: https://github.com/mongoid/mongo_session_store/issues/17
data/RELEASING.md CHANGED
@@ -1,37 +1,35 @@
1
- # Releasing
1
+ # Releasing MongoSessionStore
2
2
 
3
- Release from a clean local checkout of the upstream repository, not a fork. You need push access, RubyGems ownership with MFA, and an authenticated GitHub CLI.
3
+ Releases use [ruby-gem-release](https://github.com/dblock/ruby-gem-release) 0.9.0 through a manually dispatched [Release workflow](.github/workflows/release.yml). Keep the `ruby-gem-release` gem in [Gemfile](Gemfile) and the reusable workflow in `release.yml` pinned to the same version. The workflow publishes through RubyGems Trusted Publishing, so no RubyGems API key or one-time password is needed. It only runs from `main` in `mongoid/mongo_session_store`. The local Bundler `rake release`, `release:rubygem_push`, and `release:source_control_push` tasks are disabled.
4
4
 
5
- ## Prepare
5
+ ## One-Time Setup
6
6
 
7
- 1. Run `git switch main`, `git pull --ff-only`, and confirm that `origin` points to `mongoid/mongo_session_store`.
8
- 2. Choose the next semantic version, update `lib/mongo_session_store/version.rb`, and replace the unreleased changelog heading with the version and release date. Remove the contribution placeholder.
9
- 3. With MongoDB running, install dependencies and run `bundle exec rake test` using each supported adapter's `BUNDLE_GEMFILE`, for example `gemfiles/rails-6.0-mongo.gemfile` and `gemfiles/rails-6.0-mongoid.gemfile`. Run `bundle exec rubocop` with the default Gemfile.
10
- 4. Commit the preparation, push `main`, and wait for the complete GitHub Actions matrix to pass for that commit.
7
+ Before the first automated release, a maintainer must:
11
8
 
12
- ## Publish
9
+ 1. Create the GitHub environment `release` in `mongoid/mongo_session_store`, for example with `gh api --method PUT repos/mongoid/mongo_session_store/environments/release`, and restrict its deployment branches to `main`. Add required reviewers to require maintainer approval before publication.
10
+ 2. At [mongo_session_store's trusted publishers](https://rubygems.org/gems/mongo_session_store/trusted_publishers), add a GitHub Actions publisher with repository owner `mongoid`, repository `mongo_session_store`, workflow filename `release.yml`, environment `release`, and the separate workflow repository owner `dblock` and repository `ruby-gem-release`.
11
+ 3. Allow GitHub Actions to push release commits and `v*` tags to `main`. See the upstream [setup and permissions guidance](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/RELEASING.md#one-time-setup).
13
12
 
14
- Do not use the legacy `rake release` task: it assumes `master` and performs interactive edits. Build and publish the prepared version explicitly:
13
+ Verify the setup without publishing with a [dry run](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#dry-run), which never edits files, builds, pushes, or publishes:
15
14
 
16
15
  ```sh
17
- version=3.2.2 # Replace with the version being released.
18
- gem build mongo_session_store.gemspec
19
- git tag "v$version"
20
- git push origin "v$version"
21
- gem push "mongo_session_store-$version.gem"
16
+ gh workflow run release.yml --repo mongoid/mongo_session_store --ref main -f dry-run=true
22
17
  ```
23
18
 
24
- Enter a fresh RubyGems MFA code when prompted. Create a GitHub release from the same tag, using the matching changelog section as the release notes:
19
+ ## Prepare
20
+
21
+ Start with a clean, up-to-date `main` and verify that the latest [CI checks](https://github.com/mongoid/mongo_session_store/actions) pass. Follow semantic versioning: patch for fixes, minor for backward-compatible features, major for breaking changes. Check `VERSION` in [lib/mongo_session_store/version.rb](lib/mongo_session_store/version.rb) and the matching `(Next)` heading in [CHANGELOG.md](CHANGELOG.md), and change both in a pull request if needed, or pass a `version` override when dispatching. The workflow dates the `(Next)` heading using `YYYY/MM/DD` and removes the `* Your contribution here.` placeholder; a section without notes cannot be released.
22
+
23
+ Release automation requires MRI Ruby 3.3 or newer; the release dependency and tasks are skipped on older Ruby versions and JRuby. Release specs in [spec/release](spec/release) run the actual release tasks against a local fixture with the [ruby-gem-release RSpec helpers](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/testing.md), without contacting RubyGems or GitHub.
24
+
25
+ ## Publish
25
26
 
26
27
  ```sh
27
- gh release create "v$version" --repo mongoid/mongo_session_store \
28
- --verify-tag --title "$version" --notes-file /path/to/release-notes.md --latest
28
+ gh workflow run release.yml --repo mongoid/mongo_session_store --ref main
29
29
  ```
30
30
 
31
- Verify the exact version at `https://rubygems.org/gems/mongo_session_store/versions/VERSION` and inspect `gh release view "v$version" --repo mongoid/mongo_session_store` to confirm a published, non-draft release.
32
-
33
- If publication is interrupted, check the remote tag, RubyGems version, and GitHub release first. Resume only the missing step; never move a published tag or rebuild an already published version. If the gem push needs a new code, retry that command with `--otp CODE`.
31
+ Pass `-f version=x.y.z` to release a different version. Dispatching starts a real release; do not merge into `main` while it runs. The workflow prepares the release commit, starts MongoDB 8.0, runs lint and specs on Ruby 3.3, builds the gem, preserves recovery artifacts, publishes to RubyGems, pushes the release commit and `v` tag, and creates a GitHub Release with the changelog notes and the gem attached. It then increments the patch version, adds a new `(Next)` section, and pushes the next development commit. Verify the published version on [RubyGems](https://rubygems.org/gems/mongo_session_store), the tag, the [GitHub Release](https://github.com/mongoid/mongo_session_store/releases), and the next development commit.
34
32
 
35
- ## Next development version
33
+ ## Recover a Partial Release
36
34
 
37
- Increment the patch version in `lib/mongo_session_store/version.rb`, add a new `## (unreleased)` section with a contribution placeholder, and commit and push the changes to `main`. Remove the local built gem after successful publication.
35
+ Inspect the failed run, RubyGems, remote commits and tags, and the GitHub Release before retrying. Publication may have succeeded even if a later step failed. Never move a published tag or republish a version with different contents. Use the run's retained recovery artifacts and the upstream [recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#recovery-artifacts).
data/Rakefile CHANGED
@@ -23,68 +23,29 @@ end
23
23
  desc "Run the mongo_session_store gem test suite."
24
24
  RSpec::Core::RakeTask.new :test => :mongo_prepare
25
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"
26
+ require "bundler/gem_tasks"
31
27
 
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
- system "gem build #{GEMSPEC_NAME}.gemspec"
44
- puts "# Publishing Gem"
45
- system "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
28
+ if RUBY_ENGINE == "ruby" && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3") &&
29
+ Gem.loaded_specs.key?("ruby-gem-release")
30
+ require_relative "script/release"
31
+ MongoSessionStoreRelease.workflow.install_tasks
58
32
 
59
- def changes
60
- git_status_to_array(`git status -s -u`)
33
+ %w[release release:rubygem_push release:source_control_push].each do |name|
34
+ Rake::Task[name].clear
35
+ desc "Disabled; releases run through GitHub Actions, see RELEASING.md"
36
+ task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
61
37
  end
38
+ end
62
39
 
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
40
+ lint = RUBY_ENGINE == "ruby" && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3") &&
41
+ Gem.loaded_specs.key?("rubocop")
42
+ if lint
43
+ require "rubocop/rake_task"
44
+ RuboCop::RakeTask.new(:rubocop)
78
45
 
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
46
+ desc "Lint Ruby, Markdown, YAML, and spelling"
47
+ task :lint => :rubocop
87
48
  end
88
49
 
89
- desc "Default task for Rake. Runs test suite."
90
- task :default => :test
50
+ desc "Default task for Rake. Runs lint, where available, and the test suite."
51
+ task :default => (lint ? [:rubocop, :test] : [:test])
@@ -13,4 +13,9 @@ gem "benchmark"
13
13
  gem "ostruct"
14
14
  gem "simplecov", "~> 0.22", :require => false if ENV["COVERAGE"] == "true"
15
15
 
16
+ if RUBY_ENGINE == "ruby" && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3")
17
+ gem "commonmarker", "~> 2.10", :require => false
18
+ gem "ruby-gem-release", "0.9.0", :require => false
19
+ end
20
+
16
21
  gemspec :path => "../"
@@ -1,3 +1,3 @@
1
1
  module MongoSessionStore
2
- VERSION = "3.3.0".freeze
2
+ VERSION = "3.3.1".freeze
3
3
  end
@@ -7,7 +7,6 @@ Gem::Specification.new do |s|
7
7
  s.authors = ["Tom de Bruijn", "Brian Hempel", "Nicolas M\303\251rouze", "Tony Pitale", "Chris Brickley"]
8
8
  s.email = ["tom@tomdebruijn.com"]
9
9
  s.files = `git ls-files`.split("\n")
10
- s.test_files = `git ls-files -- {spec,perf}/*`.split("\n")
11
10
  s.homepage = "http://github.com/mongoid/mongo_session_store"
12
11
  s.license = "MIT"
13
12
  s.require_paths = ["lib"]
@@ -20,4 +19,5 @@ Gem::Specification.new do |s|
20
19
  s.add_development_dependency "capybara", ">= 2.15"
21
20
  s.add_development_dependency "rake"
22
21
  s.add_development_dependency "rspec-rails", ">= 4.0"
22
+ s.metadata["rubygems_mfa_required"] = "true"
23
23
  end
data/script/release.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ruby-gem-release/changelog"
4
+ require "ruby-gem-release/workflow/ruby_gem"
5
+
6
+ # Builds the ruby-gem-release workflow used by the Rakefile, the Release GitHub Actions workflow, and spec/release.
7
+ module MongoSessionStoreRelease
8
+ def self.workflow(**options)
9
+ RubyGemRelease::Workflow::RubyGem.new(
10
+ :version => RubyGemRelease::Version::RubyConstant.new(:path => "lib/mongo_session_store/version.rb",
11
+ :constant => "VERSION"),
12
+ :changelog => RubyGemRelease::Changelog::Intridea.new(:placeholder => "* Your contribution here."),
13
+ **options
14
+ )
15
+ end
16
+ end
data/spec/.rubocop.yml CHANGED
@@ -2,3 +2,9 @@ inherit_from: ../.rubocop.yml
2
2
 
3
3
  Layout/LineLength:
4
4
  Max: 100
5
+
6
+ Spellcheck:
7
+ DictionaryFiles:
8
+ en:
9
+ - gem:rubocop-spellcheck/data/en/en.dic
10
+ - ../.spellcheck.txt
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ if RUBY_ENGINE == "ruby" && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3") &&
4
+ Gem.loaded_specs.key?("ruby-gem-release")
5
+ require_relative "../../script/release"
6
+ require "ruby-gem-release/rspec"
7
+
8
+ RSpec.describe MongoSessionStoreRelease do
9
+ include RubyGemRelease::RSpec
10
+
11
+ let(:root) { File.expand_path("../..", __dir__) }
12
+ let(:version_path) { "lib/mongo_session_store/version.rb" }
13
+ let(:placeholder) { "* Your contribution here." }
14
+ let(:note) { "* [#1](https://github.com/mongoid/mongo_session_store/pull/1): Added a feature." }
15
+ let(:fixture_files) do
16
+ %w[
17
+ mongo_session_store.gemspec script/release.rb lib/**/*.rb CHANGELOG.md
18
+ CONTRIBUTING.md LICENSE README.md RELEASING.md
19
+ ]
20
+ end
21
+
22
+ def changelog(notes)
23
+ [
24
+ "### 1.2.0 (Next)", "", notes, placeholder, "",
25
+ "### 1.1.0 (2026/01/01)", "", "* Previous release.", ""
26
+ ].join("\n")
27
+ end
28
+
29
+ def write_version(project, version)
30
+ source = File.read(File.join(root, version_path))
31
+ project.write(version_path,
32
+ source.sub(/VERSION = (['"])[^'"]+\1/, "VERSION = \"#{version}\""))
33
+ end
34
+
35
+ def prepare(project, notes)
36
+ project.environment.merge!(ENV.to_h.slice("MONGOID_VERSION", "RAILS_VERSION",
37
+ "SQLITE_VERSION"))
38
+ project.copy_files(:path => root, :files => fixture_files)
39
+ project.configure_workflow(:require => "script/release",
40
+ :builder => "MongoSessionStoreRelease.workflow")
41
+ project.write("CHANGELOG.md", changelog(notes))
42
+ write_version(project, "1.2.0")
43
+ project.commit!
44
+ end
45
+
46
+ def with_project(notes)
47
+ with_release_project do |project|
48
+ prepare(project, notes)
49
+ yield project
50
+ end
51
+ end
52
+
53
+ it "builds the standard ruby-gem-release workflow" do
54
+ expect(described_class.workflow).to be_a(RubyGemRelease::Workflow::RubyGem)
55
+ end
56
+
57
+ it "dates the release and prepares the next patch version" do
58
+ with_project(note) do |project|
59
+ project.release!
60
+
61
+ released = project.remote_file("v1.2.0", "CHANGELOG.md")
62
+ expect(released).to match(%r{\A### 1\.2\.0 \(\d{4}/\d{2}/\d{2}\)\n\n})
63
+ expect(released).to include(note)
64
+ expect(released).not_to include("(Next)", placeholder)
65
+ expect(project.remote_file("v1.2.0", version_path)).to include('VERSION = "1.2.0"')
66
+ pending = project.remote_file("master", "CHANGELOG.md")
67
+ expect(pending).to start_with("### 1.2.1 (Next)\n\n#{placeholder}\n\n### 1.2.0 (")
68
+ expect(project.remote_file("master", version_path)).to include('VERSION = "1.2.1"')
69
+ expect(project.git("status", "--porcelain")).to be_empty
70
+ end
71
+ end
72
+
73
+ it "rejects placeholder-only notes without changing files or remote refs" do
74
+ with_project("") do |project|
75
+ original = project.git("rev-parse", "origin/master")
76
+ project.run_task("release:workflow:capture")
77
+
78
+ expect { project.run_task("release:validate") }
79
+ .to raise_error(RuntimeError, /no pending changelog notes/)
80
+ expect(project.git("status", "--porcelain")).to be_empty
81
+ expect(project.git("rev-parse", "origin/master")).to eq(original)
82
+ end
83
+ end
84
+ end
85
+ end