[Pkg-puppet-devel] [facter] 184/352: (fact-194) Add Facter.search_external{, _path}

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:44 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 1590a4c5475da93f8f609a14b7f9a4e63511f8dc
Author: Kylo Ginsberg <kylo at puppetlabs.com>
Date:   Wed Jan 22 23:00:29 2014 -0800

    (fact-194) Add Facter.search_external{,_path}
---
 lib/facter.rb            | 20 ++++++++++++++++++++
 spec/unit/facter_spec.rb | 23 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/lib/facter.rb b/lib/facter.rb
index eff1665..da433d0 100644
--- a/lib/facter.rb
+++ b/lib/facter.rb
@@ -399,4 +399,24 @@ module Facter
   def self.search_path
     @search_path.dup
   end
+
+  # Registers directories to be searched for external facts.
+  #
+  # @param dirs [Array<String>] directories to search
+  #
+  # @return [void]
+  #
+  # @api public
+  def self.search_external(dirs)
+    Facter::Util::Config.external_facts_dirs += dirs
+  end
+
+  # Returns the registered search directories.
+  #
+  # @return [Array<String>] An array of the directories searched
+  #
+  # @api public
+  def self.search_external_path
+    Facter::Util::Config.external_facts_dirs.dup
+  end
 end
diff --git a/spec/unit/facter_spec.rb b/spec/unit/facter_spec.rb
index 9c3bdef..2279c27 100755
--- a/spec/unit/facter_spec.rb
+++ b/spec/unit/facter_spec.rb
@@ -116,6 +116,14 @@ describe Facter do
     Facter.should respond_to(:search_path)
   end
 
+  it "should have a method for registering directories to search for external facts" do
+    Facter.should respond_to(:search_external)
+  end
+
+  it "should have a method for returning the registered search directories for external facts" do
+    Facter.should respond_to(:search_external_path)
+  end
+
   it "should have a method to query debugging mode" do
     Facter.should respond_to(:debugging?)
   end
@@ -253,4 +261,19 @@ describe Facter do
       Facter.search_path.should == %w{/my/dir /other/dir}
     end
   end
+
+  describe "when registering directories to search for external facts" do
+    it "should allow registration of a directory" do
+      Facter.search_external ["/my/dir"]
+    end
+
+    it "should allow registration of multiple directories" do
+      Facter.search_external ["/my/dir", "/other/dir"]
+    end
+
+    it "should return all registered directories when asked" do
+      Facter.search_external ["/my/dir", "/other/dir"]
+      Facter.search_external_path.should include("/my/dir", "/other/dir")
+    end
+  end
 end

-- 
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