ros-apartment 2.11.0 → 3.0.2
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 +4 -4
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +256 -53
- data/.ruby-version +1 -1
- data/Appraisals +22 -30
- data/CHANGELOG.md +5 -3
- data/README.md +4 -5
- data/Rakefile +3 -17
- data/lib/apartment/active_record/connection_handling.rb +18 -7
- data/lib/apartment/active_record/postgresql_adapter.rb +4 -0
- data/lib/apartment/active_record/schema_migration.rb +1 -1
- data/lib/apartment/log_subscriber.rb +21 -9
- data/lib/apartment/migrator.rb +3 -21
- data/lib/apartment/railtie.rb +6 -1
- data/lib/apartment/version.rb +1 -1
- data/lib/apartment.rb +6 -16
- data/ros-apartment.gemspec +14 -11
- metadata +29 -41
- data/.circleci/config.yml +0 -78
- data/.github/ISSUE_TEMPLATE.md +0 -21
- data/.github/workflows/changelog.yml +0 -63
- data/.github/workflows/reviewdog.yml +0 -22
- data/.story_branch.yml +0 -5
- data/HISTORY.md +0 -496
- data/TODO.md +0 -50
- data/docker-compose.yml +0 -33
- data/gemfiles/rails_5_2.gemfile +0 -13
- data/gemfiles/rails_6_0.gemfile +0 -17
- data/gemfiles/rails_6_1.gemfile +0 -17
- data/gemfiles/rails_7_0.gemfile +0 -17
- data/gemfiles/rails_master.gemfile +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 793fd10dfd8877d9771404883e999dbb9a190ce0e1ca6d41ad05995f3d374df5
|
4
|
+
data.tar.gz: 27eb3923d9a8688eefb8ab7deeec360b9fa76579fdb48d7a85c5eed22dfc078c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae1043d76528ac646baec58e009678894d7d544ec43ad0abefd95f5097d98fbbb115551fb34bb32d046f3f5716d6ca07cf618b574a7299a7fade2d44adc66ab2
|
7
|
+
data.tar.gz: 5d9f4e6473d8862cf346c082b26c7348bc6f0c1dd300bfb20621fc5ca8713fe8cb25d4c2989413db01bf49144ac2a432004499e2d93fd9ff99133f6f6530d182
|
data/.rubocop.yml
CHANGED
@@ -7,6 +7,7 @@ require:
|
|
7
7
|
|
8
8
|
AllCops:
|
9
9
|
Exclude:
|
10
|
+
- vendor/bundle/**/*
|
10
11
|
- gemfiles/**/*.gemfile
|
11
12
|
- gemfiles/vendor/**/*
|
12
13
|
- spec/dummy_engine/dummy_engine.gemspec
|
@@ -30,3 +31,6 @@ Rails/ApplicationRecord:
|
|
30
31
|
|
31
32
|
Rails/Output:
|
32
33
|
Enabled: false
|
34
|
+
|
35
|
+
Style/Documentation:
|
36
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -1,24 +1,92 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2024-05-07 18:57:21 UTC using RuboCop version 1.63.4.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 1
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
11
|
+
# Configuration parameters: Severity, Include.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/DeprecatedAttributeAssignment:
|
14
|
+
Exclude:
|
15
|
+
- 'ros-apartment.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 20
|
18
|
+
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
|
19
|
+
# SupportedStyles: Gemfile, gems.rb, gemspec
|
20
|
+
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
|
21
|
+
Gemspec/DevelopmentDependencies:
|
22
|
+
Exclude:
|
23
|
+
- 'ros-apartment.gemspec'
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# This cop supports safe autocorrection (--autocorrect).
|
27
|
+
# Configuration parameters: Severity, Include.
|
28
|
+
# Include: **/*.gemspec
|
29
|
+
Gemspec/RequireMFA:
|
30
|
+
Exclude:
|
31
|
+
- 'ros-apartment.gemspec'
|
32
|
+
|
33
|
+
# Offense count: 6
|
34
|
+
# This cop supports safe autocorrection (--autocorrect).
|
35
|
+
Layout/EmptyLineAfterMagicComment:
|
36
|
+
Exclude:
|
37
|
+
- 'spec/dummy/config/initializers/backtrace_silencers.rb'
|
38
|
+
- 'spec/dummy/config/initializers/inflections.rb'
|
39
|
+
- 'spec/dummy/config/initializers/mime_types.rb'
|
40
|
+
- 'spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb'
|
41
|
+
- 'spec/dummy_engine/test/dummy/config/initializers/inflections.rb'
|
42
|
+
- 'spec/dummy_engine/test/dummy/config/initializers/mime_types.rb'
|
43
|
+
|
44
|
+
# Offense count: 3
|
45
|
+
# This cop supports safe autocorrection (--autocorrect).
|
46
|
+
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
|
47
|
+
Layout/LeadingCommentSpace:
|
48
|
+
Exclude:
|
49
|
+
- 'ros-apartment.gemspec'
|
50
|
+
|
51
|
+
# Offense count: 2
|
52
|
+
# This cop supports safe autocorrection (--autocorrect).
|
53
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
54
|
+
# SupportedStyles: aligned, indented
|
55
|
+
Layout/LineEndStringConcatenationIndentation:
|
56
|
+
Exclude:
|
57
|
+
- 'lib/apartment/custom_console.rb'
|
58
|
+
|
59
|
+
# Offense count: 3
|
60
|
+
# This cop supports safe autocorrection (--autocorrect).
|
61
|
+
Layout/SpaceBeforeComment:
|
62
|
+
Exclude:
|
63
|
+
- 'ros-apartment.gemspec'
|
64
|
+
|
9
65
|
# Offense count: 1
|
10
66
|
Lint/MixedRegexpCaptureTypes:
|
11
67
|
Exclude:
|
12
68
|
- 'lib/apartment/elevators/domain.rb'
|
13
69
|
|
14
|
-
# Offense count:
|
15
|
-
#
|
70
|
+
# Offense count: 1
|
71
|
+
# This cop supports safe autocorrection (--autocorrect).
|
72
|
+
Lint/RedundantCopDisableDirective:
|
73
|
+
Exclude:
|
74
|
+
- 'spec/support/config.rb'
|
75
|
+
|
76
|
+
# Offense count: 2
|
77
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
78
|
+
Lint/RedundantDirGlobSort:
|
79
|
+
Exclude:
|
80
|
+
- 'spec/spec_helper.rb'
|
81
|
+
|
82
|
+
# Offense count: 2
|
83
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
16
84
|
Metrics/AbcSize:
|
17
85
|
Max: 28
|
18
86
|
|
19
|
-
# Offense count:
|
20
|
-
# Configuration parameters: CountComments, CountAsOne,
|
21
|
-
#
|
87
|
+
# Offense count: 4
|
88
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
|
89
|
+
# AllowedMethods: refine
|
22
90
|
Metrics/BlockLength:
|
23
91
|
Max: 83
|
24
92
|
|
@@ -28,26 +96,51 @@ Metrics/ClassLength:
|
|
28
96
|
Max: 151
|
29
97
|
|
30
98
|
# Offense count: 6
|
31
|
-
# Configuration parameters: CountComments, CountAsOne,
|
99
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
32
100
|
Metrics/MethodLength:
|
33
|
-
Max:
|
101
|
+
Max: 23
|
102
|
+
|
103
|
+
# Offense count: 3
|
104
|
+
# This cop supports safe autocorrection (--autocorrect).
|
105
|
+
# Configuration parameters: EnforcedStyle, BlockForwardingName.
|
106
|
+
# SupportedStyles: anonymous, explicit
|
107
|
+
Naming/BlockForwarding:
|
108
|
+
Exclude:
|
109
|
+
- 'lib/apartment/adapters/abstract_adapter.rb'
|
110
|
+
- 'lib/apartment/log_subscriber.rb'
|
111
|
+
|
112
|
+
# Offense count: 1
|
113
|
+
# This cop supports safe autocorrection (--autocorrect).
|
114
|
+
Performance/RedundantBlockCall:
|
115
|
+
Exclude:
|
116
|
+
- 'lib/apartment/tasks/task_helper.rb'
|
117
|
+
|
118
|
+
# Offense count: 1
|
119
|
+
# This cop supports safe autocorrection (--autocorrect).
|
120
|
+
Performance/StringIdentifierArgument:
|
121
|
+
Exclude:
|
122
|
+
- 'lib/apartment/railtie.rb'
|
34
123
|
|
35
124
|
# Offense count: 3
|
36
125
|
RSpec/AnyInstance:
|
37
126
|
Exclude:
|
38
127
|
- 'spec/unit/migrator_spec.rb'
|
39
128
|
|
129
|
+
# Offense count: 4
|
130
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
131
|
+
RSpec/BeEq:
|
132
|
+
Exclude:
|
133
|
+
- 'spec/adapters/sqlite3_adapter_spec.rb'
|
134
|
+
- 'spec/unit/elevators/first_subdomain_spec.rb'
|
135
|
+
|
40
136
|
# Offense count: 2
|
41
137
|
RSpec/BeforeAfterAll:
|
42
138
|
Exclude:
|
43
|
-
- 'spec/spec_helper.rb'
|
44
|
-
- 'spec/rails_helper.rb'
|
45
|
-
- 'spec/support/**/*.rb'
|
46
139
|
- 'spec/adapters/sqlite3_adapter_spec.rb'
|
47
140
|
- 'spec/tasks/apartment_rake_spec.rb'
|
48
141
|
|
49
142
|
# Offense count: 18
|
50
|
-
# Configuration parameters: Prefixes.
|
143
|
+
# Configuration parameters: Prefixes, AllowedPatterns.
|
51
144
|
# Prefixes: when, with, without
|
52
145
|
RSpec/ContextWording:
|
53
146
|
Exclude:
|
@@ -58,18 +151,19 @@ RSpec/ContextWording:
|
|
58
151
|
- 'spec/tasks/apartment_rake_spec.rb'
|
59
152
|
- 'spec/tenant_spec.rb'
|
60
153
|
|
61
|
-
# Offense count:
|
154
|
+
# Offense count: 5
|
62
155
|
# Configuration parameters: IgnoredMetadata.
|
63
156
|
RSpec/DescribeClass:
|
64
157
|
Exclude:
|
65
158
|
- 'spec/integration/apartment_rake_integration_spec.rb'
|
159
|
+
- 'spec/integration/connection_handling_spec.rb'
|
66
160
|
- 'spec/integration/query_caching_spec.rb'
|
67
161
|
- 'spec/integration/use_within_an_engine_spec.rb'
|
68
162
|
- 'spec/tasks/apartment_rake_spec.rb'
|
69
163
|
|
70
|
-
# Offense count:
|
71
|
-
#
|
72
|
-
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
164
|
+
# Offense count: 6
|
165
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
166
|
+
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
|
73
167
|
# SupportedStyles: described_class, explicit
|
74
168
|
RSpec/DescribedClass:
|
75
169
|
Exclude:
|
@@ -79,25 +173,21 @@ RSpec/DescribedClass:
|
|
79
173
|
- 'spec/unit/migrator_spec.rb'
|
80
174
|
|
81
175
|
# Offense count: 5
|
82
|
-
#
|
176
|
+
# This cop supports safe autocorrection (--autocorrect).
|
83
177
|
RSpec/EmptyLineAfterFinalLet:
|
84
178
|
Exclude:
|
85
179
|
- 'spec/adapters/sqlite3_adapter_spec.rb'
|
86
180
|
- 'spec/examples/schema_adapter_examples.rb'
|
87
181
|
|
88
182
|
# Offense count: 14
|
89
|
-
# Configuration parameters:
|
183
|
+
# Configuration parameters: CountAsOne.
|
90
184
|
RSpec/ExampleLength:
|
91
|
-
|
92
|
-
- 'spec/examples/generic_adapter_custom_configuration_example.rb'
|
93
|
-
- 'spec/examples/generic_adapter_examples.rb'
|
94
|
-
- 'spec/examples/schema_adapter_examples.rb'
|
95
|
-
- 'spec/integration/query_caching_spec.rb'
|
96
|
-
- 'spec/tenant_spec.rb'
|
185
|
+
Max: 12
|
97
186
|
|
98
|
-
# Offense count:
|
99
|
-
#
|
100
|
-
# Configuration parameters: CustomTransform, IgnoredWords.
|
187
|
+
# Offense count: 58
|
188
|
+
# This cop supports safe autocorrection (--autocorrect).
|
189
|
+
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
|
190
|
+
# DisallowedExamples: works
|
101
191
|
RSpec/ExampleWording:
|
102
192
|
Exclude:
|
103
193
|
- 'spec/adapters/sqlite3_adapter_spec.rb'
|
@@ -111,8 +201,9 @@ RSpec/ExampleWording:
|
|
111
201
|
- 'spec/tasks/apartment_rake_spec.rb'
|
112
202
|
- 'spec/tenant_spec.rb'
|
113
203
|
|
114
|
-
# Offense count:
|
115
|
-
# Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
204
|
+
# Offense count: 12
|
205
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
206
|
+
# Include: **/*_spec*rb*, **/spec/**/*
|
116
207
|
RSpec/FilePath:
|
117
208
|
Exclude:
|
118
209
|
- 'spec/adapters/mysql2_adapter_spec.rb'
|
@@ -129,7 +220,7 @@ RSpec/FilePath:
|
|
129
220
|
- 'spec/unit/migrator_spec.rb'
|
130
221
|
|
131
222
|
# Offense count: 1
|
132
|
-
#
|
223
|
+
# This cop supports safe autocorrection (--autocorrect).
|
133
224
|
# Configuration parameters: EnforcedStyle.
|
134
225
|
# SupportedStyles: implicit, each, example
|
135
226
|
RSpec/HookArgument:
|
@@ -137,13 +228,20 @@ RSpec/HookArgument:
|
|
137
228
|
- 'spec/support/setup.rb'
|
138
229
|
|
139
230
|
# Offense count: 4
|
140
|
-
#
|
231
|
+
# This cop supports safe autocorrection (--autocorrect).
|
141
232
|
RSpec/HooksBeforeExamples:
|
142
233
|
Exclude:
|
143
234
|
- 'spec/adapters/sqlite3_adapter_spec.rb'
|
144
235
|
- 'spec/examples/schema_adapter_examples.rb'
|
145
236
|
|
146
|
-
# Offense count:
|
237
|
+
# Offense count: 4
|
238
|
+
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
|
239
|
+
RSpec/IndexedLet:
|
240
|
+
Exclude:
|
241
|
+
- 'spec/examples/schema_adapter_examples.rb'
|
242
|
+
- 'spec/support/contexts.rb'
|
243
|
+
|
244
|
+
# Offense count: 16
|
147
245
|
# Configuration parameters: AssignmentOnly.
|
148
246
|
RSpec/InstanceVariable:
|
149
247
|
Exclude:
|
@@ -153,18 +251,13 @@ RSpec/InstanceVariable:
|
|
153
251
|
- 'spec/integration/use_within_an_engine_spec.rb'
|
154
252
|
- 'spec/tasks/apartment_rake_spec.rb'
|
155
253
|
|
156
|
-
# Offense count: 1
|
157
|
-
# Cop supports --auto-correct.
|
158
|
-
RSpec/LeadingSubject:
|
159
|
-
Exclude:
|
160
|
-
|
161
254
|
# Offense count: 2
|
162
255
|
RSpec/LeakyConstantDeclaration:
|
163
256
|
Exclude:
|
164
257
|
- 'spec/examples/generic_adapters_callbacks_examples.rb'
|
165
258
|
- 'spec/unit/elevators/generic_spec.rb'
|
166
259
|
|
167
|
-
# Offense count:
|
260
|
+
# Offense count: 27
|
168
261
|
# Configuration parameters: EnforcedStyle.
|
169
262
|
# SupportedStyles: have_received, receive
|
170
263
|
RSpec/MessageSpies:
|
@@ -180,12 +273,22 @@ RSpec/MessageSpies:
|
|
180
273
|
- 'spec/unit/elevators/subdomain_spec.rb'
|
181
274
|
- 'spec/unit/migrator_spec.rb'
|
182
275
|
|
183
|
-
# Offense count:
|
276
|
+
# Offense count: 11
|
277
|
+
# This cop supports safe autocorrection (--autocorrect).
|
278
|
+
# Configuration parameters: EnforcedStyle.
|
279
|
+
# SupportedStyles: hash, symbol
|
280
|
+
RSpec/MetadataStyle:
|
281
|
+
Exclude:
|
282
|
+
- 'spec/examples/schema_adapter_examples.rb'
|
283
|
+
- 'spec/support/contexts.rb'
|
284
|
+
|
285
|
+
# Offense count: 27
|
184
286
|
RSpec/MultipleExpectations:
|
185
|
-
Max:
|
287
|
+
Max: 6
|
186
288
|
|
187
|
-
# Offense count:
|
188
|
-
# Configuration parameters: IgnoreSharedExamples.
|
289
|
+
# Offense count: 46
|
290
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
291
|
+
# SupportedStyles: always, named_only
|
189
292
|
RSpec/NamedSubject:
|
190
293
|
Exclude:
|
191
294
|
- 'spec/adapters/mysql2_adapter_spec.rb'
|
@@ -194,31 +297,69 @@ RSpec/NamedSubject:
|
|
194
297
|
- 'spec/support/requirements.rb'
|
195
298
|
- 'spec/tenant_spec.rb'
|
196
299
|
|
197
|
-
# Offense count:
|
300
|
+
# Offense count: 22
|
301
|
+
# Configuration parameters: AllowedGroups.
|
198
302
|
RSpec/NestedGroups:
|
199
303
|
Max: 5
|
200
304
|
|
201
|
-
# Offense count:
|
202
|
-
#
|
203
|
-
#
|
204
|
-
|
205
|
-
RSpec/ReturnFromStub:
|
305
|
+
# Offense count: 1
|
306
|
+
# Configuration parameters: AllowedPatterns.
|
307
|
+
# AllowedPatterns: ^expect_, ^assert_
|
308
|
+
RSpec/NoExpectationExample:
|
206
309
|
Exclude:
|
207
|
-
- 'spec/
|
310
|
+
- 'spec/tenant_spec.rb'
|
311
|
+
|
312
|
+
# Offense count: 12
|
313
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
314
|
+
# Include: **/*_spec.rb
|
315
|
+
RSpec/SpecFilePathFormat:
|
316
|
+
Exclude:
|
317
|
+
- 'spec/adapters/mysql2_adapter_spec.rb'
|
318
|
+
- 'spec/adapters/postgresql_adapter_spec.rb'
|
319
|
+
- 'spec/adapters/sqlite3_adapter_spec.rb'
|
320
|
+
- 'spec/tenant_spec.rb'
|
321
|
+
- 'spec/unit/config_spec.rb'
|
322
|
+
- 'spec/unit/elevators/domain_spec.rb'
|
323
|
+
- 'spec/unit/elevators/first_subdomain_spec.rb'
|
324
|
+
- 'spec/unit/elevators/generic_spec.rb'
|
325
|
+
- 'spec/unit/elevators/host_hash_spec.rb'
|
326
|
+
- 'spec/unit/elevators/host_spec.rb'
|
327
|
+
- 'spec/unit/elevators/subdomain_spec.rb'
|
208
328
|
- 'spec/unit/migrator_spec.rb'
|
209
329
|
|
210
|
-
# Offense count:
|
330
|
+
# Offense count: 2
|
211
331
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
212
332
|
RSpec/VerifiedDoubles:
|
213
333
|
Exclude:
|
214
334
|
- 'spec/integration/apartment_rake_integration_spec.rb'
|
215
335
|
- 'spec/unit/elevators/first_subdomain_spec.rb'
|
216
336
|
|
217
|
-
# Offense count:
|
337
|
+
# Offense count: 2
|
338
|
+
# This cop supports safe autocorrection (--autocorrect).
|
339
|
+
Rails/IndexWith:
|
340
|
+
Exclude:
|
341
|
+
- 'lib/apartment.rb'
|
342
|
+
- 'spec/unit/config_spec.rb'
|
343
|
+
|
344
|
+
# Offense count: 7
|
345
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
346
|
+
Rails/Pluck:
|
347
|
+
Exclude:
|
348
|
+
- 'spec/adapters/jdbc_mysql_adapter_spec.rb'
|
349
|
+
- 'spec/adapters/jdbc_postgresql_adapter_spec.rb'
|
350
|
+
- 'spec/adapters/mysql2_adapter_spec.rb'
|
351
|
+
- 'spec/adapters/postgresql_adapter_spec.rb'
|
352
|
+
|
353
|
+
# Offense count: 1
|
354
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
355
|
+
Security/IoMethods:
|
356
|
+
Exclude:
|
357
|
+
- 'spec/support/config.rb'
|
358
|
+
|
359
|
+
# Offense count: 16
|
360
|
+
# Configuration parameters: AllowedConstants.
|
218
361
|
Style/Documentation:
|
219
362
|
Exclude:
|
220
|
-
- 'spec/**/*'
|
221
|
-
- 'test/**/*'
|
222
363
|
- 'lib/apartment/adapters/jdbc_mysql_adapter.rb'
|
223
364
|
- 'lib/apartment/adapters/postgis_adapter.rb'
|
224
365
|
- 'lib/apartment/adapters/postgresql_adapter.rb'
|
@@ -231,3 +372,65 @@ Style/Documentation:
|
|
231
372
|
- 'lib/apartment/tasks/enhancements.rb'
|
232
373
|
- 'lib/apartment/tasks/task_helper.rb'
|
233
374
|
- 'lib/generators/apartment/install/install_generator.rb'
|
375
|
+
|
376
|
+
# Offense count: 4
|
377
|
+
# This cop supports safe autocorrection (--autocorrect).
|
378
|
+
# Configuration parameters: AllowedVars.
|
379
|
+
Style/FetchEnvVar:
|
380
|
+
Exclude:
|
381
|
+
- 'lib/apartment/adapters/postgresql_adapter.rb'
|
382
|
+
|
383
|
+
# Offense count: 3
|
384
|
+
# This cop supports safe autocorrection (--autocorrect).
|
385
|
+
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
386
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
387
|
+
# SupportedShorthandSyntax: always, never, either, consistent
|
388
|
+
Style/HashSyntax:
|
389
|
+
Exclude:
|
390
|
+
- 'lib/apartment/active_record/connection_handling.rb'
|
391
|
+
- 'spec/integration/connection_handling_spec.rb'
|
392
|
+
|
393
|
+
# Offense count: 1
|
394
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
395
|
+
# Configuration parameters: EnforcedStyle, Autocorrect.
|
396
|
+
# SupportedStyles: module_function, extend_self, forbidden
|
397
|
+
Style/ModuleFunction:
|
398
|
+
Exclude:
|
399
|
+
- 'lib/apartment/migrator.rb'
|
400
|
+
|
401
|
+
# Offense count: 4
|
402
|
+
# This cop supports safe autocorrection (--autocorrect).
|
403
|
+
Style/RedundantConstantBase:
|
404
|
+
Exclude:
|
405
|
+
- 'spec/apartment_spec.rb'
|
406
|
+
- 'spec/dummy/config.ru'
|
407
|
+
- 'spec/dummy_engine/test/dummy/config.ru'
|
408
|
+
- 'spec/dummy_engine/test/dummy/config/environments/production.rb'
|
409
|
+
|
410
|
+
# Offense count: 1
|
411
|
+
# This cop supports safe autocorrection (--autocorrect).
|
412
|
+
Style/RedundantParentheses:
|
413
|
+
Exclude:
|
414
|
+
- 'lib/apartment.rb'
|
415
|
+
|
416
|
+
# Offense count: 1
|
417
|
+
# This cop supports safe autocorrection (--autocorrect).
|
418
|
+
Style/RedundantRegexpArgument:
|
419
|
+
Exclude:
|
420
|
+
- 'lib/apartment/tasks/enhancements.rb'
|
421
|
+
|
422
|
+
# Offense count: 3
|
423
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
424
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
425
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
426
|
+
Style/SafeNavigation:
|
427
|
+
Exclude:
|
428
|
+
- 'lib/apartment/migrator.rb'
|
429
|
+
- 'lib/tasks/apartment.rake'
|
430
|
+
|
431
|
+
# Offense count: 2
|
432
|
+
# This cop supports safe autocorrection (--autocorrect).
|
433
|
+
Style/SuperWithArgsParentheses:
|
434
|
+
Exclude:
|
435
|
+
- 'lib/apartment/adapters/sqlite3_adapter.rb'
|
436
|
+
- 'lib/apartment/elevators/host_hash.rb'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.3.1
|
data/Appraisals
CHANGED
@@ -1,26 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise 'rails-5-2' do
|
4
|
-
gem 'rails', '~> 5.2.0'
|
5
|
-
platforms :jruby do
|
6
|
-
gem 'activerecord-jdbc-adapter', '~> 52.0'
|
7
|
-
gem 'activerecord-jdbcpostgresql-adapter', '~> 52.0'
|
8
|
-
gem 'activerecord-jdbcmysql-adapter', '~> 52.0'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
appraise 'rails-6-0' do
|
13
|
-
gem 'rails', '~> 6.0.0'
|
14
|
-
platforms :ruby do
|
15
|
-
gem 'sqlite3', '~> 1.4'
|
16
|
-
end
|
17
|
-
platforms :jruby do
|
18
|
-
gem 'activerecord-jdbc-adapter', '~> 60.0'
|
19
|
-
gem 'activerecord-jdbcpostgresql-adapter', '~> 60.0'
|
20
|
-
gem 'activerecord-jdbcmysql-adapter', '~> 60.0'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
3
|
appraise 'rails-6-1' do
|
25
4
|
gem 'rails', '~> 6.1.0'
|
26
5
|
platforms :ruby do
|
@@ -39,20 +18,33 @@ appraise 'rails-7-0' do
|
|
39
18
|
gem 'sqlite3', '~> 1.4'
|
40
19
|
end
|
41
20
|
platforms :jruby do
|
42
|
-
gem 'activerecord-jdbc-adapter', '~>
|
43
|
-
gem 'activerecord-jdbcpostgresql-adapter', '~>
|
44
|
-
gem 'activerecord-jdbcmysql-adapter', '~>
|
21
|
+
gem 'activerecord-jdbc-adapter', '~> 70.0'
|
22
|
+
gem 'activerecord-jdbcpostgresql-adapter', '~> 70.0'
|
23
|
+
gem 'activerecord-jdbcmysql-adapter', '~> 70.0'
|
45
24
|
end
|
46
25
|
end
|
47
26
|
|
48
|
-
appraise 'rails-
|
49
|
-
gem 'rails',
|
27
|
+
appraise 'rails-7-1' do
|
28
|
+
gem 'rails', '~> 7.1.0'
|
50
29
|
platforms :ruby do
|
51
|
-
gem 'sqlite3', '~> 1.
|
30
|
+
gem 'sqlite3', '~> 1.6'
|
52
31
|
end
|
53
32
|
platforms :jruby do
|
54
|
-
gem 'activerecord-jdbc-adapter', '~>
|
55
|
-
gem 'activerecord-jdbcpostgresql-adapter', '~>
|
56
|
-
gem 'activerecord-jdbcmysql-adapter', '~>
|
33
|
+
gem 'activerecord-jdbc-adapter', '~> 71.0'
|
34
|
+
gem 'activerecord-jdbcpostgresql-adapter', '~> 71.0'
|
35
|
+
gem 'activerecord-jdbcmysql-adapter', '~> 71.0'
|
57
36
|
end
|
58
37
|
end
|
38
|
+
|
39
|
+
# Install Rails from the main branch are failing
|
40
|
+
# appraise 'rails-master' do
|
41
|
+
# gem 'rails', git: 'https://github.com/rails/rails.git'
|
42
|
+
# platforms :ruby do
|
43
|
+
# gem 'sqlite3', '~> 2.0'
|
44
|
+
# end
|
45
|
+
# platforms :jruby do
|
46
|
+
# gem 'activerecord-jdbc-adapter', '~> 61.0'
|
47
|
+
# gem 'activerecord-jdbcpostgresql-adapter', '~> 61.0'
|
48
|
+
# gem 'activerecord-jdbcmysql-adapter', '~> 61.0'
|
49
|
+
# end
|
50
|
+
# end
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
# Changelog
|
1
|
+
# Changelog [DEPRECATED]
|
2
2
|
|
3
|
-
|
3
|
+
Changes are now being tracked in the [releases](https://github.com/rails-on-services/apartment/releases) section of the repository.
|
4
4
|
|
5
|
-
[
|
5
|
+
## [v2.8.1](https://github.com/rails-on-services/apartment/tree/v2.8.1) (2020-12-17)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/rails-on-services/apartment/compare/v2.8.0...v2.8.1)
|
6
8
|
|
7
9
|
**Implemented enhancements:**
|
8
10
|
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Apartment
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/apartment)
|
3
|
+
[](https://badge.fury.io/rb/ros-apartment)
|
4
4
|
[](https://codeclimate.com/github/rails-on-services/apartment/maintainability)
|
5
|
-
[](https://travis-ci.org/rails-on-services/apartment)
|
6
5
|
|
7
6
|
*Multitenancy for Rails and ActiveRecord*
|
8
7
|
|
@@ -68,7 +67,7 @@ you need to create a new tenant, you can run the following command:
|
|
68
67
|
Apartment::Tenant.create('tenant_name')
|
69
68
|
```
|
70
69
|
|
71
|
-
If you're using the [prepend environment](https://github.com/
|
70
|
+
If you're using the [prepend environment](https://github.com/rails-on-services/apartment#handling-environments) config option or you AREN'T using Postgresql Schemas, this will create a tenant in the following format: "#{environment}\_tenant_name".
|
72
71
|
In the case of a sqlite database, this will be created in your 'db/' folder. With
|
73
72
|
other databases, the tenant will be created as a new DB within the system.
|
74
73
|
|
@@ -275,7 +274,7 @@ In the examples above, we show the Apartment middleware being appended to the Ra
|
|
275
274
|
Rails.application.config.middleware.use Apartment::Elevators::Subdomain
|
276
275
|
```
|
277
276
|
|
278
|
-
By default, the Subdomain middleware switches into a Tenant based on the subdomain at the beginning of the request, and when the request is finished, it switches back to the "public" Tenant. This happens in the [Generic](https://github.com/
|
277
|
+
By default, the Subdomain middleware switches into a Tenant based on the subdomain at the beginning of the request, and when the request is finished, it switches back to the "public" Tenant. This happens in the [Generic](https://github.com/rails-on-services/apartment/blob/development/lib/apartment/elevators/generic.rb#L22) elevator, so all elevators that inherit from this elevator will operate as such.
|
279
278
|
|
280
279
|
It's also good to note that Apartment switches back to the "public" tenant any time an error is raised in your application.
|
281
280
|
|
@@ -531,7 +530,7 @@ You can then migrate your tenants using the normal rake task:
|
|
531
530
|
rake db:migrate
|
532
531
|
```
|
533
532
|
|
534
|
-
This just invokes `Apartment::
|
533
|
+
This just invokes `Apartment::Migrator.migrate(#{tenant_name})` for each tenant name supplied
|
535
534
|
from `Apartment.tenant_names`
|
536
535
|
|
537
536
|
Note that you can disable the default migrating of all tenants with `db:migrate` by setting
|
data/Rakefile
CHANGED
@@ -132,22 +132,8 @@ def my_config
|
|
132
132
|
config['mysql']
|
133
133
|
end
|
134
134
|
|
135
|
-
def activerecord_below_5_2?
|
136
|
-
ActiveRecord.version.release < Gem::Version.new('5.2.0')
|
137
|
-
end
|
138
|
-
|
139
|
-
def activerecord_below_6_0?
|
140
|
-
ActiveRecord.version.release < Gem::Version.new('6.0.0')
|
141
|
-
end
|
142
|
-
|
143
135
|
def migrate
|
144
|
-
if
|
145
|
-
|
146
|
-
|
147
|
-
ActiveRecord::MigrationContext.new('spec/dummy/db/migrate').migrate
|
148
|
-
else
|
149
|
-
# TODO: Figure out if there is any other possibility that can/should be
|
150
|
-
# passed here as the second argument for the migration context
|
151
|
-
ActiveRecord::MigrationContext.new('spec/dummy/db/migrate', ActiveRecord::SchemaMigration).migrate
|
152
|
-
end
|
136
|
+
# TODO: Figure out if there is any other possibility that can/should be
|
137
|
+
# passed here as the second argument for the migration context
|
138
|
+
ActiveRecord::MigrationContext.new('spec/dummy/db/migrate', ActiveRecord::SchemaMigration).migrate
|
153
139
|
end
|
@@ -1,16 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module ActiveRecord
|
4
|
-
# This is monkeypatching
|
3
|
+
module ActiveRecord # :nodoc:
|
4
|
+
# This is monkeypatching Active Record to ensure that whenever a new connection is established it
|
5
5
|
# switches to the same tenant as before the connection switching. This problem is more evident when
|
6
6
|
# using read replica in Rails 6
|
7
7
|
module ConnectionHandling
|
8
|
-
|
9
|
-
|
8
|
+
if ActiveRecord.version.release <= Gem::Version.new('6.2')
|
9
|
+
def connected_to_with_tenant(database: nil, role: nil, prevent_writes: false, &blk)
|
10
|
+
current_tenant = Apartment::Tenant.current
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
connected_to_without_tenant(database: database, role: role, prevent_writes: prevent_writes) do
|
13
|
+
Apartment::Tenant.switch!(current_tenant)
|
14
|
+
yield(blk)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
else
|
18
|
+
def connected_to_with_tenant(role: nil, prevent_writes: false, &blk)
|
19
|
+
current_tenant = Apartment::Tenant.current
|
20
|
+
|
21
|
+
connected_to_without_tenant(role: role, prevent_writes: prevent_writes) do
|
22
|
+
Apartment::Tenant.switch!(current_tenant)
|
23
|
+
yield(blk)
|
24
|
+
end
|
14
25
|
end
|
15
26
|
end
|
16
27
|
|
@@ -8,6 +8,10 @@
|
|
8
8
|
module Apartment::PostgreSqlAdapterPatch
|
9
9
|
def default_sequence_name(table, _column)
|
10
10
|
res = super
|
11
|
+
|
12
|
+
# for JDBC driver, if rescued in super_method, trim leading and trailing quotes
|
13
|
+
res.delete!('"') if defined?(JRUBY_VERSION)
|
14
|
+
|
11
15
|
schema_prefix = "#{Apartment::Tenant.current}."
|
12
16
|
default_tenant_prefix = "#{Apartment::Tenant.default_tenant}."
|
13
17
|
|