Class: Oldtime::Rsync2

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, name) ⇒ Rsync2

Returns a new instance of Rsync2.



28
29
30
31
# File 'lib/oldtime/rsync.rb', line 28

def initialize(file, name)
  @file = file
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/oldtime/rsync.rb', line 26

def name
  @name
end

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/oldtime/rsync.rb', line 33

def run
  begin
    @dir = Pa.mktmpdir(Rc.profile)

    end_cmd, file_config = parse(@file)
    file_config.each { |k, v|
      File.write("#{@dir}/#{k}", v)
    }
    cmd = build_cmd(end_cmd, file_config)

    File.append(Rc.p.logfile.p, "\n#{'='*30}\n#{'='*10} rsync #{name} #{'='*10}\n#{'='*30}\n\n")
    system cmd, :verbose => true
  ensure
    # cleanup
    Pa.rm_r @dir
  end
end