Sha256: a58f3bb8cab0193aea482ec25f39b92e50d153d787df9d181bc0fdd7a3b0cb6b
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
def say(message) puts message unless Rake.application.options.silent end namespace :erd do task :options do (RailsERD.options.keys.map(&:to_s) & ENV.keys).each do |option| RailsERD.options[option.to_sym] = case ENV[option] when "true", "yes" then true when "false", "no" then false when /,/ then ENV[option].split(/\s*,\s*/) else ENV[option].to_sym end end end task :load_models do say "Loading application environment..." Rake::Task[:environment].invoke say "Loading code in search of Active Record models..." begin Rails.application.eager_load! rescue Exception => err if Rake.application.options.trace raise else trace = Rails.backtrace_cleaner.clean(err.backtrace) error = (["Loading models failed!\nError occurred while loading application: #{err} (#{err.class})"] + trace).join("\n ") raise error end end raise "Active Record was not loaded." unless defined? ActiveRecord end task :generate => [:options, :load_models] do say "Generating Entity-Relationship Diagram for #{ActiveRecord::Base.descendants.length} models..." require "rails_erd/diagram/graphviz" file = RailsERD::Diagram::Graphviz.create say "Done! Saved diagram to #{file}." end end desc "Generate an Entity-Relationship Diagram based on your models" task :erd => "erd:generate", :arg1, :arg2, :arg3 do |t, args| say "Usage: rake erd <classname> <outputfile> <traversal depth>" if args[0] == nil say "Required field: Root Class node to start with" end if args[1] == nil say "Required field: output file name" end args[2] ||= 1 RailsERD::Custom.new(args[0], args[1], args[2]) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jw-rails-erd-1.4.5 | lib/rails_erd/tasks.rake |