]> gitweb.fluxo.info Git - puppet-stdlib.git/commit
(19864) num2bool match fix
authorSteve Huff <shuff@vecna.org>
Fri, 29 Mar 2013 19:06:36 +0000 (15:06 -0400)
committerSteve Huff <shuff@vecna.org>
Fri, 29 Mar 2013 19:06:36 +0000 (15:06 -0400)
commit8d217f0012fef332642faf485ad187773a95bcc1
tree371be730f79f090cd6ae2c53d132abeb2955733a
parent4a5218a8af8c3ffaf9ea2348a3900b19d6a95416
(19864) num2bool match fix

This is a bit more heavy-handed than I might like, but it does appear to
do the right things:

* accepts numeric input appropriately, truncating floats
* matches string input against a regex, then coerces number-looking
  strings to int
* makes a best effort to coerce anything else to a string, then subjects
  it to the same treatment
* raises an error in the event of incorrect number of arguments or
  non-number-looking strings

I've also included some additional unit tests.
lib/puppet/parser/functions/num2bool.rb
spec/unit/puppet/parser/functions/num2bool_spec.rb