lib/rails_erd/diagram/graphviz.rb in rails-erd-1.0.0 vs lib/rails_erd/diagram/graphviz.rb in rails-erd-1.1.0

- old
+ new

@@ -3,11 +3,11 @@ require "graphviz" require "erb" # Fix bad RegEx test in Ruby-Graphviz. GraphViz::Types::LblString.class_eval do - def output + def output # @private :nodoc: if /^<.*>$/m =~ @data @data else @data.to_s.inspect.gsub("\\\\", "\\") end @@ -82,11 +82,11 @@ } module Simple def entity_style(entity, attributes) {}.tap do |options| - options[:fontcolor] = options[:color] = :grey60 if entity.abstract? + options[:fontcolor] = options[:color] = :grey60 if entity.virtual? end end def relationship_style(relationship) {}.tap do |options| @@ -186,11 +186,12 @@ end save do raise "Saving diagram failed!\nOutput directory '#{File.dirname(filename)}' does not exist." unless File.directory?(File.dirname(filename)) begin - graph.output(filetype => filename) + # 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}" rescue StandardError => e @@ -208,13 +209,14 @@ end each_relationship do |relationship| from, to = relationship.source, relationship.destination unless draw_edge from.name, to.name, relationship_options(relationship) - if from.children.any? - from.children.each do |child| - draw_edge child.name, to.name, relationship_options(relationship) - end + from.children.each do |child| + draw_edge child.name, to.name, relationship_options(relationship) + end + to.children.each do |child| + draw_edge from.name, child.name, relationship_options(relationship) end end end private