Sha256: 12670de2cf9942c3c44fdfa177092ea87d2840f9c903c61874f74c04721a9745

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'tork/config'
require 'active_support/inflector'

Tork::Config.reabsorb_file_greps.push(
  %r<^config/.+\.(rb|yml)$>,
  %r<^db/schema\.rb$>,
  %r<^Gemfile\.lock$>
)

Tork::Config.test_file_globbers.update(
  %r<^(app|lib|test|spec)/.+\.rb$> => lambda do |path, matches|
    base = File.basename(path, '.rb')
    poly = ActiveSupport::Inflector.pluralize(base)
    "{test,spec}/**/{#{base},#{poly}_*}_{test,spec}.rb"
  end,

  %r<^(test|spec)/factories/.+_factory\.rb$> => lambda do |path, matches|
    base = File.basename(path, '_factory.rb')
    poly = ActiveSupport::Inflector.pluralize(base)
    "{test,spec}/**/{#{base},#{poly}_*}_{test,spec}.rb"
  end
)

Tork::Config.after_fork_hooks << proc do
  if defined? ActiveRecord::Base and
    ActiveRecord::Base.connection_pool.spec.config[:database] != ':memory:'
  then
    ActiveRecord::Base.connection.reconnect!
  end
end

begin
  require 'rails/railtie'
  class Tork::Railtie < Rails::Railtie
    config.before_initialize do |app|
      if app.config.cache_classes
        warn "tork/config/rails: Setting #{app.class}.config.cache_classes = false"
        app.config.cache_classes = false
      end
    end
  end
rescue LoadError
  warn "tork/config/rails: Railtie not available; please manually set:\n\t"\
       "config.cache_classes = false"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tork-17.1.0 lib/tork/config/rails.rb
tork-17.0.1 lib/tork/config/rails.rb
tork-17.0.0 lib/tork/config/rails.rb
tork-16.0.0 lib/tork/config/rails.rb