directory_push 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/directory_push/version.rb +1 -1
- data/lib/directory_push.rb +20 -29
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b1c4c9d852154cb16f1092282a83a248bb64cb
|
4
|
+
data.tar.gz: eeee6b3a199eb39deb53e950499c921adddd12d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a93b48eb6c6c45df621b6bb385b2384744ba65ecc118c5f69393c89a672d42e75ba48079905a017692d88383af8659a80b6bc574323a1847e7ada3f6bd86b99d
|
7
|
+
data.tar.gz: 208418314bac3d46d40adec1361ff29d313d5caf8ba326c7d7c596822533e1a9097124b0f73b20cfa83c3f7037e1a2046d22a4f454720d73d95733b9ba31af5a
|
data/lib/directory_push.rb
CHANGED
@@ -19,6 +19,7 @@ module DirectoryPush
|
|
19
19
|
|
20
20
|
FILTER_FILE_NAME = '.rsync-filter'
|
21
21
|
DEFAULT_RSYNC_OPTIONS = [
|
22
|
+
'--delete',
|
22
23
|
'--verbose',
|
23
24
|
'--archive',
|
24
25
|
'--compress',
|
@@ -29,49 +30,39 @@ module DirectoryPush
|
|
29
30
|
GUARDFILE_TEXT = %q{
|
30
31
|
require 'yaml'
|
31
32
|
require 'guard/compat/plugin'
|
32
|
-
require 'rsync'
|
33
33
|
|
34
34
|
config = YAML.load(File.read(File.join(File.dirname(__FILE__), 'config.yml')))
|
35
|
-
|
36
|
-
|
37
|
-
$source = config.delete(:source)
|
35
|
+
rsync_options = ['rsync'] + config.delete(:rsync)
|
36
|
+
source = config.delete(:source)
|
38
37
|
ignore_pattern = config.delete(:ignore)
|
39
|
-
|
38
|
+
remote = %Q{#{config.delete(:user)}@#{config.delete(:remote_address)}:"#{config.delete(:destination)}"}
|
39
|
+
|
40
|
+
rsync_options << source << remote
|
41
|
+
$rsync_command = rsync_options.join(' ')
|
40
42
|
|
41
43
|
module ::Guard
|
42
44
|
class DirectoryPush < Plugin
|
43
|
-
|
44
|
-
def
|
45
|
-
|
46
|
-
result = Rsync.run $source, $remote, $rsync_options
|
47
|
-
if result.success?
|
48
|
-
result.changes.each do |change|
|
49
|
-
Compat::UI.info "#{change.filename} (#{change.summary})"
|
50
|
-
end
|
51
|
-
else
|
52
|
-
Compat::UI.error result.error
|
53
|
-
raise result.error
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
public
|
58
|
-
|
59
|
-
alias_method :start, :sync
|
60
|
-
alias_method :stop, :sync
|
61
|
-
alias_method :reload, :sync
|
62
|
-
alias_method :run_all, :sync
|
45
|
+
def start() sync end
|
46
|
+
def reload() sync end
|
47
|
+
def run_all() sync end
|
63
48
|
def run_on_additions(paths)
|
64
|
-
Compat::UI.info "Guard::DirectoryPush Files created: #{paths}"
|
49
|
+
Compat::UI.info "Guard::DirectoryPush Files created: #{paths}."
|
65
50
|
sync
|
66
51
|
end
|
67
52
|
def run_on_modifications(paths)
|
68
|
-
Compat::UI.info "Guard::DirectoryPush Files changed: #{paths}"
|
53
|
+
Compat::UI.info "Guard::DirectoryPush Files changed: #{paths}."
|
69
54
|
sync
|
70
55
|
end
|
71
56
|
def run_on_removals(paths)
|
72
|
-
Compat::UI.info "Guard::DirectoryPush Files removed: #{paths}"
|
57
|
+
Compat::UI.info "Guard::DirectoryPush Files removed: #{paths}."
|
73
58
|
sync
|
74
59
|
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def sync()
|
63
|
+
Compat::UI.info %Q{Guard::DirectoryPush `#{$rsync_command}`.}
|
64
|
+
system $rsync_command
|
65
|
+
end
|
75
66
|
end
|
76
67
|
end
|
77
68
|
|
@@ -79,7 +70,7 @@ config[:verbose] = true
|
|
79
70
|
config[:cli] = '--color'
|
80
71
|
config[:sync_on_start] = true
|
81
72
|
|
82
|
-
directories [
|
73
|
+
directories [source]
|
83
74
|
guard 'directory-push', config do
|
84
75
|
watch %r{^.+$}
|
85
76
|
if ignore_pattern
|