Sha256: c2606a942523533314f218c642c5be5033388602a157d0e271bbfa9989eef8f8

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

load File.expand_path('../tasks/local.rake', __FILE__)

require 'capistrano/scm'

require 'zlib'
require 'archive/tar/minitar'
include Archive::Tar
require 'tmpdir'
require 'fileutils'

require 'rake/packagetask'

class Capistrano::Local < Capistrano::SCM
  module PlainStrategy
    def check
      test! " [ -e #{repo_url} ] "
    end

    def release
      file_list = Dir.glob(File.join(repo_url, '*')).concat(Dir.glob(File.join(repo_url, '.[^.]*')))

      on release_roles :all do |host|
        file_list.each { |r| upload! r, release_path, recursive: true }
      end
    end
  end

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

    def release
      archive = ''
      # preparing archive
      run_locally do
        archive = fetch(:tmp_dir, Dir::tmpdir()) + '/capistrano/' + fetch(:alllication, 'distr') + "-#{fetch(:current_revision)}.tar.gz"
        debug "Archiving #{repo_url} to #{archive}"
        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 :all do |host|
        debug "Uploading #{archive} to #{host}:#{release_path}"
        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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-scm-local-0.1.16 lib/capistrano/local.rb