diff options
author | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-05-31 00:04:50 +0000 |
---|---|---|
committer | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2006-05-31 00:04:50 +0000 |
commit | a15c8f55b791a407fada52765a3e8a14a7d31f5c (patch) | |
tree | 0619a9164b70dc16e8006b13ac7d66eb4e594296 | |
parent | ee7d3cad4775956fa4cc8f6020d588aa1160e1fc (diff) | |
download | facter-a15c8f55b791a407fada52765a3e8a14a7d31f5c.tar.gz facter-a15c8f55b791a407fada52765a3e8a14a7d31f5c.tar.xz facter-a15c8f55b791a407fada52765a3e8a14a7d31f5c.zip |
Adding rubysitedir fact, as requested in #13. Also, switching the output when one fact is asked for, so it only produces the single value, with no => symbol.
git-svn-id: http://reductivelabs.com/svn/facter/trunk@122 1f5c1d6a-bddf-0310-8f58-fc49e503516a
-rwxr-xr-x | bin/facter | 6 | ||||
-rw-r--r-- | lib/facter.rb | 9 | ||||
-rwxr-xr-x | tests/tc_facterbin.rb | 12 |
3 files changed, 25 insertions, 2 deletions
@@ -67,5 +67,9 @@ else end facts.each { |name,value| - puts "%s => %s" % [name,value] + if facts.length == 1 + puts value + else + puts "%s => %s" % [name,value] + end } diff --git a/lib/facter.rb b/lib/facter.rb index 5feee20..3c61258 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -530,6 +530,15 @@ class Facter } end + Facter.add :rubysitedir do + setcode do + version = RUBY_VERSION.to_s.sub(/\.\d+$/, '') + $:.find do |dir| + dir =~ /#{File.join("site_ruby", version)}$/ + end + end + end + Facter.add("Kernel") do setcode 'uname -s' end diff --git a/tests/tc_facterbin.rb b/tests/tc_facterbin.rb index cd58698..2fa12e7 100755 --- a/tests/tc_facterbin.rb +++ b/tests/tc_facterbin.rb @@ -28,7 +28,7 @@ class TestFacterBin < Test::Unit::TestCase def test_output output = nil assert_nothing_raised { - output = %x{facter 2>&1}.chomp + output = %x{facter 2>&1}.chomp } hash = output.split("\n").inject({}) do |h, line| @@ -45,6 +45,16 @@ class TestFacterBin < Test::Unit::TestCase assert_equal(fact, hash[name], "%s was not equal" % name) end end + + # Verify we don't print much when they just want a single fact. + def test_simpleoutput + output = nil + assert_nothing_raised { + output = %x{facter kernel 2>&1}.chomp + } + + assert(output !~ / => /, "Output includes the farrow thing") + end end # $Id$ |