Sha256: fd653310344a59523536219730add1aff7338b7b7b4030efc029ca04259a3190

Contents?: true

Size: 1.9 KB

Versions: 56

Compression:

Stored size: 1.9 KB

Contents

module PowerStencil
  module Utils

    module Graphviz

      include UniverseCompiler::Utils::Graphviz

      def graph_entities(entities, filename = nil)
        entities_to_process = unless config[:graphviz][:show_config]
                                entities.reject {|e| e.type == :project_config}
                              else
                                entities
                              end

        graph_options = {
            output_file_name: filename,
            graph_type:       config[:graphviz][:graph_type],
            file_type:        config[:graphviz][:file_type]
        }

        graph_entities_to_file entities_to_process, graph_options do |graph, cache|
          graph[:label] = config[:graphviz][:label]
          graph[:labelloc] = config[:graphviz][:labelloc]
          graph.each_node do |node_name|
            node = graph.get_node node_name
            entity = cache[:by_node][node]

            # Set default node attributes
            config[:graphviz][:node].each do |k,v|
              node[k] = v
            end
            fields_to_display = {}

            # Define node tooltip
            entity.fields.keys.each do |field_name|
              constraints = entity.class.fields_constraints[field_name]
              unless constraints.nil?
                # Remove relations as they are represented as edges
                next if constraints.keys.include? :has_one
                next if constraints.keys.include? :has_many
              end
              fields_to_display[field_name] = entity[field_name]
            end
            node[:tooltip] = fields_to_display.to_yaml

            # specific customizations
            if config[:graphviz][:customizations][entity.type]
              config[:graphviz][:customizations][entity.type].each do |k,v|
                node[k] = v
              end
            end
          end
        end

      end


    end

  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
power_stencil-0.10.0 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.8 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.7 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.6 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.5 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.4 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.3 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.2 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.1 lib/power_stencil/utils/graphviz.rb
power_stencil-0.9.0 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.14 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.13 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.12 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.11 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.10 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.9 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.8 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.7 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.6 lib/power_stencil/utils/graphviz.rb
power_stencil-0.8.5 lib/power_stencil/utils/graphviz.rb