entangler 1.1.1 → 1.2.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
- SHA1:
3
- metadata.gz: 7664234684080baaf20298dfc18cb7ab65894387
4
- data.tar.gz: e90330937c330a0967e086057d8e044785505e35
2
+ SHA256:
3
+ metadata.gz: a4f98e12ff87f2be01e5370bc2142b4bed7154535481d33a95c6f43591e47de4
4
+ data.tar.gz: 27868bae2c5fd085b4f28466e26934d57c84d37ed1f70aeb44899636fd39e14c
5
5
  SHA512:
6
- metadata.gz: da01d358c301ff60072b67b10e74703446ca0e24a4d70ba0bef1a9eb6a23be7ac16b021de7f768934ffce9e9262e410f619dbf02ab20b6886c88839324092c8c
7
- data.tar.gz: 0824476a729ee980afd9ad8eb0d0c371c5b0bbe5f31b826678131027afc9b985341520f9f565e5a2ed3a282406d08c8b960c79eecaebf6898400b63d480467bd
6
+ metadata.gz: 8d02e37d871284a999f90a0f93e94a4235317c4adb5d3a222e6c53187d8c2503e32af6aabc3118e95700df768c745e6924ee53672c47f956698b80a52513e6b1
7
+ data.tar.gz: ebeccb202a07a95e63160aca13d08e3533a5e92470b7d3b1c14ead7acd405f6a4a6d82b4ee3f7c8d1a7fc60b46bbc8ff5b099f8eabbeca80aaa531e1ce4a9f4d
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in entangler.gemspec
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Entangler
1
+ <p align="center" style="width: 50px;"><img src="https://vignette1.wikia.nocookie.net/pokemon/images/e/ef/114Tangela_Dream.png/revision/latest/scale-to-width-down/185?cb=20141203054028"/></p>
2
+ <h1 align="center">Entangler</h1>
2
3
 
