diff options
| author | Luke Kanies <luke@puppetlabs.com> | 2011-02-20 15:39:54 -0800 |
|---|---|---|
| committer | Luke Kanies <luke@puppetlabs.com> | 2011-02-20 15:39:54 -0800 |
| commit | cde1baa4a9a27ba95ad2a61bc8e46d43e708b081 (patch) | |
| tree | 737760e127c5c0ccc60181aeaa519acfd89c774d /lib/puppet | |
| parent | eff4eec9d53d4fb8270799458455fe4bdc47d1df (diff) | |
| download | puppet-cde1baa4a9a27ba95ad2a61bc8e46d43e708b081.tar.gz puppet-cde1baa4a9a27ba95ad2a61bc8e46d43e708b081.tar.xz puppet-cde1baa4a9a27ba95ad2a61bc8e46d43e708b081.zip | |
Fixing Interface listing
It got broke when the Indirector base class was extracted.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/application/interface.rb | 42 | ||||
| -rw-r--r-- | lib/puppet/interface.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/interface/indirector.rb | 2 |
3 files changed, 41 insertions, 10 deletions
diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb index db926df86..8f26658c9 100644 --- a/lib/puppet/application/interface.rb +++ b/lib/puppet/application/interface.rb @@ -17,23 +17,23 @@ class Puppet::Application::Interface < Puppet::Application if arguments.empty? arguments = %w{terminuses actions} end - indirections.each do |ind| - str = "#{ind}:\n" + interfaces.each do |name| + str = "#{name}:\n" if arguments.include?("terminuses") begin - terms = terminus_classes(ind.to_sym) + terms = terminus_classes(name.to_sym) str << "\tTerminuses: #{terms.join(", ")}\n" rescue => detail - $stderr.puts "Could not load terminuses for #{ind}: #{detail}" + $stderr.puts "Could not load terminuses for #{name}: #{detail}" end end if arguments.include?("actions") begin - actions = actions(ind.to_sym) + actions = actions(name.to_sym) str << "\tActions: #{actions.join(", ")}\n" rescue => detail - $stderr.puts "Could not load actions for #{ind}: #{detail}" + $stderr.puts "Could not load actions for #{name}: #{detail}" end end @@ -70,12 +70,36 @@ class Puppet::Application::Interface < Puppet::Application end end - def indirections - Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort + def interfaces + # Load all of the interfaces + unless @interfaces + $LOAD_PATH.each do |dir| + next unless FileTest.directory?(dir) + Dir.chdir(dir) do + Dir.glob("puppet/interface/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file| + begin + require file + rescue Error => detail + puts detail.backtrace if Puppet[:trace] + raise "Could not load #{file}: #{detail}" + end + end + end + end + + @interfaces = [] + Puppet::Interface.constants.each do |name| + klass = Puppet::Interface.const_get(name) + next if klass.abstract? # skip base classes + + @interfaces << name.downcase + end + end + @interfaces end def terminus_classes(indirection) - Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort + Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort end def actions(indirection) diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb index 999c38bad..2e52de43d 100644 --- a/lib/puppet/interface.rb +++ b/lib/puppet/interface.rb @@ -3,7 +3,12 @@ require 'puppet' class Puppet::Interface class << self - attr_accessor :default_format + attr_accessor :default_format, :abstract + + # Is this an actual interface, or a base class for others? + def abstract? + abstract + end def set_default_format(format) self.default_format = format.to_sym diff --git a/lib/puppet/interface/indirector.rb b/lib/puppet/interface/indirector.rb index f0beb8a9c..507826b91 100644 --- a/lib/puppet/interface/indirector.rb +++ b/lib/puppet/interface/indirector.rb @@ -3,6 +3,8 @@ require 'puppet/interface' class Puppet::Interface::Indirector < Puppet::Interface + # This is just a base class. + @abstract = true # Here's your opportunity to override the indirection name. By default # it will be the same name as the interface. |
