Class: HerokuFeatureDeployments::Deployer

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku_feature_deployments/deployer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Deployer

Returns a new instance of Deployer.



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/heroku_feature_deployments/deployer.rb', line 4

def initialize(options = {})
  @branch_name = options[:branch_name] || get_branch_name
  @remote_name = options[:remote_name] || @branch_name.underscore
  @app_name = options[:app_name] || @branch_name.parameterize.
    gsub(/_/, '-')
  @full_app_name = "#{config.namespace}-#{@app_name}"

  DNSimple::Client.username = config.dnsimple_username
  DNSimple::Client.api_token = config.dnsimple_api_key

  PivotalTracker::Client.token = config.pivotal_tracker_api_key
  PivotalTracker::Client.use_ssl = true if config.pivotal_use_ssl
end

Instance Method Details

#deploy(pivotal_ticket_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/heroku_feature_deployments/deployer.rb', line 18

def deploy(pivotal_ticket_id)
  @pivotal_ticket_id = pivotal_ticket_id
  if app_exists?
    add_environment_variables
    add_collaborators
    push_code
    migrate_db
    add_pivotal_new_version_comment if @pivotal_ticket_id
  else
    create_app
    add_features
    add_collaborators
    add_addons
    add_to_dnsimple
    add_custom_domain
    add_environment_variables
    push_code
    create_db
    add_pivotal_comment if @pivotal_ticket_id
    create_pull_request
  end

  if config.domain
    run_command "open http://#{@app_name}.#{config.domain}"
  else
    run_command "open http://#{@full_app_name}.herokuapp.com"
  end
end

#undeployObject



47
48
49
50
51
# File 'lib/heroku_feature_deployments/deployer.rb', line 47

def undeploy
  delete_app
  remove_from_dnsimple
  remove_git_remote
end