rbrsync 0.0.5 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -230,7 +230,10 @@ module RbRsync
230
230
  def from
231
231
  @from ||= build_path(from_user, from_host, from_path)
232
232
  end
233
- attr_writer :from
233
+
234
+ def from= (from)
235
+ @from = [from].flatten unless from.nil?
236
+ end
234
237
 
235
238
  def to
236
239
  @to ||= build_path(to_user, to_host, to_path)
@@ -260,7 +263,7 @@ module RbRsync
260
263
 
261
264
  argv.concat(options_to_argv(@options))
262
265
 
263
- argv << from
266
+ argv.concat(from)
264
267
  argv << to
265
268
 
266
269
  argv
@@ -281,7 +284,7 @@ module RbRsync
281
284
  else
282
285
  [val].flatten.each do |val|
283
286
  argv << "-#{key}"
284
- argv << "'#{shell_escape(val)}'"
287
+ argv << "#{val}"
285
288
  end
286
289
  end
287
290
  else
@@ -291,7 +294,7 @@ module RbRsync
291
294
  # ignore
292
295
  else
293
296
  [val].flatten.each do |val|
294
- argv << "--#{key.to_s.tr('_', '-')}='#{shell_escape(val)}'"
297
+ argv << "--#{key.to_s.tr('_', '-')}=#{val}"
295
298
  end
296
299
 
297
300
  end
@@ -309,9 +312,5 @@ module RbRsync
309
312
  nil
310
313
  end
311
314
  end
312
-
313
- def shell_escape(str)
314
- str.to_s.gsub("'", "'\\\\''")
315
- end
316
315
  end
317
316
  end
@@ -1,3 +1,3 @@
1
1
  module RbRsync
2
- VERSION = '0.0.5'
3
- end
2
+ VERSION = '0.0.8'
3
+ end
data/spec/rbrsync_spec.rb CHANGED
@@ -140,7 +140,14 @@ describe RbRsync do
140
140
 
141
141
  @rsync.from = "newuser@newhost.com:/home/newuser"
142
142
 
143
- @rsync.from.should == "newuser@newhost.com:/home/newuser"
143
+ @rsync.from.should == %w(newuser@newhost.com:/home/newuser)
144
+ end
145
+
146
+ it "should treat multiple sources as such" do
147
+ @rsync.from = %w(/var/apps /home/user /etc/nginx)
148
+ @rsync.to = "newuser@newhost.com:/backups"
149
+
150
+ @rsync.from.should == %w(/var/apps /home/user /etc/nginx)
144
151
  end
145
152
 
146
153
  describe "command method" do
@@ -185,29 +192,33 @@ describe RbRsync do
185
192
  @rsync.from = "/home/me/"
186
193
  @rsync.to = "user@host.com:/home/user"
187
194
 
188
- command_should_have_only "/home/me/", "user@host.com:/home/user", "--exclude='*~'", "--archive"
195
+ command_should_have_only "/home/me/", "user@host.com:/home/user", "--exclude=*~", "--archive"
189
196
  end
190
197
  it "should set --exclude twice when exclude= is called with an array" do
191
198
  @rsync.exclude = ['*~', '/*']
192
199
  @rsync.from = "/home/me/"
193
200
  @rsync.to = "user@host.com:/home/user"
194
201
 
195
- command_should_have_only "/home/me/", "user@host.com:/home/user", "--exclude='*~'", "--exclude='/*'"
202
+ command_should_have_only "/home/me/", "user@host.com:/home/user", "--exclude=*~", "--exclude=/*"
196
203
  end
197
204
 
198
- it "should correctly escape argument values" do
205
+ it "should correctly handle quotes in arguments correctly" do
206
+ @rsync.dry_run!
199
207
  @rsync.log_file = 'rsync.log'
200
208
  @rsync.log_file_format = "'\\'%t '%f' with %b ''"
201
209
  @rsync.from = "/home"
202
210
  @rsync.to = "/home/user"
203
- command_should_have_only "/home", "/home/user", "--log-file='rsync.log'", %q[--log-file-format=''\''\'\''%t '\''%f'\'' with %b '\'''\''']
211
+ status = @rsync.go!
212
+ status.err.should be_empty
213
+ command_should_have_only "/home", "/home/user", "--dry-run", "--log-file=rsync.log", %[--log-file-format='\\'%t '%f' with %b '']
214
+
204
215
  end
205
216
  end
206
217
 
207
218
  describe "constructor" do
208
219
  it "should take source and destination parameters" do
209
220
  @rsync = RbRsync::RbRsync.new '/home/user', 'user@host.com:/home/user'
210
- @rsync.from.should == '/home/user'
221
+ @rsync.from.should == %w(/home/user)
211
222
  @rsync.to.should == 'user@host.com:/home/user'
212
223
  end
213
224
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbrsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-10 00:00:00.000000000 Z
13
+ date: 2013-04-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: posix-spawn