Class: Tengine::Job::Jobnet::Builder
- Inherits:
-
Object
- Object
- Tengine::Job::Jobnet::Builder
- Includes:
- TSort
- Defined in:
- lib/tengine/job/jobnet/builder.rb
Instance Method Summary collapse
- #child_by_name(*args) ⇒ Object
- #children ⇒ Object
-
#initialize(client, boot_job_names, redirections) ⇒ Builder
constructor
A new instance of Builder.
- #new_edge(*args) ⇒ Object
- #prepare_end(*args, &block) ⇒ Object
- #process ⇒ Object
Constructor Details
#initialize(client, boot_job_names, redirections) ⇒ Builder
Returns a new instance of Builder.
7 8 9 10 11 12 13 |
# File 'lib/tengine/job/jobnet/builder.rb', line 7 def initialize(client, boot_job_names, redirections) @client, @boot_job_names, @redirections = client, boot_job_names, redirections.dup @graph = Hash.new do |h, k| h[k] = Array.new end @redirections.each do |(x, y)| @graph[x] << y end end |
Instance Method Details
#child_by_name(*args) ⇒ Object
16 |
# File 'lib/tengine/job/jobnet/builder.rb', line 16 def child_by_name(*args); @client.child_by_name(*args); end |
#children ⇒ Object
15 |
# File 'lib/tengine/job/jobnet/builder.rb', line 15 def children; @client.children; end |
#new_edge(*args) ⇒ Object
17 |
# File 'lib/tengine/job/jobnet/builder.rb', line 17 def new_edge(*args); @client.new_edge(*args); end |
#prepare_end(*args, &block) ⇒ Object
18 |
# File 'lib/tengine/job/jobnet/builder.rb', line 18 def prepare_end(*args, &block); @client.prepare_end(*args, &block); end |
#process ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tengine/job/jobnet/builder.rb', line 20 def process tsort rescue TSort::Cyclic raise Tengine::Job::DslError, "circular dependency found in jobnet ``#{@client.name}''" else build_start_edges build_edge_by_redirections prepare_end do |_end| build_end_edges(_end, @boot_job_names.map{|jn| [:start, jn]} + @redirections) end end |