Sha256: e3bafbf1c4a78e9de1939ca7974dc6cd9e52be79712cce9e7d8aaa9446dcb474

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module Hanuman

  Stage.class_eval do
    class_attribute :draw_shape
    self.draw_shape = :record

    def to_graphviz(gv)
      gv.node(self.fullname,
        :label    => name,
        :shape    => draw_shape)
      # inputs.to_a.each do |input|
      #   gv.edge(input.fullname, self.fullname)
      # end
    end
  end

  Slottable.module_eval do
    def to_graphviz(gv, draw_edges=true)
      gv.node(self.fullname,
        :label    => name,
        :inslots  => inslots.to_a.map{|slot|  slot.name},
        :outslots => outslots.to_a.map{|slot| slot.name},
        :shape    => draw_shape
        )
      # inslots.to_a.each do |inslot|
      #   next unless inslot.input?
      #   gv.edge(inslot.input.fullname, inslot.fullname)
      # end
    end
  end

  InputSlot.class_eval do
    def fullname
      %Q{"#{stage.fullname}":#{name}}
    end
  end

  OutputSlot.class_eval do
    def fullname
      %Q{"#{stage.fullname}":out_#{name}}
    end
  end

  Resource.class_eval do
    self.draw_shape = :Mrecord
  end

  class Graph < Action
    self.draw_shape = :record
    def to_graphviz(gv)
      gv.graph(fullname, :label => name) do |gv2|
        stages.each_value{|stage| stage.to_graphviz(gv2) }
        edges.each_pair do |from, into|
          gv2.edge(from.fullname, into.fullname)
        end
      end
      super(gv)
    end
  end

  module ::Wukong::Universe
    def to_graphviz
      gv = Hanuman::Graphvizzer::Universe.new(:name => self.name)
      @workflows.each do |_, workflow|
        workflow.to_graphviz(gv)
      end
      @dataflows.each do |_, dataflow|
        dataflow.to_graphviz(gv)
      end
      gv
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wukong-3.0.0.pre lib/hanuman/graphviz.rb