summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@opscode.com>2013-11-25 11:34:08 -0800
committerBryan McLellan <btm@opscode.com>2013-11-25 11:34:08 -0800
commitbcc1557b31a66bd8127fa6306eb067596540db74 (patch)
tree362fa296040cb39d917c8b1e96e8b68df77bfa45
parentbed2a6a69674e99abea5d79dc312592deecc577b (diff)
parentabcaf72402b16af8894f915b1e0c30bd6c876b2f (diff)
downloadohai-bcc1557b31a66bd8127fa6306eb067596540db74.tar.gz
Merge branch 'OHAI-358'
-rw-r--r--lib/ohai/plugins/php.rb6
-rw-r--r--spec/unit/plugins/php_spec.rb7
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/ohai/plugins/php.rb b/lib/ohai/plugins/php.rb
index 7489b52f..49d8cb74 100644
--- a/lib/ohai/plugins/php.rb
+++ b/lib/ohai/plugins/php.rb
@@ -28,10 +28,10 @@ Ohai.plugin(:PHP) do
so = shell_out("php -v")
if so.exitstatus == 0
- output = so.stdout.split
- if output.length >= 6
+ output = /PHP (\S+).+built: ([^)]+)/.match(so.stdout)
+ if output
php[:version] = output[1]
- php[:builddate] = "%s %s %s" % [output[4],output[5],output[6]]
+ php[:builddate] = output[2]
end
languages[:php] = php if php[:version]
end
diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb
index fac70509..0cf011e0 100644
--- a/spec/unit/plugins/php_spec.rb
+++ b/spec/unit/plugins/php_spec.rb
@@ -48,6 +48,13 @@ describe Ohai::System, "plugin php" do
@plugin.languages.should_not have_key(:php)
end
+ it "should parse builddate even if it's suhosin patched" do
+ @stdout = "PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30) \nCopyright (c) 1997-2013 The PHP Group\nZend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies"
+ @plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
+ @plugin.run
+ @plugin.languages[:php][:builddate].should eql("Aug 30 2013 04:30:30")
+ end
+
#########
test_plugin([ "languages", "php" ], [ "php" ]) do | p |