Skip to content

(19864) Enable num2bool to accept numeric input #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
0879388
Merge branch '4.x'
Oct 25, 2012
f2143e0
Merge branch '4.x'
Oct 25, 2012
efb0a85
Merge branch '4.x'
Oct 25, 2012
aa22cde
Merge branch '4.x'
Oct 25, 2012
23cf7d0
Merge branch '4.x'
Oct 25, 2012
34b9cb8
Merge branch '4.x'
Nov 7, 2012
747dcc6
Merge branch '4.x'
Nov 7, 2012
fda49d4
Merge branch '4.x'
Nov 15, 2012
88acc52
puppet-lint cleanup
jfryman Nov 9, 2012
f40bb1e
Merge branch '4.x'
Nov 19, 2012
326a139
Merge branch 'jfryman-master'
Nov 19, 2012
32419e7
Merge branch '4.x'
Nov 20, 2012
0695296
Merge branch '4.x'
Nov 26, 2012
e590e1b
Merge branch '4.x'
Nov 27, 2012
4f91efa
Merge branch '4.x'
Nov 28, 2012
06bc5da
Merge branch '4.x'
Nov 28, 2012
bdef98d
Merge branch '4.x'
Nov 28, 2012
f960a08
Merge branch '4.x'
Nov 28, 2012
2dac135
Merge branch '4.x'
Nov 28, 2012
7742e5f
maint: style guideline fixes
Nov 30, 2012
5e3606f
Merge branch 'dalen-style_fixes'
Nov 30, 2012
3a6085f
Clarify that stdlib 3 supports Puppet 3
Dec 4, 2012
2df66c0
Merge branch 'maint/master/update_readme'
Dec 4, 2012
388cfa5
Merge branch '4.x'
Jan 3, 2013
d082046
(maint) Add Travis CI Support
Jan 5, 2013
9c97ab8
Merge branch 'feature/master/travis_ci'
Jan 5, 2013
cf261e2
Future proof travis build matrix
Jan 6, 2013
84f9ca2
Merge pull request #121 from jeffmccune/fix/master/travis
Jan 6, 2013
6d4ff99
Fix typo in travis configuration
Jan 6, 2013
2da85fa
Merge pull request #122 from jeffmccune/fix/master/travis
Jan 7, 2013
43a8cf5
Tell Travis CI to notify the PDC WebHook
Jan 7, 2013
dc04917
(maint) Update puppet version in Travis configuration
Jan 7, 2013
d674190
Merge pull request #123 from jeffmccune/feature/master/travis_webhook
Jan 10, 2013
20e0e07
Add getparam function to get defined resource parameters
offlinehacker Jan 2, 2013
3118e64
Merge branch 'offlinehacker-feature/master/getparam_function'
Jan 10, 2013
9dfc583
Ignore bundler turds
Jan 10, 2013
2a28ece
(maint) Fix getparam() spec failure on MRI 1.8
Jan 15, 2013
2559be9
Merge branch 'fix/master/getparam_failure'
Jan 15, 2013
b3fc0a3
Add geppetto project definition
DavidS Jan 14, 2013
562d325
Merge branch 'DavidS-master'
Jan 15, 2013
6902cc5
Add validate_cmd function
raphink Dec 6, 2012
f6a63ee
Merge branch 'raphink-validate_cmd'
Jan 18, 2013
bda25ac
validate_cmd: Make sure tmpfile is always closed and unlinked
raphink Jan 18, 2013
3a97c23
Add validate_augeas function
raphink Dec 6, 2012
41bc722
validate_augeas: Ensure augeas handler gets closed
raphink Jan 18, 2013
d568c4e
validate_augeas: Ensure tmpfile is closed and unlinked
raphink Jan 18, 2013
35f9a01
validate_augeas: requires augeas
raphink Jan 18, 2013
c5f0309
Add an URL to a doc on how to activate augeas in puppet
raphink Jan 20, 2013
4d24bd3
Merge branch 'raphink-validate_augeas'
Jan 23, 2013
5f22933
ammend .should raise_error to .to raise_error
Oct 16, 2012
8dd82d3
Merge branch 'stephenrjohnson-bug/master/15572_rspec_tests'
Feb 6, 2013
683ac8f
validate_cmd: Use Puppet::Util.execute
raphink Feb 5, 2013
69248df
validate_cmd(): Use Puppet::Util::Execution.execute when available
raphink Feb 7, 2013
3cef5d9
(#19201) Add concat function to join two arrays
Feb 12, 2013
15266d9
Merge branch 'fatmcgav-feature_19201'
Feb 12, 2013
36a7b29
Merge branch 'pull-126'
adrienthebo Feb 12, 2013
95cf3fe
(#19272) Add has_element() function
Feb 14, 2013
f7a1818
Merge pull request #130 from jhoblitt/has_element
Feb 15, 2013
a45d4f1
Revert "Merge pull request #130 from jhoblitt/has_element"
Feb 15, 2013
5b81c26
Merge branch '4.x'
Feb 18, 2013
9a06f11
Merge branch '4.x'
Feb 25, 2013
a1510a1
Add missing documentation for validate_augeas and validate_cmd to REA…
raphink Mar 4, 2013
d479df6
Merge pull request #132 from raphink/dev/missing_doc
adrienthebo Mar 4, 2013
96e19d0
Add contributing document
Mar 11, 2013
5a11279
Fix number of arguments check in flatten()
Oct 23, 2012
6dfd7f6
Merge branch '4.x'
adrienthebo Mar 18, 2013
961dcab
(#13610) Add is_function_available to stdlib
Apr 4, 2012
fc2352f
Merge branch 'pull-59'
adrienthebo Mar 18, 2013
0527341
Add floor function implementation and unit tests
willaerk Mar 19, 2013
893e610
Merge pull request #135 from willaerk/master
adrienthebo Mar 19, 2013
92e5960
(19864) Enable num2bool to accept numeric input
hakamadare Mar 22, 2013
88a93ac
add suffix function to accompany the prefix function
floatingatoll Mar 26, 2013
a83318d
prefix: fix doc typo Examles -> Examples
floatingatoll Mar 26, 2013
29402f3
(maint) better error reporting for prefix and suffix
adrienthebo Mar 27, 2013
f0db049
Merge branch 'pull-138'
adrienthebo Mar 27, 2013
4078a6f
Merge branch '4.x'
adrienthebo Mar 27, 2013
5f3e944
ignoring rspec fixtures directory
hakamadare Mar 29, 2013
fdadb96
ignoring rspec fixtures directory
hakamadare Mar 29, 2013
84d1e05
Merge branch 'master' of github.com:hakamadare/puppetlabs-stdlib
hakamadare Mar 29, 2013
ac6919d
(19864) Enable num2bool to accept numeric input
hakamadare Mar 22, 2013
41b07cd
Reworked number-handling logic
hakamadare Mar 29, 2013
73f91ae
Merge branch '19864_num2bool_match_fix' of github.com:hakamadare/pupp…
hakamadare Mar 29, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pkg/
.DS_Store
metadata.json
coverage/
spec/fixtures/
Gemfile.lock
.bundle/
vendor/bundle/
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>stdlib</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ bundler_args: --without development
script: "bundle exec rake spec SPEC_OPTS='--color --format documentation'"
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- ruby-head
env:
- PUPPET_VERSION=">= 3.0.0"
- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION=2.7.13
- PUPPET_VERSION=2.7.6
- PUPPET_VERSION=2.6.9
- PUPPET_GEM_VERSION=">= 3.0.0"
matrix:
allow_failures:
- rvm: 2.0.0
- rvm: ruby-head
include:
- rvm: 2.0.0
env: PUPPET_VERSION=">= 3.0.0"
- rvm: 1.9.3
env: PUPPET_VERSION=">= 3.0.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7"
notifications:
email: false
webhooks:
Expand Down
65 changes: 65 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# How to contribute

Third-party patches are essential for keeping stdlib great. We simply can't
access the huge number of platforms and myriad configurations for running
stdlib. We want to keep it as easy as possible to contribute changes that
get things working in your environment. There are a few guidelines that we
need contributors to follow so that we can have a chance of keeping on
top of things.

## Getting Started

* Make sure you have a [Redmine account](http://projects.puppetlabs.com)
* Make sure you have a [GitHub account](https://github.com/signup/free)
* Submit a ticket for your issue, assuming one does not already exist.
* Clearly describe the issue including steps to reproduce when it is a bug.
* Make sure you fill in the earliest version that you know has the issue.
* Fork the repository on GitHub

## Making Changes

* Create a topic branch from where you want to base your work.
* This is usually the master branch.
* Only target release branches if you are certain your fix must be on that
branch.
* To quickly create a topic branch based on master; `git branch
fix/master/my_contribution master` then checkout the new branch with `git
checkout fix/master/my_contribution`. Please avoid working directly on the
`master` branch.
* Make commits of logical units.
* Check for unnecessary whitespace with `git diff --check` before committing.
* Make sure your commit messages are in the proper format.

````
(#99999) Make the example in CONTRIBUTING imperative and concrete

Without this patch applied the example commit message in the CONTRIBUTING
document is not a concrete example. This is a problem because the
contributor is left to imagine what the commit message should look like
based on a description rather than an example. This patch fixes the
problem by making the example concrete and imperative.

The first line is a real life imperative statement with a ticket number
from our issue tracker. The body describes the behavior without the patch,
why this is a problem, and how the patch fixes the problem when applied.
````

* Make sure you have added the necessary tests for your changes.
* Run _all_ the tests to assure nothing else was accidentally broken.

## Submitting Changes

* Sign the [Contributor License Agreement](http://links.puppetlabs.com/cla).
* Push your changes to a topic branch in your fork of the repository.
* Submit a pull request to the repository in the puppetlabs organization.
* Update your Redmine ticket to mark that you have submitted code and are ready for it to be reviewed.
* Include a link to the pull request in the ticket

# Additional Resources

* [More information on contributing](http://links.puppetlabs.com/contribute-to-puppet)
* [Bug tracker (Redmine)](http://projects.puppetlabs.com)
* [Contributor License Agreement](http://links.puppetlabs.com/cla)
* [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
* #puppet-dev IRC channel on freenode.org
21 changes: 17 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
source "https://rubygems.org"

if puppetversion = ENV['PUPPET_VERSION']
gem 'puppet', puppetversion
group :development do
gem 'watchr'
end

group :development, :test do
gem 'rake'
gem 'rspec', "~> 2.11.0", :require => false
gem 'mocha', "~> 0.10.5", :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet'
gem 'puppet', :require => false
end
gem 'puppetlabs_spec_helper', '>= 0.1.0'

# vim:ft=ruby
114 changes: 112 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Puppet Labs Standard Library #

[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-stdlib.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-stdlib)

This module provides a "standard library" of resources for developing Puppet
Modules. This modules will include the following additions to Puppet

Expand Down Expand Up @@ -46,7 +48,7 @@ All stdlib releases in the 2.0 major version support Puppet 2.6 and Puppet 2.7.
## stdlib 3.x ##

The 3.0 major release of stdlib drops support for Puppet 2.6. Stdlib 3.x
supports Puppet 2.7.
supports Puppet 2 and Puppet 3.

# Functions #

Expand Down Expand Up @@ -94,6 +96,13 @@ separators then you should use the `chomp` function.
Requires a string or array of strings as input.


- *Type*: rvalue

concat
-----
Appends the contents of the second array onto the first array.


- *Type*: rvalue

defined_with_params
Expand Down Expand Up @@ -187,6 +196,20 @@ as a result.
Would return: ['a','b','c']


- *Type*: rvalue

floor
-----
Returns the largest integer less or equal to the argument.
Takes a single numeric value as an argument.

*Examples:*

floor('3.8')

Would return: '3'


- *Type*: rvalue

fqdn_rotate
Expand All @@ -207,6 +230,25 @@ Example:

- *Type*: rvalue

getparam
--------

Takes a resource reference and name of the parameter and returns
value of resource's parameter.

For example:

define example_resource($param) {
}

example_resource { "example_resource_instance":
param => "param_value"
}

getparam(Example_resource["example_resource_instance"], "param")

- *Type*: rvalue

getvar
------
Lookup a variable in a remote namespace.
Expand Down Expand Up @@ -437,7 +479,7 @@ prefix
------
This function applies a prefix to all elements in an array.

*Examles:*
*Examples:*

prefix(['a','b','c'], 'p')

Expand Down Expand Up @@ -617,6 +659,19 @@ every string inside an array.
Would result in: "aaa"


- *Type*: rvalue

suffix
------
This function applies a suffix to all elements in an array.

*Examples:*

suffix(['a','b','c'], 'p')

Will return: ['ap','bp','cp']


- *Type*: rvalue

swapcase
Expand Down Expand Up @@ -749,6 +804,38 @@ The following values will fail, causing compilation to abort:



- *Type*: statement

validate_augeas
--------------
Perform validation of a string using an Augeas lens
The first argument of this function should be a string to
test, and the second argument should be the name of the Augeas lens to use.
If Augeas fails to parse the string with the lens, the compilation will
abort with a parse error.

A third argument can be specified, listing paths which should
not be found in the file. The `$file` variable points to the location
of the temporary file being tested in the Augeas tree.

For example, if you want to make sure your passwd content never contains
a user `foo`, you could write:

validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])

Or if you wanted to ensure that no users used the '/bin/barsh' shell,
you could use:

validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']

If a fourth argument is specified, this will be the error message raised and
seen by the user.

A helpful error message can be returned like this:

validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')


- *Type*: statement

validate_bool
Expand All @@ -771,6 +858,29 @@ The following values will fail, causing compilation to abort:



- *Type*: statement


validate_cmd
-------------
Perform validation of a string with an external command.
The first argument of this function should be a string to
test, and the second argument should be a path to a test command
taking a file as last argument. If the command, launched against
a tempfile containing the passed string, returns a non-null value,
compilation will abort with a parse error.

If a third argument is specified, this will be the error message raised and
seen by the user.

A helpful error message can be returned like this:

Example:

validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')



- *Type*: statement

validate_hash
Expand Down
1 change: 0 additions & 1 deletion RELEASE_PROCESS.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@
* Build a new package with puppet-module or the rake build task if it exists
* Publish the new package to the forge
* Bonus points for an announcement to puppet-users.

2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/abs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Puppet::Parser::Functions
newfunction(:abs, :type => :rvalue, :doc => <<-EOS
Returns the absolute value of a number, for example -34.56 becomes
Returns the absolute value of a number, for example -34.56 becomes
34.56. Takes a single integer and float value as an argument.
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/chomp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Puppet::Parser::Functions
newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
Removes the record separator from the end of a string or an array of
Removes the record separator from the end of a string or an array of
strings, for example `hello\n` becomes `hello`.
Requires a single string or array as an input.
EOS
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/parser/functions/chop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

module Puppet::Parser::Functions
newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
Returns a new string with the last character removed. If the string ends
with `\r\n`, both characters are removed. Applying chop to an empty
string returns an empty string. If you wish to merely remove record
Returns a new string with the last character removed. If the string ends
with `\r\n`, both characters are removed. Applying chop to an empty
string returns an empty string. If you wish to merely remove record
separators then you should use the `chomp` function.
Requires a string or array of strings as input.
EOS
Expand Down
Loading