class Capistrano::TarballScm::Plugin

Public Instance Methods

create() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 22
def create
  excludes = fetch(:tarball_exclude).map { |d| "--exclude #{d}" }.join(' ')
  backend.execute(:mkdir, '-p', tarball_dir)
  backend.execute(:tar, '-C', tarball_root, '--exclude', tarball_dir, excludes, '-cjf', tarball_path, '.')
end
define_tasks() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 13
def define_tasks
  eval_rakefile File.expand_path('../tasks/tarball.rake', __FILE__)
end
fetch_revision() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 38
def fetch_revision
  backend.capture(:git, 'rev-parse', 'HEAD').strip
end
register_hooks() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 17
def register_hooks
  after 'deploy:new_release_path', 'tarball:create_release'
  before 'deploy:set_current_revision', 'tarball:set_current_revision'
end
release() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 28
def release
  backend.execute(:mkdir, '-p', release_path)
  backend.upload!(tarball_path, release_path)

  backend.within(release_path) do
    backend.execute :tar, '-xjf', File.basename(tarball_path)
    backend.execute :rm, '-f', File.basename(tarball_path)
  end
end
set_defaults() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 6
def set_defaults
  set_if_empty :repo_url, '.'
  set_if_empty :repo_tree, '.'
  set_if_empty :tarball_dir, fetch(:tmp_dir)
  set_if_empty :tarball_exclude, []
end

Private Instance Methods

tarball_dir() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 44
def tarball_dir
  fetch(:tarball_dir)
end
tarball_name() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 48
def tarball_name
  "#{release_timestamp}.tar.bz2"
end
tarball_path() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 52
def tarball_path
  File.join(tarball_dir, tarball_name)
end
tarball_root() click to toggle source
# File lib/capistrano/tarball_scm/plugin.rb, line 56
def tarball_root
  File.join(fetch(:repo_url), fetch(:repo_tree))
end