Sha256: 873539def4051deaa1f90fcfdfb6af67f7c51de4ec91ab5bc3a88dae0860b8dc

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

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")
      log("Release v#{version} aborted", "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

5 entries across 5 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.0.beta10 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta9 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta7 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta6 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta5 lib/shuttle/helpers.rb