Sha256: 321bd24594cb51855d806b958dcf9c4d7c0710723369adbad443037930951d86

Contents?: true

Size: 1000 Bytes

Versions: 4

Compression:

Stored size: 1000 Bytes

Contents

module Shuttle
  module Helpers
    LEVEL_COLORS = {
      'info'    => :green,
      'warning' => :yellow,
      'error'   => :red
    }

    def log(message, level='info')
      prefix = "----->".send(LEVEL_COLORS[level])
      STDOUT.puts("#{prefix} #{message}")
    end

    def error(message)
      log("ERROR: #{message}", 'error')
      raise DeployError, message
    end

    def git_installed?
      ssh.run("which git").success?
    end

    def svn_installed?
      ssh.run("which svn").success?
    end

    def release_exists?
      ssh.directory_exists?(release_path)
    end

    def stream_output(buff)
      str = buff.split("\n").map { |str| "       #{str}"}.join("\n")
      STDOUT.puts(str)
    end

    def git_remote
      result = ssh.run("cd #{scm_path} && git remote -v")

      if result.success?
        result.output.scan(/^origin\t(.+)\s\(fetch\)/).flatten.first
      else
        nil
      end
    end

    def deployer_hostname
      `hostname`.strip
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.0.beta4 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta3 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta2 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta1 lib/shuttle/helpers.rb