puppet 3.7.4-x64-mingw32 → 3.7.5-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +11 -6
  3. data/ext/build_defaults.yaml +2 -2
  4. data/ext/systemd/puppet.service +1 -0
  5. data/lib/hiera/puppet_function.rb +71 -0
  6. data/lib/puppet.rb +12 -0
  7. data/lib/puppet/application/device.rb +22 -5
  8. data/lib/puppet/daemon.rb +13 -4
  9. data/lib/puppet/defaults.rb +27 -4
  10. data/lib/puppet/environments.rb +1 -1
  11. data/lib/puppet/error.rb +4 -0
  12. data/lib/puppet/functions.rb +118 -65
  13. data/lib/puppet/functions/assert_type.rb +5 -5
  14. data/lib/puppet/functions/each.rb +12 -12
  15. data/lib/puppet/functions/epp.rb +3 -4
  16. data/lib/puppet/functions/filter.rb +12 -12
  17. data/lib/puppet/functions/hiera.rb +29 -0
  18. data/lib/puppet/functions/hiera_array.rb +34 -0
  19. data/lib/puppet/functions/hiera_hash.rb +36 -0
  20. data/lib/puppet/functions/hiera_include.rb +50 -0
  21. data/lib/puppet/functions/inline_epp.rb +2 -3
  22. data/lib/puppet/functions/map.rb +12 -12
  23. data/lib/puppet/functions/reduce.rb +6 -6
  24. data/lib/puppet/functions/scanf.rb +3 -3
  25. data/lib/puppet/functions/slice.rb +10 -9
  26. data/lib/puppet/functions/with.rb +3 -4
  27. data/lib/puppet/graph/simple_graph.rb +5 -5
  28. data/lib/puppet/metatype/manager.rb +1 -1
  29. data/lib/puppet/node/environment.rb +1 -1
  30. data/lib/puppet/parser/ast/arithmetic_operator.rb +1 -1
  31. data/lib/puppet/parser/ast/collexpr.rb +1 -1
  32. data/lib/puppet/parser/compiler.rb +3 -3
  33. data/lib/puppet/parser/functions/create_resources.rb +1 -9
  34. data/lib/puppet/parser/functions/defined.rb +1 -1
  35. data/lib/puppet/parser/functions/hiera.rb +20 -11
  36. data/lib/puppet/parser/functions/hiera_array.rb +23 -13
  37. data/lib/puppet/parser/functions/hiera_hash.rb +25 -15
  38. data/lib/puppet/parser/functions/hiera_include.rb +20 -9
  39. data/lib/puppet/parser/functions/lookup.rb +1 -1
  40. data/lib/puppet/parser/functions/realize.rb +1 -1
  41. data/lib/puppet/parser/functions/scanf.rb +21 -12
  42. data/lib/puppet/parser/parser_factory.rb +2 -2
  43. data/lib/puppet/parser/relationship.rb +1 -1
  44. data/lib/puppet/parser/scope.rb +34 -7
  45. data/lib/puppet/pops.rb +2 -0
  46. data/lib/puppet/pops/binder/lookup.rb +24 -7
  47. data/lib/puppet/pops/binder/producers.rb +2 -2
  48. data/lib/puppet/pops/evaluator/closure.rb +1 -1
  49. data/lib/puppet/pops/evaluator/evaluator_impl.rb +109 -17
  50. data/lib/puppet/pops/evaluator/puppet_proc.rb +69 -0
  51. data/lib/puppet/pops/evaluator/runtime3_converter.rb +175 -0
  52. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -128
  53. data/lib/puppet/pops/functions/dispatch.rb +21 -17
  54. data/lib/puppet/pops/functions/dispatcher.rb +3 -3
  55. data/lib/puppet/pops/functions/function.rb +46 -14
  56. data/lib/puppet/pops/issues.rb +2 -2
  57. data/lib/puppet/pops/model/model_label_provider.rb +1 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +2 -0
  59. data/lib/puppet/pops/parser/eparser.rb +732 -724
  60. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  61. data/lib/puppet/pops/parser/lexer2.rb +20 -22
  62. data/lib/puppet/pops/types/class_loader.rb +1 -1
  63. data/lib/puppet/pops/types/type_calculator.rb +104 -37
  64. data/lib/puppet/pops/types/type_factory.rb +1 -1
  65. data/lib/puppet/pops/types/types.rb +4 -1
  66. data/lib/puppet/pops/types/types_meta.rb +2 -2
  67. data/lib/puppet/pops/validation/checker4_0.rb +5 -3
  68. data/lib/puppet/provider/service/systemd.rb +1 -0
  69. data/lib/puppet/provider/yumrepo/inifile.rb +4 -1
  70. data/lib/puppet/resource.rb +3 -2
  71. data/lib/puppet/resource/catalog.rb +3 -2
  72. data/lib/puppet/resource/type.rb +1 -1
  73. data/lib/puppet/settings/environment_conf.rb +12 -4
  74. data/lib/puppet/type/package.rb +23 -13
  75. data/lib/puppet/util/autoload.rb +7 -7
  76. data/lib/puppet/util/errors.rb +4 -2
  77. data/lib/puppet/util/network_device/config.rb +5 -0
  78. data/lib/puppet/version.rb +1 -1
  79. data/lib/puppetx.rb +2 -2
  80. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee.rb +8 -0
  81. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee_ws.rb +8 -0
  82. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/metadata.json +9 -0
  83. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller.rb +5 -0
  84. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller_ws.rb +12 -0
  85. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/metadata.json +9 -0
  86. data/spec/integration/parser/environment_spec.rb +47 -0
  87. data/spec/integration/parser/future_compiler_spec.rb +11 -6
  88. data/spec/unit/application/device_spec.rb +52 -14
  89. data/spec/unit/daemon_spec.rb +0 -2
  90. data/spec/unit/environments_spec.rb +2 -2
  91. data/spec/unit/functions/assert_type_spec.rb +4 -25
  92. data/spec/unit/functions/hiera_spec.rb +127 -0
  93. data/spec/unit/functions/with_spec.rb +9 -4
  94. data/spec/unit/functions4_spec.rb +98 -35
  95. data/spec/unit/hiera/backend/puppet_backend_spec.rb +1 -1
  96. data/spec/unit/parser/functions/create_resources_spec.rb +2 -2
  97. data/spec/unit/parser/functions/defined_spec.rb +5 -0
  98. data/spec/unit/parser/functions/lookup_spec.rb +5 -1
  99. data/spec/unit/parser/functions/scanf_spec.rb +30 -0
  100. data/spec/unit/parser/scope_spec.rb +5 -0
  101. data/spec/unit/pops/binder/injector_spec.rb +1 -1
  102. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +33 -5
  103. data/spec/unit/pops/loaders/loaders_spec.rb +22 -1
  104. data/spec/unit/pops/parser/lexer2_spec.rb +28 -16
  105. data/spec/unit/pops/parser/parse_heredoc_spec.rb +21 -0
  106. data/spec/unit/pops/types/type_calculator_spec.rb +141 -19
  107. data/spec/unit/pops/types/type_factory_spec.rb +2 -2
  108. data/spec/unit/pops/validator/validator_spec.rb +25 -3
  109. data/spec/unit/provider/service/systemd_spec.rb +20 -4
  110. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  111. data/spec/unit/provider/yumrepo/inifile_spec.rb +1 -0
  112. data/spec/unit/settings/environment_conf_spec.rb +12 -1
  113. data/spec/unit/type/package_spec.rb +0 -20
  114. data/spec/unit/util/network_device/config_spec.rb +6 -0
  115. metadata +3422 -3419
