Sha256: ab5810c1671fea11cf8e6c9ed8e8c8c5c8fbec2a3e9cd8305e85449f8de8f9f4

Contents?: true

Size: 1.62 KB

Versions: 41

Compression:

Stored size: 1.62 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:refs/heads/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

41 entries across 41 versions & 1 rubygems

Version Path
dpl-1.5.11.travis.435.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.11.travis.432.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.11.travis.430.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.11.travis.414.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.10 lib/dpl/provider/heroku/git.rb
dpl-1.5.10.travis.413.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.10.travis.402.1 lib/dpl/provider/heroku/git.rb
dpl-1.6.0.travis.399.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.9 lib/dpl/provider/heroku/git.rb
dpl-1.5.9.travis.397.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.9.travis.394.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.9.travis.393.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.9.travis.390.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.9.travis.373.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.9.travis.372.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8 lib/dpl/provider/heroku/git.rb
dpl-1.5.9.travis.368.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.367.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.365.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.364.1 lib/dpl/provider/heroku/git.rb