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.8.travis.359.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.356.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.336.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.330.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.328.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.326.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.325.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.312.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.309.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.308.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.8.travis.303.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.7 lib/dpl/provider/heroku/git.rb
dpl-1.5.6 lib/dpl/provider/heroku/git.rb
dpl-1.5.5 lib/dpl/provider/heroku/git.rb
dpl-1.5.5.travis.270.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.4 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.269.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.268.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.264.1 lib/dpl/provider/heroku/git.rb
dpl-1.5.3.travis.265.1 lib/dpl/provider/heroku/git.rb