Class: RbRsync::RbRsync

Inherits:
Object
  • Object
show all
Defined in:
lib/rbrsync/rbrsync.rb

Constant Summary collapse

@@boolean_methods =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from = nil, to = nil) ⇒ RbRsync

Returns a new instance of RbRsync.



7
8
9
10
11
12
13
# File 'lib/rbrsync/rbrsync.rb', line 7

def initialize from=nil, to=nil
  @options = {}

  self.from = from
  self.to = to
  self.rsync = "rsync"
end

Instance Attribute Details

#fromObject



222
223
224
# File 'lib/rbrsync/rbrsync.rb', line 222

def from
  @from ||= build_path(from_user, from_host, from_path)
end

#from_hostObject

Returns the value of attribute from_host.



219
220
221
# File 'lib/rbrsync/rbrsync.rb', line 219

def from_host
  @from_host
end

#from_pathObject

Returns the value of attribute from_path.



219
220
221
# File 'lib/rbrsync/rbrsync.rb', line 219

def from_path
  @from_path
end

#from_userObject

Returns the value of attribute from_user.



219
220
221
# File 'lib/rbrsync/rbrsync.rb', line 219

def from_user
  @from_user
end

#rsyncObject

the path to rsync



218
219
220
# File 'lib/rbrsync/rbrsync.rb', line 218

def rsync
  @rsync
end

#toObject



227
228
229
# File 'lib/rbrsync/rbrsync.rb', line 227

def to
  @to ||= build_path(to_user, to_host, to_path)
end

#to_hostObject

Returns the value of attribute to_host.



220
221
222
# File 'lib/rbrsync/rbrsync.rb', line 220

def to_host
  @to_host
end

#to_pathObject

Returns the value of attribute to_path.



220
221
222
# File 'lib/rbrsync/rbrsync.rb', line 220

def to_path
  @to_path
end

#to_userObject

Returns the value of attribute to_user.



220
221
222
# File 'lib/rbrsync/rbrsync.rb', line 220

def to_user
  @to_user
end

Class Method Details

.boolean_methodsObject



251
252
253
# File 'lib/rbrsync/rbrsync.rb', line 251

def self.boolean_methods
  @@boolean_methods
end

Instance Method Details

#commandObject

returns the rsync command that would be executed



237
238
239
# File 'lib/rbrsync/rbrsync.rb', line 237

def command
  build_command.join ' '
end

#go!Object

perform the sync

Raises:

  • (ArgumentError)


242
243
244
245
246
247
248
249
# File 'lib/rbrsync/rbrsync.rb', line 242

def go!
  raise ArgumentError.new("a source and destination must be specified") if to.nil? || from.nil?

  status = Open4.popen4(command) do |pid, stdin, stdout, stderr|
    puts stderr.read if stderr
  end

end

#noObject



232
233
234
# File 'lib/rbrsync/rbrsync.rb', line 232

def no
  Negator.new self
end