Sha256: 336f4f005bec71a6174058ea3a5c9e86fd6e41b15fc41c70a13349a610d19242

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

require "github_heroku_deployer/exceptions"
require "github_heroku_deployer/configuration"
require "github_heroku_deployer/git"
require "github_heroku_deployer/heroku"
require "github_heroku_deployer/version"

module GithubHerokuDeployer
  class << self
    # A GithubHerokuDeployer configuration object. Must act like a hash and 
    # return sensible values for all GithubHerokuDeployer configuration options.
    #
    # @see GithubHerokuDeployer::Configuration.
    attr_writer :configuration

    # The configuration object.
    #
    # @see GithubHerokuDeployer.configure
    def configuration
      @configuration ||= Configuration.new
    end

    # Call this method to modify defaults in your initializers.
    #
    # @example
    #   GithubHerokuDeployer.configure do |config|
    #     config.github_repo     = ENV["GITHUB_REPO"]
    #     config.heroku_api_key  = ENV["HEROKU_API_KEY"]
    #     config.heroku_app_name = ENV["HEROKU_APP_NAME"]
    #     config.heroku_repo     = ENV["HEROKU_REPO"]
    #     config.heroku_username = ENV["HEROKU_USERNAME"]
    #     config.ssh_enabled     = false
    #   end
    def configure
      yield(configuration)
    end

    def deploy(options={})
      options = configuration.merge(options)
      validate_options(options)
      heroku_find_or_create_app(options)
      git_push_app_to_heroku(options)
      true
    end

    def validate_options(options)
      configuration.validate_presence(options)
    end

    def heroku_find_or_create_app(options)
      Heroku.new(options).find_or_create_app
    end

    def git_push_app_to_heroku(options)
      Git.new(options).push_app_to_heroku
    end
  end # class << self
end

Version data entries

4 entries across 4 versions & 1 rubygems

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