diff options
author | Matt Robinson <matt@puppetlabs.com> | 2011-05-26 15:49:06 -0700 |
---|---|---|
committer | Matt Robinson <matt@puppetlabs.com> | 2011-05-26 15:49:06 -0700 |
commit | d0592fabd27472ba0f5586393eff20e536f8766a (patch) | |
tree | 1ee331fa0f325d8a545e01d06ed068287d1a9eb1 /lib/puppet/util/autoload.rb | |
parent | 59e6be30f24dfb1011fbb242029b5ff61e19514c (diff) | |
parent | bc71266f4f76439bc7fc5ba5b78895e801cf8736 (diff) | |
download | puppet-d0592fabd27472ba0f5586393eff20e536f8766a.tar.gz puppet-d0592fabd27472ba0f5586393eff20e536f8766a.tar.xz puppet-d0592fabd27472ba0f5586393eff20e536f8766a.zip |
Merge branch 'ticket/2.7.x/maint-faces_docs_spec_fixes' into 2.7.x
* ticket/2.7.x/maint-faces_docs_spec_fixes:
maint: Fix order dependent spec failure for face indirection
(#7690) Don't blow up when listing terminuses available for faces
maint: Dedup the loadpath so we don't have to walk it multiple times
Diffstat (limited to 'lib/puppet/util/autoload.rb')
-rw-r--r-- | lib/puppet/util/autoload.rb | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index f0dd0a5c5..6537a4a4e 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -105,26 +105,28 @@ class Puppet::Util::Autoload # so that already-loaded files don't get reloaded unnecessarily. def loadall # Load every instance of everything we can find. - searchpath.each do |dir| - Dir.glob("#{dir}/*.rb").each do |file| - name = File.basename(file).sub(".rb", '').intern - next if loaded?(name) - begin - Kernel.require file - loaded(name, file) - rescue SystemExit,NoMemoryError - raise - rescue Exception => detail - puts detail.backtrace if Puppet[:trace] - raise Puppet::Error, "Could not autoload #{file}: #{detail}" - end + files_to_load.each do |file| + name = File.basename(file).chomp(".rb").intern + next if loaded?(name) + begin + Kernel.require file + loaded(name, file) + rescue SystemExit,NoMemoryError + raise + rescue Exception => detail + puts detail.backtrace if Puppet[:trace] + raise Puppet::Error, "Could not autoload #{file}: #{detail}" end end end + def files_to_load + searchpath.map { |dir| Dir.glob("#{dir}/*.rb") }.flatten + end + # The list of directories to search through for loadable plugins. def searchpath(env=nil) - search_directories(env).collect { |d| File.join(d, @path) }.find_all { |d| FileTest.directory?(d) } + search_directories(env).uniq.collect { |d| File.join(d, @path) }.find_all { |d| FileTest.directory?(d) } end def module_directories(env=nil) |