pg_multitenant_schemas 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4e4486368a3eff30c0b78d763ea5240a9c53290124bc9c86db5a95d758097543
4
+ data.tar.gz: 652ec19727ac61cb61306c50cf7cff6bc2813b35c849419299f3c07f70239e49
5
+ SHA512:
6
+ metadata.gz: c1b96e168c0e3a6c9e80fea6d842aa8fd02e1d002681d6a075b7c90a2d2974dce0f2891a17f8b1081db10a48932b096db1152d1a7c55efe860f19ac80eea8068
7
+ data.tar.gz: bbfaa928d0bbbe90bc03eddf06ab1467e072db15f2ac43522bd932eb1a2ea9fdc489a03aeb549a25480686c0854106c2e5cb1ffe5f3c7806ca0c73b991b07679
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --tag ~integration
data/.rubocop.yml ADDED
@@ -0,0 +1,372 @@
1
+ plugins:
2
+ - rubocop-rspec
3
+ - rubocop-rspec_rails
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+ TargetRubyVersion: 3.0
8
+ SuggestExtensions: false
9
+ Exclude:
10
+ - 'vendor/**/*'
11
+ - 'bin/**/*'
12
+ - 'sig/**/*'
13
+
14
+ Style/StringLiterals:
15
+ EnforcedStyle: double_quotes
16
+
17
+ Style/StringLiteralsInInterpolation:
18
+ EnforcedStyle: double_quotes
19
+
20
+ # Documentation requirements
21
+ Style/Documentation:
22
+ Enabled: true
23
+ Exclude:
24
+ - 'spec/**/*'
25
+ - 'rails_integration/**/*'
26
+
27
+ # Metrics - Allow longer blocks in specs
28
+ Metrics/BlockLength:
29
+ Enabled: true
30
+ Max: 25
31
+ Exclude:
32
+ - 'spec/**/*'
33
+ - 'rails_integration/**/*'
34
+
35
+ Metrics/MethodLength:
36
+ Enabled: true
37
+ Max: 15
38
+
39
+ Metrics/AbcSize:
40
+ Enabled: true
41
+ Max: 20
42
+
43
+ Metrics/CyclomaticComplexity:
44
+ Enabled: true
45
+ Max: 8
46
+
47
+ Metrics/PerceivedComplexity:
48
+ Enabled: true
49
+ Max: 9
50
+
51
+ # Layout
52
+ Layout/LineLength:
53
+ Enabled: true
54
+ Max: 120
55
+
56
+ # Style preferences
57
+ Style/CombinableLoops:
58
+ Enabled: false # Sometimes separate loops are clearer in tests
59
+
60
+ # RSpec configuration
61
+ RSpec/SpecFilePathFormat:
62
+ Enabled: false # Allow flexible spec file naming
63
+
64
+ RSpec/DescribeClass:
65
+ Enabled: false # Allow integration test descriptions
66
+
67
+ RSpec/MultipleExpectations:
68
+ Enabled: false # Allow multiple expectations in integration tests
69
+
70
+ RSpec/ExampleLength:
71
+ Enabled: false # Allow longer examples in integration tests
72
+
73
+ RSpec/MessageSpies:
74
+ Enabled: false # Allow traditional expect().to receive syntax
75
+
76
+ RSpec/VerifiedDoubles:
77
+ Enabled: false # Allow simple doubles in tests
78
+
79
+ RSpec/BeforeAfterAll:
80
+ Enabled: false # Allow before(:all) when needed
81
+
82
+ # Gemspec
83
+ Gemspec/RequiredRubyVersion:
84
+ Enabled: true
85
+
86
+ # Enable all new cops with defaults
87
+ Gemspec/AddRuntimeDependency:
88
+ Enabled: true
89
+ Gemspec/AttributeAssignment:
90
+ Enabled: true
91
+ Gemspec/DeprecatedAttributeAssignment:
92
+ Enabled: true
93
+ Gemspec/DevelopmentDependencies:
94
+ Enabled: true
95
+ Gemspec/RequireMFA:
96
+ Enabled: false
97
+
98
+ Layout/EmptyLinesAfterModuleInclusion:
99
+ Enabled: true
100
+ Layout/LineContinuationLeadingSpace:
101
+ Enabled: true
102
+ Layout/LineContinuationSpacing:
103
+ Enabled: true
104
+ Layout/LineEndStringConcatenationIndentation:
105
+ Enabled: true
106
+ Layout/SpaceBeforeBrackets:
107
+ Enabled: true
108
+
109
+ Lint/AmbiguousAssignment:
110
+ Enabled: true
111
+ Lint/AmbiguousOperatorPrecedence:
112
+ Enabled: true
113
+ Lint/AmbiguousRange:
114
+ Enabled: true
115
+ Lint/ArrayLiteralInRegexp:
116
+ Enabled: true
117
+ Lint/ConstantOverwrittenInRescue:
118
+ Enabled: true
119
+ Lint/ConstantReassignment:
120
+ Enabled: true
121
+ Lint/CopDirectiveSyntax:
122
+ Enabled: true
123
+ Lint/DeprecatedConstants:
124
+ Enabled: true
125
+ Lint/DuplicateBranch:
126
+ Enabled: true
127
+ Lint/DuplicateMagicComment:
128
+ Enabled: true
129
+ Lint/DuplicateMatchPattern:
130
+ Enabled: true
131
+ Lint/DuplicateRegexpCharacterClassElement:
132
+ Enabled: true
133
+ Lint/DuplicateSetElement:
134
+ Enabled: true
135
+ Lint/EmptyBlock:
136
+ Enabled: true
137
+ Lint/EmptyClass:
138
+ Enabled: true
139
+ Lint/EmptyInPattern:
140
+ Enabled: true
141
+ Lint/HashNewWithKeywordArgumentsAsDefault:
142
+ Enabled: true
143
+ Lint/IncompatibleIoSelectWithFiberScheduler:
144
+ Enabled: true
145
+ Lint/ItWithoutArgumentsInBlock:
146
+ Enabled: true
147
+ Lint/LambdaWithoutLiteralBlock:
148
+ Enabled: true
149
+ Lint/LiteralAssignmentInCondition:
150
+ Enabled: true
151
+ Lint/MixedCaseRange:
152
+ Enabled: true
153
+ Lint/NoReturnInBeginEndBlocks:
154
+ Enabled: true
155
+ Lint/NonAtomicFileOperation:
156
+ Enabled: true
157
+ Lint/NumberedParameterAssignment:
158
+ Enabled: true
159
+ Lint/NumericOperationWithConstantResult:
160
+ Enabled: true
161
+ Lint/OrAssignmentToConstant:
162
+ Enabled: true
163
+ Lint/RedundantDirGlobSort:
164
+ Enabled: true
165
+ Lint/RedundantRegexpQuantifiers:
166
+ Enabled: true
167
+ Lint/RedundantTypeConversion:
168
+ Enabled: true
169
+ Lint/RefinementImportMethods:
170
+ Enabled: true
171
+ Lint/RequireRangeParentheses:
172
+ Enabled: true
173
+ Lint/RequireRelativeSelfPath:
174
+ Enabled: true
175
+ Lint/SharedMutableDefault:
176
+ Enabled: true
177
+ Lint/SuppressedExceptionInNumberConversion:
178
+ Enabled: true
179
+ Lint/SymbolConversion:
180
+ Enabled: true
181
+ Lint/ToEnumArguments:
182
+ Enabled: true
183
+ Lint/TripleQuotes:
184
+ Enabled: true
185
+ Lint/UnescapedBracketInRegexp:
186
+ Enabled: true
187
+ Lint/UnexpectedBlockArity:
188
+ Enabled: true
189
+ Lint/UnmodifiedReduceAccumulator:
190
+ Enabled: true
191
+ Lint/UselessConstantScoping:
192
+ Enabled: true
193
+ Lint/UselessDefaultValueArgument:
194
+ Enabled: true
195
+ Lint/UselessDefined:
196
+ Enabled: true
197
+ Lint/UselessNumericOperation:
198
+ Enabled: true
199
+ Lint/UselessOr:
200
+ Enabled: true
201
+ Lint/UselessRescue:
202
+ Enabled: true
203
+ Lint/UselessRuby2Keywords:
204
+ Enabled: true
205
+
206
+ Metrics/CollectionLiteralLength:
207
+ Enabled: true
208
+
209
+ Naming/BlockForwarding:
210
+ Enabled: true
211
+ Naming/PredicateMethod:
212
+ Enabled: true
213
+
214
+ Security/CompoundHash:
215
+ Enabled: true
216
+ Security/IoMethods:
217
+ Enabled: true
218
+
219
+ Style/AmbiguousEndlessMethodDefinition:
220
+ Enabled: true
221
+ Style/ArgumentsForwarding:
222
+ Enabled: true
223
+ Style/ArrayIntersect:
224
+ Enabled: true
225
+ Style/BitwisePredicate:
226
+ Enabled: true
227
+ Style/CollectionCompact:
228
+ Enabled: true
229
+ Style/CollectionQuerying:
230
+ Enabled: true
231
+ Style/CombinableDefined:
232
+ Enabled: true
233
+ Style/ComparableBetween:
234
+ Enabled: true
235
+ Style/ComparableClamp:
236
+ Enabled: true
237
+ Style/ConcatArrayLiterals:
238
+ Enabled: true
239
+ Style/DataInheritance:
240
+ Enabled: true
241
+ Style/DigChain:
242
+ Enabled: true
243
+ Style/DirEmpty:
244
+ Enabled: true
245
+ Style/DocumentDynamicEvalDefinition:
246
+ Enabled: true
247
+ Style/EmptyHeredoc:
248
+ Enabled: true
249
+ Style/EmptyStringInsideInterpolation:
250
+ Enabled: true
251
+ Style/EndlessMethod:
252
+ Enabled: true
253
+ Style/EnvHome:
254
+ Enabled: true
255
+ Style/ExactRegexpMatch:
256
+ Enabled: true
257
+ Style/FetchEnvVar:
258
+ Enabled: true
259
+ Style/FileEmpty:
260
+ Enabled: true
261
+ Style/FileNull:
262
+ Enabled: true
263
+ Style/FileRead:
264
+ Enabled: true
265
+ Style/FileTouch:
266
+ Enabled: true
267
+ Style/FileWrite:
268
+ Enabled: true
269
+ Style/HashConversion:
270
+ Enabled: true
271
+ Style/HashExcept:
272
+ Enabled: true
273
+ Style/HashFetchChain:
274
+ Enabled: true
275
+ Style/HashSlice:
276
+ Enabled: true
277
+ Style/IfWithBooleanLiteralBranches:
278
+ Enabled: true
279
+ Style/InPatternThen:
280
+ Enabled: true
281
+ Style/ItAssignment:
282
+ Enabled: true
283
+ Style/ItBlockParameter:
284
+ Enabled: true
285
+ Style/KeywordArgumentsMerging:
286
+ Enabled: true
287
+ Style/MagicCommentFormat:
288
+ Enabled: true
289
+ Style/MapCompactWithConditionalBlock:
290
+ Enabled: true
291
+ Style/MapIntoArray:
292
+ Enabled: true
293
+ Style/MapToHash:
294
+ Enabled: true
295
+ Style/MapToSet:
296
+ Enabled: true
297
+ Style/MinMaxComparison:
298
+ Enabled: true
299
+ Style/MultilineInPatternThen:
300
+ Enabled: true
301
+ Style/NegatedIfElseCondition:
302
+ Enabled: true
303
+ Style/NestedFileDirname:
304
+ Enabled: true
305
+ Style/NilLambda:
306
+ Enabled: true
307
+ Style/NumberedParameters:
308
+ Enabled: true
309
+ Style/NumberedParametersLimit:
310
+ Enabled: true
311
+ Style/ObjectThen:
312
+ Enabled: true
313
+ Style/OpenStructUse:
314
+ Enabled: true
315
+ Style/OperatorMethodCall:
316
+ Enabled: true
317
+ Style/QuotedSymbols:
318
+ Enabled: true
319
+ Style/RedundantArgument:
320
+ Enabled: true
321
+ Style/RedundantArrayConstructor:
322
+ Enabled: true
323
+ Style/RedundantArrayFlatten:
324
+ Enabled: true
325
+ Style/RedundantConstantBase:
326
+ Enabled: true
327
+ Style/RedundantCurrentDirectoryInPath:
328
+ Enabled: true
329
+ Style/RedundantDoubleSplatHashBraces:
330
+ Enabled: true
331
+ Style/RedundantEach:
332
+ Enabled: true
333
+ Style/RedundantFilterChain:
334
+ Enabled: true
335
+ Style/RedundantFormat:
336
+ Enabled: true
337
+ Style/RedundantHeredocDelimiterQuotes:
338
+ Enabled: true
339
+ Style/RedundantInitialize:
340
+ Enabled: true
341
+ Style/RedundantInterpolationUnfreeze:
342
+ Enabled: true
343
+ Style/RedundantLineContinuation:
344
+ Enabled: true
345
+ Style/RedundantRegexpArgument:
346
+ Enabled: true
347
+ Style/RedundantRegexpConstructor:
348
+ Enabled: true
349
+ Style/RedundantSelfAssignmentBranch:
350
+ Enabled: true
351
+ Style/RedundantStringEscape:
352
+ Enabled: true
353
+ Style/ReturnNilInPredicateMethodDefinition:
354
+ Enabled: true
355
+ Style/SafeNavigationChainLength:
356
+ Enabled: true
357
+ Style/SelectByRegexp:
358
+ Enabled: true
359
+ Style/SendWithLiteralMethodName:
360
+ Enabled: true
361
+ Style/SingleLineDoEndBlock:
362
+ Enabled: true
363
+ Style/StringChars:
364
+ Enabled: true
365
+ Style/SuperArguments:
366
+ Enabled: true
367
+ Style/SuperWithArgsParentheses:
368
+ Enabled: true
369
+ Style/SwapValues:
370
+ Enabled: true
371
+ Style/YAMLFileRead:
372
+ Enabled: true
File without changes
data/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.3] - 2025-09-03
11
+
12
+ ### Added
13
+ - Rails 8 compatibility with database connection handling
14
+ - Dual API support for backward compatibility
15
+ - Comprehensive Rails integration with concerns
16
+ - Thread-safe context management
17
+ - Advanced tenant resolution from subdomains
18
+ - Automatic schema creation and cleanup
19
+ - Extensive test coverage (86 tests)
20
+
21
+ ### Changed
22
+ - Updated dependencies to latest versions
23
+ - Improved error handling and validation
24
+ - Enhanced documentation and README
25
+ - Fixed delegation issues in main module
26
+
27
+ ### Fixed
28
+ - Database connection compatibility for Rails 8
29
+ - Module loading and delegation issues
30
+ - API parameter detection logic
31
+ - Thread isolation improvements
32
+
33
+ ## [0.1.2] - 2025-09-02
34
+
35
+ ### Fixed
36
+ - Critical API bug where Context called SchemaSwitcher with incorrect parameters
37
+ - Module delegation to use fully qualified class names
38
+
39
+ ## [0.1.1] - 2025-09-02
40
+
41
+ ### Added
42
+ - Documentation for all core classes
43
+ - Development dependencies management
44
+
45
+ ## [0.1.0] - 2025-09-01
46
+
47
+ ### Added
48
+ - Initial release
49
+ - Basic schema switching functionality
50
+ - PostgreSQL multitenancy support
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Ruben Paz Chuspe
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.