diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2011-05-26 14:54:11 -0700 |
|---|---|---|
| committer | Matt Robinson <matt@puppetlabs.com> | 2011-05-26 16:08:32 -0700 |
| commit | 2aa9f2fe390c15806cce5532afed2fc7ecf51b8b (patch) | |
| tree | d6cd2cac914673d528c9dc37ef89a313437d7494 /lib/puppet/util | |
| parent | 9447cb957b8c01ba7d368baebc1061c3dbfc9399 (diff) | |
| download | puppet-2aa9f2fe390c15806cce5532afed2fc7ecf51b8b.tar.gz puppet-2aa9f2fe390c15806cce5532afed2fc7ecf51b8b.tar.xz puppet-2aa9f2fe390c15806cce5532afed2fc7ecf51b8b.zip | |
(#7690) Don't blow up when listing terminuses available for faces
Previously, in order to list the available terminuses for an indirected
face we loaded all the the terminuses in order to list them. This meant
that if a terminus like active_record didn't have the dependencies it
needed, the documentation would raise errors and not list terminuses.
<Puppet::Error: Could not autoload filename uninitialized constant Object::ActiveRecord>
Now we just list the terminuses available in the load path without
trying to load them. The terminus will still raise an error if you try
to use it without its dependencies being met.
Paired-with: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'lib/puppet/util')
| -rw-r--r-- | lib/puppet/util/autoload.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index 0e7025aef..6537a4a4e 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -105,23 +105,25 @@ 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).uniq.collect { |d| File.join(d, @path) }.find_all { |d| FileTest.directory?(d) } |
