Sha256: 4e19f338ee652521cc53d5a81cbac478bb68c011cd6113087593ee4e39166618

Contents?: true

Size: 1.11 KB

Versions: 16

Compression:

Stored size: 1.11 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 warn(message)
      log("WARNING: #{message}", "warning")
    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

16 entries across 16 versions & 1 rubygems

Version Path
shuttle-deploy-0.4.0 lib/shuttle/helpers.rb
shuttle-deploy-0.3.3 lib/shuttle/helpers.rb
shuttle-deploy-0.3.2 lib/shuttle/helpers.rb
shuttle-deploy-0.3.1 lib/shuttle/helpers.rb
shuttle-deploy-0.3.0 lib/shuttle/helpers.rb
shuttle-deploy-0.3.0.beta1 lib/shuttle/helpers.rb
shuttle-deploy-0.2.3 lib/shuttle/helpers.rb
shuttle-deploy-0.2.2 lib/shuttle/helpers.rb
shuttle-deploy-0.2.1 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta16 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta15 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta14 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta13 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta12 lib/shuttle/helpers.rb
shuttle-deploy-0.2.0.beta11 lib/shuttle/helpers.rb