# File lib/puppet/util/autoload.rb, line 130 130: def module_directories(env=nil) 131: # We have to require this late in the process because otherwise we might have 132: # load order issues. 133: require 'puppet/node/environment' 134: 135: real_env = Puppet::Node::Environment.new(env) 136: 137: # We're using a per-thread cache of said module directories, so that 138: # we don't scan the filesystem each time we try to load something with 139: # this autoload instance. But since we don't want to cache for the eternity 140: # this env_module_directories gets reset after the compilation on the master. 141: # This is also reset after an agent ran. 142: # One of the side effect of this change is that this module directories list will be 143: # shared among all autoload that we have running at a time. But that won't be an issue 144: # as by definition those directories are shared by all autoload. 145: Thread.current[:env_module_directories] ||= {} 146: Thread.current[:env_module_directories][real_env] ||= real_env.modulepath.collect do |dir| 147: Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| File.join(dir, f) } 148: end.flatten.collect { |d| [File.join(d, "plugins"), File.join(d, "lib")] }.flatten.find_all do |d| 149: FileTest.directory?(d) 150: end 151: end