culturecode_stagehand 0.7.2 → 0.7.3

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
  SHA1:
3
- metadata.gz: 32aa6c36c7e088a7ced2a1ba65eb7bebf49403b0
4
- data.tar.gz: c57ef59b9cd02ca2576e7360a57dd50285e24ec2
3
+ metadata.gz: 52ea6afe3b8d21f4df0bdea2a78b92d9c013151a
4
+ data.tar.gz: 87c189ec7bde9cd9a09c55e338b1179d6fd56a00
5
5
  SHA512:
6
- metadata.gz: fc7407c7a397721ffbf567d24a4917958b1a97ef6acbdb7d9a1828f875ca043cf5081fbb45b5190a5d2906d3f3ffc2bbc66fe6bc8b136e04798f0aa500067bd5
7
- data.tar.gz: cc5115eb348fa1a58ab94835dfba2752d6f906fbe6b394f1a70a19963ee91bb33d183d440c74b31ded684589dd4e953ff1f2c02ad7a9b4996450353876a6b2d3
6
+ metadata.gz: 6860268a6a3eb5983622b2ddb0020ce472ad7ae73fbe96f3b043370162fd76054c6fe06366b2160b06ecc95c22d149bd065d627f630ab81d7e3140c95b36d10e
7
+ data.tar.gz: f18cfc88589e4f566b68a50806a53f87c32ecade90a04fd3c490e74336a253d856fa82aea6314f5e6fd0fb66297cd6a393eec2cc47383580b19afa5c0d035d60
@@ -17,11 +17,19 @@ module Stagehand
17
17
  private
18
18
 
19
19
  def use_staging_database(&block)
20
- Database.with_connection(Configuration.staging_connection_name, &block)
20
+ use_database(Configuration.staging_connection_name, &block)
21
21
  end
22
22
 
23
23
  def use_production_database(&block)
24
- Database.with_connection(Configuration.production_connection_name, &block)
24
+ use_database(Configuration.production_connection_name, &block)
25
+ end
26
+
27
+ def use_database(connection_name, &block)
28
+ if Configuration.ghost_mode?
29
+ block.call
30
+ else
31
+ Database.with_connection(connection_name, &block)
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -29,7 +29,7 @@ module Stagehand
29
29
  end
30
30
 
31
31
  def with_connection(connection_name)
32
- different = !Configuration.ghost_mode? && current_connection_name != connection_name.to_sym
32
+ different = current_connection_name != connection_name.to_sym
33
33
 
34
34
  @@connection_name_stack.push(connection_name.to_sym)
35
35
  Rails.logger.debug "Connecting to #{current_connection_name}"
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
@@ -18,10 +18,11 @@ namespace :stagehand do
18
18
  desc "Migrate both databases used by stagehand"
19
19
  task :migrate => :environment do
20
20
  [Rails.configuration.x.stagehand.staging_connection_name,
21
- Rails.configuration.x.stagehand.production_connection_name].each do |config_key|
22
- puts "Migrating #{config_key}"
23
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[config_key.to_s])
24
- ActiveRecord::Migrator.migrate('db/migrate')
21
+ Rails.configuration.x.stagehand.production_connection_name].each do |connection_name|
22
+ puts "Migrating #{connection_name}"
23
+ Stagehand::Database.with_connection(connection_name) do
24
+ ActiveRecord::Migrator.migrate('db/migrate')
25
+ end
25
26
  end
26
27
  end
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culturecode_stagehand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-14 00:00:00.000000000 Z
12
+ date: 2016-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails