activerecord-bitemporal 3.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6034ded2e7c8b1ec28b1632ba21f6245c0e2dc6a96786294bc6883c0cc8bbbcb
4
- data.tar.gz: 3b6fca0b70c57242aa69136b5d41e7438603a0b30d1dd658ccbbebff8dd3d73d
3
+ metadata.gz: '09a592f0b1e43e737bd1fdbc8a88f025af734bf3c0d42c4fa2297dbaa72a68e5'
4
+ data.tar.gz: b591ee586a0d5fc3f109444787f86bc5c399f22d33c44d84d80bde6f91b141ac
5
5
  SHA512:
6
- metadata.gz: 6783cd51d729e2beb9ab8a8f67039ca2258bee3ad1258b7cf96f8d2b9a86d33daaa3aa6db18b96fdc277b6ee69a224c85d26d47ac5d54fb581c8685e1c4a1459
7
- data.tar.gz: 4b57fe700e248b0e630cc73959f6817b66977bc93e018445ea0c95e363b28bea770ba5869d4261a5031ae9609c78a883adf98aef821ecba942225e31fa32c991
6
+ metadata.gz: b0d9d4f5dd752200b2e803bca72b123ed067165bd61092755fb091b10eb35fd58b82617f7957d48f738b8f9ec09c480d8338553c3b33098202056d2d20e94d09
7
+ data.tar.gz: d90e6bbb55b783bc75f650c00c4bbaf226b4d5ba67c86e004bfecbe75224031c0a0ad69c95955741c0b560bdc85fc2a4f3945d07885d0b128ecbf0416f003569
data/.circleci/config.yml CHANGED
@@ -28,17 +28,12 @@ workflows:
28
28
  - '3.0'
29
29
  - '3.1'
30
30
  gemfile:
31
- - rails-5.2
32
31
  - rails-6.0
33
32
  - rails-6.1
34
33
  - rails-7.0
35
34
  - rails-main
36
35
  exclude:
37
- - ruby-version: '3.0'
38
- gemfile: rails-5.2
39
36
  - ruby-version: '3.0'
40
37
  gemfile: rails-6.0
41
- - ruby-version: '3.1'
42
- gemfile: rails-5.2
43
38
  - ruby-version: '3.1'
44
39
  gemfile: rails-6.0
@@ -6,15 +6,14 @@ addAssignees: false
6
6
 
7
7
  # A list of reviewers to be added to pull requests (GitHub user name)
8
8
  reviewers:
9
- - 16bitidol
10
- - k-myst
11
- - kodera123
12
- - kouryou
13
- - marumarism
9
+ - Dooor
10
+ - QWYNG
11
+ - bonobono555
12
+ - krororo
13
+ - lighty
14
+ - mkmn
14
15
  - motsat
15
16
  - osyo-manga
16
- - sugamasao
17
- - tknzk
18
17
  - wakasa51
19
18
  - wata727
20
19
  - yono
data/Appraisals CHANGED
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "rails-5.2" do
4
- gem "rails", "~> 5.2.0"
5
- end
6
-
7
3
  appraise "rails-main" do
8
4
  gem "rails", git: 'https://github.com/rails/rails.git', branch: "main"
