Sha256: 58fbc8afc95ddc795c27f50ba7df629449360e264149fa75379e3983601cb390

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'oai'

module Bulkrax
  class Engine < ::Rails::Engine
    isolate_namespace Bulkrax
    initializer :append_migrations do |app|
      if !app.root.to_s.match(root.to_s) && app.root.join('db/migrate').children.none? { |path| path.fnmatch?("*.bulkrax.rb") }
        config.paths["db/migrate"].expanded.each do |expanded_path|
          app.config.paths["db/migrate"] << expanded_path
        end
      end
    end

    config.generators do |g|
      g.test_framework :rspec
      begin
        g.fixture_replacement :factory_bot, dir: 'spec/factories'
      rescue
        nil
      end
    end

    config.after_initialize do
      my_engine_root = Bulkrax::Engine.root.to_s
      paths = ActionController::Base.view_paths.collect(&:to_s)
      hyrax_path = paths.detect { |path| path.match('/hyrax-') }
      paths = if hyrax_path
                paths.insert(paths.index(hyrax_path), my_engine_root + '/app/views')
              else
                paths.insert(0, my_engine_root + '/app/views')
              end
      ActionController::Base.view_paths = paths
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bulkrax-1.0.2 lib/bulkrax/engine.rb
bulkrax-1.0.1 lib/bulkrax/engine.rb
bulkrax-1.0.0 lib/bulkrax/engine.rb