photocopier 1.1.4 → 1.2.0
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.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +6 -0
- data/lib/photocopier/ssh.rb +18 -15
- data/lib/photocopier/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b3b9cc3cc86c153ef1c704c256048043f9f21a8
|
|
4
|
+
data.tar.gz: 306c1a3a7cf48f236f2e8ace351f07b66e5d76b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd735bbe44ad3c88e03e55a45bcd8bc0424939e4c26fd34625e4a367548ab72acfd647129b0d56260ba07afd8928f97887b00e7b3a8d26c545ca93c39962b12d
|
|
7
|
+
data.tar.gz: 532d2583c6eb1a0fb225a3ef7b6b12ca3e1fb242e9bb6f72fcedffe4f4c7e92b28ff2918bf144a5134262443a4e9a8b703d42c91d1059478a569bbe62a73c282
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/lib/photocopier/ssh.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
module Photocopier
|
|
2
2
|
class SSH < Adapter
|
|
3
|
-
|
|
4
3
|
attr_reader :gateway_options, :rsync_options
|
|
5
4
|
|
|
6
5
|
def initialize(options = {})
|
|
@@ -25,15 +24,15 @@ module Photocopier
|
|
|
25
24
|
exec!("rm -rf #{Shellwords.escape(remote_path)}")
|
|
26
25
|
end
|
|
27
26
|
|
|
28
|
-
def get_directory(remote_path, local_path, exclude = [])
|
|
27
|
+
def get_directory(remote_path, local_path, exclude = [], includes = [])
|
|
29
28
|
FileUtils.mkdir_p(local_path)
|
|
30
29
|
remote_path << "/" unless remote_path.end_with?("/")
|
|
31
|
-
rsync ":#{remote_path}", local_path, exclude
|
|
30
|
+
rsync ":#{remote_path}", local_path, exclude, includes
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
def put_directory(local_path, remote_path, exclude = [])
|
|
33
|
+
def put_directory(local_path, remote_path, exclude = [], includes = [])
|
|
35
34
|
local_path << "/" unless local_path.end_with?("/")
|
|
36
|
-
rsync
|
|
35
|
+
rsync local_path.to_s, ":#{remote_path}", exclude, includes
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
def exec!(cmd)
|
|
@@ -41,20 +40,20 @@ module Photocopier
|
|
|
41
40
|
stderr = ""
|
|
42
41
|
exit_code = nil
|
|
43
42
|
session.open_channel do |channel|
|
|
44
|
-
channel.exec(cmd) do |
|
|
45
|
-
channel.on_data do |
|
|
43
|
+
channel.exec(cmd) do |_ch, _success|
|
|
44
|
+
channel.on_data do |_ch, data|
|
|
46
45
|
stdout << data
|
|
47
46
|
end
|
|
48
|
-
channel.on_extended_data do |
|
|
47
|
+
channel.on_extended_data do |_ch, _type, data|
|
|
49
48
|
stderr << data
|
|
50
49
|
end
|
|
51
|
-
channel.on_request("exit-status") do |
|
|
50
|
+
channel.on_request("exit-status") do |_ch, data|
|
|
52
51
|
exit_code = data.read_long
|
|
53
52
|
end
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
session.loop
|
|
57
|
-
[
|
|
56
|
+
[stdout, stderr, exit_code]
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
private
|
|
@@ -80,15 +79,20 @@ module Photocopier
|
|
|
80
79
|
"-rlpt",
|
|
81
80
|
"--compress",
|
|
82
81
|
"--omit-dir-times",
|
|
83
|
-
"--delete"
|
|
82
|
+
"--delete"
|
|
84
83
|
]
|
|
85
84
|
command.concat Shellwords.split(rsync_options).map(&:shellescape) if rsync_options
|
|
86
85
|
command.compact
|
|
87
86
|
end
|
|
88
87
|
|
|
89
|
-
def rsync(source, destination, exclude = [])
|
|
88
|
+
def rsync(source, destination, exclude = [], includes = [])
|
|
90
89
|
command = rsync_command
|
|
91
90
|
|
|
91
|
+
includes.each do |glob|
|
|
92
|
+
command << "--include"
|
|
93
|
+
command << Shellwords.escape(glob)
|
|
94
|
+
end
|
|
95
|
+
|
|
92
96
|
exclude.each do |glob|
|
|
93
97
|
command << "--exclude"
|
|
94
98
|
command << Shellwords.escape(glob)
|
|
@@ -112,9 +116,8 @@ module Photocopier
|
|
|
112
116
|
command << "-p #{opts[:port]} " if opts[:port].present?
|
|
113
117
|
command << "#{opts[:user]}@" if opts[:user].present?
|
|
114
118
|
command << opts[:host]
|
|
115
|
-
if opts[:password]
|
|
116
|
-
|
|
117
|
-
end
|
|
119
|
+
command = "sshpass -p #{opts[:password]} #{command}" if opts[:password]
|
|
120
|
+
|
|
118
121
|
command
|
|
119
122
|
end
|
|
120
123
|
|
data/lib/photocopier/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: photocopier
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stefano Verna
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: exe
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2018-
|
|
13
|
+
date: 2018-05-22 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|