capistrano-mysql_tables 0.0.1

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
+ SHA256:
3
+ metadata.gz: '096d81e596cd1a69b983bc28c83cf3c9e5e1f2fdcc7357ed85df14cd24d98ddf'
4
+ data.tar.gz: 046b9cd8f59f498df97ae12ee045b9bb96a326595173e40ffc02b65111d32b1b
5
+ SHA512:
6
+ metadata.gz: 36a5b35904cae0fd125d45abaec75787813260f5e8c8109c12f206734c5275827c71dd0c8ae0eeffceacfc5d411284e8623f8917f2cd5763e898b1cd57d0f49f
7
+ data.tar.gz: 87358266bd3a59bd6a59968da374b78883244969c26498a9a89b523553735b549e3640bb3ef9bd53fa10e693fb7e161019c38948911ef064b3fb90b745531b97
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.5
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-mysql_tables.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-mysql_tables (0.0.1)
5
+ capistrano
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ airbrussh (1.4.1)
11
+ sshkit (>= 1.6.1, != 1.7.0)
12
+ capistrano (3.17.1)
13
+ airbrussh (>= 1.0.0)
14
+ i18n
15
+ rake (>= 10.0.0)
16
+ sshkit (>= 1.9.0)
17
+ concurrent-ruby (1.1.10)
18
+ i18n (1.12.0)
19
+ concurrent-ruby (~> 1.0)
20
+ minitest (5.17.0)
21
+ net-scp (4.0.0)
22
+ net-ssh (>= 2.6.5, < 8.0.0)
23
+ net-ssh (7.0.1)
24
+ rake (12.3.3)
25
+ sshkit (1.21.3)
26
+ net-scp (>= 1.1.2)
27
+ net-ssh (>= 2.8.0)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ capistrano-mysql_tables!
34
+ minitest (~> 5.0)
35
+ rake (~> 12.0)
36
+
37
+ BUNDLED WITH
38
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Jason Floyd
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,40 @@
1
+ # Capistrano::MysqlTables
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/capistrano/mysql_tables`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'capistrano-mysql_tables'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install capistrano-mysql_tables
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/capistrano-mysql_tables.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capistrano/mysql_tables"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require_relative "lib/capistrano/mysql_tables/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "capistrano-mysql_tables"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Jason Floyd"]
9
+ spec.email = ["jason.floyd@camfil.com"]
10
+
11
+ spec.summary = %q{Easily move tables between hosts in rails projects with Capistrano.}
12
+ spec.homepage = "https://github.com/floydj/capistrano-mysql_tables"
13
+ # spec.homepage = "https://rubygems.org/gems/capistrano-mysql_tables"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
16
+
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+
21
+ spec.require_paths = ["lib"]
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = spec.homepage
24
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
+
26
+ spec.add_runtime_dependency "capistrano", "~> 3.0"
27
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module MysqlTables
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/mysql_tables.rake', __FILE__)
@@ -0,0 +1,74 @@
1
+ requier "yaml"
2
+
3
+ def local_db_attributes
4
+ db_file = YAML.load_file("config/database.yml")
5
+ DatabaseAttributes.new(database: db_file["development"]["database"],
6
+ username: db_file["development"]["username"],
7
+ password: db_file["development"]["password"],
8
+ host: db_file["development"]["host"],
9
+ port: db_file["development"]["port"])
10
+ end
11
+
12
+ def remote_db_attributes
13
+ database = capture :ruby, %{-e \"require('yaml'); puts YAML.load_file('config/database.yml')['#{fetch(:rails_env)}']['database']\"}
14
+ username = capture :ruby, %{-e \"require('yaml'); puts YAML.load_file('config/database.yml')['#{fetch(:rails_env)}']['username']\"}
15
+ DatabaseAttributes.new(database: database,
16
+ username: username)
17
+ end
18
+
19
+ namespace :db do
20
+ desc "Push tables to server"
21
+ task :push_tables, :tables do |t, args|
22
+ set :sql_file, "tmp/from_local.sql"
23
+
24
+ if args[:tables]
25
+ set :table_names, args[:tables]
26
+ else
27
+ ask(:table_names, "the table names you want to push")
28
+ end
29
+
30
+ run_locally do
31
+ db = local_db_attributes
32
+ puts %x[mysqldump -u#{db.username} -p#{db.password} -h #{db.host} -P #{db.port} #{db.database} #{fetch(:table_names)} > #{fetch(:sql_file)}]
33
+ end
34
+
35
+ on roles(:db) do
36
+ within shared_path do
37
+ db = remote_db_attributes
38
+ set :remote_database, db.database
39
+ set :remote_username, db.username
40
+
41
+ upload! fetch(:sql_file), "./from_local.sql"
42
+ execute "mysql -u #{fetch(:remote_username)} #{fetch(:remote_database)} < #{shared_path}/from_local.sql"
43
+ end
44
+ end
45
+ end
46
+
47
+ desc "Pull tables from server"
48
+ task :pull_tables, :tables do |t, args|
49
+ set :sql_file, "#{shared_path}/from_remote.sql"
50
+
51
+ if args[:tables]
52
+ set :table_names, args[:tables]
53
+ else
54
+ ask(:table_names, "the table names you want to pull")
55
+ end
56
+
57
+ on roles(:db) do
58
+ within shared_path do
59
+ db = remote_db_attributes
60
+ set :remote_database, db.database
61
+ set :remote_username, db.username
62
+
63
+ execute("mysqldump -u#{fetch(:remote_username)} #{fetch(:remote_database)} #{fetch(:table_names)} > #{fetch(:sql_file)}")
64
+ download! fetch(:sql_file), "tmp/from_remote.sql"
65
+ end
66
+ end
67
+
68
+ run_locally do
69
+ db = local_db_attributes
70
+ puts %x[mysql -u #{db.username} -p#{db.password} -h #{db.host} -P #{db.port} #{db.database} < tmp/from_remote.sql]
71
+ end
72
+ end
73
+ end
74
+
File without changes
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-mysql_tables
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jason Floyd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description:
28
+ email:
29
+ - jason.floyd@camfil.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".travis.yml"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - bin/console
42
+ - bin/setup
43
+ - capistrano-mysql_tables.gemspec
44
+ - lib/capistrano-mysql_tables.rb
45
+ - lib/capistrano/mysql_tables.rb
46
+ - lib/capistrano/mysql_tables/version.rb
47
+ - lib/capistrano/tasks/mysql_tables.rake
48
+ homepage: https://github.com/floydj/capistrano-mysql_tables
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ homepage_uri: https://github.com/floydj/capistrano-mysql_tables
53
+ source_code_uri: https://github.com/floydj/capistrano-mysql_tables
54
+ allowed_push_host: https://rubygems.org
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.3.0
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.1.6
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Easily move tables between hosts in rails projects with Capistrano.
74
+ test_files: []