From 4624433da23db6208692c8a93b4865eb9a43aabd Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 3 Feb 2026 12:55:00 -0500 Subject: [PATCH 1/3] Add support for Mongoid 7, 8, and 9 --- .github/workflows/test.yml | 3 +++ CHANGELOG.md | 3 ++- Gemfile | 11 ++++++++++- README.md | 2 +- lib/mongoid/shell/commands/base.rb | 6 +++--- lib/mongoid/shell/version.rb | 2 +- spec/mongoid/commands/base_spec.rb | 4 ++-- spec/mongoid/properties/host_spec.rb | 2 +- spec/support/helpers/mongoid_session_helper.rb | 6 +++--- 9 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d21edd0..6d4e5fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,9 @@ jobs: - { ruby: '2.7', mongoid: '4' } - { ruby: '2.7', mongoid: '5' } - { ruby: '3.3', mongoid: '6' } + - { ruby: '2.7', mongoid: '7' } + - { ruby: '3.2', mongoid: '8' } + - { ruby: '3.3', mongoid: '9' } name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}) diff --git a/CHANGELOG.md b/CHANGELOG.md index 387b336..df57cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -### 0.4.7 (Next) +### 0.5.0 (Next) * Your contribution here. +* [#20](https://github.com/mongoid/mongoid-shell/pull/20): Added compatibility with Mongoid 7, 8, 9 - [@dblock](https://github.com/dblock). * Migrated CI from Travis CI to GitHub Actions - [@dblock](https://github.com/dblock). ### 0.4.6 (12/29/2017) diff --git a/Gemfile b/Gemfile index d7d1c13..ed08d18 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,16 @@ source 'http://rubygems.org' gemspec -case version = ENV['MONGOID_VERSION'] || '6.0' +case version = ENV['MONGOID_VERSION'] || '9.0' +when /^9/ + gem 'bigdecimal' + gem 'mongoid', '~> 9.0' +when /^8/ + gem 'bigdecimal' + gem 'mongoid', '~> 8.0' +when /^7/ + gem 'bigdecimal' + gem 'mongoid', '~> 7.0' when /^6/ gem 'bigdecimal' gem 'mongoid', '~> 6.0' diff --git a/README.md b/README.md index 0d48fe2..ca1e12a 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ To use output in logs, pass the `mask_sensitive` option to `to_s`. Compatibility ------------- -This gem supports Mongoid 3, 4, 5 and 6. +This gem supports Mongoid 3, 4, 5, 6, 7, 8 and 9. Supported Commands ------------------ diff --git a/lib/mongoid/shell/commands/base.rb b/lib/mongoid/shell/commands/base.rb index 5850f79..2629f6d 100644 --- a/lib/mongoid/shell/commands/base.rb +++ b/lib/mongoid/shell/commands/base.rb @@ -78,13 +78,13 @@ def to_s(options = {}) private - if ::Mongoid::Compatibility::Version.mongoid3? || ::Mongoid::Compatibility::Version.mongoid4? + if ::Mongoid::Compatibility::Version.mongoid5_or_newer? def default_client_or_session - Mongoid.default_session + Mongoid.default_client end else def default_client_or_session - Mongoid.default_client + Mongoid.default_session end end end diff --git a/lib/mongoid/shell/version.rb b/lib/mongoid/shell/version.rb index 482575e..1e40390 100644 --- a/lib/mongoid/shell/version.rb +++ b/lib/mongoid/shell/version.rb @@ -2,6 +2,6 @@ module Mongoid module Shell - VERSION = '0.4.7' + VERSION = '0.5.0' end end diff --git a/spec/mongoid/commands/base_spec.rb b/spec/mongoid/commands/base_spec.rb index d459cc3..8a58c8c 100644 --- a/spec/mongoid/commands/base_spec.rb +++ b/spec/mongoid/commands/base_spec.rb @@ -7,7 +7,7 @@ context 'without a default session' do before do - default_function = Mongoid::Compatibility::Version.mongoid3? || Mongoid::Compatibility::Version.mongoid4? ? :default_session : :default_client + default_function = Mongoid::Compatibility::Version.mongoid5_or_newer? ? :default_client : :default_session allow(Mongoid).to receive(default_function).and_return(nil) end @@ -24,7 +24,7 @@ end end - if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6? + if Mongoid::Compatibility::Version.mongoid5_or_newer? it 'creates a command using the default session' do command = Mongoid::Shell::Commands::Base.new expect(command.session).to eq Mongoid.default_client diff --git a/spec/mongoid/properties/host_spec.rb b/spec/mongoid/properties/host_spec.rb index 978c707..d558e6b 100644 --- a/spec/mongoid/properties/host_spec.rb +++ b/spec/mongoid/properties/host_spec.rb @@ -16,7 +16,7 @@ def session end it 'raises an exception when the session is not connected' do - if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6? + if Mongoid::Compatibility::Version.mongoid5_or_newer? allow(Mongoid.default_client.cluster).to receive(:servers).and_return([]) else allow(Mongoid.default_session.cluster).to receive(:nodes).and_return([]) diff --git a/spec/support/helpers/mongoid_session_helper.rb b/spec/support/helpers/mongoid_session_helper.rb index fa52ccc..85e489d 100644 --- a/spec/support/helpers/mongoid_session_helper.rb +++ b/spec/support/helpers/mongoid_session_helper.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true module MongoidSessionHelper - if ::Mongoid::Compatibility::Version.mongoid3? || ::Mongoid::Compatibility::Version.mongoid4? + if ::Mongoid::Compatibility::Version.mongoid5_or_newer? def default_client_or_session - Mongoid.default_session + Mongoid.default_client end else def default_client_or_session - Mongoid.default_client + Mongoid.default_session end end end From 8cf3a73d2438bd898afd35f976deb796983967e6 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 3 Feb 2026 13:14:27 -0500 Subject: [PATCH 2/3] Fix danger. --- Dangerfile | 4 +++- Gemfile | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dangerfile b/Dangerfile index de2a4a0..f769387 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,3 +1,5 @@ # frozen_string_literal: true -danger.import_dangerfile(gem: 'mongoid-danger') +danger.import_dangerfile(gem: 'danger-pr-comment') + +changelog.check! diff --git a/Gemfile b/Gemfile index ed08d18..f3429cd 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,9 @@ end group :development, :test do gem 'bundler' - gem 'mongoid-danger', '~> 0.1.1' + gem 'danger' + gem 'danger-changelog' + gem 'danger-pr-comment' gem 'rake' gem 'rspec', '~> 3.0' gem 'rubocop', '~> 1.84.1' From 8bd440416a9f8fe819df0b9ea82ea979f65291bd Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 3 Feb 2026 13:18:11 -0500 Subject: [PATCH 3/3] Fix CHANGELOG date format per danger report --- CHANGELOG.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df57cab..56b91b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,37 +4,37 @@ * [#20](https://github.com/mongoid/mongoid-shell/pull/20): Added compatibility with Mongoid 7, 8, 9 - [@dblock](https://github.com/dblock). * Migrated CI from Travis CI to GitHub Actions - [@dblock](https://github.com/dblock). -### 0.4.6 (12/29/2017) +### 0.4.6 (2017/12/29) * [#16](https://github.com/mongoid/mongoid-shell/pull/16): Add `--ssl` and `--authenticationDatabase` support to all commands - [@cavvia](https://github.com/cavvia). -### 0.4.5 (9/7/2017) +### 0.4.5 (2017/09/07) * [#13](https://github.com/mongoid/mongoid-shell/issues/13): Support masking sensitive values with `to_s(mask_sensitive: true)` - [@dblock](https://github.com/dblock). * [#14](https://github.com/mongoid/mongoid-shell/pull/14): Refactored arg definitions into `arg` and `option` - [@dblock](https://github.com/dblock). -### 0.4.4 (6/4/2017) +### 0.4.4 (2017/06/04) * [#11](https://github.com/mongoid/mongoid-shell/pull/11): Compatibility with Mongoid 6 - [@jbach](https://github.com/jbach). * [#12](https://github.com/mongoid/mongoid-shell/pull/12): Added Danger, PR linter - [@dblock](https://github.com/dblock). -### 0.4.3 (6/1/2016) +### 0.4.3 (2016/06/01) * [#9](https://github.com/mongoid/mongoid-shell/pull/9): Remove example and spec alleging that `--collection` can be specified multiple times - [@joeyAghion](https://github.com/joeyAghion). -### 0.4.2 (2/9/2015) +### 0.4.2 (2015/02/09) * [#8](https://github.com/mongoid/mongoid-shell/pull/8): Support repeatable parameters; add `excludeCollection` and `excludeCollectionsWithPrefix` to `mongodump` - [@joeyAghion](https://github.com/joeyAghion). -### 0.4.1 (10/25/2015) +### 0.4.1 (2015/10/25) * [#7](https://github.com/mongoid/mongoid-shell/pull/7): Added support for `mongoimport` and `mongoexport` - [@hoang1417](https://github.com/hoang1417). -### 0.4.0 (10/20/2015) +### 0.4.0 (2015/10/20) * [#6](https://github.com/mongoid/mongoid-shell/pull/6): Compatibility with Mongoid 5.x - [@dblock](https://github.com/dblock). -### 0.3.0 (7/1/2014) +### 0.3.0 (2014/07/01) * [#3](https://github.com/mongoid/mongoid-shell/pull/3): Added Mongoid 4.x support - [@pawelniewie](https://github.com/pawelniewie), [@dblock](https://github.com/dblock). * [#2](https://github.com/mongoid/mongoid-shell/pull/2): Added support for `--noIndexRestore` to `Mongoid::Shell::Commands::Mongorestore` - [@macreery](https://github.com/macreery). @@ -43,7 +43,7 @@ * Added Rubocop, Ruby style linter - [@dblock](https://github.com/dblock). * Upgraded to RSpec 3.x expectation syntax - [@dblock](https://github.com/dblock). -### 0.2.0 (1/29/2013) +### 0.2.0 (2013/01/29) * Added `Mongoid::Shell::Commands::Mongo` that generates a command line which connects to the session's primary node - [@dblock](https://github.com/dblock). * Added `Mongoid::Shell::Commands::Mongostat` that generates a command line for `mongostat` - [@dblock](https://github.com/dblock). @@ -53,6 +53,6 @@ * Added support for `--nodb`, `--norc`, `--quiet` and `--ipv6` to `Mongoid::Shell::Commands::Mongo` - [@dblock](https://github.com/dblock). * It's now possible to override built-in `db`, `username`, `password`, `host` and `primary` - [@dblock](https://github.com/dblock). -### 0.1.0 (1/27/2013) +### 0.1.0 (2013/01/27) * Initial public release with support for `mongodump` - [@dblock](https://github.com/dblock).