Sha256: 4bb2d355ba7fd342da0cc39a6099cacab92aa11985d825ad91a23f3e30e36faa

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

module Archangel
  ##
  # Archangel engine
  #
  class Engine < ::Rails::Engine
    isolate_namespace Archangel
    engine_name "archangel"

    require "responders"

    initializer "archangel.load_locales" do |app|
      Archangel::THEME_DIRECTORIES.each.each do |path|
        path ||= Rails.root

        full_path = "#{path}/app/themes/*/locales/**/*.yml"

        Dir.glob(full_path).each { |dir| app.config.i18n.load_paths << dir }
      end
    end

    initializer "archangel.assets_path" do |app|
      Archangel::THEME_DIRECTORIES.each.each do |path|
        path ||= Rails.root

        full_path = "#{path}/app/themes/*/assets/*"

        Dir.glob(full_path).each { |dir| app.config.assets.paths << dir }
      end
    end

    initializer "archangel.precompile" do |app|
      Archangel::THEME_DIRECTORIES.each.each do |path|
        path ||= Rails.root

        full_path = Pathname.new("#{path}/app/themes/*/assets/**/*")

        allowed_regex = %r{
          ([^/]+)
          /assets/(javascripts|stylesheets)/
          ([^/]+)
          /(auth|backend|frontend).(js|css)
        }x

        Dir.glob(full_path).each do |file|
          next unless File.file?(file)

          file_path = Pathname.new(file).relative_path_from(path).to_s

          app.config.assets.precompile << file if file_path =~ allowed_regex
        end
      end
    end

    config.after_initialize do
      Rails.application.routes_reloader.reload!
    end

    config.action_controller.include_all_helpers = false

    config.generators do |gen|
      gen.test_framework :rspec,
                         fixtures: false,
                         view_specs: false,
                         helper_specs: true,
                         routing_specs: false,
                         controller_specs: true,
                         request_specs: true

      gen.fixture_replacement :factory_bot, dir: "spec/factories"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
archangel-0.0.7 lib/archangel/engine.rb
archangel-0.0.6 lib/archangel/engine.rb