Jeff McCune [Wed, 10 Apr 2013 21:35:42 +0000 (14:35 -0700)]
(maint) Make stdlib usable as a Ruby GEM
Without this patch it is inconvenient to use the functions included in
stdlib in a development setting. The Puppet modulepath must be
explicitly set for the functions to be automatically loaded.
This patch addresses the problem by adding a gem specification and
dependency Gemfile. This makes it possible to directly use stdlib and
all of the components it depends upon, like so:
The first command will install all of the dependencies, including Puppet
and Facter, into the local project directory. The second command will
make stdlib avaialable as a Gem, which will be picked up by Puppet since
(#7788) was merged into Puppet in the 3.0 release.
Jeff McCune [Wed, 10 Apr 2013 21:33:08 +0000 (14:33 -0700)]
(maint) Add the behavior for count() with arrays and hashes
Without this patch the expected behavior of the count() function when
dealing with an out of bound array index and with a hash key that does
not exist is implicitly encoded in the spec examples. This is a problem
because the expected behavior is not clear for something similar to the
following example:
Adrien Thebo [Mon, 25 Feb 2013 22:00:20 +0000 (14:00 -0800)]
(maint) Backport Gemfile and .travis.yml to 2.x
This is a partial backport and update of 03c5c4a434c2290c021034dbfed82cb0f97e0e87
to add travis-ci support and a Gemfile to 2.x. Right now we're not
testing 2.x in travis-ci and we're experiencing spec failures because we
have to install rspec-puppet from git. The best resolution for this is
to consistently use a Gemfile for running tests.
This commit also rewrites the .travis.yml for 2.x to only test 2.x
versions against ruby 1.8.7 and Puppet < 3.0
Amos Shapira [Sun, 31 Mar 2013 12:37:30 +0000 (23:37 +1100)]
(#19998) Implement any2array
This change is to implement a new function "any2array", which will take any
argument or arguments and create an array which contains it. If the argument
is a single array then it will be returned as-is. If the argument is a single
hash then it will be converted into an array. Otherwise (if there are more than
one argument, or the only argument is not an array or a hash) the function will
return an array containing all the arguments.
Steve Huff [Fri, 29 Mar 2013 19:06:36 +0000 (15:06 -0400)]
(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
Steve Huff [Fri, 29 Mar 2013 16:03:33 +0000 (12:03 -0400)]
Reworked number-handling logic
No more coercing to String and regex matching. Instead, we now coerce
to Integer at the beginning or raise an error if we cannot coerce to
Integer.
A consequence of this change is that the function will now accept
blatantly non-numeric strings as input, and return false. This seems a
bit goofy to me, but it's how String#to_i works. If we really don't
like this, then I'm open to suggestions.
Erik Dalén [Wed, 20 Mar 2013 15:36:20 +0000 (16:36 +0100)]
Allow comparisons of Numeric and number as String
Puppet passes numbers as String to functions, but it makes more sense to
compare them as Numeric.
But sometimes Puppet passes them as the wrong type, see:
https://projects.puppetlabs.com/issues/19812
Adrien Thebo [Wed, 27 Mar 2013 20:37:25 +0000 (13:37 -0700)]
(maint) better error reporting for prefix and suffix
When prefix and suffix did error checking with positional arguments,
they would not report the position of the argument that failed to
validate. This commit changes the messages to indicate which argument
failed.
Eric Shamow [Wed, 4 Apr 2012 02:30:46 +0000 (22:30 -0400)]
(#13610) Add is_function_available to stdlib
This function provides a simple wrapper around
Puppet::Parser::Functions.function for access within Puppet manifests.
This will allow users to check whether or not a plugin or functionality
such as hiera is installed on the server.
Jeff McCune [Mon, 25 Feb 2013 22:00:20 +0000 (14:00 -0800)]
(maint) Add Ruby 2.0.0 to Travis build matrix
Without this patch we're not testing against Ruby 2.0.0 which has recently been
released. This is a problem because we'd like a way to be notified if a change
set breaks compatibility with future supported versions of Ruby.
This patch should not be taken as an indication that we fully support Ruby 2.0,
just as an indication that we plan to in the future.
This patch also tightens up the specifications of the build matrix. In
addition to testing against the specific Puppet dependency versions, we're also
testing against the latest 2.7.x release and the latest release.
I'm reverting this change because of concerns raised by Peter Meier that
it duplicates the "in" operator in the DSL. The "in" operator is new
information that I did not posses when I made the decision to merge.
Because of this new information I'm un-merging and continuing the
discussion in the comments of
https://projects.puppetlabs.com/issues/19272
Joshua Hoblitt [Thu, 14 Feb 2013 18:57:35 +0000 (11:57 -0700)]
(#19272) Add has_element() function
It is exceptionally difficult to determine if an array contains an element matching a specific value without an iteration or loop construct.
This function is the Puppet equivalent of Array.includes?(foo) in Ruby. The implementation is a verbatim copy of has_key() with the minor modifications needed to support arrays instead of hashes.
fatmcgav [Tue, 12 Feb 2013 15:07:18 +0000 (15:07 +0000)]
(#19201) Add concat function to join two arrays
Without this patch applied there is no easy way to append one array to
another. This is a problem because it is often desirable to join two
arrays without flattening the contents into a single, one dimensional
array.
This patch addresses the problem by adding a `concat()` function which
takes two arguments. The arguments will be concatenated together and a
new array returned to the caller.
Jeff McCune [Wed, 23 Jan 2013 21:30:56 +0000 (13:30 -0800)]
Merge branch 'raphink-validate_augeas'
* raphink-validate_augeas:
Add an URL to a doc on how to activate augeas in puppet
validate_augeas: requires augeas
validate_augeas: Ensure tmpfile is closed and unlinked
validate_augeas: Ensure augeas handler gets closed
Add validate_augeas function
This patch addresses the problem by explicitly returning an empty string if the
string itself is empty. This avoids trying to convert an empty string to a
symbol which is the root cause of the problem.
Jaka Hudoklin [Wed, 2 Jan 2013 12:10:43 +0000 (12:10 +0000)]
Add getparam function to get defined resource parameters
As far as i know there's no other puppet-dsl-like way to get parameter of
defined resource, so that's why i implemented getparam function, which takes
resource reference and parameter name and returns parameter value.
Here's another example why this function is really useful:
Jeff McCune [Mon, 7 Jan 2013 22:48:30 +0000 (14:48 -0800)]
(maint) Update puppet version in Travis configuration
Without this patch we'll test against all Puppet 3.0 versions, but not
4. This is a problem because the travis configuration should be
relatively future proof to minimize surprises.
This patch addresses the problem by using >= instead of ~> in the
dependency specification. The patch also combines two different
notification sections into a single entry.
Jeff McCune [Mon, 7 Jan 2013 02:45:43 +0000 (18:45 -0800)]
Tell Travis CI to notify the PDC WebHook
Without this patch the so-called "puppet development community" hook
service isn't being notified when Travis CI accepts jobs. This is a
problem because we want the ability for Travis Bot to comment on pull
requests as a result of CI build results. For example, if the build
fails, then Gepetto Bot could make some helpful suggestions on how to
re-run the build by amending a commit and force-pushing the branch.
This patch uses the notifications section of the travis.yml
configuration file, as documented at:
http://about.travis-ci.org/docs/user/notifications/#Webhook-notification
Jeff McCune [Sun, 6 Jan 2013 05:11:53 +0000 (21:11 -0800)]
Future proof travis build matrix
Without this patch we're not building against ruby head. This is a
problem because we need to know if standard lib works with the latest
version of MRI.
This patch builds against ruby head but also allows the build to pass if
there are failures with ruby-head.
Jeff McCune [Sat, 5 Jan 2013 23:01:56 +0000 (15:01 -0800)]
(maint) Add Travis CI Support
Without this patch stdlib has Travis CI configuration files, but they
don't seem to completely specify the dependency versions and the build
matrix. This patch addresses the problem by putting the dependency
information in the conventional Gemfile location.
This patch should coincide with enabling Travis CI support for pull
requests. A build status image is also included in the project README.
Jeff McCune [Thu, 3 Jan 2013 21:39:42 +0000 (13:39 -0800)]
Merge branch '4.x'
* 4.x:
Add test/validation for is_float if created from an arithmetical operation
Add test/validation for is_integer if created from an arithmetical operation
Add test/validation for is_numeric if created from an arithmetical operation
Jeff McCune [Thu, 3 Jan 2013 21:39:05 +0000 (13:39 -0800)]
Merge branch '3.x' into 4.x
* 3.x:
Add test/validation for is_float if created from an arithmetical operation
Add test/validation for is_integer if created from an arithmetical operation
Add test/validation for is_numeric if created from an arithmetical operation
Jeff McCune [Thu, 3 Jan 2013 21:38:36 +0000 (13:38 -0800)]
Merge branch '3.2.x' into 3.x
* 3.2.x:
Add test/validation for is_float if created from an arithmetical operation
Add test/validation for is_integer if created from an arithmetical operation
Add test/validation for is_numeric if created from an arithmetical operation
Jeff McCune [Thu, 3 Jan 2013 21:38:16 +0000 (13:38 -0800)]
Merge branch 'stephenrjohnson-bug/3.x/18157_arithmetical_operations' into 3.2.x
* stephenrjohnson-bug/3.x/18157_arithmetical_operations:
Add test/validation for is_float if created from an arithmetical operation
Add test/validation for is_integer if created from an arithmetical operation
Add test/validation for is_numeric if created from an arithmetical operation