lib/rails_erd/diagram/graphviz.rb in rails-erd-1.2.2 vs lib/rails_erd/diagram/graphviz.rb in rails-erd-1.3.0
- old
+ new
@@ -41,48 +41,50 @@
# PDF that is generated depends on the amount of hierarchy
# in your models.
# title:: The title to add at the top of the diagram. Defaults to
# <tt>"YourApplication domain model"</tt>.
class Graphviz < Diagram
- NODE_LABEL_TEMPLATES = { :html => "node.html.erb", :record => "node.record.erb" } # @private :nodoc:
+ NODE_LABEL_TEMPLATES = {
+ html: "node.html.erb",
+ record: "node.record.erb"
+ } # @private :nodoc:
NODE_WIDTH = 130 # @private :nodoc:
FONTS = Config.font_names_based_on_os
# Default graph attributes.
GRAPH_ATTRIBUTES = {
- :rankdir => :LR,
- :ranksep => 0.5,
- :nodesep => 0.4,
- :pad => "0.4,0.4",
- :margin => "0,0",
- :concentrate => true,
- :labelloc => :t,
- :fontsize => 13,
- :fontname => FONTS[:bold]
+ rankdir: :LR,
+ ranksep: 0.5,
+ nodesep: 0.4,
+ pad: "0.4,0.4",
+ margin: "0,0",
+ concentrate: true,
+ labelloc: :t,
+ fontsize: 13,
+ fontname: FONTS[:bold]
}
# Default node attributes.
NODE_ATTRIBUTES = {
- :shape => "Mrecord",
- :fontsize => 10,
- :fontname => FONTS[:normal],
- :margin => "0.07,0.05",
- :penwidth => 1.0
+ shape: "Mrecord",
+ fontsize: 10,
+ fontname: FONTS[:normal],
+ margin: "0.07,0.05",
+ penwidth: 1.0
}
# Default edge attributes.
EDGE_ATTRIBUTES = {
- :fontname => FONTS[:normal],
- :fontsize => 8,
- :dir => :both,
- :arrowsize => 0.9,
- :penwidth => 1.0,
- :labelangle => 32,
- :labeldistance => 1.8,
- :fontsize => 7
+ fontname: FONTS[:normal],
+ fontsize: 7,
+ dir: :both,
+ arrowsize: 0.9,
+ penwidth: 1.0,
+ labelangle: 32,
+ labeldistance: 1.8,
}
module Simple
def entity_style(entity, attributes)
{}.tap do |options|
@@ -99,11 +101,14 @@
options[:arrowtail] = relationship.many_to? ? "normal" : "none"
end
end
def specialization_style(specialization)
- { :color => :grey60, :arrowtail => :onormal, :arrowhead => :none, :arrowsize => 1.2 }
+ { color: :grey60,
+ arrowtail: :onormal,
+ arrowhead: :none,
+ arrowsize: 1.2 }
end
end
module Crowsfoot
include Simple
@@ -192,14 +197,16 @@
begin
# GraphViz doesn't like spaces in the filename
graph.output(filetype => filename.gsub(/\s/,"\\ "))
filename
rescue RuntimeError => e
- raise "Saving diagram failed!\nGraphviz produced errors. Verify it has support for filetype=#{options.filetype}, or use filetype=dot." <<
- "\nOriginal error: #{e.message.split("\n").last}"
+ raise "Saving diagram failed!\nGraphviz produced errors. Verify it " +
+ "has support for filetype=#{options.filetype}, or use " +
+ "filetype=dot.\nOriginal error: #{e.message.split("\n").last}"
rescue StandardError => e
- raise "Saving diagram failed!\nVerify that Graphviz is installed and in your path, or use filetype=dot."
+ raise "Saving diagram failed!\nVerify that Graphviz is installed " +
+ "and in your path, or use filetype=dot."
end
end
each_entity do |entity, attributes|
draw_node entity.name, entity_options(entity, attributes)
@@ -265,10 +272,10 @@
entity_style(entity, attributes).merge :label => label
end
def relationship_options(relationship)
relationship_style(relationship).tap do |options|
- # Edges with a higher weight are optimised to be shorter and straighter.
+ # Edges with a higher weight are optimized to be shorter and straighter.
options[:weight] = relationship.strength
# Indirect relationships should not influence node ranks.
options[:constraint] = false if relationship.indirect?
end