On Tuesday, February 6, 2018 at 8:16:45 AM UTC-8, Matthew Ford wrote:
>
> Sorry to bring this back up from the grave - but has anyone got a good 
> script for generating an ERD? 
>
> The links I found pointing to pastie were broken. 
>

Here's the source code for sequel_dot:

require 'sequel'
Sequel::Model.plugin :subclasses
ARGV.each{|f| require f}
associations = []
classes = []
Sequel::Model.descendents.each do |c|
  next if c.name.empty?
  c.associations.each do |a|
    ar = c.association_reflection(a)
    associations << [c.name, ar[:type], ar.associated_class.name]
  end
end
styles = {:many_to_one=>:bold, :one_to_many=>:solid, 
:many_to_many=>:dashed, :one_to_one=>:dotted}
puts "digraph G {"
puts associations.uniq.map{|c, t, ac| "  #{c} -> #{ac} 
[style=#{styles[t]}];"}.sort
puts "}"

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to