capistrano-mysqldump 1.0.8 → 1.01

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Alex Farrill
1
+ Copyright (c) 2006 Jamis Buck
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Manifest ADDED
@@ -0,0 +1,5 @@
1
+ MIT-LICENSE
2
+ Manifest
3
+ README
4
+ Rakefile
5
+ lib/capistrano/mysqldump.rb
data/README CHANGED
@@ -1,57 +1,24 @@
1
- = capistrano-mysqldump
1
+ = Capistrano Mysqldump
2
2
 
3
3
  Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database.
4
4
 
5
- WARNING: This will blow away your development database (duh)
5
+ To install: gem install capistrano-mysqldump
6
6
 
7
- == Installation
7
+ To use:
8
8
 
9
- gem install capistrano-mysqldump
10
-
11
- == Usage
12
-
13
- * In your deploy file:
9
+ 1) In your deploy file:
14
10
 
15
11
  require 'capistrano/mysqldump'
16
12
 
17
- * Run:
13
+ 2) Run:
18
14
 
19
15
  cap mysqldump
20
16
 
21
- Or if you're using capistrano-ext/multistage, do
22
-
23
- cap production mysqldump
24
-
25
- Or whatever environment you want to take the mysqldump from
26
-
27
- == Configuration
17
+ Default configuration -- override these in deploy.rb if necessary:
28
18
 
29
- Override these defaults in deploy.rb if necessary
30
-
31
- * Location of the mysqldump binary
32
19
  set :mysqldump_bin, "/usr/local/mysql/bin/mysqldump"
33
-
34
- * Where on the remote machine to dump the sql dump file
35
20
  set :mysqldump_remote_tmp_dir, "/tmp"
36
-
37
- * Where on the local machine to download the sql dump file from the remote machine
38
21
  set :mysqldump_local_tmp_dir, "/tmp"
39
22
 
40
- * Where to run the mysqldump command. If set to :local, mysqldump will use the -h parameter and run the dump locally. The default is set to :local if a host is specified, otherwise it is set to :remote
41
- set :mysqldump_location, :local
42
-
43
- == Contributing to capistrano-mysqldump
44
-
45
- * Contributions welcome
46
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
47
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
48
- * Fork the project
49
- * Start a feature/bugfix branch
50
- * Commit and push until you are happy with your contribution
51
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
52
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
53
23
 
54
- == Copyright
55
24
 
56
- Copyright (c) 2011 Alex Farrill. See LICENSE.txt for
57
- further details.
data/Rakefile CHANGED
@@ -1,53 +1,7 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
1
+ require 'echoe'
2
+ Echoe.new('capistrano-mysqldump', '1.01') do |p|
3
+ p.author = "Alexander Farrill"
4
+ p.email = "alex.farrill@gmail.com"
5
+ p.summary = "Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database"
6
+ p.dependencies = ["capistrano >=1.0.0"]
11
7
  end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "capistrano-mysqldump"