@@ -30,14 +30,14 @@ Puppet::Functions.create_function(:assert_type) do
30
30
  # @param type [Type] the type the value must be an instance of
31
31
  # @param value [Object] the value to assert
32
32
  #
33
- def assert_type(type, value, block=nil)
33
+ def assert_type(type, value)
34
34
  unless Puppet::Pops::Types::TypeCalculator.instance?(type,value)
35
35
  inferred_type = Puppet::Pops::Types::TypeCalculator.infer(value)
36
- if block
36
+ if block_given?
37
37
  # Give the inferred type to allow richer comparisson in the given block (if generalized
38
38
  # information is lost).
39
39
  #
40
- value = block.call(nil, type, inferred_type)
40
+ value = yield(type, inferred_type)
41
41
  else
42
42
  # Do not give all the details - i.e. format as Integer, instead of Integer[n, n] for exact value, which
43
43
  # is just confusing. (OTOH: may need to revisit, or provide a better "type diff" output.
@@ -52,8 +52,8 @@ Puppet::Functions.create_function(:assert_type) do
52
52
  # @param type_string [String] the type the value must be an instance of given in String form
53
53
  # @param value [Object] the value to assert
54
54
  #
55
- def assert_type_s(type_string, value)
55
+ def assert_type_s(type_string, value, &proc)
56
56
  t = Puppet::Pops::Types::TypeParser.new.parse(type_string)
