diff options
Diffstat (limited to 'lib/puppet/file_collection.rb')
-rw-r--r-- | lib/puppet/file_collection.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/puppet/file_collection.rb b/lib/puppet/file_collection.rb new file mode 100644 index 000000000..7db2600c0 --- /dev/null +++ b/lib/puppet/file_collection.rb @@ -0,0 +1,30 @@ +# A simple way to turn file names into singletons, +# so we don't have tons of copies of each file path around. +class Puppet::FileCollection + require 'puppet/file_collection/lookup' + + def self.collection + @collection + end + + def initialize + @paths = [] + @inverse = {} + end + + def index(path) + if i = @inverse[path] + return i + else + @paths << path + i = @inverse[path] = @paths.length - 1 + return i + end + end + + def path(index) + @paths[index] + end + + @collection = self.new +end |