lib/coupdoeil/engine.rb
# frozen_string_literal: true module Coupdoeil class Engine < ::Rails::Engine isolate_namespace Coupdoeil config.eager_load_namespaces << Coupdoeil config.coupdoeil = ActiveSupport::OrderedOptions.new config.autoload_once_paths = [ "#{root}/app/controllers", "#{root}/app/controllers/concerns", "#{root}/app/helpers", "#{root}/app/models", "#{root}/app/models/concerns", ] # If you don't want to precompile Coupdoeil's assets (eg. because you're using webpack), # you can do this in an intiailzer: # # config.after_initialize do # config.assets.precompile -= Coupdoeil::Engine::PRECOMPILE_ASSETS # end # # If you just want to remove specific css: # # config.after_initialize do # config.assets.precompile -= %w[coupdoeil/popover-arrow.css] # end PRECOMPILE_ASSETS = [ "coupdoeil.js", "coupdoeil.min.js", "coupdoeil.min.js.map", "coupdoeil/popover.css", "coupdoeil/popover-arrow.css", "coupdoeil/popover-animation.css", ] initializer "coupdoeil.assets" do if Rails.application.config.respond_to?(:assets) Rails.application.config.assets.precompile += PRECOMPILE_ASSETS end end initializer "coupdoeil.logger" do stdout_logger = ActiveSupport::Logger.new($stdout) stdout_logger.formatter = ::Logger::Formatter.new tagged_stdout_logger = ActiveSupport::TaggedLogging.new(stdout_logger) config.coupdoeil.logger = tagged_stdout_logger.tagged("Coupdoeil") end initializer "coupdoeil.helpers", before: :load_config_initializers do ActiveSupport.on_load(:action_controller_base) do helper Coupdoeil::Engine.helpers end end initializer "coupdoeil.view_paths" do config.to_prepare do views = Rails.application.config.paths["app/views"].existent views += Rails.application.config.paths.add("app/popovers").existent views += Rails.application.config.paths.add("app/popovers/layouts").existent Coupdoeil::Popover.prepend_view_path(views) end end initializer "coupdoeil.routes" do |app| app.routes.append do post "coupdoeil/popover", to: "coupdoeil/popovers#create" end end end end