Sha256: 3fbd4cd6a7a2bba362a0d6345824e2e2616507fc55f7ce7a03b0952c56a0d21c

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require "heroku-api"

module GithubHerokuDeployer
  class Heroku

    def initialize(options)
      @heroku_api_key = options[:heroku_api_key]
      @heroku_app_name = options[:heroku_app_name]
    end

    def heroku
      @heroku ||= ::Heroku::API.new(api_key: @heroku_api_key)
    end

    def app
      @app ||= find_or_create_app
    end

    def find_or_create_app
      find_app
    rescue ::Heroku::API::Errors::NotFound
      create_app
    end

    def find_app
      heroku.get_app(@heroku_app_name)
    end

    def create_app
      heroku.post_app(name: @heroku_app_name)
    end

    # def delete_app
    #   heroku.delete_app(@heroku_app_name)
    # end

    # def add_deployhooks_http(url)
    #   add_addon("deployhooks:http", url: url)
    # end

    # def add_addon(addon, options={})
    #   heroku.post_addon(@heroku_app_name, addon, options)
    # end

    # def delete_addon(addon)
    #   heroku.delete_addon(@heroku_app_name, addon)
    # end

    # def migrate
    #   heroku.post_ps(@heroku_app_name, "rake db:migrate")
    # end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
github_heroku_deployer-0.0.4 lib/github_heroku_deployer/heroku.rb
github_heroku_deployer-0.0.3 lib/github_heroku_deployer/heroku.rb
github_heroku_deployer-0.0.2 lib/github_heroku_deployer/heroku.rb