Class: Radiant::Configuration
- Defined in:
- lib/radiant/initializer.rb
Instance Attribute Summary collapse
-
#extension_dependencies ⇒ Object
Returns the value of attribute extension_dependencies.
-
#extension_paths ⇒ Object
Returns the value of attribute extension_paths.
- #extensions ⇒ Object
-
#view_paths ⇒ Object
Returns the value of attribute view_paths.
Instance Method Summary collapse
- #admin ⇒ Object
- #all_available_extensions ⇒ Object
- #check_extension_dependencies ⇒ Object
- #default_extension_paths ⇒ Object
-
#extension(ext) ⇒ Object
Declare another extension as a dependency.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
17 18 19 20 21 22 |
# File 'lib/radiant/initializer.rb', line 17 def initialize self.view_paths = [] self.extension_paths = default_extension_paths self.extension_dependencies = [] super end |
Instance Attribute Details
#extension_dependencies ⇒ Object
Returns the value of attribute extension_dependencies.
15 16 17 |
# File 'lib/radiant/initializer.rb', line 15 def extension_dependencies @extension_dependencies end |
#extension_paths ⇒ Object
Returns the value of attribute extension_paths.
12 13 14 |
# File 'lib/radiant/initializer.rb', line 12 def extension_paths @extension_paths end |
#extensions ⇒ Object
33 34 35 |
# File 'lib/radiant/initializer.rb', line 33 def extensions @extensions ||= all_available_extensions end |
#view_paths ⇒ Object
Returns the value of attribute view_paths.
14 15 16 |
# File 'lib/radiant/initializer.rb', line 14 def view_paths @view_paths end |
Instance Method Details
#admin ⇒ Object
43 44 45 |
# File 'lib/radiant/initializer.rb', line 43 def admin AdminUI.instance end |
#all_available_extensions ⇒ Object
37 38 39 40 41 |
# File 'lib/radiant/initializer.rb', line 37 def all_available_extensions extension_paths.map do |path| Dir["#{path}/*"].select {|f| File.directory?(f) } end.flatten.map {|f| File.basename(f).sub(/^\d+_/, '') }.sort.map {|e| e.to_sym } end |
#check_extension_dependencies ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/radiant/initializer.rb', line 58 def check_extension_dependencies unloaded_extensions = [] @extension_dependencies.each do |ext| extension = ext.camelcase + 'Extension' begin extension_class = extension.constantize unloaded_extensions << extension unless defined?(extension_class) && (extension_class.active?) rescue NameError unloaded_extensions << extension end end if unloaded_extensions.any? abort <<-end_error Missing these required extensions: #{unloaded_extensions} end_error else return true end end |
#default_extension_paths ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/radiant/initializer.rb', line 24 def default_extension_paths env = ENV["RAILS_ENV"] || RAILS_ENV paths = [RAILS_ROOT + '/vendor/extensions', RADIANT_ROOT + '/vendor/extensions'].uniq # There's no other way it will work, config/environments/test.rb loads too late # TODO: Should figure out how to include this extension path only for the tests that need it paths.unshift(RADIANT_ROOT + "/test/fixtures/extensions") if env == "test" paths end |
#extension(ext) ⇒ Object
Declare another extension as a dependency. Does not allow for the specification of versions. class MyExtension < Radiant::Extension
extension_config do |config|
config.extension 'multisite'
end
end
54 55 56 |
# File 'lib/radiant/initializer.rb', line 54 def extension(ext) @extension_dependencies << ext unless @extension_dependencies.include?(ext) end |