Class: Wizarddev::Heroku::Deploy
- Inherits:
-
Object
- Object
- Wizarddev::Heroku::Deploy
- Defined in:
- lib/wizarddev/heroku/deploy.rb
Instance Attribute Summary collapse
-
#heroku ⇒ Object
readonly
Returns the value of attribute heroku.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #deploy! ⇒ Object
- #execute(cmd) ⇒ Object
- #execute_remote(cmd) ⇒ Object
- #force_push ⇒ Object
-
#initialize(target) ⇒ Deploy
constructor
A new instance of Deploy.
- #push ⇒ Object
- #run_scripts ⇒ Object
- #tag_deploy ⇒ Object
Constructor Details
#initialize(target) ⇒ Deploy
Returns a new instance of Deploy.
21 22 23 24 25 |
# File 'lib/wizarddev/heroku/deploy.rb', line 21 def initialize(target) @target = target.to_s @app_config = load_config @heroku = PlatformClient.local_auth(app_name) end |
Instance Attribute Details
#heroku ⇒ Object (readonly)
Returns the value of attribute heroku.
6 7 8 |
# File 'lib/wizarddev/heroku/deploy.rb', line 6 def heroku @heroku end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/wizarddev/heroku/deploy.rb', line 6 def target @target end |
Class Method Details
.check_auth_config ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wizarddev/heroku/deploy.rb', line 8 def self.check_auth_config unless auth = PlatformClient.load_auth puts "Please make sure you have an up to date version of the heroku toolbelt and it's logged in" end unless config = File.exist?('app.json') puts "Please include an app.json in the root of this project." puts "`rails g wizarddev:app_json` will make one for you." end exit(1) unless auth && config end |
Instance Method Details
#deploy! ⇒ Object
27 28 29 30 31 |
# File 'lib/wizarddev/heroku/deploy.rb', line 27 def deploy! force_push? ? force_push : push tag_deploy run_scripts end |
#execute(cmd) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/wizarddev/heroku/deploy.rb', line 65 def execute(cmd) print "Executing '#{cmd}'\n" success = system(cmd) return true if success code = $CHILD_STATUS.to_i puts "Failed to Execute #{cmd} with code #{code}" exit(1) end |
#execute_remote(cmd) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/wizarddev/heroku/deploy.rb', line 56 def execute_remote(cmd) print "Executing '#{cmd}' on #{app_name}\n" output, code = heroku.run_with_code(cmd) puts output.gsub(/^/, "#\t") return true if code == 0 puts "Failed to Execute #{cmd} with code #{code}" exit(1) end |
#force_push ⇒ Object
38 39 40 41 |
# File 'lib/wizarddev/heroku/deploy.rb', line 38 def force_push puts "Force pushing HEAD to Heroku ..." execute "git push -f [email protected]:#{app_name}.git HEAD:master" end |
#push ⇒ Object
33 34 35 36 |
# File 'lib/wizarddev/heroku/deploy.rb', line 33 def push puts "Pushing HEAD to Heroku ..." execute "git push [email protected]:#{app_name}.git HEAD:master" end |
#run_scripts ⇒ Object
43 44 45 |
# File 'lib/wizarddev/heroku/deploy.rb', line 43 def run_scripts scripts.each { |script| run_script(script) } end |
#tag_deploy ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/wizarddev/heroku/deploy.rb', line 47 def tag_deploy return unless tag_name version = heroku.latest_release['version'] release_name = "#{tag_name}/v#{version}" puts "Tagging release with #{release_name}" execute "git tag -a #{release_name} -m 'Tagged release'" execute "git push #{source_repo} #{release_name}" end |