thrush 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/thrush.rb +52 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODIyMjFmYmU5MDYxNDI3N2M3MDMxNTdhYWI1MDllNDVmMTIxZDc2Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjU0OTQxNGQ4NjM1Zjk4NWRhNmYzZjIyZmZmMjMwYmY1MWE2OTJmYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGRhNTE4YzA2ZDlmYWVhNjdhYzJlOWU1NjM5YzQ5OGFlYjU0MGM3OTljNWQ4
|
10
|
+
ODQzMjlkYzhhMjU1MDNjZmY0MDJiZjdjOGQyMzU4ZmU4ZDVjNTUzNDM2NDE2
|
11
|
+
ZWM5YzZkODAxMjcxNTM1OGE5NjQ1YzEwZGIwZmE0ZjNmMTQ1ZmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTk2ZTNiNzBlOGYwNGM4YWIxZjVhZWFjOTk3MzQ1OGQ5NTEzZDY2YWYzNGQx
|
14
|
+
Zjg5MzZlZmQzNGRkMzA2ODY1MzAyYzdiOGEwMDEyODk5ODczZGY1N2I3Yzdi
|
15
|
+
YjA0NDdiZGJlYzY4NzUyODE4M2Y5MWJhMzg0ZDlhMDI5NWY4Y2Y=
|
data/lib/thrush.rb
CHANGED
@@ -75,6 +75,13 @@ def debug?
|
|
75
75
|
flag? :debug
|
76
76
|
end
|
77
77
|
|
78
|
+
def flag(key)
|
79
|
+
k = key.to_sym
|
80
|
+
if flag? k
|
81
|
+
@flags[k]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
78
85
|
# Defining commands
|
79
86
|
@commands = []
|
80
87
|
|
@@ -129,7 +136,7 @@ def run!
|
|
129
136
|
next unless found
|
130
137
|
end
|
131
138
|
|
132
|
-
sudo
|
139
|
+
sudo = cmd_vals(:sudo, cmd_values)
|
133
140
|
debug_command = ''
|
134
141
|
|
135
142
|
case cmd_values[:type]
|
@@ -145,7 +152,13 @@ def run!
|
|
145
152
|
end
|
146
153
|
when :rsync
|
147
154
|
debug = debug? ? 'n' : ''
|
148
|
-
|
155
|
+
# TODO: The default rsync values I've hardcoded including --no-o, --no-g and other defaults should be flags that someone can pass in.
|
156
|
+
cmd = ["rsync -#{ debug }vazcO --no-o --no-g"]
|
157
|
+
|
158
|
+
rsh = cmd_vals(:rsh, cmd_values)
|
159
|
+
cmd << "--rsh=#{ rsh }" unless rsh.nil?
|
160
|
+
|
161
|
+
cmd << "--exclude '.git' --exclude '.idea' --exclude '.DS_Store'"
|
149
162
|
|
150
163
|
ignore = cmd_vals(:ignore, cmd_values)
|
151
164
|
ignore.each { |exclude| cmd << "--exclude '#{ exclude }'" } unless ignore.nil? || ignore.empty?
|
@@ -156,7 +169,12 @@ def run!
|
|
156
169
|
cmd << "--rsync-path='#{ path }'" unless path.nil? || path.empty?
|
157
170
|
|
158
171
|
cmd << cmd_vals(:src, cmd_values)
|
159
|
-
|
172
|
+
|
173
|
+
if rsh == 'ssh'
|
174
|
+
cmd << "#{ cmd_vals(:hostname, cmd_values) }:#{ cmd_vals(:dest, cmd_values) }"
|
175
|
+
else
|
176
|
+
cmd << cmd_vals(:dest, cmd_values)
|
177
|
+
end
|
160
178
|
|
161
179
|
command = cmd.join(' ')
|
162
180
|
debug_command = command if debug?
|
@@ -190,21 +208,42 @@ def run!
|
|
190
208
|
# break
|
191
209
|
#end
|
192
210
|
|
193
|
-
status = Open4::popen4('sh') do |pid, stdin, stdout, stderr|
|
194
|
-
|
195
|
-
|
211
|
+
#status = Open4::popen4('sh') do |pid, stdin, stdout, stderr|
|
212
|
+
# stdin.puts command
|
213
|
+
# stdin.close
|
214
|
+
#
|
215
|
+
# while (line = stdout.gets)
|
216
|
+
# puts line
|
217
|
+
# end
|
218
|
+
#
|
219
|
+
# while (line = stderr.gets)
|
220
|
+
# puts line.red
|
221
|
+
# end
|
222
|
+
#end
|
223
|
+
#
|
224
|
+
#unless status == 0
|
225
|
+
# puts "Command failed: #{ command }".red
|
226
|
+
# break
|
227
|
+
#end
|
196
228
|
|
197
|
-
|
198
|
-
|
199
|
-
|
229
|
+
pid, stdin, stdout, stderr = Open4::popen4('sh')
|
230
|
+
stdin.puts command
|
231
|
+
stdin.close
|
200
232
|
|
233
|
+
output = false
|
234
|
+
while (line = stdout.gets)
|
235
|
+
output = true
|
236
|
+
puts line
|
237
|
+
end
|
238
|
+
|
239
|
+
ignored, status = Process.waitpid2 pid
|
240
|
+
if status.to_i == 0
|
241
|
+
puts "OK" unless output
|
242
|
+
else
|
243
|
+
puts "Command failed (#{ status.exitstatus }): #{ command }".red
|
201
244
|
while (line = stderr.gets)
|
202
245
|
puts line.red
|
203
246
|
end
|
204
|
-
end
|
205
|
-
|
206
|
-
unless status == 0
|
207
|
-
puts "Command failed: #{ command }".red
|
208
247
|
break
|
209
248
|
end
|
210
249
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thrush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Z.d. Peacock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|