Class: Kumade::Heroku
- Inherits:
-
Object
- Object
- Kumade::Heroku
- Defined in:
- lib/kumade/heroku.rb
Constant Summary collapse
- DEPLOY_BRANCH =
"deploy"
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
Instance Method Summary collapse
- #cedar? ⇒ Boolean
- #delete_deploy_branch ⇒ Object
- #heroku(command) ⇒ Object
-
#initialize ⇒ Heroku
constructor
A new instance of Heroku.
- #migrate_database ⇒ Object
- #restart_app ⇒ Object
- #sync ⇒ Object
Constructor Details
Instance Attribute Details
#git ⇒ Object (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
41 42 43 44 45 46 47 48 49 |
# File 'lib/kumade/heroku.rb', line 41 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_branch ⇒ Object
31 32 33 |
# File 'lib/kumade/heroku.rb', line 31 def delete_deploy_branch git.delete(DEPLOY_BRANCH, @branch) end |
#heroku(command) ⇒ Object
35 36 37 38 39 |
# File 'lib/kumade/heroku.rb', line 35 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_database ⇒ Object
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 |
#restart_app ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/kumade/heroku.rb', line 23 def restart_app unless Kumade.configuration.pretending? command_line = CommandLine.new("bundle exec heroku restart --remote #{Kumade.configuration.environment}") command_line.run_or_error("Failed to restart #{Kumade.configuration.environment}") end Kumade.configuration.outputter.success("Restarted #{Kumade.configuration.environment}") end |
#sync ⇒ Object
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 |