entangler 0.4.0 → 0.4.1

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: bc0ae798eba13d9d1191ca253ed99d3545ec5c1a
4
- data.tar.gz: 3846da80d6a40aa7bb4ade1a4840e99bfc50e5d9
3
+ metadata.gz: 116d9b520b874e6c30aaac728a0d341547bfdd4f
4
+ data.tar.gz: e3981339b47c28b20c1510b6e97b32086e174a7e
5
5
  SHA512:
6
- metadata.gz: fbe7d30b14fd8778cb57a5051d19be6f5951aae93e227ffa66884337582af01064f18c434dac879b7a75c1a9ebb059df19c7ce089b037477a9fee036084a5f58
7
- data.tar.gz: d4d93f058abd4dedf6ffc908bc2d56a3932b03de51a466d623cc2a8c7d1a4a964d13de619a240ed6fdb57cadaf544ecaa9bef1f129ed860b0149f5c38931daf3
6
+ metadata.gz: 42aaecf1a355c18f5f44e09e76fc95ad1c4356b1930bee788386e5577f7d5a1f906cbdc5ea1e3c6e7617aa8735a16cb7dd977d17457e5d4573da232e7e0d7df7
7
+ data.tar.gz: 35f0c0b7be7c7984bf8d5215f4996b62d28cbf57afa21fc888087b44b768d40e2c594e2a5f21c5284012cf6d1a9b24ebde73ce752f8b5ae3ad28c07a1b9d5d36
data/README.md CHANGED
@@ -14,12 +14,12 @@ $ gem install entangler
14
14
  ## Usage
15
15
 
16
16
  ```shell
17
- entangler master /some/base/path user@remote:/some/remote/path
17
+ $ entangler master /some/base/path user@remote:/some/remote/path
18
18
  ```
19
19
 
20
20
  ```
21
- entangler -h
22
- Entangler v0.4.0
21
+ $ entangler -h
22
+ Entangler v0.4.1
23
23
 
24
24
  Usage:
25
25
  entangler master <base_dir> <remote_user>@<remote_host>:<remote_base_dir> [options]
@@ -7,7 +7,8 @@ module Entangler
7
7
  require 'open3'
8
8
  ignore_opts = @opts[:ignore].map{|regexp| "-i '#{regexp.inspect}'"}.join(' ')
9
9
  entangler_cmd = "entangler slave #{@opts[:remote_base_dir]} #{ignore_opts}"
10
- full_cmd = @opts[:remote_mode] ? "ssh -q #{@opts[:remote_user]}@#{@opts[:remote_host]} -p #{@opts[:remote_port]} -C \"source ~/.rvm/environments/default && #{entangler_cmd}\"" : entangler_cmd
10
+ ssh_cmd = generate_ssh_command("source ~/.rvm/environments/default && #{entangler_cmd}")
11
+ full_cmd = @opts[:remote_mode] ? ssh_cmd : entangler_cmd
11
12
 
12
13
  @remote_writer, @remote_reader, remote_err, @remote_thread = Open3.popen3(full_cmd)
13
14
  remote_err.close
@@ -22,7 +22,7 @@ module Entangler
22
22
  raise 'Missing remote user' unless @opts.keys.include?(:remote_user)
23
23
  raise 'Missing remote host' unless @opts.keys.include?(:remote_host)
24
24
  @opts[:remote_port] ||= '22'
25
- res = `ssh -q #{@opts[:remote_user]}@#{@opts[:remote_host]} -p #{@opts[:remote_port]} -C "[[ -d '#{@opts[:remote_base_dir]}' ]] && echo 'ok' || echo 'missing'"`
25
+ res = `#{generate_ssh_command("[[ -d '#{@opts[:remote_base_dir]}' ]] && echo 'ok' || echo 'missing'")}`
26
26
  raise 'Cannot connect to remote' if res.empty?
27
27
  raise 'Remote base dir invalid' unless res.strip == 'ok'
28
28
  else
@@ -34,9 +34,15 @@ module Entangler
34
34
 
35
35
  def perform_initial_rsync
36
36
  logger.info 'Running initial sync'
37
- all_folders = Dir.glob("#{base_dir}/**/*/", File::FNM_DOTMATCH).tap{|a| a.shift(1) }.find_all{|path| !path.end_with?("/./")}
38
- all_ignore_matches = all_folders.map{|path| @opts[:ignore].map{|regexp| regexp.match("/#{path[0..-2]}")}.compact.first}.compact
39
- exclude_folders = all_ignore_matches.map{|match| match[0]}.uniq.map{|path| path[1..-1]}
37
+ local_folders = `find #{base_dir} -type d`.split("\n").tap{|a| a.shift(1) }.map{|path| path.sub(base_dir, '') }
38
+
39
+ remote_find_cmd = "find #{@opts[:remote_base_dir]} -type d"
40
+ raw_remote_folders = `#{@opts[:remote_mode] ? generate_ssh_command(remote_find_cmd) : remote_find_cmd}`
41
+ remote_folders = raw_remote_folders.split("\n").tap{|a| a.shift(1) }.map{|path| path.sub(@opts[:remote_base_dir], '') }
42
+
43
+ all_folders = remote_folders | local_folders
44
+ ignore_matches = all_folders.map{|path| @opts[:ignore].map{|regexp| (regexp.match(path) || [])[0]}.compact.first}.compact.uniq
45
+ exclude_folders = ignore_matches.map{|path| path[1..-1]}
40
46
  exclude_args = exclude_folders.map{|path| "--exclude #{path}"}.join(' ')
41
47
 
42
48
  ssh_settings = @opts[:remote_mode] ? "-e \"ssh -p #{@opts[:remote_port]}\"" : ''
@@ -49,6 +55,10 @@ module Entangler
49
55
  end
50
56
  logger.debug 'Initial sync complete'
51
57
  end
58
+
59
+ def generate_ssh_command(cmd)
60
+ "ssh -q #{@opts[:remote_user]}@#{@opts[:remote_host]} -p #{@opts[:remote_port]} -C \"#{cmd}\""
61
+ end
52
62
  end
53
63
  end
54
64
  end
@@ -1,3 +1,3 @@
1
1
  module Entangler
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Allie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.4.8
146
+ rubygems_version: 2.5.1
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Two way file syncer using platform native notify and rdiff syncing.