Skip to content

Commit 25a2af2

Browse files
committed
(MODULES-1882, IAC-114) move all function implementations to puppet4 API
* move all functions to `stdlib::` prefix * fix internal function calls * adjust test suite to test the correct functions * adjust test suite to use puppet4 semantics * reinstate deprecated functions in their original form - we don't want to rock that boat more than necessary * un-deprecate `is_function_available` as there is no comparable function elsewhere * properly deprecate `upcase`, `values` as they are real puppet6 functions TODO: * add backwards compatible shims for everything that moved to the `stdlib::` prefix. This can be used LATER to add a deprecation warning * fix the documentation on all migrated functions * add deprecation warnings for anything "weird": ** convert manual type-checking to type annotations ** deprecate non-plain types ** unused varargs (lots of functions allow infinite args, but will only use the first few) ** remove manual arg-length checking ** remove unused `require`s
1 parent f1ef935 commit 25a2af2

File tree

417 files changed

+3000
-16592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+3000
-16592
lines changed

lib/puppet/functions/is_absolute_path.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_absolute_path) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_array.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_array) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_bool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_bool) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_float.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_float) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_ip_address.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_ip_address) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_ipv4_address.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_ipv4_address) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_ipv6_address.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_ipv6_address) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_numeric.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_numeric) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/is_string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @summary
2-
# Wrapper that calls the Puppet 3.x funtion of the same name.
2+
# Wrapper that calls the Puppet 3.x function of the same name.
33
Puppet::Functions.create_function(:is_string) do
44
# @param scope
55
# The main value that will be passed to the wrapped method

lib/puppet/functions/stdlib/abs.rb

Lines changed: 0 additions & 64 deletions
This file was deleted.

lib/puppet/functions/stdlib/any2bool.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ def default_impl(*arguments)
6868
end
6969

7070
if arg.is_a?(Numeric)
71-
return function_num2bool([arguments[0]])
71+
return call_function('stdlib::num2bool', arguments[0])
7272
end
7373

7474
if arg.is_a?(String)
75-
return function_num2bool([arguments[0]]) if valid_float
76-
return function_str2bool([arguments[0]])
75+
return call_function('stdlib::num2bool', arguments[0]) if valid_float
76+
return call_function('stdlib::str2bool', arguments[0])
7777
end
7878

7979
true

lib/puppet/functions/stdlib/assert_private.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838
def default_impl(*args)
3939
raise(Puppet::ParseError, "assert_private(): Wrong number of arguments given (#{args.size}}) for 0 or 1)") if args.size > 1
4040

41-
scope = self
42-
return unless scope.lookupvar('module_name') != scope.lookupvar('caller_module_name')
41+
return unless closure_scope['module_name'] != closure_scope['caller_module_name']
4342

4443
message = nil
4544
if args[0] && args[0].is_a?(String)
4645
message = args[0]
4746
else
48-
manifest_name = scope.source.name
49-
manifest_type = scope.source.type
47+
manifest_name = closure_scope.source.name
48+
manifest_type = closure_scope.source.type
5049
message = (manifest_type.to_s == 'hostclass') ? 'Class' : 'Definition'
5150
message += " #{manifest_name} is private"
5251
end

lib/puppet/functions/stdlib/bool2num.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
def default_impl(*arguments)
5555
raise(Puppet::ParseError, "bool2num(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
5656

57-
value = function_str2bool([arguments[0]])
57+
value = call_function('stdlib::str2bool', *arguments)
5858

5959
# We have real boolean values as well ...
6060
result = value ? 1 : 0

lib/puppet/functions/stdlib/camelcase.rb

Lines changed: 0 additions & 61 deletions
This file was deleted.

lib/puppet/functions/stdlib/capitalize.rb

Lines changed: 0 additions & 62 deletions
This file was deleted.

lib/puppet/functions/stdlib/ceiling.rb

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)