Skip to content

Commit f20d495

Browse files
committed
deprecate empty()
1 parent a90b5ad commit f20d495

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,8 @@ Converts the case of a string or of all strings in an array to lowercase.
11631163

11641164
#### `empty`
11651165

1166+
**Deprecated. Puppet 5.5.0 has introduced an inbuilt `empty` function, that will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1167+
11661168
Returns `true` if the argument is an array or hash that contains no elements, or an empty string. Returns `false` when the argument is a numerical value.
11671169

11681170
*Type*: rvalue.

lib/puppet/parser/functions/empty.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module Puppet::Parser::Functions
77
DOC
88
) do |arguments|
99

10+
function_deprecation([:empty, 'This method is deprecated, this function is now shipped in puppet in versions 5.5.0 and later.
11+
For more information please see [puppet 5.5.0 release notes|https://puppet.com/docs/puppet/5.5/release_notes.html#new-features].'])
12+
1013
raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
1114
value = arguments[0]
1215

spec/functions/empty_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe 'empty' do
44
it { is_expected.not_to eq(nil) }
5-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
66
it {
77
pending('Current implementation ignores parameters after the first.')
88
is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError)

0 commit comments

Comments
 (0)