|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -# @summary |
4 | | -# Generates a random alphanumeric string. Combining the `$fqdn` fact and an |
5 | | -# optional seed for repeatable randomness. |
6 | | -# |
7 | | -# Optionally, you can specify a character set for the function (defaults to alphanumeric). |
| 3 | +# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims` |
| 4 | + |
| 5 | +# @summary DEPRECATED. Use the namespaced function [`stdlib::fqdn_rand_string`](#stdlibfqdn_rand_string) instead. |
8 | 6 | Puppet::Functions.create_function(:fqdn_rand_string) do |
9 | | - # @param length The length of the resulting string. |
10 | | - # @param charset The character set to use. |
11 | | - # @param The seed for repeatable randomness. |
12 | | - # |
13 | | - # @return [String] |
14 | | - # |
15 | | - # @example Example Usage: |
16 | | - # fqdn_rand_string(10) |
17 | | - # fqdn_rand_string(10, 'ABCDEF!@$%^') |
18 | | - # fqdn_rand_string(10, '', 'custom seed') |
19 | | - dispatch :fqdn_rand_string do |
20 | | - param 'Integer[1]', :length |
21 | | - optional_param 'String', :charset |
22 | | - optional_repeated_param 'Any', :seed |
| 7 | + dispatch :deprecation_gen do |
| 8 | + repeated_param 'Any', :args |
23 | 9 | end |
24 | | - |
25 | | - def fqdn_rand_string(length, charset = '', *seed) |
26 | | - charset = charset.chars.to_a |
27 | | - |
28 | | - charset = (0..9).map(&:to_s) + ('A'..'Z').to_a + ('a'..'z').to_a if charset.empty? |
29 | | - |
30 | | - rand_string = '' |
31 | | - length.times do |current| |
32 | | - rand_string += charset[call_function('fqdn_rand', charset.size, (seed + [current + 1]).join(':'))] |
33 | | - end |
34 | | - |
35 | | - rand_string |
| 10 | + def deprecation_gen(*args) |
| 11 | + call_function('deprecation', 'fqdn_rand_string', 'This function is deprecated, please use stdlib::fqdn_rand_string instead.') |
| 12 | + call_function('stdlib::fqdn_rand_string', *args) |
36 | 13 | end |
37 | 14 | end |
0 commit comments