18
- gem.homepage = "http://github.com/alexfarrill/capistrano-mysqldump"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database}
21
- gem.description = %Q{}
22
- gem.email = "alex.farrill@gmail.com"
23
- gem.authors = ["Alex Farrill"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |test|
30
- test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
33
- end
34
-
35
- # require 'rcov/rcovtask'
36
- # Rcov::RcovTask.new do |test|
37
- # test.libs << 'test'
38
- # test.pattern = 'test/**/test_*.rb'
39
- # test.verbose = true
40
- # test.rcov_opts << '--exclude "gems/*"'
41
- # end
42
-
43
- task :default => :test
44
-
45
- # require 'rake/rdoctask'
46
- # Rake::RDocTask.new do |rdoc|
47
- # version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
- #
49
- # rdoc.rdoc_dir = 'rdoc'
50
- # rdoc.title = "capistrano-mysqldump #{version}"
51
- # rdoc.rdoc_files.include('README*')
52
- # rdoc.rdoc_files.include('lib/**/*.rb')
53
- # end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{capistrano-mysqldump}
5
+ s.version = "1.01"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Alexander Farrill"]
9
+ s.date = %q{2011-01-09}
10
+ s.description = %q{Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database}
11
+ s.email = %q{alex.farrill@gmail.com}
12
+ s.extra_rdoc_files = ["README", "lib/capistrano/mysqldump.rb"]
13
+ s.files = ["MIT-LICENSE", "Manifest", "README", "Rakefile", "lib/capistrano/mysqldump.rb", "capistrano-mysqldump.gemspec"]
14
+ s.homepage = %q{}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capistrano-mysqldump", "--main", "README"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{capistrano-mysqldump}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<capistrano>, [">= 1.0.0"])
27
+ else
28
+ s.add_dependency(%q<capistrano>, [">= 1.0.0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<capistrano>, [">= 1.0.0"])
32
+ end
33
+ end
@@ -1,66 +1,42 @@
1
1
  Capistrano::Configuration.instance.load do
2
2
  namespace :mysqldump do
3
3
  task :default, :roles => :db do
4
- dump
5
- import
6
- end
7
-
8
- task :setup do
9
- set :mysqldump_config, YAML.load_file("config/database.yml")[rails_env.to_s]
10
- host = mysqldump_config["host"]
11
-
12
4
  # overwrite these if necessary
13
5
  set :mysqldump_bin, "/usr/local/mysql/bin/mysqldump" unless exists?(:mysqldump_bin)
14
6
  set :mysqldump_remote_tmp_dir, "/tmp" unless exists?(:mysqldump_remote_tmp_dir)
15
7
  set :mysqldump_local_tmp_dir, "/tmp" unless exists?(:mysqldump_local_tmp_dir)
16
- set :mysqldump_location, host && host.any? && host != "localhost" ? :local : :remote unless exists?(:mysqldump_location)
17
-
18
- # for convenience
19
- set :mysqldump_filename, "%s-%s.sql" % [application, Time.now.to_i]
20
- set :mysqldump_filename_gz, "%s.gz" % mysqldump_filename
8
+
9
+ set :mysqldump_filename_gz, "%s-%s.sql.gz" % [application, Time.now.to_i]
21
10
  set :mysqldump_remote_filename, File.join( mysqldump_remote_tmp_dir, mysqldump_filename_gz )
22
- set :mysqldump_local_filename, File.join( mysqldump_local_tmp_dir, mysqldump_filename )
23
- set :mysqldump_local_filename_gz, File.join( mysqldump_local_tmp_dir, mysqldump_filename_gz )
11
+ set :mysqldump_local_filename, File.join( mysqldump_local_tmp_dir, mysqldump_filename_gz )
12
+
13
+ dump
14
+ import
24
15
  end
25
-
16
+
26
17
  task :dump, :roles => :db do
27
- setup
28
- username, password, database, host = mysqldump_config.values_at *%w( username password database host )
29
-
30
- mysqldump_cmd = "%s --quick --single-transaction" % mysqldump_bin
31
- mysqldump_cmd += " -h #{host}" if host && host.any?
32
-
33
- case mysqldump_location
34
- when :remote
35
- mysqldump_cmd += " -u %s -p %s" % [ username, database ]
36
- mysqldump_cmd += " | gzip > %s" % mysqldump_remote_filename
37
-
38
- run mysqldump_cmd do |ch, stream, out|
39
- ch.send_data "#{password}\n" if out =~ /^Enter password:/
40
- end
41
-
42
- download mysqldump_remote_filename, mysqldump_local_filename_gz, :via => :scp
43
- run "rm #{mysqldump_remote_filename}"
44
-
45
- `gunzip #{mysqldump_local_filename_gz}`
46
- when :local
47
- mysqldump_cmd += " -u %s" % username
48
- mysqldump_cmd += " -p#{password}" if password && password.any?
49
- mysqldump_cmd += " %s > %s" % [ database, mysqldump_local_filename]
50
-
51
- `#{mysqldump_cmd}`
18
+ config = YAML.load_file("config/database.yml")[rails_env.to_s]
19
+ username, password, database = config.values_at *%w( username password database )
20
+
21
+ mysqldump_cmd = "%s -u %s -p %s | gzip > %s" % [mysqldump_bin, username, database, mysqldump_remote_filename]
22
+
23
+ run mysqldump_cmd do |ch, stream, out|
24
+ ch.send_data "#{password}\n" if out =~ /^Enter password:/
52
25
  end
26
+
27
+ download mysqldump_remote_filename, mysqldump_local_filename, :via => :scp
28
+ `gunzip #{mysqldump_local_filename}`
53
29
  end
54
-
30
+
55
31
  task :import do
56
32
  config = YAML.load_file("config/database.yml")["development"]
57
33
  username, password, database = config.values_at *%w( username password database )
58
-
59
- mysql_cmd = "mysql -u#{username}"
60
- mysql_cmd += " -p#{password}" if password && password.any?
61
- `#{mysql_cmd} -e "drop database #{database}; create database #{database}"`
62
- `#{mysql_cmd} #{database} < #{mysqldump_local_filename}`
63
- `rm #{mysqldump_local_filename}`
34
+
35
+ mysqldump_filename = mysqldump_local_filename.gsub(/\.gz$/, '')
36
+
37
+ `mysql -u#{username} -p#{password} -e "drop database #{database}; create database #{database}"`
38
+ `mysql -u#{username} -p#{password} #{database} < #{mysqldump_filename}`
39
+ `rm #{mysqldump_filename}`
64
40
  end
65
41
  end
66
42
  end
metadata CHANGED
@@ -1,24 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-mysqldump
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease:
4
+ hash: 13
5
+ prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 0
9
- - 8
10
- version: 1.0.8
8
+ - 1
9
+ version: "1.01"
11
10
  platform: ruby
12
11
  authors:
13
- - Alex Farrill
12
+ - Alexander Farrill
14
13
  autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-11-30 00:00:00 Z
17
+ date: 2011-01-09 00:00:00 -07:00
18
+ default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- type: :runtime
21
+ name: capistrano
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -31,65 +31,36 @@ dependencies:
31
31
  - 0
32
32
  - 0
33
33
  version: 1.0.0
34
+ type: :runtime
34
35
  version_requirements: *id001
35
- name: capistrano
36
- - !ruby/object:Gem::Dependency
37
- type: :development
38
- prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 23
45
- segments:
46
- - 1
47
- - 0
48
- - 0
49
- version: 1.0.0
50
- version_requirements: *id002
51
- name: bundler
52
- - !ruby/object:Gem::Dependency
53
- type: :development
54
- prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 7
61
- segments:
62
- - 1
63
- - 6
64
- - 4
65
- version: 1.6.4
66
- version_requirements: *id003
67
- name: jeweler
68
- description: ""
36
+ description: Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database
69
37
  email: alex.farrill@gmail.com
70
38
  executables: []
71
39
 
72
40
  extensions: []
73
41
 
74
42
  extra_rdoc_files:
75
- - LICENSE.txt
76
43
  - README
44
+ - lib/capistrano/mysqldump.rb
77
45
  files:
78
- - Gemfile
79
- - Gemfile.lock
80
- - LICENSE.txt
46
+ - MIT-LICENSE
47
+ - Manifest
81
48
  - README
82
49
  - Rakefile
83
- - VERSION
84
50
  - lib/capistrano/mysqldump.rb
85
- - test/helper.rb
86
- - test/test_capistrano-mysqldump.rb
87
- homepage: http://github.com/alexfarrill/capistrano-mysqldump
88
- licenses:
89
- - MIT
90
- post_install_message:
91
- rdoc_options: []
51
+ - capistrano-mysqldump.gemspec
52
+ has_rdoc: true
53
+ homepage: ""
54
+ licenses: []
92
55
 
56
+ post_install_message:
57
+ rdoc_options:
58
+ - --line-numbers
59
+ - --inline-source
60
+ - --title
61
+ - Capistrano-mysqldump
62
+ - --main
63
+ - README
93
64
  require_paths:
94
65
  - lib
95
66
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -106,14 +77,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
77
  requirements:
107
78
  - - ">="
108
79
  - !ruby/object:Gem::Version
109
- hash: 3
80
+ hash: 11
110
81
  segments:
111
- - 0
112
- version: "0"
82
+ - 1
83
+ - 2
84
+ version: "1.2"
113
85
  requirements: []
114
86
 
115
- rubyforge_project:
116
- rubygems_version: 1.8.11
87
+ rubyforge_project: capistrano-mysqldump
88
+ rubygems_version: 1.3.7
117
89
  signing_key:
118
90
  specification_version: 3
119
91
  summary: Capistrano extension to run mysqldump remotely, download, and import into your local Rails development database
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- gem "capistrano", ">=1.0.0"
7
-
8
- # Add dependencies to develop your gem here.
9
- # Include everything needed to run rake, tests, features, etc.
10
- group :development do
11
- gem "bundler", "~> 1.0.0"
12
- gem "jeweler", "~> 1.6.4"
13
- end
data/Gemfile.lock DELETED
@@ -1,31 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- capistrano (2.8.0)
5
- highline
6
- net-scp (>= 1.0.0)
7
- net-sftp (>= 2.0.0)
8
- net-ssh (>= 2.0.14)
9
- net-ssh-gateway (>= 1.1.0)
10
- git (1.2.5)
11
- highline (1.6.2)
12
- jeweler (1.6.4)
13
- bundler (~> 1.0)
14
- git (>= 1.2.5)
15
- rake
16
- net-scp (1.0.4)
17
- net-ssh (>= 1.99.1)
18
- net-sftp (2.0.5)
19
- net-ssh (>= 2.0.9)
20
- net-ssh (2.2.1)
21
- net-ssh-gateway (1.1.0)
22
- net-ssh (>= 1.99.1)
23
- rake (0.9.2.2)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- bundler (~> 1.0.0)
30
- capistrano (>= 1.0.0)
31
- jeweler (~> 1.6.4)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.8
data/test/helper.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'capistrano-mysqldump'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestCapistranoMysqldump < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end