secondbase 2.0.0 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 957af9b02d7c9c9661dbf3068c11e3071a9f16e7
4
- data.tar.gz: 4ff4ac5bec6b6eaee9f398e14f267b854894e954
3
+ metadata.gz: 78a47d016139857a1c9b4167e4b2960dd833ba78
4
+ data.tar.gz: 7bf629b8e5bb03a805c67ffc04daee46d4635be2
5
5
  SHA512:
6
- metadata.gz: 157600ae2064ec41999df39dae6a01f14be0771056a1bdddd1d53f80300b8a65325552aaf49c5b95f4db7d44154806e99e0e09ec1c2f70d7eb185cc8db266271
7
- data.tar.gz: 47a3bd10685228413f56559ce91353ef0bb10962facee6e282a3958fd661c521abce4ab953e38f205e19fea0200499365f613ae3afe4f50947f79f6557c6695b
6
+ metadata.gz: e300a7436d8528aa1342b4b5a9aa14a0d129668b38dace6a9c27bb1cd4bf4272fb8e6d2f899eead5c2fc8afd1b0b47aab80b46af49d56b8237b8fd223e40409b
7
+ data.tar.gz: 78f37cc71147a09b0fcac2f6582a0ce5d36f30286a68ce7b549b436b6d161dceea51b0b8a3a0fe3e715d0f388a7b212c8a4c601ffaed42d11921ec0f9dde5e71
data/README.md CHANGED
@@ -34,7 +34,7 @@ secondbase:
34
34
 
35
35
  #### Database Tasks
36
36
 
37
- SecondBase aims to work seamlessly within your Rails application. When it makes sense, we run a mirrored `db:second_base` task for matching ActiveRecord base database task. For example:
37
+ SecondBase aims to work seamlessly within your Rails application. When it makes sense, we run a mirrored `db:second_base` task for matching ActiveRecord base database task. These can all be deactivated by setting `config.second_base.run_with_db_tasks = false` in your Application's configuration. For example:
38
38
 
39
39
  ```shell
40
40
  $ rake db:create
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.1.0
@@ -113,7 +113,7 @@ end
113
113
  test:purge test:load_schema test:load_structure test:prepare
114
114
  }.each do |name|
115
115
  task = Rake::Task["db:#{name}"] rescue nil
116
- next unless task
116
+ next unless task && SecondBase::Railtie.run_with_db_tasks?
117
117
  task.enhance do
118
118
  Rake::Task["db:load_config"].invoke
119
119
  Rake::Task["db:second_base:#{name}"].invoke
@@ -14,7 +14,7 @@ end
14
14
  drop:_unsafe
15
15
  }.each do |name|
16
16
  task = Rake::Task["db:#{name}"] rescue nil
17
- next unless task
17
+ next unless task && SecondBase::Railtie.run_with_db_tasks?
18
18
  task.enhance do
19
19
  Rake::Task["db:load_config"].invoke
20
20
  Rake::Task["db:second_base:#{name}"].invoke
@@ -14,7 +14,7 @@ end
14
14
  drop
15
15
  }.each do |name|
16
16
  task = Rake::Task["db:#{name}"] rescue nil
17
- next unless task
17
+ next unless task && SecondBase::Railtie.run_with_db_tasks?
18
18
  task.enhance do
19
19
  Rake::Task["db:load_config"].invoke
20
20
  Rake::Task["db:second_base:#{name}"].invoke
@@ -4,6 +4,7 @@ module SecondBase
4
4
  config.second_base = ActiveSupport::OrderedOptions.new
5
5
  config.second_base.path = 'db/secondbase'
6
6
  config.second_base.config_key = 'secondbase'
7
+ config.second_base.run_with_db_tasks = true
7
8
 
8
9
  config.after_initialize do |app|
9
10
  secondbase_dir = app.root.join(config.second_base.path)
@@ -38,6 +39,10 @@ module SecondBase
38
39
  config.second_base.config_key
39
40
  end
40
41
 
42
+ def run_with_db_tasks?
43
+ config.second_base.run_with_db_tasks
44
+ end
45
+
41
46
  def fullpath(extra=nil)
42
47
  path = Rails.root.join(config.second_base.path)
43
48
  (extra ? path.join(path, extra) : path).to_s
@@ -207,9 +207,19 @@ class DbTaskTest < SecondBase::TestCase
207
207
  assert_match(/version: 20151202075826/, run_secondbase(:version))
208
208
  end
209
209
 
210
+ def test_secondbase_db_tasks_disabled
211
+ refute_dummy_databases
212
+ run_db :create, :stdout, false
213
+ assert_dummy_created_but_not_secondbase
214
+ end
210
215
 
211
216
  private
212
217
 
218
+ def assert_dummy_created_but_not_secondbase
219
+ assert_equal 'base.sqlite3', dummy_database_sqlite
220
+ refute_match(/secondbase_test/, `mysql -uroot -e "SHOW DATABASES"`)
221
+ end
222
+
213
223
  def assert_no_tables
214
224
  if ActiveRecord::Base.connection.respond_to? :data_sources
215
225
  assert_equal [], ActiveRecord::Base.connection.data_sources
@@ -33,7 +33,9 @@ module Dummy
33
33
 
34
34
  config.active_record.schema_format = ENV['SCHEMA_FORMAT'] ? :sql : :ruby
35
35
 
36
-
36
+ if ENV['WITH_SECONDBASE_TASKS'].present?
37
+ config.second_base.run_with_db_tasks = ENV['WITH_SECONDBASE_TASKS'] == 'true'
38
+ end
37
39
  end
38
40
  end
39
41
 
@@ -33,7 +33,9 @@ module Dummy
33
33
 
34
34
  config.active_record.schema_format = ENV['SCHEMA_FORMAT'] ? :sql : :ruby
35
35
 
36
-
36
+ if ENV['WITH_SECONDBASE_TASKS'].present?
37
+ config.second_base.run_with_db_tasks = ENV['WITH_SECONDBASE_TASKS'] == 'true'
38
+ end
37
39
  end
38
40
  end
39
41
 
@@ -66,9 +66,9 @@ module SecondBase
66
66
  'rake'
67
67
  end
68
68
 
69
- def run_db(args, stream=:stdout)
69
+ def run_db(args, stream=:stdout, with_secondbase_tasks=true)
70
70
  capture(stream) do
71
- Dir.chdir(dummy_root) { Kernel.system "#{run_cmd} db:#{args}" }
71
+ Dir.chdir(dummy_root) { Kernel.system "env WITH_SECONDBASE_TASKS=#{with_secondbase_tasks} #{run_cmd} db:#{args}" }
72
72
  end
73
73
  end
74
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secondbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karle Durante
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-05-11 00:00:00.000000000 Z
13
+ date: 2016-05-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails