load_remote_db 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76cb1980c871da64c2a8c9bf320b20fb06168269
4
- data.tar.gz: b4f234ea9d192f44347b72eefa33766caf63a263
3
+ metadata.gz: 0705b92198785747da391a7e4020bb7c6f764c7f
4
+ data.tar.gz: 1e0f3f6c569035e3cbf2a826a230f73d587affc1
5
5
  SHA512:
6
- metadata.gz: 10326c8102959b20327ccf657c3d145b78d13d6da15fa02638cd94a9ef6d22ec9307069178ffcc28ad36dbb83f09f5313ac396a66e9b328a19293a73c52214d8
7
- data.tar.gz: c074b0dc0ee7703d4e4aa3f4527990b8747e6cab6f59455bc17fb457dcba12387bf839aa802f906368c56081ec9a97fabc5904f6b4b86ad58c478cffb6d14198
6
+ metadata.gz: 01d65a974dcf8f852cf34c1bd719c5a33eeb5d2f576398a5e38757840d82290c079599625769aeb36fa6cc6377c30d4749c32fc46dacbf218856bf8866a2165d
7
+ data.tar.gz: '07822d4c51b20080a7bcae1fa23cdc0a66ad22311bfa9076c2ed807241555ee59d9b47f09f08a12e2b1f63ea2ce20ee21d9ef15eb4cb3c7f8b991a60b5f449ee'
@@ -1,3 +1,3 @@
1
1
  module LoadRemoteDb
2
- VERSION = '0.1.8'.freeze
2
+ VERSION = '0.1.9'.freeze
3
3
  end
@@ -24,11 +24,15 @@ class RemoteDbLoader
24
24
  password = development_db['password']
25
25
  database = development_db['database']
26
26
 
27
- eval File.read("#{Rails.root}/config/deploy.rb")
27
+ begin
28
+ eval File.read("#{Rails.root}/config/deploy.rb")
29
+ rescue LoadError
30
+ end
28
31
  eval File.read("#{Rails.root}/config/deploy/#{env}.rb")
32
+ port = @port || 22
29
33
 
30
34
  ## get remote database config.yml
