Class: TaskTempest::Task
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#execution ⇒ Object
Returns the value of attribute execution.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #format_log(message, show_duration = false) ⇒ Object
- #init(options = {}) ⇒ Object
-
#initialize(*args) ⇒ Task
constructor
A new instance of Task.
- #logger ⇒ Object
- #run ⇒ Object
- #start(*args) ⇒ Object
- #to_message ⇒ Object
Constructor Details
#initialize(*args) ⇒ Task
Returns a new instance of Task.
12 13 14 15 |
# File 'lib/task_tempest/task.rb', line 12 def initialize(*args) @id = generate_id @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/task_tempest/task.rb', line 9 def args @args end |
#execution ⇒ Object
Returns the value of attribute execution.
10 11 12 |
# File 'lib/task_tempest/task.rb', line 10 def execution @execution end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/task_tempest/task.rb', line 9 def id @id end |
Instance Method Details
#format_log(message, show_duration = false) ⇒ Object
39 40 41 42 43 |
# File 'lib/task_tempest/task.rb', line 39 def format_log(, show_duration = false) s = "{#{id}} <#{self.class}> #{}" s += " #{execution.duration.round(3)}" if show_duration and execution.finished? s end |
#init(options = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/task_tempest/task.rb', line 17 def init( = {}) @id = [:id] if [:id] @logger = TaskLogger.new([:logger], self) if [:logger] self end |
#logger ⇒ Object
31 32 33 |
# File 'lib/task_tempest/task.rb', line 31 def logger @logger ||= TaskLogger.new(Logger.new(STDOUT), self) end |
#run ⇒ Object
23 24 25 |
# File 'lib/task_tempest/task.rb', line 23 def run Kernel.record_requires!{ start(*args) } end |
#start(*args) ⇒ Object
27 28 29 |
# File 'lib/task_tempest/task.rb', line 27 def start(*args) raise "not implemented" end |
#to_message ⇒ Object
35 36 37 |
# File 'lib/task_tempest/task.rb', line 35 def [id, self.class.name, *args] end |