Sha256: e78d76a34f3fb6e2818c67736c2a7e80239f2e1877c29929ca7a135fc12c2220

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

require 'rails'

module Bastion
  class Engine < ::Rails::Engine

    isolate_namespace Bastion

    initializer 'bastion.assets_dispatcher', :before => :build_middleware_stack do |app|
      app.middleware.use ::ActionDispatch::Static, "#{Bastion::Engine.root}/app/assets/javascripts/bastion"
    end

    initializer 'bastion.mount_engine', :after => :build_middleware_stack do |app|
      app.routes_reloader.paths << "#{Bastion::Engine.root}/config/routes/mount_engine.rb"
      app.routes_reloader.paths.unshift("#{Bastion::Engine.root}/config/routes.rb")
    end

    initializer "bastion.assets", :group => :all do |app|
      app.config.assets.paths << "#{Bastion::Engine.root}/vendor/assets/stylesheets/bastion"
    end

    initializer "bastion.configure_assets", :group => :all do |app|
      SETTINGS[:bastion] = {:assets => {}} if SETTINGS[:bastion].nil?
      SETTINGS[:bastion][:assets] = {} if SETTINGS[:bastion][:assets].nil?

      SETTINGS[:bastion][:assets][:precompile] = [
        'bastion/bastion.css',
        'bastion/bastion.js',
      ]

      locale_files = Dir.glob("#{Bastion::Engine.root}/vendor/assets/javascripts/#{Bastion.localization_path("*")}")
      locale_files.map do |file|
        file.gsub!("#{Bastion::Engine.root}/vendor/assets/javascripts/", "")
      end

      SETTINGS[:bastion][:assets][:precompile].concat(locale_files)
    end

    initializer 'bastion.assets.precompile', :after => 'bastion.configure_assets' do |app|
      app.config.assets.precompile += SETTINGS[:bastion][:assets][:precompile]
    end

    initializer "angular_templates", :group => :all do |app|
      app.config.angular_templates.ignore_prefix = %w([bastion]*\/+)
    end

    initializer 'bastion.register_plugin', :before => :finisher_hook do
      Foreman::Plugin.register :bastion do
        requires_foreman '>= 1.16'
      end
    end

    rake_tasks do
      load "#{Bastion::Engine.root}/Rakefile"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bastion-5.0.9 lib/bastion/engine.rb
bastion-5.0.8 lib/bastion/engine.rb
bastion-5.0.7 lib/bastion/engine.rb