Class: Hookit::Resource::Rsync

Inherits:
Base
  • Object
show all
Defined in:
lib/hookit/resource/rsync.rb

Instance Attribute Summary

Attributes inherited from Base

#dict

Instance Method Summary collapse

Methods inherited from Base

#action, actions, #can_run?, default_action, #default_action, field, #not_if, #only_if

Constructor Details

#initialize(name) ⇒ Rsync

Returns a new instance of Rsync.



16
17
18
19
# File 'lib/hookit/resource/rsync.rb', line 16

def initialize(name)
  source name unless source
  super
end

Instance Method Details

#archive!Object



32
33
34
35
# File 'lib/hookit/resource/rsync.rb', line 32

def archive!
  (return "a") if archive
  ""
end

#checksum!Object



42
43
44
45
# File 'lib/hookit/resource/rsync.rb', line 42

def checksum!
  (return "c") if archive
  ""
end

#compress!Object



47
48
49
50
# File 'lib/hookit/resource/rsync.rb', line 47

def compress!
  (return "z") if archive
  ""
end

#recursive!Object



37
38
39
40
# File 'lib/hookit/resource/rsync.rb', line 37

def recursive!
  (return "r") if archive
  ""
end

#run(action) ⇒ Object



21
22
23
24
25
26
# File 'lib/hookit/resource/rsync.rb', line 21

def run(action)
  case action
  when :sync
    sync!
  end
end

#sync!Object



28
29
30
# File 'lib/hookit/resource/rsync.rb', line 28

def sync!
  run_command! "rsync -q#{archive!}#{recursive!}#{checksum!}#{compress!} #{wrapper!} #{source} #{destination}"
end

#wrapper!Object



52
53
54
55
# File 'lib/hookit/resource/rsync.rb', line 52

def wrapper!
  (return "-e '#{wrapper}'") if wrapper
  ""
end