vagrant-vaimo-unison 1.1.2 → 2.0.0

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: 4ebcf4087c4bb4a894b49a7f35964f27fd78cbc6
4
- data.tar.gz: 5f915685226d238aea73b79dbf75baaa581a6015
3
+ metadata.gz: c7f7c7b8e8b09e06d91b2ac37bebd6f985024935
4
+ data.tar.gz: 3e363ea9c5cce5dc7fc601262682a14e407b6646
5
5
  SHA512:
6
- metadata.gz: a5a2a042c45de58c946dd528eadded0c88568455b0b32b24f16abb70c472c9e94f884ef4dbf8ece906a017872c7e7149a3fd6f6b8700f88aacf39ee5aaf4ee93
7
- data.tar.gz: ed874f13de4afe52bd96d85e312f88d25d19584354aea586cc4ed77b92dcc6ac23a645713ea560230a95c138bcc3566c8861b3db09c6ce2059e0b95badfc6aa3
6
+ metadata.gz: 5809cee217026ff63da55ecc006b226e50318a359ba6958a69bc647aff04fa36172be50874c936f7fe7016cc4d40ad706817d5b7b086b25fefa31611ade13256
7
+ data.tar.gz: 0038097598f920b3b513f9d3ea5133d4e2f35d295efb90e7d3d38e6de1412f4b08fc53bf8c75f37318546f126c3f8eefb6604aa186e8e72d1b4243425c106e9a
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Vagrant Unison 2 Plugin
2
2
 
