[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:34:06 UTC 2010


The following commit has been merged in the upstream branch:
commit b5f14c6eeaaf8cc70287f3b1b2f74441157ac4b6
Author: Matt Robinson <matt at puppetlabs.com>
Date:   Fri Jun 4 11:05:09 2010 -0700

    {#3866] Rename the method metaclass to singleton_class to avoid the deprecation warnings from Rails ActiveSupport
    
    The metaid.rb file came straight from why the lucky stiff's "seeing
    metaclasses clearly" article.  Rails used this too, but they recently
    deprecated the name metaclass in favor of singleton_class to match what
    ruby-core decided to do.  meta, eigen and singlton class were all
    suggested and in the end singleton was agreed upon.
    
    http://redmine.ruby-lang.org/issues/show/1082

diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb
index 513c1c7..f7910e3 100644
--- a/lib/puppet/metatype/manager.rb
+++ b/lib/puppet/metatype/manager.rb
@@ -42,7 +42,7 @@ module Manager
         newmethod = "new#{name.to_s}"
 
         # Used for method manipulation.
-        selfobj = metaclass()
+        selfobj = singleton_class()
 
         @types ||= {}
 
@@ -103,7 +103,7 @@ module Manager
         )
 
         if respond_to?("new" + name.to_s)
-            metaclass.send(:remove_method, "new" + name.to_s)
+            singleton_class.send(:remove_method, "new" + name.to_s)
         end
     end
 
diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb
index 9faa71c..f12d279 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -49,7 +49,7 @@ module Puppet::Network
 
         class ErrorHandler
             def initialize(&block)
-                metaclass.define_method(:execute, &block)
+                singleton_class.define_method(:execute, &block)
             end
         end
 
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index 8ba19ff..b709ebd 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -87,8 +87,8 @@ class Puppet::Parameter
         # Optionaly convert the value to a canonical form so that it will
         # be found in hashes, etc.  Mostly useful for namevars.
         def to_canonicalize(&block)
-            metaclass = (class << self; self; end)
-            metaclass.send(:define_method,:canonicalize,&block)
+            singleton_class = (class << self; self; end)
+            singleton_class.send(:define_method,:canonicalize,&block)
         end
 
         # Mark whether we're the namevar.
diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb
index 3cef0dd..2627926 100644
--- a/lib/puppet/provider.rb
+++ b/lib/puppet/provider.rb
@@ -109,7 +109,7 @@ class Puppet::Provider
     # Create the methods for a given command.
     def self.make_command_methods(name)
         # Now define a method for that command
-        unless metaclass.method_defined? name
+        unless singleton_class.method_defined? name
             meta_def(name) do |*args|
                 unless command(name)
                     raise Puppet::Error, "Command %s is missing" % name
diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb
index 2d4fc24..b882e80 100644
--- a/lib/puppet/provider/nameservice/directoryservice.rb
+++ b/lib/puppet/provider/nameservice/directoryservice.rb
@@ -20,7 +20,7 @@ require 'cgi'
 
 class Puppet::Provider::NameService
 class DirectoryService < Puppet::Provider::NameService
-    # JJM: Dive into the eigenclass
+    # JJM: Dive into the singleton_class
     class << self
         # JJM: This allows us to pass information when calling
         #      Puppet::Type.type
diff --git a/lib/puppet/util/metaid.rb b/lib/puppet/util/metaid.rb
index 0c38a5b..076775c 100644
--- a/lib/puppet/util/metaid.rb
+++ b/lib/puppet/util/metaid.rb
@@ -1,14 +1,14 @@
 class Object
     # The hidden singleton lurks behind everyone
-    def metaclass; class << self; self; end; end
-    def meta_eval(&blk); metaclass.instance_eval(&blk); end
+    def singleton_class; class << self; self; end; end
+    def meta_eval(&blk); singleton_class.instance_eval(&blk); end
 
-    # Adds methods to a metaclass
+    # Adds methods to a singleton_class
     def meta_def(name, &blk)
         meta_eval { define_method name, &blk }
     end
 
-    # Remove metaclass methods.
+    # Remove singleton_class methods.
     def meta_undef(name, &blk)
         meta_eval { remove_method name }
     end
diff --git a/spec/unit/file_serving/content.rb b/spec/unit/file_serving/content.rb
index cba7039..f772b86 100755
--- a/spec/unit/file_serving/content.rb
+++ b/spec/unit/file_serving/content.rb
@@ -14,7 +14,7 @@ describe Puppet::FileServing::Content do
     end
 
     it "should should include the IndirectionHooks module in its indirection" do
-        Puppet::FileServing::Content.indirection.metaclass.included_modules.should include(Puppet::FileServing::IndirectionHooks)
+        Puppet::FileServing::Content.indirection.singleton_class.included_modules.should include(Puppet::FileServing::IndirectionHooks)
     end
 
     it "should only support the raw format" do
diff --git a/spec/unit/file_serving/metadata.rb b/spec/unit/file_serving/metadata.rb
index 22f033d..ef2b3b6 100755
--- a/spec/unit/file_serving/metadata.rb
+++ b/spec/unit/file_serving/metadata.rb
@@ -14,7 +14,7 @@ describe Puppet::FileServing::Metadata do
     end
 
     it "should should include the IndirectionHooks module in its indirection" do
-        Puppet::FileServing::Metadata.indirection.metaclass.included_modules.should include(Puppet::FileServing::IndirectionHooks)
+        Puppet::FileServing::Metadata.indirection.singleton_class.included_modules.should include(Puppet::FileServing::IndirectionHooks)
     end
 
     it "should have a method that triggers attribute collection" do
diff --git a/spec/unit/indirector.rb b/spec/unit/indirector.rb
index cb1b049..806bcec 100755
--- a/spec/unit/indirector.rb
+++ b/spec/unit/indirector.rb
@@ -56,7 +56,7 @@ describe Puppet::Indirector, "when registering an indirection" do
 
     it "should extend the class with the Format Handler" do
         @indirection = @thingie.indirects :first
-        @thingie.metaclass.ancestors.should be_include(Puppet::Network::FormatHandler)
+        @thingie.singleton_class.ancestors.should be_include(Puppet::Network::FormatHandler)
     end
 
     after do
diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb
index 0f6fd13..8e62e15 100755
--- a/spec/unit/indirector/indirection.rb
+++ b/spec/unit/indirector/indirection.rb
@@ -133,7 +133,7 @@ describe Puppet::Indirector::Indirection do
         it "should extend itself with any specified module" do
             mod = Module.new
             @indirection = Puppet::Indirector::Indirection.new(mock('model'), :test, :extend => mod)
-            @indirection.metaclass.included_modules.should include(mod)
+            @indirection.singleton_class.included_modules.should include(mod)
         end
 
         after do
diff --git a/spec/unit/indirector/yaml.rb b/spec/unit/indirector/yaml.rb
index d93199e..37c33f0 100755
--- a/spec/unit/indirector/yaml.rb
+++ b/spec/unit/indirector/yaml.rb
@@ -16,7 +16,7 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
         @store = @store_class.new
 
         @subject = Object.new
-        @subject.metaclass.send(:attr_accessor, :name)
+        @subject.singleton_class.send(:attr_accessor, :name)
         @subject.name = :me
 
         @dir = "/what/ever"
diff --git a/spec/unit/relationship.rb b/spec/unit/relationship.rb
index 5a52cb5..b98e4e2 100755
--- a/spec/unit/relationship.rb
+++ b/spec/unit/relationship.rb
@@ -213,7 +213,7 @@ describe Puppet::Relationship, "when converting from pson" do
     end
 
     it "should be extended with the PSON utility module" do
-        Puppet::Relationship.metaclass.ancestors.should be_include(Puppet::Util::Pson)
+        Puppet::Relationship.singleton_class.ancestors.should be_include(Puppet::Util::Pson)
     end
 
     # LAK:NOTE For all of these tests, we convert back to the edge so we can
diff --git a/spec/unit/resource.rb b/spec/unit/resource.rb
index a2b214d..0e34c3c 100755
--- a/spec/unit/resource.rb
+++ b/spec/unit/resource.rb
@@ -615,7 +615,7 @@ describe Puppet::Resource do
         end
 
         it "should include the pson util module" do
-            Puppet::Resource.metaclass.ancestors.should be_include(Puppet::Util::Pson)
+            Puppet::Resource.singleton_class.ancestors.should be_include(Puppet::Util::Pson)
         end
 
         # LAK:NOTE For all of these tests, we convert back to the resource so we can
diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb
index 6c6a5e1..26f69ae 100755
--- a/spec/unit/resource/catalog.rb
+++ b/spec/unit/resource/catalog.rb
@@ -950,7 +950,7 @@ describe Puppet::Resource::Catalog, "when converting from pson" do
     end
 
     it "should be extended with the PSON utility module" do
-        Puppet::Resource::Catalog.metaclass.ancestors.should be_include(Puppet::Util::Pson)
+        Puppet::Resource::Catalog.singleton_class.ancestors.should be_include(Puppet::Util::Pson)
     end
 
     it "should create it with the provided name" do
diff --git a/spec/unit/ssl/certificate.rb b/spec/unit/ssl/certificate.rb
index 0d48991..6bd7e77 100755
--- a/spec/unit/ssl/certificate.rb
+++ b/spec/unit/ssl/certificate.rb
@@ -14,7 +14,7 @@ describe Puppet::SSL::Certificate do
     end
 
     it "should be extended with the Indirector module" do
-        @class.metaclass.should be_include(Puppet::Indirector)
+        @class.singleton_class.should be_include(Puppet::Indirector)
     end
 
     it "should indirect certificate" do
diff --git a/spec/unit/ssl/certificate_request.rb b/spec/unit/ssl/certificate_request.rb
index 63bc9f1..253009b 100755
--- a/spec/unit/ssl/certificate_request.rb
+++ b/spec/unit/ssl/certificate_request.rb
@@ -11,7 +11,7 @@ describe Puppet::SSL::CertificateRequest do
     end
 
     it "should be extended with the Indirector module" do
-        @class.metaclass.should be_include(Puppet::Indirector)
+        @class.singleton_class.should be_include(Puppet::Indirector)
     end
 
     it "should indirect certificate_request" do
diff --git a/spec/unit/ssl/key.rb b/spec/unit/ssl/key.rb
index b234704..cfeaf79 100755
--- a/spec/unit/ssl/key.rb
+++ b/spec/unit/ssl/key.rb
@@ -10,7 +10,7 @@ describe Puppet::SSL::Key do
     end
 
     it "should be extended with the Indirector module" do
-        @class.metaclass.should be_include(Puppet::Indirector)
+        @class.singleton_class.should be_include(Puppet::Indirector)
     end
 
     it "should indirect key" do
diff --git a/spec/unit/util/cacher.rb b/spec/unit/util/cacher.rb
index 40688bc..eb8515e 100755
--- a/spec/unit/util/cacher.rb
+++ b/spec/unit/util/cacher.rb
@@ -40,7 +40,7 @@ end
 
 describe Puppet::Util::Cacher do
     it "should be extended with the Expirer module" do
-        Puppet::Util::Cacher.metaclass.ancestors.should be_include(Puppet::Util::Cacher::Expirer)
+        Puppet::Util::Cacher.singleton_class.ancestors.should be_include(Puppet::Util::Cacher::Expirer)
     end
 
     it "should support defining cached attributes" do
@@ -154,7 +154,7 @@ describe Puppet::Util::Cacher do
                 extend Puppet::Util::Cacher
             end
 
-            klass.metaclass.cached_attr(:myattr) { "eh" }
+            klass.singleton_class.cached_attr(:myattr) { "eh" }
             klass.myattr
         end
 
diff --git a/spec/unit/util/tagging.rb b/spec/unit/util/tagging.rb
index 3486f46..04800b3 100755
--- a/spec/unit/util/tagging.rb
+++ b/spec/unit/util/tagging.rb
@@ -66,7 +66,7 @@ describe Puppet::Util::Tagging, "when adding tags" do
     end
 
     it "should provide a method for testing tag validity" do
-        @tagger.metaclass.publicize_methods(:valid_tag?)  { @tagger.should be_respond_to(:valid_tag?) }
+        @tagger.singleton_class.publicize_methods(:valid_tag?)  { @tagger.should be_respond_to(:valid_tag?) }
     end
 
     it "should add qualified classes as tags" do
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 0bed35c..282a01b 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -228,6 +228,54 @@ Host <<||>>"
             "Did not add extra namespace correctly")
     end
 
