planetscale_rails 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: bf23532a87e19821c294ec2ac486af07532faf348da21e961354821565c0db96
4
+ data.tar.gz: 4d099558a9f98001569e214ad1d17ec0a3eb21e29035622b907d6a4bf1c464bf
5
+ SHA512:
6
+ metadata.gz: ee1c5436a220d1c532f4469a87050c4e9b7e05d6e4d1dd22afd355d0d84039f2054581994761beea23cd49f73c8d5c79bce8982bcc9514723fa561e1a4b3a708
7
+ data.tar.gz: aa180c4dcfa9e06c2b50e88d2de7f807accd1a3675d38fb4420f1d56e450f4b6106cd7361ec2e52cc98b445ee71ca98ce917026a3f5f38275c9d06505d05780c
@@ -0,0 +1,27 @@
1
+ name: Verify dependency licenses
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ types:
9
+ - opened
10
+ - reopened
11
+ - synchronize
12
+
13
+ jobs:
14
+ licensing:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ with:
19
+ fetch-depth: 0
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: 3.1.2
24
+ bundler-cache: false
25
+ - run: bundle install
26
+ - run: gem install license_finder
27
+ - run: license_finder
@@ -0,0 +1,17 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v3
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.2.1
14
+ bundler-cache: false
15
+ - run: bundle install
16
+ - name: Run the default task
17
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /pkg/
6
+ /spec/reports/
7
+ /tmp/
8
+ *.gem
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3
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: 180
14
+
15
+ Metrics/BlockLength:
16
+ Enabled: false
17
+
18
+ Style/Documentation:
19
+ Enabled: false
20
+
21
+ Style/IfUnlessModifier:
22
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.1
@@ -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 coutermarsh.mike@gmail.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/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in planetscale_rails.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/Gemfile.lock ADDED
@@ -0,0 +1,198 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ planetscale_rails (0.1.0)
5
+ rails (~> 7.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.4.2)
11
+ actionpack (= 7.0.4.2)
12
+ activesupport (= 7.0.4.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.4.2)
16
+ actionpack (= 7.0.4.2)
17
+ activejob (= 7.0.4.2)
18
+ activerecord (= 7.0.4.2)
19
+ activestorage (= 7.0.4.2)
20
+ activesupport (= 7.0.4.2)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.4.2)
26
+ actionpack (= 7.0.4.2)
27
+ actionview (= 7.0.4.2)
28
+ activejob (= 7.0.4.2)
29
+ activesupport (= 7.0.4.2)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.4.2)
36
+ actionview (= 7.0.4.2)
37
+ activesupport (= 7.0.4.2)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.4.2)
43
+ actionpack (= 7.0.4.2)
44
+ activerecord (= 7.0.4.2)
45
+ activestorage (= 7.0.4.2)
46
+ activesupport (= 7.0.4.2)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.4.2)
50
+ activesupport (= 7.0.4.2)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.4.2)
56
+ activesupport (= 7.0.4.2)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.4.2)
59
+ activesupport (= 7.0.4.2)
60
+ activerecord (7.0.4.2)
61
+ activemodel (= 7.0.4.2)
62
+ activesupport (= 7.0.4.2)
63
+ activestorage (7.0.4.2)
64
+ actionpack (= 7.0.4.2)
65
+ activejob (= 7.0.4.2)
66
+ activerecord (= 7.0.4.2)
67
+ activesupport (= 7.0.4.2)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.4.2)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ ast (2.4.2)
76
+ builder (3.2.4)
77
+ concurrent-ruby (1.2.2)
78
+ crass (1.0.6)
79
+ date (3.3.3)
80
+ diff-lcs (1.5.0)
81
+ erubi (1.12.0)
82
+ globalid (1.1.0)
83
+ activesupport (>= 5.0)
84
+ i18n (1.12.0)
85
+ concurrent-ruby (~> 1.0)
86
+ json (2.6.3)
87
+ loofah (2.19.1)
88
+ crass (~> 1.0.2)
89
+ nokogiri (>= 1.5.9)
90
+ mail (2.8.1)
91
+ mini_mime (>= 0.1.1)
92
+ net-imap
93
+ net-pop
94
+ net-smtp
95
+ marcel (1.0.2)
96
+ method_source (1.0.0)
97
+ mini_mime (1.1.2)
98
+ minitest (5.17.0)
99
+ net-imap (0.3.4)
100
+ date
101
+ net-protocol
102
+ net-pop (0.1.2)
103
+ net-protocol
104
+ net-protocol (0.2.1)
105
+ timeout
106
+ net-smtp (0.3.3)
107
+ net-protocol
108
+ nio4r (2.5.8)
109
+ nokogiri (1.14.2-x86_64-darwin)
110
+ racc (~> 1.4)
111
+ nokogiri (1.14.2-x86_64-linux)
112
+ racc (~> 1.4)
113
+ parallel (1.22.1)
114
+ parser (3.2.1.0)
115
+ ast (~> 2.4.1)
116
+ racc (1.6.2)
117
+ rack (2.2.6.3)
118
+ rack-test (2.0.2)
119
+ rack (>= 1.3)
120
+ rails (7.0.4.2)
121
+ actioncable (= 7.0.4.2)
122
+ actionmailbox (= 7.0.4.2)
123
+ actionmailer (= 7.0.4.2)
124
+ actionpack (= 7.0.4.2)
125
+ actiontext (= 7.0.4.2)
126
+ actionview (= 7.0.4.2)
127
+ activejob (= 7.0.4.2)
128
+ activemodel (= 7.0.4.2)
129
+ activerecord (= 7.0.4.2)
130
+ activestorage (= 7.0.4.2)
131
+ activesupport (= 7.0.4.2)
132
+ bundler (>= 1.15.0)
133
+ railties (= 7.0.4.2)
134
+ rails-dom-testing (2.0.3)
135
+ activesupport (>= 4.2.0)
136
+ nokogiri (>= 1.6)
137
+ rails-html-sanitizer (1.5.0)
138
+ loofah (~> 2.19, >= 2.19.1)
139
+ railties (7.0.4.2)
140
+ actionpack (= 7.0.4.2)
141
+ activesupport (= 7.0.4.2)
142
+ method_source
143
+ rake (>= 12.2)
144
+ thor (~> 1.0)
145
+ zeitwerk (~> 2.5)
146
+ rainbow (3.1.1)
147
+ rake (13.0.6)
148
+ regexp_parser (2.7.0)
149
+ rexml (3.2.5)
150
+ rspec (3.12.0)
151
+ rspec-core (~> 3.12.0)
152
+ rspec-expectations (~> 3.12.0)
153
+ rspec-mocks (~> 3.12.0)
154
+ rspec-core (3.12.1)
155
+ rspec-support (~> 3.12.0)
156
+ rspec-expectations (3.12.2)
157
+ diff-lcs (>= 1.2.0, < 2.0)
158
+ rspec-support (~> 3.12.0)
159
+ rspec-mocks (3.12.3)
160
+ diff-lcs (>= 1.2.0, < 2.0)
161
+ rspec-support (~> 3.12.0)
162
+ rspec-support (3.12.0)
163
+ rubocop (1.47.0)
164
+ json (~> 2.3)
165
+ parallel (~> 1.10)
166
+ parser (>= 3.2.0.0)
167
+ rainbow (>= 2.2.2, < 4.0)
168
+ regexp_parser (>= 1.8, < 3.0)
169
+ rexml (>= 3.2.5, < 4.0)
170
+ rubocop-ast (>= 1.26.0, < 2.0)
171
+ ruby-progressbar (~> 1.7)
172
+ unicode-display_width (>= 2.4.0, < 3.0)
173
+ rubocop-ast (1.27.0)
174
+ parser (>= 3.2.1.0)
175
+ ruby-progressbar (1.12.0)
176
+ thor (1.2.1)
177
+ timeout (0.3.2)
178
+ tzinfo (2.0.6)
179
+ concurrent-ruby (~> 1.0)
180
+ unicode-display_width (2.4.2)
181
+ websocket-driver (0.7.5)
182
+ websocket-extensions (>= 0.1.0)
183
+ websocket-extensions (0.1.5)
184
+ zeitwerk (2.6.7)
185
+
186
+ PLATFORMS
187
+ x86_64-darwin-20
188
+ x86_64-darwin-22
189
+ x86_64-linux
190
+
191
+ DEPENDENCIES
192
+ planetscale_rails!
193
+ rake (~> 13.0)
194
+ rspec (~> 3.0)
195
+ rubocop (~> 1.7)
196
+
197
+ BUNDLED WITH
198
+ 2.2.21
data/LICENSE.txt ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # PlanetScale Rails
2
+
3
+ Rake tasks for easily running Rails migrations against PlanetScale database branches.
4
+
5
+ For information on how to connect your Rails app to PlanetScale, please [see our guide here](https://planetscale.com/docs/tutorials/connect-rails-app).
6
+
7
+ ## Included rake tasks
8
+
9
+ The rake tasks allow you to use local MySQL for development. When you're ready to make a schema change, you can create a PlanetScale branch and run migrations
10
+ against it. See [usage](#usage) for details.
11
+
12
+ ```
13
+ rake psdb:migrate # Migrate the database for current environment
14
+ rake psdb:rollback # Rollback primary database for current environment
15
+ rake psdb:schema:load # Load the current schema into the database
16
+ rake psdb:setup_pscale # Setup a proxy to connect to PlanetScale
17
+ ```
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ group :development do
25
+ gem 'planetscale_rails'
26
+ end
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle install
32
+
33
+ ## Usage
34
+
35
+ First, make sure you have the [`pscale` CLI installed](https://github.com/planetscale/cli#installation). You'll use `pscale` to create a new branch.
36
+
37
+ 1. `pscale branch switch my-new-branch-name --database my-db-name --create`
38
+
39
+ Run this locally, it will create a new branch off of `main`. The `switch` command will update a `.pscale.yml` file to track
40
+ that this is the branch you want to migrate.
41
+
42
+ **Tip:** In your database settings. Enable "Automatically copy migration data." Select "Rails/Phoenix" as the migration framework. This will auto copy your `schema_migrations` table between branches.
43
+
44
+ 2. Once your branch is ready, you can then use the `psdb` rake task to connect to your branch and run `db:migrate`.
45
+
46
+ ```
47
+ bundle exec rails psdb:migrate
48
+ ```
49
+
50
+ If you run multiple databases in your Rails app, you can specify the DB name.
51
+
52
+ ```
53
+ bundle exec rails psdb:migrate:primary
54
+ ```
55
+
56
+ This will connect to the branch that you created, and run migrations against the branch.
57
+
58
+ If you make a mistake, you can use `bundle exec rails psdb:rollback` to rollback the changes on your PlanetScale branch.
59
+
60
+ 3. Next, you can either open the Deploy Request via the UI. Or the CLI.
61
+
62
+ Via CLI is:
63
+ ```
64
+ pscale deploy-request create database-name my-new-branch-name
65
+ ```
66
+
67
+ 4. To get your schema change to production, run the deploy request. Then, once it's complete, you can merge your code changes into your `main` branch in git and deploy your application code.
68
+
69
+
70
+ ## Development
71
+
72
+ 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.
73
+
74
+ 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).
75
+
76
+ ## Contributing
77
+
78
+ Bug reports and pull requests are welcome on GitHub at https://github.com/planetscale/planetscale_rails. 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/planetscale/planetscale_rails/blob/main/CODE_OF_CONDUCT.md).
79
+
80
+ ## License
81
+
82
+ The gem is available as open source under the terms of the [Apache 2.0 License](https://opensource.org/license/apache-2-0/).
83
+
84
+ ## Code of Conduct
85
+
86
+ Everyone interacting in the PlanetScale Rails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/planetscale/planetscale_rails/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]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "planetscale_rails"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "planetscale_rails"
4
+
5
+ path = File.expand_path(__dir__)
6
+ Dir.glob("#{path}/tasks/*.rake").each { |f| import f }
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/railtie.rb
4
+ require "planetscale_rails"
5
+ require "rails"
6
+
7
+ module PlanetscaleRails
8
+ class Railtie < Rails::Railtie
9
+ railtie_name :planetscale_rails
10
+
11
+ rake_tasks do
12
+ path = File.expand_path(__dir__)
13
+ Dir.glob("#{path}/tasks/*.rake").each { |f| load f }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,200 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "English"
4
+ require "yaml"
5
+ require "pty"
6
+
7
+ databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
8
+
9
+ def shared_deps(name = nil)
10
+ return [:environment, :check_ci, "setup_pscale:#{name}".to_sym] if name
11
+ return %i[environment check_ci] if name.nil?
12
+ end
13
+
14
+ def kill_pscale_process
15
+ Process.kill("TERM", ENV["PSCALE_PID"].to_i) if ENV["PSCALE_PID"]
16
+ end
17
+
18
+ namespace :psdb do
19
+ task check_ci: :environment do
20
+ use_service_token = ENV["PSCALE_SERVICE_TOKEN"] && ENV["PSCALE_SERVICE_TOKEN_ID"]
21
+ if ENV["CI"]
22
+ raise "For CI, you can only authenticate using service tokens." unless use_service_token
23
+
24
+ service_token_config = "--service-token #{ENV["PSCALE_SERVICE_TOKEN"]} --service-token-id #{ENV["PSCALE_SERVICE_TOKEN_ID"]}"
25
+
26
+ ENV["SERVICE_TOKEN_CONFIG"] = service_token_config
27
+ end
28
+ end
29
+
30
+ desc "Setup a proxy to connect to PlanetScale"
31
+ task "setup_pscale" => shared_deps do
32
+ ENV["ENABLE_PSDB"] = "1"
33
+ ENV["DISABLE_PS_GEM"] = "1"
34
+ ps_config = YAML.load_file(".pscale.yml")
35
+ database = ps_config["database"]
36
+ branch = ps_config["branch"]
37
+
38
+ raise "You must have `pscale` installed on your computer" unless command?("pscale")
39
+ if branch.blank? || database.blank?
40
+ raise "Your branch is not properly setup, please switch to a branch by using the CLI."
41
+ end
42
+ raise "Unable to run migrations against the main branch" if branch == "main"
43
+
44
+ r, = PTY.open
45
+
46
+ puts "Spawning background connect process..."
47
+
48
+ # Spawns the process in the background
49
+ pid = Process.spawn("pscale connect #{database} #{branch} --port 3305 #{ENV["SERVICE_TOKEN_CONFIG"]}", out: r)
50
+ ENV["PSCALE_PID"] = pid.to_s
51
+
52
+ out = ""
53
+ start_time = Time.current
54
+ time_elapsed = Time.current - start_time
55
+ sleep(1)
56
+ while out.blank? && time_elapsed < 10.seconds
57
+ PTY.check(pid, true)
58
+ out = r.gets
59
+ time_elapsed = Time.current - start_time
60
+ end
61
+
62
+ raise "Timed out waiting for PlanetScale connection to be established" if time_elapsed > 10.seconds
63
+
64
+ # Comment out for now, this messes up when running migrations.
65
+ # Kernel.system("bundle exec rails db:environment:set RAILS_ENV=development")
66
+ ensure
67
+ r&.close
68
+ end
69
+
70
+ namespace :setup_pscale do
71
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
72
+ desc "Setup a proxy to connect to #{name} in PlanetScale"
73
+ task name => shared_deps do
74
+ ENV["ENABLE_PSDB"] = "1"
75
+ ENV["DISABLE_PS_GEM"] = "1"
76
+ ps_config = YAML.load_file(".pscale.yml")
77
+ database = ps_config["database"]
78
+ branch = ps_config["branch"]
79
+
80
+ raise "You must have `pscale` installed on your computer" unless command?("pscale")
81
+ if branch.blank? || database.blank?
82
+ raise "Your branch is not properly setup, please switch to a branch by using the CLI."
83
+ end
84
+ raise "Unable to run migrations against the main branch" if branch == "main"
85
+
86
+ config = Rails.configuration.database_configuration[Rails.env][name]
87
+
88
+ raise "Database #{name} is not configured for the current environment" unless config
89
+
90
+ r, = PTY.open
91
+
92
+ puts "Spawning background connect process..."
93
+
94
+ # Spawns the process in the background
95
+ pid = Process.spawn("pscale connect #{database} #{branch} --port 3305 #{ENV["SERVICE_TOKEN_CONFIG"]}", out: r)
96
+ ENV["PSCALE_PID"] = pid.to_s
97
+
98
+ out = ""
99
+ start_time = Time.current
100
+ time_elapsed = Time.current - start_time
101
+ sleep(1)
102
+ while out.blank? && time_elapsed < 10.seconds
103
+ PTY.check(pid, true)
104
+ out = r.gets
105
+ time_elapsed = Time.current - start_time
106
+ end
107
+
108
+ raise "Timed out waiting for PlanetScale connection to be established" if time_elapsed > 10.seconds
109
+
110
+ # Comment out for now, this messes up when running migrations.
111
+ # Kernel.system("bundle exec rails db:environment:set RAILS_ENV=development")
112
+ ensure
113
+ r&.close
114
+ end
115
+ end
116
+ end
117
+
118
+ desc "Migrate the database for current environment"
119
+ task migrate: %i[environment check_ci setup_pscale] do
120
+ db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
121
+
122
+ unless db_configs.size == 1
123
+ raise "Found multiple database configurations, please specify which database you want to migrate using `psdb:migrate:<database_name>`"
124
+ end
125
+
126
+ puts "Running migrations..."
127
+ Kernel.system("bundle exec rails db:migrate")
128
+ puts "Finished running migrations"
129
+
130
+ ensure
131
+ kill_pscale_process
132
+ end
133
+
134
+ namespace :migrate do
135
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
136
+ desc "Migrate #{name} database for current environment"
137
+ task name => shared_deps(name) do
138
+ puts "Running migrations..."
139
+ # We run it using the Kernel.system here because this properly handles
140
+ # when exceptions occur whereas Rake::Task.invoke does not.
141
+ Kernel.system("bundle exec rake db:migrate:#{name}")
142
+ puts "Finished running migrations."
143
+ ensure
144
+ kill_pscale_process
145
+ end
146
+ end
147
+ end
148
+
149
+ namespace :truncate_all do
150
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
151
+ desc "Truncate all tables in #{name} database for current environment"
152
+ task name => shared_deps(name) do
153
+ puts "Truncating database..."
154
+ # We run it using the Kernel.system here because this properly handles
155
+ # when exceptions occur whereas Rake::Task.invoke does not.
156
+ Kernel.system("bundle exec rake db:truncate_all")
157
+ puts "Finished truncating database."
158
+ ensure
159
+ kill_pscale_process
160
+ end
161
+ end
162
+ end
163
+
164
+ namespace :schema do
165
+ namespace :load do
166
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
167
+ desc "Load the current schema into the #{name} database"
168
+ task name => shared_deps(name) do
169
+ puts "Loading schema..."
170
+ # We run it using the Kernel.system here because this properly handles
171
+ # when exceptions occur whereas Rake::Task.invoke does not.
172
+ Kernel.system("bundle exec rake db:schema:load:#{name}")
173
+ puts "Finished loading schema."
174
+ ensure
175
+ kill_pscale_process
176
+ end
177
+ end
178
+ end
179
+ end
180
+
181
+ namespace :rollback do
182
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
183
+ desc "Rollback #{name} database for current environment"
184
+ task name => shared_deps(name) do
185
+ puts "Rolling back migrations..."
186
+ # We run it using the Kernel.system here because this properly handles
187
+ # when exceptions occur whereas Rake::Task.invoke does not.
188
+ Kernel.system("bundle exec rake db:rollback:#{name}")
189
+ puts "Finished rolling back migrations."
190
+ ensure
191
+ kill_pscale_process
192
+ end
193
+ end
194
+ end
195
+ end
196
+
197
+ def command?(name)
198
+ `which #{name}`
199
+ $CHILD_STATUS.success?
200
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PlanetscaleRails
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "planetscale_rails/version"
4
+
5
+ module PlanetscaleRails
6
+ require "planetscale_rails/railtie" if defined?(Rails)
7
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/planetscale_rails/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "planetscale_rails"
7
+ spec.version = PlanetscaleRails::VERSION
8
+ spec.authors = ["Mike Coutermarsh"]
9
+ spec.email = ["coutermarsh.mike@gmail.com"]
10
+
11
+ spec.summary = "Rake tasks for running migrations on PlanetScale database branches"
12
+ spec.homepage = "https://github.com/planetscale/planetscale_rails"
13
+ spec.license = "Apache-2.0"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|doc)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "rails", "~> 7.0"
31
+
32
+ # For more information and examples about making a new gem, checkout our
33
+ # guide at: https://bundler.io/guides/creating_gem.html
34
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: planetscale_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Coutermarsh
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ description:
28
+ email:
29
+ - coutermarsh.mike@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/licensing.yml"
35
+ - ".github/workflows/main.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".rubocop.yml"
39
+ - ".ruby-version"
40
+ - CODE_OF_CONDUCT.md
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - bin/console
47
+ - bin/setup
48
+ - lib/Rakefile
49
+ - lib/planetscale_rails.rb
50
+ - lib/planetscale_rails/railtie.rb
51
+ - lib/planetscale_rails/tasks/psdb.rake
52
+ - lib/planetscale_rails/version.rb
53
+ - planetscale_rails.gemspec
54
+ homepage: https://github.com/planetscale/planetscale_rails
55
+ licenses:
56
+ - Apache-2.0
57
+ metadata:
58
+ allowed_push_host: https://rubygems.org
59
+ homepage_uri: https://github.com/planetscale/planetscale_rails
60
+ source_code_uri: https://github.com/planetscale/planetscale_rails
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 3.0.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.4.7
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Rake tasks for running migrations on PlanetScale database branches
80
+ test_files: []