ros-apartment 2.9.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f31fef7b2332c76bce3bff4823754c145b7a049bbf845ce29bb22b65b29585e4
4
- data.tar.gz: 657b9a8bf128f912894e03bd2331b2e2201bf9f43f38515117e434ef65694341
3
+ metadata.gz: 9729bd0cd46375da3b48c1aad59bd2de396f90e9a7cd92d24dafee964988cbc4
4
+ data.tar.gz: 1e0b6a955a15691edcbbb680657d1a65c75c7b49cd93e342d4df7212d29313c5
5
5
  SHA512:
6
- metadata.gz: d35580a7ed02ea8423251e0e7ed555d002fe34f4d2705cb16b982e5211a5f79fd8f078b97c7ac633f8b1bb605c9ada8176a6c082c0d1ad00591ba4b079acb7b4
7
- data.tar.gz: fa77558d5731e0a99c8ff1f8611c5353e633a5bbcd37fe94c64fe310414f8f724177d6fa7121ca88031315638990087546892a7411fd7477e37362de52682e31
6
+ metadata.gz: 9f12f51635a20b87a5a8bddcd00eceac5ccd355699e2932947689a929695b1ad4337528da976a7905c31ed91413ee41eddc6f2ce7aed1d79f7643073b50053fa
7
+ data.tar.gz: 617c702d5f698a3a8b81649f10bb91373ff9fabab4755270ffc2289a44ea7b48b814f939c4363bb23d45a378f1f444963188980ea0acc1e5b76cd7d28207e3f3
data/.circleci/config.yml CHANGED
@@ -1,8 +1,5 @@
1
1
  version: 2.1
2
2
 
3
- orbs:
4
- rubocop: hanachin/rubocop@0.0.6
5
-
6
3
  jobs:
7
4
  build:
8
5
  docker:
@@ -61,7 +58,10 @@ jobs:
61
58
 
62
59
  - run:
63
60
  name: Run tests
64
- command: bundle exec rspec
61
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/test-results/rspec/rspec.xml
62
+
63
+ - store_test_results:
64
+ path: ~/test-results/rspec/
65
65
 
66
66
  workflows:
67
67
  tests:
@@ -69,10 +69,8 @@ workflows:
69
69
  - build:
70
70
  matrix:
71
71
  parameters:
72
- ruby_version: ["ruby:2.6-buster", "ruby:2.7-buster"]
72
+ ruby_version: ["ruby:2.6-buster", "ruby:2.7-buster", "ruby:3.0-buster"]
73
73
  gemfile: ["gemfiles/rails_5_2.gemfile", "gemfiles/rails_6_0.gemfile", "gemfiles/rails_6_1.gemfile"]
74
-
75
- rubocop:
76
- jobs:
77
- - rubocop/rubocop:
78
- version: 0.88.0
74
+ exclude:
75
+ - ruby_version: "ruby:3.0-buster"
76
+ gemfile: "gemfiles/rails_5_2.gemfile"
@@ -0,0 +1,22 @@
1
+ name: reviewdog
2
+ on: [push, pull_request]
3
+ jobs:
4
+ rubocop:
5
+ name: runner / rubocop
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Check out code
9
+ uses: actions/checkout@v2
10
+ - name: Read ruby version
11
+ run: echo ::set-output name=RUBY_VERSION::$(cat .ruby-version | cut -f 1,2 -d .)
12
+ id: rv
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: "${{ steps.rv.outputs.RUBY_VERSION }}"
16
+ - uses: reviewdog/action-rubocop@v1
17
+ with:
18
+ filter_mode: nofilter
19
+ reporter: github-check
20
+ rubocop_version: 0.93.1
21
+ github_token: ${{ secrets.github_token }}
22
+ rubocop_extensions: rubocop-performance:1.10.2 rubocop-rails:2.9.1 rubocop-rspec:1.44.1
data/.rubocop.yml CHANGED
@@ -1,96 +1,32 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- AllCops:
4
- Exclude:
5
- - 'gemfiles/**/*.gemfile'
6
- - 'gemfiles/vendor/**/*'
7
- - 'spec/dummy_engine/dummy_engine.gemspec'
8
-
9
- Gemspec/RequiredRubyVersion:
10
- Exclude:
11
- - 'ros-apartment.gemspec'
3
+ require:
4
+ - rubocop-rails
5
+ - rubocop-performance
6
+ - rubocop-rspec
12
7
 
