operator_recordable 1.0.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +85 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -1
- data/Appraisals +43 -0
- data/CHANGELOG.md +65 -0
- data/Gemfile +0 -4
- data/README.md +12 -7
- data/gemfiles/activerecord_5.2.gemfile +2 -2
- data/gemfiles/activerecord_5.2_with_request_store.gemfile +2 -2
- data/gemfiles/activerecord_6.0.gemfile +2 -2
- data/gemfiles/activerecord_6.0_with_request_store.gemfile +2 -2
- data/gemfiles/activerecord_6.1.gemfile +8 -0
- data/gemfiles/activerecord_6.1_with_request_store.gemfile +9 -0
- data/gemfiles/activerecord_7.0.gemfile +8 -0
- data/gemfiles/activerecord_7.0_with_request_store.gemfile +9 -0
- data/lib/operator_recordable/configuration.rb +9 -3
- data/lib/operator_recordable/recorder.rb +49 -22
- data/lib/operator_recordable/store.rb +1 -1
- data/lib/operator_recordable/version.rb +1 -1
- data/operator_recordable.gemspec +15 -3
- metadata +48 -14
- data/.travis.yml +0 -37
- data/gemfiles/activerecord_5.0.gemfile +0 -8
- data/gemfiles/activerecord_5.0_with_request_store.gemfile +0 -9
- data/gemfiles/activerecord_5.1.gemfile +0 -7
- data/gemfiles/activerecord_5.1_with_request_store.gemfile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f15fe7bfab329bcdac169e462ecfdb78af6c49a18e851c904ef9e16a8b33ac4c
|
4
|
+
data.tar.gz: 60a6488ec7540f1b7ea60173126a4817b9ae139058cddfec0e34999adac33244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ad18e622600bd8ba978d998f24ab6b5aa25cd9763159d290b27e9e6b8003715229239da507364ddb083bbc0a03e9ecaa87acc947743aa16e9087ae36dee4853
|
7
|
+
data.tar.gz: f32382da136939d9cad3d9bce663886ae116e6006b0235d7196a567f4830e67ececc1af2bef838f96ec7d386b604195e4c92549a1ad7155ac54d8282531bbb58
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Build
|
9
|
+
|
10
|
+
on: [push, pull_request]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
|
18
|
+
activerecord: ['5.2', '6.0', '6.1', '7.0']
|
19
|
+
plugin: ['', '_with_request_store']
|
20
|
+
experimental: [false]
|
21
|
+
exclude:
|
22
|
+
- ruby: '2.5'
|
23
|
+
activerecord: '7.0'
|
24
|
+
plugin: ''
|
25
|
+
experimental: false
|
26
|
+
- ruby: '2.5'
|
27
|
+
activerecord: '7.0'
|
28
|
+
plugin: '_with_request_store'
|
29
|
+
experimental: false
|
30
|
+
- ruby: '2.6'
|
31
|
+
activerecord: '7.0'
|
32
|
+
plugin: ''
|
33
|
+
experimental: false
|
34
|
+
- ruby: '2.6'
|
35
|
+
activerecord: '7.0'
|
36
|
+
plugin: '_with_request_store'
|
37
|
+
experimental: false
|
38
|
+
- ruby: '2.7'
|
39
|
+
activerecord: '5.2'
|
40
|
+
plugin: ''
|
41
|
+
experimental: false
|
42
|
+
- ruby: '2.7'
|
43
|
+
activerecord: '5.2'
|
44
|
+
plugin: '_with_request_store'
|
45
|
+
experimental: false
|
46
|
+
- ruby: '3.0'
|
47
|
+
activerecord: '5.2'
|
48
|
+
plugin: ''
|
49
|
+
experimental: false
|
50
|
+
- ruby: '3.0'
|
51
|
+
activerecord: '5.2'
|
52
|
+
plugin: '_with_request_store'
|
53
|
+
experimental: false
|
54
|
+
- ruby: '3.1'
|
55
|
+
activerecord: '5.2'
|
56
|
+
plugin: ''
|
57
|
+
experimental: false
|
58
|
+
- ruby: '3.1'
|
59
|
+
activerecord: '5.2'
|
60
|
+
plugin: '_with_request_store'
|
61
|
+
experimental: false
|
62
|
+
include:
|
63
|
+
- ruby: '2.7'
|
64
|
+
activerecord: '5.2'
|
65
|
+
plugin: ''
|
66
|
+
experimental: true
|
67
|
+
- ruby: '2.7'
|
68
|
+
activerecord: '5.2'
|
69
|
+
plugin: '_with_request_store'
|
70
|
+
experimental: true
|
71
|
+
continue-on-error: ${{ matrix.experimental }}
|
72
|
+
env:
|
73
|
+
APPRAISAL: activerecord_${{ matrix.activerecord }}${{ matrix.plugin }}
|
74
|
+
steps:
|
75
|
+
- uses: actions/checkout@v2
|
76
|
+
- name: Set up Ruby
|
77
|
+
uses: ruby/setup-ruby@v1
|
78
|
+
with:
|
79
|
+
ruby-version: ${{ matrix.ruby }}
|
80
|
+
- name: Install dependencies
|
81
|
+
run: |
|
82
|
+
bundle install
|
83
|
+
bundle exec appraisal $APPRAISAL bundle install
|
84
|
+
- name: Run tests
|
85
|
+
run: bundle exec appraisal $APPRAISAL rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
Exclude:
|
3
|
+
- gemfiles/**/*
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
NewCops: enable
|
3
6
|
|
4
7
|
Style/AsciiComments:
|
5
8
|
Enabled: false
|
@@ -21,6 +24,10 @@ Layout/EndOfLine:
|
|
21
24
|
Layout/LineLength:
|
22
25
|
Max: 128
|
23
26
|
|
27
|
+
Metrics/AbcSize:
|
28
|
+
Exclude:
|
29
|
+
- spec/**/*
|
30
|
+
|
24
31
|
Metrics/BlockLength:
|
25
32
|
Exclude:
|
26
33
|
- spec/**/*
|
data/Appraisals
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
appraise "activerecord_5.2" do
|
4
|
+
gem "activerecord", "~> 5.2.0"
|
5
|
+
end
|
6
|
+
|
7
|
+
appraise "activerecord_5.2_with_request_store" do
|
8
|
+
gem "activerecord", "~> 5.2.0"
|
9
|
+
gem "request_store"
|
10
|
+
end
|
11
|
+
|
12
|
+
appraise "activerecord_6.0" do
|
13
|
+
gem "activerecord", "~> 6.0.0"
|
14
|
+
gem "sqlite3", "~> 1.4"
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise "activerecord_6.0_with_request_store" do
|
18
|
+
gem "activerecord", "~> 6.0.0"
|
19
|
+
gem "request_store"
|
20
|
+
gem "sqlite3", "~> 1.4"
|
21
|
+
end
|
22
|
+
|
23
|
+
appraise "activerecord_6.1" do
|
24
|
+
gem "activerecord", "~> 6.1.0"
|
25
|
+
gem "sqlite3", "~> 1.4"
|
26
|
+
end
|
27
|
+
|
28
|
+
appraise "activerecord_6.1_with_request_store" do
|
29
|
+
gem "activerecord", "~> 6.1.0"
|
30
|
+
gem "request_store"
|
31
|
+
gem "sqlite3", "~> 1.4"
|
32
|
+
end
|
33
|
+
|
34
|
+
appraise "activerecord_7.0" do
|
35
|
+
gem "activerecord", "~> 7.0.1"
|
36
|
+
gem "sqlite3", "~> 1.4"
|
37
|
+
end
|
38
|
+
|
39
|
+
appraise "activerecord_7.0_with_request_store" do
|
40
|
+
gem "activerecord", "~> 7.0.1"
|
41
|
+
gem "request_store"
|
42
|
+
gem "sqlite3", "~> 1.4"
|
43
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,69 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
3
|
|
4
|
+
## 1.3.0 (2022-06-01)
|
5
|
+
|
6
|
+
### Changes
|
7
|
+
|
8
|
+
* Support discard gem for soft deletes
|
9
|
+
+ [PR#31](https://github.com/yujideveloper/operator_recordable/pull/31)
|
10
|
+
* Get rid of needless guard clauses for ActiveSupport 5.1 and older
|
11
|
+
+ [PR#32](https://github.com/yujideveloper/operator_recordable/pull/32)
|
12
|
+
|
13
|
+
### Misc
|
14
|
+
|
15
|
+
* Fix RuboCop offenses
|
16
|
+
+ [PR#33](https://github.com/yujideveloper/operator_recordable/pull/33)
|
17
|
+
|
18
|
+
|
19
|
+
## 1.2.0 (2022-04-26)
|
20
|
+
|
21
|
+
### Changes
|
22
|
+
|
23
|
+
* Make associations optional
|
24
|
+
+ [PR#28](https://github.com/yujideveloper/operator_recordable/pull/28)
|
25
|
+
|
26
|
+
### Misc
|
27
|
+
|
28
|
+
* CI against for Rails 7.0 running on Ruby 3.1
|
29
|
+
+ [PR#26](https://github.com/yujideveloper/operator_recordable/pull/26)
|
30
|
+
* Call `super` in `OperatorRecordable::Recorder#initialize`
|
31
|
+
+ [PR#30](https://github.com/yujideveloper/operator_recordable/pull/30)
|
32
|
+
|
33
|
+
|
34
|
+
## 1.1.0 (2022-01-07)
|
35
|
+
|
36
|
+
### Changes
|
37
|
+
|
38
|
+
* Add gem metadata
|
39
|
+
+ [PR#24](https://github.com/yujideveloper/operator_recordable/pull/24)
|
40
|
+
* Drop Ruby 2.4 support
|
41
|
+
+ [PR#25](https://github.com/yujideveloper/operator_recordable/pull/25)
|
42
|
+
* Drop ActiveRecord 5.0 and 5.1 support
|
43
|
+
+ [PR#25](https://github.com/yujideveloper/operator_recordable/pull/25)
|
44
|
+
|
45
|
+
### Misc
|
46
|
+
|
47
|
+
* Introduce Appraisal
|
48
|
+
+ [PR#19](https://github.com/yujideveloper/operator_recordable/pull/19)
|
49
|
+
* CI against for ActiveRecord 6.1 and 7.0
|
50
|
+
+ [PR#19](https://github.com/yujideveloper/operator_recordable/pull/19)
|
51
|
+
+ [PR#22](https://github.com/yujideveloper/operator_recordable/pull/22)
|
52
|
+
* Use GitHub Actions and stop using Travis CI
|
53
|
+
+ [PR#20](https://github.com/yujideveloper/operator_recordable/pull/20)
|
54
|
+
* CI against for Ruby 3.0 and 3.1
|
55
|
+
+ [PR#23](https://github.com/yujideveloper/operator_recordable/pull/23)
|
56
|
+
+ [PR#25](https://github.com/yujideveloper/operator_recordable/pull/25)
|
57
|
+
* Require MFA to release gem
|
58
|
+
+ [PR#24](https://github.com/yujideveloper/operator_recordable/pull/24)
|
59
|
+
|
60
|
+
|
4
61
|
## 1.0.0 (2020-10-16)
|
5
62
|
|
6
63
|
### Changes
|
7
64
|
|
8
65
|
* Support Ruby 2.7
|
66
|
+
+ [PR#14](https://github.com/yujideveloper/operator_recordable/pull/14)
|
9
67
|
|
10
68
|
|
11
69
|
## 0.4.0 (2019-08-22)
|
@@ -13,10 +71,12 @@
|
|
13
71
|
### Changes
|
14
72
|
|
15
73
|
* Support ActiveRecord 6.0.0
|
74
|
+
+ [PR#13](https://github.com/yujideveloper/operator_recordable/pull/13)
|
16
75
|
|
17
76
|
### Misc
|
18
77
|
|
19
78
|
* Improve rspec and CI
|
79
|
+
+ [PR#11](https://github.com/yujideveloper/operator_recordable/pull/11)
|
20
80
|
|
21
81
|
|
22
82
|
## 0.3.0 (2018-10-05)
|
@@ -24,6 +84,7 @@
|
|
24
84
|
### Breaking changes
|
25
85
|
|
26
86
|
* Change mixin module from `OperatorRecordable` to `OperatorRecordable::Extension`
|
87
|
+
+ [PR#5](https://github.com/yujideveloper/operator_recordable/pull/5)
|
27
88
|
|
28
89
|
|
29
90
|
## 0.2.0 (2018-09-27)
|
@@ -31,11 +92,14 @@
|
|
31
92
|
### Changes
|
32
93
|
|
33
94
|
* Add association name options
|
95
|
+
+ [PR#2](https://github.com/yujideveloper/operator_recordable/pull/2)
|
34
96
|
* Modify not to define unnecessary class methods for ActiveRecord model
|
97
|
+
+ [PR#3](https://github.com/yujideveloper/operator_recordable/pull/3)
|
35
98
|
|
36
99
|
### Misc
|
37
100
|
|
38
101
|
* Remove unecessary `require`
|
102
|
+
+ [PR#4](https://github.com/yujideveloper/operator_recordable/pull/4)
|
39
103
|
|
40
104
|
|
41
105
|
## 0.1.1 (2018-09-19)
|
@@ -43,6 +107,7 @@
|
|
43
107
|
### Misc
|
44
108
|
|
45
109
|
* Refactor internal structures
|
110
|
+
+ [PR#1](https://github.com/yujideveloper/operator_recordable/pull/1)
|
46
111
|
|
47
112
|
|
48
113
|
## 0.1.0 (2018-09-14)
|
data/Gemfile
CHANGED
@@ -6,7 +6,3 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
7
7
|
# Specify your gem's dependencies in operator_recordable.gemspec
|
8
8
|
gemspec
|
9
|
-
|
10
|
-
gem "activerecord", ENV.fetch("AR_VERSION", "~> 6.0.0")
|
11
|
-
gem "request_store" unless ENV["WITHOUT_REQUEST_STORE"]
|
12
|
-
gem "sqlite3", ENV.fetch("SQLITE3_VERSION", ">= 1.4.0")
|
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# OperatorRecordable
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/operator_recordable.svg)](https://badge.fury.io/rb/operator_recordable)
|
4
|
-
[![Build
|
4
|
+
[![Build](https://github.com/yujideveloper/operator_recordable/workflows/Build/badge.svg)](https://github.com/yujideveloper/operator_recordable/actions?query=workflow%3ABuild)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/aaa0fcd567da9232a847/maintainability)](https://codeclimate.com/github/yujideveloper/operator_recordable/maintainability)
|
6
6
|
|
7
7
|
OperatorRecordable is a Rails plugin gem that makes your ActiveRecord models to be saved or logically deleted with automatically set `created_by`, `updated_by`, and `deleted_by`.
|
8
8
|
Also it makes `creator`, `updater`, and `deleter` `belongs_to` association if a class has `created_by`, `updated_by`, or `deleted_by`.
|
9
9
|
|
10
|
+
It also supports `discarded_by` column if [discard gem](https://github.com/jhawthorn/discard) is available.
|
11
|
+
|
10
12
|
This gem is inspired by [RecordWithOperator](https://github.com/nay/record_with_operator).
|
11
13
|
|
12
14
|
## Installation
|
@@ -19,7 +21,7 @@ gem 'operator_recordable'
|
|
19
21
|
|
20
22
|
And then execute:
|
21
23
|
|
22
|
-
$ bundle
|
24
|
+
$ bundle install
|
23
25
|
|
24
26
|
Or install it yourself as:
|
25
27
|
|
@@ -38,9 +40,11 @@ OperatorRecordable.config = {
|
|
38
40
|
creator_column_name: "created_by",
|
39
41
|
updater_column_name: "updated_by",
|
40
42
|
deleter_column_name: "deleted_by",
|
43
|
+
discarder_column_name: "discarded_by",
|
41
44
|
creator_association_name: "creator",
|
42
45
|
updater_association_name: "updater",
|
43
46
|
deleter_association_name: "deleter",
|
47
|
+
discarder_association_name: "discarder",
|
44
48
|
operator_association_options: {},
|
45
49
|
operator_association_scope: nil,
|
46
50
|
store: :thread_store
|
@@ -55,10 +59,12 @@ OperatorRecordable.config = {
|
|
55
59
|
| `creator_column_name` | String | column name of creator. | `"created_by"` |
|
56
60
|
| `updater_column_name` | String | column name of updater. | `"updated_by"` |
|
57
61
|
| `deleter_column_name` | String | column name of deleter. | `"deleted_by"` |
|
62
|
+
| `discarder_column_name` | String | column name of discarder. | `"discarded_by"` |
|
58
63
|
| `creator_association_name` | String | association name of creator. | `"creator"` |
|
59
64
|
| `updater_association_name` | String | association name of updater. | `"updater"` |
|
60
65
|
| `deleter_association_name` | String | association name of deleter. | `"deleter"` |
|
61
|
-
| `
|
66
|
+
| `discarder_association_name` | String | association name of discarder. | `"discarder"` |
|
67
|
+
| `operator_association_options` | Hash | options of operator associations. e.g. `{ touch: true }` | `{}` |
|
62
68
|
| `operator_association_scope` | Proc | The scope of operator associations. e.g. `-> { with_deleted }` | `nil` |
|
63
69
|
| `store` | Enum | operator store. any value of `:thread_store`, `:request_store` or `:current_attributes_store` | `:thread_store` |
|
64
70
|
|
@@ -99,7 +105,7 @@ This is default store.
|
|
99
105
|
This store is implemented by using [RequestStore gem](https://github.com/steveklabnik/request_store).
|
100
106
|
So, this requires RequestStore gem.
|
101
107
|
|
102
|
-
RequestStore must be
|
108
|
+
RequestStore must be loaded before OperatorRecordable.
|
103
109
|
|
104
110
|
``` ruby
|
105
111
|
gem "request_store"
|
@@ -112,15 +118,14 @@ require "request_store"
|
|
112
118
|
require "operator_recordable"
|
113
119
|
```
|
114
120
|
|
115
|
-
Otherwise, you need to
|
121
|
+
Otherwise, you need to load it yourself.
|
116
122
|
``` ruby
|
117
123
|
require "operator_recordable/store/request_store"
|
118
124
|
```
|
119
125
|
|
120
126
|
#### `:current_attributes_store`
|
121
127
|
|
122
|
-
This store is implemented by using [`ActiveSupport::CurrentAttributes`](https://api.rubyonrails.org/v5.2.0/classes/ActiveSupport/CurrentAttributes.html).
|
123
|
-
So, this requires ActiveSupport 5.2 or later.
|
128
|
+
This store is implemented by using [`ActiveSupport::CurrentAttributes`](https://api.rubyonrails.org/v5.2.0/classes/ActiveSupport/CurrentAttributes.html).
|
124
129
|
|
125
130
|
|
126
131
|
## Development
|
@@ -11,8 +11,8 @@ module OperatorRecordable
|
|
11
11
|
@store = initialize_store
|
12
12
|
end
|
13
13
|
|
14
|
-
%i[operator_class_name creator_column_name updater_column_name deleter_column_name
|
15
|
-
creator_association_name updater_association_name deleter_association_name
|
14
|
+
%i[operator_class_name creator_column_name updater_column_name deleter_column_name discarder_column_name
|
15
|
+
creator_association_name updater_association_name deleter_association_name discarder_association_name
|
16
16
|
operator_association_options operator_association_scope].each do |name|
|
17
17
|
define_method name do
|
18
18
|
config[name]
|
@@ -37,9 +37,11 @@ module OperatorRecordable
|
|
37
37
|
creator_column_name: "created_by",
|
38
38
|
updater_column_name: "updated_by",
|
39
39
|
deleter_column_name: "deleted_by",
|
40
|
+
discarder_column_name: "discarded_by",
|
40
41
|
creator_association_name: "creator",
|
41
42
|
updater_association_name: "updater",
|
42
43
|
deleter_association_name: "deleter",
|
44
|
+
discarder_association_name: "discarder",
|
43
45
|
operator_association_options: {},
|
44
46
|
operator_association_scope: nil,
|
45
47
|
store: :thread_store
|
@@ -53,7 +55,7 @@ module OperatorRecordable
|
|
53
55
|
end
|
54
56
|
|
55
57
|
class Model
|
56
|
-
VALID_ACTIONS = %i[create update destroy].freeze
|
58
|
+
VALID_ACTIONS = %i[create update destroy discard].freeze
|
57
59
|
|
58
60
|
def initialize(actions)
|
59
61
|
@actions = actions
|
@@ -72,6 +74,10 @@ module OperatorRecordable
|
|
72
74
|
actions.include? :destroy
|
73
75
|
end
|
74
76
|
|
77
|
+
def record_discarder?
|
78
|
+
actions.include? :discard
|
79
|
+
end
|
80
|
+
|
75
81
|
private
|
76
82
|
|
77
83
|
attr_reader :actions
|
@@ -5,6 +5,7 @@ require "operator_recordable/configuration"
|
|
5
5
|
module OperatorRecordable
|
6
6
|
class Recorder < ::Module
|
7
7
|
def initialize(config)
|
8
|
+
super()
|
8
9
|
define_activate_method(config)
|
9
10
|
end
|
10
11
|
|
@@ -30,6 +31,11 @@ module OperatorRecordable
|
|
30
31
|
m.__send__(:run_deleter_dsl, self, config)
|
31
32
|
m.__send__(:define_deleter_instance_methods, self, config)
|
32
33
|
end
|
34
|
+
|
35
|
+
if c.record_discarder?
|
36
|
+
m.__send__(:run_discarder_dsl, self, config)
|
37
|
+
m.__send__(:define_discarder_instance_methods, self, config)
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
@@ -48,46 +54,67 @@ module OperatorRecordable
|
|
48
54
|
run_add_association_dsl(:deleter, klass, config)
|
49
55
|
end
|
50
56
|
|
57
|
+
def run_discarder_dsl(klass, config)
|
58
|
+
klass.before_discard :"assign_#{config.discarder_association_name}"
|
59
|
+
run_add_association_dsl(:discarder, klass, config)
|
60
|
+
end
|
61
|
+
|
51
62
|
def run_add_association_dsl(type, klass, config)
|
52
63
|
klass.belongs_to config.association_name_for(type).to_sym,
|
53
64
|
config.operator_association_scope,
|
54
65
|
**{ foreign_key: config.column_name_for(type),
|
55
|
-
class_name: config.operator_class_name
|
66
|
+
class_name: config.operator_class_name,
|
67
|
+
optional: true }.merge(config.operator_association_options)
|
56
68
|
end
|
57
69
|
|
58
70
|
def define_creator_instance_methods(klass, config)
|
59
71
|
klass.class_eval <<~END_OF_DEF, __FILE__, __LINE__ + 1
|
60
|
-
private def assign_#{config.creator_association_name}
|
61
|
-
return unless (op = OperatorRecordable.operator)
|
62
|
-
|
63
|
-
self.#{config.creator_column_name} = op.id
|
64
|
-
end
|
72
|
+
private def assign_#{config.creator_association_name} # private def assign_creator
|
73
|
+
return unless (op = OperatorRecordable.operator) # return unless (op = OperatorRecordable.operator)
|
74
|
+
#
|
75
|
+
self.#{config.creator_column_name} = op.id # self.created_by = op.id
|
76
|
+
end # end
|
65
77
|
END_OF_DEF
|
66
78
|
end
|
67
79
|
|
68
80
|
def define_updater_instance_methods(klass, config)
|
69
81
|
klass.class_eval <<~END_OF_DEF, __FILE__, __LINE__ + 1
|
70
|
-
private def assign_#{config.updater_association_name}
|
71
|
-
return if !self.new_record? && !self.changed?
|
72
|
-
return unless (op = OperatorRecordable.operator)
|
73
|
-
|
74
|
-
self.#{config.updater_column_name} = op.id
|
75
|
-
end
|
82
|
+
private def assign_#{config.updater_association_name} # private def assign_updater
|
83
|
+
return if !self.new_record? && !self.changed? # return if !self.new_record? && !self.changed?
|
84
|
+
return unless (op = OperatorRecordable.operator) # return unless (op = OperatorRecordable.operator)
|
85
|
+
#
|
86
|
+
self.#{config.updater_column_name} = op.id # self.updated_by = op.id
|
87
|
+
end # end
|
76
88
|
END_OF_DEF
|
77
89
|
end
|
78
90
|
|
79
91
|
def define_deleter_instance_methods(klass, config)
|
80
92
|
klass.class_eval <<~END_OF_DEF, __FILE__, __LINE__ + 1
|
81
|
-
private def assign_#{config.deleter_association_name}
|
82
|
-
return if self.frozen?
|
83
|
-
return unless (op = OperatorRecordable.operator)
|
84
|
-
|
85
|
-
self
|
86
|
-
.class
|
87
|
-
.where(self.class.primary_key => id)
|
88
|
-
.update_all('#{config.deleter_column_name}' => op.id)
|
89
|
-
self.#{config.deleter_column_name} = op.id
|
90
|
-
end
|
93
|
+
private def assign_#{config.deleter_association_name} # private def assign_deleter
|
94
|
+
return if self.frozen? # return if self.frozen?
|
95
|
+
return unless (op = OperatorRecordable.operator) # return unless (op = OperatorRecordable.operator)
|
96
|
+
#
|
97
|
+
self # self
|
98
|
+
.class # .class
|
99
|
+
.where(self.class.primary_key => id) # .where(self.class.primary_key => id)
|
100
|
+
.update_all('#{config.deleter_column_name}' => op.id) # .update_all('deleted_by' => op.id)
|
101
|
+
self.#{config.deleter_column_name} = op.id # self.deleted_by = op.id
|
102
|
+
end # end
|
103
|
+
END_OF_DEF
|
104
|
+
end
|
105
|
+
|
106
|
+
def define_discarder_instance_methods(klass, config)
|
107
|
+
klass.class_eval <<~END_OF_DEF, __FILE__, __LINE__ + 1
|
108
|
+
private def assign_#{config.discarder_association_name} # private def assign_discarder
|
109
|
+
return if self.frozen? # return if self.frozen?
|
110
|
+
return unless (op = OperatorRecordable.operator) # return unless (op = OperatorRecordable.operator)
|
111
|
+
#
|
112
|
+
self # self
|
113
|
+
.class # .class
|
114
|
+
.where(self.class.primary_key => id) # .where(self.class.primary_key => id)
|
115
|
+
.update_all('#{config.discarder_column_name}' => op.id) # .update_all('discarded_by' => op.id)
|
116
|
+
self.#{config.discarder_column_name} = op.id # self.discarded_by = op.id
|
117
|
+
end # end
|
91
118
|
END_OF_DEF
|
92
119
|
end
|
93
120
|
end
|
@@ -15,4 +15,4 @@ end
|
|
15
15
|
|
16
16
|
require "operator_recordable/store/thread_store"
|
17
17
|
require "operator_recordable/store/request_store" if defined? ::RequestStore
|
18
|
-
require "operator_recordable/store/current_attributes_store"
|
18
|
+
require "operator_recordable/store/current_attributes_store"
|
data/operator_recordable.gemspec
CHANGED
@@ -24,20 +24,32 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
24
24
|
spec.homepage = "https://github.com/yujideveloper/operator_recordable"
|
25
25
|
spec.license = "MIT"
|
26
26
|
|
27
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
28
|
+
|
29
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
30
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
31
|
+
spec.metadata["changelog_uri"] = "https://github.com/yujideveloper/operator_recordable/tree/master/CHANGELOG.md"
|
32
|
+
|
33
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
34
|
+
|
27
35
|
# Specify which files should be added to the gem when it is released.
|
28
36
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
-
spec.files
|
37
|
+
spec.files = Dir.chdir(__dir__) do
|
30
38
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
39
|
end
|
32
40
|
spec.bindir = "exe"
|
33
41
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
42
|
spec.require_paths = ["lib"]
|
35
43
|
|
36
|
-
spec.
|
44
|
+
spec.required_ruby_version = ">= 2.5"
|
45
|
+
|
46
|
+
spec.add_dependency "activerecord", ">= 5.2"
|
47
|
+
spec.add_development_dependency "appraisal", ">= 2.3.0"
|
37
48
|
spec.add_development_dependency "bundler", ">= 1.16"
|
49
|
+
spec.add_development_dependency "discard", ">= 1.2"
|
38
50
|
spec.add_development_dependency "pry", ">= 0.10.0"
|
39
51
|
spec.add_development_dependency "rake", ">= 10.0"
|
40
52
|
spec.add_development_dependency "rspec", "~> 3.7"
|
41
|
-
spec.add_development_dependency "rubocop", ">=
|
53
|
+
spec.add_development_dependency "rubocop", ">= 1.13.0"
|
42
54
|
spec.add_development_dependency "sqlite3", ">= 1.3.13"
|
43
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: operator_recordable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Hanamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: appraisal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.3.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: discard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.2'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: pry
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +114,14 @@ dependencies:
|
|
86
114
|
requirements:
|
87
115
|
- - ">="
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
117
|
+
version: 1.13.0
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
122
|
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
124
|
+
version: 1.13.0
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: sqlite3
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,10 +146,11 @@ executables: []
|
|
118
146
|
extensions: []
|
119
147
|
extra_rdoc_files: []
|
120
148
|
files:
|
149
|
+
- ".github/workflows/ruby.yml"
|
121
150
|
- ".gitignore"
|
122
151
|
- ".rspec"
|
123
152
|
- ".rubocop.yml"
|
124
|
-
-
|
153
|
+
- Appraisals
|
125
154
|
- CHANGELOG.md
|
126
155
|
- Gemfile
|
127
156
|
- LICENSE.txt
|
@@ -129,14 +158,14 @@ files:
|
|
129
158
|
- Rakefile
|
130
159
|
- bin/console
|
131
160
|
- bin/setup
|
132
|
-
- gemfiles/activerecord_5.0.gemfile
|
133
|
-
- gemfiles/activerecord_5.0_with_request_store.gemfile
|
134
|
-
- gemfiles/activerecord_5.1.gemfile
|
135
|
-
- gemfiles/activerecord_5.1_with_request_store.gemfile
|
136
161
|
- gemfiles/activerecord_5.2.gemfile
|
137
162
|
- gemfiles/activerecord_5.2_with_request_store.gemfile
|
138
163
|
- gemfiles/activerecord_6.0.gemfile
|
139
164
|
- gemfiles/activerecord_6.0_with_request_store.gemfile
|
165
|
+
- gemfiles/activerecord_6.1.gemfile
|
166
|
+
- gemfiles/activerecord_6.1_with_request_store.gemfile
|
167
|
+
- gemfiles/activerecord_7.0.gemfile
|
168
|
+
- gemfiles/activerecord_7.0_with_request_store.gemfile
|
140
169
|
- lib/operator_recordable.rb
|
141
170
|
- lib/operator_recordable/configuration.rb
|
142
171
|
- lib/operator_recordable/extension.rb
|
@@ -150,7 +179,12 @@ files:
|
|
150
179
|
homepage: https://github.com/yujideveloper/operator_recordable
|
151
180
|
licenses:
|
152
181
|
- MIT
|
153
|
-
metadata:
|
182
|
+
metadata:
|
183
|
+
allowed_push_host: https://rubygems.org
|
184
|
+
homepage_uri: https://github.com/yujideveloper/operator_recordable
|
185
|
+
source_code_uri: https://github.com/yujideveloper/operator_recordable
|
186
|
+
changelog_uri: https://github.com/yujideveloper/operator_recordable/tree/master/CHANGELOG.md
|
187
|
+
rubygems_mfa_required: 'true'
|
154
188
|
post_install_message:
|
155
189
|
rdoc_options: []
|
156
190
|
require_paths:
|
@@ -159,14 +193,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
193
|
requirements:
|
160
194
|
- - ">="
|
161
195
|
- !ruby/object:Gem::Version
|
162
|
-
version: '
|
196
|
+
version: '2.5'
|
163
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
198
|
requirements:
|
165
199
|
- - ">="
|
166
200
|
- !ruby/object:Gem::Version
|
167
201
|
version: '0'
|
168
202
|
requirements: []
|
169
|
-
rubygems_version: 3.1.
|
203
|
+
rubygems_version: 3.1.6
|
170
204
|
signing_key:
|
171
205
|
specification_version: 4
|
172
206
|
summary: OperatorRecordable is a Rails plugin to set created_by, updated_by, and deleted_by
|
data/.travis.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
language: ruby
|
4
|
-
cache: bundler
|
5
|
-
rvm:
|
6
|
-
- 2.4
|
7
|
-
- 2.5
|
8
|
-
- 2.6
|
9
|
-
- 2.7
|
10
|
-
gemfile:
|
11
|
-
- gemfiles/activerecord_5.0.gemfile
|
12
|
-
- gemfiles/activerecord_5.0_with_request_store.gemfile
|
13
|
-
- gemfiles/activerecord_5.1.gemfile
|
14
|
-
- gemfiles/activerecord_5.1_with_request_store.gemfile
|
15
|
-
- gemfiles/activerecord_5.2.gemfile
|
16
|
-
- gemfiles/activerecord_5.2_with_request_store.gemfile
|
17
|
-
- gemfiles/activerecord_6.0.gemfile
|
18
|
-
- gemfiles/activerecord_6.0_with_request_store.gemfile
|
19
|
-
matrix:
|
20
|
-
exclude:
|
21
|
-
- rvm: 2.4
|
22
|
-
gemfile: gemfiles/activerecord_6.0.gemfile
|
23
|
-
- rvm: 2.4
|
24
|
-
gemfile: gemfiles/activerecord_6.0_with_request_store.gemfile
|
25
|
-
allow_failures:
|
26
|
-
- rvm: 2.7
|
27
|
-
gemfile: gemfiles/activerecord_5.0.gemfile
|
28
|
-
- rvm: 2.7
|
29
|
-
gemfile: gemfiles/activerecord_5.0_with_request_store.gemfile
|
30
|
-
- rvm: 2.7
|
31
|
-
gemfile: gemfiles/activerecord_5.1.gemfile
|
32
|
-
- rvm: 2.7
|
33
|
-
gemfile: gemfiles/activerecord_5.1_with_request_store.gemfile
|
34
|
-
- rvm: 2.7
|
35
|
-
gemfile: gemfiles/activerecord_5.2.gemfile
|
36
|
-
- rvm: 2.7
|
37
|
-
gemfile: gemfiles/activerecord_5.2_with_request_store.gemfile
|