Removed the @autoloaders hash (and the classproxy declaration which
enabled code to access it).  This hash was only being stored into and
never read.  This made it possible to remove the "object" parameter to
Autoload#initialize(), which was only being used as a key for the
@autoloaders hash.

Signed-off-by: Paul Berry <[email protected]>
---
 lib/puppet/metatype/manager.rb             |   14 ++------------
 lib/puppet/parser/functions.rb             |    8 +-------
 lib/puppet/util/autoload.rb                |   16 ++--------------
 lib/puppet/util/feature.rb                 |    2 +-
 lib/puppet/util/instance_loader.rb         |    2 +-
 lib/puppet/util/subclass_loader.rb         |    6 +-----
 spec/integration/util/autoload_spec.rb     |    9 ++-------
 spec/unit/util/autoload/file_cache_spec.rb |    4 ++--
 spec/unit/util/autoload_spec.rb            |    4 ++--
 9 files changed, 14 insertions(+), 51 deletions(-)

diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb
index 12cbf64..6d39d80 100644
--- a/lib/puppet/metatype/manager.rb
+++ b/lib/puppet/metatype/manager.rb
@@ -86,12 +86,7 @@ module Manager
     klass.ensurable if klass.ensurable? and ! klass.validproperty?(:ensure)
 
     # Now set up autoload any providers that might exist for this type.
-
-          klass.providerloader = Puppet::Util::Autoload.new(
-        klass,
-        
-      "puppet/provider/#{klass.name.to_s}"
-    )
+    klass.providerloader = 
Puppet::Util::Autoload.new("puppet/provider/#{klass.name.to_s}")
 
     # We have to load everything so that we can figure out the default type.
     klass.providerloader.loadall
@@ -132,12 +127,7 @@ module Manager
   # Create a loader for Puppet types.
   def typeloader
     unless defined?(@typeloader)
-
-            @typeloader = Puppet::Util::Autoload.new(
-        self,
-        
-        "puppet/type", :wrap => false
-      )
+      @typeloader = Puppet::Util::Autoload.new("puppet/type", :wrap => false)
     end
 
     @typeloader
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index b0deac5..a3e1836 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -16,13 +16,7 @@ module Puppet::Parser::Functions
 
   def self.autoloader
     unless defined?(@autoloader)
-
-            @autoloader = Puppet::Util::Autoload.new(
-        self,
-        "puppet/parser/functions",
-
-        :wrap => false
-      )
+      @autoloader = Puppet::Util::Autoload.new("puppet/parser/functions", 
:wrap => false)
     end
 
     @autoloader
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb
index f0dd0a5..df0d127 100644
--- a/lib/puppet/util/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -10,17 +10,8 @@ class Puppet::Util::Autoload
   include Puppet::Util::Cacher
   include Puppet::Util::Autoload::FileCache
 
-  @autoloaders = {}
   @loaded = []
 
-  class << self
-    attr_reader :autoloaders
-    private :autoloaders
-  end
-
-  # Send [], []=, and :clear to the @autloaders hash
-  Puppet::Util.classproxy self, :autoloaders, "[]", "[]="
-
   # List all loaded files.
   def self.list_loaded
     @loaded.sort { |a,b| a[0] <=> b[0] }.collect do |path, hash|
@@ -46,14 +37,11 @@ class Puppet::Util::Autoload
     @loaded << file unless @loaded.include?(file)
   end
 
-  attr_accessor :object, :path, :objwarn, :wrap
+  attr_accessor :path, :objwarn, :wrap
 
-  def initialize(obj, path, options = {})
+  def initialize(path, options = {})
     @path = path.to_s
     raise ArgumentError, "Autoload paths cannot be fully qualified" if @path 
!~ /^\w/
-    @object = obj
-
-    self.class[obj] = self
 
     options.each do |opt, value|
       opt = opt.intern if opt.is_a? String
diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb
index 2f70410..b3ea3f0 100644
--- a/lib/puppet/util/feature.rb
+++ b/lib/puppet/util/feature.rb
@@ -35,7 +35,7 @@ class Puppet::Util::Feature
   def initialize(path)
     @path = path
     @results = {}
-    @loader = Puppet::Util::Autoload.new(self, @path)
+    @loader = Puppet::Util::Autoload.new(@path)
   end
 
   def load
diff --git a/lib/puppet/util/instance_loader.rb 
b/lib/puppet/util/instance_loader.rb
index 5e16bd7..b041f56 100755
--- a/lib/puppet/util/instance_loader.rb
+++ b/lib/puppet/util/instance_loader.rb
@@ -17,7 +17,7 @@ module Puppet::Util::InstanceLoader
     @instances ||= {}
     type = symbolize(type)
     @instances[type] = {}
