Class: Kumade::Heroku

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

Constant Summary collapse

DEPLOY_BRANCH =
"deploy"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeroku

Returns a new instance of Heroku.


8
9
10
11
# File 'lib/kumade/heroku.rb', line 8

def initialize
  @git    = Git.new
  @branch = @git.current_branch
end

Instance Attribute Details

#gitObject (readonly)

Returns the value of attribute git


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

def git
  @git
end

Instance Method Details

#cedar?Boolean

Returns:

  • (Boolean)

33
34
35
36
37
38
39
40
41
# File 'lib/kumade/heroku.rb', line 33

def cedar?
  return @cedar unless @cedar.nil?

  command_line = CommandLine.new("bundle exec heroku stack --remote #{Kumade.configuration.environment}")

  @cedar = command_line.run_or_error.split("\n").grep(/\*/).any? do |line|
    line.include?("cedar")
  end
end

#delete_deploy_branchObject


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

def delete_deploy_branch
  git.delete(DEPLOY_BRANCH, @branch)
end

#heroku(command) ⇒ Object


27
28
29
30
31
# File 'lib/kumade/heroku.rb', line 27

def heroku(command)
  full_heroku_command = "#{bundle_exec_heroku} #{command} --remote #{Kumade.configuration.environment}"
  command_line = CommandLine.new(full_heroku_command)
  command_line.run_or_error("Failed to run #{command} on Heroku")
end

#migrate_databaseObject


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

def migrate_database
  heroku("rake db:migrate") unless Kumade.configuration.pretending?
  Kumade.configuration.outputter.success("Migrated #{Kumade.configuration.environment}")
end

#syncObject


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

def sync
  git.create(DEPLOY_BRANCH)
  git.push("#{DEPLOY_BRANCH}:master", Kumade.configuration.environment, true)
end