db-clone 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +13 -20
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/db-clone.gemspec +30 -0
- data/lib/db/clone.rb +50 -0
- data/lib/db/clone/base.rb +59 -0
- data/lib/{db_clone → db/clone}/cmd_builder.rb +10 -12
- data/lib/db/clone/cmd_prompt.rb +43 -0
- data/lib/db/clone/rake_task.rb +17 -0
- data/lib/db/clone/version.rb +5 -0
- data/screenshot.png +0 -0
- metadata +54 -123
- data/MIT-LICENSE +0 -20
- data/app/assets/javascripts/db_clone/application.js +0 -13
- data/app/assets/stylesheets/db_clone/application.css +0 -15
- data/app/controllers/db_clone/application_controller.rb +0 -5
- data/app/helpers/db_clone/application_helper.rb +0 -4
- data/app/views/layouts/db_clone/application.html.erb +0 -14
- data/config/routes.rb +0 -2
- data/lib/db_clone.rb +0 -27
- data/lib/db_clone/db_selections.rb +0 -65
- data/lib/db_clone/engine.rb +0 -14
- data/lib/db_clone/version.rb +0 -3
- data/lib/tasks/db_clone_tasks.rake +0 -6
- data/spec/cmd_builder_spec.rb +0 -73
- data/spec/db_clone_spec.rb +0 -15
- data/spec/db_selections_spec.rb +0 -74
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -31
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -59
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/log/test.log +0 -40
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/rails_helper.rb +0 -59
- data/spec/spec_helper.rb +0 -92
data/screenshot.png
ADDED
Binary file
|
metadata
CHANGED
@@ -1,91 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-clone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: colorize
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '4.0'
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '0.7'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '4.0'
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '0.7'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
28
|
+
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
type: :
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '1.15'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
42
|
+
name: rake
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '10.0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
54
|
+
version: '10.0'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
56
|
+
name: rspec
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
61
|
+
version: '3.0'
|
68
62
|
type: :development
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
66
|
- - "~>"
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
68
|
+
version: '3.0'
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
70
|
+
name: coveralls
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
78
72
|
requirements:
|
79
73
|
- - "~>"
|
80
74
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
75
|
+
version: '0.8'
|
82
76
|
type: :development
|
83
77
|
prerelease: false
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
85
79
|
requirements:
|
86
80
|
- - "~>"
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
82
|
+
version: '0.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: awesome_print
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
89
97
|
description: rake db:clone[manual] provides a CLI for selecting a specific source
|
90
98
|
database to copy to a specific destination database. Supports postgreql and mysql.
|
91
99
|
email:
|
@@ -94,60 +102,23 @@ executables: []
|
|
94
102
|
extensions: []
|
95
103
|
extra_rdoc_files: []
|
96
104
|
files:
|
97
|
-
-
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
98
111
|
- Rakefile
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
- lib/
|
106
|
-
- lib/
|
107
|
-
- lib/
|
108
|
-
-
|
109
|
-
- lib/db_clone/version.rb
|
110
|
-
- lib/tasks/db_clone_tasks.rake
|
111
|
-
- spec/cmd_builder_spec.rb
|
112
|
-
- spec/db_clone_spec.rb
|
113
|
-
- spec/db_selections_spec.rb
|
114
|
-
- spec/dummy/README.rdoc
|
115
|
-
- spec/dummy/Rakefile
|
116
|
-
- spec/dummy/app/assets/javascripts/application.js
|
117
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
118
|
-
- spec/dummy/app/controllers/application_controller.rb
|
119
|
-
- spec/dummy/app/helpers/application_helper.rb
|
120
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
121
|
-
- spec/dummy/bin/bundle
|
122
|
-
- spec/dummy/bin/rails
|
123
|
-
- spec/dummy/bin/rake
|
124
|
-
- spec/dummy/bin/setup
|
125
|
-
- spec/dummy/config.ru
|
126
|
-
- spec/dummy/config/application.rb
|
127
|
-
- spec/dummy/config/boot.rb
|
128
|
-
- spec/dummy/config/database.yml
|
129
|
-
- spec/dummy/config/environment.rb
|
130
|
-
- spec/dummy/config/environments/development.rb
|
131
|
-
- spec/dummy/config/environments/production.rb
|
132
|
-
- spec/dummy/config/environments/test.rb
|
133
|
-
- spec/dummy/config/initializers/assets.rb
|
134
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
135
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
136
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
137
|
-
- spec/dummy/config/initializers/inflections.rb
|
138
|
-
- spec/dummy/config/initializers/mime_types.rb
|
139
|
-
- spec/dummy/config/initializers/session_store.rb
|
140
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
141
|
-
- spec/dummy/config/locales/en.yml
|
142
|
-
- spec/dummy/config/routes.rb
|
143
|
-
- spec/dummy/config/secrets.yml
|
144
|
-
- spec/dummy/log/test.log
|
145
|
-
- spec/dummy/public/404.html
|
146
|
-
- spec/dummy/public/422.html
|
147
|
-
- spec/dummy/public/500.html
|
148
|
-
- spec/dummy/public/favicon.ico
|
149
|
-
- spec/rails_helper.rb
|
150
|
-
- spec/spec_helper.rb
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- db-clone.gemspec
|
115
|
+
- lib/db/clone.rb
|
116
|
+
- lib/db/clone/base.rb
|
117
|
+
- lib/db/clone/cmd_builder.rb
|
118
|
+
- lib/db/clone/cmd_prompt.rb
|
119
|
+
- lib/db/clone/rake_task.rb
|
120
|
+
- lib/db/clone/version.rb
|
121
|
+
- screenshot.png
|
151
122
|
homepage: https://github.com/seanhuber/db-clone
|
152
123
|
licenses:
|
153
124
|
- MIT
|
@@ -160,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
131
|
requirements:
|
161
132
|
- - ">="
|
162
133
|
- !ruby/object:Gem::Version
|
163
|
-
version: '
|
134
|
+
version: '0'
|
164
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
136
|
requirements:
|
166
137
|
- - ">="
|
@@ -168,48 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
139
|
version: '0'
|
169
140
|
requirements: []
|
170
141
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.6.13
|
172
143
|
signing_key:
|
173
144
|
specification_version: 4
|
174
145
|
summary: rake db:clone will clone your production database to development
|
175
|
-
test_files:
|
176
|
-
- spec/cmd_builder_spec.rb
|
177
|
-
- spec/db_clone_spec.rb
|
178
|
-
- spec/db_selections_spec.rb
|
179
|
-
- spec/dummy/app/assets/javascripts/application.js
|
180
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
181
|
-
- spec/dummy/app/controllers/application_controller.rb
|
182
|
-
- spec/dummy/app/helpers/application_helper.rb
|
183
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
184
|
-
- spec/dummy/bin/bundle
|
185
|
-
- spec/dummy/bin/rails
|
186
|
-
- spec/dummy/bin/rake
|
187
|
-
- spec/dummy/bin/setup
|
188
|
-
- spec/dummy/config/application.rb
|
189
|
-
- spec/dummy/config/boot.rb
|
190
|
-
- spec/dummy/config/database.yml
|
191
|
-
- spec/dummy/config/environment.rb
|
192
|
-
- spec/dummy/config/environments/development.rb
|
193
|
-
- spec/dummy/config/environments/production.rb
|
194
|
-
- spec/dummy/config/environments/test.rb
|
195
|
-
- spec/dummy/config/initializers/assets.rb
|
196
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
197
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
198
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
199
|
-
- spec/dummy/config/initializers/inflections.rb
|
200
|
-
- spec/dummy/config/initializers/mime_types.rb
|
201
|
-
- spec/dummy/config/initializers/session_store.rb
|
202
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
203
|
-
- spec/dummy/config/locales/en.yml
|
204
|
-
- spec/dummy/config/routes.rb
|
205
|
-
- spec/dummy/config/secrets.yml
|
206
|
-
- spec/dummy/config.ru
|
207
|
-
- spec/dummy/log/test.log
|
208
|
-
- spec/dummy/public/404.html
|
209
|
-
- spec/dummy/public/422.html
|
210
|
-
- spec/dummy/public/500.html
|
211
|
-
- spec/dummy/public/favicon.ico
|
212
|
-
- spec/dummy/Rakefile
|
213
|
-
- spec/dummy/README.rdoc
|
214
|
-
- spec/rails_helper.rb
|
215
|
-
- spec/spec_helper.rb
|
146
|
+
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2016 Sean Huber
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>DbClone</title>
|
5
|
-
<%= stylesheet_link_tag "db_clone/application", media: "all" %>
|
6
|
-
<%= javascript_include_tag "db_clone/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
data/config/routes.rb
DELETED
data/lib/db_clone.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'colorize'
|
2
|
-
require 'db_clone/cmd_builder'
|
3
|
-
require 'db_clone/db_selections'
|
4
|
-
require 'db_clone/engine'
|
5
|
-
|
6
|
-
module DbClone
|
7
|
-
mattr_accessor :config
|
8
|
-
|
9
|
-
def self.clone!( **opts )
|
10
|
-
DbClone.config ||= {}
|
11
|
-
DbClone.config[:ignore_tables] ||= []
|
12
|
-
DbClone.config[:default_source] ||= 'production'
|
13
|
-
DbClone.config[:default_destination] ||= 'development'
|
14
|
-
|
15
|
-
ds = DbSelections.new Rails.root.join('config', 'database.yml')
|
16
|
-
src_dest = if opts[:manual]
|
17
|
-
[:source_prompt, :source_get, :dest_prompt, :dest_get].each{|m| ds.send(m)}
|
18
|
-
ds.selections
|
19
|
-
else
|
20
|
-
ds.selections( use_defaults: true )
|
21
|
-
end
|
22
|
-
|
23
|
-
cb = CmdBuilder.new src_dest
|
24
|
-
puts "\n Executing: #{cb.get_cmd.light_blue}\n\n"
|
25
|
-
cb.exec!
|
26
|
-
end
|
27
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module DbClone
|
4
|
-
class DbSelections
|
5
|
-
# read database blocks from config/database.yml
|
6
|
-
def initialize( database_yml )
|
7
|
-
h = YAML.load_file database_yml
|
8
|
-
@dbs = h.sort_by{|k,v| k}.map{|k,v| v.merge(label: k)}
|
9
|
-
@default_src_idx = @dbs.find_index{|db| db[:label] == DbClone.config[:default_source]}
|
10
|
-
@default_dest_idx = @dbs.find_index{|db| db[:label] == DbClone.config[:default_destination]}
|
11
|
-
@selections = {src: nil, dest: nil}
|
12
|
-
end
|
13
|
-
|
14
|
-
# STEP 1: prompt user for which database block to use as the source
|
15
|
-
def source_prompt
|
16
|
-
db_prompt 'source'
|
17
|
-
end
|
18
|
-
|
19
|
-
# STEP 2: retrieve from use which database block to use as the source
|
20
|
-
def source_get
|
21
|
-
db_select 'source'
|
22
|
-
end
|
23
|
-
|
24
|
-
# STEP 3: prompt user for which database block to use as the destination
|
25
|
-
def dest_prompt
|
26
|
-
db_prompt 'destination'
|
27
|
-
end
|
28
|
-
|
29
|
-
# STEP 4: retrieve from use which database block to use as the destination
|
30
|
-
def dest_get
|
31
|
-
db_select 'destination'
|
32
|
-
end
|
33
|
-
|
34
|
-
def selections( **opts )
|
35
|
-
opts[:use_defaults] ? {src: @dbs[@default_src_idx], dest: @dbs[@default_dest_idx]} : @selections.map{|k,v| [k, v.nil? ? nil : @dbs[v]] }.to_h
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def db_prompt( src_dest )
|
41
|
-
num_dbs = @dbs.length
|
42
|
-
puts "\n Choose a #{src_dest.magenta} database from one of the blocks defined in #{'config/database.yml'.light_green}:\n\n"
|
43
|
-
@dbs.each_with_index do |db, idx|
|
44
|
-
if src_dest == 'destination' && idx == @selections[:src]
|
45
|
-
puts " [ #{"#{'X'.ljust(num_dbs.to_s.length).red}"} ] #{db[:label].red}"
|
46
|
-
else
|
47
|
-
puts " [ #{"#{(idx+1).to_s.ljust(num_dbs.to_s.length).light_blue}"} ] #{db[:label].yellow}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
default = src_dest=='source' ? "#{@dbs[@default_src_idx][:label]} = #{(@default_src_idx+1).to_s.light_blue}" : "#{@dbs[@default_dest_idx][:label]} = #{(@default_dest_idx+1).to_s.light_blue}"
|
51
|
-
print "\n Choose a #{src_dest.magenta} database (#{'1'.light_blue}-#{num_dbs.to_s.light_blue}) [#{default}]: "
|
52
|
-
end
|
53
|
-
|
54
|
-
def db_select( src_dest )
|
55
|
-
sk = src_dest=='source' ? :src : :dest
|
56
|
-
idx = STDIN.gets.chomp
|
57
|
-
idx = ((src_dest=='source' ? @default_src_idx : @default_dest_idx)+1).to_s if idx == ''
|
58
|
-
raise(ArgumentError, "Invalid selection: #{src_idx}") unless (1..@dbs.length).map(&:to_s).include?(idx)
|
59
|
-
@selections[sk] = idx.to_i - 1
|
60
|
-
raise(ArgumentError, 'Destination cannot be the same as the source') unless @selections.values.uniq.length == 2
|
61
|
-
raise(ArgumentError, 'Source and destination databases must be of the same type') if src_dest=='destination' && @dbs[@selections[:src]]['adapter'] != @dbs[@selections[:dest]]['adapter']
|
62
|
-
puts "\n #{src_dest.capitalize.magenta} set to: #{@dbs[@selections[sk]][:label].yellow}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|