13
- Style/WordArray:
8
+ AllCops:
14
9
  Exclude:
10
+ - gemfiles/**/*.gemfile
11
+ - gemfiles/vendor/**/*
12
+ - spec/dummy_engine/dummy_engine.gemspec
15
13
  - spec/schemas/**/*.rb
16
14
 
17
- Style/NumericLiterals:
18
- Exclude:
19
- - spec/schemas/**/*.rb
15
+ NewCops: enable
20
16
 
21
- Layout/EmptyLineAfterMagicComment:
17
+ Gemspec/RequiredRubyVersion:
22
18
  Exclude:
23
- - spec/schemas/**/*.rb
19
+ - 'ros-apartment.gemspec'
24
20
 
25
21
  Metrics/BlockLength:
26
22
  Exclude:
27
23
  - spec/**/*.rb
28
24
 
29
- Layout/EmptyLinesAroundAttributeAccessor:
30
- Enabled: true
31
-
32
- Layout/SpaceAroundMethodCallOperator:
33
- Enabled: true
34
-
35
- Lint/DeprecatedOpenSSLConstant:
36
- Enabled: true
37
-
38
- Lint/DuplicateElsifCondition:
39
- Enabled: true
40
-
41
- Lint/MixedRegexpCaptureTypes:
42
- Enabled: true
43
-
44
- Lint/RaiseException:
45
- Enabled: true
46
-
47
- Lint/StructNewOverride:
48
- Enabled: true
49
-
50
- Style/AccessorGrouping:
51
- Enabled: true
52
-
53
- Style/ArrayCoercion:
54
- Enabled: true
55
-
56
- Style/BisectedAttrAccessor:
57
- Enabled: true
58
-
59
- Style/CaseLikeIf:
60
- Enabled: true
61
-
62
- Style/ExponentialNotation:
63
- Enabled: true
64
-
65
- Style/HashAsLastArrayItem:
66
- Enabled: true
67
-
68
- Style/HashEachMethods:
69
- Enabled: true
70
-
71
- Style/HashLikeCase:
72
- Enabled: true
73
-
74
- Style/HashTransformKeys:
75
- Enabled: true
76
-
77
- Style/HashTransformValues:
78
- Enabled: true
79
-
80
- Style/RedundantAssignment:
81
- Enabled: true
82
-
83
- Style/RedundantFetchBlock:
84
- Enabled: true
85
-
86
- Style/RedundantFileExtensionInRequire:
87
- Enabled: true
88
-
89
- Style/RedundantRegexpCharacterClass:
90
- Enabled: true
25
+ Rails/RakeEnvironment:
26
+ Enabled: false
91
27
 
92
- Style/RedundantRegexpEscape:
93
- Enabled: true
28
+ Rails/ApplicationRecord:
29
+ Enabled: false
94
30
 
95
- Style/SlicingWithRange:
96
- Enabled: true
31
+ Rails/Output:
32
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-07-16 04:15:41 UTC using RuboCop version 0.88.0.
3
+ # on 2021-06-26 03:25:28 UTC using RuboCop version 0.93.1.
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
@@ -11,22 +11,16 @@ Lint/MixedRegexpCaptureTypes:
11
11
  Exclude:
12
12
  - 'lib/apartment/elevators/domain.rb'
13
13
 
14
- # Offense count: 2
15
- # Cop supports --auto-correct.
16
- Lint/NonDeterministicRequireOrder:
17
- Exclude:
18
- - 'spec/spec_helper.rb'
19
-
20
- # Offense count: 7
14
+ # Offense count: 3
21
15
  # Configuration parameters: IgnoredMethods.
22
16
  Metrics/AbcSize:
23
- Max: 33
17
+ Max: 28
24
18
 
25
- # Offense count: 3
19
+ # Offense count: 5
26
20
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
27
21
  # ExcludedMethods: refine
28
22
  Metrics/BlockLength:
29
- Max: 102
23
+ Max: 83
30
24
 
31
25
  # Offense count: 1
32
26
  # Configuration parameters: CountComments, CountAsOne.
@@ -38,6 +32,193 @@ Metrics/ClassLength:
38
32
  Metrics/MethodLength:
39
33
  Max: 24
