Class Tap::Join
In: lib/tap/join.rb
Parent: App::Api

Join defines an unsynchronized, multi-way join where n inputs send their results to m outputs. Flags can augment how the results are passed, in particular for array results.

Methods

associations   build   call   convert_to_spec   join   new   to_spec  

Attributes

inputs  [R]  An array of input tasks, or nil if the join has not been set.
outputs  [R]  An array of output tasks, or nil if the join has not been set.

Configurations

arrayify  [RW]  Converts each result into a one-member array before being passed onto outputs. Arrayify occurs before iterate and combined the two flags cancel. (false)
enq  [RW]  Causes the outputs to be enqued rather than executed immediately. (false)
iterate  [RW]  Iterates the results to the outputs. Non-array results are converted to arrays using to_ary:
  # results: [1,2,3]
  # outputs: call(input)
  result.to_ary.each {|r| app.exe(output, r) }

(false)

Public Class methods

[Source]

    # File lib/tap/join.rb, line 12
12:       def build(spec={}, app=Tap::App.current)
13:         inputs = resolve(spec['inputs']) do |var|
14:           app.get(var) or raise "missing join input: #{var}"
15:         end
16:         
17:         outputs = resolve(spec['outputs']) do |var|
18:           app.get(var) or raise "missing join output: #{var}"
19:         end
20:         
21:         new(spec['config'] || {}, app).join(inputs, outputs)
22:       end

Initializes a new join with the specified configuration.

[Source]

     # File lib/tap/join.rb, line 96
 96:     def initialize(config={}, app=Tap::App.current)
 97:       @inputs = nil
 98:       @outputs = nil
 99:       super
100:     end

Protected Class methods

[Source]

    # File lib/tap/join.rb, line 26
26:       def convert_to_spec(parser, args)
27:         {
28:           'config' => parser.nested_config,
29:           'inputs' => args.shift,
30:           'outputs' => args.shift
31:         }
32:       end

Public Instance methods

[Source]

     # File lib/tap/join.rb, line 132
132:     def associations
133:       [inputs + outputs]
134:     end

Executes the join logic for self, which by default passes the result to each output.

[Source]

     # File lib/tap/join.rb, line 126
126:     def call(result)
127:       outputs.each do |output|
128:         exe(output, result)
129:       end
130:     end

Sets self as a join between the inputs and outputs.

[Source]

     # File lib/tap/join.rb, line 103
103:     def join(inputs, outputs)
104:       @inputs.each do |input|
105:         input.joins.delete(self)
106:       end if @inputs
107:       
108:       inputs.each do |input|
109:         unless input.respond_to?(:joins)
110:           raise "input does not support joins: #{input.inspect}"
111:         end
112:       end
113:       
114:       @inputs = inputs
115:       
116:       inputs.each do |input|
117:         input.joins << self
118:       end if inputs
119:       
120:       @outputs = outputs
121:       self
122:     end

[Source]

     # File lib/tap/join.rb, line 136
136:     def to_spec
137:       spec = super
138:       spec['inputs'] = inputs.collect {|task| app.var(task) }
139:       spec['outputs'] = outputs.collect {|task| app.var(task) }
140:       spec
141:     end

[Validate]