class TrustyCms::ExtensionLoader

def activate_extensions


The admin UI and views have to be reinitialized each time to pick up changes and avoid duplicates.
Activates all enabled extensions and makes sure that any newly declared subclasses of Page are recognised.
def activate_extensions
  initializer.initialize_views
  ordered_extensions = []
  configuration = TrustyCms::Application.config
  if configuration.extensions.first == :all
    ordered_extensions = extensions
  else
    configuration.extensions.each { |name| ordered_extensions << select_extension(name) }
  end
  ordered_extensions.flatten.each(&:activate)
  Page.load_subclasses
end

def deactivate_extensions


Deactivates all enabled extensions.
def deactivate_extensions
  extensions.each(&:deactivate)
end

def enabled_extension_paths


Returns a list of paths to all the extensions that are enabled in the configuration of this application.
def enabled_extension_paths
  ExtensionPath.enabled.map(&:to_s)
end

def initialize #:nodoc

:nodoc
def initialize #:nodoc
  self.extensions = []
end

def load_extension(name)


Loads the specified extension.
def load_extension(name)
  extension_path = ExtensionPath.find(name)
  begin
    constant = "#{name}_extension".camelize
    extension = constant.constantize
    extension.unloadable
    extension.path = extension_path
    extension
  rescue LoadError, NameError => e
    warn "Could not load extension: #{name}.\n#{e.inspect}"
    nil
  end
end

def load_extension_initalizers


Loads all the initializers defined in enabled extensions, in the configured order.
def load_extension_initalizers
  extensions.each(&:load_initializers)
end

def load_extensions


and startup will halt.
but application startup will continue. If an extension doesn't exist, a LoadError will be raised
(which defaults to alphabetically). If an extension fails to load an error will be logged
Loads but does not activate all the extensions that have been enabled, in the configured order
def load_extensions
  configuration = TrustyCms::Application.config
  @observer ||= DependenciesObserver.new(configuration).observe(::ActiveSupport::Dependencies)
  self.extensions = configuration.enabled_extensions.map { |ext| load_extension(ext) }.compact
end

def paths(type)


There are also (deprecated) +add_type_paths+ methods.
For compatibility with the old loader, there are corresponding +type_paths+ methods.

extension_loader.paths(:eager_load) #=> ['extension/app/controllers', 'extension/app/models', 'extension/app/helpers']
extension_loader.paths(:controller) #=> ['extension/app/controllers', 'extension/app/controllers']
extension_loader.paths(:metal) #=> ['extension/app/metal', 'extension/app/metal']

(by calling the corresponding class method on ExtensionPath).
Returns a list of all the paths discovered within extension roots of the specified type.
def paths(type)
  ExtensionPath.send("#{type}_paths".to_sym)
end

def record_path(path, name = nil)


remove trusty- and -extension and any verion numbering.
An extension name can be supplied in addition to the path. It will be processed in the usual way to
The ExtensionPath object will later be used to scan and load the extension.
Builds an ExtensionPath object from the supplied path, working out the name of the extension on the way.
def record_path(path, name = nil)
  ExtensionPath.from_path(path, name)
end

def select_extension(name)

def select_extension(name)
  extensions.select { |ext| ext.extension_name.symbolize == name }
end