88 lines
2.7 KiB
Ruby
88 lines
2.7 KiB
Ruby
|
|
# Asset groups
|
|
if (Rails.groups.map(&:to_s) & %w[development assets test]).any?
|
|
require "sass-rails"
|
|
#require "js-routes"
|
|
#require "momentjs-rails"
|
|
require 'coffee-rails'
|
|
#require "pickadate-rails"
|
|
end
|
|
|
|
require "slim-rails"
|
|
#require 'record_collection'
|
|
require 'request_store'
|
|
require 'ransack'
|
|
require 'devise'
|
|
require 'devise-token_authenticatable'
|
|
require 'state_machines-activerecord'
|
|
require 'simple_form'
|
|
require 'redcarpet'
|
|
require 'exception_notification'
|
|
require 'facets/enumerable/map_send'
|
|
require 'memoist'
|
|
require 'cancancan'
|
|
|
|
if Rails::VERSION::MAJOR < 5
|
|
ActiveRecord::Associations::Builder::Association.valid_options |= [:optional]
|
|
class ActiveRecord::Migration
|
|
# rails5 compatibility
|
|
def self.[](*)
|
|
self
|
|
end
|
|
end
|
|
end
|
|
|
|
module Dunlop
|
|
class Engine < ::Rails::Engine
|
|
isolate_namespace Dunlop
|
|
|
|
initializer "dunlop.ability", group: 'dunlop' do |app|
|
|
if ability_class = "Ability".safe_constantize and ability_class.respond_to?(:add_dunlop_allowed_authorization_classes!)
|
|
ability_class.add_dunlop_allowed_authorization_classes!
|
|
end
|
|
end
|
|
|
|
# add migrations to containing application
|
|
initializer 'dunlop.append_migrations' do |app|
|
|
unless app.root.to_s.match root.to_s
|
|
config.paths["db/migrate"].expanded.each do |expanded_path|
|
|
app.config.paths["db/migrate"] << expanded_path
|
|
end
|
|
end
|
|
end
|
|
|
|
config.after_initialize do
|
|
|
|
# Auto generate target-file's ::Job classes having purpose triggering .generate on the class
|
|
::Dunlop.target_file_models.each do |target_file_base_model|
|
|
## Generte a job for all target files
|
|
base_job = "#{target_file_base_model.name.deconstantize}::ApplicationJob".constantize
|
|
target_file_base_model.classes.each do |cls|
|
|
next if cls.const_defined?(:Job)
|
|
cls::Job = Class.new base_job do
|
|
def perform
|
|
self.class.name.sub(/::Job$/, '').constantize.generate!
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
#FIXES
|
|
|
|
if defined?(MimeMagic)
|
|
#A CSV FILE STARTING WITH MZ IS RECOGNIZED AS X-MS-DOS-EXECUTABLE
|
|
# https://github.com/minad/mimemagic/issues/67
|
|
if mime_magic_ms_dos_index = MimeMagic::MAGIC.index{|r| r == ['application/x-ms-dos-executable', [[0, 'MZ']]]}
|
|
MimeMagic::MAGIC.delete_at(mime_magic_ms_dos_index)
|
|
end
|
|
|
|
if mime_magix_x_executable_index = MimeMagic::MAGIC.index{|r| r.first == 'application/x-executable'}
|
|
if mime_magix_x_executable_mz_index = MimeMagic::MAGIC[mime_magix_x_executable_index][1].index{|r| r == [0, "MZ"]}
|
|
MimeMagic::MAGIC[mime_magix_x_executable_index][1].delete_at(mime_magix_x_executable_mz_index)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|