summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/application/interface_base.rb2
-rw-r--r--lib/puppet/interface.rb13
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb
index 88f97b69b..1f18b086c 100644
--- a/lib/puppet/application/interface_base.rb
+++ b/lib/puppet/application/interface_base.rb
@@ -71,7 +71,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application
@type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym
- unless @interface = Puppet::Interface.interface(@type)
+ unless @interface = Puppet::Interface.const_get(@type)
raise "Could not find interface '#{@type}'"
end
@format ||= @interface.default_format
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index f9b26950a..dfd75ef58 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -42,20 +42,25 @@ class Puppet::Interface
nil
end
+ def self.const_get(name)
+ name = constantize(name)
+ super(name)
+ end
+
def self.register_interface(name, instance)
- const_set(name2const(name), instance)
+ const_set(constantize(name), instance)
end
def self.unload_interface(name)
- remove_const(name2const(name)) rescue nil
+ remove_const(constantize(name)) rescue nil
end
def self.unify_name(name)
name.to_s.downcase.to_sym
end
- def self.name2const(name)
- name.to_s.capitalize
+ def self.constantize(name)
+ name.to_s.split(/\W|_/).map { |x| x.capitalize }.join
end
attr_accessor :default_format