Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests
on: [push, pull_request]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
fail-fast: false
matrix:
gemfile: ["mongoid_5", "mongoid_6", "mongoid_7_0", "mongoid_7_1", "mongoid_7_2", "mongoid_7_3", "mongoid_7_4", "mongoid_8", "mongoid_9", "rails_5", "rails_6_0", "rails_6_1", "rails_7"]
ruby: ["3.1", "3.2", "3.3"]
runs-on: ubuntu-latest
services:
mongodb:
image: mongo
ports: ["27017:27017"]
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
/pkg/
/spec/reports/
/tmp/

/gemfiles/*.gemfile.lock
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.0
3.3.4
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

55 changes: 55 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
appraise "mongoid-5" do
gem "mongoid", "5.4.1"
gem "bigdecimal", "1.4.2"
end

appraise "mongoid-6" do
gem "mongoid", "6.4.8"
end

appraise "mongoid-7-0" do
gem "mongoid", "7.0.13"
end

appraise "mongoid-7-1" do
gem "mongoid", "7.1.11"
end

appraise "mongoid-7-2" do
gem "mongoid", "7.2.6"
end

appraise "mongoid-7-3" do
gem "mongoid", "7.3.4"
end

appraise "mongoid-7-4" do
gem "mongoid", "7.4.0"
end

appraise "mongoid-8" do
gem "mongoid", "~> 8.0"
end

appraise "mongoid-9" do
gem "mongoid", "~> 9.0"
end

appraise "rails-5" do
gem "rails", "~> 5.0"
gem "mongoid", "~> 7.0"
end

appraise "rails-6-0" do
gem "rails", "~> 6.0.0"
gem "mongoid", "~> 7.0"
end

appraise "rails-6-1" do
gem "rails", "~> 6.1.0"
gem "mongoid", "~> 7.0"
end

appraise "rails-7" do
gem "rails", "~> 7.0"
end
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Next

* Mongoid 8 support

# 1.7.1

* FIX: BSON 4+ returns BSON::Document instead of Hash, [#15](https://github.com/Sign2Pay/mongoid-archivable/pull/15)
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in mongoid-archivable.gemspec
gemspec

case version = ENV['MONGOID_VERSION'] || '~> 7.0'
case version = ENV['MONGOID_VERSION'] || '~> 9.0'
when /9/ then gem 'mongoid', '~> 9.0'
when /8/ then gem 'mongoid', '~> 8.0'
when /7/ then gem 'mongoid', '~> 7.0'
when /6/ then gem 'mongoid', '~> 6.0'
when /5/ then gem 'mongoid', '~> 5.1'
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mongoid::Archivable

[![Build Status](https://travis-ci.org/Sign2Pay/mongoid-archivable.svg)](https://travis-ci.org/Sign2Pay/mongoid-archivable) [![Gem Version](https://badge.fury.io/rb/mongoid-archivable.svg)](http://badge.fury.io/rb/mongoid-archivable)
[![Tests](https://github.com/asgerb/mongoid-archivable/actions/workflows/test.yml/badge.svg)](https://github.com/asgerb/mongoid-archivable/actions/workflows/test.yml) [![Gem Version](https://badge.fury.io/rb/mongoid-archivable.svg)](http://badge.fury.io/rb/mongoid-archivable)

Moves Mongoid documents to an archive instead of destroying them.

Expand Down Expand Up @@ -91,7 +91,6 @@ development:
<<: *client_options
```


## Development

Please report any issues to the [GitHub issue tracker](https://github.com/Sign2Pay/mongoid-archivable/issues).
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
8 changes: 8 additions & 0 deletions gemfiles/mongoid_5.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "5.4.1"
gem "bigdecimal", "1.4.2"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_6.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "6.4.8"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "7.0.13"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_7_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "7.1.11"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_7_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "7.2.6"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_7_3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "7.3.4"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_7_4.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "7.4.0"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_8.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "~> 8.0"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/mongoid_9.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "~> 9.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_5.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "~> 7.0"
gem "rails", "~> 5.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "~> 7.0"
gem "rails", "~> 6.0.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "~> 7.0"
gem "rails", "~> 6.1.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "mongoid", "~> 9.0"
gem "rails", "~> 7.0"

gemspec path: "../"
4 changes: 2 additions & 2 deletions lib/mongoid/archivable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def configure(&proc)
end

included do
mattr_accessor :archive_storage
class_attribute :archive_storage
include Mongoid::Archivable::Gluten

const_set('Archive', Class.new)
Expand All @@ -35,7 +35,7 @@ def configure(&proc)
field :archived_at, type: Time
field :original_id, type: String
field :original_type, type: String

end

before_destroy :archive
Expand Down
2 changes: 1 addition & 1 deletion lib/mongoid/archivable/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def get_client
end
end
end
end
end
23 changes: 17 additions & 6 deletions lib/mongoid/archivable/depot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,50 @@ module Mongoid
module Archivable
module Depot
extend ActiveSupport::Concern

included do
include ClassMethods
end

module ClassMethods
def has_archive_storage?
!parent.archive_storage.nil?
!parent_class.archive_storage.nil?
end

def has_archive_client?
has_archive_storage? && !parent.archive_storage[:client].nil?
has_archive_storage? && !parent_class.archive_storage[:client].nil?
end

def has_archive_database?
has_archive_storage? && !parent.archive_storage[:client].nil?
has_archive_storage? && !parent_class.archive_storage[:client].nil?
end

def archive_database_name
if has_archive_database?
parent.archive_storage[:database]
parent_class.archive_storage[:database]
else
Mongoid::Archivable.config.get_database
end
end

def archive_client_name
if has_archive_client?
parent.archive_storage[:client]
parent_class.archive_storage[:client]
else
Mongoid::Archivable.config.get_client
end
end

private

def parent_class
if ActiveSupport::VERSION::MAJOR >= 6
module_parent
else
parent
end
end
end
end
end
end
end
1 change: 1 addition & 0 deletions mongoid-archivable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'mongoid', '>= 5.0'
spec.add_dependency 'activesupport', '>= 4.0.0'

spec.add_development_dependency 'appraisal'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'
Expand Down