9
5
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.1.0
4
+
5
+ ### Added
6
+ - [add label option #127](https://github.com/kufu/activerecord-bitemporal/pull/127)
7
+
8
+ ### Changed
9
+ - [Support for inverse_of of Rails 6.1 or higher #130](https://github.com/kufu/activerecord-bitemporal/pull/130)
10
+
11
+ ### Deprecated
12
+
13
+ ### Removed
14
+
15
+ ### Fixed
16
+
17
+ ## 4.0.0
18
+
19
+ ### Breaking Changed
20
+
21
+ - [[proposal]When bitemporal_at exists inside the nest, the specified date was not prioritized, so the date of the inner bitemporal_at is now prioritized. #121](https://github.com/kufu/activerecord-bitemporal/pull/121)
22
+ - [Drop support Rails 5.2 #122](https://github.com/kufu/activerecord-bitemporal/pull/122)
23
+ - [Add required_ruby_version >= 2.7.0 #125](https://github.com/kufu/activerecord-bitemporal/pull/125)
24
+
25
+ ### Added
26
+
27
+ - [Add support `bitemporal_callbacks` #123](https://github.com/kufu/activerecord-bitemporal/pull/123)
28
+
29
+ ```rb
30
+ class Employee < ActiveRecord::Base
31
+ include ActiveRecord::Bitemporal
32
+
33
+ after_bitemporal_create :log_create
34
+ after_bitemporal_update :log_update
35
+ after_bitemporal_destroy :log_destroy
36
+
37
+ private
38
+
39
+ def log_create
40
+ puts "employee created"
41
+ end
42
+
43
+ def log_update
44
+ puts "employee updated"
45
+ end
46
+
47
+ def log_destroy
48
+ puts "employee destroyed"
49
+ end
50
+ end
51
+
52
+ employee = Employee.create!(...) # => "employee created"
53
+ employee.update!(...) # => "employee updated"
54
+ employee.destroy! # => "employee destroyed"
55
+ ```
56
+
57
+ ### Changed
58
+
59
+ - [Update auto asgn #124](https://github.com/kufu/activerecord-bitemporal/pull/124)
60
+ - [Update License and CoC files #115](https://github.com/kufu/activerecord-bitemporal/pull/115)
61
+
62
+ ### Deprecated
63
+
64
+ ### Removed
65
+
66
+ - [Remove Gemfile.lock #126](https://github.com/kufu/activerecord-bitemporal/pull/126)
67
+ - [Remove test cases for using bitemporal_option_merge! of ActiveRecord:::Bitemporal::Callbacks #129](https://github.com/kufu/activerecord-bitemporal/pull/129)
68
+
69
+ ### Fixed
70
+
71
+
3
72
  ## 3.0.0
4
73
 
5
74
  ### Breaking Changed
@@ -0,0 +1,86 @@
1
+ # コントリビューター行動規範
2
+
3
+ ## 私たちの約束
4
+ メンバー、コントリビューター、およびリーダーとして、年齢、体の大きさ、目に見えるまたは目に見えない障害、民族性、性別、
5
+ 性同一性、表現、経験のレベル、教育、社会経済的地位、国籍、人格、人種、宗教、または性的同一性と指向に関係なく、
6
+ コミュニティへの参加をハラスメントのない体験にすることを誓います。
7
+
8
+ 私たちは、オープンで親しみやすく、多様で包括的で健全なコミュニティに貢献する方法で行動し、交流することを誓います。
9
+
10
+ ## 私たちの標準
11
+
12
+ 前向きな環境を作り上げることに貢献する行動の例:
13
+
14
+ * 他人への共感と優しさを示す
15
+
16
+ * 異なる意見、視点、経験を尊重する
17
+
18
+ * 建設的なフィードバックを与え、優雅に受け入れる
19
+
20
+ * 私たちの過ちの影響を受けた人々に責任を受け入れ、謝罪し、そしてその経験から学ぶ
21
+
22
+ * 個人としてだけでなく、コミュニティ全体にとっても最善であることに焦点を当てる
23
+
24
+ 許容できない行動の例は次のとおりです。
25
+
26
+ * 性的な言葉や画像の使用、および性的な注意またはその他あらゆる種類の問題行為
27
+
28
+ * トローリング、侮辱的または中傷的なコメント、個人的または政治的攻撃
29
+
30
+ * 公的またはプライベートの嫌がらせ
31
+
32
+ * 明示的な許可なしに、住所や電子メールアドレスなど、他者の個人情報を公開する
33
+
34
+ * 職業上不適切と合理的に考えられるその他の行為
35
+
36
+ ## 執行責任
37
+
38
+ コミュニティリーダーは、許容される行動の基準を明確にし、実施する責任があり、不適切、脅迫的、攻撃的、または有害と見なされる行動に応じて、適切で公正な是正措置を講じます。
39
+
40
+ コミュニティリーダーは、コメント、コミット、コード、wikiの編集、問題、およびこの行動規範に沿っていないその他の貢献を削除、編集、または拒否する権利と責任を持ち、適切な場合はモデレーションの決定の理由を伝えます。
41
+
42
+ ## 適用範囲
43
+
44
+ この行動規範は、すべてのコミュニティスペース内で適用され、個人がパブリックスペースでコミュニティを公式に代表している場合にも適用されます。
45
+ 私たちのコミュニティを代表する例には、公式の電子メールアドレスの使用、公式のソーシャルメディアアカウントを介した投稿、オンラインまたはオフラインのイベントでの指定代理人としての行動などがあります。
46
+
47
+ ## 執行
48
+
49
+ 虐待的、嫌がらせ、またはその他の許容できない行動の事例は、執行を担当するコミュニティリーダーに対して `oss@smarthr.co.jp` で報告される場合があります。
50
+ すべての苦情は迅速かつ公正にレビューおよび調査されます。
51
+
52
+ すべてのコミュニティリーダーは、問題の報告者のプライバシーとセキュリティを尊重する義務があります。
53
+
54
+ ## 執行ガイドライン
55
+
56
+ コミュニティリーダーは、この行動規範に違反していると見なした行動への帰結を判断する際に、これらのコミュニティガイドラインに従います。
57
+
58
+ ### 1. 更生
59
+
60
+ **コミュニティへの影響**: コミュニティで専門家にふさわしくない、または歓迎されないと思われる不適切な言葉の使用やその他の不適切な行動をすること。
61
+
62
+ **帰結**: コミュニティリーダーからの非公開の書面による警告。違反の理由を明確にし、行動が不適切だった理由を説明します。 公の謝罪が要求される場合があります。
63
+
64
+ ### 2. 警告
65
+
66
+ **コミュニティへの影響**: 単一の出来事または一連の動作による違反。
67
+
68
+ **帰結**: 持続的な行動の結果を伴う警告。 指定された期間、行動規範の実施者との一方的な対話を含め、関係者との対話はありません。 これには、コミュニティスペースやソーシャルメディアなどの外部チャネルでの相互作用の回避が含まれます。 これらの条件に違反すると、一時的または永続的に禁止される場合があります。
69
+
70
+ ### 3. 一時的な禁止
71
+ **コミュニティへの影響**: 持続的で不適切な行動を含む、コミュニティ標準の重大な違反。
72
+
73
+ **帰結**: 指定された期間のコミュニティとのあらゆる種類の相互関係または公的なコミュニケーションの一時的な禁止。 この期間中、行動規範を実施する人々との一方的な対話を含め、関係する人々との公的または私的な対話は許可されません。
74
+ これらの条件に違反すると、永久的に禁止される場合があります。
75
+ ### 4. 永久的な禁止
76
+ **コミュニティへの影響**: 連続的な不適切な行動、個人への嫌がらせ、または個人の集団に対する攻撃または名誉毀損を含む、コミュニティの標準への違反のパターンを示す。
77
+
78
+ **帰結**: コミュニティ内でのあらゆる種類の公的な相互関係の永久的な禁止。
79
+
80
+ ## 帰属
81
+ この行動規範は、https://www.contributor-covenant.org/version/2/0/code_of_conduct.html で利用可能な [Contributor Covenant][homepage] バージョン2.0を基に作成されています。
82
+
83
+ コミュニティへの影響ガイドラインは[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity)に適合しています。
84
+
85
+ [homepage]: https://www.contributor-covenant.org
86
+ この行動規範に関する一般的な質問への回答については、https://www.contributor-covenant.org/faq のFAQを参照してください。翻訳はhttps://www.contributor-covenant.org/translations で入手できます。
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,74 +1,133 @@
1
+
1
2
  # Contributor Covenant Code of Conduct
2
3
 
3
4
  ## Our Pledge
4
5
 
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
11
15
 
12
16
  ## Our Standards
13
17
 
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
16
20
 
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
22
28
 
23
- Examples of unacceptable behavior by participants include:
29
+ Examples of unacceptable behavior include:
24
30
 
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
28
34
  * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
31
37
  * Other conduct which could reasonably be considered inappropriate in a
32
38
  professional setting
33
39
 
34
- ## Our Responsibilities
40
+ ## Enforcement Responsibilities
35
41
 
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
39
46
 
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
45
51
 
46
52
  ## Scope
47
53
 
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
54
59
 
55
60
  ## Enforcement
56
61
 
57
62
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at dev@smarthr.jp. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
+ reported to the community leaders responsible for enforcement at
64
+ `oss@smarthr.co.jp`.
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
63
85
 
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
86
+ **Community Impact**: A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within
114
+ the community.
67
115
 
68
116
  ## Attribution
69
117
 
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.0, available at
120
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
121
+
122
+ Community Impact Guidelines were inspired by
123
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124
+
125
+ For answers to common questions about this code of conduct, see the FAQ at
126
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
127
+ at [https://www.contributor-covenant.org/translations][translations].
72
128
 
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
129
+ [homepage]: https://www.contributor-covenant.org
130
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
131
+ [Mozilla CoC]: https://github.com/mozilla/diversity
132
+ [FAQ]: https://www.contributor-covenant.org/faq
133
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE CHANGED
@@ -1,202 +1,13 @@
1
+ Copyright 2023 SmartHR, Inc.
1
2
 
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
5
6
 
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+ http://www.apache.org/licenses/LICENSE-2.0
7
8
 
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright 2018 SmartHR, Inc.
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = %q{Enable ActiveRecord models to be handled as BiTemporal Data Model.}
15
15
  spec.homepage = "https://github.com/kufu/activerecord-bitemporal"
16
16
  spec.license = "Apache 2.0"
17
+ spec.required_ruby_version = ">= 2.7.0"
17
18
 
18
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
20
  f.match(%r{^(test|spec|features)/})
@@ -22,7 +23,7 @@ Gem::Specification.new do |spec|
22
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
24
  spec.require_paths = ["lib"]
24
25
 
25
- spec.add_dependency "activerecord", ">= 5.2"
26
+ spec.add_dependency "activerecord", ">= 6.0"
26
27
 
27
28
  spec.add_development_dependency "bundler"
28
29
  spec.add_development_dependency "rake", "~> 13.0"
@@ -317,9 +317,9 @@ module ActiveRecord
317
317
  # MEMO: このメソッドに来るまでに validation が発動しているので、以後 validate は考慮しなくて大丈夫
318
318
  ActiveRecord::Base.transaction(requires_new: true) do
319
319
  current_valid_record&.update_transaction_to(current_valid_record.transaction_to)
320
- before_instance&.save!(validate: false)
320
+ before_instance&.save_without_bitemporal_callbacks!(validate: false)
321
321
  # NOTE: after_instance always exists
322
- after_instance.save!(validate: false)
322
+ after_instance.save_without_bitemporal_callbacks!(validate: false)
323
323
 
324
324
  # update 後に新しく生成したインスタンスのデータを移行する
325
325
  @_swapped_id_previously_was = swapped_id
@@ -350,7 +350,7 @@ module ActiveRecord
350
350
  # 削除時の状態を履歴レコードとして保存する
351
351
  duplicated_instance.valid_to = target_datetime
352
352
  duplicated_instance.transaction_from = current_time
353
- duplicated_instance.save!(validate: false)
353
+ duplicated_instance.save_without_bitemporal_callbacks!(validate: false)
354
354
  if @destroyed
355
355
  @_swapped_id_previously_was = swapped_id
356
356
  @_swapped_id = duplicated_instance.swapped_id
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord::Bitemporal
4
+ module Callbacks
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ define_model_callbacks :bitemporal_create
9
+ define_model_callbacks :bitemporal_update
10
+ define_model_callbacks :bitemporal_destroy
11
+ end
12
+
13
+ def destroy
14
+ perform_bitemporal_callbacks? ? run_callbacks(:bitemporal_destroy) { super } : super
15
+ end
16
+
17
+ def save_without_bitemporal_callbacks!(...)
18
+ with_bitemporal_option(ignore_bitemporal_callbacks: true) {
19
+ save!(...)
20
+ }
21
+ end
22
+
23
+ private
24
+
25
+ def _create_record
26
+ perform_bitemporal_callbacks? ? run_callbacks(:bitemporal_create) { super } : super
27
+ end
28
+
29
+ def _update_record(*)
30
+ perform_bitemporal_callbacks? ? run_callbacks(:bitemporal_update) { super } : super
31
+ end
32
+
33
+ def perform_bitemporal_callbacks?
34
+ bitemporal_option[:ignore_bitemporal_callbacks] != true
35
+ end
36
+ end
37
+ end
@@ -79,6 +79,18 @@ module ActiveRecord::Bitemporal
79
79
  def bi_temporal_model?
80
80
  owner.class.bi_temporal_model? && klass&.bi_temporal_model?
81
81
  end
82
+
83
+ def matches_foreign_key?(record)
84
+ return super unless owner.class.bi_temporal_model?
85
+
86
+ begin
87
+ original_owner_id = owner.id
88
+ owner.id = owner.read_attribute(owner.class.bitemporal_id_key)
89
+ super
90
+ ensure
91
+ owner.id = original_owner_id
92
+ end
93
+ end
82
94
  end
83
95
 
84
96
  module ThroughAssociation
@@ -407,15 +407,15 @@ module ActiveRecord::Bitemporal
407
407
  }
408
408
 
409
409
  scope :bitemporal_at, -> (datetime) {
410
- datetime = Time.current if datetime.nil?
411
410
  relation = self
411
+ current_time = Time.current
412
412
 
413
413
  if !ActiveRecord::Bitemporal.ignore_transaction_datetime?
414
- relation = relation.transaction_at(ActiveRecord::Bitemporal.transaction_datetime || datetime)
414
+ relation = relation.transaction_at(datetime || ActiveRecord::Bitemporal.transaction_datetime || current_time)
415
415
  end
416
416
 
417
417
  if !ActiveRecord::Bitemporal.ignore_valid_datetime?
418
- relation = relation.valid_at(ActiveRecord::Bitemporal.valid_datetime || datetime)
418
+ relation = relation.valid_at(datetime || ActiveRecord::Bitemporal.valid_datetime || current_time)
419
419
  end
420
420
 
421
421
  relation
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Bitemporal
5
- VERSION = "3.0.0"
5
+ VERSION = "4.1.0"
6
6
  end
7
7
  end
@@ -91,8 +91,17 @@ module ActiveRecord::Bitemporal
91
91
  end
92
92
  end
93
93
  end
94
-
95
- "#{headers.to_s}\n#{body.to_s}"
94
+
95
+ transaction_label = 'transaction_datetime'
96
+ right_margin = time_length + 1 - transaction_label.size
97
+
98
+ label = if right_margin >= 0
99
+ "#{transaction_label + ' ' * right_margin}| valid_datetime"
100
+ else
101
+ "#{transaction_label[0...right_margin]}| valid_datetime"
102
+ end
103
+
104
+ "#{label}\n#{headers.to_s}\n#{body.to_s}"
96
105
  end
97
106
 
98
107
  # Compute a dictionary of where each time should be plotted.
@@ -7,6 +7,7 @@ require "activerecord-bitemporal/scope"
7
7
  require "activerecord-bitemporal/patches"
8
8
  require "activerecord-bitemporal/version"
9
9
  require "activerecord-bitemporal/visualizer"
10
+ require "activerecord-bitemporal/callbacks"
10
11
 
11
12
  module ActiveRecord::Bitemporal
12
13
  DEFAULT_VALID_FROM = Time.utc(1900, 12, 31).in_time_zone.freeze
@@ -123,6 +124,7 @@ module ActiveRecord::Bitemporal::Bitemporalize
123
124
  extend ClassMethods
124
125
  include InstanceMethods
125
126
  include ActiveRecord::Bitemporal::Scope
127
+ include ActiveRecord::Bitemporal::Callbacks
126
128
 
127
129
  if enable_merge_with_except_bitemporal_default_scope
128
130
  relation_delegate_class(ActiveRecord::Relation).prepend ActiveRecord::Bitemporal::Relation::MergeWithExceptBitemporalDefaultScope
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-bitemporal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SmartHR
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-01 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
19
+ version: '6.0'
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.2'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -149,9 +149,9 @@ files:
149
149
  - ".gitignore"
150
150
  - Appraisals
151
151
  - CHANGELOG.md
152
+ - CODE_OF_CONDUCT.jp.md
152
153
  - CODE_OF_CONDUCT.md
153
154
  - Gemfile
154
- - Gemfile.lock
155
155
  - LICENSE
156
156
  - README.md
157
157
  - Rakefile
@@ -159,13 +159,13 @@ files:
159
159
  - bin/console
160
160
  - bin/setup
161
161
  - docker-compose.yml
162
- - gemfiles/rails_5.2.gemfile
163
162
  - gemfiles/rails_6.0.gemfile
164
163
  - gemfiles/rails_6.1.gemfile
165
164
  - gemfiles/rails_7.0.gemfile
166
165
  - gemfiles/rails_main.gemfile
167
166
  - lib/activerecord-bitemporal.rb
168
167
  - lib/activerecord-bitemporal/bitemporal.rb
168
+ - lib/activerecord-bitemporal/callbacks.rb
169
169
  - lib/activerecord-bitemporal/patches.rb
170
170
  - lib/activerecord-bitemporal/scope.rb
171
171
  - lib/activerecord-bitemporal/version.rb
@@ -182,14 +182,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - ">="
184
184
  - !ruby/object:Gem::Version
185
- version: '0'
185
+ version: 2.7.0
186
186
  required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  requirements:
188
188
  - - ">="
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.1.6
192
+ rubygems_version: 3.3.26
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: BiTemporal Data Model for ActiveRecord
data/Gemfile.lock DELETED
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- activerecord-bitemporal (3.0.0)
5
- activerecord (>= 5.2)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (7.0.4.2)
11
- activesupport (= 7.0.4.2)
12
- activerecord (7.0.4.2)
13
- activemodel (= 7.0.4.2)
14
- activesupport (= 7.0.4.2)
15
- activesupport (7.0.4.2)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 1.6, < 2)
18
- minitest (>= 5.1)
19
- tzinfo (~> 2.0)
20
- appraisal (2.2.0)
21
- bundler
22
- rake
23
- thor (>= 0.14.0)
24
- byebug (10.0.2)
25
- coderay (1.1.2)
26
- concurrent-ruby (1.2.0)
27
- database_cleaner (1.7.0)
28
- diff-lcs (1.3)
29
- i18n (1.12.0)
30
- concurrent-ruby (~> 1.0)
31
- method_source (0.9.0)
32
- minitest (5.17.0)
33
- pg (1.1.3)
34
- pry (0.11.3)
35
- coderay (~> 1.1.0)
36
- method_source (~> 0.9.0)
37
- pry-byebug (3.6.0)
38
- byebug (~> 10.0)
39
- pry (~> 0.10)
40
- rake (13.0.1)
41
- rspec (3.8.0)
42
- rspec-core (~> 3.8.0)
43
- rspec-expectations (~> 3.8.0)
44
- rspec-mocks (~> 3.8.0)
45
- rspec-core (3.8.0)
46
- rspec-support (~> 3.8.0)
47
- rspec-expectations (3.8.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-mocks (3.8.0)
51
- diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-support (3.8.0)
54
- thor (0.20.3)
55
- timecop (0.9.1)
56
- tzinfo (2.0.6)
57
- concurrent-ruby (~> 1.0)
58
-
59
- PLATFORMS
60
- ruby
61
-
62
- DEPENDENCIES
63
- activerecord-bitemporal!
64
- appraisal
65
- bundler
66
- database_cleaner
67
- pg
68
- pry
69
- pry-byebug
70
- rake (~> 13.0)
71
- rspec (~> 3.0)
72
- timecop
73
-
74
- BUNDLED WITH
75
- 2.2.3
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "rails", "~> 5.2.0"
7
-
8
- gemspec path: "../"