40
34
 
35
+ # Offense count: 3
36
+ RSpec/AnyInstance:
37
+ Exclude:
38
+ - 'spec/unit/migrator_spec.rb'
39
+
40
+ # Offense count: 2
41
+ RSpec/BeforeAfterAll:
42
+ Exclude:
43
+ - 'spec/spec_helper.rb'
44
+ - 'spec/rails_helper.rb'
45
+ - 'spec/support/**/*.rb'
46
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
47
+ - 'spec/tasks/apartment_rake_spec.rb'
48
+
49
+ # Offense count: 18
50
+ # Configuration parameters: Prefixes.
51
+ # Prefixes: when, with, without
52
+ RSpec/ContextWording:
53
+ Exclude:
54
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
55
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
56
+ - 'spec/examples/schema_adapter_examples.rb'
57
+ - 'spec/support/contexts.rb'
58
+ - 'spec/tasks/apartment_rake_spec.rb'
59
+ - 'spec/tenant_spec.rb'
60
+
61
+ # Offense count: 4
62
+ # Configuration parameters: IgnoredMetadata.
63
+ RSpec/DescribeClass:
64
+ Exclude:
65
+ - 'spec/integration/apartment_rake_integration_spec.rb'
66
+ - 'spec/integration/query_caching_spec.rb'
67
+ - 'spec/integration/use_within_an_engine_spec.rb'
68
+ - 'spec/tasks/apartment_rake_spec.rb'
69
+
70
+ # Offense count: 12
71
+ # Cop supports --auto-correct.
72
+ # Configuration parameters: SkipBlocks, EnforcedStyle.
73
+ # SupportedStyles: described_class, explicit
74
+ RSpec/DescribedClass:
75
+ Exclude:
76
+ - 'spec/apartment_spec.rb'
77
+ - 'spec/tenant_spec.rb'
78
+ - 'spec/unit/elevators/host_hash_spec.rb'
79
+ - 'spec/unit/migrator_spec.rb'
80
+ - 'spec/unit/reloader_spec.rb'
81
+
82
+ # Offense count: 5
83
+ # Cop supports --auto-correct.
84
+ RSpec/EmptyLineAfterFinalLet:
85
+ Exclude:
86
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
87
+ - 'spec/examples/schema_adapter_examples.rb'
88
+
89
+ # Offense count: 14
90
+ # Configuration parameters: Max.
91
+ RSpec/ExampleLength:
92
+ Exclude:
93
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
94
+ - 'spec/examples/generic_adapter_examples.rb'
95
+ - 'spec/examples/schema_adapter_examples.rb'
96
+ - 'spec/integration/query_caching_spec.rb'
97
+ - 'spec/tenant_spec.rb'
98
+
99
+ # Offense count: 60
100
+ # Cop supports --auto-correct.
101
+ # Configuration parameters: CustomTransform, IgnoredWords.
102
+ RSpec/ExampleWording:
103
+ Exclude:
104
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
105
+ - 'spec/apartment_spec.rb'
106
+ - 'spec/examples/connection_adapter_examples.rb'
107
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
108
+ - 'spec/examples/generic_adapter_examples.rb'
109
+ - 'spec/examples/schema_adapter_examples.rb'
110
+ - 'spec/integration/apartment_rake_integration_spec.rb'
111
+ - 'spec/integration/use_within_an_engine_spec.rb'
112
+ - 'spec/tasks/apartment_rake_spec.rb'
113
+ - 'spec/tenant_spec.rb'
114
+
115
+ # Offense count: 13
116
+ # Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
117
+ RSpec/FilePath:
118
+ Exclude:
119
+ - 'spec/adapters/mysql2_adapter_spec.rb'
120
+ - 'spec/adapters/postgresql_adapter_spec.rb'
121
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
122
+ - 'spec/tenant_spec.rb'
123
+ - 'spec/unit/config_spec.rb'
124
+ - 'spec/unit/elevators/domain_spec.rb'
125
+ - 'spec/unit/elevators/first_subdomain_spec.rb'
126
+ - 'spec/unit/elevators/generic_spec.rb'
127
+ - 'spec/unit/elevators/host_hash_spec.rb'
128
+ - 'spec/unit/elevators/host_spec.rb'
129
+ - 'spec/unit/elevators/subdomain_spec.rb'
130
+ - 'spec/unit/migrator_spec.rb'
131
+ - 'spec/unit/reloader_spec.rb'
132
+
133
+ # Offense count: 1
134
+ # Cop supports --auto-correct.
135
+ # Configuration parameters: EnforcedStyle.
136
+ # SupportedStyles: implicit, each, example
137
+ RSpec/HookArgument:
138
+ Exclude:
139
+ - 'spec/support/setup.rb'
140
+
141
+ # Offense count: 4
142
+ # Cop supports --auto-correct.
143
+ RSpec/HooksBeforeExamples:
144
+ Exclude:
145
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
146
+ - 'spec/examples/schema_adapter_examples.rb'
147
+
148
+ # Offense count: 18
149
+ # Configuration parameters: AssignmentOnly.
150
+ RSpec/InstanceVariable:
151
+ Exclude:
152
+ - 'spec/examples/generic_adapter_examples.rb'
153
+ - 'spec/examples/schema_adapter_examples.rb'
154
+ - 'spec/integration/apartment_rake_integration_spec.rb'
155
+ - 'spec/integration/use_within_an_engine_spec.rb'
156
+ - 'spec/tasks/apartment_rake_spec.rb'
157
+
158
+ # Offense count: 1
159
+ # Cop supports --auto-correct.
160
+ RSpec/LeadingSubject:
161
+ Exclude:
162
+ - 'spec/unit/reloader_spec.rb'
163
+
164
+ # Offense count: 2
165
+ RSpec/LeakyConstantDeclaration:
166
+ Exclude:
167
+ - 'spec/examples/generic_adapters_callbacks_examples.rb'
168
+ - 'spec/unit/elevators/generic_spec.rb'
169
+
170
+ # Offense count: 35
171
+ # Configuration parameters: EnforcedStyle.
172
+ # SupportedStyles: have_received, receive
173
+ RSpec/MessageSpies:
174
+ Exclude:
175
+ - 'spec/examples/generic_adapter_custom_configuration_example.rb'
176
+ - 'spec/integration/apartment_rake_integration_spec.rb'
177
+ - 'spec/integration/use_within_an_engine_spec.rb'
178
+ - 'spec/tasks/apartment_rake_spec.rb'
179
+ - 'spec/unit/elevators/domain_spec.rb'
180
+ - 'spec/unit/elevators/generic_spec.rb'
181
+ - 'spec/unit/elevators/host_hash_spec.rb'
182
+ - 'spec/unit/elevators/host_spec.rb'
183
+ - 'spec/unit/elevators/subdomain_spec.rb'
184
+ - 'spec/unit/migrator_spec.rb'
185
+
186
+ # Offense count: 29
187
+ RSpec/MultipleExpectations:
188
+ Max: 4
189
+
190
+ # Offense count: 47
191
+ # Configuration parameters: IgnoreSharedExamples.
192
+ RSpec/NamedSubject:
193
+ Exclude:
194
+ - 'spec/adapters/mysql2_adapter_spec.rb'
195
+ - 'spec/adapters/sqlite3_adapter_spec.rb'
196
+ - 'spec/support/contexts.rb'
197
+ - 'spec/support/requirements.rb'
198
+ - 'spec/tenant_spec.rb'
199
+ - 'spec/unit/reloader_spec.rb'
200
+
201
+ # Offense count: 24
202
+ RSpec/NestedGroups:
203
+ Max: 5
204
+
205
+ # Offense count: 6
206
+ # Cop supports --auto-correct.
207
+ # Configuration parameters: EnforcedStyle.
208
+ # SupportedStyles: and_return, block
209
+ RSpec/ReturnFromStub:
210
+ Exclude:
211
+ - 'spec/integration/apartment_rake_integration_spec.rb'
212
+ - 'spec/unit/migrator_spec.rb'
213
+
214
+ # Offense count: 4
215
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
216
+ RSpec/VerifiedDoubles:
217
+ Exclude:
218
+ - 'spec/integration/apartment_rake_integration_spec.rb'
219
+ - 'spec/unit/elevators/first_subdomain_spec.rb'
220
+ - 'spec/unit/reloader_spec.rb'
221
+
41
222
  # Offense count: 17