+    def test_find_hostclass_and_find_definition
+        parser = mkparser
+
+        # Make sure our scope calls the parser find_hostclass method with
+        # the right namespaces
+        scope = mkscope :parser => parser
+
+        parser.singleton_class.send(:attr_accessor, :last)
+
+        methods = [:find_hostclass, :find_definition]
+        methods.each do |m|
+            parser.meta_def(m) do |namespace, name|
+                @checked ||= []
+                @checked << [namespace, name]
+
+                # Only return a value on the last call.
+                if @last == namespace
+                    ret = @checked.dup
+                    @checked.clear
+                    return ret
+                else
+                    return nil
+                end
+            end
+        end
+
+        test = proc do |should|
+            parser.last = scope.namespaces[-1]
+            methods.each do |method|
+                result = scope.send(method, "testing")
+                assert_equal(should, result,
+                    "did not get correct value from %s with namespaces %s" %
+                    [method, scope.namespaces.inspect])
+            end
+        end
+
+        # Start with the empty namespace
+        assert_nothing_raised { test.call([["", "testing"]]) }
+
+        # Now add a namespace
+        scope.add_namespace("a")
+        assert_nothing_raised { test.call([["a", "testing"]]) }
+
+        # And another
+        scope.add_namespace("b")
+        assert_nothing_raised { test.call([["a", "testing"], ["b", "testing"]]) }
+    end
+
     # #629 - undef should be "" or :undef
     def test_lookupvar_with_undef
         scope = mkscope
diff --git a/test/network/server/mongrel_test.rb b/test/network/server/mongrel_test.rb
index 54bfb39..4414097 100755
--- a/test/network/server/mongrel_test.rb
+++ b/test/network/server/mongrel_test.rb
@@ -18,7 +18,7 @@ class TestMongrelServer < PuppetTest::TestCase
     # Make sure client info is correctly extracted.
     def test_client_info
         obj = Object.new
-        obj.metaclass.send(:attr_accessor, :params)
+        obj.singleton_class.send(:attr_accessor, :params)
         params = {}
         obj.params = params
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list