Sha256: 445d30ef98154549302fcfc9b254ad1a7177cf9cbce8196e139e0cf58463e820

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Shuttle
  class Deploy
    include Shuttle::Tasks
    include Shuttle::Helpers

    attr_reader :ssh
    attr_reader :target
    attr_reader :environment
    attr_reader :version
    attr_reader :config

    def initialize(config, ssh, target, environment)
      @config      = config
      @target      = target
      @ssh         = ssh
      @environment = environment

      if ssh.file_exists?(version_path)
        res = ssh.capture("cat #{version_path}")
        @version = (res.empty? ? 1 : Integer(res) + 1).to_s
      else
        @version = 1
      end
    end

    def deploy_path(path=nil)
      [target.deploy_to, path].compact.join('/')
    end

    def shared_path(path=nil)
      [deploy_path, 'shared', path].compact.join('/')
    end

    def current_path(path=nil)
      [deploy_path, 'current', path].compact.join('/')
    end

    def version_path
      deploy_path('version')
    end

    def release_path(path=nil)
      [deploy_path, 'releases', version, path].compact.join('/')
    end

    def scm_path
      deploy_path('scm')
    end

    def deploy
      setup
      update_code
      checkout_code
      link_release
      cleanup_releases
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.0.beta1 lib/shuttle/deploy.rb