Class: RhoDevelopment::LiveUpdateTask

Inherits:
Object
  • Object
show all
Defined in:
lib/build/development/live_update_task.rb

Overview

Abstract class for all live update tasks

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descendantsArray

Returns LiveUpdateTask subclasses

Returns:

  • (Array)

    array of classes



14
15
16
# File 'lib/build/development/live_update_task.rb', line 14

def self.descendants
  ObjectSpace.each_object(Class).select { |each| each < self }
end

.fromHash(aHash) ⇒ Object

Creates an object, parametrises and returns it

Parameters:

  • aHash (Hash)

    values for new instance parameterization

Returns:



21
22
23
# File 'lib/build/development/live_update_task.rb', line 21

def self.fromHash(aHash)
  self.new
end

.taskNameString

Returns unique task name

Returns:

  • (String)

    Unique task name



8
9
10
# File 'lib/build/development/live_update_task.rb', line 8

def self.taskName
  self.name
end

Instance Method Details

#dispatchToUrl(anUri) ⇒ Object

Method serializes itself to a hash and sends post request with the hash to specified URI

Parameters:

  • anUri (URI)

    URI for post request



39
40
41
42
# File 'lib/build/development/live_update_task.rb', line 39

def dispatchToUrl(anUri)
  uri = URI.join(anUri, 'tasks/new')
  Net::HTTP.post_form(uri, {'taskName' => self.class.taskName})
end

#executeObject

Execute specific task action



26
27
28
29
30
31
32
33
34
35
# File 'lib/build/development/live_update_task.rb', line 26

def execute
  puts "Executing #{self.class.taskName} at #{Time::now}".primary
  begin
    self.action
  rescue => e
    puts "Executing #{self.class.taskName} failed".warning
    puts e.inspect.to_s.info
    puts e.backtrace.to_s.info
  end
end