Class: GithubHerokuDeployer::Heroku

Inherits:
Object
  • Object
show all
Defined in:
lib/github_heroku_deployer/heroku.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Heroku



7
8
9
10
11
12
# File 'lib/github_heroku_deployer/heroku.rb', line 7

def initialize(options)
  @heroku_api_key = options[:heroku_api_key]
  @heroku_app_name = options[:heroku_app_name]
  @heroku_organization_name = options[:heroku_organization_name]
  @logger = GithubHerokuDeployer.configuration.logger
end

Instance Method Details

#addon_add(addon, addon_options = {}) ⇒ Object



54
55
56
# File 'lib/github_heroku_deployer/heroku.rb', line 54

def addon_add(addon, addon_options={})
  heroku.post_addon(@heroku_app_name, addon, addon_options)
end

#addon_remove(addon) ⇒ Object



58
59
60
# File 'lib/github_heroku_deployer/heroku.rb', line 58

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

#appObject



19
20
21
# File 'lib/github_heroku_deployer/heroku.rb', line 19

def app
  @app ||= find_or_create_app
end

#config_set(config_vars) ⇒ Object



50
51
52
# File 'lib/github_heroku_deployer/heroku.rb', line 50

def config_set(config_vars)
  heroku.put_config_vars(@heroku_app_name, config_vars)
end

#create_appObject



33
34
35
36
# File 'lib/github_heroku_deployer/heroku.rb', line 33

def create_app
  @logger.info("Creating Heroku app with options: #{platform_api_options}")
  heroku_platform_api.organization_app.create(platform_api_options)
end

#destroy_appObject



42
43
44
# File 'lib/github_heroku_deployer/heroku.rb', line 42

def destroy_app
  heroku.delete_app(@heroku_app_name)
end

#find_appObject



29
30
31
# File 'lib/github_heroku_deployer/heroku.rb', line 29

def find_app
  heroku.get_app(@heroku_app_name)
end

#find_or_create_appObject



23
24
25
26
27
# File 'lib/github_heroku_deployer/heroku.rb', line 23

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

#herokuObject



14
15
16
# File 'lib/github_heroku_deployer/heroku.rb', line 14

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

#post_ps_scale(process, quantity) ⇒ Object



62
63
64
# File 'lib/github_heroku_deployer/heroku.rb', line 62

def post_ps_scale(process, quantity)
  heroku.post_ps_scale(@heroku_app_name, process, quantity)
end

#restart_appObject



38
39
40
# File 'lib/github_heroku_deployer/heroku.rb', line 38

def restart_app
  heroku.post_ps_restart(@heroku_app_name)
end

#run(command) ⇒ Object



46
47
48
# File 'lib/github_heroku_deployer/heroku.rb', line 46

def run(command)
  heroku.post_ps(@heroku_app_name, command)
end