diff options
| author | Pieter van de Bruggen <pieter@puppetlabs.com> | 2011-03-21 15:02:20 -0700 |
|---|---|---|
| committer | Pieter van de Bruggen <pieter@puppetlabs.com> | 2011-03-21 15:02:20 -0700 |
| commit | 55877dd42da11ffa3cf00fb49db8cfd558ec0641 (patch) | |
| tree | 84fc248b09c9989bc24c9c8eacf8b2906371804d | |
| parent | 3a22334cc0041b39ce4289e957a0d49e53418560 (diff) | |
| parent | a7173dc2054c4167c71a23fb70e3ca54d07c7447 (diff) | |
| download | puppet-55877dd42da11ffa3cf00fb49db8cfd558ec0641.tar.gz puppet-55877dd42da11ffa3cf00fb49db8cfd558ec0641.tar.xz puppet-55877dd42da11ffa3cf00fb49db8cfd558ec0641.zip | |
Merge branch 'tickets/master/6786'
| -rw-r--r-- | lib/puppet/application/interface_base.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/interface.rb | 13 | ||||
| -rw-r--r-- | spec/unit/interface/catalog_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_request_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_revocation_list_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/config_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/facts_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/file_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/key_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/node_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/report_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/resource_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/resource_type_spec.rb | 4 |
14 files changed, 34 insertions, 29 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 diff --git a/spec/unit/interface/catalog_spec.rb b/spec/unit/interface/catalog_spec.rb index 8eb0040ff..574842754 100644 --- a/spec/unit/interface/catalog_spec.rb +++ b/spec/unit/interface/catalog_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/catalog' -describe Puppet::Interface.interface(:catalog) do +describe Puppet::Interface::Catalog do before do - @interface = Puppet::Interface.interface(:catalog) + @interface = Puppet::Interface::Catalog end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/certificate_request_spec.rb b/spec/unit/interface/certificate_request_spec.rb index 8a613e5e5..fa9e819b4 100644 --- a/spec/unit/interface/certificate_request_spec.rb +++ b/spec/unit/interface/certificate_request_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/certificate_request' -describe Puppet::Interface.interface(:certificate_request) do +describe Puppet::Interface::CertificateRequest do before do - @interface = Puppet::Interface.interface(:certificate_request) + @interface = Puppet::Interface::CertificateRequest end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/certificate_revocation_list_spec.rb b/spec/unit/interface/certificate_revocation_list_spec.rb index 8ee341bef..3fc981bd4 100644 --- a/spec/unit/interface/certificate_revocation_list_spec.rb +++ b/spec/unit/interface/certificate_revocation_list_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/certificate_revocation_list' -describe Puppet::Interface.interface(:certificate_revocation_list) do +describe Puppet::Interface::CertificateRevocationList do before do - @interface = Puppet::Interface.interface(:certificate_revocation_list) + @interface = Puppet::Interface::CertificateRevocationList end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/certificate_spec.rb b/spec/unit/interface/certificate_spec.rb index 47ddcb52e..6b5f9224b 100644 --- a/spec/unit/interface/certificate_spec.rb +++ b/spec/unit/interface/certificate_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/certificate' -describe Puppet::Interface.interface(:certificate) do +describe Puppet::Interface::Certificate do before do - @interface = Puppet::Interface.interface(:certificate) + @interface = Puppet::Interface::Certificate end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/config_spec.rb b/spec/unit/interface/config_spec.rb index 79c65f2ac..683e8abae 100644 --- a/spec/unit/interface/config_spec.rb +++ b/spec/unit/interface/config_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/config' -describe Puppet::Interface.interface(:config) do +describe Puppet::Interface::Config do before do - @interface = Puppet::Interface.interface(:config) + @interface = Puppet::Interface::Config end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/facts_spec.rb b/spec/unit/interface/facts_spec.rb index 03d6410f9..c311b5d3d 100644 --- a/spec/unit/interface/facts_spec.rb +++ b/spec/unit/interface/facts_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/facts' -describe Puppet::Interface.interface(:facts) do +describe Puppet::Interface::Facts do before do - @interface = Puppet::Interface.interface(:facts) + @interface = Puppet::Interface::Facts end it "should define an 'upload' fact" do diff --git a/spec/unit/interface/file_spec.rb b/spec/unit/interface/file_spec.rb index fc7accf0d..1d9e55752 100644 --- a/spec/unit/interface/file_spec.rb +++ b/spec/unit/interface/file_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/file' -describe Puppet::Interface.interface(:file) do +describe Puppet::Interface::File do before do - @interface = Puppet::Interface.interface(:file) + @interface = Puppet::Interface::File end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/key_spec.rb b/spec/unit/interface/key_spec.rb index 93a7c937c..9be024445 100644 --- a/spec/unit/interface/key_spec.rb +++ b/spec/unit/interface/key_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/key' -describe Puppet::Interface.interface(:key) do +describe Puppet::Interface::Key do before do - @interface = Puppet::Interface.interface(:key) + @interface = Puppet::Interface::Key end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/node_spec.rb b/spec/unit/interface/node_spec.rb index 63109308d..cfb15e38a 100644 --- a/spec/unit/interface/node_spec.rb +++ b/spec/unit/interface/node_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/node' -describe Puppet::Interface.interface(:node) do +describe Puppet::Interface::Node do before do - @interface = Puppet::Interface.interface(:node) + @interface = Puppet::Interface::Node end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/report_spec.rb b/spec/unit/interface/report_spec.rb index b5bee1a62..932fc5cc9 100644 --- a/spec/unit/interface/report_spec.rb +++ b/spec/unit/interface/report_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/report' -describe Puppet::Interface.interface(:report) do +describe Puppet::Interface::Report do before do - @interface = Puppet::Interface.interface(:report) + @interface = Puppet::Interface::Report end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/resource_spec.rb b/spec/unit/interface/resource_spec.rb index cad45b66b..b28b04310 100644 --- a/spec/unit/interface/resource_spec.rb +++ b/spec/unit/interface/resource_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/resource' -describe Puppet::Interface.interface(:resource) do +describe Puppet::Interface::Resource do before do - @interface = Puppet::Interface.interface(:resource) + @interface = Puppet::Interface::Resource end it "should be a subclass of 'Indirection'" do diff --git a/spec/unit/interface/resource_type_spec.rb b/spec/unit/interface/resource_type_spec.rb index 6c437c475..95b9ec7f1 100644 --- a/spec/unit/interface/resource_type_spec.rb +++ b/spec/unit/interface/resource_type_spec.rb @@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/interface/resource_type' -describe Puppet::Interface.interface(:resource_type) do +describe Puppet::Interface::ResourceType do before do - @interface = Puppet::Interface.interface(:resource_type) + @interface = Puppet::Interface::ResourceType end it "should be a subclass of 'Indirection'" do |
