Sha256: f7c3fb2350b279f696574d9f05dd07e791cf408f1135ad09bc2be81af9f47fc1
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Umwelt::History class Trace < Umwelt::Abstract::Interactor expose :continuity def initialize @queue = Queue.new # for phases @phases_index = {} @continuity = [] @timeline = {} end def call(history, phase_id) to_index(history.phases) @queue.push from_index(phase_id) loop do break if @queue.empty? process(@queue.pop) end @continuity = @timeline.values end def process(phase) @timeline[phase[:id]] = phase enqueue(phase) end def enqueue(phase) @queue.push from_index(phase.merge_id) unless phase.merge_id.nil? @queue.push from_index(phase.parent_id) unless phase.parent_id.nil? end def from_index(phase_id) phase = @phases_index[phase_id] phase || error!("Phase with ID #{phase_id} not exist, but referenced") end def to_index(phases) phases.each do |phase| @phases_index[phase[:id]] = phase end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
umwelt-0.2 | lib/umwelt/history/trace.rb |