57
- assert_type(t, value)
57
+ block_given? ? assert_type(t, value, &proc) : assert_type(t, value)
58
58
  end
59
59
  end
@@ -41,58 +41,58 @@
41
41
  Puppet::Functions.create_function(:each) do
42
42
  dispatch :foreach_Hash_2 do
43
43
  param 'Hash[Any, Any]', :hash
44
- required_block_param 'Callable[2,2]', :block
44
+ block_param 'Callable[2,2]', :block
45
45
  end
46
46
 
47
47
  dispatch :foreach_Hash_1 do
48
48
  param 'Hash[Any, Any]', :hash
49
- required_block_param 'Callable[1,1]', :block
49
+ block_param 'Callable[1,1]', :block
50
50
  end
51
51
 
52
52
  dispatch :foreach_Enumerable_2 do
53
53
  param 'Any', :enumerable
54
- required_block_param 'Callable[2,2]', :block
54
+ block_param 'Callable[2,2]', :block
55
55
  end
56
56
 
57
57
  dispatch :foreach_Enumerable_1 do
58
58
  param 'Any', :enumerable
59
- required_block_param 'Callable[1,1]', :block
59
+ block_param 'Callable[1,1]', :block
60
60
  end
61
61
 
62
- def foreach_Hash_1(hash, pblock)
62
+ def foreach_Hash_1(hash)
63
63
  enumerator = hash.each_pair
64
64
  hash.size.times do
65
- pblock.call(nil, enumerator.next)
65
+ yield(enumerator.next)
66
66
  end
67
67
  # produces the receiver
68
68
  hash
69
69
  end
70
70
 
71
- def foreach_Hash_2(hash, pblock)
71
+ def foreach_Hash_2(hash)
72
72
  enumerator = hash.each_pair
73
73
  hash.size.times do
74
- pblock.call(nil, *enumerator.next)
74
+ yield(*enumerator.next)
75
75
  end
76
76
  # produces the receiver
77
77
  hash
78
78
  end
79
79
 
80
- def foreach_Enumerable_1(enumerable, pblock)
80
+ def foreach_Enumerable_1(enumerable)
81
81
  enum = asserted_enumerable(enumerable)
82
82
  begin
83
- loop { pblock.call(nil, enum.next) }
83
+ loop { yield(enum.next) }
84
84
  rescue StopIteration
85
85
  end
86
86
  # produces the receiver
87
87
  enumerable
88
88
  end
89
89
 
90
- def foreach_Enumerable_2(enumerable, pblock)
90
+ def foreach_Enumerable_2(enumerable)
91
91
  enum = asserted_enumerable(enumerable)
92
92
  index = 0
93
93
  begin
94
94
  loop do
95
- pblock.call(nil, index, enum.next)
95
+ yield(index, enum.next)
96
96
  index += 1
97
97
  end
98
98
  rescue StopIteration
@@ -42,10 +42,9 @@
42
42
  Puppet::Functions.create_function(:epp, Puppet::Functions::InternalFunction) do
43
43
 
44
44
  dispatch :epp do
45
- scope_param()
46
- param 'String', 'path'
47
- param 'Hash[Pattern[/^\w+$/], Any]', 'parameters'
48
- arg_count(1, 2)
45
+ scope_param
46
+ param 'String', :path
47
+ optional_param 'Hash[Pattern[/^\w+$/], Any]', :parameters
49
48
  end
50
49
 
51
50
  def epp(scope, path, parameters = nil)
@@ -38,46 +38,46 @@
38
38
  Puppet::Functions.create_function(:filter) do
39
39
  dispatch :filter_Hash_2 do
40
40
  param 'Hash[Any, Any]', :hash
41
- required_block_param 'Callable[2,2]', :block
41
+ block_param 'Callable[2,2]', :block
42
42
  end
43
43
 
44
44
  dispatch :filter_Hash_1 do
45
45
  param 'Hash[Any, Any]', :hash
46
- required_block_param 'Callable[1,1]', :block
46
+ block_param 'Callable[1,1]', :block
47
47
  end
48
48
 
49
49
  dispatch :filter_Enumerable_2 do
50
50
  param 'Any', :enumerable
