class Rails::Application::Configuration
def admin
More commonly accessed in the initializer via its call to +configuration.admin+.
Returns the AdminUI singleton, giving get-and-set access to the tabs and partial-sets it defines.
def admin TrustyCms::AdminUI.instance end
def available_extensions
used when activating those extensions that have been enabled.
available. One of its side effects is to populate the ExtensionLoader's list of extension root locations, later
This method is always called during initialization, either as a default or to check that specified extensions are
TrustyCms.configuration.available_extensions # => [:name, :name, :name, :name]
gem whose path ends in the form +trusty-something-extension+ is considered to be an extension.
Returns an alphabetical list of every extension found among all the load paths and bundled gems. Any plugin or
def available_extensions @available_extensions ||= (vendored_extensions + gem_extensions).uniq.sort.map(&:to_sym) end
def default_controller_paths
Overrides the Rails::Initializer default to look for controllers in TRUSTY_CMS_ROOT rather than Rails.root.
def default_controller_paths [File.join(TRUSTY_CMS_ROOT, 'app', 'controllers')] end
def default_extension_paths
In test mode we also add a fixtures path for testing the extension loader.
There are no vendor/* directories in +TRUSTY_CMS_ROOT+ any more but the possibility remains for compatibility reasons.
TrustyCms.root/vendor/extensions
Rails.root/vendor/extensions
Sets the locations in which we look for vendored extensions. Normally:
def default_extension_paths env = ENV["RAILS_ENV"] || Rails.env paths = [Rails.root + 'vendor/extensions'] paths.unshift(TRUSTY_CMS_ROOT + "/vendor/extensions") unless Rails.root == TRUSTY_CMS_ROOT paths.unshift(TRUSTY_CMS_ROOT + "test/fixtures/extensions") if env =~ /test/ paths end
def default_plugin_paths
Overrides the Rails::Initializer default to add plugin paths in TRUSTY_CMS_ROOT as well as Rails.root.
def default_plugin_paths super + ["#{TRUSTY_CMS_ROOT}/lib/plugins", "#{TRUSTY_CMS_ROOT}/vendor/plugins"] end
def default_view_path
Overrides the Rails::Initializer default to look for views in TRUSTY_CMS_ROOT rather than Rails.root.
def default_view_path File.join(TRUSTY_CMS_ROOT, 'app', 'views') end
def enabled_extensions
that the application is configured to load that extension.
Note that an extension enabled is not the same as an extension activated or even loaded: it just means
TrustyCms.configuration.enabled_extensions # => [:name, :name, :name, :name]
and for most purposes this is the list you want to refer to.
configuration directives. These are the extensions that will actually be loaded or migrated,
The list of extensions, expanded and in load order, that results from combining all the extension
def enabled_extensions @enabled_extensions ||= expanded_extension_list - ignored_extensions end
def expand_and_check(extension_list) #:nodoc
def expand_and_check(extension_list) #:nodoc missing_extensions = extension_list - [:all] - available_extensions raise LoadError, "These configured extensions have not been found: #{missing_extensions.to_sentence}" if missing_extensions.any? if m = extension_list.index(:all) extension_list[m] = available_extensions - extension_list end extension_list.flatten end
def expanded_extension_list
If an extension in the configurted list is not found, a LoadError will be thrown from here.
TrustyCms.configuration.expanded_extension_list # => [:name, :name, :name, :name]
of every extension found among gems and vendor/extensions directories.
(it is here that the :all entry is expanded to mean 'everything else'), or will default to an alphabetical list
The expanded and ordered list of extensions, including any that may later be ignored. This can be configured
def expanded_extension_list # NB. it should remain possible to say config.extensions = [] @extension_list ||= extensions ? expand_and_check(extensions) : available_extensions end
def extension(ext)
Old extension-dependency mechanism now deprecated
def extension(ext) ::ActiveSupport::Deprecation.warn("Extension dependencies have been deprecated and are no longer supported in trusty 1.0. Extensions with dependencies should be packaged as gems and use the .gemspec to declare them.", caller) end
def extensions
TrustyCms.configuration.extensions # => [:name, :all, :name]
returned by +available_extensions+.
Without such a call, we default to the alphabetical list of all well-formed vendor and gem extensions
def extensions @requested_extensions ||= available_extensions end
def extensions=(extensions)
A LoadError is raised if any of the specified extensions can't be found.
config.extensions = [:dashboard, :blog, :all, :comments]
config.extensions = [:dashboard, :blog, :all]
config.extensions = [:layouts, :taggable, :all]
It can include an :all marker to mean 'everything else' and is typically set in environment.rb:
Sets the list of extensions that will be loaded and the order in which to load them.
def extensions=(extensions) @requested_extensions = extensions end
def gem(name, options = {})
Old gem-invogation method now deprecated
def gem(name, options = {}) ::ActiveSupport::Deprecation.warn("Please declare gem dependencies in your Gemfile (or for an extension, in the .gemspec file).", caller) super end
def gem_extensions
TrustyCms.configuration.gem_extensions # => [:name, :name]
and returns a list of their names as symbols.
Scans the bundled gems for any whose name match the +trusty-something-extension+ format
def gem_extensions Gem.loaded_specs.each_with_object([]) do |(gemname, gemspec), found| if gemname =~ /trusty-.*-extension$/ ep = TrustyCms::ExtensionLoader.record_path(gemspec.full_gem_path, gemname) found << ep.name end end end
def ignore_extensions(array)
required extensions then ignores them will not boot and is likely to fail with errors about unitialized constants.
These exclusions are applied regardless of dependencies and extension locations. A configuration that bundles
TrustyCms.configuration.ignored_extensions # => [:experimental, :broken]
You can also retrieve the list with +ignored_extensions+:
config.ignore_extensions = [:experimental, :broken]
This is a configurable list of extension that should not be loaded.
def ignore_extensions(array) self.ignored_extensions |= array end
def initialize_extension_paths
def initialize_extension_paths self.extension_paths = default_extension_paths self.ignored_extensions = [] end
def vendored_extensions
TrustyCms.configuration.vendored_extensions # => [:name, :name]
Searches the defined extension_paths for subdirectories and returns a list of names as symbols.
def vendored_extensions extension_paths.each_with_object([]) do |load_path, found| Dir["#{load_path}/*"].each do |path| if File.directory?(path) ep = TrustyCms::ExtensionLoader.record_path(path) found << ep.name end end end end