42
223
  Style/Documentation:
43
224
  Exclude:
@@ -56,11 +237,3 @@ Style/Documentation:
56
237
  - 'lib/apartment/tasks/enhancements.rb'
57
238
  - 'lib/apartment/tasks/task_helper.rb'
58
239
  - 'lib/generators/apartment/install/install_generator.rb'
59
-
60
- # Offense count: 3
61
- # Cop supports --auto-correct.
62
- Style/IfUnlessModifier:
63
- Exclude:
64
- - 'Rakefile'
65
- - 'lib/apartment.rb'
66
- - 'lib/apartment/tenant.rb'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.3
data/Gemfile CHANGED
@@ -3,11 +3,3 @@
3
3
  source 'http://rubygems.org'
4
4
 
5
5
  gemspec
6
-
7
- gem 'rails', '>= 3.1.2'
8
- gem 'rubocop'
9
-
10
- group :local do
11
- gem 'guard-rspec', '~> 4.2'
12
- gem 'pry'
13
- end
data/README.md CHANGED
@@ -101,6 +101,16 @@ switched back at the end of the block to what it was before.
101
101
  There is also `switch!` which doesn't take a block, but it's recommended to use `switch`.
102
102
  To return to the default tenant, you can call `switch` with no arguments.
103
103
 
