summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/facter6
-rw-r--r--lib/facter.rb9
-rwxr-xr-xtests/tc_facterbin.rb12
3 files changed, 25 insertions, 2 deletions
diff --git a/bin/facter b/bin/facter
index 61db7ea..f4a8b54 100755
--- a/bin/facter
+++ b/bin/facter
@@ -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$