From 7574eee552130388182b3fbc002744909104bfa2 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:33:28 +0900 Subject: [PATCH] - Loosen version support requirement to include Mongoid 7.3, 8.0, and above. - Add Rubocop to CI. - Fix minor Rubocop issues. - Dropped Ruby < 2.7. --- .github/workflows/rubocop.yml | 22 ++++++++++++++++++++++ .github/workflows/test.yml | 7 ++++++- .rubocop.yml | 4 ++-- CHANGELOG.md | 33 ++++++++++++++++++++------------- Gemfile | 17 ++++++++++------- lib/mongoid/paranoia.rb | 6 +++--- mongoid_paranoia.gemspec | 6 ++---- perf/scope.rb | 2 +- 8 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/rubocop.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..631fdd7 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,22 @@ +--- +name: Rubocop + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + env: + CI: true + TESTOPTS: '-v' + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby 3.2 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + - name: bundle install + run: bundle install --jobs 4 --retry 3 + - name: Run Rubocop + run: bundle exec rubocop --parallel diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fe2244..6de07cf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,8 @@ jobs: strategy: fail-fast: true matrix: - ruby: [2.4, 2.5, 2.6, 2.7, 3.0, jruby, truffleruby] + ruby: [2.7, 3.0, 3.1, 3.2, jruby, truffleruby] + mongoid: [7, 8] experimental: [false] include: - ruby: head @@ -42,8 +43,12 @@ jobs: - name: bundle install run: bundle install --jobs 4 --retry 3 + env: + MONGOID_VERSION: ${{ matrix.mongoid }} - name: test timeout-minutes: 10 run: bundle exec rake spec continue-on-error: ${{ matrix.experimental }} + env: + MONGOID_VERSION: ${{ matrix.mongoid }} diff --git a/.rubocop.yml b/.rubocop.yml index 655a681..78c76b9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml AllCops: NewCops: enable SuggestExtensions: false - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.7 Exclude: - spec/**/* - vendor/**/* @@ -19,7 +19,7 @@ Layout/EmptyLineAfterGuardClause: Enabled: false Layout/IndentationWidth: - IgnoredPatterns: + AllowedPatterns: - '^\s*module' Layout/LineLength: diff --git a/CHANGELOG.md b/CHANGELOG.md index adb33ed..3d73420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.6.0 (2023/09/18) + +* Loosen version support requirement to include Mongoid 7.3, 8.0, and above. +* Add Rubocop to CI. +* Fix minor Rubocop issues. +* Drop support for Ruby < 2.7. + ## 0.5.0 (2021/07/24) * Support only Mongoid 7.3 and later. @@ -5,31 +12,31 @@ ## 0.4.1 (2021/07/24) -* Do not allow Mongoid 7.3 and later, due to breaking changes -* Switch to Github Actions from Travis CI -* Add Rubocop and fix issues -* Dropped Ruby < 2.4 +* Do not allow Mongoid 7.3 and later, due to breaking changes. +* Switch to Github Actions from Travis CI. +* Add Rubocop and fix issues. +* Drop support for Ruby < 2.4. ## 0.4.0 (2019/05/29) -* Mongoid 7.0 support -* Drop Mongoid 6 and Ruby < 2.3 +* Mongoid 7.0 support. +* Drop support for Mongoid 6 and Ruby < 2.3. ## 0.3.0 (2017/01/05) -* Mongoid 6.0 support -* Drop Mongoid 4/5 and Ruby < 2.2.2 +* Mongoid 6.0 support. +* Drop support for Mongoid 4/5 and Ruby < 2.2.2. ## 0.2.1 (2015/09/28) -* [#40](https://github.com/simi/mongoid_paranoia/pull/40): Don't override mongoid original update - [@simi](https://github.com/simi). +* [#40](https://github.com/simi/mongoid_paranoia/pull/40): Don't override mongoid original update - [@simi](https://github.com/simi) ## 0.2.0 (2015/09/22) -* [#38](https://github.com/simi/mongoid_paranoia/pull/38): Added support for Mongoid 5 - [@dblock](https://github.com/dblock). -* [#29](https://github.com/simi/mongoid_paranoia/pull/29): Added `before_remove`, `after_remove` and `around_remove` callbacks - [@marcelloma](https://github.com/marcelloma). -* [#34](https://github.com/simi/mongoid_paranoia/pull/34): Allow configuring of the paranoid field naming on a global basis - [@ak47](https://github.com/ak47). +* [#38](https://github.com/simi/mongoid_paranoia/pull/38): Added support for Mongoid 5 - [@dblock](https://github.com/dblock) +* [#29](https://github.com/simi/mongoid_paranoia/pull/29): Added `before_remove`, `after_remove` and `around_remove` callbacks - [@marcelloma](https://github.com/marcelloma) +* [#34](https://github.com/simi/mongoid_paranoia/pull/34): Allow configuring of the paranoid field naming on a global basis - [@ak47](https://github.com/ak47) ## 0.1.2 (2014/07/11) -* Initial public release - [@simi](https://github.com/simi). +* Initial public release - [@simi](https://github.com/simi) diff --git a/Gemfile b/Gemfile index fdb1c1a..9a34a7d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,12 +3,15 @@ source 'https://rubygems.org' gemspec name: 'mongoid_paranoia' -gem 'mongoid', '~> 7.3' - -group :test do - gem 'rspec', '~> 3.8' +case (version = ENV['MONGOID_VERSION'] || '8') +when 'HEAD' + gem 'mongoid', github: 'mongodb/mongoid' +when /\A\d+\z/ + gem 'mongoid', "~> #{version}.0" +else + gem 'mongoid', version end -group :development do - gem 'rake' -end +gem 'rake' +gem 'rspec' +gem 'rubocop' diff --git a/lib/mongoid/paranoia.rb b/lib/mongoid/paranoia.rb index 6aeda88..b339e04 100644 --- a/lib/mongoid/paranoia.rb +++ b/lib/mongoid/paranoia.rb @@ -75,7 +75,7 @@ def persisted? # @return [ true ] True. # # @since 1.0.0 - alias :orig_delete :delete + alias orig_delete delete def remove(_ = {}) time = self.deleted_at = Time.now @@ -84,8 +84,8 @@ def remove(_ = {}) true end - alias :delete :remove - alias :delete! :orig_delete + alias delete remove + alias delete! orig_delete # Delete the paranoid +Document+ from the database completely. This will # run the destroy and remove callbacks. diff --git a/mongoid_paranoia.gemspec b/mongoid_paranoia.gemspec index 5cf402e..250e00e 100644 --- a/mongoid_paranoia.gemspec +++ b/mongoid_paranoia.gemspec @@ -14,10 +14,8 @@ Gem::Specification.new do |gem| gem.license = 'MIT' gem.files = Dir.glob('lib/**/*') + %w[LICENSE README.md] - gem.test_files = Dir.glob('{perf,spec}/**/*') gem.require_paths = ['lib'] - gem.add_dependency 'mongoid', '~> 7.3' - - gem.add_development_dependency 'rubocop', '>= 1.8.1' + gem.add_dependency 'mongoid', '>= 7.3' + gem.metadata['rubygems_mfa_required'] = 'true' end diff --git a/perf/scope.rb b/perf/scope.rb index 4f369a6..60c4023 100644 --- a/perf/scope.rb +++ b/perf/scope.rb @@ -35,7 +35,7 @@ class MetaParanoidModel if ENV['FORCE'] Mongoid.purge! - ::Mongoid::Tasks::Database.create_indexes + Mongoid::Tasks::Database.create_indexes n = 50_000 n.times {|i| Model.create(text: "text #{i}") }