-    @autoloaders[type] = Puppet::Util::Autoload.new(self, path, options)
+    @autoloaders[type] = Puppet::Util::Autoload.new(path, options)
 
     # Now define our new simple methods
     unless respond_to?(type)
diff --git a/lib/puppet/util/subclass_loader.rb 
b/lib/puppet/util/subclass_loader.rb
index 3fb0488..a21c9bf 100644
--- a/lib/puppet/util/subclass_loader.rb
+++ b/lib/puppet/util/subclass_loader.rb
@@ -18,11 +18,7 @@ module Puppet::Util::SubclassLoader
     raise ArgumentError, "Must be a class to use SubclassLoader" unless 
self.is_a?(Class)
     @subclasses = []
 
-          @loader = Puppet::Util::Autoload.new(
-        self,
-        
-      path, :wrap => false
-    )
+    @loader = Puppet::Util::Autoload.new(path, :wrap => false)
 
     @subclassname = name
 
diff --git a/spec/integration/util/autoload_spec.rb 
b/spec/integration/util/autoload_spec.rb
index 8a5d662..ea1d95f 100755
--- a/spec/integration/util/autoload_spec.rb
+++ b/spec/integration/util/autoload_spec.rb
@@ -41,7 +41,7 @@ describe Puppet::Util::Autoload do
     Dir.mkdir(dir)
     rbdir = File.join(dir, path.to_s)
     Dir.mkdir(rbdir)
-    loader = Puppet::Util::Autoload.new(name, path)
+    loader = Puppet::Util::Autoload.new(path)
     yield rbdir, loader
     Dir.rmdir(rbdir)
     Dir.rmdir(dir)
@@ -49,13 +49,8 @@ describe Puppet::Util::Autoload do
     AutoloadIntegrator.clear
   end
 
-  it "should make instances available by the loading class" do
-    loader = Puppet::Util::Autoload.new("foo", "bar")
-    Puppet::Util::Autoload["foo"].should == loader
-  end
-
   it "should not fail when asked to load a missing file" do
-    Puppet::Util::Autoload.new("foo", "bar").load(:eh).should be_false
+    Puppet::Util::Autoload.new("bar").load(:eh).should be_false
   end
 
   it "should load and return true when it successfully loads a file" do
diff --git a/spec/unit/util/autoload/file_cache_spec.rb 
b/spec/unit/util/autoload/file_cache_spec.rb
index c94ec71..84177a6 100755
--- a/spec/unit/util/autoload/file_cache_spec.rb
+++ b/spec/unit/util/autoload/file_cache_spec.rb
@@ -76,7 +76,7 @@ describe Puppet::Util::Autoload::FileCache do
 
     it "should share cached data across autoload instances" do
       File.expects(:lstat).with("/my/file").once.returns mock("stat")
-      other = Puppet::Util::Autoload.new("bar", "tmp")
+      other = Puppet::Util::Autoload.new("tmp")
 
       @cacher.should be_file_exist("/my/file")
       other.should be_file_exist("/my/file")
@@ -150,7 +150,7 @@ describe Puppet::Util::Autoload::FileCache do
 
     it "should share cached data across autoload instances" do
       File.expects(:lstat).with("/my/file").once.returns @stat
-      other = Puppet::Util::Autoload.new("bar", "tmp")
+      other = Puppet::Util::Autoload.new("tmp")
 
       @cacher.should be_directory_exist("/my/file")
       other.should be_directory_exist("/my/file")
diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb
index eb0b705..a03dffc 100755
--- a/spec/unit/util/autoload_spec.rb
+++ b/spec/unit/util/autoload_spec.rb
@@ -6,7 +6,7 @@ require 'puppet/util/autoload'
 
 describe Puppet::Util::Autoload do
   before do
-    @autoload = Puppet::Util::Autoload.new("foo", "tmp")
+    @autoload = Puppet::Util::Autoload.new("tmp")
 
     @autoload.stubs(:eachdir).yields "/my/dir"
   end
@@ -53,7 +53,7 @@ describe Puppet::Util::Autoload do
     end
 
     it "should include in its search path all of the search directories that 
have a subdirectory matching the autoload path" do
-      @autoload = Puppet::Util::Autoload.new("foo", "loaddir")
+      @autoload = Puppet::Util::Autoload.new("loaddir")
       @autoload.expects(:search_directories).returns %w{/one /two /three}
       FileTest.expects(:directory?).with("/one/loaddir").returns true
       FileTest.expects(:directory?).with("/two/loaddir").returns false
-- 
1.7.2

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to