class Statistrano::Deployment::Strategy::Base

A Base Deployment Instance it holds the common methods needed to create a deployment

Attributes

name[R]

Public Class Methods

new(name) click to toggle source

create a new deployment instance @param name [String] @return [Void]

# File lib/statistrano/deployment/strategy/base.rb, line 42
def initialize name
  @name = name
end

Public Instance Methods

deploy() click to toggle source

Standard deployment flow @return [Void]

# File lib/statistrano/deployment/strategy/base.rb, line 48
def deploy
  unless safe_to_deploy?
    Log.error "exiting due to git check failing"
    abort()
  end

  build_data = invoke_build_task
  build_data = ensure_data_is_hash build_data

  unless safe_to_deploy?
    Log.error "exiting due to git check failing",
              "your build task modified checked in files"
    abort()
  end

  remotes.each do |remote|
    persisted_releaser.create_release remote, build_data
  end

  post_deploy_data = invoke_post_deploy_task
  post_deploy_data = ensure_data_is_hash post_deploy_data

  if config.log_file_path
    log_entry = config.log_file_entry.call self, persisted_releaser,
                                           build_data, post_deploy_data

    remotes.each do |remote|
      log_file(remote).append! log_entry
    end
  end

  flush_persisted_releaser!
end
flush_persisted_releaser!() click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 105
def flush_persisted_releaser!
  @_persisted_releaser = nil
end
log_file(remote=remotes.first) click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 97
def log_file remote=remotes.first
  Deployment::LogFile.new config.log_file_path, remote
end
persisted_releaser() click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 101
def persisted_releaser
  @_persisted_releaser ||= releaser
end
register_tasks() click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 82
def register_tasks
  RakeTasks.register self
end
remotes() click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 86
def remotes
  return @_remotes if @_remotes

  @_remotes = config.options[:remotes].map do |remote_options|
    Remote.new Config.new( options: config.options.dup.merge(remote_options) )
  end
  @_remotes.push Remote.new(config) if @_remotes.empty?

  return @_remotes
end

Private Instance Methods

ensure_data_is_hash(data) click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 119
def ensure_data_is_hash data
  if data.respond_to? :to_hash
    data = data.to_hash
  else
    data = {}
  end
end
releaser() click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 127
def releaser
  Releaser::Single.new
end
resolve_log_file_path() click to toggle source
# File lib/statistrano/deployment/strategy/base.rb, line 111
def resolve_log_file_path
  if config.log_file_path.start_with? '/'
    config.log_file_path
  else
    File.join( config.remote_dir, config.log_file_path )
  end
end