summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-26 19:27:30 -0600
committerLuke Kanies <luke@madstop.com>2007-11-26 19:27:30 -0600
commit12ebbe2442e8f05585fb1c0bd9dcbe052fd59ba7 (patch)
treeb437db22033e6ff7310675eda781097803e4fa9a /lib/puppet/util
parentfc7f1b4f70d8e4b62852a0da0af21fcb67a1a89c (diff)
downloadpuppet-12ebbe2442e8f05585fb1c0bd9dcbe052fd59ba7.tar.gz
puppet-12ebbe2442e8f05585fb1c0bd9dcbe052fd59ba7.tar.xz
puppet-12ebbe2442e8f05585fb1c0bd9dcbe052fd59ba7.zip
Rewriting the tests for the package resource type, fixing #930.
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/provider_features.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb
index d5f272420..3a9d4262d 100644
--- a/lib/puppet/util/provider_features.rb
+++ b/lib/puppet/util/provider_features.rb
@@ -55,9 +55,7 @@ module Puppet::Util::ProviderFeatures
# required to determine if the feature is present.
def feature(name, docs, hash = {})
@features ||= {}
- if @features.include?(name)
- raise Puppet::DevError, "Feature %s is already defined" % name
- end
+ raise(Puppet::DevError, "Feature %s is already defined" % name) if @features.include?(name)
begin
obj = ProviderFeature.new(name, docs, hash)
@features[obj.name] = obj
@@ -133,7 +131,8 @@ module Puppet::Util::ProviderFeatures
}
end
- # Create a method that will list all functional features.
+ # Create a method that will determine if a provided list of
+ # features are satisfied by the curred provider.
@feature_module.send(:define_method, :satisfies?) do |*needed|
ret = true
needed.flatten.each do |feature|
@@ -150,13 +149,7 @@ module Puppet::Util::ProviderFeatures
@features.each do |name, feature|
method = name.to_s + "?"
@feature_module.send(:define_method, method) do
- if defined? @declared_features and @declared_features.include?(name)
- true
- elsif feature.available?(self)
- true
- else
- false
- end
+ self.class.declared_feature?(name) or feature.available?(self)
end
end
@@ -173,5 +166,12 @@ module Puppet::Util::ProviderFeatures
end
@feature_module
end
+
+ # Return the actual provider feature instance. Really only used for testing.
+ def provider_feature(name)
+ return nil unless defined?(@features)
+
+ @features[name]
+ end
end