Class: Swineherd::Job
- Inherits:
-
Object
- Object
- Swineherd::Job
- Defined in:
- lib/swineherd/workflow/job.rb
Overview
Job class is at its core a rake task
Instance Method Summary collapse
- #cmd ⇒ Object
-
#dependencies(dependencies = nil) ⇒ Object
An array of job names as dependencies.
- #handle_dependencies ⇒ Object
-
#initialize(job_id, &blk) ⇒ Job
constructor
Initialize job, fill variables, and create rake task.
-
#name(name = nil) ⇒ Object
Will be the name of the rake task.
-
#raketask ⇒ Object
Every job is compiled into a rake task.
- #script(script = nil) ⇒ Object
Constructor Details
#initialize(job_id, &blk) ⇒ Job
Initialize job, fill variables, and create rake task
11 12 13 14 15 16 17 18 19 |
# File 'lib/swineherd/workflow/job.rb', line 11 def initialize job_id, &blk @job_id = job_id @name = '' @dependencies = [] @script = '' self.instance_eval(&blk) raketask handle_dependencies end |
Instance Method Details
#cmd ⇒ Object
47 48 49 |
# File 'lib/swineherd/workflow/job.rb', line 47 def cmd @script.cmd end |
#dependencies(dependencies = nil) ⇒ Object
An array of job names as dependencies
37 38 39 40 |
# File 'lib/swineherd/workflow/job.rb', line 37 def dependencies dependencies = nil return @dependencies unless dependencies @dependencies = dependencies end |
#handle_dependencies ⇒ Object
42 43 44 45 |
# File 'lib/swineherd/workflow/job.rb', line 42 def handle_dependencies return if dependencies.empty? task name => dependencies end |
#name(name = nil) ⇒ Object
Will be the name of the rake task
24 25 26 27 |
# File 'lib/swineherd/workflow/job.rb', line 24 def name name = nil return @name unless name @name = name end |
#raketask ⇒ Object
Every job is compiled into a rake task
54 55 56 57 58 |
# File 'lib/swineherd/workflow/job.rb', line 54 def raketask task name do @script.run end end |
#script(script = nil) ⇒ Object
29 30 31 32 |
# File 'lib/swineherd/workflow/job.rb', line 29 def script script = nil return @script unless script @script = script end |