write_once 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b8beaf274ef4aaf1cc45ec97c7604a6a3cd5ebc7c24a1cde8ca3ca0d835f284d
4
+ data.tar.gz: 717be275ced78cf53d260e719a45b994dc323aec3d953d426582a5142f86c2c2
5
+ SHA512:
6
+ metadata.gz: b5a7b685ce6d81ef766ea143fa19e6094a111c9c4edbfb7f93a6a3b31168b3bf64cd135b01341be947fbd708761b2bb45df5659d4ca47c3588edacd81a18ce19
7
+ data.tar.gz: f55a0b8967b26e9e1a3cd4464e513215ac4f372b91cfd0a644239d16ffd28138468613bc9ba9bfb25b68e5394b1db7794cbcb00f919406bab7f87fdcf6dbd8b3
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "activerecord-6.1" do
2
+ gem "activerecord", "~> 6.1"
3
+ end
4
+
5
+ appraise "activerecord-7.0" do
6
+ gem "activerecord", "~> 7.0"
7
+ end
8
+
9
+ appraise "activerecord-7.1" do
10
+ gem "activerecord", "~> 7.1"
11
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-03-08
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at noel.rappin@chime.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Noel Rappin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # WriteOnce
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/write_once`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/write_once. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/write_once/blob/main/CODE_OF_CONDUCT.md).
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the WriteOnce project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/write_once/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "standard"
8
+ gem "appraisal"
9
+ gem "activerecord", "~> 6.1"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,119 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ write_once (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (6.1.7.3)
10
+ activesupport (= 6.1.7.3)
11
+ activerecord (6.1.7.3)
12
+ activemodel (= 6.1.7.3)
13
+ activesupport (= 6.1.7.3)
14
+ activesupport (6.1.7.3)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ zeitwerk (~> 2.3)
20
+ appraisal (2.5.0)
21
+ bundler
22
+ rake
23
+ thor (>= 0.14.0)
24
+ ast (2.4.2)
25
+ concurrent-ruby (1.2.3)
26
+ debug (1.9.1)
27
+ irb (~> 1.10)
28
+ reline (>= 0.3.8)
29
+ diff-lcs (1.5.0)
30
+ i18n (1.14.1)
31
+ concurrent-ruby (~> 1.0)
32
+ io-console (0.7.1)
33
+ irb (1.11.0)
34
+ rdoc
35
+ reline (>= 0.3.8)
36
+ json (2.7.1)
37
+ language_server-protocol (3.17.0.3)
38
+ lint_roller (1.1.0)
39
+ minitest (5.21.2)
40
+ parallel (1.24.0)
41
+ parser (3.3.0.5)
42
+ ast (~> 2.4.1)
43
+ racc
44
+ psych (5.1.2)
45
+ stringio
46
+ racc (1.7.3)
47
+ rainbow (3.1.1)
48
+ rake (13.1.0)
49
+ rdoc (6.6.2)
50
+ psych (>= 4.0.0)
51
+ regexp_parser (2.9.0)
52
+ reline (0.4.1)
53
+ io-console (~> 0.5)
54
+ rexml (3.2.6)
55
+ rspec (3.12.0)
56
+ rspec-core (~> 3.12.0)
57
+ rspec-expectations (~> 3.12.0)
58
+ rspec-mocks (~> 3.12.0)
59
+ rspec-core (3.12.2)
60
+ rspec-support (~> 3.12.0)
61
+ rspec-expectations (3.12.3)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.12.0)
64
+ rspec-mocks (3.12.6)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.12.0)
67
+ rspec-support (3.12.1)
68
+ rubocop (1.62.0)
69
+ json (~> 2.3)
70
+ language_server-protocol (>= 3.17.0)
71
+ parallel (~> 1.10)
72
+ parser (>= 3.3.0.2)
73
+ rainbow (>= 2.2.2, < 4.0)
74
+ regexp_parser (>= 1.8, < 3.0)
75
+ rexml (>= 3.2.5, < 4.0)
76
+ rubocop-ast (>= 1.31.1, < 2.0)
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (>= 2.4.0, < 3.0)
79
+ rubocop-ast (1.31.2)
80
+ parser (>= 3.3.0.4)
81
+ rubocop-performance (1.20.2)
82
+ rubocop (>= 1.48.1, < 2.0)
83
+ rubocop-ast (>= 1.30.0, < 2.0)
84
+ ruby-progressbar (1.13.0)
85
+ sqlite3 (1.7.2-x86_64-darwin)
86
+ standard (1.34.0)
87
+ language_server-protocol (~> 3.17.0.2)
88
+ lint_roller (~> 1.0)
89
+ rubocop (~> 1.60)
90
+ standard-custom (~> 1.0.0)
91
+ standard-performance (~> 1.3)
92
+ standard-custom (1.0.2)
93
+ lint_roller (~> 1.0)
94
+ rubocop (~> 1.50)
95
+ standard-performance (1.3.1)
96
+ lint_roller (~> 1.1)
97
+ rubocop-performance (~> 1.20.2)
98
+ stringio (3.1.0)
99
+ thor (1.3.0)
100
+ tzinfo (2.0.6)
101
+ concurrent-ruby (~> 1.0)
102
+ unicode-display_width (2.5.0)
103
+ zeitwerk (2.6.12)
104
+
105
+ PLATFORMS
106
+ x86_64-darwin-20
107
+
108
+ DEPENDENCIES
109
+ activerecord (~> 6.1)
110
+ appraisal
111
+ debug
112
+ rake (~> 13.0)
113
+ rspec (~> 3.0)
114
+ sqlite3
115
+ standard
116
+ write_once!
117
+
118
+ BUNDLED WITH
119
+ 2.2.32
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "standard"
8
+ gem "appraisal"
9
+ gem "activerecord", "~> 7.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,260 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ write_once (0.1.0)
5
+ rails (>= 5.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.1.2)
11
+ actionpack (= 7.1.2)
12
+ activesupport (= 7.1.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ zeitwerk (~> 2.6)
16
+ actionmailbox (7.1.2)
17
+ actionpack (= 7.1.2)
18
+ activejob (= 7.1.2)
19
+ activerecord (= 7.1.2)
20
+ activestorage (= 7.1.2)
21
+ activesupport (= 7.1.2)
22
+ mail (>= 2.7.1)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.1.2)
27
+ actionpack (= 7.1.2)
28
+ actionview (= 7.1.2)
29
+ activejob (= 7.1.2)
30
+ activesupport (= 7.1.2)
31
+ mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
35
+ rails-dom-testing (~> 2.2)
36
+ actionpack (7.1.2)
37
+ actionview (= 7.1.2)
38
+ activesupport (= 7.1.2)
39
+ nokogiri (>= 1.8.5)
40
+ racc
41
+ rack (>= 2.2.4)
42
+ rack-session (>= 1.0.1)
43
+ rack-test (>= 0.6.3)
44
+ rails-dom-testing (~> 2.2)
45
+ rails-html-sanitizer (~> 1.6)
46
+ actiontext (7.1.2)
47
+ actionpack (= 7.1.2)
48
+ activerecord (= 7.1.2)
49
+ activestorage (= 7.1.2)
50
+ activesupport (= 7.1.2)
51
+ globalid (>= 0.6.0)
52
+ nokogiri (>= 1.8.5)
53
+ actionview (7.1.2)
54
+ activesupport (= 7.1.2)
55
+ builder (~> 3.1)
56
+ erubi (~> 1.11)
57
+ rails-dom-testing (~> 2.2)
58
+ rails-html-sanitizer (~> 1.6)
59
+ activejob (7.1.2)
60
+ activesupport (= 7.1.2)
61
+ globalid (>= 0.3.6)
62
+ activemodel (7.1.2)
63
+ activesupport (= 7.1.2)
64
+ activerecord (7.1.2)
65
+ activemodel (= 7.1.2)
66
+ activesupport (= 7.1.2)
67
+ timeout (>= 0.4.0)
68
+ activestorage (7.1.2)
69
+ actionpack (= 7.1.2)
70
+ activejob (= 7.1.2)
71
+ activerecord (= 7.1.2)
72
+ activesupport (= 7.1.2)
73
+ marcel (~> 1.0)
74
+ activesupport (7.1.2)
75
+ base64
76
+ bigdecimal
77
+ concurrent-ruby (~> 1.0, >= 1.0.2)
78
+ connection_pool (>= 2.2.5)
79
+ drb
80
+ i18n (>= 1.6, < 2)
81
+ minitest (>= 5.1)
82
+ mutex_m
83
+ tzinfo (~> 2.0)
84
+ appraisal (2.5.0)
85
+ bundler
86
+ rake
87
+ thor (>= 0.14.0)
88
+ ast (2.4.2)
89
+ base64 (0.2.0)
90
+ bigdecimal (3.1.6)
91
+ builder (3.2.4)
92
+ concurrent-ruby (1.2.3)
93
+ connection_pool (2.4.1)
94
+ crass (1.0.6)
95
+ date (3.3.4)
96
+ debug (1.9.1)
97
+ irb (~> 1.10)
98
+ reline (>= 0.3.8)
99
+ diff-lcs (1.5.0)
100
+ drb (2.2.0)
101
+ ruby2_keywords
102
+ erubi (1.12.0)
103
+ globalid (1.2.1)
104
+ activesupport (>= 6.1)
105
+ i18n (1.14.1)
106
+ concurrent-ruby (~> 1.0)
107
+ io-console (0.7.1)
108
+ irb (1.11.0)
109
+ rdoc
110
+ reline (>= 0.3.8)
111
+ json (2.7.1)
112
+ language_server-protocol (3.17.0.3)
113
+ lint_roller (1.1.0)
114
+ loofah (2.22.0)
115
+ crass (~> 1.0.2)
116
+ nokogiri (>= 1.12.0)
117
+ mail (2.8.1)
118
+ mini_mime (>= 0.1.1)
119
+ net-imap
120
+ net-pop
121
+ net-smtp
122
+ marcel (1.0.2)
123
+ mini_mime (1.1.5)
124
+ minitest (5.21.2)
125
+ mutex_m (0.2.0)
126
+ net-imap (0.4.8)
127
+ date
128
+ net-protocol
129
+ net-pop (0.1.2)
130
+ net-protocol
131
+ net-protocol (0.2.2)
132
+ timeout
133
+ net-smtp (0.4.0)
134
+ net-protocol
135
+ nio4r (2.7.0)
136
+ nokogiri (1.16.2-x86_64-darwin)
137
+ racc (~> 1.4)
138
+ parallel (1.24.0)
139
+ parser (3.3.0.5)
140
+ ast (~> 2.4.1)
141
+ racc
142
+ psych (5.1.2)
143
+ stringio
144
+ racc (1.7.3)
145
+ rack (3.0.8)
146
+ rack-session (2.0.0)
147
+ rack (>= 3.0.0)
148
+ rack-test (2.1.0)
149
+ rack (>= 1.3)
150
+ rackup (2.1.0)
151
+ rack (>= 3)
152
+ webrick (~> 1.8)
153
+ rails (7.1.2)
154
+ actioncable (= 7.1.2)
155
+ actionmailbox (= 7.1.2)
156
+ actionmailer (= 7.1.2)
157
+ actionpack (= 7.1.2)
158
+ actiontext (= 7.1.2)
159
+ actionview (= 7.1.2)
160
+ activejob (= 7.1.2)
161
+ activemodel (= 7.1.2)
162
+ activerecord (= 7.1.2)
163
+ activestorage (= 7.1.2)
164
+ activesupport (= 7.1.2)
165
+ bundler (>= 1.15.0)
166
+ railties (= 7.1.2)
167
+ rails-dom-testing (2.2.0)
168
+ activesupport (>= 5.0.0)
169
+ minitest
170
+ nokogiri (>= 1.6)
171
+ rails-html-sanitizer (1.6.0)
172
+ loofah (~> 2.21)
173
+ nokogiri (~> 1.14)
174
+ railties (7.1.2)
175
+ actionpack (= 7.1.2)
176
+ activesupport (= 7.1.2)
177
+ irb
178
+ rackup (>= 1.0.0)
179
+ rake (>= 12.2)
180
+ thor (~> 1.0, >= 1.2.2)
181
+ zeitwerk (~> 2.6)
182
+ rainbow (3.1.1)
183
+ rake (13.1.0)
184
+ rdoc (6.6.2)
185
+ psych (>= 4.0.0)
186
+ regexp_parser (2.9.0)
187
+ reline (0.4.1)
188
+ io-console (~> 0.5)
189
+ rexml (3.2.6)
190
+ rspec (3.12.0)
191
+ rspec-core (~> 3.12.0)
192
+ rspec-expectations (~> 3.12.0)
193
+ rspec-mocks (~> 3.12.0)
194
+ rspec-core (3.12.2)
195
+ rspec-support (~> 3.12.0)
196
+ rspec-expectations (3.12.3)
197
+ diff-lcs (>= 1.2.0, < 2.0)
198
+ rspec-support (~> 3.12.0)
199
+ rspec-mocks (3.12.6)
200
+ diff-lcs (>= 1.2.0, < 2.0)
201
+ rspec-support (~> 3.12.0)
202
+ rspec-support (3.12.1)
203
+ rubocop (1.62.0)
204
+ json (~> 2.3)
205
+ language_server-protocol (>= 3.17.0)
206
+ parallel (~> 1.10)
207
+ parser (>= 3.3.0.2)
208
+ rainbow (>= 2.2.2, < 4.0)
209
+ regexp_parser (>= 1.8, < 3.0)
210
+ rexml (>= 3.2.5, < 4.0)
211
+ rubocop-ast (>= 1.31.1, < 2.0)
212
+ ruby-progressbar (~> 1.7)
213
+ unicode-display_width (>= 2.4.0, < 3.0)
214
+ rubocop-ast (1.31.2)
215
+ parser (>= 3.3.0.4)
216
+ rubocop-performance (1.20.2)
217
+ rubocop (>= 1.48.1, < 2.0)
218
+ rubocop-ast (>= 1.30.0, < 2.0)
219
+ ruby-progressbar (1.13.0)
220
+ ruby2_keywords (0.0.5)
221
+ sqlite3 (1.7.2-x86_64-darwin)
222
+ standard (1.34.0)
223
+ language_server-protocol (~> 3.17.0.2)
224
+ lint_roller (~> 1.0)
225
+ rubocop (~> 1.60)
226
+ standard-custom (~> 1.0.0)
227
+ standard-performance (~> 1.3)
228
+ standard-custom (1.0.2)
229
+ lint_roller (~> 1.0)
230
+ rubocop (~> 1.50)
231
+ standard-performance (1.3.1)
232
+ lint_roller (~> 1.1)
233
+ rubocop-performance (~> 1.20.2)
234
+ stringio (3.1.0)
235
+ thor (1.3.0)
236
+ timeout (0.4.1)
237
+ tzinfo (2.0.6)
238
+ concurrent-ruby (~> 1.0)
239
+ unicode-display_width (2.5.0)
240
+ webrick (1.8.1)
241
+ websocket-driver (0.7.6)
242
+ websocket-extensions (>= 0.1.0)
243
+ websocket-extensions (0.1.5)
244
+ zeitwerk (2.6.12)
245
+
246
+ PLATFORMS
247
+ x86_64-darwin-20
248
+
249
+ DEPENDENCIES
250
+ activerecord (~> 7.0)
251
+ appraisal
252
+ debug
253
+ rake (~> 13.0)
254
+ rspec (~> 3.0)
255
+ sqlite3
256
+ standard
257
+ write_once!
258
+
259
+ BUNDLED WITH
260
+ 2.2.32
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "standard"
8
+ gem "appraisal"
9
+ gem "activerecord", "~> 7.1"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,260 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ write_once (0.1.0)
5
+ rails (>= 5.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.1.2)
11
+ actionpack (= 7.1.2)
12
+ activesupport (= 7.1.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ zeitwerk (~> 2.6)
16
+ actionmailbox (7.1.2)
17
+ actionpack (= 7.1.2)
18
+ activejob (= 7.1.2)
19
+ activerecord (= 7.1.2)
20
+ activestorage (= 7.1.2)
21
+ activesupport (= 7.1.2)
22
+ mail (>= 2.7.1)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.1.2)
27
+ actionpack (= 7.1.2)
28
+ actionview (= 7.1.2)
29
+ activejob (= 7.1.2)
30
+ activesupport (= 7.1.2)
31
+ mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
35
+ rails-dom-testing (~> 2.2)
36
+ actionpack (7.1.2)
37
+ actionview (= 7.1.2)
38
+ activesupport (= 7.1.2)
39
+ nokogiri (>= 1.8.5)
40
+ racc
41
+ rack (>= 2.2.4)
42
+ rack-session (>= 1.0.1)
43
+ rack-test (>= 0.6.3)
44
+ rails-dom-testing (~> 2.2)
45
+ rails-html-sanitizer (~> 1.6)
46
+ actiontext (7.1.2)
47
+ actionpack (= 7.1.2)
48
+ activerecord (= 7.1.2)
49
+ activestorage (= 7.1.2)
50
+ activesupport (= 7.1.2)
51
+ globalid (>= 0.6.0)
52
+ nokogiri (>= 1.8.5)
53
+ actionview (7.1.2)
54
+ activesupport (= 7.1.2)
55
+ builder (~> 3.1)
56
+ erubi (~> 1.11)
57
+ rails-dom-testing (~> 2.2)
58
+ rails-html-sanitizer (~> 1.6)
59
+ activejob (7.1.2)
60
+ activesupport (= 7.1.2)
61
+ globalid (>= 0.3.6)
62
+ activemodel (7.1.2)
63
+ activesupport (= 7.1.2)
64
+ activerecord (7.1.2)
65
+ activemodel (= 7.1.2)
66
+ activesupport (= 7.1.2)
67
+ timeout (>= 0.4.0)
68
+ activestorage (7.1.2)
69
+ actionpack (= 7.1.2)
70
+ activejob (= 7.1.2)
71
+ activerecord (= 7.1.2)
72
+ activesupport (= 7.1.2)
73
+ marcel (~> 1.0)
74
+ activesupport (7.1.2)
75
+ base64
76
+ bigdecimal
77
+ concurrent-ruby (~> 1.0, >= 1.0.2)
78
+ connection_pool (>= 2.2.5)
79
+ drb
80
+ i18n (>= 1.6, < 2)
81
+ minitest (>= 5.1)
82
+ mutex_m
83
+ tzinfo (~> 2.0)
84
+ appraisal (2.5.0)
85
+ bundler
86
+ rake
87
+ thor (>= 0.14.0)
88
+ ast (2.4.2)
89
+ base64 (0.2.0)
90
+ bigdecimal (3.1.6)
91
+ builder (3.2.4)
92
+ concurrent-ruby (1.2.3)
93
+ connection_pool (2.4.1)
94
+ crass (1.0.6)
95
+ date (3.3.4)
96
+ debug (1.9.1)
97
+ irb (~> 1.10)
98
+ reline (>= 0.3.8)
99
+ diff-lcs (1.5.0)
100
+ drb (2.2.0)
101
+ ruby2_keywords
102
+ erubi (1.12.0)
103
+ globalid (1.2.1)
104
+ activesupport (>= 6.1)
105
+ i18n (1.14.1)
106
+ concurrent-ruby (~> 1.0)
107
+ io-console (0.7.1)
108
+ irb (1.11.0)
109
+ rdoc
110
+ reline (>= 0.3.8)
111
+ json (2.7.1)
112
+ language_server-protocol (3.17.0.3)
113
+ lint_roller (1.1.0)
114
+ loofah (2.22.0)
115
+ crass (~> 1.0.2)
116
+ nokogiri (>= 1.12.0)
117
+ mail (2.8.1)
118
+ mini_mime (>= 0.1.1)
119
+ net-imap
120
+ net-pop
121
+ net-smtp
122
+ marcel (1.0.2)
123
+ mini_mime (1.1.5)
124
+ minitest (5.21.2)
125
+ mutex_m (0.2.0)
126
+ net-imap (0.4.8)
127
+ date
128
+ net-protocol
129
+ net-pop (0.1.2)
130
+ net-protocol
131
+ net-protocol (0.2.2)
132
+ timeout
133
+ net-smtp (0.4.0)
134
+ net-protocol
135
+ nio4r (2.7.0)
136
+ nokogiri (1.16.2-x86_64-darwin)
137
+ racc (~> 1.4)
138
+ parallel (1.24.0)
139
+ parser (3.3.0.5)
140
+ ast (~> 2.4.1)
141
+ racc
142
+ psych (5.1.2)
143
+ stringio
144
+ racc (1.7.3)
145
+ rack (3.0.8)
146
+ rack-session (2.0.0)
147
+ rack (>= 3.0.0)
148
+ rack-test (2.1.0)
149
+ rack (>= 1.3)
150
+ rackup (2.1.0)
151
+ rack (>= 3)
152
+ webrick (~> 1.8)
153
+ rails (7.1.2)
154
+ actioncable (= 7.1.2)
155
+ actionmailbox (= 7.1.2)
156
+ actionmailer (= 7.1.2)
157
+ actionpack (= 7.1.2)
158
+ actiontext (= 7.1.2)
159
+ actionview (= 7.1.2)
160
+ activejob (= 7.1.2)
161
+ activemodel (= 7.1.2)
162
+ activerecord (= 7.1.2)
163
+ activestorage (= 7.1.2)
164
+ activesupport (= 7.1.2)
165
+ bundler (>= 1.15.0)
166
+ railties (= 7.1.2)
167
+ rails-dom-testing (2.2.0)
168
+ activesupport (>= 5.0.0)
169
+ minitest
170
+ nokogiri (>= 1.6)
171
+ rails-html-sanitizer (1.6.0)
172
+ loofah (~> 2.21)
173
+ nokogiri (~> 1.14)
174
+ railties (7.1.2)
175
+ actionpack (= 7.1.2)
176
+ activesupport (= 7.1.2)
177
+ irb
178
+ rackup (>= 1.0.0)
179
+ rake (>= 12.2)
180
+ thor (~> 1.0, >= 1.2.2)
181
+ zeitwerk (~> 2.6)
182
+ rainbow (3.1.1)
183
+ rake (13.1.0)
184
+ rdoc (6.6.2)
185
+ psych (>= 4.0.0)
186
+ regexp_parser (2.9.0)
187
+ reline (0.4.1)
188
+ io-console (~> 0.5)
189
+ rexml (3.2.6)
190
+ rspec (3.12.0)
191
+ rspec-core (~> 3.12.0)
192
+ rspec-expectations (~> 3.12.0)
193
+ rspec-mocks (~> 3.12.0)
194
+ rspec-core (3.12.2)
195
+ rspec-support (~> 3.12.0)
196
+ rspec-expectations (3.12.3)
197
+ diff-lcs (>= 1.2.0, < 2.0)
198
+ rspec-support (~> 3.12.0)
199
+ rspec-mocks (3.12.6)
200
+ diff-lcs (>= 1.2.0, < 2.0)
201
+ rspec-support (~> 3.12.0)
202
+ rspec-support (3.12.1)
203
+ rubocop (1.62.0)
204
+ json (~> 2.3)
205
+ language_server-protocol (>= 3.17.0)
206
+ parallel (~> 1.10)
207
+ parser (>= 3.3.0.2)
208
+ rainbow (>= 2.2.2, < 4.0)
209
+ regexp_parser (>= 1.8, < 3.0)
210
+ rexml (>= 3.2.5, < 4.0)
211
+ rubocop-ast (>= 1.31.1, < 2.0)
212
+ ruby-progressbar (~> 1.7)
213
+ unicode-display_width (>= 2.4.0, < 3.0)
214
+ rubocop-ast (1.31.2)
215
+ parser (>= 3.3.0.4)
216
+ rubocop-performance (1.20.2)
217
+ rubocop (>= 1.48.1, < 2.0)
218
+ rubocop-ast (>= 1.30.0, < 2.0)
219
+ ruby-progressbar (1.13.0)
220
+ ruby2_keywords (0.0.5)
221
+ sqlite3 (1.7.2-x86_64-darwin)
222
+ standard (1.34.0)
223
+ language_server-protocol (~> 3.17.0.2)
224
+ lint_roller (~> 1.0)
225
+ rubocop (~> 1.60)
226
+ standard-custom (~> 1.0.0)
227
+ standard-performance (~> 1.3)
228
+ standard-custom (1.0.2)
229
+ lint_roller (~> 1.0)
230
+ rubocop (~> 1.50)
231
+ standard-performance (1.3.1)
232
+ lint_roller (~> 1.1)
233
+ rubocop-performance (~> 1.20.2)
234
+ stringio (3.1.0)
235
+ thor (1.3.0)
236
+ timeout (0.4.1)
237
+ tzinfo (2.0.6)
238
+ concurrent-ruby (~> 1.0)
239
+ unicode-display_width (2.5.0)
240
+ webrick (1.8.1)
241
+ websocket-driver (0.7.6)
242
+ websocket-extensions (>= 0.1.0)
243
+ websocket-extensions (0.1.5)
244
+ zeitwerk (2.6.12)
245
+
246
+ PLATFORMS
247
+ x86_64-darwin-20
248
+
249
+ DEPENDENCIES
250
+ activerecord (~> 7.1)
251
+ appraisal
252
+ debug
253
+ rake (~> 13.0)
254
+ rspec (~> 3.0)
255
+ sqlite3
256
+ standard
257
+ write_once!
258
+
259
+ BUNDLED WITH
260
+ 2.2.32
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module WriteOnce
6
+ class Configuration
7
+ attr_accessor :enforce_errors, :logger
8
+
9
+ def initialize
10
+ @enforce_errors = true
11
+ @logger = Logger.new(STDOUT)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WriteOnce
4
+ VERSION = "0.1.0"
5
+ end
data/lib/write_once.rb ADDED
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "write_once/version"
4
+ require_relative "write_once/configuration"
5
+ require "active_record"
6
+ require "active_support/concern"
7
+ require "active_support/hash_with_indifferent_access"
8
+
9
+ class WriteOnceAttributeError < StandardError; end
10
+
11
+ module WriteOnce
12
+ extend ActiveSupport::Concern
13
+
14
+ included do
15
+ class_attribute :_attr_write_once, instance_accessor: false, default: []
16
+ end
17
+
18
+ def self.configure(&block)
19
+ block.call(config)
20
+ end
21
+
22
+ def self.config
23
+ @config ||= Configuration.new
24
+ end
25
+
26
+ module ClassMethods
27
+ # Attributes listed as write_once will be used to create a new record.
28
+ # Assigning a new value to a write_once attribute that is NOT currently nil
29
+ # and is attempting to be changed on a persisted record raises an error.
30
+ #
31
+ # ==== Examples
32
+ #
33
+ # class Post < ActiveRecord::Base
34
+ # attr_write_once :title
35
+ # end
36
+ #
37
+ # post = Post.create!(title: "Introducing Ruby on Rails!")
38
+ # post.title = "a different title" # raises write_onceAttributeError
39
+ # post.update(title: "a different title") # raises write_onceAttributeError
40
+ #
41
+ # post_with_nil = Post.create!(title: nil)
42
+ # post_with_nil.title = "a different title" # works fine
43
+ #
44
+ # post_with_nil2 = Post.create!(title: nil)
45
+ # post_with_nil2.update(title: "a different title") # works fine
46
+ def attr_write_once(*attributes)
47
+ self._attr_write_once |= attributes.map(&:to_s)
48
+
49
+ include(HasWriteOnceAttributes)
50
+ end
51
+
52
+ # Returns an array of all the attributes that have been specified as write_once.
53
+ def write_once_attributes
54
+ _attr_write_once
55
+ end
56
+
57
+ def write_once_attribute?(name) # :nodoc:
58
+ _attr_write_once.include?(name)
59
+ end
60
+ end
61
+
62
+ module HasWriteOnceAttributes # :nodoc:
63
+ def valid_change?(attr_name, new_value)
64
+ current_value = send(attr_name)
65
+ current_value.nil? || current_value == new_value
66
+ end
67
+
68
+ def attr_is_write_only?(attr_name)
69
+ self.class.write_once_attribute?(attr_name.to_s)
70
+ end
71
+
72
+ def write_attribute(attr_name, value)
73
+ if !new_record? && attr_is_write_only?(attr_name) && !valid_change?(attr_name, value)
74
+ handle_error(attr_name, value)
75
+ end
76
+
77
+ super
78
+ end
79
+
80
+ def _write_attribute(attr_name, value)
81
+ if !new_record? && attr_is_write_only?(attr_name) && !valid_change?(attr_name, value)
82
+ handle_error(attr_name, value)
83
+ end
84
+
85
+ super
86
+ end
87
+
88
+ def handle_error(attr_name, value)
89
+ if WriteOnce.config.enforce_errors
90
+ raise WriteOnceAttributeError, attr_name
91
+ else
92
+ WriteOnce.config.logger.warn(
93
+ message: "Write once attribute #{attr_name} changed",
94
+ old_value: send(attr_name),
95
+ new_value: value,
96
+ )
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/write_once/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "write_once"
7
+ spec.version = WriteOnce::VERSION
8
+ spec.authors = ["Braden Staudacher"]
9
+ spec.email = ["braden.staudacher@chime.com"]
10
+
11
+ spec.summary = ""
12
+ spec.description = ""
13
+ spec.homepage = "https://github.com/1debit/write_once"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.0"
16
+
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/1debit/write_once"
20
+ spec.metadata["changelog_uri"] = "https://github.com/1debit/write_once/changelog.md"
21
+
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (File.expand_path(f) == __FILE__) ||
25
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # spec.add_dependency "rails", "~> 7.0"
33
+ spec.add_development_dependency "activerecord", "~> 7.1.2"
34
+ spec.add_development_dependency "appraisal", "~> 2.5.0"
35
+ spec.add_development_dependency "debug"
36
+ spec.add_development_dependency "sqlite3"
37
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: write_once
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Braden Staudacher
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 7.1.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 7.1.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.5.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.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: debug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: ''
70
+ email:
71
+ - braden.staudacher@chime.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rspec"
77
+ - ".rubocop.yml"
78
+ - Appraisals
79
+ - CHANGELOG.md
80
+ - CODE_OF_CONDUCT.md
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - gemfiles/activerecord_6.1.gemfile
85
+ - gemfiles/activerecord_6.1.gemfile.lock
86
+ - gemfiles/activerecord_7.0.gemfile
87
+ - gemfiles/activerecord_7.0.gemfile.lock
88
+ - gemfiles/activerecord_7.1.gemfile
89
+ - gemfiles/activerecord_7.1.gemfile.lock
90
+ - lib/write_once.rb
91
+ - lib/write_once/configuration.rb
92
+ - lib/write_once/version.rb
93
+ - write_once.gemspec
94
+ homepage: https://github.com/1debit/write_once
95
+ licenses:
96
+ - MIT
97
+ metadata:
98
+ homepage_uri: https://github.com/1debit/write_once
99
+ source_code_uri: https://github.com/1debit/write_once
100
+ changelog_uri: https://github.com/1debit/write_once/changelog.md
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubygems_version: 3.2.32
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: ''
120
+ test_files: []