Class: DanarchyDeploy::Archiver

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_deploy/archiver.rb,
lib/danarchy_deploy/archiver/svn.rb

Defined Under Namespace

Classes: Svn

Class Method Summary collapse

Class Method Details

.new(archives, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/danarchy_deploy/archiver.rb', line 5

def self.new(archives, options)
  puts "\n" + self.name

  archives.each do |archive|
    abort("No target destination set for archive: #{archive[:source]}!") if !archive[:target]

    tmparchive = false
    if !archive[:source] && archive[:data]
      archive[:source] = options[:deploy_dir] + "/.tmp_archive_#{Time.now.strftime("%Y%m%d_%H%M%S")}"
      tmparchive = true
      data = DanarchyDeploy::Helpers.decode_base64(archive[:data])
      write_tmp_archive(archive[:source], data)
    end

    puts " > Extracting #{archive[:source]} to #{archive[:target]}"
    if !File.exist?(archive[:source])
      puts "    ! Source file not found!: #{archive[:source]}"
      return false
    end

    Dir.exist?(archive[:target]) || FileUtils.mkdir_p(archive[:target])
    command = prep_extraction(archive, options)
    archive_result = DanarchyDeploy::Helpers.run_command(command, options)

    if archive_result[:stderr]
      puts '   ! Archive extraction failed!'
      abort("STDERR:\n#{archive_result[:stderr]}")
    elsif archive_result[:stdout]
      puts "   |+ Archive extracted: #{archive[:source]}\n"
    end

    set_target_ownership(archive[:target], archive[:perms]) if archive[:perms]
    cleanup_source_archive(archive[:source]) if tmparchive
  end
end