Sha256: 4754efb42edf5dd529bb5b5fa1c871fe48c3c5f75e46ccfbd7523f0ff07ed6cb

Contents?: true

Size: 1.92 KB

Versions: 31

Compression:

Stored size: 1.92 KB

Contents

# requires all dependencies
Gem.loaded_specs["avo"].dependencies.each do |d|
  require d.name
end
require "view_component/engine"

module Avo
  class Engine < ::Rails::Engine
    isolate_namespace Avo

    config.after_initialize do
      # Boot Avo
      ::Avo::App.boot
    end

    initializer "avo.autoload", before: :set_autoload_paths do |app|
      [
        ["app", "avo", "filters"],
        ["app", "avo", "actions"],
        ["app", "avo", "resources"]
      ].each do |path_params|
        path = Rails.root.join(*path_params)

        if File.directory? path.to_s
          Rails.autoloaders.main.push_dir path
        end
      end
    end

    initializer "avo.init_fields" do |app|
      # Init the fields
      ::Avo::App.init_fields
    end

    initializer "avo.reload_avo_files" do |app|
      if Avo::IN_DEVELOPMENT && ENV["RELOAD_AVO_FILES"]
        avo_root_path = Avo::Engine.root.to_s
        # Register reloader
        app.reloaders << app.config.file_watcher.new([], {
          Avo::Engine.root.join("lib", "avo").to_s => ["rb"]
        }) {}

        # What to do on file change
        config.to_prepare do
          Dir.glob(avo_root_path + "/lib/avo/**/*.rb".to_s).each { |c| load c }
          Avo::App.boot
        end
      end
    end

    initializer "webpacker.proxy" do |app|
      app.config.debug_exception_response_format = :api
      # app.config.logger = ::Logger.new(STDOUT)

      insert_middleware = begin
        Avo.webpacker.config.dev_server.present?
      rescue
        nil
      end

      if insert_middleware
        app.middleware.insert_before(
          0, Webpacker::DevServerProxy,
          ssl_verify_none: true,
          webpacker: Avo.webpacker
        )
      end
    end

    config.app_middleware.use(
      Rack::Static,
      urls: ["/avo-packs"],
      root: Avo::Engine.root.join("public")
    )

    config.generators do |g|
      g.test_framework :rspec, view_specs: false
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
avo-1.4.0.pre.1 lib/avo/engine.rb
avo-1.3.5 lib/avo/engine.rb
avo-1.3.5.pre.1 lib/avo/engine.rb
avo-1.3.4 lib/avo/engine.rb
avo-1.3.3 lib/avo/engine.rb
avo-1.3.2 lib/avo/engine.rb
avo-1.3.1 lib/avo/engine.rb
avo-1.3.0 lib/avo/engine.rb
avo-1.2.11.pre.4 lib/avo/engine.rb
avo-1.2.11.pre.3 lib/avo/engine.rb
avo-1.2.11.pre.2 lib/avo/engine.rb
avo-1.2.11.pre.1 lib/avo/engine.rb
avo-1.2.10 lib/avo/engine.rb
avo-1.2.9 lib/avo/engine.rb
avo-1.2.8 lib/avo/engine.rb
avo-1.2.7 lib/avo/engine.rb
avo-1.2.6 lib/avo/engine.rb
avo-1.2.6.pre.1 lib/avo/engine.rb
avo-1.2.5 lib/avo/engine.rb
avo-1.2.4 lib/avo/engine.rb