104
+ #### Multiple Tenants
105
+
106
+ When using schemas, you can also pass in a list of schemas if desired. Any tables defined in a schema earlier in the chain will be referenced first, so this is only useful if you have a schema with only some of the tables defined:
107
+
108
+ ```ruby
109
+ Apartment::Tenant.switch(['tenant_1', 'tenant_2']) do
110
+ # ...
111
+ end
112
+ ```
113
+
104
114
  ### Switching Tenants per request
105
115
 
106
116
  You can have Apartment route to the appropriate tenant by adding some Rack middleware.
@@ -38,11 +38,9 @@ module Apartment
38
38
  #
39
39
  def connect_to_new(tenant = nil)
40
40
  return reset if tenant.nil?
41
+ raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless schema_exists?(tenant)
41
42
 
42
- tenant = tenant.to_s
43
- raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant)
44
-
45
- @current = tenant
43
+ @current = tenant.is_a?(Array) ? tenant.map(&:to_s) : tenant.to_s
46
44
  Apartment.connection.schema_search_path = full_search_path
47
45
  rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError
48
46
  raise TenantNotFound, "One of the following schema(s) is invalid: #{full_search_path}"
@@ -72,11 +72,9 @@ module Apartment
72
72
  #
73
73
  def connect_to_new(tenant = nil)
74
74
  return reset if tenant.nil?
75
+ raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless schema_exists?(tenant)
75
76
 
76
- tenant = tenant.to_s
77
- raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant)
78
-
79
- @current = tenant
77
+ @current = tenant.is_a?(Array) ? tenant.map(&:to_s) : tenant.to_s
80
78
  Apartment.connection.schema_search_path = full_search_path
81
79
 
82
80
  # When the PostgreSQL version is < 9.3,
@@ -149,6 +147,12 @@ module Apartment
149
147
  c.remove_instance_variable :@sequence_name if c.instance_variable_defined?(:@sequence_name)
150
148
  end
151
149
  end
150
+
151
+ def schema_exists?(schemas)
152
+ return true unless Apartment.tenant_presence_check
153
+
154
+ Array(schemas).all? { |schema| Apartment.connection.schema_exists?(schema.to_s) }
155
+ end
152
156
  end
153
157
 
154
158
  # Another Adapter for Postgresql when using schemas and SQL
@@ -158,6 +162,7 @@ module Apartment
158
162
  /SET lock_timeout/i, # new in postgresql 9.3
159
163
  /SET row_security/i, # new in postgresql 9.5
160
164
  /SET idle_in_transaction_session_timeout/i, # new in postgresql 9.6
165
+ /SET default_table_access_method/i, # new in postgresql 12
161
166
  /CREATE SCHEMA public/i,
162
167
  /COMMENT ON SCHEMA public/i
163
168
 
@@ -224,7 +229,7 @@ module Apartment
224
229
 
225
230
  # Temporary set Postgresql related environment variables if there are in @config
226
231
  #
227
- def with_pg_env(&block)
232
+ def with_pg_env
228
233
  pghost = ENV['PGHOST']
229
234
  pgport = ENV['PGPORT']