31
- get_db_info_command = %{ssh #{@server_user}@#{@server_ip} \
35
+ get_db_info_command = %{ssh #{@server_user}@#{@server_ip} -p#{port} \
32
36
  "/home/#{@server_user}/.rbenv/shims/ruby -e \
33
37
  \\"require 'yaml'; \
34
38
  puts YAML.load_file('#{@deploy_to}/shared/config/database.yml')['#{env}']\\""}
@@ -46,12 +50,12 @@ class RemoteDbLoader
46
50
  puts 'Running the remote backup...'
47
51
  mysql_cmd = "mysqldump -u #{remote_db_username} -p'#{remote_db_password}' \
48
52
  -h #{remote_db_host} #{remote_db_name} > #{shared_path}/backup.sql".shellescape
49
- backup_command = %(ssh #{@server_user}@#{@server_ip} #{mysql_cmd})
53
+ backup_command = %(ssh #{@server_user}@#{@server_ip} -p#{port} #{mysql_cmd})
50
54
  system(backup_command)
51
55
 
52
56
  check_gzip_exist_cmd = 'which gzip'
53
57
  check_gzip_exist_remote_cmd =
54
- %(ssh #{@server_user}@#{@server_ip} #{check_gzip_exist_cmd})
58
+ %(ssh #{@server_user}@#{@server_ip} -p#{port} #{check_gzip_exist_cmd})
55
59
 
56
60
  puts 'Checking for remote gzip location...'
57
61
  gzip_exist = system(check_gzip_exist_remote_cmd) != ''
@@ -60,19 +64,19 @@ class RemoteDbLoader
60
64
  puts 'zipping remote backup file...'
61
65
  zip_cmd = "gzip -f #{shared_path}/backup.sql"
62
66
  zip_cmd_remote =
63
- %(ssh #{@server_user}@#{@server_ip} #{zip_cmd})
67
+ %(ssh #{@server_user}@#{@server_ip} -p#{port} #{zip_cmd})
64
68
  system(zip_cmd_remote)
65
69
  end
66
70
 
67
71
  puts 'Downloading remote backup file...'
68
72
  bk_extension = gzip_exist ? 'sql.gz' : 'sql'
69
73
  download_db_dump_command =
70
- %(scp #{@server_user}@#{@server_ip}:#{shared_path}/backup.#{bk_extension} .)
74
+ %(scp -P#{port} #{@server_user}@#{@server_ip}:#{shared_path}/backup.#{bk_extension} .)
71
75
 
72
76
  system(download_db_dump_command)
73
77
 
74
78
  puts 'Deleting remote backup file...'
75
- delete_db_dump_command = %(ssh #{@server_user}@#{@server_ip} \
79
+ delete_db_dump_command = %(ssh #{@server_user}@#{@server_ip} -p#{port} \
76
80
  "rm -rf #{shared_path}/backup.#{bk_extension}")
77
81
 
78
82
  system(delete_db_dump_command)
@@ -117,8 +121,21 @@ class RemoteDbLoader
117
121
  end
118
122
 
119
123
  def method_missing(name, *args, &block)
120
- return @server_user if name == :fetch && args[0] == :deploy_user
121
- return @application if name == :fetch && args[0] == :application
124
+ if name == :fetch && args[0] == :deploy_user
125
+ return @server_user
126
+ end
127
+
128
+ if name == :fetch && args[0] == :application
129
+ return @application
130
+ end
131
+
132
+ if name == :fetch && args[0] == :full_app_name
133
+ return @full_app_name
134
+ end
135
+
136
+ if name == :fetch && args[0] == :stage
137
+ return @stage
138
+ end
122
139
 
123
140
  return self unless %I[server set].include?(name)
124
141
  @server_ip ||= if name == :server
@@ -127,10 +144,11 @@ class RemoteDbLoader
127
144
  args[1]
128
145
  end
129
146
  @server_user ||= args[1] if name == :set && args[0] == :user
147
+ @stage ||= args[1] if name == :set && args[0] == :stage
148
+ @server_user = args[1] if name == :set && args[0] == :deploy_user
130
149
  @application ||= args[1] if name == :set && args[0] == :application
131
- @server_user ||= args[1] if name == :set && args[0] == :deploy_user
132
- if name == :set && args[0] == :deploy_to
133
- @deploy_to ||= args[1]
134
- end
150
+ @full_app_name ||= args[1] if name == :set && args[0] == :full_app_name
151
+ @port ||= args[1] if name == :set && args[0] == :port
152
+ @deploy_to ||= args[1] if name == :set && args[0] == :deploy_to
135
153
  end
136
154
  end
@@ -1,26 +1,25 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'load_remote_db/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "load_remote_db"
6
+ spec.name = 'load_remote_db'
8
7
  spec.version = LoadRemoteDb::VERSION
9
- spec.authors = ["James Huynh"]
10
- spec.email = ["james@rubify.com"]
8
+ spec.authors = ['James Huynh']
9
+ spec.email = ['james@rubify.com']
11
10
 
12
- spec.summary = %q{Load MySQL Remote DB for Mina/Capistrano}
13
- spec.description = %q{Load MySQL Remote DB for Mina/Capistrano}
14
- spec.homepage = "https://github.com/jameshuynh/load_remote_db"
15
- spec.license = "MIT"
11
+ spec.summary = 'Load MySQL Remote DB for Mina/Capistrano'
12
+ spec.description = 'Load MySQL Remote DB for Mina/Capistrano'
13
+ spec.homepage = 'https://github.com/jameshuynh/load_remote_db'
14
+ spec.license = 'MIT'
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
17
  f.match(%r{^(test|spec|features)/})
19
18
  end
20
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
21
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
23
22
 
24
- spec.add_development_dependency "bundler", "~> 1.14"
25
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'bundler', '~> 1.14'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
26
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: load_remote_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Huynh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,4 +82,3 @@ signing_key:
82
82
  specification_version: 4
83
83
  summary: Load MySQL Remote DB for Mina/Capistrano
84
84
  test_files: []
85
- has_rdoc: