Sha256: 65f4a34c4ed601c5957a7ea23eaf5e2a3854ca339990e67dad7c5fe3f2918da2

Contents?: true

Size: 1.91 KB

Versions: 29

Compression:

Stored size: 1.91 KB

Contents

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

# In development we should load the engine so we get the autoload for components
if ENV["RAILS_ENV"] === "development"
  require "view_component/engine"
end

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

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

    config.i18n.load_path += Dir[Avo::Engine.root.join('lib', 'generators', 'avo', 'templates', 'locales', '*.{rb,yml}')]

    initializer "avo.autoload", before: :set_autoload_paths do |app|
      [
        ["app", "avo", "fields"],
        ["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 "debug_exception_response_format" do |app|
      app.config.debug_exception_response_format = :api
      # app.config.logger = ::Logger.new(STDOUT)
    end

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

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

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
avo-1.25.2 lib/avo/engine.rb
avo-1.25.1 lib/avo/engine.rb
avo-1.25.0 lib/avo/engine.rb
avo-1.24.2 lib/avo/engine.rb
avo-1.24.1 lib/avo/engine.rb
avo-1.24.0 lib/avo/engine.rb
avo-1.23.0 lib/avo/engine.rb
avo-1.22.4 lib/avo/engine.rb
avo-1.22.3 lib/avo/engine.rb
avo-1.22.2 lib/avo/engine.rb
avo-1.22.1 lib/avo/engine.rb
avo-1.22.1.pre.2 lib/avo/engine.rb
avo-1.22.1.pre.1 lib/avo/engine.rb
avo-1.22.0 lib/avo/engine.rb
avo-1.22.0.pre.1 lib/avo/engine.rb
avo-1.21.1.pre.1 lib/avo/engine.rb
avo-1.21.0 lib/avo/engine.rb
avo-1.20.2.pre.2 lib/avo/engine.rb
avo-1.20.2.pre.1 lib/avo/engine.rb
avo-1.21.0.pre.1 lib/avo/engine.rb