230
235
  pguser = ENV['PGUSER']
@@ -235,7 +240,7 @@ module Apartment
235
240
  ENV['PGUSER'] = @config[:username].to_s if @config[:username]
236
241
  ENV['PGPASSWORD'] = @config[:password].to_s if @config[:password]
237
242
 
238
- block.call
243
+ yield
239
244
  ensure
240
245
  ENV['PGHOST'] = pghost
241
246
  ENV['PGPORT'] = pgport
@@ -17,7 +17,9 @@ module Apartment
17
17
  cache_key = if key.is_a? String
18
18
  "#{Apartment::Tenant.current}_#{key}"
19
19
  else
20
- [Apartment::Tenant.current] + key
20
+ # NOTE: In Rails 6.0.4 we start receiving an ActiveRecord::Reflection::BelongsToReflection
21
+ # as the key, which wouldn't work well with an array.
22
+ [Apartment::Tenant.current] + Array.wrap(key)
21
23
  end
22
24
  cache = @find_by_statement_cache[connection.prepared_statements]
23
25
  cache.compute_if_absent(cache_key) { ActiveRecord::StatementCache.create(connection, &block) }
@@ -32,7 +32,7 @@ module Apartment
32
32
  #
33
33
  config.to_prepare do
34
34
  next if ARGV.any? { |arg| arg =~ /\Aassets:(?:precompile|clean)\z/ }
35
- next if ARGV.any? { |arg| arg == 'webpacker:compile' }
35
+ next if ARGV.any?('webpacker:compile')
36
36
  next if ENV['APARTMENT_DISABLE_INIT']
37
37
 
38
38
  begin
@@ -74,11 +74,9 @@ module Apartment
74
74
 
75
75
  # Overrides reload! to also call Apartment::Tenant.init as well
76
76
  # so that the reloaded classes have the proper table_names
77
- # rubocop:disable Lint/Debugger
78
77
  console do
79
78
  require 'apartment/console'
80
79
  end
81
- # rubocop:enable Lint/Debugger
82
80
  end
83
81
  end
84
82
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Apartment
4
- VERSION = '2.9.0'
4
+ VERSION = '2.10.0'
5
5
  end
data/lib/apartment.rb CHANGED
@@ -107,13 +107,13 @@ module Apartment
107
107
  def database_schema_file
108
108
  return @database_schema_file if defined?(@database_schema_file)
109
109
 
110
- @database_schema_file = Rails.root.join('db', 'schema.rb')
110
+ @database_schema_file = Rails.root.join('db/schema.rb')
111
111
  end
112
112
 
113
113
  def seed_data_file
114
114
  return @seed_data_file if defined?(@seed_data_file)
115
115
 
116
- @seed_data_file = Rails.root.join('db', 'seeds.rb')
116
+ @seed_data_file = Rails.root.join('db/seeds.rb')
117
117
  end
118
118
 
119
119
  def pg_excluded_names
@@ -17,12 +17,10 @@ apartment_namespace = namespace :apartment do
17
17
  desc 'Drop all tenants'
18
18
  task :drop do
19
19
  Apartment::TaskHelper.tenants.each do |tenant|
20
- begin
21
- puts("Dropping #{tenant} tenant")
22
- Apartment::Tenant.drop(tenant)
23
- rescue Apartment::TenantNotFound, ActiveRecord::NoDatabaseError => e
24
- puts e.message
25
- end
20
+ puts("Dropping #{tenant} tenant")
21
+ Apartment::Tenant.drop(tenant)
22
+ rescue Apartment::TenantNotFound, ActiveRecord::NoDatabaseError => e
23
+ puts e.message
26
24
  end
27
25
  end
28
26
 
@@ -39,15 +37,13 @@ apartment_namespace = namespace :apartment do
39
37
  Apartment::TaskHelper.warn_if_tenants_empty
40
38
 
41
39
  Apartment::TaskHelper.each_tenant do |tenant|
42
- begin
43
- Apartment::TaskHelper.create_tenant(tenant)
44
- puts("Seeding #{tenant} tenant")
45
- Apartment::Tenant.switch(tenant) do
46
- Apartment::Tenant.seed
47
- end
48
- rescue Apartment::TenantNotFound => e
49
- puts e.message
40
+ Apartment::TaskHelper.create_tenant(tenant)
41
+ puts("Seeding #{tenant} tenant")
42
+ Apartment::Tenant.switch(tenant) do
43
+ Apartment::Tenant.seed
50
44
  end
