lib/radiant/extension_loader.rb in radiant-0.9.1 vs lib/radiant/extension_loader.rb in radiant-1.0.0.rc1

- old
+ new

@@ -41,11 +41,11 @@ load_extension_roots.map {|extension| "#{extension}/vendor/plugins" }.select {|d| File.directory?(d) } end def add_extension_paths extension_load_paths.reverse_each do |path| - configuration.load_paths.unshift path + configuration.autoload_paths.unshift path $LOAD_PATH.unshift path end end def add_plugin_paths @@ -79,21 +79,25 @@ # 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).gsub(/^radiant-|-extension-[\d.]+$/,'')}_extension" + extension_file = "#{File.basename(root).gsub(/^radiant-|-extension-([\d\.a-z]+|[a-z\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 + + def load_extension_initalizers + extensions.each &:load_initializers + end def deactivate_extensions extensions.each &:deactivate end @@ -127,38 +131,41 @@ select_extension_roots else [] end end - + def select_extension_roots all_roots = all_extension_roots.dup roots = configuration.extensions.uniq.map do |ext_name| if :all === ext_name :all else ext_path = all_roots.detect do |maybe_path| - File.basename(maybe_path).gsub(/^radiant-|-extension-[\d.]+$/, '') == ext_name.to_s + File.basename(maybe_path).gsub(/^radiant-|-extension-([\d\.a-z]+|[a-z\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 + configuration.ignored_extensions.each do |removed| + roots.delete_if{|root| root.split('/').last.to_s == removed.to_s } + end roots end def all_extension_roots @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\.]+$/] } + gem.specification.full_gem_path[/radiant-.*-extension-([\d\.a-z]+|[a-z\d]+)$/] } end roots.flatten end end