lib/woodhouse/rails.rb in woodhouse-0.1.5 vs lib/woodhouse/rails.rb in woodhouse-1.0.0

- old
+ new

@@ -17,30 +17,32 @@ end Woodhouse.extend Woodhouse::RailsExtensions class Woodhouse::Rails < Rails::Engine -# config.autoload_paths << Rails.root.join("app/workers") - - initializer 'woodhouse' do - config_paths = %w[woodhouse.yml workling.yml].map{|file| - Rails.root.join("config/" + file) - } + initializer 'woodhouse-defaults', before: :load_config_initializers do + # Legacy config file just containing AMQP information. + legacy_config_path = Rails.root.join("config/workling.yml") + # New config file containing any configuration options. + config_path = Rails.root.join("config/woodhouse.yml") + # Preload everything in app/workers so default layout includes them Rails.root.join("app/workers").tap do |workers| Pathname.glob(workers.join("**/*.rb")).each do |worker_path| worker_path.relative_path_from(workers).basename(".rb").to_s.camelize.constantize end end + # Set up reasonable defaults Woodhouse.configure do |config| config.logger = ::Rails.logger - config_paths.each do |path| - if File.exist?(path) - config.server_info = YAML.load(File.read(path))[::Rails.env] - end - end + + config.load_yaml legacy_config_path, section: "server_info", environment: ::Rails.env + config.load_yaml config_path, environment: ::Rails.env end + end + + initializer "woodhouse-layout" do Woodhouse.finish_loading_layout! end end end