Sha256: 03884a2ce7f80ace3b009f264d7d2db12b2df6defb72e0b8092a4608c87ce078

Contents?: true

Size: 1009 Bytes

Versions: 57

Compression:

Stored size: 1009 Bytes

Contents

module Dynflow
  class ExecutionHistory
    include Algebrick::TypeCheck
    include Enumerable

    Event = Algebrick.type do
      fields! time:     Integer,
              name:     String,
              world_id: type { variants String, NilClass }
    end

    module Event
      def inspect
        "#{Time.at(time).utc}: #{name}".tap { |s| s << " @ #{world_id}" if world_id }
      end
    end

    attr_reader :events

    def initialize(events = [])
      @events = (events || []).each { |e| Type! e, Event }
    end

    def each(&block)
      @events.each(&block)
    end

    def add(name, world_id = nil)
      @events << Event[Time.now.to_i, name, world_id]
    end

    def to_hash
      @events.map(&:to_hash)
    end

    def inspect
      "ExecutionHistory: #{ @events.inspect }"
    end

    def self.new_from_hash(value)
      value ||= [] # for compatibility with tasks before the
      # introduction of execution history
      self.new(value.map { |hash| Event[hash] })
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
dynflow-1.3.0 lib/dynflow/execution_history.rb
dynflow-1.2.3 lib/dynflow/execution_history.rb
dynflow-1.2.2 lib/dynflow/execution_history.rb
dynflow-1.2.1 lib/dynflow/execution_history.rb
dynflow-1.2.0 lib/dynflow/execution_history.rb
dynflow-1.2.0.pre1 lib/dynflow/execution_history.rb
dynflow-1.1.6 lib/dynflow/execution_history.rb
dynflow-1.1.5 lib/dynflow/execution_history.rb
dynflow-1.1.4 lib/dynflow/execution_history.rb
dynflow-1.1.3 lib/dynflow/execution_history.rb
dynflow-1.1.2 lib/dynflow/execution_history.rb
dynflow-1.1.1 lib/dynflow/execution_history.rb
dynflow-1.1.0 lib/dynflow/execution_history.rb
dynflow-1.0.5 lib/dynflow/execution_history.rb
dynflow-1.0.4 lib/dynflow/execution_history.rb
dynflow-1.0.3 lib/dynflow/execution_history.rb
dynflow-1.0.2 lib/dynflow/execution_history.rb
dynflow-1.0.1 lib/dynflow/execution_history.rb
dynflow-1.0.0 lib/dynflow/execution_history.rb
dynflow-0.8.37 lib/dynflow/execution_history.rb