Sha256: b99eb886b079bcdc3e2e58dd72fe8bb79e878042bffa5b03b80d64236fac880a

Contents?: true

Size: 1010 Bytes

Versions: 7

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

require "bundler"
require "English"

module KapostDeploy
  module Heroku
    # Wraps the heroku shell environment
    # Derived from https://github.com/fastestforward/heroku_san
    class Shell
      def initialize(app)
        self.app = app
      end

      def run(command)
        sh("run " + command)
      end

      def sh(command)
        preflight_check_for_cli

        cmd = command.split(" ")
        cmd += ["--app", app]
        cmd << "--exit-code" if command =~ /^run/

        show_command = cmd.join(" ")
        ok = ::Bundler.with_clean_env { system "heroku", *cmd }

        ok or fail "Command failed with status (#{$CHILD_STATUS.exitstatus}): [heroku #{show_command}]"
      end

      private

      attr_accessor :app

      def preflight_check_for_cli
        if Bundler.with_clean_env { system("heroku version").nil? }
          fail "The Heroku Toolbelt is required for this action. http://toolbelt.heroku.com"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kapost_deploy-0.7.1 lib/kapost_deploy/heroku/shell.rb
kapost_deploy-0.7.0 lib/kapost_deploy/heroku/shell.rb
kapost_deploy-0.6.2 lib/kapost_deploy/heroku/shell.rb
kapost_deploy-0.6.1 lib/kapost_deploy/heroku/shell.rb
kapost_deploy-0.5.0 lib/kapost_deploy/heroku/shell.rb
kapost_deploy-0.4.0 lib/kapost_deploy/heroku/shell.rb
kapost_deploy-0.3.0 lib/kapost_deploy/heroku/shell.rb