diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/application/faces.rb | 6 | ||||
-rw-r--r-- | lib/puppet/indirector/terminus.rb | 9 | ||||
-rw-r--r-- | lib/puppet/util/autoload.rb | 30 |
3 files changed, 20 insertions, 25 deletions
diff --git a/lib/puppet/application/faces.rb b/lib/puppet/application/faces.rb index e7fce66b1..3145da821 100644 --- a/lib/puppet/application/faces.rb +++ b/lib/puppet/application/faces.rb @@ -66,7 +66,7 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License str = "#{name}:\n" if arguments.include?("terminuses") begin - terms = terminus_classes(name.to_sym) + terms = Puppet::Indirector::Face.terminus_classes(name.to_sym) str << "\tTerminuses: #{terms.join(", ")}\n" rescue => detail puts detail.backtrace if Puppet[:trace] @@ -107,10 +107,6 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License Puppet::Face.faces end - def terminus_classes(indirection) - Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort - end - def actions(indirection) return [] unless face = Puppet::Face[indirection, '0.0.1'] face.load_actions diff --git a/lib/puppet/indirector/terminus.rb b/lib/puppet/indirector/terminus.rb index 4ebd0d004..d488869d1 100644 --- a/lib/puppet/indirector/terminus.rb +++ b/lib/puppet/indirector/terminus.rb @@ -111,12 +111,9 @@ class Puppet::Indirector::Terminus # Return all terminus classes for a given indirection. def terminus_classes(indirection_name) setup_instance_loading indirection_name - - # Load them all. - instance_loader(indirection_name).loadall - - # And return the list of names. - loaded_instances(indirection_name) + instance_loader(indirection_name).files_to_load.map do |file| + File.basename(file).chomp(".rb").intern + end end private 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) |