vagrant-unison 0.0.4 → 0.0.5
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.
- data/lib/vagrant-unison/command.rb +49 -27
- data/lib/vagrant-unison/version.rb +1 -1
- data/vagrant-unison.gemspec +2 -1
- metadata +21 -5
@@ -1,15 +1,33 @@
|
|
1
1
|
require "log4r"
|
2
2
|
require "vagrant"
|
3
|
+
require 'listen'
|
3
4
|
|
4
5
|
module VagrantPlugins
|
5
6
|
module Unison
|
6
7
|
class Command < Vagrant.plugin("2", :command)
|
8
|
+
|
7
9
|
def execute
|
8
|
-
|
10
|
+
|
9
11
|
with_target_vms do |machine|
|
12
|
+
hostpath, guestpath = init_paths machine
|
13
|
+
|
14
|
+
trigger_unison_sync machine
|
15
|
+
|
16
|
+
@env.ui.info "Watching #{hostpath} for changes..."
|
17
|
+
|
18
|
+
Listen.to(hostpath) do |modified, added, removed|
|
19
|
+
@env.ui.info "Detected modifications to #{modified.inspect}" unless modified.empty?
|
20
|
+
@env.ui.info "Detected new files #{added.inspect}" unless added.empty?
|
21
|
+
@env.ui.info "Detected deleted files #{removed.inspect}" unless removed.empty?
|
22
|
+
|
23
|
+
trigger_unison_sync machine
|
24
|
+
end
|
25
|
+
end
|
10
26
|
|
11
|
-
|
27
|
+
0 #all is well
|
28
|
+
end
|
12
29
|
|
30
|
+
def init_paths(machine)
|
13
31
|
hostpath = File.expand_path(machine.config.sync.host_folder, @env.root_path)
|
14
32
|
guestpath = machine.config.sync.guest_folder
|
15
33
|
|
@@ -17,33 +35,37 @@ module VagrantPlugins
|
|
17
35
|
# avoid creating an additional directory with rsync
|
18
36
|
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
|
19
37
|
|
20
|
-
|
21
|
-
|
22
|
-
# Create the guest path
|
23
|
-
#machine.communicate.sudo("mkdir -p '#{guestpath}'")
|
24
|
-
#machine.communicate.sudo("chown #{ssh_info[:username]} '#{guestpath}'")
|
25
|
-
|
26
|
-
# Unison over to the guest path using the SSH info
|
27
|
-
command = [
|
28
|
-
"unison", "-batch",
|
29
|
-
"-ignore=Name {git*,.vagrant/,*.DS_Store}",
|
30
|
-
"-sshargs", "-p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i #{ssh_info[:private_key_path]}",
|
31
|
-
hostpath,
|
32
|
-
"ssh://#{ssh_info[:username]}@#{ssh_info[:host]}/#{guestpath}"
|
33
|
-
]
|
34
|
-
|
35
|
-
r = Vagrant::Util::Subprocess.execute(*command)
|
36
|
-
if r.exit_code != 0
|
37
|
-
raise Vagrant::Errors::UnisonError,
|
38
|
-
:command => command.inspect,
|
39
|
-
:guestpath => guestpath,
|
40
|
-
:hostpath => hostpath,
|
41
|
-
:stderr => r.stderr
|
42
|
-
end
|
38
|
+
[hostpath, guestpath]
|
39
|
+
end
|
43
40
|
|
44
|
-
|
41
|
+
def trigger_unison_sync(machine)
|
42
|
+
hostpath, guestpath = init_paths machine
|
43
|
+
|
44
|
+
@env.ui.info "Unisoning changes from {host}::#{hostpath} --> {guest VM}::#{guestpath}"
|
45
|
+
|
46
|
+
ssh_info = machine.ssh_info
|
45
47
|
|
46
|
-
|
48
|
+
# Create the guest path
|
49
|
+
machine.communicate.sudo("mkdir -p '#{guestpath}'")
|
50
|
+
machine.communicate.sudo("chown #{ssh_info[:username]} '#{guestpath}'")
|
51
|
+
|
52
|
+
# Unison over to the guest path using the SSH info
|
53
|
+
command = [
|
54
|
+
"unison", "-batch",
|
55
|
+
"-ignore=Name {git*,.vagrant/,*.DS_Store}",
|
56
|
+
"-sshargs", "-p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i #{ssh_info[:private_key_path]}",
|
57
|
+
hostpath,
|
58
|
+
"ssh://#{ssh_info[:username]}@#{ssh_info[:host]}/#{guestpath}"
|
59
|
+
]
|
60
|
+
|
61
|
+
r = Vagrant::Util::Subprocess.execute(*command)
|
62
|
+
if r.exit_code != 0
|
63
|
+
raise Vagrant::Errors::UnisonError,
|
64
|
+
:command => command.inspect,
|
65
|
+
:guestpath => guestpath,
|
66
|
+
:hostpath => hostpath,
|
67
|
+
:stderr => r.stderr
|
68
|
+
end
|
47
69
|
end
|
48
70
|
|
49
71
|
end
|
data/vagrant-unison.gemspec
CHANGED
@@ -13,7 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
15
|
|
16
|
-
s.add_runtime_dependency "
|
16
|
+
s.add_runtime_dependency "listen", "~> 0.7.3"
|
17
|
+
s.add_runtime_dependency "rb-fsevent", "~> 0.9"
|
17
18
|
|
18
19
|
s.add_development_dependency "rake"
|
19
20
|
s.add_development_dependency "rspec-core", "~> 2.12.2"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-unison
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,13 +12,13 @@ cert_chain: []
|
|
12
12
|
date: 2013-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: listen
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.7.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,23 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.7.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rb-fsevent
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0.9'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.9'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rake
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
142
|
version: '0'
|
127
143
|
segments:
|
128
144
|
- 0
|
129
|
-
hash: -
|
145
|
+
hash: -4193190591169953002
|
130
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
147
|
none: false
|
132
148
|
requirements:
|