51
- required_block_param 'Callable[2,2]', :block
51
+ block_param 'Callable[2,2]', :block
52
52
  end
53
53
 
54
54
  dispatch :filter_Enumerable_1 do
55
55
  param 'Any', :enumerable
56
- required_block_param 'Callable[1,1]', :block
56
+ block_param 'Callable[1,1]', :block
57
57
  end
58
58
 
59
- def filter_Hash_1(hash, pblock)
60
- result = hash.select {|x, y| pblock.call(self, [x, y]) }
59
+ def filter_Hash_1(hash)
60
+ result = hash.select {|x, y| yield([x, y]) }
61
61
  # Ruby 1.8.7 returns Array
62
62
  result = Hash[result] unless result.is_a? Hash
63
63
  result
64
64
  end
65
65
 
66
- def filter_Hash_2(hash, pblock)
67
- result = hash.select {|x, y| pblock.call(self, x, y) }
66
+ def filter_Hash_2(hash)
67
+ result = hash.select {|x, y| yield(x, y) }
68
68
  # Ruby 1.8.7 returns Array
69
69
  result = Hash[result] unless result.is_a? Hash
70
70
  result
71
71
  end
72
72
 
73
- def filter_Enumerable_1(enumerable, pblock)
73
+ def filter_Enumerable_1(enumerable)
74
74
  result = []
75
75
  index = 0
76
76
  enum = asserted_enumerable(enumerable)
77
77
  begin
78
78
  loop do
79
79
  it = enum.next
80
- if pblock.call(nil, it) == true
80
+ if yield(it) == true
81
81
  result << it
82
82
  end
83
83
  end
@@ -86,14 +86,14 @@ Puppet::Functions.create_function(:filter) do
86
86
  result
87
87
  end
88
88
 
89
- def filter_Enumerable_2(enumerable, pblock)
89
+ def filter_Enumerable_2(enumerable)
90
90
  result = []
91
91
  index = 0
92
92
  enum = asserted_enumerable(enumerable)
93
93
  begin
94
94
  loop do
95
95
  it = enum.next
96
- if pblock.call(nil, index, it) == true
96
+ if yield(index, it) == true
97
97
  result << it
98
98
  end
99
99
  index += 1
