Class: Dpl::Providers::Heroku

Inherits:
Dpl::Provider show all
Defined in:
lib/dpl/providers/heroku.rb,
lib/dpl/providers/heroku/api.rb,
lib/dpl/providers/heroku/git.rb

Direct Known Subclasses

Api, Git

Defined Under Namespace

Classes: Api, Git

Constant Summary collapse

URL =
'https://api.heroku.com'
HEADERS =
{
  'Accept': 'application/vnd.heroku+json; version=3',
  'User-Agent': user_agent,
}

Constants inherited from Dpl::Provider

Dpl::Provider::FOLDS, Dpl::Provider::STAGES

Instance Attribute Summary collapse

Attributes inherited from Dpl::Provider

#key_name, #repo_name

Instance Method Summary collapse

Methods inherited from Dpl::Provider

#before_finish, #before_init, #before_install, #before_prepare, #before_setup, #chmod, #cleanup, #cmd, #compact, #err, #error, #escape, examples, #expand, #file?, #finish?, #fold, #fold?, #info, #initialize, install_deps, install_deps?, #mkdir_p, move_files, #msg, #mv, #only, #open, #opt_for, #opt_key, #opts_for, #print, #quote, #read, #remove_dpl_dir, #rm_rf, #run, #run_cmds, #run_stage, #run_stage?, #script, #setup_dpl_dir, #setup_git_config, #setup_git_http_user_agent, #setup_git_ssh, #setup_ssh_key, #shell, #sq, #ssh_keygen, #symbolize, #try_ssh_access, #uncleanup, unmove_files, validate_runtimes, #wait_for_ssh_access, #warn

Methods included from Dpl::Provider::Dsl

#apt, #apt?, #cmds, #description, #env, #errs, #full_name, #gem, #gem?, #keep, #move, #msgs, #needs, #needs?, #node_js, #npm, #npm?, #opt, #path, #pip, #pip?, #python, #ruby_pre?, #ruby_version, #runtimes, #status, #strs, #summary, #user_agent, #vars

Methods included from Squiggle

#sq

Methods included from Assets

#asset

Methods included from Env

included, #opts

Methods included from ConfigFile

included, #opts

Methods included from Interpolate

#interpolate, #obfuscate, #vars

Methods included from Memoize

included

Constructor Details

This class inherits a constructor from Dpl::Provider

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



33
34
35
# File 'lib/dpl/providers/heroku.rb', line 33

def email
  @email
end

Instance Method Details

#loginObject



35
36
37
38
39
40
41
# File 'lib/dpl/providers/heroku.rb', line 35

def 
  print :login
  res = http.get('/account')
  handle_error(res) unless res.success?
  @email = JSON.parse(res.body)["email"]
  info :success
end

#restartObject



50
51
52
53
54
55
56
57
# File 'lib/dpl/providers/heroku.rb', line 50

def restart
  print :restart
  res = http.delete "/apps/#{app}/dynos" do |req|
    req.headers['Content-Type'] = 'application/json'
  end
  handle_error(res) unless res.success?
  info :success
end

#run_cmd(cmd) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/dpl/providers/heroku.rb', line 59

def run_cmd(cmd)
  print :run_cmd, cmd
  res = http.post "/apps/#{app}/dynos" do |req|
    req.headers['Content-Type'] = 'application/json'
    req.body = { command: cmd, attach: true}.to_json
  end
  handle_error(res) unless res.success?
  rendezvous(JSON.parse(res.body)['attach_url'])
end

#validateObject



43
44
45
46
47
48
# File 'lib/dpl/providers/heroku.rb', line 43

def validate
  print :validate
  res = http.get("/apps/#{app}")
  handle_error(res) unless res.success?
  info :success
end