ridgepole-rails 1.0.6 → 1.0.7
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/lib/ridgepole/rails/rake_task.rb +31 -10
- data/lib/ridgepole/rails/version.rb +1 -1
- data/lib/tasks/ridgepole.rake +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf33f872636cb2386289ee8d1de3fd9fd708cbdb04aab976288abf5bb735c6c6
|
4
|
+
data.tar.gz: 0bc427b2c69261fd3665814dd2d137e9e040d62d8f1046d178123742237035b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e962df18d0748ebb73c2d68776abad62a42828c4b6972f04bc9c42fa5f226a888204870690540660bf443fde64056d4a232ea527e1b63a1367a8af465fd2a302
|
7
|
+
data.tar.gz: 93f916011771e075f83f92aa589a7d851cad5c49ce9076502f4d3ea007f3bbfc3b081ca5752993c1986640d707d4b56d9c9f71c79d4c8e21c78f15e97cddfeb0
|
@@ -6,52 +6,73 @@ require 'ridgepole/rails/restore_extensions_on_purge'
|
|
6
6
|
module Ridgepole
|
7
7
|
module Rails
|
8
8
|
class RakeTask < ::Rake::TaskLib
|
9
|
-
def initialize(name)
|
9
|
+
def initialize(name=default_task_name)
|
10
10
|
task name, :rails_env do |_t, args|
|
11
|
-
self.operation = name
|
12
11
|
yield self if block_given?
|
12
|
+
command = build_command(args[:rails_env])
|
13
13
|
options = {out: IO::NULL}
|
14
|
-
|
14
|
+
command.execute(options)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
private
|
19
|
+
|
20
|
+
def default_task_name
|
21
|
+
self.class.name.demodulize.downcase
|
22
|
+
end
|
23
|
+
|
24
|
+
def operation
|
25
|
+
self.class.name.demodulize.downcase
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_command(env)
|
29
|
+
Command.build(operation, env)
|
30
|
+
end
|
31
|
+
|
32
|
+
class Apply < self; end
|
33
|
+
class Export < self; end
|
19
34
|
end
|
20
35
|
|
21
36
|
class Command
|
22
37
|
RIDGEPOLE_COMMAND = 'bundle exec ridgepole'.shellsplit
|
23
38
|
|
39
|
+
include FileUtils
|
40
|
+
|
24
41
|
class << self
|
25
42
|
def build(operation, env)
|
26
43
|
const_get(operation.classify).new(env)
|
27
44
|
end
|
28
45
|
end
|
29
46
|
|
30
|
-
def
|
31
|
-
|
47
|
+
def execute(options={})
|
48
|
+
sh command, options
|
32
49
|
end
|
33
50
|
|
34
51
|
private
|
35
52
|
|
53
|
+
def initialize(env)
|
54
|
+
@env = env || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
55
|
+
end
|
56
|
+
|
36
57
|
def ignore_tables
|
37
58
|
ActiveRecord::SchemaDumper.ignore_tables.map(&:source)
|
38
59
|
end
|
39
60
|
|
40
61
|
def options
|
41
|
-
options_hash = {
|
42
|
-
options_hash['--ignore-tables'] = ignore_tables.join(',') if ignore_tables.
|
62
|
+
options_hash = {'-E' => @env, '-c' => 'config/database.yml'}
|
63
|
+
options_hash['--ignore-tables'] = ignore_tables.join(',') if ignore_tables.present? # rubocop:disable Metrics/LineLength
|
43
64
|
options_hash.to_a.flatten
|
44
65
|
end
|
45
66
|
|
46
67
|
class Export < self
|
47
68
|
def command
|
48
|
-
[*RIDGEPOLE_COMMAND, *%w(--export -o Schemafile), *options].shelljoin
|
69
|
+
[*RIDGEPOLE_COMMAND, *%w(--export -o Schemafile), *options].shelljoin # rubocop:disable Lint/UnneededSplatExpansion
|
49
70
|
end
|
50
71
|
end
|
51
72
|
|
52
73
|
class Apply < self
|
53
74
|
def command
|
54
|
-
[*RIDGEPOLE_COMMAND, *%w(--apply), *options].shelljoin
|
75
|
+
[*RIDGEPOLE_COMMAND, *%w(--apply), *options].shelljoin # rubocop:disable Lint/UnneededSplatExpansion
|
55
76
|
end
|
56
77
|
end
|
57
78
|
end
|
data/lib/tasks/ridgepole.rake
CHANGED
@@ -2,10 +2,10 @@ require 'ridgepole/rails/rake_task'
|
|
2
2
|
|
3
3
|
namespace :ridgepole do
|
4
4
|
desc 'Export the database schema to Schemafile'
|
5
|
-
Ridgepole::Rails::RakeTask.new
|
5
|
+
Ridgepole::Rails::RakeTask::Export.new
|
6
6
|
|
7
7
|
desc 'Apply Schemafile to the database'
|
8
|
-
Ridgepole::Rails::RakeTask.new
|
8
|
+
Ridgepole::Rails::RakeTask::Apply.new
|
9
9
|
end
|
10
10
|
|
11
11
|
Rake.application.lookup('db:migrate').clear
|