entangler 0.2.1 → 0.3.0
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 +4 -4
- data/README.md +13 -0
- data/entangler.gemspec +1 -0
- data/exe/entangler +18 -1
- data/lib/entangler/executor/background/master.rb +2 -1
- data/lib/entangler/executor/base.rb +3 -1
- data/lib/entangler/executor/master.rb +7 -1
- data/lib/entangler/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3ef95e28e08db3d7ba05137821bfdf2ac9e0b45
|
4
|
+
data.tar.gz: 63c508ce43601ee0911e9027671ace3ec89e39cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a78ef9e6108412dd28877afc9bfd423286d6ee4c61a83c63363311664bcac9cb9f50552ee4f44d70069d8a89adba3605f0e619505d6128c2c56087f6e767805
|
7
|
+
data.tar.gz: 89c9a6bb2c136167f29ff94783cc78f6e307b3987ae67d63629e8ce70f040ea277f83a2d299add9ce6c2103c457b4f4dbbd352801febd7dfff31531ccad30110
|
data/README.md
CHANGED
@@ -15,19 +15,32 @@ $ gem install entangler
|
|
15
15
|
|
16
16
|
```shell
|
17
17
|
entangler master /some/base/path user@remote:/some/remote/path
|
18
|
+
```
|
18
19
|
|
20
|
+
```
|
19
21
|
entangler -h
|
22
|
+
Entangler v0.3.0
|
23
|
+
|
20
24
|
Usage:
|
21
25
|
entangler master <base_dir> <remote_user>@<remote_host>:<remote_base_dir> [options]
|
22
26
|
entangler slave <base_dir> [options]
|
23
27
|
|
24
28
|
Options:
|
29
|
+
-i, --ignore '/.git' Ignore folder when syncing, string is regex if surrounded by '/'
|
30
|
+
All folders should be relative to the base sync directory, but should start with a '/'.
|
25
31
|
-p, --port PORT Overwrite the SSH port (usually 22)
|
26
32
|
(doesn't do anything in slave mode)
|
27
33
|
-v, --version Show version number
|
28
34
|
-h, --help Show this message
|
29
35
|
```
|
30
36
|
|
37
|
+
### Ignoring folders
|
38
|
+
|
39
|
+
If you specify string, instead of regex, it will match any folder path starting with that string, i.e. `-i '/.git'` will ignore the `.git` folder and all its sub-directories.
|
40
|
+
If you want to just ignore the the `.git` sub-directories but not the content in the git folder, you can use `-i '/^\/\.git\/[^\/]*/'` which will match any path starting with `/.git/`, but not `/.git` itself.
|
41
|
+
|
42
|
+
You can specify multiple `-i` or `--ignore` flags to ignore multiple directories.
|
43
|
+
|
31
44
|
## Development
|
32
45
|
|
33
46
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/entangler.gemspec
CHANGED
data/exe/entangler
CHANGED
@@ -1,14 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'entangler'
|
3
3
|
require 'optparse'
|
4
|
+
require 'to_regexp'
|
4
5
|
|
5
6
|
options = {}
|
6
7
|
OptionParser.new do |opts|
|
7
|
-
opts.banner =
|
8
|
+
opts.banner = %Q(Entangler v#{Entangler::VERSION}
|
9
|
+
|
10
|
+
Usage:
|
11
|
+
entangler master <base_dir> <remote_user>@<remote_host>:<remote_base_dir> [options]
|
12
|
+
entangler slave <base_dir> [options])
|
8
13
|
|
9
14
|
opts.separator ""
|
10
15
|
opts.separator "Options:"
|
11
16
|
|
17
|
+
opts.on("-i", "--ignore '/.git'", "Ignore folder when syncing, string is regex if surrounded by '/'",
|
18
|
+
"All folders should be relative to the base sync directory, but should start with a '/'.") do |ignore|
|
19
|
+
options[:ignore] ||= []
|
20
|
+
options[:ignore] << ignore
|
21
|
+
end
|
22
|
+
|
12
23
|
opts.on("-p", "--port PORT", "Overwrite the SSH port (usually 22)", "(doesn't do anything in slave mode)") do |port|
|
13
24
|
options[:port] = port
|
14
25
|
end
|
@@ -62,4 +73,10 @@ else
|
|
62
73
|
opts = {mode: 'slave'}
|
63
74
|
end
|
64
75
|
|
76
|
+
if options[:ignore]
|
77
|
+
opts[:ignore] = options[:ignore].map do |opt|
|
78
|
+
opt.to_regexp(detect: true)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
65
82
|
Entangler.run(base_dir, opts)
|
@@ -5,7 +5,8 @@ module Entangler
|
|
5
5
|
protected
|
6
6
|
def start_remote_slave
|
7
7
|
require 'open3'
|
8
|
-
|
8
|
+
ignore_opts = @opts[:ignore].map{|regexp| "-i '#{regexp.inspect}'"}.join(' ')
|
9
|
+
@remote_writer, @remote_reader, remote_err, @remote_thread = Open3.popen3("ssh -q #{@opts[:remote_user]}@#{@opts[:remote_host]} -p #{@opts[:remote_port]} -C \"source ~/.rvm/environments/default && entangler slave #{@opts[:remote_base_dir]} #{ignore_opts}\"")
|
9
10
|
remote_err.close
|
10
11
|
end
|
11
12
|
|
@@ -16,7 +16,9 @@ module Entangler
|
|
16
16
|
@notify_sleep = 0
|
17
17
|
@exported_at = 0
|
18
18
|
@opts = opts
|
19
|
-
@opts[:ignore] = [/^\/\.git
|
19
|
+
@opts[:ignore] = [/^\/\.git.*/] unless @opts.has_key?(:ignore)
|
20
|
+
@opts[:ignore] << /^\/\.entangler.*/
|
21
|
+
|
20
22
|
validate_opts
|
21
23
|
logger.info("Starting executor")
|
22
24
|
end
|
@@ -28,7 +28,13 @@ module Entangler
|
|
28
28
|
|
29
29
|
def perform_initial_rsync
|
30
30
|
logger.info 'Running initial sync'
|
31
|
-
|
31
|
+
all_folders = Dir.glob("#{base_dir}/**/*/", File::FNM_DOTMATCH).tap{|a| a.shift(1) }.find_all{|path| !path.end_with?("/./")}
|
32
|
+
all_ignore_matches = all_folders.map{|path| @opts[:ignore].map{|regexp| regexp.match("/#{path[0..-2]}")}.compact.first}.compact
|
33
|
+
exclude_folders = all_ignore_matches.map{|match| match[0]}.uniq.map{|path| path[1..-1]}
|
34
|
+
exclude_args = exclude_folders.map{|path| "--exclude #{path}"}.join(' ')
|
35
|
+
rsync_cmd = "rsync -azv #{exclude_args} -e \"ssh -p #{@opts[:remote_port]}\" --delete #{base_dir}/ #{@opts[:remote_user]}@#{@opts[:remote_host]}:#{@opts[:remote_base_dir]}/"
|
36
|
+
|
37
|
+
IO.popen(rsync_cmd).each do |line|
|
32
38
|
logger.debug line.chomp
|
33
39
|
end
|
34
40
|
logger.debug 'Initial sync complete'
|
data/lib/entangler/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: entangler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Allie
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: to_regexp
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.2'
|
69
83
|
description: Two way file syncer using platform native notify and rdiff syncing.
|
70
84
|
email:
|
71
85
|
- dave@daveallie.com
|