capistrano-mysqldump 1.1.2 → 2.0.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 +5 -5
- data/.travis.yml +17 -0
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +36 -31
- data/README.md +2 -6
- data/VERSION +1 -1
- data/capistrano-mysqldump.gemspec +6 -4
- data/lib/capistrano/dsl/mysqldump.rb +36 -0
- data/lib/capistrano/mysqldump.rb +5 -132
- data/lib/capistrano/tasks/mysqldump.rake +96 -0
- data/test/test_capistrano-mysqldump.rb +15 -12
- metadata +22 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a4dac8ba8a4797570e17b69860e660d50db64cc912cfac0bf167dcfc0db6c00e
|
|
4
|
+
data.tar.gz: 60057567797ed539e0b7016c22d34abe454ed2011111e1ebb8ebf9b48151a965
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62626182f607c82a9772085d41b59af0767d70c8b98011b5dd978b9243e200e503ba08ecb078bdfceea1163a35270844941517c47c12e67a2acbce9b549abb9a
|
|
7
|
+
data.tar.gz: f9cf7d5801a82dcce81afc9b334ab64b7c0ae3193df8f653f69a69e4dba874d28e5e9c9b46c75bf5fa68bb4f8497f33b44c9df320aa76b4c220a123e62a12325
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
2.0.0 - 2018-02-06
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
## features
|
|
5
|
+
[Upgraded to support Capistrano 3](https://github.com/alexfarrill/capistrano-mysqldump/pull/12)
|
|
6
|
+
|
|
1
7
|
1.1.2 - 2014-10-06
|
|
2
8
|
==================
|
|
3
9
|
|
|
@@ -11,4 +17,4 @@
|
|
|
11
17
|
## style & finesse
|
|
12
18
|
|
|
13
19
|
[fixed readme formatting](https://github.com/alexfarrill/capistrano-mysqldump/pull/5)
|
|
14
|
-
[setup test env](https://github.com/alexfarrill/capistrano-mysqldump/pull/7)
|
|
20
|
+
[setup test env](https://github.com/alexfarrill/capistrano-mysqldump/pull/7)
|
data/Gemfile.lock
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
capistrano-mysqldump (
|
|
5
|
-
capistrano (>=
|
|
4
|
+
capistrano-mysqldump (2.0.0)
|
|
5
|
+
capistrano (>= 3.0.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
activesupport (4.
|
|
11
|
-
i18n (~> 0.
|
|
12
|
-
minitest (~>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
capistrano (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
minitest (
|
|
26
|
-
|
|
27
|
-
net-scp (1.1.2)
|
|
28
|
-
net-ssh (>= 2.6.5)
|
|
29
|
-
net-sftp (2.1.2)
|
|
30
|
-
net-ssh (>= 2.6.5)
|
|
31
|
-
net-ssh (2.7.0)
|
|
32
|
-
net-ssh-gateway (1.2.0)
|
|
10
|
+
activesupport (4.2.10)
|
|
11
|
+
i18n (~> 0.7)
|
|
12
|
+
minitest (~> 5.1)
|
|
13
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
14
|
+
tzinfo (~> 1.1)
|
|
15
|
+
airbrussh (1.3.0)
|
|
16
|
+
sshkit (>= 1.6.1, != 1.7.0)
|
|
17
|
+
capistrano (3.10.1)
|
|
18
|
+
airbrussh (>= 1.0.0)
|
|
19
|
+
i18n
|
|
20
|
+
rake (>= 10.0.0)
|
|
21
|
+
sshkit (>= 1.9.0)
|
|
22
|
+
concurrent-ruby (1.0.5)
|
|
23
|
+
i18n (0.9.1)
|
|
24
|
+
concurrent-ruby (~> 1.0)
|
|
25
|
+
minitest (5.10.3)
|
|
26
|
+
net-scp (1.2.1)
|
|
33
27
|
net-ssh (>= 2.6.5)
|
|
34
|
-
|
|
28
|
+
net-ssh (4.2.0)
|
|
29
|
+
power_assert (1.1.1)
|
|
30
|
+
rake (12.3.0)
|
|
35
31
|
shoulda (3.5.0)
|
|
36
32
|
shoulda-context (~> 1.0, >= 1.0.1)
|
|
37
33
|
shoulda-matchers (>= 1.4.1, < 3.0)
|
|
38
|
-
shoulda-context (1.
|
|
39
|
-
shoulda-matchers (2.
|
|
34
|
+
shoulda-context (1.2.2)
|
|
35
|
+
shoulda-matchers (2.8.0)
|
|
40
36
|
activesupport (>= 3.0.0)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
sshkit (1.16.0)
|
|
38
|
+
net-scp (>= 1.1.2)
|
|
39
|
+
net-ssh (>= 2.8.0)
|
|
40
|
+
test-unit (3.2.6)
|
|
41
|
+
power_assert
|
|
42
|
+
thread_safe (0.3.6)
|
|
43
|
+
tzinfo (1.2.4)
|
|
44
|
+
thread_safe (~> 0.1)
|
|
44
45
|
|
|
45
46
|
PLATFORMS
|
|
46
47
|
ruby
|
|
@@ -50,3 +51,7 @@ DEPENDENCIES
|
|
|
50
51
|
capistrano-mysqldump!
|
|
51
52
|
rake
|
|
52
53
|
shoulda
|
|
54
|
+
test-unit
|
|
55
|
+
|
|
56
|
+
BUNDLED WITH
|
|
57
|
+
1.16.1
|
data/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Capistrano extension to run mysqldump remotely, download, and import into your l
|
|
|
4
4
|
|
|
5
5
|
WARNING: This will blow away your development database (duh)
|
|
6
6
|
|
|
7
|
+
## Note: For capistrano v2, see version 1
|
|
8
|
+
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
11
|
```ruby
|
|
@@ -20,12 +22,6 @@ require 'capistrano/mysqldump'
|
|
|
20
22
|
|
|
21
23
|
* Run:
|
|
22
24
|
|
|
23
|
-
```ruby
|
|
24
|
-
cap mysqldump
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Or if you're using `capistrano-ext/multistage`, do
|
|
28
|
-
|
|
29
25
|
```ruby
|
|
30
26
|
cap production mysqldump
|
|
31
27
|
```
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2.0.0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
Gem::Specification.new do |s|
|
|
3
3
|
s.name = "capistrano-mysqldump"
|
|
4
|
-
s.version = "
|
|
4
|
+
s.version = "2.0.0"
|
|
5
5
|
|
|
6
6
|
s.authors = ["Alex Farrill"]
|
|
7
7
|
s.date = "2013-07-03"
|
|
@@ -21,12 +21,14 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
s.homepage = "http://github.com/alexfarrill/capistrano-mysqldump"
|
|
22
22
|
s.licenses = ["MIT"]
|
|
23
23
|
s.require_paths = ["lib"]
|
|
24
|
-
s.rubygems_version = "1.8.25"
|
|
25
24
|
s.summary = "Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database"
|
|
26
25
|
|
|
27
26
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
s.required_ruby_version = ">= 2.0"
|
|
29
|
+
s.add_runtime_dependency(%q<capistrano>, [">= 3.0.0"])
|
|
29
30
|
s.add_development_dependency "bundler", "~> 1.3"
|
|
30
31
|
s.add_development_dependency "rake"
|
|
31
32
|
s.add_development_dependency "shoulda"
|
|
32
|
-
|
|
33
|
+
s.add_development_dependency "test-unit"
|
|
34
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Capistrano
|
|
2
|
+
module DSL
|
|
3
|
+
module Mysqldump
|
|
4
|
+
|
|
5
|
+
# converts a hash of options into a string.
|
|
6
|
+
# drops falsey-valued keys.
|
|
7
|
+
#
|
|
8
|
+
# `{u: 'foo', 'single-transaction' => true, ignore-tables' => 'bar', p: nil}`
|
|
9
|
+
# => '-ufoo --ignore-tables=bar --single-transaction
|
|
10
|
+
#
|
|
11
|
+
def mysqldump_options_string(options = nil)
|
|
12
|
+
options
|
|
13
|
+
options.map do |k,v|
|
|
14
|
+
next unless v
|
|
15
|
+
used_value = v == true ? nil : v
|
|
16
|
+
used_prefix, used_join = if k.length == 1
|
|
17
|
+
["-", '']
|
|
18
|
+
else
|
|
19
|
+
["--", '=']
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
"#{used_prefix}#{[k, used_value].compact.join used_join}"
|
|
23
|
+
end.compact.join ' '
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# returns credential options for a given username and password
|
|
27
|
+
# when given an empty or nil password, does not include p: in the returned hash
|
|
28
|
+
def mysqldump_credential_options(username, password)
|
|
29
|
+
{}.tap do |opts|
|
|
30
|
+
opts[:u] = username
|
|
31
|
+
opts[:p] = password if password == true || password && !password.empty?
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/capistrano/mysqldump.rb
CHANGED
|
@@ -1,135 +1,8 @@
|
|
|
1
1
|
require 'capistrano'
|
|
2
|
+
require "capistrano/dsl/mysqldump"
|
|
3
|
+
require 'sshkit'
|
|
4
|
+
self.extend Capistrano::DSL::Mysqldump
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
module Mysqldump
|
|
6
|
+
SSHKit::Backend::Netssh.send(:include, Capistrano::DSL::Mysqldump)
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
# drops falsey-valued keys.
|
|
8
|
-
#
|
|
9
|
-
# `{u: 'foo', 'single-transaction' => true, ignore-tables' => 'bar', p: nil}`
|
|
10
|
-
# => '-ufoo --ignore-tables=bar --single-transaction
|
|
11
|
-
#
|
|
12
|
-
def self.options_string(options = nil)
|
|
13
|
-
options
|
|
14
|
-
options.map do |k,v|
|
|
15
|
-
next unless v
|
|
16
|
-
used_value = v == true ? nil : v
|
|
17
|
-
used_prefix, used_join = if k.length == 1
|
|
18
|
-
["-", '']
|
|
19
|
-
else
|
|
20
|
-
["--", '=']
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
"#{used_prefix}#{[k, used_value].compact.join used_join}"
|
|
24
|
-
end.compact.join ' '
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# returns credential options for a given username and password
|
|
28
|
-
# when given an empty or nil password, does not include p: in the returned hash
|
|
29
|
-
def self.credential_options(username, password)
|
|
30
|
-
{}.tap do |opts|
|
|
31
|
-
opts[:u] = username
|
|
32
|
-
opts[:p] = password if password == true || password && !password.empty?
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def self.load_into(configuration)
|
|
37
|
-
configuration.load do
|
|
38
|
-
namespace :mysqldump do
|
|
39
|
-
task :default, :roles => :db do
|
|
40
|
-
dump
|
|
41
|
-
import
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
task :setup do
|
|
45
|
-
@mysqldump_config = fetch :mysqldump_config, YAML.load_file("config/database.yml")[rails_env.to_s]
|
|
46
|
-
unless @mysqldump_config
|
|
47
|
-
raise "Cannot load database config for #{rails_env} environment"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
host = @mysqldump_config["host"]
|
|
51
|
-
|
|
52
|
-
# overwrite these if necessary
|
|
53
|
-
@mysqldump_bin = fetch :mysqldump_bin, "`which mysqldump`"
|
|
54
|
-
mysqldump_remote_tmp_dir = fetch :mysqldump_remote_tmp_dir, "/tmp"
|
|
55
|
-
mysqldump_local_tmp_dir = fetch :mysqldump_local_tmp_dir, "/tmp"
|
|
56
|
-
@mysqldump_location = fetch :mysqldump_location, host && !host.empty? && host != "localhost" ? :remote : :local
|
|
57
|
-
@mysqldump_options = fetch :mysqldump_options, {}
|
|
58
|
-
|
|
59
|
-
# for convenience
|
|
60
|
-
mysqldump_filename = "%s-%s.sql" % [application, Time.now.to_i]
|
|
61
|
-
mysqldump_filename_gz = "%s.gz" % mysqldump_filename
|
|
62
|
-
@mysqldump_remote_filename = File.join( mysqldump_remote_tmp_dir, mysqldump_filename_gz )
|
|
63
|
-
@mysqldump_local_filename = File.join( mysqldump_local_tmp_dir, mysqldump_filename )
|
|
64
|
-
@mysqldump_local_filename_gz = File.join( mysqldump_local_tmp_dir, mysqldump_filename_gz )
|
|
65
|
-
|
|
66
|
-
@mysqldump_ignore_tables = fetch :mysqldump_ignore_tables, []
|
|
67
|
-
@mysqldump_tables = fetch :mysqldump_tables, []
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def default_options
|
|
71
|
-
setup
|
|
72
|
-
username, password, host = @mysqldump_config.values_at *%w( username password host )
|
|
73
|
-
{
|
|
74
|
-
:h => host,
|
|
75
|
-
:quick => true,
|
|
76
|
-
"single-transaction" => true,
|
|
77
|
-
}.tap do |options|
|
|
78
|
-
|
|
79
|
-
password = true if @mysqldump_location == :remote
|
|
80
|
-
|
|
81
|
-
if @mysqldump_ignore_tables.any?
|
|
82
|
-
options['ignore-tables'] = [@mysqldump_ignore_tables].flatten.join ' '
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
options.merge! Mysqldump.credential_options(username, password)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
task :dump, :roles => :db do
|
|
92
|
-
options = default_options
|
|
93
|
-
options.merge! @mysqldump_options
|
|
94
|
-
password, database = @mysqldump_config.values_at *%w( password database )
|
|
95
|
-
mysqldump_cmd = "#{@mysqldump_bin} #{Mysqldump.options_string(options)} #{database} #{[@mysqldump_tables].flatten.compact.join ' '}"
|
|
96
|
-
|
|
97
|
-
case @mysqldump_location
|
|
98
|
-
when :remote
|
|
99
|
-
mysqldump_cmd += " | gzip > %s" % @mysqldump_remote_filename
|
|
100
|
-
|
|
101
|
-
run mysqldump_cmd do |ch, stream, out|
|
|
102
|
-
ch.send_data "#{password}\n" if out =~ /^Enter password:/
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
download @mysqldump_remote_filename, @mysqldump_local_filename_gz, :via => :scp
|
|
106
|
-
run "rm #{@mysqldump_remote_filename}"
|
|
107
|
-
|
|
108
|
-
`gunzip #{@mysqldump_local_filename_gz}`
|
|
109
|
-
when :local
|
|
110
|
-
mysqldump_cmd += " > %s" % @mysqldump_local_filename
|
|
111
|
-
|
|
112
|
-
`#{mysqldump_cmd}`
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
task :import do
|
|
117
|
-
config = YAML.load_file("config/database.yml")["development"]
|
|
118
|
-
username, password, database = config.values_at *%w( username password database )
|
|
119
|
-
|
|
120
|
-
credentials_string = Mysqldump.options_string Mysqldump.credential_options(username, password)
|
|
121
|
-
|
|
122
|
-
mysql_cmd = "mysql #{credentials_string}"
|
|
123
|
-
`#{mysql_cmd} -e "drop database #{database}; create database #{database}"`
|
|
124
|
-
`#{mysql_cmd} #{database} < #{@mysqldump_local_filename}`
|
|
125
|
-
`rm #{@mysqldump_local_filename}`
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
if Capistrano::Configuration.instance
|
|
134
|
-
Capistrano::Mysqldump.load_into(Capistrano::Configuration.instance)
|
|
135
|
-
end
|
|
8
|
+
load File.expand_path("../tasks/mysqldump.rake", __FILE__)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
namespace :mysqldump do
|
|
2
|
+
task :default do
|
|
3
|
+
on roles(:db) do
|
|
4
|
+
dump
|
|
5
|
+
import
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def setup_variables
|
|
10
|
+
@mysqldump_config = fetch :mysqldump_config, YAML.load_file("config/database.yml")[fetch(:rails_env).to_s]
|
|
11
|
+
unless @mysqldump_config
|
|
12
|
+
raise "Cannot load database config for #{fetch(:rails_env)} environment"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
host = @mysqldump_config["host"]
|
|
16
|
+
|
|
17
|
+
# overwrite these if necessary
|
|
18
|
+
@mysqldump_bin = fetch :mysqldump_bin, "`which mysqldump`"
|
|
19
|
+
mysqldump_remote_tmp_dir = fetch :mysqldump_remote_tmp_dir, "/tmp"
|
|
20
|
+
mysqldump_local_tmp_dir = fetch :mysqldump_local_tmp_dir, "/tmp"
|
|
21
|
+
@mysqldump_location = fetch :mysqldump_location, host && !host.empty? && host != "localhost" ? :remote : :local
|
|
22
|
+
@mysqldump_options = fetch :mysqldump_options, {}
|
|
23
|
+
|
|
24
|
+
# for convenience
|
|
25
|
+
mysqldump_filename = "%s-%s.sql" % [fetch(:application), Time.now.to_i]
|
|
26
|
+
mysqldump_filename_gz = "%s.gz" % mysqldump_filename
|
|
27
|
+
@mysqldump_remote_filename = File.join( mysqldump_remote_tmp_dir, mysqldump_filename_gz )
|
|
28
|
+
@mysqldump_local_filename = File.join( mysqldump_local_tmp_dir, mysqldump_filename )
|
|
29
|
+
@mysqldump_local_filename_gz = File.join( mysqldump_local_tmp_dir, mysqldump_filename_gz )
|
|
30
|
+
|
|
31
|
+
@mysqldump_ignore_tables = fetch :mysqldump_ignore_tables, []
|
|
32
|
+
@mysqldump_tables = fetch :mysqldump_tables, []
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def default_options
|
|
36
|
+
setup_variables
|
|
37
|
+
username, password, host = @mysqldump_config.values_at *%w( username password host )
|
|
38
|
+
{
|
|
39
|
+
:h => host,
|
|
40
|
+
:quick => true,
|
|
41
|
+
"single-transaction" => true,
|
|
42
|
+
}.tap do |options|
|
|
43
|
+
|
|
44
|
+
password = true if @mysqldump_location == :remote
|
|
45
|
+
|
|
46
|
+
if @mysqldump_ignore_tables.any?
|
|
47
|
+
options['ignore-tables'] = [@mysqldump_ignore_tables].flatten.join ' '
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
options.merge! mysqldump_credential_options(username, password)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
task :dump do
|
|
55
|
+
options = default_options
|
|
56
|
+
options.merge! @mysqldump_options
|
|
57
|
+
password, database = @mysqldump_config.values_at *%w( password database )
|
|
58
|
+
mysqldump_cmd = "#{@mysqldump_bin} #{mysqldump_options_string(options)} #{database} #{[@mysqldump_tables].flatten.compact.join ' '}"
|
|
59
|
+
|
|
60
|
+
case @mysqldump_location
|
|
61
|
+
when :remote
|
|
62
|
+
# TODO: use `set` instead of binding to local variables
|
|
63
|
+
remote_filename = @mysqldump_remote_filename
|
|
64
|
+
local_filename_gz = @mysqldump_local_filename_gz
|
|
65
|
+
mysqldump_cmd += " | gzip > %s" % @mysqldump_remote_filename
|
|
66
|
+
|
|
67
|
+
on roles(:db) do
|
|
68
|
+
execute(
|
|
69
|
+
mysqldump_cmd,
|
|
70
|
+
interaction_handler: {
|
|
71
|
+
/^Enter password:/ => "#{password}\n"
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
download! remote_filename, local_filename_gz
|
|
75
|
+
execute "rm #{remote_filename}"
|
|
76
|
+
end
|
|
77
|
+
`gunzip #{@mysqldump_local_filename_gz}`
|
|
78
|
+
when :local
|
|
79
|
+
mysqldump_cmd += " > %s" % @mysqldump_local_filename
|
|
80
|
+
|
|
81
|
+
`#{mysqldump_cmd}`
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
task :import do
|
|
86
|
+
config = YAML.load_file("config/database.yml")["development"]
|
|
87
|
+
username, password, database = config.values_at *%w( username password database )
|
|
88
|
+
|
|
89
|
+
credentials_string = mysqldump_options_string mysqldump_credential_options(username, password)
|
|
90
|
+
|
|
91
|
+
mysql_cmd = "mysql #{credentials_string}"
|
|
92
|
+
`#{mysql_cmd} -e "drop database #{database}; create database #{database}"`
|
|
93
|
+
`#{mysql_cmd} #{database} < #{@mysqldump_local_filename}`
|
|
94
|
+
`rm #{@mysqldump_local_filename}`
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -2,39 +2,42 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class TestCapistranoMysqldump < Test::Unit::TestCase
|
|
5
|
-
|
|
5
|
+
class Dummy
|
|
6
|
+
include Capistrano::DSL::Mysqldump
|
|
7
|
+
end
|
|
8
|
+
mysqldump = Dummy.new
|
|
6
9
|
|
|
7
|
-
context '.
|
|
10
|
+
context '.mysqldump_options_string' do
|
|
8
11
|
should "not include falesy values" do
|
|
9
|
-
assert_equal '', mysqldump.
|
|
12
|
+
assert_equal '', mysqldump.mysqldump_options_string({:a => nil, :b => false})
|
|
10
13
|
end
|
|
11
14
|
|
|
12
15
|
should 'use "--" prefix and "=" join for length > 1 keys' do
|
|
13
|
-
assert_equal '--multi_char_key=foo', mysqldump.
|
|
16
|
+
assert_equal '--multi_char_key=foo', mysqldump.mysqldump_options_string(:multi_char_key => 'foo')
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
should 'use "-" prefix and "" join for length == 1 keys' do
|
|
17
|
-
assert_equal '-ofoo', mysqldump.
|
|
20
|
+
assert_equal '-ofoo', mysqldump.mysqldump_options_string({:o => 'foo'})
|
|
18
21
|
end
|
|
19
|
-
|
|
22
|
+
|
|
20
23
|
should 'not include variable for value = true' do
|
|
21
|
-
assert_equal '-o --multi_char_key', mysqldump.
|
|
24
|
+
assert_equal '-o --multi_char_key', mysqldump.mysqldump_options_string(:o => true, :multi_char_key => true)
|
|
22
25
|
end
|
|
23
26
|
end
|
|
24
27
|
|
|
25
|
-
context '.
|
|
28
|
+
context '.mysqldump_credential_options(username, password)' do
|
|
26
29
|
should 'includes password if it exists' do
|
|
27
30
|
assert_equal(
|
|
28
|
-
{:u => 'foo', :p => 'bar'},
|
|
29
|
-
mysqldump.
|
|
31
|
+
{:u => 'foo', :p => 'bar'},
|
|
32
|
+
mysqldump.mysqldump_credential_options('foo', 'bar')
|
|
30
33
|
)
|
|
31
34
|
end
|
|
32
35
|
|
|
33
36
|
should 'does not include password if falsey or empty' do
|
|
34
37
|
assert_equal(
|
|
35
38
|
{:u => 'foo'},
|
|
36
|
-
mysqldump.
|
|
37
|
-
mysqldump.
|
|
39
|
+
mysqldump.mysqldump_credential_options('foo', ''),
|
|
40
|
+
mysqldump.mysqldump_credential_options('foo', false)
|
|
38
41
|
)
|
|
39
42
|
end
|
|
40
43
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capistrano-mysqldump
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Farrill
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 3.0.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 3.0.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: test-unit
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
69
83
|
description: ''
|
|
70
84
|
email: alex.farrill@gmail.com
|
|
71
85
|
executables: []
|
|
@@ -75,6 +89,7 @@ extra_rdoc_files:
|
|
|
75
89
|
- README.md
|
|
76
90
|
files:
|
|
77
91
|
- ".gitignore"
|
|
92
|
+
- ".travis.yml"
|
|
78
93
|
- CHANGELOG.md
|
|
79
94
|
- Gemfile
|
|
80
95
|
- Gemfile.lock
|
|
@@ -83,7 +98,9 @@ files:
|
|
|
83
98
|
- Rakefile
|
|
84
99
|
- VERSION
|
|
85
100
|
- capistrano-mysqldump.gemspec
|
|
101
|
+
- lib/capistrano/dsl/mysqldump.rb
|
|
86
102
|
- lib/capistrano/mysqldump.rb
|
|
103
|
+
- lib/capistrano/tasks/mysqldump.rake
|
|
87
104
|
- test/helper.rb
|
|
88
105
|
- test/test_capistrano-mysqldump.rb
|
|
89
106
|
homepage: http://github.com/alexfarrill/capistrano-mysqldump
|
|
@@ -98,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
98
115
|
requirements:
|
|
99
116
|
- - ">="
|
|
100
117
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '0'
|
|
118
|
+
version: '2.0'
|
|
102
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
120
|
requirements:
|
|
104
121
|
- - ">="
|
|
@@ -106,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
106
123
|
version: '0'
|
|
107
124
|
requirements: []
|
|
108
125
|
rubyforge_project:
|
|
109
|
-
rubygems_version: 2.
|
|
126
|
+
rubygems_version: 2.7.3
|
|
110
127
|
signing_key:
|
|
111
128
|
specification_version: 4
|
|
112
129
|
summary: Capistrano extension to run mysqldump remotely, download, and import into
|