Class: CapExtWebistrano::Task
- Inherits:
-
Object
- Object
- CapExtWebistrano::Task
- Defined in:
- lib/cap_ext_webistrano/task.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
-
#initialize(task, config) ⇒ Task
constructor
A new instance of Task.
- #loop_latest_deployment ⇒ Object
- #print_diff(deployment) ⇒ Object
- #run ⇒ Object
- #set_access_data ⇒ Object
Constructor Details
#initialize(task, config) ⇒ Task
Returns a new instance of Task.
9 10 11 12 13 |
# File 'lib/cap_ext_webistrano/task.rb', line 9 def initialize(task, config) @task = task @config = config @log = "" end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
7 8 9 |
# File 'lib/cap_ext_webistrano/task.rb', line 7 def log @log end |
#task ⇒ Object
Returns the value of attribute task.
7 8 9 |
# File 'lib/cap_ext_webistrano/task.rb', line 7 def task @task end |
Instance Method Details
#loop_latest_deployment ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cap_ext_webistrano/task.rb', line 21 def loop_latest_deployment still_running = true = @deployment. while still_running sleep 5 @deployment..merge!() @deployment.reload print_diff(@deployment) still_running = false unless @deployment.completed_at.nil? end end |
#print_diff(deployment) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/cap_ext_webistrano/task.rb', line 33 def print_diff(deployment) if deployment.log diff = deployment.log diff.slice!(log) print diff log << diff end end |
#run ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cap_ext_webistrano/task.rb', line 42 def run set_access_data @project = Project.find_by_name(@config[:application]) @stage = @project.find_stage(@config[:stage]) params = { :task => task, :stage_id => @stage.id, :project_id => @project.id, :description => @config[:description] } params.merge!(:prompt_config => @config[:prompt_config]) if @config.exists?(:prompt_config) @deployment = Deployment.create(params) loop_latest_deployment exit(-1) unless @deployment.status == "success" end |
#set_access_data ⇒ Object
15 16 17 18 19 |
# File 'lib/cap_ext_webistrano/task.rb', line 15 def set_access_data [Project, Stage, Deployment].each do |klazz| klazz.configure(@config) end end |