[Pkg-puppet-devel] [facter] 161/352: (maint) decouple option settings on facts and resolutions
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:41 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit 697a3c3e5666ad28e069877f8e304480522902e4
Author: Adrien Thebo <git at somethingsinistral.net>
Date: Mon Dec 30 12:29:12 2013 -0800
(maint) decouple option settings on facts and resolutions
---
lib/facter/util/collection.rb | 22 ++--------------------
lib/facter/util/resolution.rb | 6 +++---
spec/unit/util/collection_spec.rb | 2 +-
3 files changed, 6 insertions(+), 24 deletions(-)
diff --git a/lib/facter/util/collection.rb b/lib/facter/util/collection.rb
index 76df949..ea5b95d 100644
--- a/lib/facter/util/collection.rb
+++ b/lib/facter/util/collection.rb
@@ -60,14 +60,7 @@ class Facter::Util::Collection
@facts[name] = fact
end
- # Set any fact-appropriate options.
- options.each do |opt, value|
- method = opt.to_s + "="
- if fact.respond_to?(method)
- fact.send(method, value)
- options.delete(opt)
- end
- end
+ fact.extract_ldapname_option!(options)
if block_given?
resolve = fact.add(&block)
@@ -77,18 +70,7 @@ class Facter::Util::Collection
# Set any resolve-appropriate options
if resolve
- # If the resolve was actually added, set any resolve-appropriate options
- options.each do |opt, value|
- method = opt.to_s + "="
- if resolve.respond_to?(method)
- resolve.send(method, value)
- options.delete(opt)
- end
- end
- end
-
- unless options.empty?
- raise ArgumentError, "Invalid facter option(s) %s" % options.keys.collect { |k| k.to_s }.join(",")
+ resolve.set_options(options)
end
return fact
diff --git a/lib/facter/util/resolution.rb b/lib/facter/util/resolution.rb
index c36ecc9..c5c159f 100644
--- a/lib/facter/util/resolution.rb
+++ b/lib/facter/util/resolution.rb
@@ -108,15 +108,15 @@ class Facter::Util::Resolution
def set_options(options)
ret = {}
- if options[:value]
+ if options.has_key?(:value)
@value = options.delete(:value)
end
- if options[:timeout]
+ if options.has_key?(:timeout)
@timeout = options.delete(:timeout)
end
- if options[:weight]
+ if options.has_key?(:weight)
@weight = options.delete(:weight)
end
diff --git a/spec/unit/util/collection_spec.rb b/spec/unit/util/collection_spec.rb
index afca69b..c77f429 100755
--- a/spec/unit/util/collection_spec.rb
+++ b/spec/unit/util/collection_spec.rb
@@ -46,7 +46,7 @@ describe Facter::Util::Collection do
describe "and a block is provided" do
it "should use the block to add a resolution to the fact" do
- fact = mock 'fact'
+ fact = mock 'fact', :extract_ldapname_option! => nil
Facter::Util::Fact.expects(:new).returns fact
fact.expects(:add)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list