Module: Capistrano::Local::ArchiveStrategy

Defined in:
lib/capistrano/local.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



29
30
31
# File 'lib/capistrano/local.rb', line 29

def check
  test! " [ -e #{repo_url} ] "
end

#releaseObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/capistrano/local.rb', line 33

def release
  archive = ''
  # preparing archive
  run_locally do
    archive = fetch(:tmp_dir, Dir::tmpdir()) + '/capistrano/' + fetch(:application, 'distr') + "-#{fetch(:current_revision)}.tar.gz"
    execute :mkdir, '-p', File.dirname(archive)

    if File.exists?(archive) && !test(:tar, 'tzf', archive)
      execute :rm, '-f', archive
    end

    unless File.exists?(archive)
      if File.directory?(repo_url) || !File.fnmatch('*.tar.gz', repo_url)
        within repo_url do
          execute :tar, 'czf', archive, '-C', repo_url, '.'
        end
        execute :tar, 'tzf', archive
      else
        execute :cp, repo_url, archive
      end
    end
  end

  # uploading and unpacking
  on release_roles :app, in: :parallel do |host|
    upload! archive, releases_path, verbose: false
    remote_archive = File.join(releases_path, File.basename(archive))
    execute :tar, 'xzf', remote_archive, '-C', release_path
    execute :rm, '-f', remote_archive
  end

  # removing archive
  run_locally do
    execute :rm, '-f', archive
  end
end