cloner 0.5.1 → 0.5.2

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: ff039ecf77aa04b16d10b76f3ec8ec8dc494085d
4
- data.tar.gz: 03534218c250e015f8f4ecc8d8f33d4cc6a7b610
3
+ metadata.gz: 32d8735e858cfef73a306c3c97b2e28025f796b7
4
+ data.tar.gz: 0fefb2d9aaf996acdaa975efd96e65dbf5ccbfc0
5
5
  SHA512:
6
- metadata.gz: b9b5605a4be19035cc327d101f8a35cb654d1bee6f859af0ece4eeacc694277b6bb761d4940e21c7f1af9630c453d4b26a7215bc82210b3bf7e2474e860f63c2
7
- data.tar.gz: 76a975a0aa4083a9e78ee1a38aa8718f20979354bc9c99b4adb55e5eacee5a2e8e178f691eabaf2ddd975aaa77a78319289ebf967b7841780527b90c8f125b9a
6
+ metadata.gz: 94388283f46759e3b2ba846c0cc2e0713b6f4c65c1b210be9b061e8be678ee1ebc2956830aab9b535d979086135a8c93dbb696cf903c349dbdae60081aa81935
7
+ data.tar.gz: 50ac11a234d90e286506e68e89b03f390f4ab4818c8be8454bd7385217c7fb9e4cc3327fec573b65a9fda80427e1c3e739b6ae8cef9290dafcfa26eb0fbbd71e
@@ -18,10 +18,19 @@ module Cloner::MongoDB
18
18
 
19
19
  def mongodb_r_conf
20
20
  @r_conf ||= begin
21
- Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
21
+ do_ssh do |ssh|
22
22
  ret = ssh_exec!(ssh, "cat #{e(remote_app_path + '/config/mongoid.yml')}")
23
23
  check_ssh_err(ret)
24
- yml = YAML.load(ret[0])[env_from]
24
+
25
+ begin
26
+ yml = YAML.load(ret[0])[env_from]
27
+ raise 'no data' if yml.blank?
28
+ rescue Exception => e
29
+ puts "unable to read remote database.yml for env #{env_from}."
30
+ puts "Remote file contents:"
31
+ puts ret[0]
32
+ end
33
+
25
34
  if yml.key?('sessions')
26
35
  yml['sessions']['default']
27
36
  else
@@ -43,7 +52,7 @@ module Cloner::MongoDB
43
52
 
44
53
  def mongodb_dump_remote
45
54
  puts "backup remote DB via ssh"
46
- Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
55
+ do_ssh do |ssh|
47
56
  ssh.exec!("rm -R #{remote_dump_path}")
48
57
  ret = ssh_exec!(ssh, "mkdir -p #{remote_dump_path}")
49
58
  check_ssh_err(ret)
@@ -13,11 +13,18 @@ module Cloner::Postgres
13
13
 
14
14
  def ar_r_conf
15
15
  @ar_r_conf ||= begin
16
- Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
16
+ do_ssh do |ssh|
17
17
  ret = ssh_exec!(ssh, "cat #{e(remote_app_path + '/config/database.yml')}")
18
18
  check_ssh_err(ret)
19
- res = YAML.load(ret[0])[env_from]
20
- res['host'] ||= '127.0.0.1'
19
+ begin
20
+ res = YAML.load(ret[0])[env_from]
21
+ raise 'no data' if res.blank?
22
+ res['host'] ||= '127.0.0.1'
23
+ rescue Exception => e
24
+ puts "unable to read remote database.yml for env #{env_from}."
25
+ puts "Remote file contents:"
26
+ puts ret[0]
27
+ end
21
28
  res
22
29
  end
23
30
  end
@@ -41,7 +48,7 @@ module Cloner::Postgres
41
48
 
42
49
  def pg_dump_remote
43
50
  puts "backup remote DB via ssh"
44
- Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
51
+ do_ssh do |ssh|
45
52
  ssh.exec!("rm -R #{e remote_dump_path}")
46
53
  ret = ssh_exec!(ssh, "mkdir -p #{e remote_dump_path}")
47
54
  check_ssh_err(ret)
data/lib/cloner/rsync.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Cloner::RSync
2
2
  extend ActiveSupport::Concern
3
3
  def rsync(from, to)
4
- cmd = "rsync -e ssh -zutvr --checksum #{e ssh_user}@#{e ssh_host}:#{e from}/ #{e to}/"
4
+ port = ssh_opts[:port] || 22
5
+ cmd = "rsync -e ssh -zutvr --checksum -e \"ssh -p #{port}\" #{e ssh_user}@#{e ssh_host}:#{e from}/ #{e to}/"
5
6
  puts "Running RSync: #{cmd}"
6
7
  pipe = IO.popen(cmd)
7
8
  while (line = pipe.gets)
data/lib/cloner/ssh.rb CHANGED
@@ -5,6 +5,12 @@ module Cloner::SSH
5
5
  {}
6
6
  end
7
7
 
8
+ def do_ssh(&block)
9
+ Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
10
+ yield ssh
11
+ end
12
+ end
13
+
8
14
  # http://stackoverflow.com/questions/3386233/how-to-get-exit-status-with-rubys-netssh-library
9
15
  def ssh_exec!(ssh, command)
10
16
  stdout_data = ""
@@ -46,3 +52,4 @@ module Cloner::SSH
46
52
  end
47
53
  end
48
54
  end
55
+
@@ -1,3 +1,4 @@
1
1
  module Cloner
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
4
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-09 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.4.5
126
+ rubygems_version: 2.4.5.1
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Easily clone your production Mongoid database and files for local development