45
+ rescue Apartment::TenantNotFound => e
46
+ puts e.message
51
47
  end
52
48
  end
53
49
 
@@ -58,12 +54,10 @@ apartment_namespace = namespace :apartment do
58
54
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
59
55
 
60
56
  Apartment::TaskHelper.each_tenant do |tenant|
61
- begin
62
- puts("Rolling back #{tenant} tenant")
63
- Apartment::Migrator.rollback tenant, step
64
- rescue Apartment::TenantNotFound => e
65
- puts e.message
66
- end
57
+ puts("Rolling back #{tenant} tenant")
58
+ Apartment::Migrator.rollback tenant, step
59
+ rescue Apartment::TenantNotFound => e
60
+ puts e.message
67
61
  end
68
62
  end
69
63
 
@@ -76,12 +70,10 @@ apartment_namespace = namespace :apartment do
76
70
  raise 'VERSION is required' unless version
77
71
 
78
72
  Apartment::TaskHelper.each_tenant do |tenant|
79
- begin
80
- puts("Migrating #{tenant} tenant up")
81
- Apartment::Migrator.run :up, tenant, version
82
- rescue Apartment::TenantNotFound => e
83
- puts e.message
84
- end
73
+ puts("Migrating #{tenant} tenant up")
74
+ Apartment::Migrator.run :up, tenant, version
75
+ rescue Apartment::TenantNotFound => e
76
+ puts e.message
85
77
  end
86
78
  end
87
79
 
@@ -93,12 +85,10 @@ apartment_namespace = namespace :apartment do
93
85
  raise 'VERSION is required' unless version
94
86
 
95
87
  Apartment::TaskHelper.each_tenant do |tenant|
96
- begin
97
- puts("Migrating #{tenant} tenant down")
98
- Apartment::Migrator.run :down, tenant, version
99
- rescue Apartment::TenantNotFound => e
100
- puts e.message
101
- end
88
+ puts("Migrating #{tenant} tenant down")
89
+ Apartment::Migrator.run :down, tenant, version
90
+ rescue Apartment::TenantNotFound => e
91
+ puts e.message
102
92
  end
103
93
  end
104
94
 
@@ -27,17 +27,23 @@ Gem::Specification.new do |s|
27
27
  s.homepage = 'https://github.com/rails-on-services/apartment'
28
28
  s.licenses = ['MIT']
29
29
 
30
- s.add_dependency 'activerecord', '>= 5.0.0', '< 6.2'
31
- s.add_dependency 'parallel', '< 2.0'
32
- s.add_dependency 'public_suffix', '>= 2.0.5', '< 5.0'
33
- s.add_dependency 'rack', '>= 1.3.6', '< 3.0'
30
+ s.add_dependency 'activerecord', '>= 5.0.0', '< 6.2'
31
+ s.add_dependency 'parallel', '< 2.0'
32
+ s.add_dependency 'public_suffix', '>= 2.0.5', '< 5.0'
33
+ s.add_dependency 'rack', '>= 1.3.6', '< 3.0'
34
34
 
35
- s.add_development_dependency 'appraisal', '~> 2.2'
36
- s.add_development_dependency 'bundler', '>= 1.3', '< 3.0'
37
- s.add_development_dependency 'capybara', '~> 2.0'
38
- s.add_development_dependency 'rake', '~> 13.0'
39
- s.add_development_dependency 'rspec', '~> 3.4'
40
- s.add_development_dependency 'rspec-rails', '~> 3.4'
35
+ s.add_development_dependency 'appraisal', '~> 2.2'
36
+ s.add_development_dependency 'bundler', '>= 1.3', '< 3.0'
37
+ s.add_development_dependency 'guard-rspec', '~> 4.2'
38
+ s.add_development_dependency 'pry'
39
+ s.add_development_dependency 'rake', '~> 13.0'
40
+ s.add_development_dependency 'rspec', '~> 3.4'
41
+ s.add_development_dependency 'rspec_junit_formatter'
42
+ s.add_development_dependency 'rspec-rails', '~> 3.4'
43
+ s.add_development_dependency 'rubocop', '~> 0.93'
44
+ s.add_development_dependency 'rubocop-performance', '~> 1.10'
45
+ s.add_development_dependency 'rubocop-rails', '~> 2.1'
46
+ s.add_development_dependency 'rubocop-rspec', '~> 1.44'
41
47
 