3
4
  [![Build Status](https://travis-ci.org/daveallie/entangler.svg?branch=master)](https://travis-ci.org/daveallie/entangler)
4
5
 
@@ -18,7 +19,7 @@ $ entangler master /some/base/path user@remote:/some/remote/path
18
19
 
19
20
  ```
20
21
  $ entangler -h
21
- Entangler v1.1.1
22
+ Entangler v1.2.2
22
23
 
23
24
  Usage:
24
25
  entangler master <base_dir> <remote_user>@<remote_host>:<remote_base_dir> [options]
data/entangler.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'entangler/version'
4
6
 
@@ -18,11 +20,14 @@ Gem::Specification.new do |spec|
18
20
  spec.bindir = 'exe'
19
21
  spec.executables = ['entangler']
20
22
  spec.require_paths = ['lib']
23
+ spec.required_ruby_version = '>= 2.5'
21
24
 
22
- spec.add_development_dependency 'bundler', '~> 1.13'
23
- spec.add_development_dependency 'rake', '~> 10.0'
24
- spec.add_development_dependency 'rspec', '~> 3.0'
25
- spec.add_development_dependency 'rubocop', '~> 0.49.1'
26
- spec.add_dependency 'listen', '~> 3.1'
27
- spec.add_dependency 'to_regexp', '~> 0.2.0'
25
+ spec.add_development_dependency 'bundler', '>= 2.1'
26
+ spec.add_development_dependency 'rake', '>= 13.0.1'
27
+ spec.add_development_dependency 'rspec', '>= 3.9'
28
+ spec.add_development_dependency 'rubocop', '~> 1.6'
29
+ spec.add_development_dependency 'rubocop-rake', '~> 0.5.1'
30
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
31
+ spec.add_dependency 'listen', '~> 3.7'
32
+ spec.add_dependency 'to_regexp', '~> 0.2.1'
28
33
  end
data/exe/entangler CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require 'entangler'
3
5
  require 'optparse'
4
6
  require 'to_regexp'
@@ -99,9 +101,7 @@ end
99
101
 
100
102
  if options[:ignore]
101
103
  opts[:ignore] = options[:ignore].map do |opt|
102
- if opt.start_with?('"') && opt.end_with?('"') || opt.start_with?("'") && opt.end_with?("'")
103
- opt = opt[1..-2]
104
- end
104
+ opt = opt[1..-2] if opt.start_with?('"') && opt.end_with?('"') || opt.start_with?("'") && opt.end_with?("'")
105
105
 
106
106
  if ToRegexp::String.literal? opt
107
107
  source, *rest = opt.as_regexp(detect: true)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
 
3
5
  module Entangler
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Entangler
2
4
  class EntanglerError < StandardError; end
3
5
  class ValidationError < EntanglerError; end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'listen'
2
4
  require 'entangler/entangled_file'
3
5
  require 'benchmark'
@@ -56,6 +58,7 @@ module Entangler
56
58
  def remove_recently_changed_files(entangled_files)
57
59
  @recently_received_paths.select! { |_, time| Time.now.to_f < time + 0.5 }
58
60
  paths = @recently_received_paths.map(&:first)
61
+ logger.debug("Skipping paths #{paths.join(', ')} as they have changed recently") if paths.any?
59
62
  entangled_files.reject { |ef| paths.include?(ef.path) }
60
63
  end
61
64
 
@@ -75,6 +78,7 @@ module Entangler
75
78
  def process_remote_changes(changes)
76
79
  with_listener_pause(1) do
77
80
  return if changes.nil?
81
+
78
82
  logger.info("Processing - #{changes.length} remote changes")
79
83
  logger.debug("File List:\n#{changes.map(&:path).join("\n")}")
80
84
  with_log_time("Completed - #{changes.length} remote changes") do
@@ -97,9 +101,9 @@ module Entangler
97
101
 
98
102
  def with_kill_threads_rescue
99
103
  yield
100
- rescue => e
101
- $stderr.puts e.message
102
- $stderr.puts e.backtrace.join("\n")
104
+ rescue StandardError => e
105
+ warn e.message
106
+ warn e.backtrace.join("\n")
103
107
  kill_off_threads
104
108
  end
105
109
 
@@ -107,6 +111,7 @@ module Entangler
107
111
  @listener_pauses[idx] = true
108
112
  listener.pause
109
113
  yield
114
+ ensure
110
115
  @listener_pauses[idx] = false
111
116
  listener.start if @listener_pauses.none?
112
117
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open3'
2
4
 
3
5
  module Entangler
@@ -21,7 +23,7 @@ module Entangler
21
23
  super
22
24
  begin
23
25
  Process.wait @remote_thread[:pid]
24
- rescue
26
+ rescue StandardError
25
27
  nil
26
28
  end
27
29
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
  require 'fileutils'
3
- require 'thread'
4
5
  require_relative 'background/base'
5
6
  require_relative 'validation/base'
6
7
 
@@ -52,7 +53,7 @@ module Entangler
52
53
  end
53
54
 
54
55
  def logger
55
- @logger ||= Entangler::Logger.new(log_outputs, @opts[:verbose])
56
+ @logger ||= Entangler::Logger.new(log_outputs, verbose: @opts[:verbose])
56
57
  end
57
58
 
58
59
  def log_outputs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Entangler
2
4
  module Helper
3
5
  def self.with_temp_file(name: 'tmp_file', contents: nil)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'helpers'
2
4
  require_relative 'background/master'
3
5
  require_relative 'validation/master'
@@ -21,7 +23,7 @@ module Entangler
21
23
 
22
24
  def log_outputs
23
25
  outs = [Entangler::Logger.log_file_path(base_dir)]
24
- outs << STDOUT unless @opts[:quiet]
26
+ outs << $stdout unless @opts[:quiet]
25
27
  end
26
28
 
27
29
  def perform_initial_rsync
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Entangler
2
4
  module Executor
3
5
  class Slave < Base
4
6
  def initialize(base_dir, opts = {})
5
7
  super(base_dir, opts)
6
- STDIN.binmode
7
- STDOUT.binmode
8
- STDIN.sync = true
9
- STDOUT.sync = true
8
+ $stdin.binmode
9
+ $stdout.binmode
10
+ $stdin.sync = true
11
+ $stdout.sync = true
10
12
 
11
- @remote_reader = STDIN
12
- @remote_writer = STDOUT
13
+ @remote_reader = $stdin
14
+ @remote_writer = $stdout
13
15
  $stderr.reopen(File.join(Entangler::Logger.log_file_path(base_dir, 'entangler.err')), 'w')
14
16
  end
15
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Entangler
2
4
  module Executor
3
5
  module Validation
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Entangler
2
4
  module Executor
3
5
  module Validation
@@ -21,8 +23,10 @@ module Entangler
21
23
  unless File.directory?(@opts[:remote_base_dir])
22
24
  raise Entangler::ValidationError, 'Destination directory is a file'
23
25
  end
26
+
24
27
  @opts[:remote_base_dir] = File.realpath(File.expand_path(@opts[:remote_base_dir]))
25
28
  return unless @opts[:remote_base_dir] == base_dir
29
+
26
30
  raise Entangler::ValidationError, "Destination directory can't be the same as the base directory"
27
31
  end
28
32
 
@@ -31,6 +35,7 @@ module Entangler
31
35
  raise Entangler::ValidationError, 'Missing remote base dir' unless keys.include?(:remote_base_dir)
32
36
  raise Entangler::ValidationError, 'Missing remote user' unless keys.include?(:remote_user)
33
37
  raise Entangler::ValidationError, 'Missing remote host' unless keys.include?(:remote_host)
38
+
34
39
  validate_remote_base_dir
35
40
  validate_remote_entangler_version
36
41
  end
@@ -43,10 +48,12 @@ module Entangler
43
48
 
44
49
  def validate_remote_entangler_version
45
50
  return unless @opts[:remote_mode]
51
+
46
52
  res = `#{generate_ssh_command('source ~/.rvm/environments/default && entangler --version')}`
47
53
  remote_version = Gem::Version.new(res.strip)
48
54
  local_version = Gem::Version.new(Entangler::VERSION)
49
55
  return unless major_version_mismatch?(local_version, remote_version)
56
+
50
57
  msg = 'Entangler version too far apart, please update either local or remote Entangler.' \
51
58
  " Local version is #{local_version} and remote version is #{remote_version}."
52
59
  raise Entangler::VersionMismatchError, msg
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
  require 'logger'
3
5
 
@@ -11,7 +13,7 @@ module Entangler
11
13
  File.join(base_dir, '.entangler', 'log', log_file_name)
12
14
  end
13
15
 
14
- def initialize(outputs, verbose = false)
16
+ def initialize(outputs, verbose: false)
15
17
  @loggers = Array(outputs).map do |output|
16
18
  logger = ::Logger.new(output)
17
19
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Entangler
2
- VERSION = '1.1.1'.freeze
4
+ VERSION = '1.2.2'
3
5
  end
data/lib/entangler.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'entangler/version'
2
4
  require_relative 'entangler/errors'
3
5
  require_relative 'entangler/logger'
metadata CHANGED
@@ -1,99 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Allie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-06 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 13.0.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 13.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - "~>"
32
60
  - !ruby/object:Gem::Version
33
- version: '10.0'
61
+ version: '1.6'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: '10.0'
68
+ version: '1.6'
41
69
  - !ruby/object:Gem::Dependency
42
- name: rspec
70
+ name: rubocop-rake
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
73
  - - "~>"
46
74
  - !ruby/object:Gem::Version
47
- version: '3.0'
75
+ version: 0.5.1
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: '3.0'
82
+ version: 0.5.1
55
83
  - !ruby/object:Gem::Dependency
56
- name: rubocop
84
+ name: rubocop-rspec
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: 0.49.1
89
+ version: '2.0'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: 0.49.1
96
+ version: '2.0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: listen
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '3.1'
103
+ version: '3.7'
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '3.1'
110
+ version: '3.7'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: to_regexp
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: 0.2.0
117
+ version: 0.2.1
90
118
  type: :runtime
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: 0.2.0
124
+ version: 0.2.1
97
125
  description: Two way file syncer using platform native notify.
98
126
  email:
99
127
  - dave@daveallie.com
@@ -133,15 +161,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
161
  requirements:
134
162
  - - ">="
135
163
  - !ruby/object:Gem::Version
136
- version: '0'
164
+ version: '2.5'
137
165
  required_rubygems_version: !ruby/object:Gem::Requirement
138
166
  requirements:
139
167
  - - ">="
140
168
  - !ruby/object:Gem::Version
141
169
  version: '0'
142
170
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.6.12
171
+ rubygems_version: 3.0.3.1
145
172
  signing_key:
146
173
  specification_version: 4
147
174
  summary: Two way file syncer using platform native notify.