Faidon Liambotis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/106876


Change subject: librenms: minor fixes to phpdump
......................................................................

librenms: minor fixes to phpdump

Handle integers properly, NULL & strings with embedded quotes. Borrowed
from Ori's equivalent code that was developed before this but was never
imported into this repo.

Change-Id: I36dfd0f082ed48f62c537283ed24017f1ac8ada1
---
M modules/librenms/lib/puppet/parser/functions/phpdump.rb
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/76/106876/1

diff --git a/modules/librenms/lib/puppet/parser/functions/phpdump.rb 
b/modules/librenms/lib/puppet/parser/functions/phpdump.rb
index 205f8ce..0c094b5 100644
--- a/modules/librenms/lib/puppet/parser/functions/phpdump.rb
+++ b/modules/librenms/lib/puppet/parser/functions/phpdump.rb
@@ -11,7 +11,7 @@
     contents = ''
     o.sort.each do |k, v|
       contents += indent*level
-      contents += "\"#{k}\" => " + phpdump(v, level+1)
+      contents += k.to_pson + " => " + phpdump(v, level+1)
       contents += ",\n"
     end
     "array(\n" + contents + indent*(level-1) + ")"
@@ -21,8 +21,10 @@
     "TRUE"
   when FalseClass
     "FALSE"
+  when nil
+    "NULL"
   else
-    '"' + o.to_s + '"'
+    o.include?('.') ? Float(o).to_s : Integer(o).to_s rescue o.to_pson
   end
 end
 

-- 
To view, visit https://gerrit.wikimedia.org/r/106876
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I36dfd0f082ed48f62c537283ed24017f1ac8ada1
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to