lib/rails_erd/diagram/graphviz.rb in rails-erd-0.4.5 vs lib/rails_erd/diagram/graphviz.rb in rails-erd-1.0.0
- old
+ new
@@ -101,10 +101,30 @@
def specialization_style(specialization)
{ :color => :grey60, :arrowtail => :onormal, :arrowhead => :none, :arrowsize => 1.2 }
end
end
+ module Crowsfoot
+ include Simple
+ def relationship_style(relationship)
+ {}.tap do |options|
+ options[:style] = :dotted if relationship.indirect?
+
+ # Cardinality is "look-across".
+ dst = relationship.to_many? ? "crow" : "tee"
+ src = relationship.many_to? ? "crow" : "tee"
+
+ # Participation is "look-across".
+ dst << (relationship.destination_optional? ? "odot" : "tee")
+ src << (relationship.source_optional? ? "odot" : "tee")
+
+ options[:arrowsize] = 0.6
+ options[:arrowhead], options[:arrowtail] = dst, src
+ end
+ end
+ end
+
module Bachman
include Simple
def relationship_style(relationship)
{}.tap do |options|
options[:style] = :dotted if relationship.indirect?
@@ -114,10 +134,11 @@
src = relationship.destination_optional? ? "odot" : "dot"
# Cardinality is "look-across".
dst << "normal" if relationship.to_many?
src << "normal" if relationship.many_to?
+
options[:arrowsize] = 0.6
options[:arrowhead], options[:arrowtail] = dst, src
end
end
end
@@ -202,14 +223,14 @@
def node_exists?(name)
!!graph.get_node(escape_name(name))
end
def draw_node(name, options)
- graph.add_node escape_name(name), options
+ graph.add_nodes escape_name(name), options
end
def draw_edge(from, to, options)
- graph.add_edge graph.get_node(escape_name(from)), graph.get_node(escape_name(to)), options if node_exists?(from) and node_exists?(to)
+ graph.add_edges graph.get_node(escape_name(from)), graph.get_node(escape_name(to)), options if node_exists?(from) and node_exists?(to)
end
def escape_name(name)
"m_#{name}"
end