penthouse 0.8.0 → 0.9.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: 92248bef6760f1ed6455c27c851fce79e267b8e7
4
- data.tar.gz: cc5a1f2bfdda094227a8449123dd8178a09305a0
3
+ metadata.gz: ddf585328bcdfaa3c9899c24c391500330ddcc84
4
+ data.tar.gz: 1b1ab82b1efdb9fd4e9defb3819317d47ae4e4f0
5
5
  SHA512:
6
- metadata.gz: 41bcde8417c7e7c4ee517682c47230a91dcf72fa918b8834a7ad21032daf3c661ea5c38374c129a9cbdc7b5754faf65eaf85d783f72aceca938996fc20301e85
7
- data.tar.gz: 2c1fe638a8a09aabce3a3c80813f4f4f4ed5106b794688f6b083b8c35413dd7e94d1387370feeeb7a2bc26acd777d592991e4804e056278d619cbe784c8d1278
6
+ metadata.gz: 0c3a1758e69b996836f73cdb094217bec0ae9b8584692e678708579e05ff9589ef8d48abd285fcc8f4c085c0a67f2331992db879b372f54e6531ad6e9ae472fe
7
+ data.tar.gz: 43f988b517f943dd75d4924dc78016f1ccadd1255e7e4a48e9668738933f7e76a489f8964df2f186689563ad2f747dd4d1e7e85211e9e4aa6a15a3d57dfa2d0c
@@ -1,7 +1,5 @@
1
1
  require 'active_record'
2
- require 'set'
3
2
  require 'active_support/core_ext/module/aliasing'
4
- require 'active_support/core_ext/array/wrap'
5
3
 
6
4
  module Penthouse
7
5
  module Migration
@@ -37,16 +35,33 @@ module Penthouse
37
35
  alias_method :down_with_octopus, :down_with_penthouse
38
36
  alias_method :run_with_octopus, :run_with_penthouse
39
37
  end
38
+
39
+ alias_method_chain :migrate, :penthouse
40
+ alias_method_chain :migrations, :penthouse
41
+
42
+ # override any new Octopus methods with the new Penthouse ones
43
+ alias_method :migrate_with_octopus, :migrate_with_penthouse
44
+ alias_method :migrations_with_octopus, :migrations_with_penthouse
40
45
  end
41
46
  end
42
47
 
48
+ # this may seem stupid but it gets around issues with Octopus
49
+ def migrate_with_penthouse(*args)
50
+ migrate_without_penthouse(*args)
51
+ end
52
+
53
+ # this may seem stupid but it gets around issues with Octopus
54
+ def migrations_with_penthouse
55
+ migrations_without_penthouse
56
+ end
57
+
43
58
  module ClassMethods
44
59
  def migrate_with_penthouse(migrations_paths, target_version = nil, &block)
45
60
  unless Penthouse.configuration.migrate_tenants?
46
61
  return migrate_without_penthouse(migrations_paths, target_version, &block)
47
62
  end
48
63
 
49
- Penthouse.each_tenant(tenant_identifiers: tenants_to_migrate) do |tenant|
64
+ wrap_penthouse do
50
65
  migrate_without_penthouse(migrations_paths, target_version, &block)
51
66
  end
52
67
  end
@@ -56,18 +71,18 @@ module Penthouse
56
71
  return up_without_penthouse(migrations_paths, target_version, &block)
57
72
  end
58
73
 
59
- Penthouse.each_tenant(tenant_identifiers: tenants_to_migrate) do |tenant|
60
- up_without_penthouse(migrations_paths, target_version, &block)
74
+ wrap_penthouse do
75
+ up_without_penthouse(migrations_paths, target_version)
61
76
  end
62
77
  end
63
78
 
64
79
  def down_with_penthouse(migrations_paths, target_version = nil, &block)
65
80
  unless Penthouse.configuration.migrate_tenants?
66
- return down_without_penthouse(migrations_paths, target_version, &block)
81
+ return down_without_penthouse(migrations_paths, target_version)
67
82
  end
68
83
 
69
- Penthouse.each_tenant(tenant_identifiers: tenants_to_migrate) do |tenant|
70
- down_without_penthouse(migrations_paths, target_version, &block)
84
+ wrap_penthouse do
85
+ down_without_penthouse(migrations_paths, target_version)
71
86
  end
72
87
  end
73
88
 
@@ -76,13 +91,21 @@ module Penthouse
76
91
  return run_without_penthouse(direction, migrations_paths, target_version)
77
92
  end
78
93
 
79
- Penthouse.each_tenant(tenant_identifiers: tenants_to_migrate) do |tenant|
94
+ wrap_penthouse do
80
95
  run_without_penthouse(direction, migrations_paths, target_version)
81
96
  end
82
97
  end
83
98
 
84
99
  private
85
100
 
101
+ def wrap_penthouse(&block)
102
+ if Penthouse.tenant
103
+ block.yield
104
+ else
105
+ Penthouse.each_tenant(tenant_identifiers: tenants_to_migrate, &block)
106
+ end
107
+ end
108
+
86
109
  def tenants_to_migrate
87
110
  return @tenants_to_migrate if defined?(@tenants_to_migrate)
88
111
  @tenants_to_migrate = begin
@@ -1,3 +1,3 @@
1
1
  module Penthouse
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
data/penthouse.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'rack', '~> 1.6.4'
30
30
  # db
31
31
  spec.add_development_dependency 'ar-octopus', '~> 0.8.6'
32
+ spec.add_development_dependency 'activesupport', '~> 4.2.6'
32
33
  spec.add_development_dependency 'activerecord', '~> 4.2.6'
33
34
  spec.add_development_dependency 'pg'
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: penthouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Townsend
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.8.6
125
+ - !ruby/object:Gem::Dependency
126
+ name: activesupport
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 4.2.6
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 4.2.6
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: activerecord
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +192,6 @@ files:
178
192
  - lib/penthouse/sidekiq/middleware/client.rb
179
193
  - lib/penthouse/sidekiq/middleware/server.rb
180
194
  - lib/penthouse/sidekiq/railtie.rb
181
- - lib/penthouse/tasks/enhancements.rb
182
195
  - lib/penthouse/tenants/base_tenant.rb
183
196
  - lib/penthouse/tenants/migratable.rb
184
197
  - lib/penthouse/tenants/octopus_schema_tenant.rb
@@ -1,35 +0,0 @@
1
- # Require this file to append Penthouse rake tasks to ActiveRecord db rake tasks
2
- # Enabled by default in the initializer
3
-
4
- # shamelessly copied & adjusted from Apartment
5
- # @see https://github.com/influitive/apartment/blob/development/lib/apartment/tasks/enhancements.rb
6
-
7
- module Penthouse
8
- class RakeTaskEnhancer
9
- TASKS = %w(db:migrate db:rollback db:migrate:up db:migrate:down db:migrate:redo db:seed)
10
-
11
- class << self
12
- def enhance!
13
- TASKS.each do |name|
14
- task = Rake::Task[name]
15
- task.enhance do
16
- if should_enhance?
17
- enhance_task(task)
18
- end
19
- end
20
- end
21
- end
22
-
23
- def should_enhance?
24
- Penthouse.configuration.migrate_tenants?
25
- end
26
-
27
- def enhance_task(task)
28
- Rake::Task[task.name.sub(/db:/, 'penthouse:')].invoke
29
- end
30
- end
31
-
32
- end
33
- end
34
-
35
- Penthouse::RakeTaskEnhancer.enhance!