module Jumpup module Heroku class << self attr_accessor :configuration end def self.configure self.configuration ||= Configuration.new yield(configuration) end class Configuration attr_accessor :app, :staging_app, :production_app, :run_database_tasks, :host def initialize @run_database_tasks ||= true @host ||= 'heroku.com' end def account(account_token) if account_token == current_account self.app = nil self.host = "heroku.#{account_token}" yield(self) end end def valid? boolean_run_database_tasks? && (only_app? || only_production_and_staging_apps?) end private def current_account (ENV["HEROKU_ACCOUNT"] || %x{ git config heroku.account }.chomp).to_sym end def only_app? app && staging_app.nil? && production_app.nil? end def only_production_and_staging_apps? staging_app && production_app && app.nil? end def boolean_run_database_tasks? run_database_tasks.is_a?(TrueClass) || run_database_tasks.is_a?(FalseClass) end end end end