Class: SourceTreeSyncer

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

Constant Summary collapse

SYS_COMMAND =
'rsync'
OPTS =
"-azr --timeout=5 --delete"
EXCLUDE_OPT =
"--exclude"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_tree_path) ⇒ SourceTreeSyncer

Returns a new instance of SourceTreeSyncer.



11
12
13
14
# File 'lib/gorgon/source_tree_syncer.rb', line 11

def initialize source_tree_path
  @source_tree_path = source_tree_path
  @exclude = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/gorgon/source_tree_syncer.rb', line 5

def errors
  @errors
end

#excludeObject

Returns the value of attribute exclude.



4
5
6
# File 'lib/gorgon/source_tree_syncer.rb', line 4

def exclude
  @exclude
end

#outputObject (readonly)

Returns the value of attribute output.



5
6
7
# File 'lib/gorgon/source_tree_syncer.rb', line 5

def output
  @output
end

#sys_commandObject (readonly)

Returns the value of attribute sys_command.



5
6
7
# File 'lib/gorgon/source_tree_syncer.rb', line 5

def sys_command
  @sys_command
end

Instance Method Details

#pushObject



27
28
29
30
31
32
33
# File 'lib/gorgon/source_tree_syncer.rb', line 27

def push
  return if blank_source_tree_path?

  @sys_command = "#{SYS_COMMAND} #{OPTS} #{build_exclude_opt} . #{@source_tree_path}"

  execute_command
end

#remove_temp_dirObject



39
40
41
# File 'lib/gorgon/source_tree_syncer.rb', line 39

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

#success?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/gorgon/source_tree_syncer.rb', line 35

def success?
  @exitstatus == 0
end

#syncObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/gorgon/source_tree_syncer.rb', line 16

def sync
  return if blank_source_tree_path?

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

  @sys_command = "#{SYS_COMMAND} #{OPTS} #{build_exclude_opt} #{@source_tree_path}/ ."

  execute_command
end