@@ -0,0 +1,29 @@
1
+ require 'hiera/puppet_function'
2
+
3
+ # Performs a standard priority lookup and returns the most specific value for a given key.
4
+ # The returned value can be data of any type (strings, arrays, or hashes).
5
+ #
6
+ # The function can be called in one of three ways:
7
+ # 1. Using 1 to 3 arguments where the arguments are:
8
+ # 'key' [String] Required
9
+ # The key to lookup.
10
+ # 'default` [Any] Optional
11
+ # A value to return when there's no match for `key`. Optional
12
+ # `override` [Any] Optional
13
+ # An argument in the third position, providing a data source
14
+ # to consult for matching values, even if it would not ordinarily be
15
+ # part of the matched hierarchy. If Hiera doesn't find a matching key
16
+ # in the named override data source, it will continue to search through the
17
+ # rest of the hierarchy.
18
+ #
19
+ # 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
20
+ # provide the default value. The block is called with one parameter (the key) and
21
+ # should return the value.
22
+ #
23
+ # 3. Like #1 but with all arguments passed in an array.
24
+ #
25
+ # More thorough examples of `hiera` are available at:
26
+ # <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
27
+ Puppet::Functions.create_function(:hiera, Hiera::PuppetFunction) do
28
+ init_dispatch
29
+ end
@@ -0,0 +1,34 @@
1
+ require 'hiera/puppet_function'
2
+
3
+ # Returns all matches throughout the hierarchy --- not just the first match --- as a flattened array of unique values.
4
+ # If any of the matched values are arrays, they're flattened and included in the results.
5
+ #
6
+ # The function can be called in one of three ways:
7
+ # 1. Using 1 to 3 arguments where the arguments are:
8
+ # 'key' [String] Required
9
+ # The key to lookup.
10
+ # 'default` [Any] Optional
11
+ # A value to return when there's no match for `key`. Optional
12
+ # `override` [Any] Optional
13
+ # An argument in the third position, providing a data source
14
+ # to consult for matching values, even if it would not ordinarily be
15
+ # part of the matched hierarchy. If Hiera doesn't find a matching key
16
+ # in the named override data source, it will continue to search through the
17
+ # rest of the hierarchy.
18
+ #
19
+ # 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
20
+ # provide the default value. The block is called with one parameter (the key) and
21
+ # should return the value.
22
+ #
23
+ # 3. Like #1 but with all arguments passed in an array.
24
+ # If any matched value is a hash, puppet will raise a type mismatch error.
25
+ #
26
+ # More thorough examples of `hiera` are available at:
27
+ # <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
28
+ Puppet::Functions.create_function(:hiera_array, Hiera::PuppetFunction) do
29
+ init_dispatch
30
+
31
+ def merge_type
32
+ :array
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ require 'hiera/puppet_function'
2
+
3
+ # Returns a merged hash of matches from throughout the hierarchy. In cases where two or
4
+ # more hashes share keys, the hierarchy order determines which key/value pair will be
5
+ # used in the returned hash, with the pair in the highest priority data source winning.
6
+ #
7
+ # The function can be called in one of three ways:
8
+ # 1. Using 1 to 3 arguments where the arguments are:
9
+ # 'key' [String] Required
10
+ # The key to lookup.
11
+ # 'default` [Any] Optional
12
+ # A value to return when there's no match for `key`. Optional
13
+ # `override` [Any] Optional
14
+ # An argument in the third position, providing a data source
15
+ # to consult for matching values, even if it would not ordinarily be
16
+ # part of the matched hierarchy. If Hiera doesn't find a matching key
17
+ # in the named override data source, it will continue to search through the
18
+ # rest of the hierarchy.
19
+ #
20
+ # 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
21
+ # provide the default value. The block is called with one parameter (the key) and
22
+ # should return the value.
23
+ #
24
+ # 3. Like #1 but with all arguments passed in an array.
25
+ # `hiera_hash` expects that all values returned will be hashes. If any of the values
26
+ # found in the data sources are strings or arrays, puppet will raise a type mismatch error.
27
+ #
28
+ # More thorough examples of `hiera_hash` are available at:
29
+ # <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
30
+ Puppet::Functions.create_function(:hiera_hash, Hiera::PuppetFunction) do
31
+ init_dispatch
32
+
33
+ def merge_type
34
+ :hash
35
+ end
36
+ end
@@ -0,0 +1,50 @@
1
+ require 'hiera_puppet'
2
+
3
+ # Assigns classes to a node using an array merge lookup that retrieves the value for a user-specified key
4
+ # from a Hiera data source.
5
+ #
6
+ # To use `hiera_include`, the following configuration is required:
7
+ # - A key name to use for classes, e.g. `classes`.
8
+ # - A line in the puppet `sites.pp` file (e.g. `/etc/puppet/manifests/sites.pp`)
9
+ # reading `hiera_include('classes')`. Note that this line must be outside any node
10
+ # definition and below any top-scope variables in use for Hiera lookups.
11
+ # - Class keys in the appropriate data sources. In a data source keyed to a node's role,
12
+ # one might have:
13
+ #
14
+ # ---
15
+ # classes:
16
+ # - apache
17
+ # - apache::passenger
18
+ # The function can be called in one of three ways:
19
+ # 1. Using 1 to 3 arguments where the arguments are:
20
+ # 'key' [String] Required
21
+ # The key to lookup.
22
+ # 'default` [Any] Optional
23
+ # A value to return when there's no match for `key`. Optional
24
+ # `override` [Any] Optional
25
+ # An argument in the third position, providing a data source
26
+ # to consult for matching values, even if it would not ordinarily be
27
+ # part of the matched hierarchy. If Hiera doesn't find a matching key
28
+ # in the named override data source, it will continue to search through the
29
+ # rest of the hierarchy.
30
+ #
31
+ # 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
32
+ # provide the default value. The block is called with one parameter (the key) and
33
+ # should return the array to be used in the subsequent call to include.
34
+ #
35
+ # 3. Like #1 but with all arguments passed in an array.
36
+ #
37
+ # More thorough examples of `hiera_include` are available at:
38
+ # <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
39
+ Puppet::Functions.create_function(:hiera_include, Hiera::PuppetFunction) do
40
+ init_dispatch
41
+
42
+ def merge_type
43
+ :array
44
+ end
45
+
46
+ def post_lookup(key, value)
47
+ raise Puppet::ParseError, "Could not find data item #{key}" if value.nil?
48
+ call_function('include', value) unless value.empty?
49
+ end
50
+ end
@@ -77,9 +77,8 @@ Puppet::Functions.create_function(:inline_epp, Puppet::Functions::InternalFuncti
77
77
 
78
78
  dispatch :inline_epp do
79
79
  scope_param()
80
- param 'String', 'template'
81
- param 'Hash[Pattern[/^\w+$/], Any]', 'parameters'
82
- arg_count(1, 2)
80
+ param 'String', :template
81
+ optional_param 'Hash[Pattern[/^\w+$/], Any]', :parameters
83
82
  end
84
83
 
85
84
  def inline_epp(scope, template, parameters = nil)
@@ -36,50 +36,50 @@
36
36
  Puppet::Functions.create_function(:map) do
37
37
  dispatch :map_Hash_2 do
38
38
  param 'Hash[Any, Any]', :hash
39
- required_block_param 'Callable[2,2]', :block
39
+ block_param 'Callable[2,2]', :block
40
40
  end
41
41
 
42
42
  dispatch :map_Hash_1 do
43
43
  param 'Hash[Any, Any]', :hash
44
- required_block_param 'Callable[1,1]', :block
44
+ block_param 'Callable[1,1]', :block
45
45
  end
46
46
 
47
47
  dispatch :map_Enumerable_2 do
48
48
  param 'Any', :enumerable
49
- required_block_param 'Callable[2,2]', :block
49
+ block_param 'Callable[2,2]', :block
50
50
  end
51
51
 
52
52
  dispatch :map_Enumerable_1 do
53
53
  param 'Any', :enumerable
54
- required_block_param 'Callable[1,1]', :block
54
+ block_param 'Callable[1,1]', :block
55
55
  end
56
56
 
57
- def map_Hash_1(hash, pblock)
58
- hash.map {|x, y| pblock.call(nil, [x, y]) }
57
+ def map_Hash_1(hash)
58
+ hash.map {|x, y| yield([x, y]) }
59
59
  end
60
60
 
61
- def map_Hash_2(hash, pblock)
62
- hash.map {|x, y| pblock.call(nil, x, y) }
61
+ def map_Hash_2(hash)
62
+ hash.map {|x, y| yield(x, y) }
63
63
  end
64
64
 
65
- def map_Enumerable_1(enumerable, pblock)
65
+ def map_Enumerable_1(enumerable)
66
66
  result = []
67
67
  index = 0
68
68
  enum = asserted_enumerable(enumerable)
69
69
  begin
70
- loop { result << pblock.call(nil, enum.next) }
70
+ loop { result << yield(enum.next) }
71
71
  rescue StopIteration
72
72
  end
73
73
  result
74
74
  end
75
75
 
76
- def map_Enumerable_2(enumerable, pblock)
76
+ def map_Enumerable_2(enumerable)
77
77
  result = []
78
78
  index = 0
79
79
  enum = asserted_enumerable(enumerable)
80
80
  begin
81
81
  loop do
82
- result << pblock.call(nil, index, enum.next)
82
+ result << yield(index, enum.next)
83
83
  index = index +1
84
84
  end
85
85
  rescue StopIteration
@@ -65,23 +65,23 @@ Puppet::Functions.create_function(:reduce) do
65
65
 
66
66
  dispatch :reduce_without_memo do
67
67
  param 'Any', :enumerable
68
- required_block_param 'Callable[2,2]', :block
68
+ block_param 'Callable[2,2]', :block
69
69
  end
70
70
 
71
71
  dispatch :reduce_with_memo do
72
72
  param 'Any', :enumerable
73
73
  param 'Any', :memo
74
- required_block_param 'Callable[2,2]', :block
74
+ block_param 'Callable[2,2]', :block
75
75
  end
76
76
 
77
- def reduce_without_memo(enumerable, pblock)
77
+ def reduce_without_memo(enumerable)
78
78
  enum = asserted_enumerable(enumerable)
79
- enum.reduce {|memo, x| pblock.call(nil, memo, x) }
79
+ enum.reduce {|memo, x| yield(memo, x) }
80
80
  end
81
81
 
82
- def reduce_with_memo(enumerable, given_memo, pblock)
82
+ def reduce_with_memo(enumerable, given_memo)
83
83
  enum = asserted_enumerable(enumerable)
84
- enum.reduce(given_memo) {|memo, x| pblock.call(nil, memo, x) }
84
+ enum.reduce(given_memo) {|memo, x| yield(memo, x) }
85
85
  end
86
86
 
87
87
  def asserted_enumerable(obj)