Class: Jumpup::Heroku::Integrate

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Integrate

Returns a new instance of Integrate.



37
38
39
40
# File 'lib/jumpup/heroku/integrate.rb', line 37

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

Class Method Details

.add_remoteObject



15
16
17
# File 'lib/jumpup/heroku/integrate.rb', line 15

def self.add_remote
  integrate.add_remote
end

.checkObject



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

def self.check
  integrate.check
end

.deployObject



6
7
8
# File 'lib/jumpup/heroku/integrate.rb', line 6

def self.deploy
  integrate.deploy
end

.deploy_to_productionObject



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

def self.deploy_to_production
  app = Env.all[:production_app]
  new(app).deploy_to_production
end

.integrateObject



31
32
33
34
35
# File 'lib/jumpup/heroku/integrate.rb', line 31

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

.lockObject



23
24
25
# File 'lib/jumpup/heroku/integrate.rb', line 23

def self.lock
  integrate.lock
end

.unlockObject



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

def self.unlock
  integrate.unlock
end

Instance Method Details

#add_remoteObject



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

def add_remote
  puts "--> Adding Heroku git remotes for app #{app}"
  remote = run_with_clean_env("git remote | grep heroku", true).strip
  run_with_clean_env("git remote add heroku [email protected]:#{app}.git") if remote.blank?
end

#checkObject



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/jumpup/heroku/integrate.rb', line 70

def check
  puts "--> Checking if there's already someone integrating to #{app}"

  var = run_with_clean_env("heroku config -s --app #{app} | grep INTEGRATING_BY", true).strip
  integrating_by = var.split('=')[1]

  integrating_by.strip! unless integrating_by.blank?

  if integrating_by != user and not integrating_by.blank?
    puts "--> Project is already being integrated by '#{integrating_by}', halting"
    exit
  end
end

#deployObject



42
43
44
45
46
47
48
# File 'lib/jumpup/heroku/integrate.rb', line 42

def deploy
  backup
  push
  migrate
  seed
  restart
end

#deploy_to_productionObject



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

def deploy_to_production
  confirm_deploy
  spec
  confirm_maintenance
  maintenance
  backup
  tag
  push
  migrate
  seed
  close_maintenance
  restart
end

#lockObject



84
85
86
87
# File 'lib/jumpup/heroku/integrate.rb', line 84

def lock
  puts "--> Locking Heroku integration for you (#{user})"
  run_with_clean_env("heroku config:set INTEGRATING_BY='#{user}' --app #{app}")
end

#unlockObject



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

def unlock
  puts "--> Unlocking Heroku integration"
  run_with_clean_env("heroku config:unset INTEGRATING_BY --app #{app}")
end