Class: Pipa
- Inherits:
-
Object
- Object
- Pipa
- Defined in:
- lib/pipa.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(stages) ⇒ Pipa
constructor
A new instance of Pipa.
- #wait ⇒ Object
Constructor Details
#initialize(stages) ⇒ Pipa
Returns a new instance of Pipa.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pipa.rb', line 6 def initialize(stages) @stages = stages @to_be_executed = Set.new( stages.map{|k,v| k} ) @executed = Set.new @log = {} @ret = {} @stages.each do |name, attributes| attributes["dependencies"] ||= [] attributes["dependencies_set"] = Set.new(attributes["dependencies"]) end @threads = [] @success = true end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pipa.rb', line 23 def execute @to_be_executed.delete_if do |stage| if resolved_dependencies? stage execute_stage(stage) true else false end end end |
#wait ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/pipa.rb', line 34 def wait @threads.map(&:join) unless @to_be_executed.empty? log_error "Some stages couldn't be executed: #{@to_be_executed.to_a}" end @success end |