Class: Jumpup::Heroku::Integrate

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Integrate

Returns a new instance of Integrate.



46
47
48
49
# File 'lib/jumpup/heroku/integrate.rb', line 46

def initialize(app)
  @app = app
  @envs = Env.all
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



8
9
10
# File 'lib/jumpup/heroku/integrate.rb', line 8

def app
  @app
end

Class Method Details

.add_remoteObject



26
27
28
29
30
31
# File 'lib/jumpup/heroku/integrate.rb', line 26

def self.add_remote
  message = "Adding Heroku git remotes for app #{integrate.app}"
  integrate.when_branch_send_to_heroku(message) do
    integrate.add_remote
  end
end

.checkObject



33
34
35
36
37
38
# File 'lib/jumpup/heroku/integrate.rb', line 33

def self.check
  message = "Checking if you can integrate to #{integrate.app}"
  integrate.when_branch_send_to_heroku(message) do
    integrate.check
  end
end

.deployObject



10
11
12
13
14
15
# File 'lib/jumpup/heroku/integrate.rb', line 10

def self.deploy
  message = "Starting to deploy on Heroku app #{integrate.app}"
  integrate.when_branch_send_to_heroku(message) do
    integrate.deploy
  end
end

.deploy_to_productionObject



17
18
19
20
21
22
23
24
# File 'lib/jumpup/heroku/integrate.rb', line 17

def self.deploy_to_production
  app = Env.all[:production_app]
  integrate = new(app)
  message = "Starting to deploy to production on Heroku app #{integrate.app}"
  integrate.when_branch_send_to_heroku(message) do
    integrate.deploy_to_production
  end
end

.integrateObject



40
41
42
43
44
# File 'lib/jumpup/heroku/integrate.rb', line 40

def self.integrate
  envs = Env.all
  app = envs[:app] || envs[:staging_app]
  new(app)
end

Instance Method Details

#add_remoteObject



90
91
92
93
# File 'lib/jumpup/heroku/integrate.rb', line 90

def add_remote
  remote = run_with_clean_env("git remote | grep heroku").strip
  exec_with_clean_env("git remote add heroku [email protected]:#{app}.git") if remote.blank?
end

#branches_that_send_to_herokuObject



60
61
62
# File 'lib/jumpup/heroku/integrate.rb', line 60

def branches_that_send_to_heroku
  [Env.all[:deploy_branch], Env.all[:deploy_to_production_branch]]
end

#checkObject



95
96
97
98
99
100
# File 'lib/jumpup/heroku/integrate.rb', line 95

def check
  unless authenticated_on_heroku?
    puts "----> You haven't logged in to heroku, please run `heroku login`"
    exit 1
  end
end

#deployObject



64
65
66
67
68
69
70
71
72
# File 'lib/jumpup/heroku/integrate.rb', line 64

def deploy
  run_database_checks if run_database_tasks?

  backup if run_database_tasks? and !skip_backup?
  push(Env.all[:deploy_branch])
  migrate if run_database_tasks?
  seed if run_database_tasks?
  restart
end

#deploy_to_productionObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/jumpup/heroku/integrate.rb', line 74

def deploy_to_production
  run_database_checks if run_database_tasks?

  confirm_deploy
  spec unless skip_spec?
  confirm_maintenance
  maintenance
  backup if run_database_tasks? and !skip_backup?
  tag
  push(Env.all[:deploy_to_production_branch])
  migrate if run_database_tasks?
  seed if run_database_tasks?
  close_maintenance
  restart
end

#when_branch_send_to_heroku(message, &block) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/jumpup/heroku/integrate.rb', line 51

def when_branch_send_to_heroku(message, &block)
  puts "--> #{message}"
  if branches_that_send_to_heroku.include?(actual_branch)
    block.call
  else
    puts "----> Skipping since you are in a feature branch [#{actual_branch}]"
  end
end