diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/fact.rb | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/puppet/fact.rb b/lib/puppet/fact.rb deleted file mode 100644 index f17131d02..000000000 --- a/lib/puppet/fact.rb +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/local/bin/ruby -w - -# $Id$ - -# an interface for registering and retrieving facts -# this is an abstract interface, and should just be used to interact -# with another library - -# currently a very thin veneer on 'facter' - -require 'facter' -require 'puppet' -require 'puppet/type' - -module Puppet - class Fact - def Fact.[](name) - fact = Facter[name] - if fact.value.nil? - raise "Could not retrieve fact %s" % name - end - return fact.value - end - - # just pass the block to 'add' - # the block has to do things like set the interpreter, - # the code (which can be a ruby block), and maybe the - # os and osrelease - def Fact.add(name,&block) - Facter[name].add(&block) - end - - def Fact.name - return :fact - end - - def Fact.namevar - return :name - end - - #Puppet::Type.newtype(self) - - # we're adding a new resolution mechanism here; this is just how - # types work - # we don't have any real interest in the returned object - def initialize(hash) - name = hash[:name] - hash.delete(:name) - Fact.add(name) { |fact| - method = nil - hash.each { |key,value| - if key.is_a?(String) - method = key + "=" - elsif key.is_a?(Symbol) - method = key.id2name + "=" - else - raise "Key must be either string or symbol" - end - fact.send(method,value) - } - } - end - end -end |