Sha256: b39a3b276b1b96b93849a16f5def82851df0c0d3974bc4628c71bfaea68a5aad

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require 'i18n'

Dir[File.dirname(__FILE__) + '/**/*.rb'].each {|file| require file }

module DiscourseDev
  require 'discourse_dev/railtie'
  require 'discourse_dev/engine'

  def self.auth_plugin_enabled?
    config.auth_plugin_enabled
  end

  def self.config
    @config ||= Config.new
  end

  def self.auth_plugin
    return unless auth_plugin_enabled?

    @auth_plugin ||= begin
      path = File.join(root, 'auth', 'plugin.rb')
      source = File.read(path)
      metadata = Plugin::Metadata.parse(source)
      Plugin::Instance.new(metadata, path)
    end
  end

  def self.settings_file
    File.join(root, "config", "settings.yml")
  end

  def self.client_locale_files(locale_str)
    Dir[File.join(root, "config", "locales", "client*.#{locale_str}.yml")]
  end

  def self.root
    File.expand_path("..", __dir__)
  end
end

require "active_record/database_configurations"

ActiveRecord::Tasks::DatabaseTasks.module_eval do
  alias_method :rails_each_current_configuration, :each_current_configuration

  private
  def each_current_configuration(environment, name = nil)
    rails_each_current_configuration(environment, name) { |db_config|
      next if environment == "development" && ENV["SKIP_TEST_DATABASE"] == "1" && db_config["database"] != "discourse_development"
      yield db_config
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
discourse_dev-0.1.0 lib/discourse_dev.rb