vagrant-unify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +9 -0
- data/LICENSE +8 -0
- data/README.md +35 -0
- data/lib/vagrant-unify.rb +12 -0
- data/lib/vagrant-unify/command-pull.rb +47 -0
- data/lib/vagrant-unify/command-push.rb +47 -0
- data/lib/vagrant-unify/command-sync.rb +47 -0
- data/lib/vagrant-unify/config.rb +17 -0
- data/lib/vagrant-unify/errors.rb +12 -0
- data/lib/vagrant-unify/helper.rb +197 -0
- data/lib/vagrant-unify/plugin.rb +75 -0
- data/lib/vagrant-unify/version.rb +5 -0
- data/locales/en.yml +50 -0
- data/vagrant-unify.gemspec +50 -0
- metadata +81 -0
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2013 Mitchell Hashimoto
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Vagrant Unify Plugin
|
2
|
+
|
3
|
+
This is a [Vagrant](http://www.vagrantup.com) 1.5+ plugin liberally copy-and-paste'd from
|
4
|
+
the [vagrant-unison](https://github.com/mrdavidlaing/vagrant-unison) plugin and
|
5
|
+
Vagrant's own rsync plugin. It allows you to configure a set of folders to synchronize
|
6
|
+
with Unison or RSync but without the on-startup and automatic sync features of Vagrant's
|
7
|
+
synchronized folders and the Unison plugin.
|
8
|
+
|
9
|
+
**NOTE:** This plugin requires Vagrant 1.5+.
|
10
|
+
|
11
|
+
**NOTE:** In order to use the unify-sync command the [Unison](http://www.cis.upenn.edu/~bcpierce/unison/)
|
12
|
+
application must be installed on both the host and guest machines and available on the PATH as `unison`.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Install using standard Vagrant 1.1+ plugin installation methods.
|
17
|
+
```
|
18
|
+
$ vagrant plugin install vagrant-unify
|
19
|
+
```
|
20
|
+
After installing, edit your Vagrantfile and add a configuration directive similar to the below:
|
21
|
+
```
|
22
|
+
Vagrant.configure("2") do |config|
|
23
|
+
config.vm.box = "dummy"
|
24
|
+
config.unify.unify_folder "/home/myuser/project1", "/opt/project1"
|
25
|
+
config.unify.unify_folder "/home/myuser/git/project2", "/opt/project2", exclude: ".git*"
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## Syncing folders
|
30
|
+
|
31
|
+
Run `vagrant unify-pull` to rsync files from the guest to your local host.
|
32
|
+
|
33
|
+
Run `vagrant unify-push` to rsync files from your local host to the guest.
|
34
|
+
|
35
|
+
Run `vagrant unify-sync` to Unison files between your local host and the guest.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "log4r"
|
3
|
+
require "vagrant"
|
4
|
+
|
5
|
+
require_relative "helper"
|
6
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module Unify
|
9
|
+
class Command < Vagrant.plugin("2", :command)
|
10
|
+
def self.synopsis
|
11
|
+
I18n.t("vagrant_unify.pull.synopsis")
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
params = OptionParser.new do |o|
|
16
|
+
o.banner = "Usage: vagrant unify-pull [vm-name]"
|
17
|
+
o.separator ""
|
18
|
+
end
|
19
|
+
|
20
|
+
argv = parse_options(params)
|
21
|
+
return if !argv
|
22
|
+
|
23
|
+
error = false
|
24
|
+
with_target_vms do |machine|
|
25
|
+
if !machine.communicate.ready?
|
26
|
+
machine.ui.error(I18n.t("vagrant.rsync_communicator_not_ready"))
|
27
|
+
error = true
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
machine.config.unify.folders.each { |folder|
|
32
|
+
local_path = folder.fetch(0, nil)
|
33
|
+
remote_path = folder.fetch(1, nil)
|
34
|
+
opts = folder.fetch(2, {})
|
35
|
+
|
36
|
+
raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.local_path_required") if local_path.nil? or local_path.empty?
|
37
|
+
raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.remote_path_required") if remote_path.nil? or remote_path.empty?
|
38
|
+
|
39
|
+
UnifyHelper.rsync_single(:pull, machine, local_path, remote_path, opts)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
return error ? 1 : 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "log4r"
|
3
|
+
require "vagrant"
|
4
|
+
|
5
|
+
require_relative "helper"
|
6
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module Unify
|
9
|
+
class Command < Vagrant.plugin("2", :command)
|
10
|
+
def self.synopsis
|
11
|
+
I18n.t("vagrant_unify.push.synopsis")
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
params = OptionParser.new do |o|
|
16
|
+
o.banner = "Usage: vagrant unify-push [vm-name]"
|
17
|
+
o.separator ""
|
18
|
+
end
|
19
|
+
|
20
|
+
argv = parse_options(params)
|
21
|
+
return if !argv
|
22
|
+
|
23
|
+
error = false
|
24
|
+
with_target_vms do |machine|
|
25
|
+
if !machine.communicate.ready?
|
26
|
+
machine.ui.error(I18n.t("vagrant.rsync_communicator_not_ready"))
|
27
|
+
error = true
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
machine.config.unify.folders.each { |folder|
|
32
|
+
local_path = folder.fetch(0, nil)
|
33
|
+
remote_path = folder.fetch(1, nil)
|
34
|
+
opts = folder.fetch(2, {})
|
35
|
+
|
36
|
+
raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.local_path_required") if local_path.nil? or local_path.empty?
|
37
|
+
raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.remote_path_required") if remote_path.nil? or remote_path.empty?
|
38
|
+
|
39
|
+
UnifyHelper.rsync_single(:push, machine, local_path, remote_path, opts)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
return error ? 1 : 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "log4r"
|
3
|
+
require "vagrant"
|
4
|
+
|
5
|
+
require_relative "helper"
|
6
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module Unify
|
9
|
+
class Command < Vagrant.plugin("2", :command)
|
10
|
+
def self.synopsis
|
11
|
+
I18n.t("vagrant_unify.sync.synopsis")
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
params = OptionParser.new do |o|
|
16
|
+
o.banner = "Usage: vagrant unify-sync [vm-name]"
|
17
|
+
o.separator ""
|
18
|
+
end
|
19
|
+
|
20
|
+
argv = parse_options(params)
|
21
|
+
return if !argv
|
22
|
+
|
23
|
+
error = false
|
24
|
+
with_target_vms do |machine|
|
25
|
+
if !machine.communicate.ready?
|
26
|
+
machine.ui.error(I18n.t("vagrant.rsync_communicator_not_ready"))
|
27
|
+
error = true
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
machine.config.unify.folders.each { |folder|
|
32
|
+
local_path = folder.fetch(0, nil)
|
33
|
+
remote_path = folder.fetch(1, nil)
|
34
|
+
opts = folder.fetch(2, {})
|
35
|
+
|
36
|
+
raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.local_path_required") if local_path.nil? or local_path.empty?
|
37
|
+
raise Vagrant::Errors::UnifyConfigError, :err => I18n.t("vagrant_unify.config.remote_path_required") if remote_path.nil? or remote_path.empty?
|
38
|
+
|
39
|
+
UnifyHelper.unison_single(machine, local_path, remote_path, opts)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
return error ? 1 : 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Unify
|
5
|
+
class Config < Vagrant.plugin("2", :config)
|
6
|
+
attr_accessor :folders
|
7
|
+
|
8
|
+
def initialize(region_specific=false)
|
9
|
+
@folders = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def unify_folder(local_path, remote_path, opts = {})
|
13
|
+
@folders << [local_path, remote_path, opts]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "vagrant/util/platform"
|
3
|
+
require "vagrant/util/subprocess"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Unify
|
7
|
+
class UnifyHelper
|
8
|
+
def self.init_ops(machine, local_path, remote_path, opts)
|
9
|
+
opts[:hostpath] ||= local_path
|
10
|
+
opts[:guestpath] ||= remote_path
|
11
|
+
opts[:owner] ||= machine.ssh_info[:username]
|
12
|
+
opts[:group] ||= machine.ssh_info[:username]
|
13
|
+
return opts
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.init_paths(machine, local_path, remote_path, cygwinify = false)
|
17
|
+
guestpath = remote_path
|
18
|
+
hostpath = File.expand_path(local_path, machine.env.root_path)
|
19
|
+
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
20
|
+
|
21
|
+
if cygwinify and Vagrant::Util::Platform.windows?
|
22
|
+
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
23
|
+
end
|
24
|
+
|
25
|
+
if !guestpath.end_with?("/")
|
26
|
+
guestpath += "/"
|
27
|
+
end
|
28
|
+
|
29
|
+
if !hostpath.end_with?("/")
|
30
|
+
hostpath += "/"
|
31
|
+
end
|
32
|
+
|
33
|
+
return [hostpath, guestpath]
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.init_ssh_args(machine)
|
37
|
+
ssh_info = machine.ssh_info
|
38
|
+
proxy_command = ""
|
39
|
+
|
40
|
+
if ssh_info[:proxy_command]
|
41
|
+
proxy_command = "-o ProxyCommand='#{ssh_info[:proxy_command]}' "
|
42
|
+
end
|
43
|
+
|
44
|
+
return [
|
45
|
+
"-p #{ssh_info[:port]} " +
|
46
|
+
proxy_command +
|
47
|
+
"-o StrictHostKeyChecking=no " +
|
48
|
+
"-o UserKnownHostsFile=/dev/null",
|
49
|
+
ssh_info[:private_key_path].map { |p| "-i '#{p}'" },
|
50
|
+
].flatten.join(" ")
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.init_excludes(opts)
|
54
|
+
excludes = ['.vagrant/', '.DS_Store']
|
55
|
+
excludes += Array(opts[:exclude]).map(&:to_s) if opts[:exclude]
|
56
|
+
excludes.uniq!
|
57
|
+
return excludes
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.pre_sync(machine, hostpath, guestpath, opts)
|
61
|
+
if machine.guest.capability?(:rsync_pre)
|
62
|
+
machine.guest.capability(:rsync_pre, opts)
|
63
|
+
else
|
64
|
+
machine.communicate.sudo("mkdir -p '#{guestpath}'")
|
65
|
+
machine.communicate.sudo("chown #{machine.ssh_info[:username]} '#{guestpath}'")
|
66
|
+
end
|
67
|
+
|
68
|
+
FileUtils.mkdir_p(hostpath)
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.post_sync(machine, opts)
|
72
|
+
if machine.guest.capability?(:rsync_post)
|
73
|
+
machine.guest.capability(:rsync_post, opts)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.unison_single(machine, local_path, remote_path, opts)
|
78
|
+
opts = init_ops(machine, local_path, remote_path, opts)
|
79
|
+
hostpath, guestpath = init_paths(machine, local_path, remote_path)
|
80
|
+
ssh_args = init_ssh_args(machine)
|
81
|
+
excludes = init_excludes(opts)
|
82
|
+
|
83
|
+
command = [
|
84
|
+
"unison", "-batch",
|
85
|
+
"-ignore=Name {" + excludes.join(",") + "}",
|
86
|
+
"-sshargs", ssh_args,
|
87
|
+
hostpath,
|
88
|
+
"ssh://#{machine.ssh_info[:username]}@#{machine.ssh_info[:host]}/#{guestpath}"
|
89
|
+
]
|
90
|
+
|
91
|
+
command_opts = {}
|
92
|
+
command_opts[:workdir] = machine.env.root_path.to_s
|
93
|
+
|
94
|
+
command = command + [command_opts]
|
95
|
+
|
96
|
+
machine.ui.info(I18n.t(
|
97
|
+
"vagrant_unify.sync.message", guestpath: guestpath, hostpath: hostpath))
|
98
|
+
if excludes.length > 1
|
99
|
+
machine.ui.info(I18n.t(
|
100
|
+
"vagrant_unify.excludes", excludes: excludes.inspect))
|
101
|
+
end
|
102
|
+
|
103
|
+
pre_sync(machine, hostpath, guestpath, opts)
|
104
|
+
|
105
|
+
r = Vagrant::Util::Subprocess.execute(*command)
|
106
|
+
case r.exit_code
|
107
|
+
when 0
|
108
|
+
machine.ui.info(I18n.t("vagrant_unify.unison.success_0"))
|
109
|
+
when 1
|
110
|
+
machine.ui.info(I18n.t("vagrant_unify.unison.success_1"))
|
111
|
+
when 2
|
112
|
+
machine.ui.info(I18n.t("vagrant_unify.unison.success_2"))
|
113
|
+
else
|
114
|
+
raise Vagrant::Errors::UnifyError,
|
115
|
+
:command => command.inspect,
|
116
|
+
:guestpath => guestpath,
|
117
|
+
:hostpath => hostpath,
|
118
|
+
:stderr => r.stderr
|
119
|
+
end
|
120
|
+
|
121
|
+
post_sync(machine, opts)
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.rsync_single(direction, machine, local_path, remote_path, opts)
|
125
|
+
opts = init_ops(machine, local_path, remote_path, opts)
|
126
|
+
hostpath, guestpath = init_paths(machine, local_path, remote_path, true)
|
127
|
+
ssh_args = init_ssh_args(machine)
|
128
|
+
excludes = init_excludes(opts)
|
129
|
+
|
130
|
+
args = nil
|
131
|
+
args = Array(opts[:args]).dup if opts[:args]
|
132
|
+
args ||= ["--verbose", "--archive", "--delete", "-z", "--copy-links"]
|
133
|
+
|
134
|
+
if Vagrant::Util::Platform.windows? && !args.any? { |arg| arg.start_with?("--chmod=") }
|
135
|
+
args << "--chmod=ugo=rwX"
|
136
|
+
|
137
|
+
args << "--no-perms" if args.include?("--archive") || args.include?("-a")
|
138
|
+
end
|
139
|
+
|
140
|
+
args << "--no-owner" unless args.include?("--owner") || args.include?("-o")
|
141
|
+
args << "--no-group" unless args.include?("--group") || args.include?("-g")
|
142
|
+
|
143
|
+
if machine.guest.capability?(:rsync_command)
|
144
|
+
args << "--rsync-path"<< machine.guest.capability(:rsync_command)
|
145
|
+
end
|
146
|
+
|
147
|
+
guest_spec = "#{machine.ssh_info[:username]}@#{machine.ssh_info[:host]}:#{guestpath}"
|
148
|
+
from_path = hostpath
|
149
|
+
to_path = guest_spec
|
150
|
+
|
151
|
+
if :pull.equal?(direction)
|
152
|
+
from_path = guest_spec
|
153
|
+
to_path = hostpath
|
154
|
+
end
|
155
|
+
|
156
|
+
command = [
|
157
|
+
"rsync",
|
158
|
+
args,
|
159
|
+
"-e", "ssh " + ssh_args,
|
160
|
+
excludes.map { |e| ["--exclude", e] },
|
161
|
+
from_path,
|
162
|
+
to_path,
|
163
|
+
].flatten
|
164
|
+
|
165
|
+
command_opts = {}
|
166
|
+
command_opts[:workdir] = machine.env.root_path.to_s
|
167
|
+
|
168
|
+
command = command + [command_opts]
|
169
|
+
|
170
|
+
if :pull.equal?(direction)
|
171
|
+
machine.ui.info(I18n.t(
|
172
|
+
"vagrant_unify.pull.message", guestpath: guestpath, hostpath: hostpath))
|
173
|
+
else
|
174
|
+
machine.ui.info(I18n.t(
|
175
|
+
"vagrant_unify.push.message", guestpath: guestpath, hostpath: hostpath))
|
176
|
+
end
|
177
|
+
if excludes.length > 1
|
178
|
+
machine.ui.info(I18n.t(
|
179
|
+
"vagrant_unify.excludes", excludes: excludes.inspect))
|
180
|
+
end
|
181
|
+
|
182
|
+
pre_sync(machine, hostpath, guestpath, opts)
|
183
|
+
|
184
|
+
r = Vagrant::Util::Subprocess.execute(*command)
|
185
|
+
if r.exit_code != 0
|
186
|
+
raise Vagrant::Errors::UnifyError,
|
187
|
+
command: command.inspect,
|
188
|
+
guestpath: guestpath,
|
189
|
+
hostpath: hostpath,
|
190
|
+
stderr: r.stderr
|
191
|
+
end
|
192
|
+
|
193
|
+
post_sync(machine, opts)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The vagrant-unify plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
if Vagrant::VERSION < "1.5"
|
8
|
+
raise "The vagrant-unify plugin is only compatible with Vagrant 1.5+"
|
9
|
+
end
|
10
|
+
|
11
|
+
module VagrantPlugins
|
12
|
+
module Unify
|
13
|
+
class Plugin < Vagrant.plugin("2")
|
14
|
+
name "Unify"
|
15
|
+
description = <<-DESC
|
16
|
+
This plugin syncs files between a local folder and
|
17
|
+
your Vagrant machine via either Unison or RSync
|
18
|
+
DESC
|
19
|
+
|
20
|
+
config "unify" do
|
21
|
+
require_relative "config"
|
22
|
+
Config
|
23
|
+
end
|
24
|
+
|
25
|
+
command "unify-pull" do
|
26
|
+
setup_logging
|
27
|
+
setup_i18n
|
28
|
+
|
29
|
+
require_relative "command-pull"
|
30
|
+
Command
|
31
|
+
end
|
32
|
+
|
33
|
+
command "unify-push" do
|
34
|
+
setup_logging
|
35
|
+
setup_i18n
|
36
|
+
|
37
|
+
require_relative "command-push"
|
38
|
+
Command
|
39
|
+
end
|
40
|
+
|
41
|
+
command "unify-sync" do
|
42
|
+
setup_logging
|
43
|
+
setup_i18n
|
44
|
+
|
45
|
+
require_relative "command-sync"
|
46
|
+
Command
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.setup_i18n
|
50
|
+
I18n.load_path << File.expand_path("locales/en.yml", Unify.source_root)
|
51
|
+
I18n.reload!
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.setup_logging
|
55
|
+
require "log4r"
|
56
|
+
|
57
|
+
level = nil
|
58
|
+
begin
|
59
|
+
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
60
|
+
rescue NameError
|
61
|
+
level = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
level = nil if !level.is_a?(Integer)
|
65
|
+
|
66
|
+
if level
|
67
|
+
logger = Log4r::Logger.new("vagrant_unify")
|
68
|
+
logger.outputters = Log4r::Outputter.stderr
|
69
|
+
logger.level = level
|
70
|
+
logger = nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_unify:
|
3
|
+
|
4
|
+
pull:
|
5
|
+
synopsis: |-
|
6
|
+
rsyncs guest files to host
|
7
|
+
message: |-
|
8
|
+
Unify - pulling [guest]::%{guestpath} --> [host]::%{hostpath}
|
9
|
+
|
10
|
+
push:
|
11
|
+
synopsis: |-
|
12
|
+
rsyncs host files to guest
|
13
|
+
message: |-
|
14
|
+
Unify - pushing [host]::%{hostpath} --> [guest]::%{guestpath}
|
15
|
+
|
16
|
+
sync:
|
17
|
+
synopsis: |-
|
18
|
+
syncs files between host and guest via Unison
|
19
|
+
message: |-
|
20
|
+
Unify - syncing [host]::%{hostpath} <-> [guest]::%{guestpath}
|
21
|
+
|
22
|
+
excludes: |-
|
23
|
+
Excluding: %{excludes}
|
24
|
+
|
25
|
+
unison:
|
26
|
+
success_0: |-
|
27
|
+
Unison completed succesfully
|
28
|
+
success_1: |-
|
29
|
+
Unison completed - all file transfers were successful; some files were skipped
|
30
|
+
success_2: |-
|
31
|
+
Unison completed - non-fatal failures during file transfer
|
32
|
+
|
33
|
+
config:
|
34
|
+
local_path_required: |-
|
35
|
+
Local path is required
|
36
|
+
remote_path_required: |-
|
37
|
+
Remote path is required
|
38
|
+
|
39
|
+
errors:
|
40
|
+
config_error: |-
|
41
|
+
Error in unify configuration: %{err}
|
42
|
+
unify_error: |-
|
43
|
+
There was an error when attemping to unify folders.
|
44
|
+
Please inspect the error message below for more info.
|
45
|
+
|
46
|
+
Host path: %{hostpath}
|
47
|
+
Guest path: %{guestpath}
|
48
|
+
Error: %{stderr}
|
49
|
+
Full command causing error:
|
50
|
+
%{command}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "vagrant-unify/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "vagrant-unify"
|
6
|
+
s.version = VagrantPlugins::Unify::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = "Ed Toon"
|
9
|
+
s.email = "edtoon@edtoon"
|
10
|
+
s.homepage = "https://github.com/edtoon/vagrant-unify"
|
11
|
+
s.summary = "Vagrant plugin to sync files between a local folder and a Vagrant machine via either Unison or RSync"
|
12
|
+
s.description = "Vagrant plugin to sync files between a local folder and a Vagrant machine via either Unison or RSync"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
|
16
|
+
# The following block of code determines the files that should be included
|
17
|
+
# in the gem. It does this by reading all the files in the directory where
|
18
|
+
# this gemspec is, and parsing out the ignored files from the gitignore.
|
19
|
+
# Note that the entire gitignore(5) syntax is not supported, specifically
|
20
|
+
# the "!" syntax, but it should mostly work correctly.
|
21
|
+
root_path = File.dirname(__FILE__)
|
22
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
23
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
24
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
25
|
+
gitignore = File.readlines(gitignore_path)
|
26
|
+
gitignore.map! { |line| line.chomp.strip }
|
27
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
28
|
+
|
29
|
+
unignored_files = all_files.reject do |file|
|
30
|
+
# Ignore any directories, the gemspec only cares about files
|
31
|
+
next true if File.directory?(file)
|
32
|
+
|
33
|
+
# Ignore any paths that match anything in the gitignore. We do
|
34
|
+
# two tests here:
|
35
|
+
#
|
36
|
+
# - First, test to see if the entire path matches the gitignore.
|
37
|
+
# - Second, match if the basename does, this makes it so that things
|
38
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
39
|
+
# as git).
|
40
|
+
#
|
41
|
+
gitignore.any? do |ignore|
|
42
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
43
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
s.files = unignored_files
|
48
|
+
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
49
|
+
s.require_path = 'lib'
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-unify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Ed Toon
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2014-07-11 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Vagrant plugin to sync files between a local folder and a Vagrant machine via either Unison or RSync
|
22
|
+
email: edtoon@edtoon
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- vagrant-unify.gemspec
|
31
|
+
- README.md
|
32
|
+
- CHANGELOG.md
|
33
|
+
- locales/en.yml
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- lib/vagrant-unify/helper.rb
|
37
|
+
- lib/vagrant-unify/plugin.rb
|
38
|
+
- lib/vagrant-unify/errors.rb
|
39
|
+
- lib/vagrant-unify/config.rb
|
40
|
+
- lib/vagrant-unify/version.rb
|
41
|
+
- lib/vagrant-unify/command-sync.rb
|
42
|
+
- lib/vagrant-unify/command-pull.rb
|
43
|
+
- lib/vagrant-unify/command-push.rb
|
44
|
+
- lib/vagrant-unify.rb
|
45
|
+
- .gitignore
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: https://github.com/edtoon/vagrant-unify
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 1
|
70
|
+
- 3
|
71
|
+
- 6
|
72
|
+
version: 1.3.6
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.7
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: Vagrant plugin to sync files between a local folder and a Vagrant machine via either Unison or RSync
|
80
|
+
test_files: []
|
81
|
+
|