Sha256: c1b9b90b3613833c7964a18aa3469845f03cd3b13350852f6b06438f936aea0d

Contents?: true

Size: 1.61 KB

Versions: 79

Compression:

Stored size: 1.61 KB

Contents

module DPL
  class Provider
    module Heroku
      class Git < Provider
        requires 'heroku-api'
        requires 'rendezvous'

        def api
          @api ||= ::Heroku::API.new(:api_key => option(:api_key)) unless options[:user] and options[:password]
          @api ||= ::Heroku::API.new(:user => options[:user], :password => options[:password])
        end

        def user
          @user ||= api.get_user.body["email"]
        end

        def check_auth
          log "authenticated as %s" % user
        end

        def check_app
          info = api.get_app(option(:app)).body
          options[:git] ||= info['git_url']
          log "found app #{info['name']}"
        end

        def setup_key(file)
          api.post_key File.read(file)
        end

        def remove_key
          api.delete_key(option(:key_name))
        end

        def push_app
          context.shell "git push #{option(:git)} HEAD:master -f"
        end

        def run(command)
          data           = api.post_ps(option(:app), command, :attach => true).body
          rendezvous_url = data['rendezvous_url']
          Rendezvous.start(:url => rendezvous_url) unless rendezvous_url.nil?
        end

        def restart
          api.post_ps_restart option(:app)
        end

        def deploy
          super
        rescue ::Heroku::API::Errors::NotFound => error
          raise Error, "#{error.message} (wrong app #{options[:app].inspect}?)", error.backtrace
        rescue ::Heroku::API::Errors::Unauthorized => error
          raise Error, "#{error.message} (wrong API key?)", error.backtrace
        end
      end
    end
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
dpl-1.5.3.travis.261.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.259.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.257.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.255.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.254.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.252.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.248.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.249.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.245.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.244.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.243.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.242.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.241.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.240.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.226.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.220.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.218.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.217.2 lib/dpl/provider/heroku/git.rb
dpl-1.5.2.travis.216.2 lib/dpl/provider/heroku/git.rb