ridgepole_rake 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66b86d868274645bbd50d8aef5252f1436d1e0a0
4
+ data.tar.gz: 2a9cf0c9659d22fb9906c53dda66c455f35a8989
5
+ SHA512:
6
+ metadata.gz: e6dd6208c91236d3b54c7304dac9448de024e898036dd954722f7acd33c9b9336f01ac903ed0af767bd2f915eb0cefd9696543c1edfbddecd9e1429f6096f680
7
+ data.tar.gz: 257aa8175249d4054d19e659fba32378df4a5865fc1275c176572bddf4d52610e4b7dcb8ffc444fa00a70d39e70e302c287fbc7efe67640c1b7c0142e5a10f61
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile*.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ cache: bundler
3
+ bundler_args: "--without production"
4
+ rvm:
5
+ - 2.1.6
6
+ - 2.2.0
7
+ - 2.2.1
8
+ - 2.2.2
9
+ - 2.2.3
10
+ gemfile:
11
+ - Gemfile
12
+ - Gemfile-rails
13
+ - Gemfile-minimum
14
+ before_install: gem install bundler -v 1.10.6
15
+ addons:
16
+ code_climate:
17
+ repo_token: f1d3de8fd8a6342cd1a107dd7619a218e433a338b4138a4dc3d0fb4a27060086
18
+ notifications:
19
+ slack:
20
+ secure: crXLS0et/PmOSstxqTiyYH5rLXMMW3dyn4jX2Ks/RlWSXW8cuqjwXKIHJ4E4DTU1US6NQ7m9xIR3rUe3hLRFWwjZxrescYwZRhnpV32d09W+bk/WR96oEYmSbMSgArrBWbDFxO5g6fKZvUauftQ8jp1Krxa7ANjRLNYgMmpNbnIXLhOyjsuKBzOQrnyip3mMcpJjae1V81DhU5r8XbPdWpUzvjgowYaKc1IV1SYtrjGJH+w/JlAzb7aPKiyM7dGZw08nPS1kRNO8fUcIHaYwcvXifxQBxlgVb8YtkR7B+DCRtEea/sxZEVmAfXuAdahGKjMP6LsQfl1qJCWVVPpaRgYCd0+JGzTPRu3ReAy+TTHdlWbjWtf+kmhkxXRRkwJEVhA7aLlgzFyNAfYg1fICxuzppzjeK3t8BOlkSEfjV37QPacgo19h5wTT5pyddcCfiOVWSTRCUCXBq4D7AXt2jVDxJtW01sGDmh9Z726HAec5zDYJNAX4UKinf9f2dzD3gknD23IFerkdl/HyxTEKrVvE9dVlVeaOsjuyEPiJdM/IjdVmPEIb4RVYwYDSfoks98rnd/k5JO/TPOMBAlJC3qYNr1QK6R5NcrBxLpCRSnAZT1vUn0CkBBhbPbVH70U+zH2iOFJSL6R5ev8oHJdPuYie224joY6ShvoErtcZa3M=
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ridgepole_rake.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'pry'
8
+ gem 'pry-power_assert'
9
+ gem 'pry-doc'
10
+ gem 'pry-byebug'
11
+ end
12
+
13
+ group :test do
14
+ gem 'minitest'
15
+ gem 'minitest-reporters'
16
+ gem 'brancher'
17
+ gem 'rails'
18
+ gem "codeclimate-test-reporter", require: false
19
+ end
data/Gemfile-minimum ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'minitest'
7
+ gem 'minitest-reporters'
8
+ end
data/Gemfile-rails ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'minitest'
7
+ gem 'minitest-reporters'
8
+ gem 'rails'
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,168 @@
1
+ # RidgepoleRake
2
+
3
+ [![Build Status](https://travis-ci.org/nalabjp/ridgepole_rake.svg?branch=master)](https://travis-ci.org/nalabjp/ridgepole_rake)
4
+ [![Code Climate](https://codeclimate.com/github/nalabjp/ridgepole_rake/badges/gpa.svg)](https://codeclimate.com/github/nalabjp/ridgepole_rake)
5
+ [![Test Coverage](https://codeclimate.com/github/nalabjp/ridgepole_rake/badges/coverage.svg)](https://codeclimate.com/github/nalabjp/ridgepole_rake/coverage)
6
+ [![Dependency Status](https://gemnasium.com/nalabjp/ridgepole_rake.svg)](https://gemnasium.com/nalabjp/ridgepole_rake)
7
+
8
+ RidgepoleRake provides basic Rake Task for [Ridgepole](https://github.com/winebarrel/ridgepole).
9
+
10
+ RidgepoleRake supports the version 0.5.0 or later of Ridgepole.
11
+
12
+ ## Installation
13
+
14
+ Add to your Gemfile:
15
+
16
+ ```ruby
17
+ gem 'ridgepole_rake'
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Add to your Rakefile:
23
+
24
+ ```ruby
25
+ require 'ridgepole_rake'
26
+ load 'tasks/ridgepole_rake.rake'
27
+ ```
28
+
29
+ If you are using Rails, it has tasks are loaded automatically.
30
+
31
+ ## Tasks
32
+
33
+ $ rake -T
34
+ rake ridgepole:apply # `ridgepole --apply`
35
+ rake ridgepole:apply:dry-run # `ridgepole --apply --dry-run`
36
+ rake ridgepole:diff # `ridgepole --diff` current db and schema file
37
+ rake ridgepole:export # `ridgepole --export`
38
+ rake ridgepole:merge[file] # `ridgepole --merge`
39
+ rake ridgepole:merge:dry-run[file] # `ridgepole --merge --dry-run`
40
+ rake ridgepole:reset # `rake db:drop`, `rake db:create` and `ridgepole --apply`
41
+
42
+ ## Configuration
43
+
44
+ RidgepoleRake can configure options of Ridgepole.
45
+
46
+ ### Configurable options
47
+ see also https://github.com/winebarrel/ridgepole#help
48
+
49
+ ### Default configuration
50
+ ```ruby
51
+ # default configuration
52
+ RidgepoleRake.config.ridgepole
53
+ # => {"config"=>"config/database.yml", "file"=>"db/schemas/Schemafile", "output"=>"db/schemas.dump/Schemafile", "env"=>"development"}
54
+ ```
55
+
56
+ ### Example
57
+ Set by Symbol key.
58
+ ```ruby
59
+ # Symbol key
60
+ RidgepoleRake.config.ridgepole[:env] = 'staging'
61
+ # => {"config"=>"config/database.yml", "file"=>"db/schemas/Schemafile", "output"=>"db/schemas.dump/Schemafile", "env"=>"staging"}
62
+
63
+ RidgepoleRake.config.ridgepole[:env]
64
+ # => 'staging'
65
+ ```
66
+
67
+ Set by String key.
68
+ ```ruby
69
+ # String key
70
+ RidgepoleRake.config.ridgepole['env'] = 'production'
71
+ # => {"config"=>"config/database.yml", "file"=>"db/schemas/Schemafile", "output"=>"db/schemas.dump/Schemafile", "env"=>"production"}
72
+
73
+ RidgepoleRake.config.ridgepole['env']
74
+ # => 'production'
75
+ ```
76
+
77
+ Convert to `ActiveSupport::HashWithIndifferentAccess`.
78
+ ```ruby
79
+ RidgepoleRake.config.ridgepole = { env: 'test' }
80
+ RidgepoleRake.config.ridgepole.class
81
+ # => ActiveSupport::HashWithIndifferentAccess
82
+ ```
83
+
84
+ Use `.configure` block
85
+ ```ruby
86
+ RidgepoleRake.configure do |config|
87
+ config.ridgepole[:config] = 'database_config.yml'
88
+ config.ridgepole[:file] = 'Schemafile'
89
+ config.ridgepole[:env] = 'production'
90
+ config.ridgepole[:log_file] = 'log/ridgepole.log'
91
+ config.ridgepole['enable-mysql-awesome'] = true # It allows all the values, if the key does not have value.
92
+ end
93
+ ```
94
+
95
+ ### Custom configuration with Task
96
+ ```ruby
97
+ task :my_config do
98
+ RidgepoleRake.configure do |config|
99
+ config.ridgepole[:config] = 'database_config.yml'
100
+ config.ridgepole[:file] = 'Schemafile'
101
+ config.ridgepole[:env] = 'production'
102
+ config.ridgepole[:log_file] = 'log/ridgepole.log'
103
+ config.ridgepole['enable-mysql-awesome'] = true
104
+ end
105
+ end
106
+
107
+ task 'ridgepole:apply:dry-run' => ['my_config']
108
+ ```
109
+
110
+ or
111
+
112
+ ```ruby
113
+ task :my_ridgepole_apply_dryrun do
114
+ RidgepoleRake.configure do |config|
115
+ config.ridgepole[:config] = 'database_config.yml'
116
+ config.ridgepole[:file] = 'Schemafile'
117
+ config.ridgepole[:env] = 'production'
118
+ config.ridgepole[:log_file] = 'log/ridgepole.log'
119
+ config.ridgepole['enable-mysql-awesome'] = true
120
+ end
121
+
122
+ Rake::Task['ridgepole:apply:dry-run'].invoke
123
+ end
124
+ ```
125
+
126
+ ## Rails
127
+
128
+ If you are using Rails, `:env`'s default value is `Rails.env`.
129
+ ```ruby
130
+ Rails.env
131
+ # => production
132
+
133
+ RidgepoleRake.config.ridgepole[:env]
134
+ # => 'production'
135
+ ```
136
+
137
+ ## Brancher
138
+
139
+ RidgepoleRake supports [Brancher](https://github.com/naoty/brancher).
140
+
141
+ Supported version is 0.3.0 or later.
142
+
143
+ Add to your Gemfile:
144
+ ```ruby
145
+ gem 'brancher', '>= 0.3.0'
146
+ ```
147
+
148
+ ```ruby
149
+ RidgepoleRake.config.brancher[:use]
150
+ # => true
151
+ ```
152
+
153
+ ## Bundler
154
+
155
+ RidgepoleRake supports Bundler.
156
+
157
+ ```ruby
158
+ RidgepoleRake.config.bundler
159
+ # => {"use"=>true, "clean_system"=>true}
160
+ ```
161
+
162
+ If `RidgepoleRake.config.bundler[:use] == true` and `RidgepoleRake.config.bundler[:clean_system] == true`, Ridgepole will be performed using `Bundler.clean_system`.
163
+
164
+ ## License
165
+
166
+ MIT License
167
+
168
+ see [LICENSE.txt](https://github.com/nalabjp/ridgepole_rake/blob/master/LICENSE.txt)
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ridgepole_rake"
5
+
6
+ require "pry"
7
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,106 @@
1
+ module RidgepoleRake
2
+ class Command
3
+
4
+ attr_reader :stash, :action, :config, :options
5
+
6
+ def initialize(action, config, options = {})
7
+ @stash = []
8
+ @action = action
9
+ @config = config
10
+ @options = options
11
+ end
12
+
13
+ def execute
14
+ Kernel.system(command)
15
+ end
16
+
17
+ def command
18
+ @command ||= begin
19
+ clear
20
+ build
21
+ join
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def clear
28
+ stash.clear
29
+ end
30
+
31
+ def build
32
+ add_action
33
+ add_dry_run
34
+ add_env
35
+ add_config
36
+ add_extras
37
+ add_ridgepole
38
+ end
39
+
40
+ def join
41
+ stash.join(' ').strip
42
+ end
43
+
44
+ def add_action
45
+ case action
46
+ when :apply, :merge, :export, :diff
47
+ __send__("add_#{action}_action")
48
+ else
49
+ raise UndefinedActionError, "Undefined action: '#{action}'"
50
+ end
51
+ end
52
+
53
+ def add_apply_action
54
+ stash.push('--apply')
55
+ stash.push('--file', config.ridgepole.fetch(:file))
56
+ end
57
+
58
+ def add_merge_action
59
+ stash.push('--merge')
60
+ stash.push('--file', options[:merge_file])
61
+ end
62
+
63
+ def add_export_action
64
+ stash.push('--export')
65
+ stash.push('--output', config.ridgepole.fetch(:output))
66
+ end
67
+
68
+ def add_diff_action
69
+ stash.push('--diff', config.ridgepole.fetch(:config), config.ridgepole.fetch(:file))
70
+ end
71
+
72
+ def add_dry_run
73
+ stash.push('--dry-run') if options[:dry_run]
74
+ end
75
+
76
+ def add_env
77
+ stash.push('--env', config.ridgepole.fetch(:env))
78
+ end
79
+
80
+ def add_config
81
+ stash.push('--config', config.ridgepole.fetch(:config))
82
+ end
83
+
84
+ def add_extras
85
+ stash.concat(extra_options)
86
+ end
87
+
88
+ def extra_options
89
+ configurable_options.each_with_object([]) do |(k, v), arr|
90
+ v = nil if Option.non_value_key?(k)
91
+ k = Option.add_hyphens_if_needed(k)
92
+ arr.push(k, v)
93
+ end.compact
94
+ end
95
+
96
+ def configurable_options
97
+ config.ridgepole.except(*Option.ignored_keys).slice(*Option.recognized_keys)
98
+ end
99
+
100
+ def add_ridgepole
101
+ stash.unshift('ridgepole')
102
+ end
103
+ end
104
+
105
+ class UndefinedActionError < StandardError; end
106
+ end
@@ -0,0 +1,24 @@
1
+ module RidgepoleRake
2
+ class Configuration
3
+ attr_reader :ridgepole
4
+
5
+ def initialize
6
+ @ridgepole = default_ridgepole_options.with_indifferent_access
7
+ end
8
+
9
+ def ridgepole=(hash)
10
+ @ridgepole = hash.with_indifferent_access
11
+ end
12
+
13
+ private
14
+
15
+ def default_ridgepole_options
16
+ {
17
+ config: 'config/database.yml',
18
+ file: 'db/schemas/Schemafile',
19
+ output: 'db/schemas.dump/Schemafile',
20
+ env: 'development',
21
+ }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,63 @@
1
+ require 'erb'
2
+
3
+ module RidgepoleRake
4
+ module Brancher
5
+ module Configuration
6
+ def self.prepended(klass)
7
+ klass.class_eval { attr_reader :brancher }
8
+ end
9
+
10
+ # @note override
11
+ def initialize
12
+ super
13
+ @brancher = { use: true }.with_indifferent_access
14
+ end
15
+
16
+ def brancher=(hash)
17
+ @brancher = hash.with_indifferent_access
18
+ end
19
+ end
20
+
21
+ module Command
22
+ private
23
+
24
+ # @note override
25
+ def add_config
26
+ stash.push('--config', database_configuration)
27
+ end
28
+
29
+ def database_configuration
30
+ if config.brancher[:use] && (yaml = database_configuration_with_brancher rescue nil)
31
+ action.eql?(:diff) ? remove_first_line_in_yaml(yaml) : yaml
32
+ else
33
+ config.ridgepole.fetch(:config)
34
+ end
35
+ end
36
+
37
+ def database_configuration_with_brancher
38
+ configurations = load_configurations
39
+ env = config.ridgepole.fetch(:env)
40
+
41
+ ::Brancher::DatabaseRenameService.rename!(configurations, env)
42
+
43
+ configurations[env].to_yaml
44
+ end
45
+
46
+ def load_configurations
47
+ YAML.load(ERB.new(File.read(config.ridgepole.fetch(:config))).result)
48
+ end
49
+
50
+ def remove_first_line_in_yaml(yaml)
51
+ yaml.sub(/\A---\n/, '')
52
+ end
53
+
54
+ # @note override
55
+ def add_diff_action
56
+ stash.push('--diff', database_configuration, config.ridgepole.fetch(:file))
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ RidgepoleRake::Configuration.prepend(RidgepoleRake::Brancher::Configuration)
63
+ RidgepoleRake::Command.prepend(RidgepoleRake::Brancher::Command)
@@ -0,0 +1,41 @@
1
+ module RidgepoleRake
2
+ module Bundler
3
+ module Configuration
4
+ def self.prepended(klass)
5
+ klass.class_eval { attr_reader :bundler }
6
+ end
7
+
8
+ # @note override
9
+ def initialize
10
+ super
11
+ @bundler = { use: true, clean_system: true }.with_indifferent_access
12
+ end
13
+
14
+ def bundler=(hash)
15
+ @bundler = hash.with_indifferent_access
16
+ end
17
+ end
18
+
19
+ module Command
20
+ # @note override
21
+ def execute
22
+ if config.bundler[:use] && config.bundler[:clean_system]
23
+ ::Bundler.clean_system(command)
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ # @note override
32
+ def add_ridgepole
33
+ super
34
+ stash.unshift('bundle exec') if config.bundler[:use]
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ RidgepoleRake::Configuration.prepend(RidgepoleRake::Bundler::Configuration)
41
+ RidgepoleRake::Command.prepend(RidgepoleRake::Bundler::Command)
@@ -0,0 +1,14 @@
1
+ module RidgepoleRake
2
+ module Rails
3
+ module Configuration
4
+ private
5
+
6
+ # @note override
7
+ def default_ridgepole_options
8
+ super.merge!({ env: ::Rails.env })
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ RidgepoleRake::Configuration.prepend(RidgepoleRake::Rails::Configuration)
@@ -0,0 +1,54 @@
1
+ module RidgepoleRake
2
+ module Option
3
+ extend self
4
+
5
+ def non_value_key?(key)
6
+ non_value_keys.include?(key.to_s)
7
+ end
8
+
9
+ def add_hyphens_if_needed(key)
10
+ case key.to_s
11
+ when /\A[#{single_char_keys.join}]\z/
12
+ "-#{key}"
13
+ when /\A[a-z].+\z/
14
+ "--#{key}"
15
+ else
16
+ key.to_s
17
+ end
18
+ end
19
+
20
+ def ignored_keys
21
+ stash.fetch('ignored_keys')
22
+ end
23
+
24
+ def recognized_keys
25
+ stash.fetch('recognized_keys')
26
+ end
27
+
28
+ def non_value_keys
29
+ stash.fetch('non_value_keys')
30
+ end
31
+
32
+ def single_char_keys
33
+ stash.fetch('single_char_keys')
34
+ end
35
+
36
+ def clear
37
+ @stash = nil
38
+ end
39
+
40
+ private
41
+
42
+ def stash
43
+ @stash ||= YAML.load_file(yaml_path).fetch(ridgepole_version)
44
+ end
45
+
46
+ def yaml_path
47
+ File.expand_path('option_keys.yml', File.dirname(__FILE__))
48
+ end
49
+
50
+ def ridgepole_version
51
+ Ridgepole::VERSION
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,249 @@
1
+ 0.5.0:
2
+ ignored_keys: &050_ignored_keys
3
+ - config
4
+ - c
5
+ - env
6
+ - E
7
+ - apply
8
+ - a
9
+ - merge
10
+ - m
11
+ - file
12
+ - f
13
+ - dry-run
14
+ - export
15
+ - e
16
+ - diff
17
+ - d
18
+ - output
19
+ - o
20
+ recognized_keys:
21
+ - table-options
22
+ - bulk-change
23
+ - default-int-limit
24
+ - pre-query
25
+ - post-query
26
+ - split
27
+ - split-with-dir
28
+ - reverse
29
+ - with-apply
30
+ - tables
31
+ - t
32
+ - ignore-tables
33
+ - enable-mysql-unsigned
34
+ - enable-mysql-pkdump
35
+ - enable-mysql-foreigner
36
+ - log-file
37
+ - verbose
38
+ - debug
39
+ - version
40
+ - v
41
+ non_value_keys:
42
+ - bulk-change
43
+ - split
44
+ - split-with-dir
45
+ - reverse
46
+ - with-apply
47
+ - enable-mysql-unsigned
48
+ - enable-mysql-pkdump
49
+ - enable-mysql-foreigner
50
+ - verbose
51
+ - debug
52
+ - version
53
+ - v
54
+ single_char_keys: &050_single_char_keys
55
+ - t
56
+ - v
57
+ 0.5.1:
58
+ ignored_keys: *050_ignored_keys
59
+ recognized_keys:
60
+ - table-options
61
+ - bulk-change
62
+ - default-int-limit
63
+ - pre-query
64
+ - post-query
65
+ - split
66
+ - split-with-dir
67
+ - reverse
68
+ - with-apply
69
+ - tables
70
+ - t
71
+ - ignore-tables
72
+ - enable-mysql-unsigned
73
+ - enable-mysql-pkdump
74
+ - enable-mysql-foreigner
75
+ - enable-migration-comments
76
+ - normalize-mysql-float
77
+ - log-file
78
+ - verbose
79
+ - debug
80
+ - version
81
+ - v
82
+ non_value_keys:
83
+ - bulk-change
84
+ - split
85
+ - split-with-dir
86
+ - reverse
87
+ - with-apply
88
+ - enable-mysql-unsigned
89
+ - enable-mysql-pkdump
90
+ - enable-mysql-foreigner
91
+ - enable-migration-comments
92
+ - normalize-mysql-float
93
+ - verbose
94
+ - debug
95
+ - version
96
+ - v
97
+ single_char_keys: *050_single_char_keys
98
+ 0.5.2:
99
+ ignored_keys: *050_ignored_keys
100
+ recognized_keys:
101
+ - table-options
102
+ - bulk-change
103
+ - default-int-limit
104
+ - pre-query
105
+ - post-query
106
+ - split
107
+ - split-with-dir
108
+ - reverse
109
+ - with-apply
110
+ - tables
111
+ - t
112
+ - ignore-tables
113
+ - enable-mysql-unsigned
114
+ - enable-mysql-pkdump
115
+ - enable-mysql-foreigner
116
+ - enable-migration-comments
117
+ - normalize-mysql-float
118
+ - enable-mysql-awesome
119
+ - mysql-awesome-unsigned-pk
120
+ - dump-without-table-options
121
+ - require
122
+ - r
123
+ - log-file
124
+ - verbose
125
+ - debug
126
+ - version
127
+ - v
128
+ non_value_keys:
129
+ - bulk-change
130
+ - split
131
+ - split-with-dir
132
+ - reverse
133
+ - with-apply
134
+ - enable-mysql-unsigned
135
+ - enable-mysql-pkdump
136
+ - enable-mysql-foreigner
137
+ - enable-migration-comments
138
+ - normalize-mysql-float
139
+ - enable-mysql-awesome
140
+ - mysql-awesome-unsigned-pk
141
+ - dump-without-table-options
142
+ - verbose
143
+ - debug
144
+ - version
145
+ - v
146
+ single_char_keys: &052_single_char_keys
147
+ - r
148
+ - t
149
+ - v
150
+ 0.6.0:
151
+ ignored_keys: *050_ignored_keys
152
+ recognized_keys: &060_recognized_keys
153
+ - table-options
154
+ - bulk-change
155
+ - default-bool-limit
156
+ - default-int-limit
157
+ - default-float-limit
158
+ - default-string-limit
159
+ - default-text-limit
160
+ - default-binary-limit
161
+ - pre-query
162
+ - post-query
163
+ - split
164
+ - split-with-dir
165
+ - reverse
166
+ - with-apply
167
+ - tables
168
+ - t
169
+ - ignore-tables
170
+ - enable-mysql-awesome
171
+ - dump-without-table-options
172
+ - index-removed-drop-column
173
+ - require
174
+ - r
175
+ - log-file
176
+ - verbose
177
+ - debug
178
+ - version
179
+ - v
180
+ non_value_keys: &060_non_value_keys
181
+ - bulk-change
182
+ - split
183
+ - split-with-dir
184
+ - reverse
185
+ - with-apply
186
+ - enable-mysql-awesome
187
+ - dump-without-table-options
188
+ - index-removed-drop-column
189
+ - verbose
190
+ - debug
191
+ - version
192
+ - v
193
+ single_char_keys: *052_single_char_keys
194
+ 0.6.1:
195
+ ignored_keys: *050_ignored_keys
196
+ recognized_keys: *060_recognized_keys
197
+ non_value_keys: *060_non_value_keys
198
+ single_char_keys: *052_single_char_keys
199
+ 0.6.2:
200
+ ignored_keys: *050_ignored_keys
201
+ recognized_keys: *060_recognized_keys
202
+ non_value_keys: *060_non_value_keys
203
+ single_char_keys: *052_single_char_keys
204
+ 0.6.3:
205
+ ignored_keys: *050_ignored_keys
206
+ recognized_keys:
207
+ - table-options
208
+ - bulk-change
209
+ - default-bool-limit
210
+ - default-int-limit
211
+ - default-float-limit
212
+ - default-string-limit
213
+ - default-text-limit
214
+ - default-binary-limit
215
+ - pre-query
216
+ - post-query
217
+ - split
218
+ - split-with-dir
219
+ - reverse
220
+ - with-apply
221
+ - tables
222
+ - t
223
+ - ignore-tables
224
+ - enable-mysql-awesome
225
+ - dump-without-table-options
226
+ - index-removed-drop-column
227
+ - enable-migration-comments
228
+ - require
229
+ - r
230
+ - log-file
231
+ - verbose
232
+ - debug
233
+ - version
234
+ - v
235
+ non_value_keys:
236
+ - bulk-change
237
+ - split
238
+ - split-with-dir
239
+ - reverse
240
+ - with-apply
241
+ - enable-mysql-awesome
242
+ - dump-without-table-options
243
+ - index-removed-drop-column
244
+ - enable-migration-comments
245
+ - verbose
246
+ - debug
247
+ - version
248
+ - v
249
+ single_char_keys: *052_single_char_keys
@@ -0,0 +1,9 @@
1
+ require 'rails/railtie'
2
+
3
+ module RidgepoleRake
4
+ class Railtie < ::Rails::Railtie
5
+ rake_tasks do
6
+ load "tasks/ridgepole_rake.rake"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ module RidgepoleRake
2
+ class Tasks
3
+ class << self
4
+ def apply(dry_run = false)
5
+ run(:apply, dry_run: dry_run)
6
+ end
7
+
8
+ def merge(merge_file, dry_run = false)
9
+ run(:merge, merge_file: merge_file, dry_run: dry_run)
10
+ end
11
+
12
+ def export
13
+ run(:export)
14
+ end
15
+
16
+ def diff
17
+ run(:diff)
18
+ end
19
+
20
+ private
21
+
22
+ def run(action, options = {})
23
+ cmd = Command.new(action, RidgepoleRake.config, options)
24
+ cmd.execute
25
+
26
+ result(cmd.command)
27
+ end
28
+
29
+ def result(command)
30
+ puts '-----'
31
+ puts "Executed command => #{command}"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module RidgepoleRake
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,41 @@
1
+ require 'yaml'
2
+ require 'active_support/core_ext/hash'
3
+
4
+ require 'ridgepole'
5
+
6
+ require 'ridgepole_rake/configuration'
7
+ require 'ridgepole_rake/option'
8
+ require 'ridgepole_rake/command'
9
+ require 'ridgepole_rake/tasks'
10
+ require 'ridgepole_rake/version'
11
+
12
+ %w(
13
+ rails
14
+ bundler
15
+ brancher
16
+ ).each do |extension|
17
+ begin
18
+ require extension
19
+ require "ridgepole_rake/ext/#{extension}"
20
+ rescue LoadError
21
+ end
22
+ end
23
+
24
+ require 'ridgepole_rake/railtie' if defined?(Rails)
25
+
26
+ module RidgepoleRake
27
+ extend self
28
+
29
+ def configure
30
+ yield config
31
+ end
32
+
33
+ def config
34
+ @config ||= Configuration.new
35
+ end
36
+
37
+ def reset
38
+ @config = nil
39
+ config
40
+ end
41
+ end
@@ -0,0 +1,50 @@
1
+ Rake::Task.define_task :environment unless Rake::Task.task_defined?(:environment)
2
+
3
+ namespace :ridgepole do
4
+ desc '`ridgepole --apply`'
5
+ task apply: :environment do
6
+ RidgepoleRake::Tasks.apply
7
+ end
8
+
9
+ desc '`ridgepole --apply --dry-run`'
10
+ namespace :apply do
11
+ task 'dry-run' => :environment do
12
+ RidgepoleRake::Tasks.apply(true)
13
+ end
14
+ end
15
+
16
+ desc '`ridgepole --merge`'
17
+ task :merge, [:file] => :environment do |_t, args|
18
+ raise 'Require table schema file or execution file' if args.file.blank?
19
+
20
+ RidgepoleRake::Tasks.merge(args.file)
21
+ end
22
+
23
+ desc '`ridgepole --merge --dry-run`'
24
+ namespace :merge do
25
+ task 'dry-run', [:file] => :environment do |_t, args|
26
+ raise 'Require table schema file or execution file' if args.file.blank?
27
+
28
+ RidgepoleRake::Tasks.merge(args.file, true)
29
+ end
30
+ end
31
+
32
+ desc '`ridgepole --export`'
33
+ task export: :environment do
34
+ RidgepoleRake::Tasks.export
35
+ end
36
+
37
+ desc '`ridgepole --diff` current db and schema file'
38
+ task diff: :environment do
39
+ RidgepoleRake::Tasks.diff
40
+ end
41
+
42
+ if defined?(ActiveRecord)
43
+ desc '`rake db:drop`, `rake db:create` and `ridgepole --apply`'
44
+ task reset: :environment do
45
+ ActiveRecord::Tasks::DatabaseTasks.drop_current
46
+ ActiveRecord::Tasks::DatabaseTasks.create_current
47
+ RidgepoleRake::Tasks.apply
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ridgepole_rake/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ridgepole_rake'
8
+ spec.version = RidgepoleRake::VERSION
9
+ spec.authors = ['nalabjp']
10
+ spec.email = ['nalabjp@gmail.com']
11
+
12
+ spec.summary = %q{Rake Tasks for Ridgepole.}
13
+ spec.description = %q{Rake Tasks for Ridgepole.}
14
+ spec.homepage = 'https://github.com/nalabjp/ridgepole_rake'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'ridgepole', '>= 0.5', '< 0.7'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.10'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ridgepole_rake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nalabjp
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ridgepole
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.5'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.10'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.10'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ description: Rake Tasks for Ridgepole.
62
+ email:
63
+ - nalabjp@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - ".travis.yml"
70
+ - Gemfile
71
+ - Gemfile-minimum
72
+ - Gemfile-rails
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - bin/console
77
+ - bin/setup
78
+ - lib/ridgepole_rake.rb
79
+ - lib/ridgepole_rake/command.rb
80
+ - lib/ridgepole_rake/configuration.rb
81
+ - lib/ridgepole_rake/ext/brancher.rb
82
+ - lib/ridgepole_rake/ext/bundler.rb
83
+ - lib/ridgepole_rake/ext/rails.rb
84
+ - lib/ridgepole_rake/option.rb
85
+ - lib/ridgepole_rake/option_keys.yml
86
+ - lib/ridgepole_rake/railtie.rb
87
+ - lib/ridgepole_rake/tasks.rb
88
+ - lib/ridgepole_rake/version.rb
89
+ - lib/tasks/ridgepole_rake.rake
90
+ - ridgepole_rake.gemspec
91
+ homepage: https://github.com/nalabjp/ridgepole_rake
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.5
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Rake Tasks for Ridgepole.
115
+ test_files: []
116
+ has_rdoc: