lib/radiant/extension_loader.rb in radiant-0.8.2 vs lib/radiant/extension_loader.rb in radiant-0.9.0.rc2
- old
+ new
@@ -49,10 +49,18 @@
end
def add_plugin_paths
configuration.plugin_paths.concat plugin_paths
end
+
+ def locale_paths
+ load_extension_roots.map { |extension| "#{extension}/config/locales" }.select { |d| File.directory?(d) }.reverse
+ end
+
+ def add_locale_paths
+ configuration.i18n.load_path.concat(locale_paths.map{ |path| Dir[File.join("#{path}","*.{rb,yml}")] })
+ end
def controller_paths
extensions.map { |extension| "#{extension.root}/app/controllers" }.select { |d| File.directory?(d) }
end
@@ -71,11 +79,11 @@
# Load the extensions
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_file = "#{File.basename(root).gsub(/^radiant-|-extension-[\d.]+$/,'')}_extension"
extension = extension_file.camelize.constantize
extension.unloadable
extension.root = root
extension
rescue LoadError, NameError => e
@@ -122,32 +130,38 @@
end
end
def select_extension_roots
all_roots = all_extension_roots.dup
-
roots = configuration.extensions.map do |ext_name|
if :all === ext_name
:all
else
ext_path = all_roots.detect do |maybe_path|
- File.basename(maybe_path).sub(/^\d+_/, '') == ext_name.to_s
+ File.basename(maybe_path).gsub(/^radiant-|-extension-[\d.]+$/, '') == ext_name.to_s
end
raise LoadError, "Cannot find the extension '#{ext_name}'!" if ext_path.nil?
all_roots.delete(ext_path)
end
end
-
if placeholder = roots.index(:all)
# replace the :all symbol with any remaining paths
roots[placeholder, 1] = all_roots
end
roots
end
def all_extension_roots
- @all_extension_roots ||= configuration.extension_paths.map do |path|
- Dir["#{path}/*"].map {|f| File.expand_path(f) if File.directory?(f) }.compact.sort
- end.flatten
+ @all_extension_roots ||= begin
+ roots = configuration.extension_paths.map do |path|
+ Dir["#{path}/*"].map {|f| File.expand_path(f) if File.directory?(f) }.compact.sort
+ end
+ configuration.gems.inject(roots) do |paths,gem|
+ paths.tap { |p| p << gem.specification.full_gem_path if gem.specification and
+ gem.specification.full_gem_path[/radiant-.*-extension-[\d\.]+$/] }
+ end
+ roots.flatten
+ end
end
+
end
end