Class: SourceTreeSyncer

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

Constant Summary collapse

RSYNC_TRANSPORT_SSH =
'ssh'
RSYNC_TRANSPORT_ANONYMOUS =
'anonymous'
SYS_COMMAND =
'rsync'
OPTS =
'-azr --timeout=5 --delete'
RSH_OPTS =
'ssh -o NumberOfPasswordPrompts=0 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i gorgon.pem'
EXCLUDE_OPT =
'--exclude'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sync_config) ⇒ SourceTreeSyncer

Returns a new instance of SourceTreeSyncer.



14
15
16
17
18
19
20
# File 'lib/gorgon/source_tree_syncer.rb', line 14

def initialize(sync_config)
  if sync_config
    @source_tree_path = sync_config[:source_tree_path]
    @exclude = sync_config[:exclude]
    @rsync_transport = sync_config[:rsync_transport]
  end
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/gorgon/source_tree_syncer.rb', line 7

def errors
  @errors
end

#outputObject (readonly)

Returns the value of attribute output.



7
8
9
# File 'lib/gorgon/source_tree_syncer.rb', line 7

def output
  @output
end

#sys_commandObject (readonly)

Returns the value of attribute sys_command.



7
8
9
# File 'lib/gorgon/source_tree_syncer.rb', line 7

def sys_command
  @sys_command
end

Instance Method Details

#pushObject



34
35
36
37
38
39
40
# File 'lib/gorgon/source_tree_syncer.rb', line 34

def push
  return if blank_source_tree_path?

  @sys_command = "#{SYS_COMMAND} #{rsync_options} . #{@source_tree_path}"

  execute_command
end

#remove_temp_dirObject



46
47
48
# File 'lib/gorgon/source_tree_syncer.rb', line 46

def remove_temp_dir
  FileUtils::remove_entry_secure(@tempdir) if @tempdir
end

#success?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/gorgon/source_tree_syncer.rb', line 42

def success?
  @exitstatus == 0
end

#syncObject

TODO: rename sync to pull



23
24
25
26
27
28
29
30
31
32
# File 'lib/gorgon/source_tree_syncer.rb', line 23

def sync
  return if blank_source_tree_path?

  @tempdir = Dir.mktmpdir("gorgon")
  Dir.chdir(@tempdir)

  @sys_command = "#{SYS_COMMAND} #{rsync_options} #{@source_tree_path}/ ."

  execute_command
end