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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f908a39e8ca653da51b795fc1358d61e6e03ffc3a1136481a6f44f3a3ff5ff3
4
- data.tar.gz: dc286001f28ed79397bd5fb62d166dca5b0113e0cf5e30d209ee54257e3b49a4
3
+ metadata.gz: cf33f872636cb2386289ee8d1de3fd9fd708cbdb04aab976288abf5bb735c6c6
4
+ data.tar.gz: 0bc427b2c69261fd3665814dd2d137e9e040d62d8f1046d178123742237035b2
5
5
  SHA512:
6
- metadata.gz: 6eba3a9866a5ba3a9d50a0a45407854abc1817e662b1b6f420bfd3fddab48ec6600fc9ca1cb7fd88b4dbcd9a17bdbd308fd16acb9a8203e1168508a9cf0b9430
7
- data.tar.gz: bb3b44bd30418341277b7233b3e97b453d3b96da58683a71f0c6c2e01e68408d2d3e1d0b24282ad1f99d7a544a2f69659f64be1f75d7e916982cf0496a793c73
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
- sh Command.build(operation, args[:rails_env]).command, options
14
+ command.execute(options)
15
15
  end
16
16
  end
17
17
 
18
- attr_accessor :operation
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 initialize(env)
31
- @env = env || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
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 = { '-E' => @env, '-c' => 'config/database.yml' }
42
- options_hash['--ignore-tables'] = ignore_tables.join(',') if ignore_tables.size > 0
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
@@ -1,5 +1,5 @@
1
1
  module Ridgepole
2
2
  module Rails
3
- VERSION = '1.0.6'
3
+ VERSION = -'1.0.7'
4
4
  end
5
5
  end
@@ -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('export')
5
+ Ridgepole::Rails::RakeTask::Export.new
6
6
 
7
7
  desc 'Apply Schemafile to the database'
8
- Ridgepole::Rails::RakeTask.new('apply')
8
+ Ridgepole::Rails::RakeTask::Apply.new
9
9
  end
10
10
 
11
11
  Rake.application.lookup('db:migrate').clear
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridgepole-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - OZAWA Sakuro