Class: Radiant::ExtensionLoader
Defined Under Namespace
Classes: DependenciesObserver
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Simpleton
included
Constructor Details
Returns a new instance of ExtensionLoader.
28
29
30
|
# File 'lib/radiant/extension_loader.rb', line 28
def initialize
self.extensions = []
end
|
Instance Attribute Details
#extensions ⇒ Object
Returns the value of attribute extensions.
26
27
28
|
# File 'lib/radiant/extension_loader.rb', line 26
def extensions
@extensions
end
|
#initializer ⇒ Object
Returns the value of attribute initializer.
26
27
28
|
# File 'lib/radiant/extension_loader.rb', line 26
def initializer
@initializer
end
|
Instance Method Details
#activate_extensions ⇒ Object
Also known as:
reactivate
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/radiant/extension_loader.rb', line 92
def activate_extensions
initializer.initialize_default_admin_tabs
initializer.initialize_framework_views
initializer.admin.load_default_regions
extensions.each &:activate
Page.load_subclasses
end
|
#add_controller_paths ⇒ Object
59
60
61
|
# File 'lib/radiant/extension_loader.rb', line 59
def add_controller_paths
configuration.controller_paths.concat(controller_paths)
end
|
#add_extension_paths ⇒ Object
44
45
46
47
48
49
|
# File 'lib/radiant/extension_loader.rb', line 44
def add_extension_paths
extension_load_paths.reverse_each do |path|
configuration.load_paths.unshift path
$LOAD_PATH.unshift path
end
end
|
#add_plugin_paths ⇒ Object
51
52
53
|
# File 'lib/radiant/extension_loader.rb', line 51
def add_plugin_paths
configuration.plugin_paths.concat plugin_paths
end
|
#configuration ⇒ Object
32
33
34
|
# File 'lib/radiant/extension_loader.rb', line 32
def configuration
initializer.configuration
end
|
#controller_paths ⇒ Object
55
56
57
|
# File 'lib/radiant/extension_loader.rb', line 55
def controller_paths
extensions.map { |extension| "#{extension.root}/app/controllers" }.select { |d| File.directory?(d) }
end
|
#deactivate_extensions ⇒ Object
88
89
90
|
# File 'lib/radiant/extension_loader.rb', line 88
def deactivate_extensions
extensions.each &:deactivate
end
|
#extension_load_paths ⇒ Object
36
37
38
|
# File 'lib/radiant/extension_loader.rb', line 36
def extension_load_paths
load_extension_roots.map { |extension| load_paths_for(extension) }.flatten.select { |d| File.directory?(d) }
end
|
#load_extensions ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/radiant/extension_loader.rb', line 72
def load_extensions
@observer ||= DependenciesObserver.new(configuration).observe(::ActiveSupport::Dependencies)
self.extensions = load_extension_roots.map do |root|
begin
extension_file = "#{File.basename(root).sub(/^\d+_/,'')}_extension"
extension = extension_file.camelize.constantize
extension.unloadable
extension.root = root
extension
rescue LoadError, NameError => e
$stderr.puts "Could not load extension from file: #{extension_file}.\n#{e.inspect}"
nil
end
end.compact
end
|
67
68
69
|
# File 'lib/radiant/extension_loader.rb', line 67
def metal_paths
load_extension_roots.map { |extension| "#{extension}/app/metal" }.select { |d| File.directory?(d) }.reverse
end
|
#plugin_paths ⇒ Object
40
41
42
|
# File 'lib/radiant/extension_loader.rb', line 40
def plugin_paths
load_extension_roots.map {|extension| "#{extension}/vendor/plugins" }.select {|d| File.directory?(d) }
end
|
#view_paths ⇒ Object
63
64
65
|
# File 'lib/radiant/extension_loader.rb', line 63
def view_paths
extensions.map { |extension| "#{extension.root}/app/views" }.select { |d| File.directory?(d) }.reverse
end
|