42
48
  if defined?(JRUBY_VERSION)
43
49
  s.add_development_dependency 'activerecord-jdbc-adapter'
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ros-apartment
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
8
8
  - Brad Robertson
9
9
  - Rui Baltazar
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-21 00:00:00.000000000 Z
13
+ date: 2021-09-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -121,19 +121,33 @@ dependencies:
121
121
  - !ruby/object:Gem::Version
122
122
  version: '3.0'
123
123
  - !ruby/object:Gem::Dependency
124
- name: capybara
124
+ name: guard-rspec
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '2.0'
129
+ version: '4.2'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '2.0'
136
+ version: '4.2'
137
+ - !ruby/object:Gem::Dependency
138
+ name: pry
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
137
151
  - !ruby/object:Gem::Dependency
138
152
  name: rake
139
153
  requirement: !ruby/object:Gem::Requirement
@@ -162,6 +176,20 @@ dependencies:
162
176
  - - "~>"
163
177
  - !ruby/object:Gem::Version
164
178
  version: '3.4'
179
+ - !ruby/object:Gem::Dependency
180
+ name: rspec_junit_formatter
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
165
193
  - !ruby/object:Gem::Dependency
166
194
  name: rspec-rails
167
195
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +204,62 @@ dependencies:
176
204
  - - "~>"
177
205
  - !ruby/object:Gem::Version
178
206
  version: '3.4'
207
+ - !ruby/object:Gem::Dependency
208
+ name: rubocop
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: '0.93'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - "~>"
219
+ - !ruby/object:Gem::Version
220
+ version: '0.93'
221
+ - !ruby/object:Gem::Dependency
222
+ name: rubocop-performance
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "~>"
226
+ - !ruby/object:Gem::Version
227
+ version: '1.10'
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "~>"
233
+ - !ruby/object:Gem::Version
234
+ version: '1.10'
235
+ - !ruby/object:Gem::Dependency
236
+ name: rubocop-rails
237
+ requirement: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: '2.1'
242
+ type: :development
243
+ prerelease: false
244
+ version_requirements: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - "~>"
247
+ - !ruby/object:Gem::Version
248
+ version: '2.1'
249
+ - !ruby/object:Gem::Dependency
250
+ name: rubocop-rspec
251
+ requirement: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - "~>"
254
+ - !ruby/object:Gem::Version
255
+ version: '1.44'
256
+ type: :development
257
+ prerelease: false
258
+ version_requirements: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - "~>"
261
+ - !ruby/object:Gem::Version
262
+ version: '1.44'
179
263
  - !ruby/object:Gem::Dependency
180
264
  name: mysql2
181
265
  requirement: !ruby/object:Gem::Requirement
@@ -231,11 +315,13 @@ files:
231
315
  - ".circleci/config.yml"
232
316
  - ".github/ISSUE_TEMPLATE.md"
233
317
  - ".github/workflows/changelog.yml"
318
+ - ".github/workflows/reviewdog.yml"
234
319
  - ".gitignore"
235
320
  - ".pryrc"
236
321
  - ".rspec"
237
322
  - ".rubocop.yml"
238
323
  - ".rubocop_todo.yml"
324
+ - ".ruby-version"
239
325
  - ".story_branch.yml"
240
326
  - Appraisals
241
327
  - CHANGELOG.md
@@ -292,7 +378,7 @@ homepage: https://github.com/rails-on-services/apartment
292
378
  licenses:
293
379
  - MIT
294
380
  metadata: {}
295
- post_install_message:
381
+ post_install_message:
296
382
  rdoc_options: []
297
383
  require_paths:
298
384
  - lib
@@ -307,8 +393,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
393
  - !ruby/object:Gem::Version
308
394
  version: '0'
309
395
  requirements: []
310
- rubygems_version: 3.1.4
311
- signing_key:
396
+ rubygems_version: 3.1.6
397
+ signing_key:
312
398
  specification_version: 4
313
399
  summary: A Ruby gem for managing database multitenancy. Apartment Gem drop in replacement
314
400
  test_files: []