Sha256: 957238fc530e295df853302dc7c574864e87f28e17f2ff97d0b128763b4af539

Contents?: true

Size: 1.72 KB

Versions: 5

Compression:

Stored size: 1.72 KB

Contents

begin
  # Try to include the rails initializer. If this isn't in a gem, this will fail.
  require 'initializer' unless REFINERY_ROOT == RAILS_ROOT # A Refinery gem install's RAILS_ROOT is not the REFINERY_ROOT.
rescue LoadError => load_error
end

module Refinery
  if defined? Rails::Configuration
    class Configuration < Rails::Configuration
      def default_plugin_paths
        paths = super.push("#{REFINERY_ROOT}/vendor/plugins").uniq
      end
    end
  end
  if defined? Rails::Plugin::Loader
    class PluginLoader < Rails::Plugin::Loader
      def add_plugin_load_paths
        super
        # add plugin lib paths to the $LOAD_PATH so that rake tasks etc. can be run when using a gem for refinery or gems for plugins.
        search_for = Regexp.new(File.join('(', REFINERY_ROOT, %w(vendor plugins \)? .+? lib)))
        paths = plugins.collect{ |plugin| plugin.load_paths }.flatten.reject{|path| path.scan(search_for).empty? or path.include?('/rails-') }
        paths = paths.reject{ |path| path.include?(REFINERY_ROOT) } if REFINERY_ROOT == RAILS_ROOT # superfluous when not in gem.
        ($refinery_gem_plugin_lib_paths = paths).each do |path|
          $LOAD_PATH.unshift path
        end
        $LOAD_PATH.uniq!
      end
    end
  end
  if defined? Rails::Initializer
    class Initializer < Rails::Initializer
      def self.run(command = :process, configuration = Configuration.new)
        Rails.configuration = configuration
        configuration.reload_plugins = true if RAILS_ENV =~ /development/ and REFINERY_ROOT == RAILS_ROOT # seems to work, don't in gem.
        configuration.plugin_loader = Refinery::PluginLoader
        super
      end

      def load_plugins
        Refinery.add_gems
        super
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refinerycms-0.9.5.29 vendor/plugins/refinery/lib/refinery/initializer.rb
refinerycms-0.9.5.28 vendor/plugins/refinery/lib/refinery/initializer.rb
refinerycms-0.9.5.27 vendor/plugins/refinery/lib/refinery/initializer.rb
refinerycms-0.9.5.26 vendor/plugins/refinery/lib/refinery/initializer.rb
refinerycms-0.9.5.25 vendor/plugins/refinery/lib/refinery/initializer.rb