3
- This is a [Vagrant](http://www.vagrantup.com) 1.7+ plugin that syncs files over SSH from a local folder
3
+ This is a [Vagrant](http://www.vagrantup.com) 2.0+ plugin that syncs files over SSH from a local folder
4
4
  to your Vagrant VM (local or on AWS). Under the covers it uses [Unison](http://www.cis.upenn.edu/~bcpierce/unison/)
5
5
 
6
- **NOTE:** This plugin requires Vagrant 1.9+,
6
+ **NOTE:** This plugin requires Vagrant 2.0+
7
+
8
+ **INFO:** This plugin is based on [vagrant-unison by Danny Cosson](https://github.com/dcosson/vagrant-unison2)
7
9
 
8
10
  ## Features
9
11
 
@@ -12,8 +14,10 @@ to your Vagrant VM (local or on AWS). Under the covers it uses [Unison](http://
12
14
  ## Usage
13
15
 
14
16
  1. You must already have [Unison](http://www.cis.upenn.edu/~bcpierce/unison/) installed on your path on your host and guest machines, and it must be the same version of Unison on both.
15
- * On Mac you can install this with Homebrew: `brew install unison`
16
- * This will install unison 2.48.3
17
+ * On Mac you can install this with Homebrew:
18
+ * `brew tap eugenmayer/dockersync`
19
+ * `brew install unison eugenmayer/dockersync/unox`
20
+ * This will install unison 2.48.3
17
21
  * On Ubuntu:
18
22
  * [Xenial (16.04)](https://launchpad.net/ubuntu/xenial/+source/unison): `sudo apt-get install unison`
19
23
  * Ubuntu Trusty (14.04):
@@ -24,7 +28,7 @@ to your Vagrant VM (local or on AWS). Under the covers it uses [Unison](http://
24
28
  * Install package from `http://ftp5.gwdg.de/pub/linux/archlinux/extra/os/x86_64/unison-2.48.3-2-x86_64.pkg.tar.xz`. (Install at your own risk, this is a plain http link. If someone knows of a signed version, checksum, or https host let me know so I can update it).
25
29
  * On Windows, download [2.48.3](http://www.pps.univ-paris-diderot.fr/~vouillon/unison/unison 2.48.3.zip), unzip, rename `unison-2.48.3 text.exe` to `unison.exe` and copy to somewhere in your path. Alternatively, install [using Chocolatey](https://chocolatey.org/packages/unison).
26
30
 
27
- 2. Install using standard Vagrant 1.1+ plugin installation methods.
31
+ 2. Install using standard Vagrant 2.0+ plugin installation methods.
28
32
  * `vagrant plugin install vagrant-vaimo-unison`
29
33
 
30
34
  3. Configure unison in your Vagrantfile, as shown below.
@@ -56,7 +60,7 @@ to your Vagrant VM (local or on AWS). Under the covers it uses [Unison](http://
56
60
 
57
61
  # `vagrant unison-sync-polling` command will restart unison in VM if memory
58
62
  # usage gets above this threshold (in MB).
59
- config.unison.mem_cap_mb = 500 # Default: 200
63
+ config.unison.mem_cap_mb = 400 # Default: 500
60
64
 
61
65
  # Change polling interval (in seconds) at which to sync changes
62
66
  config.unison.repeat = 5 # Default: 1
@@ -65,7 +69,7 @@ to your Vagrant VM (local or on AWS). Under the covers it uses [Unison](http://
65
69
 
66
70
  ## Start syncing/watching Folders
67
71
 
68
- Run `vagrant unison-sync` to run polling (will sync files from host to guest if changes are made)
72
+ Run `vagrant unison-sync` to start the unison process, on the first step it will start the main sync to get your sync folder to host and guest and then the polling process will start
69
73
 
70
74
  ## Sync in interactive mode
71
75
 
@@ -138,17 +142,18 @@ See [perms documentation](http://www.cis.upenn.edu/~bcpierce/unison/download/rel
138
142
 
139
143
  ## Development
140
144
 
141
- To work on the `vagrant-unison` plugin, clone this repository out, and use
142
- [Bundler](http://gembundler.com) to get the dependencies:
145
+ When using ubuntu for development and testing then be sure to install ruby-dev
143
146
 
144
147
  ```
145
- $ bundle
148
+ $ sudo apt-get install ruby-dev
149
+ $ sudo gem install bundle
146
150
  ```
147
151
 
148
- When using devbox for development and testing then be sure to install ruby-dev
152
+ To work on the `vagrant-vaimo-unison` plugin, clone this repository out, and use
153
+ [Bundler](http://gembundler.com) to get the dependencies:
149
154
 
150
155
  ```
151
- $ sudo apt-get install ruby-dev
156
+ $ bundle
152
157
  ```
153
158
 
154
159
  Once you have the dependencies, verify the unit tests pass with `rake`:
@@ -179,5 +184,5 @@ rake build
179
184
  Now you'll see the built gem in a pkg directory. Install it with
180
185
 
181
186
  ```
182
- vagrant plugin install pkg/vagrant-unison-VERSION.gem
187
+ vagrant plugin install pkg/vagrant-vaimo-unison-VERSION.gem
183
188
  ```
@@ -4,6 +4,7 @@ require 'vagrant-vaimo-unison/plugin'
4
4
  require 'vagrant-vaimo-unison/errors'
5
5
 
6
6
  module VagrantPlugins
7
+ # Unison
7
8
  module Unison
8
9
  # This returns the path to the source of this plugin.
9
10
  #
@@ -9,6 +9,7 @@ require_relative 'unison_sync'
9
9
 
10
10
  module VagrantPlugins
11
11
  module Unison
12
+ # Command Sync
12
13
  class CommandSync < Vagrant.plugin('2', :command)
13
14
  include UnisonSync
14
15
  attr_accessor :bg_thread
@@ -19,7 +20,7 @@ module VagrantPlugins
19
20
 
20
21
  def execute
21
22
  sync_once
22
- sync_polling
23
+ sync_polling unless options[:no_polling]
23
24
  end
24
25
 
25
26
  def sync_once
@@ -67,7 +68,7 @@ module VagrantPlugins
67
68
  # If INT comes in after we've respanwned,
68
69
  # will bring us back to this trap handler.
69
70
  exit_on_next_sigint = false
70
- while true
71
+ loop do
71
72
  begin
72
73
  sleep 2 if exit_on_next_sigint
73
74
  exit_on_next_sigint = false
@@ -80,8 +81,8 @@ module VagrantPlugins
80
81
  end
81
82
  @env.ui.info '** Hit Ctrl + C again to kill. **'
82
83
  exit_on_next_sigint = true
83
- rescue Exception
84
- @env.ui.info '** Sync crashed. Respawning. Hit Ctrl + C twice to kill. **'
84
+ rescue StandardError
85
+ @env.ui.info '** Sync crashed. Restarting. Hit Ctrl + C twice to kill. **'
85
86
  end
86
87
  end
87
88
  end
@@ -94,7 +95,7 @@ module VagrantPlugins
94
95
  def watch_vm_for_memory_leak(machine)
95
96
  ssh_command = SshCommand.new(machine, options)
96
97
  Thread.new(ssh_command.ssh, machine.config.unison.mem_cap_mb) do |ssh_command_text, mem_cap_mb|
97
- while true
98
+ loop do
98
99
  sleep 15
99
100
  total_mem = `#{ssh_command_text} 'free -m | egrep "^Mem:" | awk "{print \\$2}"' 2>/dev/null`
100
101
  unison_proc_returnval = `#{ssh_command_text} 'ps aux | grep "[u]nison -server" | awk "{print \\$2, \\$4}"' 2>/dev/null`
@@ -117,31 +118,7 @@ module VagrantPlugins
117
118
  end
118
119
  end
119
120
 
120
- class CommandOnce < Vagrant.plugin('2', :command)
121
- include UnisonSync
122
-
123
- def self.synopsis
124
- 'sync the unison shared folder once (deprecated)'
125
- end
126
-
127
- def execute
128
- @env.ui.info 'The command is deprecated, use vagrant unison-sync --no-polling'
129
- end
130
- end
131
-
132
- class CommandPolling < Vagrant.plugin('2', :command)
133
- include UnisonSync
134
- attr_accessor :bg_thread
135
-
136
- def self.synopsis
137
- 'sync the unison shared folder forever, by polling for changes (deprecated)'
138
- end
139
-
140
- def execute
141
- @env.ui.info 'The command is deprecated, use vagrant unison-sync'
142
- end
143
- end
144
-
121
+ # Command Cleanup
145
122
  class CommandCleanup < Vagrant.plugin('2', :command)
146
123
  def self.synopsis
147
124
  'Remove archives and configuration from host and guest. Keeps files in guest (need to remove manually if needed)'
@@ -150,11 +127,11 @@ module VagrantPlugins
150
127
  def execute
151
128
  with_target_vms do |machine|
152
129
  command = "rm -rf ~/Library/'Application Support'/Unison/*"
153
- @env.ui.info "Running #{command} on host"
130
+ @env.ui.info "Running #{command} on host" if options[:verbose]
154
131
  system(command)
155
132
 
156
133
  command = 'rm -rf ~/.unison'
157
- @env.ui.info "Running #{command} on guest VM"
134
+ @env.ui.info "Running #{command} on guest VM" if options[:verbose]
158
135
  machine.communicate.execute(command)
159
136
  end
160
137
 
@@ -162,6 +139,7 @@ module VagrantPlugins
162
139
  end
163
140
  end
164
141
 
142
+ # Command Interact
165
143
  class CommandInteract < Vagrant.plugin('2', :command)
166
144
  include UnisonSync
167
145
 
@@ -175,7 +153,7 @@ module VagrantPlugins
175
153
  command.terse = true
176
154
  command = command.to_s
177
155
 
178
- @env.ui.info "Running #{command}"
156
+ @env.ui.info "Running #{command}" if options[:verbose]
179
157
 
180
158
  system(command)
181
159
  end
@@ -1,7 +1,10 @@
1
1
  require 'vagrant'
2
2
 
3
+ UNSET_VALUE = nil
4
+
3
5
  module VagrantPlugins
4
6
  module Unison
7
+ # Config
5
8
  class Config < Vagrant.plugin('2', :config)
6
9
  # Host Folder to Sync
7
10
  #
@@ -60,7 +63,7 @@ module VagrantPlugins
60
63
  # @return [Boolean]
61
64
  attr_accessor :ssh_use_agent
62
65
 
63
- def initialize(region_specific = false)
66
+ def initialize
64
67
  @host_folder = UNSET_VALUE
65
68
  @guest_folder = UNSET_VALUE
66
69
  @ignore = UNSET_VALUE
@@ -92,7 +95,7 @@ module VagrantPlugins
92
95
  @__finalized = true
93
96
  end
94
97
 
95
- def validate(machine)
98
+ def validate
96
99
  errors = []
97
100
 
98
101
  unless @host_folder.nil? && @guest_folder.nil?
@@ -100,7 +103,7 @@ module VagrantPlugins
100
103
  errors << I18n.t('vagrant_unison.config.unison_guest_folder_required') if @guest_folder.nil?
101
104
  end
102
105
 
103
- { 'Unison' => errors }
106
+ {'Unison' => errors}
104
107
  end
105
108
  end
106
109
  end
@@ -2,6 +2,7 @@ require 'vagrant'
2
2
 
3
3
  module Vagrant
4
4
  module Errors
5
+ # UnisonError
5
6
  class UnisonError < VagrantError
6
7
  error_key(:unison_error, 'vagrant_unison.errors')
7
8
  end
@@ -6,12 +6,13 @@ end
6
6
 
7
7
  # This is a sanity check to make sure no one is attempting to install
8
8
  # this into an early Vagrant version.
9
- if Vagrant::VERSION < '1.9.0'
10
- raise 'The vagrant-unison plugin is only compatible with Vagrant 1.9+'
9
+ if Vagrant::VERSION < '2.0.0'
10
+ raise 'The vagrant-unison plugin is only compatible with Vagrant 2.0+'
11
11
  end
12
12
 
13
13
  module VagrantPlugins
14
14
  module Unison
15
+ # Unison Plugin
15
16
  class Plugin < Vagrant.plugin('2')
16
17
  name 'Unison'
17
18
  description <<-DESC
@@ -25,50 +26,31 @@ module VagrantPlugins
25
26
  end
26
27
 
27
28
  command 'unison-sync' do
29
+ # Setup logging and i18n
28
30
  setup_logging
29
31
  setup_i18n
30
32
 
31
- #Return the command
33
+ # Return the command
32
34
  require_relative 'command'
33
35
  CommandSync
34
36
  end
35
37
 
36
- command 'unison-sync-once' do
37
- setup_logging
38
- setup_i18n
39
-
40
- #Return the command
41
- require_relative 'command'
42
- CommandOnce
43
- end
44
-
45
38
  command 'unison-sync-interact' do
46
39
  # Setup logging and i18n
47
40
  setup_logging
48
41
  setup_i18n
49
42
 
50
- #Return the command
43
+ # Return the command
51
44
  require_relative 'command'
52
45
  CommandInteract
53
46
  end
54
47
 
55
-
56
- command 'unison-sync-polling' do
57
- # Setup logging and i18n
58
- setup_logging
59
- setup_i18n
60
-
61
- #Return the command
62
- require_relative 'command'
63
- CommandPolling
64
- end
65
-
66
48
  command 'unison-cleanup' do
67
49
  # Setup logging and i18n
68
50
  setup_logging
69
51
  setup_i18n
70
52
 
71
- #Return the command
53
+ # Return the command
72
54
  require_relative 'command'
73
55
  CommandCleanup
74
56
  end
@@ -1,5 +1,6 @@
1
1
  module VagrantPlugins
2
2
  module Unison
3
+ # ShellCommand
3
4
  class ShellCommand
4
5
  def initialize(machine, unison_paths, ssh_command)
5
6
  @machine = machine
@@ -26,20 +27,12 @@ module VagrantPlugins
26
27
  private
27
28
 
28
29
  def args
29
- _args = [
30
- 'unison',
31
- local_root_arg,
32
- remote_root_arg,
33
- batch_arg,
34
- terse_arg,
35
- repeat_arg,
36
- ignore_arg,
37
- ignorenot_arg,
38
- perms_arg,
39
- force_arg,
40
- prefer_arg,
41
- ssh_args,
42
- ].flatten.compact
30
+ _args = ['unison',
31
+ local_root_arg, remote_root_arg,
32
+ batch_arg, terse_arg, repeat_arg, perms_arg,
33
+ ignore_arg, ignorenot_arg,
34
+ force_arg, prefer_arg,
35
+ ssh_args].flatten.compact
43
36
  end
44
37
 
45
38
  def local_root_arg
@@ -59,27 +52,15 @@ module VagrantPlugins
59
52
  end
60
53
 
61
54
  def ignore_arg
62
- patterns = []
63
- if @machine.config.unison.ignore.is_a? ::Array
64
- patterns += @machine.config.unison.ignore
65
- elsif @machine.config.unison.ignore
66
- patterns << @machine.config.unison.ignore
67
- end
68
-
69
- patterns.map do |pattern|
55
+ ignore = @machine.config.unison.ignore
56
+ patterns_from_config(ignore).map do |pattern|
70
57
  ['-ignore', %("#{pattern}")]
71
58
  end
72
59
  end
73
60
 
74
61
  def ignorenot_arg
75
- patterns = []
76
- if @machine.config.unison.ignorenot.is_a? ::Array
77
- patterns += @machine.config.unison.ignorenot
78
- elsif @machine.config.unison.ignorenot
79
- patterns << @machine.config.unison.ignorenot
80
- end
81
-
82
- patterns.map do |pattern|
62
+ ignorenot = @machine.config.unison.ignorenot
63
+ patterns_from_config(ignorenot).map do |pattern|
83
64
  ['-ignorenot', %("#{pattern}")]
84
65
  end
85
66
  end
@@ -126,6 +107,17 @@ module VagrantPlugins
126
107
  return ['-prefer', local_root_arg] if prefer_local
127
108
  ['-prefer', remote_root_arg] if prefer_remote
128
109
  end
110
+
111
+ def patterns_from_config(data)
112
+ patterns = []
113
+ if data.is_a? ::Array
114
+ patterns += data
115
+ elsif data
116
+ patterns << data
117
+ end
118
+
119
+ patterns
120
+ end
129
121
  end
130
122
  end
131
123
  end
@@ -7,25 +7,17 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def ssh
10
- %W(
11
- ssh
12
- #{@machine.config.unison.ssh_user}@#{@machine.config.unison.ssh_host}
13
- #{ssh_args}
14
- ).compact.join(' ')
10
+ %W[ssh #{ssh_auth} #{ssh_args}].compact.join(' ')
15
11
  end
16
12
 
17
13
  def ssh_args
18
- log_line = ''
19
- log_line = '-o LogLevel=quiet' unless @options[:verbose]
20
-
21
- %W(
22
- -p #{@machine.config.unison.ssh_port}
23
- #{proxy_command}
24
- #{log_line}
25
- -o StrictHostKeyChecking=no
26
- -o UserKnownHostsFile=/dev/null
27
- #{identity}
28
- ).compact.join(' ')
14
+ %W[
15
+ #{ssh_port}
16
+ #{proxy_command}
17
+ #{ssh_log_options}
18
+ #{ssh_options}
19
+ #{identity}
20
+ ].compact.join(' ')
29
21
  end
30
22
 
31
23
  def uri(unison_paths)
@@ -37,6 +29,24 @@ module VagrantPlugins
37
29
 
38
30
  private
39
31
 
32
+ def ssh_auth
33
+ "#{@machine.config.unison.ssh_user}@#{@machine.config.unison.ssh_host}"
34
+ end
35
+
36
+ def ssh_port
37
+ "-p #{@machine.config.unison.ssh_port}"
38
+ end
39
+
40
+ def ssh_log_options
41
+ log_line = ''
42
+ log_line = '-o LogLevel=quiet' unless @options[:verbose]
43
+ log_line
44
+ end
45
+
46
+ def ssh_options
47
+ ' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
48
+ end
49
+
40
50
  def proxy_command
41
51
  command = @machine.ssh_info[:proxy_command]
42
52
  return nil unless command
@@ -47,12 +57,14 @@ module VagrantPlugins
47
57
  if @machine.config.unison.ssh_use_agent
48
58
  ''
49
59
  else
50
- (%w(-o IdentitiesOnly=yes) << key_paths).join(' ')
60
+ (%w[-o IdentitiesOnly=yes] << key_paths).join(' ')
51
61
  end
52
62
  end
53
63
 
54
64
  def key_paths
55
- @machine.ssh_info[:private_key_path].map { |p| "-i #{p.shellescape}" }.join(' ')
65
+ @machine.ssh_info[:private_key_path].map { |p|
66
+ "-i #{p.shellescape}"
67
+ }.join(' ')
56
68
  end
57
69
  end
58
70
  end
@@ -1,5 +1,6 @@
1
1
  module VagrantPlugins
2
2
  module Unison
3
+ # UnisonPaths
3
4
  class UnisonPaths
4
5
  def initialize(env, machine, project = '')
5
6
  @env = env
@@ -17,7 +18,7 @@ module VagrantPlugins
17
18
 
18
19
  # Make sure there is a trailing slash on the host path to
19
20
  # avoid creating an additional directory with rsync
20
- path = "#{path}/#{@project}" if path !~ /\/$/
21
+ "#{path}/#{@project}" if path !~ /\/$/
21
22
  end
22
23
  end
23
24
  end
@@ -7,22 +7,30 @@ module VagrantPlugins
7
7
  def execute_sync_command(machine)
8
8
  parse_options!
9
9
 
10
- return unless machine.config.unison.host_folder
10
+ return 0 if machine.config.unison.host_folder.nil?
11
11
 
12
12
  unison_paths = UnisonPaths.new(@env, machine, options[:project])
13
13
 
14
+ startup_command(machine, unison_paths)
15
+
16
+ yield set_shell_command(machine, options, unison_paths)
17
+ end
18
+
19
+ def startup_command(machine, unison_paths)
14
20
  guest_path = unison_paths.guest
15
21
  host_path = unison_paths.host
16
-
17
- ssh_user = machine.config.unison.ssh_user
22
+ ssh_user = machine.config.unison.ssh_user
18
23
 
19
24
  @env.ui.info "Sync changes from {host}::#{host_path}"
20
25
  @env.ui.info " --> {guest VM}::#{guest_path}"
21
26
 
22
- # Create the guest path
27
+ # Create the guest and host path if they don't exists path
23
28
  machine.communicate.sudo("mkdir -p '#{guest_path}'")
24
29
  machine.communicate.sudo("chown #{ssh_user} '#{guest_path}'")
30
+ system("mkdir -p '#{host_path}'")
31
+ end
25
32
 
33
+ def set_shell_command(machine, options, unison_paths)
26
34
  ssh_command = SshCommand.new(machine, options)
27
35
  shell_command = ShellCommand.new(machine, unison_paths, ssh_command)
28
36
 
@@ -32,7 +40,7 @@ module VagrantPlugins
32
40
  shell_command.force_remote = options[:force_remote]
33
41
  shell_command.project = options[:project]
34
42
 
35
- yield shell_command
43
+ shell_command
36
44
  end
37
45
 
38
46
  def parse_options!
@@ -41,74 +49,81 @@ module VagrantPlugins
41
49
  # a binding.pry in here and then type `? parse_options`
42
50
  @parsed_argv ||= parse_options(options_parser)
43
51
 
44
- if options[:verbose]
45
- @env.ui.info "Options: #{options}"
46
- end
52
+ @env.ui.info "Options: #{options}" if options[:verbose]
47
53
 
48
54
  # According to the docs:
49
55
  # > If parse_options returns `nil`, then you should assume that
50
56
  # > help was printed and parsing failed.
51
- if @parsed_argv == nil
52
- exit 1
53
- end
57
+ exit 1 if @parsed_argv.nil?
54
58
  end
55
59
 
56
60
  def options
57
- @options ||= {
58
- :prefer_local => false,
59
- :prefer_remote => false,
60
- :force_local => false,
61
- :force_remote => false,
62
- :verbose => false,
63
- :project => nil,
64
- :no_polling => false
65
- }
61
+ @options ||= { prefer_local: false,
62
+ prefer_remote: false,
63
+ force_local: false,
64
+ force_remote: false,
65
+ verbose: false,
66
+ project: nil,
67
+ no_polling: false }
66
68
  end
67
69
 
68
70
  def options_parser
69
71
  @option_parser ||= OptionParser.new do |o|
70
72
  o.banner = "Usage: vagrant #{ARGV[0]} [options]"
73
+ options_pull_flags(o)
74
+ options_push_flags(o)
75
+ options_optional_flags(o)
76
+ options_optional_values(o)
77
+ end
78
+ end
79
+
80
+ def options_optional_flags(o)
81
+ # Coming soon
82
+ # o.on('--no-polling', 'trigger sync without starting the polling process') do |flag|
83
+ # options[:no_polling] = flag
84
+ # end
85
+
86
+ o.on('--verbose', 'print additional debug information') do |flag|
87
+ options[:verbose] = flag
88
+ end
89
+ end
90
+
91
+ def options_optional_values(o)
92
+ o.on('-p', '--project=project', 'project folder to sync') do |project|
93
+ options[:project] = project
94
+ end
95
+ end
96
+
97
+ def options_pull_flags(o)
98
+ o.on('--pull', 'prefer changes on the remote machine.') do |flag|
99
+ options[:prefer_remote] = flag
100
+ check_conflicting_options!
101
+ end
102
+
103
+ o.on('--force-pull', 'force-pull changes from the remote machine. Super dangerous!') do |flag|
104
+ options[:force_remote] = flag
105
+ check_conflicting_options!
106
+ end
107
+ end
108
+
109
+ def options_push_flags(o)
110
+ o.on('--push', 'prefer changes on the local machine.') do |flag|
111
+ options[:prefer_local] = flag
112
+ check_conflicting_options!
113
+ end
71
114
 
72
- # o.on('--no-polling', 'trigger sync without starting the polling process') do |flag|
73
- # options[:no_polling] = flag
74
- # end
75
-
76
- o.on('--push', 'prefer changes on the local machine.') do |flag|
77
- options[:prefer_local] = flag
78
- check_conflicting_options!
79
- end
80
-
81
- o.on('--pull', 'prefer changes on the remote machine.') do |flag|
82
- options[:prefer_remote] = flag
83
- check_conflicting_options!
84
- end
85
-
86
- o.on('--force-push', 'force-push changes to the remote machine. Dangerous!') do |flag|
87
- options[:force_local] = flag
88
- check_conflicting_options!
89
- end
90
-
91
- o.on('--force-pull', 'force-pull changes from the remote machine. Super dangerous!') do |flag|
92
- options[:force_remote] = flag
93
- check_conflicting_options!
94
- end
95
-
96
- o.on('--verbose', 'print additional debug information') do |flag|
97
- options[:verbose] = flag
98
- end
99
-
100
- o.on('-p', '--project=project', 'project folder to sync') do |project|
101
- options[:project] = project
102
- end
115
+ o.on('--force-push', 'force-push changes to the remote machine. Dangerous!') do |flag|
116
+ options[:force_local] = flag
117
+ check_conflicting_options!
103
118
  end
104
119
  end
105
120
 
106
121
  def check_conflicting_options!
107
- enabled = [:prefer_local, :prefer_remote, :force_local, :force_remote].select do |opt|
122
+ enabled = %i[prefer_local prefer_remote force_local force_remote].select do |opt|
108
123
  options[opt]
109
124
  end
110
125
 
111
- raise ArgumentError.new("Conflicting options: #{enabled.inspect}") if enabled.length > 1
126
+ raise ArgumentError, "Conflicting options: #{enabled.inspect}" if enabled.length > 1
112
127
  end
113
128
  end
114
129
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Unison
3
- VERSION = '1.1.2'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -6,11 +6,11 @@ Gem::Specification.new do |s|
6
6
  s.name = 'vagrant-vaimo-unison'
7
7
  s.version = VagrantPlugins::Unison::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ['David Laing', 'dmatora', 'Danny Cosson', 'Platform Team @ Vaimo']
9
+ s.authors = ['Platform Team @ Vaimo']
10
10
  s.email = 'platform@vaimo.com'
11
11
  s.homepage = 'https://bitbucket.org/vaimo/vagrant-vaimo-unison'
12
12
  s.summary = 'Vagrant plugin to sync local files to VM over SSH using Unison'
13
- s.description = 'Vagrant 1.9+ plugin to sync local files to VM over SSH using Unison'
13
+ s.description = 'Vagrant 2.0+ plugin to sync local files to VM over SSH using Unison'
14
14
 
15
15
  s.required_rubygems_version = '>= 1.3.6'
16
16
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  # the "!" syntax, but it should mostly work correctly.
27
27
  root_path = File.dirname(__FILE__)
28
28
  all_files = Dir.chdir(root_path) { Dir.glob('**/{*,.*}') }
29
- all_files.reject! { |file| %w(. ..).include?(File.basename(file)) }
29
+ all_files.reject! { |file| %w[. ..].include?(File.basename(file)) }
30
30
  gitignore_path = File.join(root_path, '.gitignore')
31
31
  gitignore = File.readlines(gitignore_path)
32
32
  gitignore.map! { |line| line.chomp.strip }
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
46
46
  #
47
47
  gitignore.any? do |ignore|
48
48
  File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
49
- File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
49
+ File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
50
50
  end
51
51
  end
52
52
 
metadata CHANGED
@@ -1,12 +1,9 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vaimo-unison
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - David Laing
8
- - dmatora
9
- - Danny Cosson
10
7
  - Platform Team @ Vaimo
11
8
  autorequire:
12
9
  bindir: bin
@@ -69,7 +66,7 @@ dependencies:
69
66
  - - "~>"
70
67
  - !ruby/object:Gem::Version
71
68
  version: 2.12.1
72
- description: Vagrant 1.9+ plugin to sync local files to VM over SSH using Unison
69
+ description: Vagrant 2.0+ plugin to sync local files to VM over SSH using Unison
73
70
  email: platform@vaimo.com
74
71
  executables: []
75
72
  extensions: []