lib/rails_erd/tasks.rake in rails-erd-1.5.0 vs lib/rails_erd/tasks.rake in rails-erd-1.5.1

- old
+ new

@@ -1,10 +1,20 @@ +require 'graphviz/utils' + def say(message) puts message unless Rake.application.options.silent end namespace :erd do + task :check_dependencies do + include GraphViz::Utils + unless find_executable("dot", nil) + raise "Unable to find GraphViz's \"dot\" executable. Please " \ + "visit https://voormedia.github.io/rails-erd/install.html for installation instructions." + end + end + 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 @@ -19,10 +29,14 @@ Rake::Task[:environment].invoke say "Loading code in search of Active Record models..." begin Rails.application.eager_load! + + if Rails.application.respond_to?(:config) && !Rails.application.config.nil? + Rails.application.config.eager_load_namespaces.each(&:eager_load!) + end rescue Exception => err if Rake.application.options.trace raise else trace = Rails.backtrace_cleaner.clean(err.backtrace) @@ -32,10 +46,10 @@ end raise "Active Record was not loaded." unless defined? ActiveRecord end - task :generate => [:options, :load_models] do + task :generate => [:check_dependencies, :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