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 15 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: 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
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_ip_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Puppet::Parser::Functions
"given #{arguments.size} for 1")
end

begin
begin
ip = IPAddr.new(arguments[0])
rescue ArgumentError
return false
Expand Down
3 changes: 2 additions & 1 deletion lib/puppet/parser/functions/num2bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module Puppet::Parser::Functions
raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1

number = arguments[0]
# Since we're matching against a regex, coerce to String
number = arguments[0].to_s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to cast a number to a string and do a regex on it, but we already have the number. It would be better to check of arguments[0] is a number and if so do the logic on that number.


# Only numbers allowed ...
unless number.match(/^\-?\d+$/)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/parseyaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Puppet::Parser::Functions
newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS
This function accepts YAML as a string and converts it into the correct
This function accepts YAML as a string and converts it into the correct
Puppet structure.
EOS
) do |arguments|
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/parser/functions/squeeze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module Puppet::Parser::Functions
end

item = arguments[0]
squeezeval = arguments[1]
squeezeval = arguments[1]

if item.is_a?(Array) then
if item.is_a?(Array) then
if squeezeval then
item.collect { |i| i.squeeze(squeezeval) }
else
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/str2bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Puppet::Parser::Functions
newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS
This converts a string to a boolean. This attempt to convert strings that
This converts a string to a boolean. This attempt to convert strings that
contain things like: y, 1, t, true to 'true' and strings that contain things
like: 0, f, n, false, no to 'false'.
EOS
Expand Down
1 change: 0 additions & 1 deletion spec/monkey_patches/publicize_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ def publicize_methods(*methods)
self.class_eval { private(*saved_private_instance_methods) }
end
end

2 changes: 1 addition & 1 deletion spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
end

it "should rotate a string to give the same results for one host" do
scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
scope.function_fqdn_rotate(["abcdefg"]).should eql(scope.function_fqdn_rotate(["abcdefg"]))
end

Expand Down
24 changes: 22 additions & 2 deletions spec/unit/puppet/parser/functions/num2bool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,33 @@
lambda { scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError))
end

it "should return true if 1" do
it "should return true if passed string 1" do
result = scope.function_num2bool(["1"])
result.should(be_true)
end

it "should return false if 0" do
it "should return true if passed number 1" do
result = scope.function_num2bool([1])
result.should(be_true)
end

it "should return false if passed string 0" do
result = scope.function_num2bool(["0"])
result.should(be_false)
end

it "should return false if passed number 0" do
result = scope.function_num2bool([0])
result.should(be_false)
end

it "should return false if passed string -1" do
result = scope.function_num2bool(["-1"])
result.should(be_false)
end

it "should return false if passed number -1" do
result = scope.function_num2bool([-1])
result.should(be_false)
end
end
1 change: 0 additions & 1 deletion spec/unit/puppet/parser/functions/validate_hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@
end

end

1 change: 0 additions & 1 deletion spec/unit/puppet/parser/functions/validate_string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@
end
end
end