Update puppetlabs/stdlib module
authorAurelien Jarno <aurelien@aurel32.net>
Sun, 31 Mar 2019 22:05:19 +0000 (00:05 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Sun, 31 Mar 2019 22:05:40 +0000 (00:05 +0200)
488 files changed:
3rdparty/Puppetfile
3rdparty/modules/stdlib/CHANGELOG.md
3rdparty/modules/stdlib/CONTRIBUTING.md
3rdparty/modules/stdlib/Gemfile
3rdparty/modules/stdlib/README.md
3rdparty/modules/stdlib/Rakefile
3rdparty/modules/stdlib/appveyor.yml
3rdparty/modules/stdlib/checksums.json
3rdparty/modules/stdlib/lib/facter/facter_dot_d.rb
3rdparty/modules/stdlib/lib/facter/package_provider.rb
3rdparty/modules/stdlib/lib/facter/pe_version.rb
3rdparty/modules/stdlib/lib/facter/puppet_settings.rb
3rdparty/modules/stdlib/lib/facter/root_home.rb
3rdparty/modules/stdlib/lib/facter/util/puppet_settings.rb
3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb
3rdparty/modules/stdlib/lib/puppet/functions/fact.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb
3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb
3rdparty/modules/stdlib/lib/puppet/functions/length.rb
3rdparty/modules/stdlib/lib/puppet/functions/type_of.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/abs.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/assert_private.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/basename.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2num.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2str.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/camelcase.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/capitalize.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/ceiling.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/chomp.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/chop.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/clamp.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/concat.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/count.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/delete.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_at.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_regex.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/deprecation.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/difference.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/dirname.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/downcase.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/empty.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/flatten.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/floor.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_uuid.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/getparam.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/grep.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/has_key.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/hash.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/intersection.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_array.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_bool.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_float.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_hash.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_integer.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_string.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/join.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/keys.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/lstrip.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/max.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/merge.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/min.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/parsejson.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/pick.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/pick_default.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/prefix.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/private.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/range.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/regexpescape.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/reject.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/reverse.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/rstrip.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/shuffle.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/squeeze.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/str2bool.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/strftime.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/suffix.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/swapcase.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/time.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/type.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/union.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/unique.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/upcase.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/uriescape.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_array.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_domain_name.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_re.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_string.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/values.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/zip.rb
3rdparty/modules/stdlib/lib/puppet/provider/file_line/ruby.rb
3rdparty/modules/stdlib/lib/puppet/type/anchor.rb
3rdparty/modules/stdlib/lib/puppet/type/file_line.rb
3rdparty/modules/stdlib/locales/config.yaml
3rdparty/modules/stdlib/metadata.json
3rdparty/modules/stdlib/readmes/README_ja_JP.md
3rdparty/modules/stdlib/spec/acceptance/abs_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/any2array_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/base64_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/build_csv.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/capitalize_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/ceiling_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/chomp_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/chop_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/concat_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/count_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/deep_merge_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/defined_with_params_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/delete_at_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/delete_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/delete_values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb
3rdparty/modules/stdlib/spec/acceptance/difference_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/dirname_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/downcase_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/empty_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/ensure_resource_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/flatten_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/floor_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb
3rdparty/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/get_module_path_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/getparam_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/getvar_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/grep_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/has_interface_with_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/has_ip_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/has_ip_network_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/has_key_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/hash_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/intersection_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_array_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_domain_name_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_float_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_function_available_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_hash_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_integer_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_ip_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_mac_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_numeric_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/is_string_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/join_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/keys_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb
3rdparty/modules/stdlib/spec/acceptance/loadyaml_spec.rb
3rdparty/modules/stdlib/spec/acceptance/lstrip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/max_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/member_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/merge_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/min_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/num2bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/parsejson_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/parseyaml_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/pick_default_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/pick_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/prefix_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/pw_hash_spec.rb
3rdparty/modules/stdlib/spec/acceptance/range_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/reject_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/reverse_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/rstrip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/shuffle_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/size_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/sort_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/squeeze_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/str2bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/strftime_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/strip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/suffix_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/swapcase_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/time_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/to_bytes_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/type_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/union_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/unique_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/upcase_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/uriescape_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_array_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_augeas_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_cmd_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_hash_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_re_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_slength_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/validate_string_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/values_at_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/acceptance/zip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/aliases/absolute_path_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/absolutepath_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/array_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/bool_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/float_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/hash_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/httpsurl_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/httpurl_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/integer_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/ip_address.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/ipv4_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/ipv6_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/numeric_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/string_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/unixpath_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/aliases/windowspath_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolute_path.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolutepath.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/array.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/bool.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/deftype.pp
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ensure_resources.pp
3rdparty/modules/stdlib/spec/fixtures/test/manifests/float.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/hash.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpsurl.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpurl.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/integer.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ip_address.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv4.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv6.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/numeric.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/string.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/unixpath.pp [deleted file]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/windowspath.pp [deleted file]
3rdparty/modules/stdlib/spec/functions/abs_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/any2array_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/any2bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/assert_private_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/base64_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/basename_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/bool2str_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/camelcase_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/capitalize_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/ceiling_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/chomp_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/chop_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/clamp_spec.rb
3rdparty/modules/stdlib/spec/functions/concat_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/convert_base_spec.rb
3rdparty/modules/stdlib/spec/functions/count_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/deep_merge_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/defined_with_params_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/delete_at_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/delete_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/delete_undef_values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/delete_values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/deprecation_spec.rb
3rdparty/modules/stdlib/spec/functions/difference_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/dig44_spec.rb
3rdparty/modules/stdlib/spec/functions/dig_spec.rb
3rdparty/modules/stdlib/spec/functions/dirname_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb
3rdparty/modules/stdlib/spec/functions/downcase_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/empty_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/ensure_packages_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/ensure_resource_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/ensure_resources_spec.rb
3rdparty/modules/stdlib/spec/functions/flatten_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/floor_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb
3rdparty/modules/stdlib/spec/functions/fqdn_rotate_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb
3rdparty/modules/stdlib/spec/functions/get_module_path_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/getparam_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/getvar_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/glob_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/grep_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/has_interface_with_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/has_ip_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/has_ip_network_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/has_key_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/hash_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/intersection_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_a_spec.rb
3rdparty/modules/stdlib/spec/functions/is_array_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_domain_name_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_email_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_float_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_function_available.rb [deleted file]
3rdparty/modules/stdlib/spec/functions/is_hash_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_integer_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_ip_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_ipv4_address_spec.rb
3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb
3rdparty/modules/stdlib/spec/functions/is_mac_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_numeric_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/is_string_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/join_keys_to_values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/join_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/keys_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/length.rb [deleted file]
3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb
3rdparty/modules/stdlib/spec/functions/loadyaml_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/lstrip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/max_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/member_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/merge_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/min_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/num2bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/parsejson_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/parseyaml_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/pick_default_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/pick_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/prefix_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/private_spec.rb
3rdparty/modules/stdlib/spec/functions/pw_hash_spec.rb
3rdparty/modules/stdlib/spec/functions/range_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/regexpescape_spec.rb
3rdparty/modules/stdlib/spec/functions/reject_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/reverse_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/round_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/rstrip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/seeded_rand_spec.rb
3rdparty/modules/stdlib/spec/functions/shell_escape_spec.rb
3rdparty/modules/stdlib/spec/functions/shell_join_spec.rb
3rdparty/modules/stdlib/spec/functions/shell_split_spec.rb
3rdparty/modules/stdlib/spec/functions/shuffle_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/size_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/sort_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/squeeze_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/str2bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/str2saltedsha512_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/strftime_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/strip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/suffix_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/swapcase_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/time_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/to_bytes_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb
3rdparty/modules/stdlib/spec/functions/type3x_spec.rb
3rdparty/modules/stdlib/spec/functions/type_of_spec.rb
3rdparty/modules/stdlib/spec/functions/type_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/union_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/unique_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/unix2dos_spec.rb
3rdparty/modules/stdlib/spec/functions/upcase_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/uriescape_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_absolute_path_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_array_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_augeas_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_bool_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_cmd_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_domain_name_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_email_address_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_hash_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_integer_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_ip_address_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_legacy_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_numeric_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_re_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_slength_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_string_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/values_at_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/values_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/functions/zip_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/monkey_patches/publicize_methods.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/spec_helper.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/spec_helper_local.rb
3rdparty/modules/stdlib/spec/support/shared_data.rb
3rdparty/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/unit/facter/package_provider_spec.rb
3rdparty/modules/stdlib/spec/unit/facter/pe_version_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/unit/facter/root_home_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/unit/facter/service_provider_spec.rb
3rdparty/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb
3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb
3rdparty/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb [changed mode: 0755->0644]
3rdparty/modules/stdlib/types/compat/absolute_path.pp
3rdparty/modules/stdlib/types/compat/integer.pp
3rdparty/modules/stdlib/types/compat/ipv4.pp
3rdparty/modules/stdlib/types/compat/ipv6.pp
3rdparty/modules/stdlib/types/compat/numeric.pp
3rdparty/modules/stdlib/types/httpsurl.pp
3rdparty/modules/stdlib/types/httpurl.pp
3rdparty/modules/stdlib/types/mac.pp
3rdparty/modules/stdlib/types/unixpath.pp

index e896bbc..f234126 100644 (file)
@@ -1,6 +1,6 @@
 forge "http://forge.puppetlabs.com"
 
-mod 'puppetlabs/stdlib', '4.19.0'
+mod 'puppetlabs/stdlib', '5.2.0'
 mod 'puppetlabs/concat', '4.0.1'
 mod 'puppetlabs-postgresql', '5.1.0'
 
index f021e64..5842991 100644 (file)
@@ -3,6 +3,272 @@
 All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
 and this project adheres to [Semantic Versioning](http://semver.org).
 
+## Supported Release 5.2.0
+### Summary
+This is a moderate release made in order to roll up various new features.
+
+#### Fixed
+- `ensure-packages()` duplicate checking now works as it should.
+
+#### Added
+- (MODULES-7024) - Support for 20-octet MAC addresses added.
+- `extname()` function added - This function returns the extensionof whatever file it is passed.
+- (MODULES-8273) - Unquoted classes can now be used with the `defined_with_params()` function.
+- (MODULES-8137) - Support has been added for SLES 15.
+- (MODULES-8404) - `Stdlib::Filesource` has been relaxed and now supports custom mount points.
+- (MODULES-8322) - IPs values of `0.0.0.0/0` and `::/0` are now considered to be valid.
+- New type `Stdlib::IP::Address::V6::CIDR` has been created.
+
+## Supported Release 5.1.0
+### Summary
+This is a moderate release which adds support for Puppet 6.
+
+#### Fixed
+- Handle nil in `delete_undef_values()` function
+- Readme error regarding concatenation fixed.
+- Fix to the `pick()` function documentation.
+
+#### Added
+- Support added for Puppet 6
+
+## Supported Release 5.0.0
+### Summary
+This is a major release which removes support for the Scientific 5 and Debian 7 OS, as well as a removal of the `Stdlib::(Ipv4|IPv6|Ip_address)` data types in favour of `Stdlib::IP::*`.
+
+**In addition it contains a substantial piece of work centered around updating functions that have now been migrated into Puppet itself. Please note that this will be the last major release to support Puppet 2 and Puppet 3 and that they will soon be removed.**
+
+#### Fixed
+- Docs URLs corrected.
+- Docs clarified that `Stdlib::Unixpath` only matches absolute paths.
+- `dirname()` now fails when passed an empty string.
+- `basename()` documentation clarified.
+- Corrected documentation of `count()` wrt matches and empty string.
+- Corrected example in `getparam()` and added note about equivalent in puppet.
+- Fixed URL to use 'latest' instead of '5.5' for `Hash.new` function.
+
+#### Added
+- Support added for symbolic file nodes.
+- `loadjson()` and `loadyml()` now compatible with HTTPS files.
+- `loadjson()` and `loadyml()` now compatible with HTTP basic auth files.
+- `any2array` now returns and empty array when given an empty string.
+- Support has now been added for Ubuntu 18.04.
+- `seeded_rand_string()` function has been added.
+
+#### Changed
+- PDK update `1.5.0` has been applied.
+- `size()` function deprecated for Puppet 6 and above.
+- `wrt` functions moved to Puppet as of Puppet 6.
+- `sprintf_hash` has had notification put in place to show that as of Puppet 4.10.10 it's functionality is supported by the puppet core.
+- Added note that `abs()` is in puppet since 6.0.0.
+- Added information to `base64` function about Binary data type.
+- Added note to `camelcase()` that function is now in puppet.
+- Added note to `capitalize()` that function is now in puppet.
+- Added note to `ceiling()` that function is now in puppet.
+- Added note to `chomp()` that function is now in puppet.
+- Added note to `chop()` that function is now in puppet.
+- Added note how to do equivalence of `clamp()` function in puppet 6.
+- Added note that `concat()` can be done with + since puppet 4.0.0.
+- Added note to `convert_base()` how to do this with puppet core.
+- Added equivalent puppet core way of doing `count()`.
+- Added docs for equivalent puppet language for `delete_regexp()`.
+- Added docs for equivalent language constructs for `delete_at()`.
+- Added puppet 4 equivalent for `delete_undef()` function.
+- Added equivalent puppet language for `delete_values()`.
+- Updated `delete()` function with docs about equivalent language.
+- Added docs that - between arrays is the same as `difference()`.
+- Added note to `downcase()` that function is now in puppet.
+- Added note to `empty()` that function is now in puppet.
+- Added note to `flatten()` that function is now in puppet.
+- Added note to `floor()` that function is now in puppet.
+- Added note to `get_module_path()` that puppet has similar function.
+- Amended documentation for `getvar()`.
+- Add note to `grep()` that `filter()` in puppet does the same.
+- Updated `has_key()` with equivalent puppet lang expresion.
+- Updated the `hash()` function to show equivalent expression.
+- Added note about more formatting options with `String()` in puppet.
+- Added note to `join()` that it is in puppet since 5.4.0.
+- Added note to `keys()` that it is in puppet since 5.4.0.
+- Added note to `lstrip()`, `rstrip()`, `strip()` and `upcase()` that they are in puppet since 6.0.0.
+- Updated `member()` with equivalent language expression example.
+- Updated `merge()` with puppt language equivalent example.
+- Updated `min()` and `max()` with note that they are in puppet.
+- Updated `num2bool()` with information that Boolean can convert.
+- Updated `prefix()` function with equivalent operation in pupppet.
+- Updated `range()` with information that Integer can be used.
+- Updated `reject()` with equivalent filter() call.
+- Added note to `reverse()` that the `reverse_each()` Puppet function does the same as it.
+- Added note to `round()` that it has moved to puppet in 6.0.0.
+- Added note to `size()` that `length()` is in puppet since 5.4.0.
+- Added note to `sort()` that is has moved to Puppet in 6.0.0.
+- Updated `str2bool()` with a note that Boolean can handle conversion.
+- Added note to `strftime()` that it moved to puppet in 4.8.0.
+- Added note to `suffix()` that the same can be done with `map()`.
+- Updated `time()` to mention Timespan and Timestamp data types.
+- Added note to `values_at()` for equivalent slice operation in language.
+- Added note to `values()` that it moved to puppet in 5.5.0.
+- Corrected docs for `keys()` - in puppet since 5.5.0.
+- Added note to `length()` that function moved to puppet.
+- Updated README.md with deprecations for functions moved to puppet.
+- Updated documentation of `values_at()`.
+- Updated README with note from `time()` about data types for time.
+- Updated README for `strintf_hash()` (supported by builtin sprintf).
+- Updated README with deprecation of `hash()` function (use data type).
+- Updated README `suffix` with equiv example for `map`.
+- Updated README with `reject` equivalent call to `filter`.
+- Updated README with `range` equiv use of type system + `each`.
+- Updated README with `prefix` equiv func using `map`.
+- Updated README for `num2bool` with info about Boolean type.
+- Updated README `str2bool` with information about `Boolean` equivalent.
+- Updated README `merge` with info about `+` operator equivalent.
+- Updated README `member` with equivalent alternative in language.
+- Updated README `join_keys_to_values` with link to String.new.
+- Updated README `has_key` shows deprecation in favor of `in`.
+- Updated README `grep` adds information about `filter`.
+- Updated README and `getvar.rb` as getvar has moved to puppet.
+- Updated README for `getparam` to be the same as in function.
+- Updated README `get_module_path` with info about built in variant.
+- Updated README `difference` to mention `-` operator equiv.
+- Updated README `delete` with built-in alternatives.
+- Updated README `delete_values` with builtin equiv.
+- Updated README `delete_undef` & `delete_regexp` with builtin equiv.
+- Updated README `delete_at` with equivalent built-in examples.
+- Updated README `coun`t to show built-in equiv.
+- Updated README `convert_base` with built-in equiv.
+- Updated README `concat` with built-in equiv using + and <<.
+- Updated README `base_64` with built-in equiv using Binary type.
+- Skipped tests for `abs` if puppet version < 6.0.0.
+- Skipped tests for `min` and `max` if puppet version < 6.0.0.
+- Skipped tests for `floor` if puppet version < 6.0.0.
+- Skipped tests for `ceiling` if puppet version < 6.0.0.
+- Skipped tests for `round` if puppet version < 6.0.0.
+- Skipped tests for `upcase` if puppet version < 6.0.0.
+- Skipped tests for `downcase` if puppet version < 6.0.0.
+- Skipped tests for `capitalize` if puppet version < 6.0.0.
+- Skipped tests for `camelcase` if puppet version < 6.0.0.
+- Skipped tests for strip functions if puppet version < 6.0.0.
+- Skipped tests for `chop` and `chomp` if puppet version < 6.0.0.
+- Skipped tests for `sort` if puppet version < 6.0.0.
+- Removed extra space in `describe` for `abs` test.
+- Updated README and `any2array` with built-in equiv Array.new.
+- Updated README and `any2bool` with built-in equiv Boolean.new.
+- Updated README and `bool2num` with built-in equiv Numeric.new.
+- Updated README and `bool2str` with built-in equiv String.new.
+- Corrected equivalent example for `count`.
+- Updated README and made mention of `filter` in `delete` a link.
+- Updated docs and tests for `strftime`.
+- Updated all acceptance test using Puppet.version.
+- Change 'puppet' to 'Puppet' in function doc strings.
+- HTTP type checks are now case insensitive.
+
+#### Removed
+- Support has been removed for `Scientific 5` and `Debian 7` operating systems.
+- `Stdlib::(Ipv4|IPv6|Ip_address)` have been removed.
+
+## Supported Release 4.25.1
+### Summary
+
+This is a patch which includes a roll up of small fixes. In Puppet 5.5.0 `flatten()`, `length(),` `empty(),` `join(),` `keys(),` and `values()` are now built into Puppet. Please note that the Puppet implementation of the functions will take precedence over the functions in 'puppetlabs-stdlib'.
+
+#### Fixed
+- Remove unneeded execute permission from test files.
+- Puppet 5.5.0 function deprecation [MODULES-6894](https://tickets.puppetlabs.com/browse/MODULES-6894).
+
+## Supported Release 4.25.0
+### Summary
+
+This is quite a feature heavy release, it makes this module PDK-compliant for easier maintenance and includes a roll up of maintenance changes.
+
+#### Added
+- PDK conversion [MODULES-6332](https://tickets.puppetlabs.com/browse/MODULES-6332).
+- Update `join_keys_to_values` with an undef statement.
+- Type alias `Stdlib::Fqdn` matches paths on a fully qualified domain name.
+- Type alias `Stdlib::Host` matches a valid host, this can be a valid 'ipv4', 'ipv6' or 'fqdn'.
+- Type alias `Stdlib::Port` matches a valid TCP/UDP Port number.
+- Type alias `Stdlib::Filesource` matches paths valid values for the source parameter of the puppet file type.
+- Type alias `Stdlib::IP::Address` matches any IP address, including both IPv4 and IPv6 addresses,
+- Type alias `Stdlib::IP::Address::V4` matches any string consisting of a valid IPv4 address, this is extended by 'CIDR' and 'nosubnet'.
+- Type alias `Stdlib::IP::Address::V6` matches any string consisting of a valid IPv6 address, this is extended by 'Full', 'Alternate' and 'Compressed'.
+- Type alias `Stdlib::IP::Address::V6::Nosubnet`matches any string consisting of a valid IPv6 address with no subnet, this is extended by 'Full', 'Alternate' and 'Compressed'.
+- Type alias `Stdlib::Port` matches a valid TCP/UDP Port number this is then extended to 'Privileged' which are ports less than 1024 and 'Unprivileged' which are ports greater than 1024.
+
+## Supported Release 4.24.0
+### Summary
+
+This release includes a roll up of minor changes and a new feature which provides the ability to skip undef values `to_json_pretty()`.
+We have also reverted a change that was previously made and resulted in breaking compatibility with Ruby 1.8.7.
+
+#### Added
+- Ability to skip undef values in `to_json_pretty()`.
+- Fix type3x function in stdlib ([MODULES-6216](https://tickets.puppet.com/browse/MODULES-6216))
+
+#### Changed
+- Indentation for `sync.yml` was fixed.
+- Updated type alias tests and dropped superfluous wrapper classes
+- Revert to old ruby 1.X style of hash ([MODULES-6139](https://tickets.puppet.com/browse/MODULES-6139))
+- `rubocop.yml` not managed by msync ([MODULES-6201](https://tickets.puppet.com/browse/MODULES-6201))
+
+## Supported Release 4.23.0
+### Summary
+
+This release is in order to implement Rubocop changes throughout the module.
+
+#### Added
+- Standard and translated readme's have been updated.
+- Rubocop has been implemented in the module and a wide variety of changes have been made to the code.
+- Modulesync changes have been merged into the code.
+
+#### Fixed
+- Minor fix to the readme.
+
+## Supported Release 4.22.0
+### Summary
+
+This is a clean release in preparation of putting the module through the rubocop process.
+
+#### Added
+- Support has been added for Debian 9
+- 'Stdlib::Mode type' has been added to the module.
+- A type for 'ensure' has been added to the service resources.
+- A new function 'sprintf_hash' has been added to allow the use of named references.
+
+#### Removed
+- Support has been removed for: RedHat 4, CentOS 4, OracleLinux 4, Scientific 4, SLES 10 SP4, Windows Server 2003, Windows Server 2003 R2 and Windows 8.
+
+#### Fixed
+- The 'ruby_spec.rb' test file has been altered s that it properly checks results.
+- Example syntax in 'file_line.rb' has been fixed.
+
+## Supported Release 4.21.0
+### Summary
+
+This is a small feature release that includes a revamped, albeit backwards-compatible file_line type.
+
+#### Added
+- `replace_all_matches_not_matching_line` parameter in file_line
+- additional tests and documentation for file_line
+
+#### Removed
+- duplicate spec test for absolute_path
+
+#### Fixed
+- Unixpath type to allow "/" as valid path
+- file_line behavior that caused infinite appending of `line` to a file ([MODULES-5651](https://tickets.puppet.com/browse/MODULES-5651))
+
+## Supported Release 4.20.0
+### Summary
+
+This release adds new functions and updated README translations.
+
+#### Added
+- `to_json`, `to_json_pretty`, and `to_yaml` functions
+- new Japanese README translations
+
+#### Fixed
+- compatibility issue with older versions of Puppet and the `pw_hash` function ([MODULES-5546](https://tickets.puppet.com/browse/MODULES-5546))
+
+#### Removed
+- support for EOL platform Debian 6 (Squeeze)
+
 ## Supported Release 4.19.0
 ### Summary
 
@@ -16,9 +282,9 @@ This release adds new functions and better documentation/fixes for existing func
 - Add new function, fact() (FACT-932)
 
 #### Fixed
-- Fixes for the file_line provider ([MODULES-5003](https://tickets.puppet.com/browse/MODULES-5003)) 
-- Add documentation for email functions ([MODULES-5382](https://tickets.puppet.com/browse/MODULES-5382)) 
-- unique function is deprecated for puppet version > 5. (FM-6239) 
+- Fixes for the file_line provider ([MODULES-5003](https://tickets.puppet.com/browse/MODULES-5003))
+- Add documentation for email functions ([MODULES-5382](https://tickets.puppet.com/browse/MODULES-5382))
+- unique function is deprecated for puppet version > 5. (FM-6239)
 - Fix headers in CHANGELOG.md so that headers render correctly
 - ensure_packages, converge ensure values 'present' and 'installed'
 
index 990edba..1a9fb3a 100644 (file)
@@ -1,63 +1,75 @@
-Checklist (and a short version for the impatient)
-=================================================
+# Contributing to Puppet modules
 
-  * Commits:
+So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing
+that very thing while setting expectations around code quality as well as a few tips for making the
+process as easy as possible. 
 
-    - Make commits of logical units.
+### Table of Contents
 
-    - Check for unnecessary whitespace with "git diff --check" before
-      committing.
+1. [Getting Started](#getting-started)
+1. [Commit Checklist](#commit-checklist)
+1. [Submission](#submission)
+1. [More about commits](#more-about-commits)
+1. [Testing](#testing)
+    - [Running Tests](#running-tests)
+    - [Writing Tests](#writing-tests)
+1. [Get Help](#get-help)
 
-    - Commit using Unix line endings (check the settings around "crlf" in
-      git-config(1)).
+## Getting Started
 
-    - Do not check in commented out code or unneeded files.
+- Fork the module repository on GitHub and clone to your workspace
 
-    - The first line of the commit message should be a short
-      description (50 characters is the soft limit, excluding ticket
-      number(s)), and should skip the full stop.
+- Make your changes!
 
-    - Associate the issue in the message. The first line should include
-      the issue number in the form "(#XXXX) Rest of message".
+## Commit Checklist
 
-    - The body should provide a meaningful commit message, which:
+### The Basics
 
-      - uses the imperative, present tense: "change", not "changed" or
-        "changes".
+- [x] my commit is a single logical unit of work
 
-      - includes motivation for the change, and contrasts its
-        implementation with the previous behavior.
+- [x] I have checked for unnecessary whitespace with "git diff --check" 
 
-    - Make sure that you have tests for the bug you are fixing, or
-      feature you are adding.
+- [x] my commit does not include commented out code or unneeded files
 
-    - Make sure the test suites passes after your commit:
-      `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below
+### The Content
 
-    - When introducing a new feature, make sure it is properly
-      documented in the README.md
+- [x] my commit includes tests for the bug I fixed or feature I added
 
-  * Submission:
+- [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality
+    
+- [x] my code passes existing test suites
 
-    * Pre-requisites:
+### The Commit Message
 
-      - Make sure you have a [GitHub account](https://github.com/join)
+- [x] the first line of my commit message includes:
 
-      - [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
+  - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line" 
+  
+  - [x] a short description (50 characters is the soft limit, excluding ticket number(s))
 
-    * Preferred method:
+- [x] the body of my commit message:
 
-      - Fork the repository on GitHub.
+  - [x] is meaningful
 
-      - Push your changes to a topic branch in your fork of the
-        repository. (the format ticket/1234-short_description_of_change is
-        usually preferred for this project).
+  - [x] uses the imperative, present tense: "change", not "changed" or "changes"
 
-      - Submit a pull request to the repository in the puppetlabs
-        organization.
+  - [x] includes motivation for the change, and contrasts its implementation with the previous behavior
 
-The long version
-================
+## Submission
+
+### Pre-requisites
+
+- Make sure you have a [GitHub account](https://github.com/join)
+
+- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
+
+### Push and PR
+
+- Push your changes to your fork
+
+- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization
+
+## More about commits 
 
   1.  Make separate commits for logically separate changes.
 
@@ -104,37 +116,32 @@ The long version
       GitHub has some pretty good
       [general documentation](http://help.github.com/) on using
       their site.  They also have documentation on
-      [creating pull requests](http://help.github.com/send-pull-requests/).
+      [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
 
       In general, after pushing your topic branch up to your
       repository on GitHub, you can switch to the branch in the
       GitHub UI and click "Pull Request" towards the top of the page
       in order to open a pull request.
 
+  3.  Update the related JIRA issue.
 
-  3.  Update the related GitHub issue.
-
-      If there is a GitHub issue associated with the change you
+      If there is a JIRA issue associated with the change you
       submitted, then you should update the ticket to include the
       location of your branch, along with any other commentary you
       may wish to make.
 
-Testing
-=======
+# Testing
 
-Getting Started
----------------
+## Getting Started
 
-Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby
-package manager such as [bundler](http://bundler.io/) what Ruby packages,
+Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
 or Gems, are required to build, develop, and test this software.
 
-Please make sure you have [bundler installed](http://bundler.io/#getting-started)
-on your system, then use it to install all dependencies needed for this project,
-by running
+Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to 
+install all dependencies needed for this project in the project root by running
 
 ```shell
-% bundle install
+% bundle install --path .bundle/gems
 Fetching gem metadata from https://rubygems.org/........
 Fetching gem metadata from https://rubygems.org/..
 Using rake (10.1.0)
@@ -148,7 +155,7 @@ Your bundle is complete!
 Use `bundle show [gemname]` to see where a bundled gem is installed.
 ```
 
-NOTE some systems may require you to run this command with sudo.
+NOTE: some systems may require you to run this command with sudo.
 
 If you already have those gems installed, make sure they are up-to-date:
 
@@ -156,26 +163,27 @@ If you already have those gems installed, make sure they are up-to-date:
 % bundle update
 ```
 
-With all dependencies in place and up-to-date we can now run the tests:
+## Running Tests
+
+With all dependencies in place and up-to-date, run the tests:
+
+### Unit Tests
 
 ```shell
 % bundle exec rake spec
 ```
 
-This will execute all the [rspec tests](http://rspec-puppet.com/) tests
-under [spec/defines](./spec/defines), [spec/classes](./spec/classes),
-and so on. rspec tests may have the same kind of dependencies as the
-module they are testing. While the module defines in its [Modulefile](./Modulefile),
+This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on. 
+rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json),
 rspec tests define them in [.fixtures.yml](./fixtures.yml).
 
-Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker)
-tests. These tests spin up a virtual machine under
-[VirtualBox](https://www.virtualbox.org/)) with, controlling it with
-[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test
-scenarios. In order to run these, you will need both of those tools
-installed on your system.
+### Acceptance Tests
+
+Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under
+[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test
+scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system.
 
-You can run them by issuing the following command
+Run the tests by issuing the following command
 
 ```shell
 % bundle exec rake spec_clean
@@ -183,35 +191,81 @@ You can run them by issuing the following command
 ```
 
 This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
-install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
+install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
 and then run all the tests under [spec/acceptance](./spec/acceptance).
 
-Writing Tests
--------------
+## Writing Tests
+
+### Unit Tests
 
-XXX getting started writing tests.
+When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a 
+catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs] 
+but here's a tiny sample:
 
-If you have commit access to the repository
-===========================================
+Sample manifest:
 
-Even if you have commit access to the repository, you will still need to
-go through the process above, and have someone else review and merge
-in your changes.  The rule is that all changes must be reviewed by a
-developer on the project (that did not write the code) to ensure that
-all changes go through a code review process.
+```puppet
+file { "a test file":
+  ensure => present,
+  path   => "/etc/sample",
+}
+```
+
+Sample test:
 
-Having someone other than the author of the topic branch recorded as
-performing the merge is the record that they performed the code
-review.
+```ruby
+it 'does a thing' do
+  expect(subject).to contain_file("a test file").with({:path => "/etc/sample"})
+end
+```
 
+### Acceptance Tests
+
+Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it
+twice to check for idempotency or errors, then run expectations.
+
+```ruby
+it 'does an end-to-end thing' do
+  pp = <<-EOF
+    file { 'a test file': 
+      ensure  => present,
+      path    => "/etc/sample",
+      content => "test string",
+    }
+    
+  apply_manifest(pp, :catch_failures => true)
+  apply_manifest(pp, :catch_changes => true)
+  
+end
+
+describe file("/etc/sample") do
+  it { is_expected.to contain "test string" }
+end
 
-Additional Resources
-====================
+```
 
-* [Getting additional help](http://puppet.com/community/get-help)
+# If you have commit access to the repository
 
-* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
+Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
+in your changes.  The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that
+all changes go through a code review process.**
 
-* [General GitHub documentation](http://help.github.com/)
+The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch.
 
+# Get Help
+
+### On the web
+* [Puppet help messageboard](http://puppet.com/community/get-help)
+* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
+* [General GitHub documentation](http://help.github.com/)
 * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
+
+### On chat
+* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
+* IRC (freenode) #puppet-dev, #voxpupuli
+
+
+[rspec-puppet]: http://rspec-puppet.com/
+[rspec-puppet_docs]: http://rspec-puppet.com/documentation/
+[beaker]: https://github.com/puppetlabs/beaker
+[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec
index a9f0161..b7d80c3 100644 (file)
@@ -1,76 +1,76 @@
-#This file is generated by ModuleSync, do not edit.
+source ENV['GEM_SOURCE'] || 'https://rubygems.org'
 
-source ENV['GEM_SOURCE'] || "https://rubygems.org"
-
-# Determines what type of gem is requested based on place_or_version.
-def gem_type(place_or_version)
-  if place_or_version =~ /^git:/
-    :git
-  elsif place_or_version =~ /^file:/
-    :file
-  else
-    :gem
-  end
-end
-
-# Find a location or specific version for a gem. place_or_version can be a
-# version, which is most often used. It can also be git, which is specified as
-# `git://somewhere.git#branch`. You can also use a file source location, which
-# is specified as `file://some/location/on/disk`.
 def location_for(place_or_version, fake_version = nil)
-  if place_or_version =~ /^(git[:@][^#]*)#(.*)/
-    [fake_version, { :git => $1, :branch => $2, :require => false }].compact
-  elsif place_or_version =~ /^file:\/\/(.*)/
-    ['>= 0', { :path => File.expand_path($1), :require => false }]
+  git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
+  file_url_regex = %r{\Afile:\/\/(?<path>.*)}
+
+  if place_or_version && (git_url = place_or_version.match(git_url_regex))
+    [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
+  elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
+    ['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
   else
-    [place_or_version, { :require => false }]
+    [place_or_version, { require: false }]
   end
 end
 
-# Used for gem conditionals
-supports_windows = false
 ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
-minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}"
+minor_version = ruby_version_segments[0..1].join('.')
 
 group :development do
-  gem "puppet-module-posix-default-r#{minor_version}",    :require => false, :platforms => "ruby"
-  gem "puppet-module-win-default-r#{minor_version}",      :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
-  gem "puppet-module-posix-dev-r#{minor_version}",        :require => false, :platforms => "ruby"
-  gem "puppet-module-win-dev-r#{minor_version}", '0.0.7', :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
-  gem "json_pure", '<= 2.0.1',                            :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
-  gem "fast_gettext", '1.1.0',                            :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
-  gem "fast_gettext",                                     :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
+  gem "fast_gettext", '1.1.0',                         require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
+  gem "fast_gettext",                                  require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
+  gem "json_pure", '<= 2.0.1',                         require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
+  gem "json", '= 1.8.1',                               require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
+  gem "json", '= 2.0.4',                               require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+  gem "json", '= 2.1.0',                               require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+  gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
+  gem "puppet-module-posix-dev-r#{minor_version}",     require: false, platforms: [:ruby]
+  gem "puppet-module-win-default-r#{minor_version}",   require: false, platforms: [:mswin, :mingw, :x64_mingw]
+  gem "puppet-module-win-dev-r#{minor_version}",       require: false, platforms: [:mswin, :mingw, :x64_mingw]
+  gem "github_changelog_generator",                    require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')
 end
-
 group :system_tests do
-  gem "puppet-module-posix-system-r#{minor_version}",                            :require => false, :platforms => "ruby"
-  gem "puppet-module-win-system-r#{minor_version}",                              :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
-  gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3')                  
-  gem "beaker-pe",                                                               :require => false
-  gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'])                
-  gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
-  gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')        
-  gem "puppet-blacksmith", '~> 3.4',                                             :require => false
+  gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
+  gem "puppet-module-win-system-r#{minor_version}",   require: false, platforms: [:mswin, :mingw, :x64_mingw]
 end
 
-gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
+puppet_version = ENV['PUPPET_GEM_VERSION']
+facter_version = ENV['FACTER_GEM_VERSION']
+hiera_version = ENV['HIERA_GEM_VERSION']
+
+gems = {}
+
+gems['puppet'] = location_for(puppet_version)
 
-# Only explicitly specify Facter/Hiera if a version has been specified.
-# Otherwise it can lead to strange bundler behavior. If you are seeing weird
-# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable
-# to `1` and then run bundle install.
-gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION']
-gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION']
+# If facter or hiera versions have been specified via the environment
+# variables
 
+gems['facter'] = location_for(facter_version) if facter_version
+gems['hiera'] = location_for(hiera_version) if hiera_version
 
-# Evaluate Gemfile.local if it exists
-if File.exists? "#{__FILE__}.local"
-  eval(File.read("#{__FILE__}.local"), binding)
+if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
+  # If we're using a Puppet gem on Windows which handles its own win32-xxx gem
+  # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
+  gems['win32-dir'] =      ['<= 0.4.9', require: false]
+  gems['win32-eventlog'] = ['<= 0.6.5', require: false]
+  gems['win32-process'] =  ['<= 0.7.5', require: false]
+  gems['win32-security'] = ['<= 0.2.5', require: false]
+  gems['win32-service'] =  ['0.8.8', require: false]
 end
 
-# Evaluate ~/.gemfile if it exists
-if File.exists?(File.join(Dir.home, '.gemfile'))
-  eval(File.read(File.join(Dir.home, '.gemfile')), binding)
+gems.each do |gem_name, gem_params|
+  gem gem_name, *gem_params
 end
 
-# vim:ft=ruby
+# Evaluate Gemfile.local and ~/.gemfile if they exist
+extra_gemfiles = [
+  "#{__FILE__}.local",
+  File.join(Dir.home, '.gemfile'),
+]
+
+extra_gemfiles.each do |gemfile|
+  if File.file?(gemfile) && File.readable?(gemfile)
+    eval(File.read(gemfile), binding)
+  end
+end
+# vim: syntax=ruby
index 7813f19..e2e9ee6 100644 (file)
@@ -15,7 +15,7 @@
 1. [Development - Guide for contributing to the module](#development)
 1. [Contributors](#contributors)
 
-
+<a id="module-description"></a>
 ## Module Description
 
 This module provides a standard library of resources for Puppet modules. Puppet modules make heavy use of this standard library. The stdlib module adds the following resources to Puppet:
@@ -29,12 +29,14 @@ This module provides a standard library of resources for Puppet modules. Puppet
 
 > *Note:* As of version 3.7, Puppet Enterprise no longer includes the stdlib module. If you're running Puppet Enterprise, you should install the most recent release of stdlib for compatibility with Puppet modules.
 
+<a id="setup"></a>
 ## Setup
 
-[Install](https://docs.puppet.com/puppet/latest/modules_installing.html) the stdlib module to add the functions, facts, and resources of this standard library to Puppet.
+[Install](https://puppet.com/docs/puppet/latest/modules_installing.html) the stdlib module to add the functions, facts, and resources of this standard library to Puppet.
 
-If you are authoring a module that depends on stdlib, be sure to [specify dependencies](https://docs.puppet.com/puppet/latest/modules_metadata.html#specifying-dependencies) in your metadata.json.
+If you are authoring a module that depends on stdlib, be sure to [specify dependencies](https://puppet.com/docs/puppet/latest/modules_metadata.html#specifying-dependencies-in-modules) in your metadata.json.
 
+<a id="usage"></a>
 ## Usage
 
 Most of stdlib's features are automatically loaded by Puppet. To use standardized run stages in Puppet, declare this class in your manifest with `include stdlib`.
@@ -61,6 +63,7 @@ node default {
 }
 ```
 
+<a id="reference"></a>
 ## Reference
 
 * [Public classes](#public-classes)
@@ -70,16 +73,20 @@ node default {
 * [Facts](#facts)
 * [Functions](#functions)
 
+<a id="classes"></a>
 ### Classes
 
+<a id="public-classes"></a>
 #### Public classes
 
 The `stdlib` class has no parameters.
 
+<a id="private-classes"></a>
 #### Private classes
 
 * `stdlib::stages`: Manages a standard set of run stages for Puppet.
 
+<a id="defined-types"></a>
 ### Defined types
 
 #### `file_line`
@@ -117,29 +124,49 @@ In the example above, `match` looks for a line beginning with 'export' followed
 
 Match Example:
 
-    file_line { 'bashrc_proxy':
-      ensure             => present,
-      path               => '/etc/bashrc',
-      line               => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
-      match              => '^export\ HTTP_PROXY\=',
-      append_on_no_match => false,
-    }
+```puppet
+file_line { 'bashrc_proxy':
+  ensure             => present,
+  path               => '/etc/bashrc',
+  line               => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+  match              => '^export\ HTTP_PROXY\=',
+  append_on_no_match => false,
+}
+```
 
-In this code example, `match` looks for a line beginning with export followed by HTTP_PROXY and replaces it with the value in line. If a match is not found, then no changes are made to the file.
+In this code example, `match` looks for a line beginning with export followed by 'HTTP_PROXY' and replaces it with the value in line. If a match is not found, then no changes are made to the file.
 
-Match Example with `ensure => absent`:
+Examples of `ensure => absent`:
+
+This type has two behaviors when `ensure => absent` is set.
+
+The first is to set `match => ...` and `match_for_absence => true`. Match looks for a line beginning with 'export', followed by 'HTTP_PROXY', and then deletes it. If multiple lines match, an error is raised unless the `multiple => true` parameter is set.
+
+The `line => ...` parameter in this example would be accepted but ignored.
+
+For example:
 
 ```puppet
 file_line { 'bashrc_proxy':
   ensure            => absent,
   path              => '/etc/bashrc',
-  line              => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
   match             => '^export\ HTTP_PROXY\=',
   match_for_absence => true,
 }
 ```
 
-In the example above, `match` looks for a line beginning with 'export' followed by 'HTTP_PROXY' and deletes it. If multiple lines match, an error is raised, unless the `multiple => true` parameter is set.
+The second way of using `ensure => absent` is to specify a `line => ...` and no match. When ensuring lines are absent, the default behavior is to remove all lines matching. This behavior can't be disabled.
+
+For example:
+
+```puppet
+file_line { 'bashrc_proxy':
+  ensure => absent,
+  path   => '/etc/bashrc',
+  line   => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+}
+```
+
 
 Encoding example:
 
@@ -177,7 +204,9 @@ Values: String specifying a valid Ruby character encoding.
 
 Default: 'UTF-8'.
 
-##### `ensure`: Specifies whether the resource is present.
+##### `ensure`
+
+Specifies whether the resource is present.
 
 Values: 'present', 'absent'.
 
@@ -193,7 +222,7 @@ Values: String.
 
 ##### `match`
 
-Specifies a regular expression to compare against existing lines in the file; if a match is found, it is replaced rather than adding a new line. A regex comparison is performed against the line value, and if it does not match, an exception is raised.
+Specifies a regular expression to compare against existing lines in the file; if a match is found, it is replaced rather than adding a new line.
 
 Values: String containing a regex.
 
@@ -210,7 +239,7 @@ Default value: `false`.
 
 ##### `multiple`
 
-Specifies whether `match` and `after` can change multiple lines. If set to `false`, an exception is raised if more than one line matches.
+Specifies whether `match` and `after` can change multiple lines. If set to `false`, allows file_line to replace only one line and raises an error if more than one will be replaced. If set to `true`, allows file_line to replace one or more lines.
 
 Values: `true`, `false`.
 
@@ -235,12 +264,21 @@ Value: String specifying an absolute path to the file.
 
 ##### `replace`
 
-Specifies whether the resource overwrites an existing line that matches the `match` parameter. If set to `false` and a line is found matching the `match` parameter, the line is not placed in the file.
+Specifies whether the resource overwrites an existing line that matches the `match` parameter when `line` does not otherwise exist.
+
+If set to `false` and a line is found matching the `match` parameter, the line is not placed in the file.
 
 Boolean.
 
 Default value: `true`.
 
+##### `replace_all_matches_not_matching_line`
+
+Replaces all lines matched by `match` parameter, even if `line` already exists in the file.
+
+Default value: `false`.
+
+<a id="data-types"></a>
 ### Data types
 
 #### `Stdlib::Absolutepath`
@@ -267,14 +305,34 @@ Unacceptable input example:
 ../relative_path
 ```
 
+#### `Stdlib::Ensure::Service`
+
+Matches acceptable ensure values for service resources.
+
+Acceptable input examples:
+
+```shell
+stopped
+running
+```
+
+Unacceptable input example:
+
+```shell
+true
+false
+```
+
 #### `Stdlib::Httpsurl`
 
-Matches HTTPS URLs.
+Matches HTTPS URLs. It is a case insensitive match.
 
 Acceptable input example:
 
 ```shell
 https://hello.com
+
+HTTPS://HELLO.COM
 ```
 
 Unacceptable input example:
@@ -285,7 +343,7 @@ httds://notquiteright.org`
 
 #### `Stdlib::Httpurl`
 
-Matches both HTTPS and HTTP URLs.
+Matches both HTTPS and HTTP URLs. It is a case insensitive match.
 
 Acceptable input example:
 
@@ -293,6 +351,8 @@ Acceptable input example:
 https://hello.com
 
 http://hello.com
+
+HTTP://HELLO.COM
 ```
 
 Unacceptable input example:
@@ -307,7 +367,7 @@ Matches MAC addresses defined in [RFC5342](https://tools.ietf.org/html/rfc5342).
 
 #### `Stdlib::Unixpath`
 
-Matches paths on Unix operating systems.
+Matches absolute paths on Unix operating systems.
 
 Acceptable input example:
 
@@ -321,6 +381,38 @@ Unacceptable input example:
 
 ```shell
 C:/whatever
+
+some/path
+
+../some/other/path
+```
+
+#### `Stdlib::Filemode`
+
+Matches octal file modes consisting of one to four numbers and symbolic file modes.
+
+Acceptable input examples:
+
+```shell
+0644
+```
+
+```shell
+1777
+```
+
+```shell
+a=Xr,g=w
+```
+
+Unacceptable input examples:
+
+```shell
+x=r,a=wx
+```
+
+```shell
+0999
 ```
 
 #### `Stdlib::Windowspath`
@@ -337,12 +429,248 @@ C:\\
 \\\\host\\windows
 ```
 
-Unacceptable input example:
+Valid values: A windows filepath.
+
+#### `Stdlib::Filesource`
+
+Matches paths valid values for the source parameter of the Puppet file type.
+
+Acceptable input example:
 
 ```shell
-/usr2/username/bin:/usr/local/bin:/usr/bin:.
+http://example.com
+
+https://example.com
+
+file:///hello/bla
+```
+
+Valid values: A filepath.
+
+#### `Stdlib::Fqdn`
+
+Matches paths on fully qualified domain name.
+
+Acceptable input example:
+
+```shell
+localhost
+
+example.com
+
+www.example.com
 ```
+Valid values: Domain name of a server.
+
+#### `Stdlib::Host`
+
+Matches a valid host which could be a valid ipv4, ipv6 or fqdn.
+
+Acceptable input example:
+
+```shell
+localhost
+
+www.example.com
+
+192.0.2.1
+```
+
+Valid values: An IP address or domain name.
+
+#### `Stdlib::Port`
+
+Matches a valid TCP/UDP Port number.
+
+Acceptable input examples:
+
+```shell
+80
+
+443
+
+65000
+```
+
+Valid values: An Integer.
+
+#### `Stdlib::Port::Privileged`
+
+Matches a valid TCP/UDP Privileged port i.e. < 1024.
+
+Acceptable input examples:
+
+```shell
+80
+
+443
+
+1023
+```
+
+Valid values: A number less than 1024.
+
+#### `Stdlib::Port::Unprivileged`
+
+Matches a valid TCP/UDP Privileged port i.e. >= 1024.
+
+Acceptable input examples:
+
+```shell
+1024
+
+1337
+
+65000
+
+```
+
+Valid values: A number more than or equal to 1024.
+
+#### `Stdlib::Base32`
+
+Matches paths a valid base32 string.
+
+Acceptable input example:
+
+```shell
+ASDASDDASD3453453
+
+asdasddasd3453453=
+
+ASDASDDASD3453453==
+```
+
+Valid values: A base32 string.
+
+#### `Stdlib::Base64`
+
+Matches paths a valid base64 string.
+
+Acceptable input example:
+
+```shell
+asdasdASDSADA342386832/746+=
+
+asdasdASDSADA34238683274/6+
+
+asdasdASDSADA3423868327/46+==
+```
+
+Valid values: A base64 string.
+
+#### `Stdlib::Ipv4`
+
+This type is no longer available. To make use of this functionality, use [Stdlib::IP::Address::V4](https://github.com/puppetlabs/puppetlabs-stdlib#stdlibipaddressv4).
+
+#### `Stdlib::Ipv6`
+
+This type is no longer available. To make use of this functionality, use  [Stdlib::IP::Address::V6](https://github.com/puppetlabs/puppetlabs-stdlib#stdlibipaddressv6).
+
+#### `Stdlib::Ip_address`
+
+This type is no longer available. To make use of this functionality, use  [Stdlib::IP::Address](https://github.com/puppetlabs/puppetlabs-stdlib#stdlibipaddress)
+
+#### `Stdlib::IP::Address`
+
+Matches any IP address, including both IPv4 and IPv6 addresses. It will match them either with or without an address prefix as used in CIDR format IPv4 addresses.
+
+Examples:
+
+```
+'127.0.0.1' =~ Stdlib::IP::Address                                # true
+'10.1.240.4/24' =~ Stdlib::IP::Address                            # true
+'52.10.10.141' =~ Stdlib::IP::Address                             # true
+'192.168.1' =~ Stdlib::IP::Address                                # false
+'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address  # true
+'FF01:0:0:0:0:0:0:101' =~ Stdlib::IP::Address                     # true
+```
+
+#### `Stdlib::IP::Address::V4`
+
+Match any string consisting of an IPv4 address in the quad-dotted decimal format, with or without a CIDR prefix. It will not match any abbreviated form (for example, 192.168.1) because these are poorly documented and inconsistently supported.
+
+Examples:
+
+```
+'127.0.0.1' =~ Stdlib::IP::Address::V4                                # true
+'10.1.240.4/24' =~ Stdlib::IP::Address::V4                            # true
+'192.168.1' =~ Stdlib::IP::Address::V4                                # false
+'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address::V4  # false
+'12AB::CD30:192.168.0.1' =~ Stdlib::IP::Address::V4                   # false
+```
+
+Valid values: An IPv4 address.
+
+#### `Stdlib::IP::Address::V6`
+
+Match any string consistenting of an IPv6 address in any of the documented formats in RFC 2373, with or without an address prefix.
+
+Examples:
+
+```
+'127.0.0.1' =~ Stdlib::IP::Address::V6                                # false
+'10.1.240.4/24' =~ Stdlib::IP::Address::V6                            # false
+'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address::V6  # true
+'FF01:0:0:0:0:0:0:101' =~ Stdlib::IP::Address::V6                     # true
+'FF01::101' =~ Stdlib::IP::Address::V6                                # true
+```
+
+Valid values: An IPv6 address.
+
+#### `Stdlib::IP::Address::Nosubnet`
+
+Match the same things as the `Stdlib::IP::Address` alias, except it will not match an address that includes an address prefix (for example, it will match '192.168.0.6' but not '192.168.0.6/24').
+
+Valid values: An IP address with no subnet.
+
+#### `Stdlib::IP::Address::V4::CIDR`
+
+Match an IPv4 address in the CIDR format. It will only match if the address contains an address prefix (for example, it will match '192.168.0.6/24'
+but not '192.168.0.6').
+
+Valid values: An IPv4 address with a CIDR provided eg: '192.186.8.101/105'. This will match anything inclusive of '192.186.8.101' to '192.168.8.105'.
+
+#### `Stdlib::IP::Address::V4::Nosubnet`
+
+Match an IPv4 address only if the address does not contain an address prefix (for example, it will match '192.168.0.6' but not '192.168.0.6/24').
+
+Valid values: An IPv4 address with no subnet.
+
+#### `Stdlib::IP::Address::V6::Full`
+
+Match an IPv6 address formatted in the "preferred form" as documented in section 2.2 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt), with or without an address prefix as documented in section 2.3 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt).
+
+#### `Stdlib::IP::Address::V6::Alternate`
+
+Match an IPv6 address formatted in the "alternative form" allowing for representing the last two 16-bit pieces of the address with a quad-dotted decimal, as documented in section 2.2.1 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt). It will match addresses with or without an address prefix as documented in section 2.3 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt).
+
+#### `Stdlib::IP::Address::V6::Compressed`
+
+Match an IPv6 address which may contain `::` used to compress zeros as documented in section 2.2.2 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt). It will match addresses with or without an address prefix as documented in section 2.3 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt).
 
+#### `Stdlib::IP::Address::V6::Nosubnet`
+
+Alias to allow `Stdlib::IP::Address::V6::Nosubnet::Full`, `Stdlib::IP::Address::V6::Nosubnet::Alternate` and `Stdlib::IP::Address::V6::Nosubnet::Compressed`.
+
+#### `Stdlib::IP::Address::V6::Nosubnet::Full`
+
+Match an IPv6 address formatted in the "preferred form" as documented in section 2.2 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt). It will not match addresses with address prefix as documented in section 2.3 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt).
+
+#### `Stdlib::IP::Address::V6::Nosubnet::Alternate`
+
+Match an IPv6 address formatted in the "alternative form" allowing for representing the last two 16-bit pieces of the address with a quad-dotted decimal, as documented in section 2.2.1 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt). It will only match addresses without an address prefix as documented in section 2.3 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt).
+
+#### `Stdlib::IP::Address::V6::Nosubnet::Compressed`
+
+Match an IPv6 address which may contain `::` used to compress zeros as documented in section 2.2.2 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt). It will only match addresses without an address prefix as documented in section 2.3 of [RFC 2373](https://www.ietf.org/rfc/rfc2373.txt).
+
+#### `Stdlib::IP::Address::V6::CIDR`
+
+Match an IPv6 address in the CIDR format. It will only match if the address contains an address prefix (for example, it will match   'FF01:0:0:0:0:0:0:101/32', 'FF01::101/60', '::/0',
+but not 'FF01:0:0:0:0:0:0:101', 'FF01::101', '::').
+
+<a id="facts"></a>
 ### Facts
 
 #### `package_provider`
@@ -391,10 +719,13 @@ Determines the root home directory, which depends on your operating system. Gene
 
 Returns the default provider Puppet uses to manage services on this system
 
+<a id="functions"></a>
 ### Functions
 
 #### `abs`
 
+**Deprecated:** This function has been replaced with a built-in [`abs`](https://puppet.com/docs/puppet/latest/function.html#abs) function as of Puppet 6.0.0.
+
 Returns the absolute value of a number. For example, '-34.56' becomes '34.56'.
 
 Argument: A single argument of either an integer or float value.
@@ -405,6 +736,19 @@ Argument: A single argument of either an integer or float value.
 
 Converts any object to an array containing that object. Converts empty argument lists are to empty arrays. Hashes are converted to arrays of alternating keys and values. Arrays are not touched.
 
+Since Puppet 5.0.0, you can create new values of almost any datatype using the type system — you can use the built-in [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) function to create a new array:
+
+    $hsh = {'key' => 42, 'another-key' => 100}
+    notice(Array($hsh))
+
+Would notice `[['key', 42], ['another-key', 100]]`
+
+The array data type also has a special mode to "create an array if not already an array":
+
+    notice(Array({'key' => 42, 'another-key' => 100}, true))
+
+Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being transformed into an array.
+
 *Type*: rvalue.
 
 #### `any2bool`
@@ -418,6 +762,8 @@ Converts any object to a Boolean:
 * An undef value returns `false`.
 * Anything else returns `true`.
 
+See the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
+
 *Type*: rvalue.
 
 #### `assert_private`
@@ -440,7 +786,18 @@ Converts a string to and from base64 encoding. Requires an `action` ('encode', '
 
 For backward compatibility, `method` is set as `default` if not specified.
 
-*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
+> **Note**: This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
+
+Since Puppet 4.8.0, the `Binary` data type can be used to produce base 64 encoded strings.
+
+See the built-in [`String.new`](https://puppet.com/docs/puppet/latest/function.html#binary-value-to-string) and [`Binary.new`](https://puppet.com/docs/puppet/latest/function.html#creating-a-binary) functions.
+
+See the built-in [`binary_file`](https://puppet.com/docs/puppet/latest/function.html#binary_file) function for reading a file with binary (non UTF-8) content.
+
+    # encode a string as if it was binary
+    $encodestring = String(Binary('thestring', '%s'))
+    # decode a Binary assuming it is an UTF-8 String
+    $decodestring = String(Binary("dGhlc3RyaW5n"), "%s")
 
 **Examples:**
 
@@ -472,9 +829,11 @@ base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe')
 
 Returns the `basename` of a path. An optional argument strips the extension. For example:
 
-  * ('/path/to/a/file.ext') returns 'file.ext'
-  * ('relative/path/file.ext') returns 'file.ext'
-  * ('/path/to/a/file.ext', '.ext') returns 'file'
+```puppet
+basename('/path/to/a/file.ext')            => 'file.ext'
+basename('relative/path/file.ext')         => 'file.ext'
+basename('/path/to/a/file.ext', '.ext')    => 'file'
+```
 
 *Type*: rvalue.
 
@@ -485,9 +844,15 @@ Converts a Boolean to a number. Converts values:
 * `false`, 'f', '0', 'n', and 'no' to 0.
 * `true`, 't', '1', 'y', and 'yes' to 1.
 
-  Argument: a single Boolean or string as an input.
+Argument: a single Boolean or string as an input.
+
+Since Puppet 5.0.0, you can create values for almost any data type using the type system — you can use the built-in [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric), [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float)
+functions to convert to numeric values:
 
-  *Type*: rvalue.
+    notice(Integer(false)) # Notices 0
+    notice(Float(true))    # Notices 1.0
+
+*Type*: rvalue.
 
 #### `bool2str`
 
@@ -503,10 +868,22 @@ bool2str(false, 't', 'f')         => 'f'
 
 Arguments: Boolean.
 
+Since Puppet 5.0.0, you can create new values for almost any
+data type using the type system — you can use the built-in
+[`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string)
+function to convert to String, with many different format options:
+
+    notice(String(false))         # Notices 'false'
+    notice(String(true))          # Notices 'true'
+    notice(String(false, '%y'))   # Notices 'yes'
+    notice(String(true, '%y'))    # Notices 'no'
+
 *Type*: rvalue.
 
 #### `camelcase`
 
+**Deprecated:** This function has been replaced with a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase) function as of Puppet 6.0.0.
+
 Converts the case of a string or all strings in an array to CamelCase (mixed case).
 
 Arguments: Either an array or string. Returns the same type of argument as it received, but in CamelCase form.
@@ -517,6 +894,8 @@ Arguments: Either an array or string. Returns the same type of argument as it re
 
 #### `capitalize`
 
+**Deprecated:** This function has been replaced with a built-in [`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize) function as of Puppet 6.0.0.
+
 Capitalizes the first character of a string or array of strings and lowercases the remaining characters of each string.
 
 Arguments: either a single string or an array as an input. *Type*: rvalue.
@@ -525,6 +904,8 @@ Arguments: either a single string or an array as an input. *Type*: rvalue.
 
 #### `ceiling`
 
+**Deprecated:** This function has been replaced with a built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function as of Puppet 6.0.0.
+
 Returns the smallest integer greater than or equal to the argument.
 
 Arguments: A single numeric value.
@@ -533,6 +914,8 @@ Arguments: A single numeric value.
 
 #### `chomp`
 
+**Deprecated:** This function has been replaced with a built-in [`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp) function as of Puppet 6.0.0.
+
 Removes the record separator from the end of a string or an array of strings; for example, 'hello\n' becomes 'hello'.
 
 Arguments: a single string or array.
@@ -541,6 +924,8 @@ Arguments: a single string or array.
 
 #### `chop`
 
+**Deprecated:** This function has been replaced with a built-in [`chop`](https://puppet.com/docs/puppet/latest/function.html#chop) function as of Puppet 6.0.0.
+
 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. To only remove record separators, use the `chomp` function.
 
 Arguments: A string or an array of strings as input.
@@ -557,6 +942,10 @@ Keeps value within the range [Min, X, Max] by sort based on integer value (param
 
 Arguments: strings, arrays, or numerics.
 
+Since Puppet 6.0.0, you can use built-in functions to get the same result:
+
+    [$minval, $maxval, $value_to_clamp].sort[1]
+
 *Type*: rvalue.
 
 #### `concat`
@@ -566,6 +955,12 @@ Appends the contents of multiple arrays onto the first array given. For example:
   * `concat(['1','2','3'],'4')` returns ['1','2','3','4'].
   * `concat(['1','2','3'],'4',['5','6','7'])` returns ['1','2','3','4','5','6','7'].
 
+Since Puppet 4.0, you can use the `+` operator for concatenation of arrays and merge of hashes, and the `<<` operator for appending:
+
+    ['1','2','3'] + ['4','5','6'] + ['7','8','9'] # returns ['1','2','3','4','5','6','7','8','9']
+    [1, 2, 3] << 4 # returns [1, 2, 3, 4]
+    [1, 2, 3] << [4, 5] # returns [1, 2, 3, [4, 5]]
+
 *Type*: rvalue.
 
 #### `convert_base`
@@ -575,9 +970,30 @@ Converts a given integer or base 10 string representing an integer to a specifie
   * `convert_base(5, 2)` results in: '101'
   * `convert_base('254', '16')` results in: 'fe'
 
+Since Puppet 4.5.0, you can do this with the built-in [`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string) function, with various formatting options:
+
+    $binary_repr = String(5, '%b') # results in "101"
+    $hex_repr = String(254, '%x')  # results in "fe"
+    $hex_repr = String(254, '%#x') # results in "0xfe"
+
 #### `count`
 
-If called with only an array, counts the number of elements that are **not** nil or `undef`. If called with a second argument, counts the number of elements in an array that matches the second argument.
+Takes an array as the first argument and an optional second argument.
+It counts the number of elements in an array that is equal to the second argument.
+If called with only an array, it counts the number of elements that are not nil/undef/empty-string.
+
+> **Note**: Equality is tested with a Ruby method. It is subject to what Ruby considers
+to be equal. For strings, equality is case sensitive.
+
+In Puppet core, counting is done using a combination of the built-in functions
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) (since Puppet 4.0.0) and
+[`length`](https://puppet.com/docs/puppet/latest/function.html#length) (since Puppet 5.5.0, before that in stdlib).
+
+This example shows counting values that are not `undef`:
+
+    notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)
+
+Would notice 2.
 
 *Type*: rvalue.
 
@@ -628,6 +1044,24 @@ For example:
 * `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}.
 * `delete(['ab', 'b'], 'b')` returns ['ab'].
 
+Since Puppet 4.0.0, the minus (`-`) operator deletes values from arrays and deletes keys from a hash:
+
+    ['a', 'b', 'c', 'b'] - 'b'
+    # would return ['a', 'c']
+
+    {'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
+    # would return {'a' => '1'}
+
+You can perform a global delete from a string with the built-in
+[`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst) function.
+
+    'abracadabra'.regsubst(/bra/, '', 'G')
+    # would return 'acada'
+
+In general, the built-in
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function
+can filter out entries from arrays and hashes based on a combination of keys and values.
+
 *Type*: rvalue.
 
 #### `delete_at`
@@ -636,6 +1070,19 @@ Deletes a determined indexed value from an array.
 
 For example: `delete_at(['a','b','c'], 1)` returns ['a','c'].
 
+Since Puppet 4, this can be done with the built-in
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
+
+    ['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 } # returns ['a', 'c']
+    ['a', 'b', 'c', 'd'].filter |$pos, $val | { $pos % 2 != 0 } # returns ['b', 'd']
+
+Or, if you want to delete from the beginning or the end of the array — or from both ends at the same time — use the slice operator `[ ]`:
+
+    $array[0, -1] # the same as all the values
+    $array[2, -1] # all but the first 2 elements
+    $array[0, -3] # all but the last 2 elements
+    $array[1, -2] # all but the first and last element
+
 *Type*: rvalue.
 
 #### `delete_regex`
@@ -644,14 +1091,19 @@ Deletes all instances of a given element from an array or hash that match a prov
 
 *Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
 
-
-For example
+For example:
 
 * `delete_regex(['a','b','c','b'], 'b')` returns ['a','c'].
 * `delete_regex({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}.
 * `delete_regex(['abf', 'ab', 'ac'], '^ab.*')` returns ['ac'].
 * `delete_regex(['ab', 'b'], 'b')` returns ['ab'].
 
+Since Puppet 4.0.0, do the equivalent with the built-in
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
+
+    ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ }
+    # Would return: ['aaa', 'aca']
+
 *Type*: rvalue.
 
 #### `delete_values`
@@ -662,6 +1114,12 @@ For example:
 
 * `delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')` returns {'a'=>'A','c'=>'C','B'=>'D'}
 
+Since Puppet 4.0.0, do the equivalent with the built-in
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
+
+    $array.filter |$val| { $val != 'B' }
+    $hash.filter |$key, $val| { $val != 'B' }
+
 *Type*: rvalue.
 
 #### `delete_undef_values`
@@ -672,6 +1130,12 @@ For example:
 
 * `$hash = delete_undef_values({a=>'A', b=>'', c=>`undef`, d => false})` returns {a => 'A', b => '', d => false}.
 
+Since Puppet 4.0.0, do the equivalent with the built-in
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
+
+    $array.filter |$val| { $val =~ NotUndef }
+    $hash.filter |$key, $val| { $val =~ NotUndef }
+
 *Type*: rvalue.
 
 #### `deprecation`
@@ -693,9 +1157,9 @@ Arguments:
 
 Other settings in Puppet affect the stdlib `deprecation` function:
 
-* [`disable_warnings`](https://docs.puppet.com/puppet/latest/reference/configuration.html#disablewarnings)
-* [`max_deprecations`](https://docs.puppet.com/puppet/latest/reference/configuration.html#maxdeprecations)
-* [`strict`](https://docs.puppet.com/puppet/latest/reference/configuration.html#strict):
+* [`disable_warnings`](https://puppet.com/docs/puppet/latest/configuration.html#disablewarnings)
+* [`max_deprecations`](https://puppet.com/docs/puppet/latest/configuration.html#maxdeprecations)
+* [`strict`](https://puppet.com/docs/puppet/latest/configuration.html#strict):
 
     * `error`: Fails immediately with the deprecation message
     * `off`: Output emits no messages.
@@ -719,11 +1183,16 @@ For example:
 
 * `difference(["a","b","c"],["b","c","d"])` returns ["a"].
 
+Since Puppet 4, the minus (`-`) operator in the Puppet language does the same:
+
+    ['a', 'b', 'c'] - ['b', 'c', 'd']
+    # would return ['a']
+
 *Type*: rvalue.
 
 #### `dig`
 
-> DEPRECATED: This function has been replaced with a built-in [`dig`](https://docs.puppet.com/puppet/latest/function.html#dig) function as of Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version.
+**Deprecated:** This function has been replaced with a built-in [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version.
 
 Retrieves a value within multiple layers of hashes and arrays via an array of keys containing a path. The function goes through the structure by each path component and tries to return the value at the end of the path.
 
@@ -819,6 +1288,8 @@ See also [unix2dos](#unix2dos).
 
 #### `downcase`
 
+**Deprecated:** This function has been replaced with a built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function as of Puppet 6.0.0.
+
 Converts the case of a string or of all strings in an array to lowercase.
 
 *Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
@@ -827,6 +1298,8 @@ Converts the case of a string or of all strings in an array to lowercase.
 
 #### `empty`
 
+**Deprecated:** This function has been replaced with a built-in [`empty`](https://puppet.com/docs/puppet/latest/function.html#empty) function as of Puppet 5.5.0.
+
 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.
 
 *Type*: rvalue.
@@ -911,6 +1384,21 @@ userlist:
 ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
 ```
 
+#### `stdlib::extname`
+
+Returns the Extension (the Portion of Filename in Path starting from the last Period).
+
+Example usage:
+
+```puppet
+stdlib::extname('test.rb')       => '.rb'
+stdlib::extname('a/b/d/test.rb') => '.rb'
+stdlib::extname('test')          => ''
+stdlib::extname('.profile')      => ''
+```
+
+*Type*: rvalue.
+
 #### `fact`
 
 Return the value of a given fact. Supports the use of dot-notation for referring to structured facts. If a fact requested does not exist, returns Undef.
@@ -938,6 +1426,8 @@ fact('vmware."VRA.version"')
 
 #### `flatten`
 
+**Deprecated:** This function has been replaced with a built-in [`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten) function as of Puppet 5.5.0.
+
 Flattens deeply nested arrays and returns a single flat array as a result.
 
 For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c'].
@@ -946,6 +1436,8 @@ For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c'].
 
 #### `floor`
 
+**Deprecated:** This function has been replaced with a built-in [`floor`](https://puppet.com/docs/puppet/latest/function.html#floor) function as of Puppet 6.0.0.
+
 Returns the largest integer less than or equal to the argument.
 
 Arguments: A single numeric value.
@@ -1015,30 +1507,53 @@ Returns the absolute path of the specified module for the current environment.
 $module_path = get_module_path('stdlib')
 ```
 
+Since Puppet 5.4.0, the built-in [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory) function does the same thing and will return the path to the first module found, if given multiple values or an array.
+
 *Type*: rvalue.
 
 #### `getparam`
-
 Returns the value of a resource's parameter.
 
 Arguments: A resource reference and the name of the parameter.
 
-For example, the following returns 'param_value':
+> Note: User defined resource types are evaluated lazily.
+
+*Examples:*
 
 ```puppet
+# define a resource type with a parameter
 define example_resource($param) {
 }
 
+# declare an instance of that type
 example_resource { "example_resource_instance":
-  param => "param_value"
+    param => "'the value we are getting in this example''"
 }
 
-getparam(Example_resource["example_resource_instance"], "param")
+# Because of order of evaluation, a second definition is needed
+# that will be evaluated after the first resource has been declared
+#
+define example_get_param {
+  # This will notice the value of the parameter
+  notice(getparam(Example_resource["example_resource_instance"], "param"))
+}
+
+# Declare an instance of the second resource type - this will call notice
+example_get_param { 'show_notify': }
 ```
 
-*Type*: rvalue.
+Would notice: 'the value we are getting in this example'
+
+Since Puppet 4.0.0, you can get a parameter value by using its data type
+and the [ ] operator. The example below is equivalent to a call to getparam():
+
+```puppet
+Example_resource['example_resource_instance']['param']
+```
 
 #### `getvar`
+**Deprecated:** This function has been replaced with a built-in [`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar)
+function as of Puppet 6.0.0. The new version also supports digging into a structured value.
 
 Looks up a variable in a remote namespace.
 
@@ -1077,6 +1592,10 @@ Searches through an array and returns any elements that match the provided regul
 
 For example, `grep(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['aaa','aaaddd'].
 
+Since Puppet 4.0.0, the built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function does the "same" — as any logic can be used to filter, as opposed to just regular expressions:
+
+    ['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }
+
 *Type*: rvalue.
 
 #### `has_interface_with`
@@ -1120,6 +1639,7 @@ Arguments: A string specifying an IP address.
 *Type*: rvalue.
 
 #### `has_key`
+**Deprecated:** This function has been replaced with the built-in operator `in`.
 
 Determines if a hash has a certain key value.
 
@@ -1135,13 +1655,26 @@ if has_key($my_hash, 'key_one') {
 }
 ```
 
+Since Puppet 4.0.0, this can be achieved in the Puppet language with the following equivalent expression:
+
+    $my_hash = {'key_one' => 'value_one'}
+    if 'key_one' in $my_hash {
+      notice('this will be printed')
+    }
+
 *Type*: rvalue.
 
 #### `hash`
 
+**Deprecated:** This function has been replaced with the built-in ability to create a new value of almost any
+data type - see the built-in [`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct) function
+in Puppet.
+
 Converts an array into a hash.
 
-For example, `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}.
+For example (deprecated), `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}.
+
+For example (built-in), `Hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}.
 
 *Type*: rvalue.
 
@@ -1173,12 +1706,12 @@ if $baz.is_a(String) {
 }
 ```
 
-* See the [the Puppet type system](https://docs.puppetlabs.com/latest/type.html#about-resource-types) for more information about types.
-* See the [`assert_type()`](https://docs.puppetlabs.com/latest/function.html#asserttype) function for flexible ways to assert the type of a value.
+* See the [the Puppet type system](https://puppet.com/docs/puppet/latest/lang_data.html) for more information about types.
+* See the [`assert_type()`](https://puppet.com/docs/puppet/latest/function.html#asserttype) function for flexible ways to assert the type of a value.
 
 #### `is_absolute_path`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the given path is absolute.
 
@@ -1186,7 +1719,7 @@ Returns `true` if the given path is absolute.
 
 #### `is_array`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the variable passed to this function is an array.
 
@@ -1194,7 +1727,7 @@ Returns `true` if the variable passed to this function is an array.
 
 #### `is_bool`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the variable passed to this function is a Boolean.
 
@@ -1202,7 +1735,7 @@ Returns `true` if the variable passed to this function is a Boolean.
 
 #### `is_domain_name`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the string passed to this function is a syntactically correct domain name.
 
@@ -1217,7 +1750,7 @@ Returns true if the string passed to this function is a valid email address.
 
 #### `is_float`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the variable passed to this function is a float.
 
@@ -1225,7 +1758,7 @@ Returns `true` if the variable passed to this function is a float.
 
 #### `is_function_available`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Accepts a string as an argument and determines whether the Puppet runtime has access to a function by that name. It returns `true` if the function exists, `false` if not.
 
@@ -1233,7 +1766,7 @@ Accepts a string as an argument and determines whether the Puppet runtime has ac
 
 #### `is_hash`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the variable passed to this function is a hash.
 
@@ -1241,7 +1774,7 @@ Returns `true` if the variable passed to this function is a hash.
 
 #### `is_integer`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the variable returned to this string is an integer.
 
@@ -1249,7 +1782,7 @@ Returns `true` if the variable returned to this string is an integer.
 
 #### `is_ip_address`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the string passed to this function is a valid IP address.
 
@@ -1257,7 +1790,7 @@ Returns `true` if the string passed to this function is a valid IP address.
 
 #### `is_ipv6_address`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the string passed to this function is a valid IPv6 address.
 
@@ -1265,7 +1798,7 @@ Returns `true` if the string passed to this function is a valid IPv6 address.
 
 #### `is_ipv4_address`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the string passed to this function is a valid IPv4 address.
 
@@ -1279,7 +1812,7 @@ Returns `true` if the string passed to this function is a valid MAC address.
 
 #### `is_numeric`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the variable passed to this function is a number.
 
@@ -1287,7 +1820,7 @@ Returns `true` if the variable passed to this function is a number.
 
 #### `is_string`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Returns `true` if the variable passed to this function is a string.
 
@@ -1295,6 +1828,8 @@ Returns `true` if the variable passed to this function is a string.
 
 #### `join`
 
+**Deprecated:** This function has been replaced with a built-in [`join`](https://puppet.com/docs/puppet/latest/function.html#join) function as of Puppet 5.5.0.
+
 Joins an array into a string using a separator. For example, `join(['a','b','c'], ",")` results in: "a,b,c".
 
 *Type*: rvalue.
@@ -1307,16 +1842,24 @@ If a value is an array, the key is prefixed to each element. The return value is
 
 For example, `join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")` results in ["a is 1","b is 2","b is 3"].
 
+Since Puppet 5.0.0, there is more control over the formatting (including indentations and line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual
+formatting of values in the array) - see the
+built-in [`String.new`](https://docs.puppet.com/puppet/latest/function.html#conversion-to-string) function and its formatting options for `Array` and `Hash`.
+
 *Type*: rvalue.
 
 #### `keys`
 
+**Deprecated:** This function has been replaced with a built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys) function as of Puppet 5.5.0.
+
 Returns the keys of a hash as an array.
 
 *Type*: rvalue.
 
 #### `length`
 
+**Deprecated:** This function has been replaced with a built-in [`length`](https://puppet.com/docs/puppet/latest/function.html#length) function as of Puppet 5.5.0.
+
 Returns the length of a given string, array or hash. Replaces the deprecated `size()` function.
 
 *Type*: rvalue.
@@ -1347,6 +1890,8 @@ Loads a JSON file containing an array, string, or hash, and returns the data in
 
 For example:
 
+The first parameter can be an absolute file path, or a URL.
+
 ```puppet
 $myhash = loadjson('/etc/puppet/data/myhash.json')
 ```
@@ -1370,7 +1915,7 @@ $metadata = load_module_metadata('archive')
 notify { $metadata['author']: }
 ```
 
-When a module's metadata file is absent, the catalog compilation fails. To avoid this failure:
+When a module's metadata file is absent, the catalog compilation fails. To avoid this failure, do the following:
 
 ```
 $metadata = load_module_metadata('mysql', true)
@@ -1383,12 +1928,16 @@ if empty($metadata) {
 
 #### `lstrip`
 
+**Deprecated:** This function has been replaced with a built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function as of Puppet 6.0.0.
+
 Strips spaces to the left of a string.
 
 *Type*: rvalue.
 
 #### `max`
 
+**Deprecated:** This function has been replaced with a built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function as of Puppet 6.0.0.
+
 Returns the highest value of all arguments. Requires at least one argument.
 
 Arguments: A numeric or a string representing a number.
@@ -1403,6 +1952,18 @@ For example, `member(['a','b'], 'b')` and `member(['a','b','c'], ['b','c'])` ret
 
 *Note*: This function does not support nested arrays. If the first argument contains nested arrays, it will not recurse through them.
 
+Since Puppet 4.0.0, you can perform the same in the Puppet language. For single values,
+use the operator `in`:
+
+    'a' in ['a', 'b']  # true
+
+And for arrays, use the operator `-` to compute a diff:
+
+    ['d', 'b'] - ['a', 'b', 'c'] == []  # false because 'd' is not subtracted
+    ['a', 'b'] - ['a', 'b', 'c'] == []  # true because both 'a' and 'b' are subtracted
+
+Also note that since Puppet 5.2.0, the general form to test the content of an array or hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any) and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions.
+
 *Type*: rvalue.
 
 #### `merge`
@@ -1421,10 +1982,16 @@ $merged_hash = merge($hash1, $hash2)
 
 When there is a duplicate key, the key in the rightmost hash takes precedence.
 
+Since Puppet 4.0.0, you can use the + operator to achieve the same merge.
+
+    $merged_hash = $hash1 + $hash2
+
 *Type*: rvalue.
 
 #### `min`
 
+**Deprecated:** This function has been replaced with a built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function as of Puppet 6.0.0.
+
 Returns the lowest value of all arguments. Requires at least one argument.
 
 Arguments: A numeric or a string representing a number.
@@ -1433,10 +2000,33 @@ Arguments: A numeric or a string representing a number.
 
 #### `num2bool`
 
-Converts a number or a string representation of a number into a true Boolean. Zero or anything non-numeric becomes `false`. Numbers greater than 0 become `true`.
+Converts a number, or a string representation of a number, into a true Boolean.
+Zero or anything non-numeric becomes `false`.
+Numbers greater than zero become `true`.
+
+Since Puppet 5.0.0, the same can be achieved with the Puppet type system.
+See the [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
+function in Puppet for the many available type conversions.
+
+    Boolean(0) # false
+    Boolean(1) # true
 
 *Type*: rvalue.
 
+#### `os_version_gte`
+
+Checks to see if the OS version is at least a certain version. Note that only the major version is taken into account.
+
+Example usage:
+```
+  if os_version_gte('Debian', '9') { }
+  if os_version_gte('Ubuntu', '18.04') { }
+```
+
+Returns:
+  - Boolean(0) # When OS is below the given version.
+  - Boolean(1) # When OS is equal to or greater than the given version.
+
 #### `parsejson`
 
 Converts a string of JSON into the correct Puppet structure (as a hash, array, string, integer, or a combination of such).
@@ -1482,6 +2072,11 @@ For example:
 * `prefix(['a','b','c'], 'p')` returns ['pa','pb','pc'].
 * `prefix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')` returns {'pa'=>'b','pb'=>'c','pc'=>'d'}.
 
+Since Puppet 4.0.0, modify values in array by using the built-in [`map`](https://docs.puppet.com/puppet/latest/function.html#map) function.
+This example does the same as the first example above:
+
+        ['a', 'b', 'c'].map |$x| { "p${x}" }
+
 *Type*: rvalue.
 
 #### `pry`
@@ -1537,6 +2132,12 @@ Passing a third argument causes the generated range to step by that interval. Fo
 
 * `range("0", "9", "2")` returns ["0","2","4","6","8"].
 
+> Note: The Puppet language supports `Integer` and `Float` ranges by using the type system. They are suitable for iterating a given number of times.
+
+See the built-in [`step`](https://docs.puppet.com/puppet/latest/function.html#step) function in Puppet for skipping values.
+
+    Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9
+
 *Type*: rvalue.
 
 #### `regexpescape`
@@ -1551,20 +2152,32 @@ Searches through an array and rejects all elements that match the provided regul
 
 For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc'].
 
+Since Puppet 4.0.0, the same is true with the built-in [`filter`](https://docs.puppet.com/puppet/latest/function.html#filter) function in Puppet.
+The equivalent of the stdlib `reject` function:
+
+    ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ /aaa/ }
+
 *Type*: rvalue.
 
 #### `reverse`
 
 Reverses the order of a string or array.
 
+> *Note*: The same can be done with the built-in [`reverse_each`](https://docs.puppet.com/puppet/latest/function.html#reverse_each) function in Puppet.
+
+
 #### `round`
 
- Rounds a number to the nearest integer
+**Deprecated:** This function has been replaced with a built-in [`round`](https://puppet.com/docs/puppet/latest/function.html#round) function as of Puppet 6.0.0.
+
+Rounds a number to the nearest integer.
 
 *Type*: rvalue.
 
 #### `rstrip`
 
+**Deprecated:** This function has been replaced with a built-in [`rstrip`](https://puppet.com/docs/puppet/latest/function.html#rstrip) function as of Puppet 6.0.0.
+
 Strips spaces to the right of the string.
 
 *Type*: rvalue.
@@ -1575,6 +2188,10 @@ Takes an integer max value and a string seed value and returns a repeatable rand
 
 *Type*: rvalue.
 
+#### `seeded_rand_string`
+
+Generates a consistent (based on seed value) random string. Useful for generating matching passwords for different hosts.
+
 #### `shell_escape`
 
 Escapes a string so that it can be safely used in a Bourne shell command line. Note that the resulting string should be used unquoted and is not intended for use in either double or single quotes. This function behaves the same as Ruby's `Shellwords.shellescape()` function; see the [Ruby documentation](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellescape).
@@ -1619,17 +2236,39 @@ Randomizes the order of a string or array elements.
 
 #### `size`
 
+**Deprecated:** This function has been replaced with a built-in [`size`](https://puppet.com/docs/puppet/latest/function.html#size) function as of Puppet 6.0.0 (`size` is now an alias for `length`).
+
 Returns the number of elements in a string, an array or a hash. This function will be deprecated in a future release. For Puppet 4, use the `length` function.
 
 *Type*: rvalue.
 
+#### `sprintf_hash`
+
+**Deprecated:** The same functionality can be achieved with the built-in [`sprintf`](https://docs.puppet.com/puppet/latest/function.html#sprintf) function as of Puppet 4.10.10 and 5.3.4. This function will be removed in a future release.
+
+Performs printf-style formatting with named references of text.
+
+The first parameter is a format string describing how to format the rest of the parameters in the hash. See Ruby documentation for [`Kernel::sprintf`](https://ruby-doc.org/core-2.4.2/Kernel.html#method-i-sprintf) for details about this function.
+
+For example:
+
+```puppet
+$output = sprintf_hash('String: %<foo>s / number converted to binary: %<number>b',
+                       { 'foo' => 'a string', 'number' => 5 })
+# $output = 'String: a string / number converted to binary: 101'
+```
+
+*Type*: rvalue
+
 #### `sort`
 
+**Deprecated:** This function has been replaced with a built-in [`sort`](https://puppet.com/docs/puppet/latest/function.html#sort) function as of Puppet 6.0.0.
+
 Sorts strings and arrays lexically.
 
 *Type*: rvalue.
 
-*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
+*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
 
 #### `squeeze`
 
@@ -1641,6 +2280,13 @@ Replaces consecutive repeats (such as 'aaaa') in a string with a single characte
 
 Converts certain strings to a Boolean. This attempts to convert strings that contain the values '1', 'true', 't', 'y', or 'yes' to `true`. Strings that contain values '0', 'false', 'f', 'n', or 'no', or that are an empty string or undefined are converted to `false`. Any other value causes an error. These checks are case insensitive.
 
+Since Puppet 5.0.0, the same can be achieved with the Puppet type system.
+See the [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
+function in Puppet for the many available type conversions.
+
+    Boolean('false'), Boolean('n'), Boolean('no') # all false
+    Boolean('true'), Boolean('y'), Boolean('yes') # all true
+
 *Type*: rvalue.
 
 #### `str2saltedsha512`
@@ -1649,10 +2295,12 @@ Converts a string to a salted-SHA512 password hash, used for OS X versions 10.7
 
 *Type*: rvalue.
 
-*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
+*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
 
 #### `strftime`
 
+**Deprecated:** This function has been replaced with a built-in [`strftime`](https://puppet.com/docs/puppet/latest/function.html#strftime) function as of Puppet 4.8.0.
+
 Returns formatted time.
 
 For example, `strftime("%s")` returns the time since Unix epoch, and `strftime("%Y-%m-%d")` returns the date.
@@ -1661,7 +2309,7 @@ Arguments: A string specifying the time in `strftime` format. See the Ruby [strf
 
 *Type*: rvalue.
 
-*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
+*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
 
 *Format:*
 
@@ -1707,12 +2355,14 @@ Arguments: A string specifying the time in `strftime` format. See the Ruby [strf
 * `%X`: Preferred representation for the time alone, no date
 * `%y`: Year without a century (00..99)
 * `%Y`: Year with century
-* `%z`: Time zone as hour offset from UTC (e.g. +0900)
+* `%z`: Time zone as hour offset from UTC (for example +0900)
 * `%Z`: Time zone name
 * `%%`: Literal '%' character
 
 #### `strip`
 
+**Deprecated:** This function has been replaced with a built-in [`strip`](https://puppet.com/docs/puppet/latest/function.html#strip) function as of Puppet 6.0.0.
+
 Removes leading and trailing whitespace from a string or from every string inside an array. For example, `strip("    aaa   ")` results in "aaa".
 
 *Type*: rvalue.
@@ -1726,6 +2376,10 @@ For example:
 * `suffix(['a','b','c'], 'p')` returns ['ap','bp','cp'].
 * `suffix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')` returns {'ap'=>'b','bp'=>'c','cp'=>'d'}.
 
+Note that since Puppet 4.0.0, you can modify values in an array using the built-in [`map`](https://docs.puppet.com/puppet/latest/function.html#map) function. This example does the same as the first example above:
+
+    ['a', 'b', 'c'].map |$x| { "${x}p" }
+
 *Type*: rvalue.
 
 #### `swapcase`
@@ -1734,7 +2388,7 @@ Swaps the existing case of a string. For example, `swapcase("aBcD")` results in
 
 *Type*: rvalue.
 
-*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
+*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
 
 #### `time`
 
@@ -1742,6 +2396,10 @@ Returns the current Unix epoch time as an integer.
 
 For example, `time()` returns something like '1311972653'.
 
+Since Puppet 4.8.0, the Puppet language has the data types `Timestamp` (a point in time) and `Timespan` (a duration). The following example is equivalent to calling `time()` without any arguments:
+
+    Timestamp()
+
 *Type*: rvalue.
 
 #### `to_bytes`
@@ -1754,9 +2412,33 @@ Arguments: A single string.
 
 *Type*: rvalue.
 
+#### `to_json`
+
+Converts input into a JSON String.
+
+For example, `{ "key" => "value" }` becomes `{"key":"value"}`.
+
+*Type*: rvalue.
+
+#### `to_json_pretty`
+
+Converts input into a pretty JSON String.
+
+For example, `{ "key" => "value" }` becomes `{\n  \"key\": \"value\"\n}`.
+
+*Type*: rvalue.
+
+#### `to_yaml`
+
+Converts input into a YAML String.
+
+For example, `{ "key" => "value" }` becomes `"---\nkey: value\n"`.
+
+*Type*: rvalue.
+
 #### `try_get_value`
 
-**DEPRECATED:** replaced by `dig()`.
+**Deprecated:** Replaced by `dig()`.
 
 Retrieves a value within multiple layers of hashes and arrays.
 
@@ -1805,7 +2487,7 @@ $value = try_get_value($data, 'a|b', [], '|')
 
 #### `type3x`
 
-**Deprecated**. This function will be removed in a future release.
+**Deprecated:** This function will be removed in a future release.
 
 Returns a string description of the type of a given value. The type can be a string, array, hash, float, integer, or Boolean. For Puppet 4, use the new type system instead.
 
@@ -1822,7 +2504,7 @@ Arguments:
 
 #### `type_of`
 
-This function is provided for backwards compatibility, but the built-in [type() function](https://docs.puppet.com/puppet/latest/reference/function.html#type) provided by Puppet is preferred.
+This function is provided for backwards compatibility, but the built-in [type() function](https://puppet.com/docs/puppet/latest/function.html#type) provided by Puppet is preferred.
 
 Returns the literal type of a given value. Requires Puppet 4. Useful for comparison of types with `<=` such as in `if type_of($some_value) <= Array[String] { ... }` (which is equivalent to `if $some_value =~ Array[String] { ... }`).
 
@@ -1861,6 +2543,8 @@ See also [dos2unix](#dos2unix).
 
 #### `upcase`
 
+**Deprecated:** This function has been replaced with a built-in [`upcase`](https://puppet.com/docs/puppet/latest/function.html#upcase) function as of Puppet 6.0.0.
+
 Converts an object, array, or hash of objects to uppercase. Objects to be converted must respond to upcase.
 
 For example, `upcase('abcd')` returns 'ABCD'.
@@ -1877,7 +2561,7 @@ Arguments: Either a single string or an array of strings.
 
 *Type*: rvalue.
 
-*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
+*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater.
 
 #### `validate_absolute_path`
 
@@ -1912,7 +2596,7 @@ validate_absolute_path($undefined)
 
 #### `validate_array`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates that all passed values are array data structures. Terminates catalog compilation if any value fails this check.
 
@@ -1965,7 +2649,7 @@ validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers
 
 #### `validate_bool`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates that all passed values are either `true` or `false`.
 Terminates catalog compilation if any value fails this check.
@@ -2012,7 +2696,7 @@ validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to va
 
 #### `validate_domain_name`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validate that all values passed are syntactically correct domain names. Aborts catalog compilation if any value fails this check.
 
@@ -2059,7 +2743,7 @@ validate_email_address($some_array)
 
 #### `validate_hash`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates that all passed values are hash data structures. Terminates catalog compilation if any value fails this check.
 
@@ -2083,7 +2767,7 @@ validate_hash($undefined)
 
 #### `validate_integer`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates an integer or an array of integers. Terminates catalog compilation if any of the checks fail.
 
@@ -2143,7 +2827,7 @@ validate_integer(1, 3, true)
 
 #### `validate_ip_address`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates that the argument is an IP address, regardless of whether it is an IPv4 or an IPv6 address. It also validates IP address with netmask.
 
@@ -2190,7 +2874,7 @@ Arguments:
 Example:
 
 ```puppet
-validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."])
+validate_legacy('Optional[String]', 'validate_re', 'Value to be validated', ["."])
 ```
 
 This function supports updating modules from Puppet 3-style argument validation (using the stdlib `validate_*` functions) to Puppet 4 data types, without breaking functionality for those depending on Puppet 3-style validation.
@@ -2201,7 +2885,7 @@ This function supports updating modules from Puppet 3-style argument validation
 
 If you are running Puppet 4, the `validate_legacy` function can help you find and resolve deprecated Puppet 3 `validate_*` functions. These functions are deprecated as of stdlib version 4.13 and will be removed in a future version of stdlib.
 
-Puppet 4 allows improved defined type checking using [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html). Data types avoid some of the problems with Puppet 3's `validate_*` functions, which were sometimes inconsistent. For example, [validate_numeric](#validate_numeric) unintentionally allowed not only numbers, but also arrays of numbers or strings that looked like numbers.
+Puppet 4 allows improved defined type checking using [data types](https://puppet.com/docs/puppet/latest/lang_data.html). Data types avoid some of the problems with Puppet 3's `validate_*` functions, which were sometimes inconsistent. For example, [validate_numeric](#validate_numeric) unintentionally allowed not only numbers, but also arrays of numbers or strings that looked like numbers.
 
 If you run Puppet 4 and use modules with deprecated `validate_*` functions, you might encounter deprecation messages. The `validate_legacy` function makes these differences visible and makes it easier to move to the clearer Puppet 4 syntax.
 
@@ -2216,7 +2900,7 @@ The deprecation messages you get can vary, depending on the modules and data tha
 
 The `validate_legacy` function helps you move from Puppet 3 style validation to Puppet 4 validation without breaking functionality your module's users depend on.
 
-Moving to Puppet 4 type validation allows much better defined type checking using [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html). Many of Puppet 3's `validate_*` functions have surprising holes in their validation. For example, [validate_numeric](#validate_numeric) allows not only numbers, but also arrays of numbers or strings that look like numbers, without giving you any control over the specifics.
+Moving to Puppet 4 type validation allows much better defined type checking using [data types](https://puppet.com/docs/puppet/latest/lang_data.html). Many of Puppet 3's `validate_*` functions have surprising holes in their validation. For example, [validate_numeric](#validate_numeric) allows not only numbers, but also arrays of numbers or strings that look like numbers, without giving you any control over the specifics.
 
 For each parameter of your classes and defined types, choose a new Puppet 4 data type to use. In most cases, the new data type allows a different set of values than the original `validate_*` function. The situation then looks like this:
 
@@ -2259,7 +2943,7 @@ Always note such changes in your CHANGELOG and README.
 
 #### `validate_numeric`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates a numeric value, or an array or string of numeric values. Terminates catalog compilation if any of the checks fail.
 
@@ -2277,7 +2961,7 @@ For passing and failing usage, see [`validate_integer`](#validate-integer). The
 
 #### `validate_re`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Performs simple validation of a string against one or more regular expressions.
 
@@ -2318,7 +3002,7 @@ To force stringification, use quotes:
 
 #### `validate_slength`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates that a string (or an array of strings) is less than or equal to a specified length
 
@@ -2348,7 +3032,7 @@ validate_slength(["discombobulate","moo"],17,10)
 
 #### `validate_string`
 
-**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).
 
 Validates that all passed values are string data structures. Aborts catalog compilation if any value fails this check.
 
@@ -2366,7 +3050,7 @@ validate_string(true)
 validate_string([ 'some', 'array' ])
 ```
 
-*Note:* validate_string(`undef`) will not fail in this version of the functions API.
+*Note:* validate_string(`undef`) will not fail in this version of the functions API.
 
 Instead, use:
 
@@ -2398,6 +3082,8 @@ validate_x509_rsa_key_pair($cert, $key)
 
 #### `values`
 
+**Deprecated:** This function has been replaced with a built-in [`values`](https://puppet.com/docs/puppet/latest/function.html#values) function as of Puppet 5.5.0.
+
 Returns the values of a given hash.
 
 For example, given `$hash = {'a'=1, 'b'=2, 'c'=3} values($hash)` returns [1,2,3].
@@ -2422,35 +3108,37 @@ For example:
 * `values_at(['a','b','c'], ["0-1"])` returns ['a','b'].
 * `values_at(['a','b','c','d','e'], [0, "2-3"])` returns ['a','c','d'].
 
+Since Puppet 4.0.0, you can slice an array with index and count directly in the language.
+A negative value is taken to be "from the end" of the array, for example:
+
+```puppet
+['a', 'b', 'c', 'd'][1, 2]   # results in ['b', 'c']
+['a', 'b', 'c', 'd'][2, -1]  # results in ['c', 'd']
+['a', 'b', 'c', 'd'][1, -2]  # results in ['b', 'c']
+```
+
 *Type*: rvalue.
 
 #### `zip`
 
 Takes one element from first array given and merges corresponding elements from second array given. This generates a sequence of n-element arrays, where *n* is one more than the count of arguments. For example, `zip(['1','2','3'],['4','5','6'])` results in ["1", "4"], ["2", "5"], ["3", "6"]. *Type*: rvalue.
 
+<a id="limitations"></a>
 ## Limitations
 
 As of Puppet Enterprise 3.7, the stdlib module is no longer included in PE. PE users should install the most recent release of stdlib for compatibility with Puppet modules.
 
-### Version Compatibility
-
-Versions | Puppet 2.6 | Puppet 2.7 | Puppet 3.x | Puppet 4.x |
-:---------------|:-----:|:---:|:---:|:----:
-**stdlib 2.x**  | **yes** | **yes** | no | no
-**stdlib 3.x**  | no    | **yes**  | **yes** | no
-**stdlib 4.x**  | no    | **yes**  | **yes** | no
-**stdlib 4.6+**  | no    | **yes**  | **yes** | **yes**
-**stdlib 5.x**  | no    | no  | **yes**  | **yes**
-
-**stdlib 5.x**: When released, stdlib 5.x will drop support for Puppet 2.7.x. Please see [this discussion](https://github.com/puppetlabs/puppetlabs-stdlib/pull/176#issuecomment-30251414).
+For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/metadata.json)
 
+<a id="development"></a>
 ## Development
 
-Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://docs.puppetlabs.com/forge/contributing.html).
+Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://docs.puppet.com/forge/contributing.html).
 
 To report or research a bug with any part of this module, please go to
 [http://tickets.puppetlabs.com/browse/MODULES](http://tickets.puppetlabs.com/browse/MODULES).
 
+<a id="contributors"></a>
 ## Contributors
 
 The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors](https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors).
index d12d854..2d60dbb 100644 (file)
@@ -1,37 +1,77 @@
 require 'puppetlabs_spec_helper/rake_tasks'
-require 'puppet-lint/tasks/puppet-lint'
+require 'puppet-syntax/tasks/puppet-syntax'
 require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
+require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
+require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
+require 'puppet-lint/tasks/puppet-lint'
 
-PuppetLint.configuration.fail_on_warnings = true
-PuppetLint.configuration.send('relative')
+def changelog_user
+  return unless Rake.application.top_level_tasks.include? "changelog"
+  returnVal = nil || JSON.load(File.read('metadata.json'))['author']
+  raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
+  puts "GitHubChangelogGenerator user:#{returnVal}"
+  returnVal
+end
 
-desc 'Generate pooler nodesets'
-task :gen_nodeset do
-  require 'beaker-hostgenerator'
-  require 'securerandom'
-  require 'fileutils'
+def changelog_project
+  return unless Rake.application.top_level_tasks.include? "changelog"
+  returnVal = nil || JSON.load(File.read('metadata.json'))['name']
+  raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
+  puts "GitHubChangelogGenerator project:#{returnVal}"
+  returnVal
+end
 
-  agent_target = ENV['TEST_TARGET']
-  if ! agent_target
-    STDERR.puts 'TEST_TARGET environment variable is not set'
-    STDERR.puts 'setting to default value of "redhat-64default."'
-    agent_target = 'redhat-64default.'
-  end
+def changelog_future_release
+  return unless Rake.application.top_level_tasks.include? "changelog"
+  returnVal = JSON.load(File.read('metadata.json'))['version']
+  raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
+  puts "GitHubChangelogGenerator future_release:#{returnVal}"
+  returnVal
+end
 
-  master_target = ENV['MASTER_TEST_TARGET']
-  if ! master_target
-    STDERR.puts 'MASTER_TEST_TARGET environment variable is not set'
-    STDERR.puts 'setting to default value of "redhat7-64mdcl"'
-    master_target = 'redhat7-64mdcl'
-  end
+PuppetLint.configuration.send('disable_relative')
 
-  targets = "#{master_target}-#{agent_target}"
-  cli = BeakerHostGenerator::CLI.new([targets])
-  nodeset_dir = "tmp/nodesets"
-  nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml"
-  FileUtils.mkdir_p(nodeset_dir)
-  File.open(nodeset, 'w') do |fh|
-    fh.print(cli.execute)
+if Bundler.rubygems.find_name('github_changelog_generator').any?
+  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
+    raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
+    config.user = "#{changelog_user}"
+    config.project = "#{changelog_project}"
+    config.future_release = "#{changelog_future_release}"
+    config.exclude_labels = ['maintenance']
+    config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
+    config.add_pr_wo_labels = true
+    config.issues = false
+    config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
+    config.configure_sections = {
+      "Changed" => {
+        "prefix" => "### Changed",
+        "labels" => ["backwards-incompatible"],
+      },
+      "Added" => {
+        "prefix" => "### Added",
+        "labels" => ["feature", "enhancement"],
+      },
+      "Fixed" => {
+        "prefix" => "### Fixed",
+        "labels" => ["bugfix"],
+      },
+    }
+  end
+else
+  desc 'Generate a Changelog from GitHub'
+  task :changelog do
+    raise <<EOM
+The changelog tasks depends on unreleased features of the github_changelog_generator gem.
+Please manually add it to your .sync.yml for now, and run `pdk update`:
+---
+Gemfile:
+  optional:
+    ':development':
+      - gem: 'github_changelog_generator'
+        git: 'https://github.com/skywinder/github-changelog-generator'
+        ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
+        condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
+EOM
   end
-  puts nodeset
 end
+
index 7e05880..e10ba3b 100644 (file)
@@ -1,52 +1,55 @@
+---
 version: 1.1.x.{build}
+branches:
+  only:
+    - master
 skip_commits:
   message: /^\(?doc\)?.*/
 clone_depth: 10
 init:
-- SET
-- 'mkdir C:\ProgramData\PuppetLabs\code && exit 0'
-- 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0'
-- 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0'
-- 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0'
+  - SET
+  - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0'
+  - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0'
+  - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0'
+  - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0'
 environment:
   matrix:
-  - PUPPET_GEM_VERSION: ~> 4.0
-    RUBY_VER: 21
-  - PUPPET_GEM_VERSION: ~> 4.0
-    RUBY_VER: 21-x64
-  - PUPPET_GEM_VERSION: ~> 5.0
-    RUBY_VER: 24
-  - PUPPET_GEM_VERSION: ~> 5.0
-    RUBY_VER: 24-x64
-  - PUPPET_GEM_VERSION: 4.7.1
-    RUBY_VER: 21-x64
+    -
+      RUBY_VERSION: 24-x64
+      CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
+    -
+      PUPPET_GEM_VERSION: ~> 5.0
+      RUBY_VERSION: 24
+      CHECK: parallel_spec
+    -
+      PUPPET_GEM_VERSION: ~> 5.0
+      RUBY_VERSION: 24-x64
+      CHECK: parallel_spec
+    -
+      PUPPET_GEM_VERSION: ~> 6.0
+      RUBY_VERSION: 25
+      CHECK: parallel_spec
+    -
+      PUPPET_GEM_VERSION: ~> 6.0
+      RUBY_VERSION: 25-x64
+      CHECK: parallel_spec
 matrix:
   fast_finish: true
 install:
-- SET PATH=C:\Ruby%RUBY_VER%\bin;%PATH%
-- ps: |
-    # AppVeyor appears to have OpenSSL headers available already
-    # which msys2 would normally install with:
-    # pacman -S mingw-w64-x86_64-openssl --noconfirm
-    #
-    if ( $(ruby --version) -match "^ruby\s+2\.4" ) {
-      Write-Output "Building OpenSSL gem ~> 2.0.4 to fix Ruby 2.4 / AppVeyor issue"
-      gem install openssl --version '~> 2.0.4' --no-ri --no-rdoc
-    }
-
-    gem list openssl
-    ruby -ropenssl -e 'puts \"OpenSSL Version - #{OpenSSL::OPENSSL_VERSION}\"; puts \"OpenSSL Library Version - #{OpenSSL::OPENSSL_LIBRARY_VERSION}\"'
-- bundle install --jobs 4 --retry 2 --without system_tests
-- type Gemfile.lock
+  - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
+  - bundle install --jobs 4 --retry 2 --without system_tests
+  - type Gemfile.lock
 build: off
 test_script:
-- bundle exec puppet -V
-- ruby -v
-- bundle exec rake spec SPEC_OPTS='--format documentation'
+  - bundle exec puppet -V
+  - ruby -v
+  - gem -v
+  - bundle -v
+  - bundle exec rake %CHECK%
 notifications:
-- provider: Email
-  to:
-  - nobody@nowhere.com
-  on_build_success: false
-  on_build_failure: false
-  on_build_status_changed: false
+  - provider: Email
+    to:
+      - nobody@nowhere.com
+    on_build_success: false
+    on_build_failure: false
+    on_build_status_changed: false
index 6fd8771..ac4b535 100644 (file)
 {
-  "CHANGELOG.md": "fac876d70b44f0d961af9d90a7a59216",
-  "CONTRIBUTING.md": "77d0440d7cd4206497f99065c60bed46",
-  "Gemfile": "99e30e5e231f5f2b460b812c37d084f7",
+  "CHANGELOG.md": "ef7ba4bf3e7b05133b8b6f360d184d3c",
+  "CONTRIBUTING.md": "4d17f3c942e7c93d1577cc4438a231e4",
+  "Gemfile": "3864447c01e8ca140685b2f085f2d262",
+  "HISTORY.md": "6b78ee53e5d501d081c45c5ee8f604e1",
   "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57",
   "MAINTAINERS.md": "b40ec4f2c16145af6f723c2c34bb2ff9",
   "NOTICE": "b2e552587e5969886fdd60481e8b0351",
-  "README.md": "cee15bd22180e5b74fac7864c45d6d1e",
+  "README.md": "1b6e0b411dea04156265364ba854742e",
   "README_DEVELOPER.markdown": "220a8b28521b5c5d2ea87c4ddb511165",
   "README_SPECS.markdown": "82bb4c6abbb711f40778b162ec0070c1",
   "RELEASE_PROCESS.markdown": "94b92bc99ac4106ba1a74d5c04e520f9",
-  "Rakefile": "3851f083966b9bbd6d46e50dba5aa52a",
-  "appveyor.yml": "5bad9cb8e861bca53eeea6247eec5c60",
+  "Rakefile": "5df4774149839a995ed5681f6545b6ff",
+  "appveyor.yml": "941f3c7018fe10bd2df05cbd0a9f0339",
   "examples/file_line.pp": "d8126b139dd1dce21ff26910d1c5a245",
   "examples/has_interface_with.pp": "d69d520cf3ff4d0b495480afaca359ef",
   "examples/has_ip_address.pp": "32f42575e49aa66f0f2398a70ae2a9f4",
   "examples/has_ip_network.pp": "bfb8db068c58d77c4dd7ae9697536537",
   "examples/init.pp": "b52fd907330ddbd9c3e070cf39f7b317",
-  "lib/facter/facter_dot_d.rb": "d71e93183a680ac78bc0389fd50470a0",
-  "lib/facter/package_provider.rb": "539766a71dfb2f65e94a7c91bf413fcf",
-  "lib/facter/pe_version.rb": "60d47406026c8201e51394227ddf780d",
-  "lib/facter/puppet_settings.rb": "9438c0839ae28dc52fffb8348ae5124f",
-  "lib/facter/root_home.rb": "35702ae0c7410ec4d2101113e2f697fa",
+  "lib/facter/facter_dot_d.rb": "9f65108ecd7b8c5ce9c90ab4cd9d45be",
+  "lib/facter/package_provider.rb": "12d57e65f9b90c13e7808c347fbdc0b0",
+  "lib/facter/pe_version.rb": "245bb8ea121e8a55e1a38668cc480530",
+  "lib/facter/puppet_settings.rb": "d86bacf2b962a4744b701868cda31729",
+  "lib/facter/root_home.rb": "b384092f0470b9e2177edaf546de2ec1",
   "lib/facter/service_provider.rb": "66cc42526eae631e306b397391f1f01c",
-  "lib/facter/util/puppet_settings.rb": "9f1d2593d0ae56bfca89d4b9266aeee1",
-  "lib/puppet/functions/deprecation.rb": "59b803eaa15b5a559040497bffc172ae",
-  "lib/puppet/functions/fact.rb": "367379bc8c0d29cc2ffceb4f4d7f9f1c",
-  "lib/puppet/functions/is_a.rb": "9dad7f8c9b75348cd97aca986ac0b29a",
-  "lib/puppet/functions/is_absolute_path.rb": "96b217f26d06dbac87a2c6a8cfd2d8c8",
-  "lib/puppet/functions/is_array.rb": "9292a646010d167417a1936b0b0c17b9",
-  "lib/puppet/functions/is_bool.rb": "73957f9efd75ed8a7ab867f9de6da117",
-  "lib/puppet/functions/is_float.rb": "af3bd6bb56878bac8cc4fe4f7564e4f9",
-  "lib/puppet/functions/is_ip_address.rb": "ee231c66c3e039778bf46702d89815a6",
-  "lib/puppet/functions/is_ipv4_address.rb": "900d33249906c4daa02aa79cac896548",
-  "lib/puppet/functions/is_ipv6_address.rb": "568fba9af6a83c8b536fafcda82eb448",
-  "lib/puppet/functions/is_numeric.rb": "33051800b886cc3b2119826b77c9821a",
-  "lib/puppet/functions/is_string.rb": "230e9eabc5c9e1d8d5fb7b3c6c12b300",
-  "lib/puppet/functions/length.rb": "03cf801867a919f801d290424fd2bb8d",
-  "lib/puppet/functions/type_of.rb": "bec00841aae556993c926ab298bc81cd",
-  "lib/puppet/functions/validate_absolute_path.rb": "54a610baa115c7505f1b35976b632a8e",
-  "lib/puppet/functions/validate_array.rb": "9052b0026da174636c276a2512cf5acc",
-  "lib/puppet/functions/validate_bool.rb": "fe979e402a5a3a19d013ce84b39ef06a",
-  "lib/puppet/functions/validate_hash.rb": "92ea8fc21bbbf6cc41f6bb9cfcaefce7",
-  "lib/puppet/functions/validate_integer.rb": "b0982b68a599262da2c6f2e032bc7713",
-  "lib/puppet/functions/validate_ip_address.rb": "65a12af9a2c2a9c70d820d04d19ec891",
-  "lib/puppet/functions/validate_ipv4_address.rb": "4a5039b99ac97cc0447faa343b9f7416",
-  "lib/puppet/functions/validate_ipv6_address.rb": "fbdf685432416505fed27d5647c26f9c",
-  "lib/puppet/functions/validate_legacy.rb": "d9f115f30c511cef536a821b94826094",
-  "lib/puppet/functions/validate_numeric.rb": "41b2cc7335395f617c2bfbeac8f579da",
-  "lib/puppet/functions/validate_re.rb": "42092f592ebf89b8a504b10c900230d8",
-  "lib/puppet/functions/validate_slength.rb": "3ae6fcc3f60032c923d06ab3e457b84e",
-  "lib/puppet/functions/validate_string.rb": "cc967a9d0ea156b2208d1760d7f6e1b2",
-  "lib/puppet/parser/functions/abs.rb": "a8e46ecf4fb378d314916599651cebe5",
-  "lib/puppet/parser/functions/any2array.rb": "a81e71d6b67a551d38770ba9a1948a75",
-  "lib/puppet/parser/functions/any2bool.rb": "8bbb74cb81ebdb164e1965415364080b",
-  "lib/puppet/parser/functions/assert_private.rb": "cb9cd79ed4e3d647a48467dfb6237d5c",
-  "lib/puppet/parser/functions/base64.rb": "0d121a32fbfe25b06a4e91b0259af91d",
-  "lib/puppet/parser/functions/basename.rb": "c61952b3f68fd86408c84fca2c3febb1",
-  "lib/puppet/parser/functions/bool2num.rb": "01b070b02611fda7e1491de0a8cd89fc",
-  "lib/puppet/parser/functions/bool2str.rb": "c00885242abf381ba482644ded70b688",
-  "lib/puppet/parser/functions/camelcase.rb": "bd5da699dfe1ec27ffe91b06187c5900",
-  "lib/puppet/parser/functions/capitalize.rb": "c94c50b0f147a22861c3b93c724e4343",
-  "lib/puppet/parser/functions/ceiling.rb": "7de4a96c8bb645fd5ce5c38438667228",
-  "lib/puppet/parser/functions/chomp.rb": "35a16c85bc59dc285baae631da1ae771",
-  "lib/puppet/parser/functions/chop.rb": "3beb80906fa3c759945a2664fe510b20",
-  "lib/puppet/parser/functions/clamp.rb": "6920e6c11b575fc65dadb21220c01a7a",
-  "lib/puppet/parser/functions/concat.rb": "d10e5428917895d4bb90c638b148b7fa",
-  "lib/puppet/parser/functions/convert_base.rb": "c3b3e59a49318af98dcb88aed7156629",
-  "lib/puppet/parser/functions/count.rb": "325bbd89a29e6ed0f31e0462d0a0d301",
-  "lib/puppet/parser/functions/deep_merge.rb": "d83696855578fb81b64b9e92b9c7cc7c",
-  "lib/puppet/parser/functions/defined_with_params.rb": "2d964410afbee415446c94d9692a2112",
-  "lib/puppet/parser/functions/delete.rb": "7af1540fee4285d93b6b28fb490db70a",
-  "lib/puppet/parser/functions/delete_at.rb": "a2cba60ac86a676d4ed1ff846a917014",
-  "lib/puppet/parser/functions/delete_regex.rb": "91cd012ef5a636ffe541814ed232b909",
-  "lib/puppet/parser/functions/delete_undef_values.rb": "52beef9ee37f84ed2278a69ec4383125",
-  "lib/puppet/parser/functions/delete_values.rb": "b410f5618b4a6158a921acb7b2dc628d",
-  "lib/puppet/parser/functions/deprecation.rb": "4323210434d36e37977251f906a232b8",
-  "lib/puppet/parser/functions/difference.rb": "467e44aeaebd0ee0a51c8b89e3769f1f",
-  "lib/puppet/parser/functions/dig.rb": "1a2a8918f646c13dcb9876a22f9295ab",
-  "lib/puppet/parser/functions/dig44.rb": "3078b97ee941c261944857373d400ed6",
-  "lib/puppet/parser/functions/dirname.rb": "8a5579f9a9a13fd737ba65eccf8e6d5a",
-  "lib/puppet/parser/functions/dos2unix.rb": "be8359a5106a7832be4180e8207dd586",
-  "lib/puppet/parser/functions/downcase.rb": "02376505a00accd0ce6b148f869c9c86",
-  "lib/puppet/parser/functions/empty.rb": "6d7d2dde2971f6a40fa913f0af1c610c",
-  "lib/puppet/parser/functions/enclose_ipv6.rb": "ec39936a9a51dc5cb8ada6eeb829b239",
-  "lib/puppet/parser/functions/ensure_packages.rb": "cd540ecd9c56321e856919f0c93de2a7",
-  "lib/puppet/parser/functions/ensure_resource.rb": "de703fe63392b939fc2b4392975263de",
-  "lib/puppet/parser/functions/ensure_resources.rb": "c92d8b69d6354eda24aa3a13d88177b2",
-  "lib/puppet/parser/functions/flatten.rb": "6a27f5b922a24fec6e823f6f51c98090",
-  "lib/puppet/parser/functions/floor.rb": "07ba3b1662a14c60fe908b51231355ee",
-  "lib/puppet/parser/functions/fqdn_rand_string.rb": "9ac5f18e563094aee62ef7586267025d",
-  "lib/puppet/parser/functions/fqdn_rotate.rb": "2483d17df4e6cb25d92b4e8520f30957",
-  "lib/puppet/parser/functions/fqdn_uuid.rb": "d357e8837ba2ed8196e926f3697be521",
-  "lib/puppet/parser/functions/get_module_path.rb": "d4bf50da25c0b98d26b75354fa1bcc45",
-  "lib/puppet/parser/functions/getparam.rb": "440a9c381b9ad589504e2e9919e83c06",
-  "lib/puppet/parser/functions/getvar.rb": "0c8c5cef7e158e232a8cf6e42c10d0ff",
-  "lib/puppet/parser/functions/glob.rb": "c4106d2aff24f4b5a32b54bf4cd452a2",
-  "lib/puppet/parser/functions/grep.rb": "c2f2dbdf79d16584579c3a7bc7b5902f",
-  "lib/puppet/parser/functions/has_interface_with.rb": "db65f5aac94e8fe105c7ca0cd1f66403",
-  "lib/puppet/parser/functions/has_ip_address.rb": "6ce9e6cdfb499b6ce86bf531848a18be",
-  "lib/puppet/parser/functions/has_ip_network.rb": "3cc7b923fd3cde5062ed9d0eaaa8155f",
-  "lib/puppet/parser/functions/has_key.rb": "7cd9728c38f0b0065f832dabd62b0e7e",
-  "lib/puppet/parser/functions/hash.rb": "c1ebb21cc5b984153a87c252a9854db2",
-  "lib/puppet/parser/functions/intersection.rb": "87469eb81ab00bbacfd744165beeaeec",
-  "lib/puppet/parser/functions/is_absolute_path.rb": "1ce9a6d1cd0a79087d73cb879ed04542",
-  "lib/puppet/parser/functions/is_array.rb": "bbce6768b688bc0f36978ecb0f60f7f4",
-  "lib/puppet/parser/functions/is_bool.rb": "b8800ff7a11b4e8c03616041e218225f",
-  "lib/puppet/parser/functions/is_domain_name.rb": "5c6106c070945a605c5adbd1852f0691",
-  "lib/puppet/parser/functions/is_email_address.rb": "1eb786779743e93a7bb9fe8087b38b8d",
-  "lib/puppet/parser/functions/is_float.rb": "6257620b98c5099293be7aa4088b88ce",
-  "lib/puppet/parser/functions/is_function_available.rb": "f13934d6b41561ef54d88cf0da86231b",
-  "lib/puppet/parser/functions/is_hash.rb": "6f1ccf659c41cb5dab4db9fa89f0b364",
-  "lib/puppet/parser/functions/is_integer.rb": "a4ae475a5a799c0cc46519e86aed2973",
-  "lib/puppet/parser/functions/is_ip_address.rb": "2eabe60c213df2e642a03ebfd4852497",
-  "lib/puppet/parser/functions/is_ipv4_address.rb": "ab854b47367921f657410fbe79054f0b",
-  "lib/puppet/parser/functions/is_ipv6_address.rb": "2a2be7adbdd5ca23c3e21f00d7d8bac7",
-  "lib/puppet/parser/functions/is_mac_address.rb": "1af27510d3b9b936384192a4e1dfbf8c",
-  "lib/puppet/parser/functions/is_numeric.rb": "bfd99f39e2506953ad00178db6fa07ea",
-  "lib/puppet/parser/functions/is_string.rb": "c1405dd293e9e3c738b83c4ef5aab1ef",
-  "lib/puppet/parser/functions/join.rb": "2ed4f56d296a4535da142e01b11a126d",
-  "lib/puppet/parser/functions/join_keys_to_values.rb": "71ad24ac1809739713c461141aedd082",
-  "lib/puppet/parser/functions/keys.rb": "c10485a3d6c53b6d57a891b9852898de",
-  "lib/puppet/parser/functions/load_module_metadata.rb": "805c5476a6e7083d133e167129885924",
-  "lib/puppet/parser/functions/loadjson.rb": "ffecf61ba2ec8011915d37009b1a273e",
-  "lib/puppet/parser/functions/loadyaml.rb": "668265f14327cba1d1400f2078b7b26b",
-  "lib/puppet/parser/functions/lstrip.rb": "e9cbd5c2233233940e7344478362fb9f",
-  "lib/puppet/parser/functions/max.rb": "529eb6ac3d88c03caa788167594bd487",
-  "lib/puppet/parser/functions/member.rb": "03d618926bbb9efd117950e6078c3878",
-  "lib/puppet/parser/functions/merge.rb": "f3dcc5c83440cdda2036cce69b61a14b",
-  "lib/puppet/parser/functions/min.rb": "8d829c8a55c9330ab02f962926221d4f",
-  "lib/puppet/parser/functions/num2bool.rb": "ddb603cf74f92e16a00f1447a4403429",
-  "lib/puppet/parser/functions/parsejson.rb": "15165fd3807d9f3d657697fa854d643d",
-  "lib/puppet/parser/functions/parseyaml.rb": "db54578d9d798ced75952217cf11b737",
-  "lib/puppet/parser/functions/pick.rb": "bf01f13bbfe2318e7f6a302ac7c4433f",
-  "lib/puppet/parser/functions/pick_default.rb": "ad3ea60262de408767786d37a54d45dc",
-  "lib/puppet/parser/functions/prefix.rb": "ece9341c5b232a25c58545718a54e92f",
-  "lib/puppet/parser/functions/private.rb": "1500a21d5cf19961c5b1d476df892d92",
-  "lib/puppet/parser/functions/pry.rb": "79a48e45196e4bbf0a3e658781513cf4",
-  "lib/puppet/parser/functions/pw_hash.rb": "312a8d91cdc1776de4825bc304b9c1bd",
-  "lib/puppet/parser/functions/range.rb": "ab19430b6b9737cf56263eb65d80cba1",
-  "lib/puppet/parser/functions/regexpescape.rb": "6378fdd413237a37c322859877147a50",
-  "lib/puppet/parser/functions/reject.rb": "689f6a7c961a55fe9dcd240921f4c7f9",
-  "lib/puppet/parser/functions/reverse.rb": "209e7ef512963251571c515e2d0aee10",
-  "lib/puppet/parser/functions/round.rb": "45d0883545b7e7bc219664c0020a1d9f",
-  "lib/puppet/parser/functions/rstrip.rb": "f3226709247741825f07d9ec20bd3887",
-  "lib/puppet/parser/functions/seeded_rand.rb": "2ad22e7613d894ae779c0c5b0e65dade",
-  "lib/puppet/parser/functions/shell_escape.rb": "13662933244e1af42ddca71ced4ac9e5",
-  "lib/puppet/parser/functions/shell_join.rb": "b99a23d5e62e2e1b98accde5c22e45c9",
-  "lib/puppet/parser/functions/shell_split.rb": "5317d71f3a7e293624b57aaca23f57d5",
-  "lib/puppet/parser/functions/shuffle.rb": "6c0555524ebc9ed5dd8295b836fb7163",
-  "lib/puppet/parser/functions/size.rb": "c171d46b87e377ebcc710ad5a5925a2b",
-  "lib/puppet/parser/functions/sort.rb": "0b7d1411decc4a92450828809fad0779",
-  "lib/puppet/parser/functions/squeeze.rb": "403ea46228a8e45e89c91168ed301fb6",
-  "lib/puppet/parser/functions/str2bool.rb": "ff82f179970a9429614bd37fa7a1ae2a",
-  "lib/puppet/parser/functions/str2saltedsha512.rb": "457ab12e4329494ae6276cfa4f20eb23",
-  "lib/puppet/parser/functions/strftime.rb": "8f15e2e3732b6d1d357a1fa1826800d4",
-  "lib/puppet/parser/functions/strip.rb": "da0ce253cb63a4863f15f9d145217db5",
-  "lib/puppet/parser/functions/suffix.rb": "1ce493098f17ea47e9435f994adbc6cd",
-  "lib/puppet/parser/functions/swapcase.rb": "48cad9bf415b5d79584c8e17ab7a06cc",
-  "lib/puppet/parser/functions/time.rb": "cd96d1f039f8875af083091e3637190b",
-  "lib/puppet/parser/functions/to_bytes.rb": "45248fd0bba8cfb24eac830fc0add17a",
-  "lib/puppet/parser/functions/try_get_value.rb": "09cd079ec5f0e5e2ac862c9ebe0f54fe",
-  "lib/puppet/parser/functions/type.rb": "4709f7ab8a8aad62d77a3c5d91a3aa08",
-  "lib/puppet/parser/functions/type3x.rb": "5d0391205bd1cfe8de985a44e8c3e8a9",
-  "lib/puppet/parser/functions/union.rb": "c02fca3fe102875ba020072b7edee532",
-  "lib/puppet/parser/functions/unique.rb": "845c10b6703714ff41397543c84f585d",
-  "lib/puppet/parser/functions/unix2dos.rb": "b1f5087fcaca69d9395094204cce887a",
-  "lib/puppet/parser/functions/upcase.rb": "e875fc4f03adec1ff3b42d22f177441e",
-  "lib/puppet/parser/functions/uriescape.rb": "ba78def2cd0e60bdc4412df6c7b891ec",
-  "lib/puppet/parser/functions/validate_absolute_path.rb": "c4b12e101055380386a235cd2c92ad10",
-  "lib/puppet/parser/functions/validate_array.rb": "bee8327014714d4cd8dbb5c46611f594",
-  "lib/puppet/parser/functions/validate_augeas.rb": "61e828e7759ba3e1e563e1fdd68aa80f",
-  "lib/puppet/parser/functions/validate_bool.rb": "971700229c4b581f67f6fadc9019eb2c",
-  "lib/puppet/parser/functions/validate_cmd.rb": "7df12370db442eddddcf4dd7a5364b5e",
-  "lib/puppet/parser/functions/validate_domain_name.rb": "889ec82b0893ea780c915d5155dae5fd",
-  "lib/puppet/parser/functions/validate_email_address.rb": "a72656cbfeda622cdd5cfdafdf464095",
-  "lib/puppet/parser/functions/validate_hash.rb": "c2ae6299148ea200f8dfcf9204875182",
-  "lib/puppet/parser/functions/validate_integer.rb": "65aa35f7450794aaadb6ad2c2e114df7",
-  "lib/puppet/parser/functions/validate_ip_address.rb": "b23c3d5ce6839e32d0186411147a6a44",
-  "lib/puppet/parser/functions/validate_ipv4_address.rb": "593e8f832469cb6a48c5f16ee66c3b2d",
-  "lib/puppet/parser/functions/validate_ipv6_address.rb": "48d3733012818993eae662839183d139",
-  "lib/puppet/parser/functions/validate_numeric.rb": "0e36d370262b8bdef2f88f0a3cb5b30e",
-  "lib/puppet/parser/functions/validate_re.rb": "d5963c404e3ac1670553f306221c2655",
-  "lib/puppet/parser/functions/validate_slength.rb": "6cbcfe15378ca4a780bac786223aacac",
-  "lib/puppet/parser/functions/validate_string.rb": "8afa7b0dcfe17bfbbb5704ad54664cc2",
-  "lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb": "f17427dfc42128dc1df0ab04f37942e5",
-  "lib/puppet/parser/functions/values.rb": "c35978761496406cc3dafdccaa014236",
-  "lib/puppet/parser/functions/values_at.rb": "f7e6ad2a1126acd4fb5f7fcf9bfc2e2b",
-  "lib/puppet/parser/functions/zip.rb": "133f3d4c54640844e656e2e6e790318e",
-  "lib/puppet/provider/file_line/ruby.rb": "1cf38c2e1e23f0218ff1b0df4517dd0f",
-  "lib/puppet/type/anchor.rb": "bbd36bb49c3b554f8602d8d3df366c0c",
-  "lib/puppet/type/file_line.rb": "7486754fca55fe98d40f268b032b7e6a",
-  "locales/config.yaml": "574ee65e2a2a9d2f67edbc58735f50d4",
+  "lib/facter/util/puppet_settings.rb": "f69007bcc02031cd772fa7f2dffa3c0c",
+  "lib/puppet/functions/deprecation.rb": "705115a036e0235840db59cf9f4c17fe",
+  "lib/puppet/functions/fact.rb": "5879006198f1f4106acfe13422087d56",
+  "lib/puppet/functions/is_a.rb": "5a61d6a34ef45d7a5490455f334ef48a",
+  "lib/puppet/functions/is_absolute_path.rb": "0806756fc12b1fc752d1b54e81b15832",
+  "lib/puppet/functions/is_array.rb": "4d5c8d6af4e481ebb42f73b6504685c8",
+  "lib/puppet/functions/is_bool.rb": "9ae803c605c5ed057508c6501ef1a47f",
+  "lib/puppet/functions/is_float.rb": "ebe18dc0096233fcd555423761fc29f2",
+  "lib/puppet/functions/is_ip_address.rb": "ab9a1c6172db59cc15023f220853e2f2",
+  "lib/puppet/functions/is_ipv4_address.rb": "dec325b5911ce409b16c643697a13822",
+  "lib/puppet/functions/is_ipv6_address.rb": "f4864fee72c42bd3e40914768fb10f8e",
+  "lib/puppet/functions/is_numeric.rb": "970d785070eaa02bcac3e0589a8d5e7f",
+  "lib/puppet/functions/is_string.rb": "5aa459896fda1782f74752a1d324f048",
+  "lib/puppet/functions/length.rb": "3320c90f7685178c11937174fcf3119c",
+  "lib/puppet/functions/os_version_gte.rb": "120da86bc93fb4ccb1a45e13d5603560",
+  "lib/puppet/functions/seeded_rand_string.rb": "24e657c88e9b2a4a77a6cf1310758568",
+  "lib/puppet/functions/sprintf_hash.rb": "19bee19c55865e3240be3567741ba347",
+  "lib/puppet/functions/stdlib/extname.rb": "a8df502dce6d3020f5ff32322b68045d",
+  "lib/puppet/functions/to_json.rb": "bb6893a3e9eb6c48064c5a3c0bd4a41a",
+  "lib/puppet/functions/to_json_pretty.rb": "61ff20121b4c09987eadf3242b6231cf",
+  "lib/puppet/functions/to_yaml.rb": "0358dfd97b9a051e15046c6842b327be",
+  "lib/puppet/functions/type_of.rb": "4ee9c082047c08b8b1a82bc0bef8fd78",
+  "lib/puppet/functions/validate_absolute_path.rb": "556b0e3de450f03d724747d7d3825309",
+  "lib/puppet/functions/validate_array.rb": "efe329c6c8f65fce1ae2560fa5751530",
+  "lib/puppet/functions/validate_bool.rb": "5516a0f2efb48eeb4460fc713c6f9521",
+  "lib/puppet/functions/validate_hash.rb": "ce99bea6e1ee4da1a67b53b3ce06ce96",
+  "lib/puppet/functions/validate_integer.rb": "c028b299f194c221002ba442077e9209",
+  "lib/puppet/functions/validate_ip_address.rb": "278f3e0ea96b4b31e7b85c13887079b6",
+  "lib/puppet/functions/validate_ipv4_address.rb": "bd015492af1f3c4bef7ac780ae1c7e61",
+  "lib/puppet/functions/validate_ipv6_address.rb": "5144a327b6850ed5b7fb26fa37113353",
+  "lib/puppet/functions/validate_legacy.rb": "789bdef436873b6fcc8205c6d2270e43",
+  "lib/puppet/functions/validate_numeric.rb": "2bd2733f44749e0e56940ceaf5d8e2f8",
+  "lib/puppet/functions/validate_re.rb": "12c3412a7383b1d258dba5d4307e9464",
+  "lib/puppet/functions/validate_slength.rb": "1fc441736085bd0b5c7862f5dc9f839a",
+  "lib/puppet/functions/validate_string.rb": "c0fe867d3b5f8fbcaa3641f0f393a669",
+  "lib/puppet/parser/functions/abs.rb": "f36ef597641f56b400bf5425f329b52c",
+  "lib/puppet/parser/functions/any2array.rb": "bb45c181f51b6cb124de9ab44ff74ae5",
+  "lib/puppet/parser/functions/any2bool.rb": "12535df795966eadcf27e05413c691cc",
+  "lib/puppet/parser/functions/assert_private.rb": "c61884d43ebdb5ee5a5aa1507165084a",
+  "lib/puppet/parser/functions/base64.rb": "5c044321bc37fecd54e06a0ec5a067ba",
+  "lib/puppet/parser/functions/basename.rb": "6b0dc955024352c8007d175f900dba36",
+  "lib/puppet/parser/functions/bool2num.rb": "0d0a75d743e099eafada405f57ead3ea",
+  "lib/puppet/parser/functions/bool2str.rb": "ab45ec6cbcd35194d478c2da0527ab74",
+  "lib/puppet/parser/functions/camelcase.rb": "b46cd7766f7f500142fedaae6e81eb47",
+  "lib/puppet/parser/functions/capitalize.rb": "45d3ba2d02056b5dd0bc7f69ab046817",
+  "lib/puppet/parser/functions/ceiling.rb": "7cc2fba2933190774468035d24778f51",
+  "lib/puppet/parser/functions/chomp.rb": "393c7ea2399b531b1528cbbac6948f3c",
+  "lib/puppet/parser/functions/chop.rb": "b8d88826795cf13f803f264ce42e1cdf",
+  "lib/puppet/parser/functions/clamp.rb": "5c2c8f3f048ed1afd0c34c0eb475b076",
+  "lib/puppet/parser/functions/concat.rb": "107cf03fb8343dbf20f69bd4a07a7bb1",
+  "lib/puppet/parser/functions/convert_base.rb": "a34a1172f158c4780f6387df082aade0",
+  "lib/puppet/parser/functions/count.rb": "b3bcfa1fc10df6f2635c10804cfb567c",
+  "lib/puppet/parser/functions/deep_merge.rb": "fae771cff4fc1d6c639bea1672e05c9c",
+  "lib/puppet/parser/functions/defined_with_params.rb": "bd2564fe13dd46e4afac1e7f7db45eee",
+  "lib/puppet/parser/functions/delete.rb": "875f64cf060e00bb6f187875a4bc5e88",
+  "lib/puppet/parser/functions/delete_at.rb": "d909ad4779276559cb05b09193b047e0",
+  "lib/puppet/parser/functions/delete_regex.rb": "509b6526b9dea21321c6d7a0f2de591a",
+  "lib/puppet/parser/functions/delete_undef_values.rb": "01e6547fcd9ff93bb5294be3c0761a49",
+  "lib/puppet/parser/functions/delete_values.rb": "7cc9f122bc7ddfb6359146cd68e5f27a",
+  "lib/puppet/parser/functions/deprecation.rb": "9f935fec2f9f0d01394292eb6f21bd7d",
+  "lib/puppet/parser/functions/difference.rb": "419c1179460a2878d99b577dfb41977d",
+  "lib/puppet/parser/functions/dig.rb": "d315de1659a037430fea9623bff323a6",
+  "lib/puppet/parser/functions/dig44.rb": "433ae008eed28fa3f99dbdd64926bfd8",
+  "lib/puppet/parser/functions/dirname.rb": "eaafc8268d35709f8d460a48e918ee4c",
+  "lib/puppet/parser/functions/dos2unix.rb": "ab2f9f280c616be55f58903948e226a2",
+  "lib/puppet/parser/functions/downcase.rb": "384d5ad77ac70bd199fcd63fa31ede38",
+  "lib/puppet/parser/functions/empty.rb": "455ab7360e7d15f78ff8f359e6da432a",
+  "lib/puppet/parser/functions/enclose_ipv6.rb": "89c728eb11f71ed9390664bad9732328",
+  "lib/puppet/parser/functions/ensure_packages.rb": "8f72ca68f1d93fc7042552fef8fdb2b2",
+  "lib/puppet/parser/functions/ensure_resource.rb": "2915c77baa0d45531912613dd1cac902",
+  "lib/puppet/parser/functions/ensure_resources.rb": "805d56e894c9dcca2595464fa87a7c56",
+  "lib/puppet/parser/functions/flatten.rb": "8558874ff069ba6cbaecac47c4836ca9",
+  "lib/puppet/parser/functions/floor.rb": "1fdd8c7a0d1350c4e67578209cbfd937",
+  "lib/puppet/parser/functions/fqdn_rand_string.rb": "731365381b6a28a196e108329e16c6c2",
+  "lib/puppet/parser/functions/fqdn_rotate.rb": "3925369078084f98f9b527d25cc9e4d2",
+  "lib/puppet/parser/functions/fqdn_uuid.rb": "adbd60dbcc561c8586567a6e58abec82",
+  "lib/puppet/parser/functions/get_module_path.rb": "91b47019658cb4f438a8f96c6e12213b",
+  "lib/puppet/parser/functions/getparam.rb": "b8f4a75c6e0d9732c5f937bd35b00923",
+  "lib/puppet/parser/functions/getvar.rb": "60ee5451005017bd3234113354f68765",
+  "lib/puppet/parser/functions/glob.rb": "f8177554be6da357b0822edaa7eb8d14",
+  "lib/puppet/parser/functions/grep.rb": "f8a965a28326f7cde962a13d8273d617",
+  "lib/puppet/parser/functions/has_interface_with.rb": "422015811c5b7c0656b83eaea3b8fdcc",
+  "lib/puppet/parser/functions/has_ip_address.rb": "fc76c9a87145560f58a4ae9a6d9df444",
+  "lib/puppet/parser/functions/has_ip_network.rb": "b1bb1868e6fef95f8ae840d420ab0816",
+  "lib/puppet/parser/functions/has_key.rb": "2831eb02496ac82c790e49d4538bd983",
+  "lib/puppet/parser/functions/hash.rb": "a986ba1253550e868d61e777dbda0890",
+  "lib/puppet/parser/functions/intersection.rb": "6436444eb8585ee71cfd5bd1e0802026",
+  "lib/puppet/parser/functions/is_absolute_path.rb": "268600b66670a29690be009d45013d42",
+  "lib/puppet/parser/functions/is_array.rb": "0e425e55c8ce9cc5e327d53d114391ba",
+  "lib/puppet/parser/functions/is_bool.rb": "4e021a5143c2c98b31344acceda5fbe2",
+  "lib/puppet/parser/functions/is_domain_name.rb": "1abf04d1d57de6f7f630045c0efe5e4c",
+  "lib/puppet/parser/functions/is_email_address.rb": "d11c644fa1bd73f8e1d36c4f9e67272e",
+  "lib/puppet/parser/functions/is_float.rb": "b95a00f15242e3f26a5cf129db7d31e5",
+  "lib/puppet/parser/functions/is_function_available.rb": "3bb60da5789493da017f84d48ac46f08",
+  "lib/puppet/parser/functions/is_hash.rb": "3f74a7e9b6e47b834c4ad58939c27eab",
+  "lib/puppet/parser/functions/is_integer.rb": "e3480725fccac1c7eba28162dc62393d",
+  "lib/puppet/parser/functions/is_ip_address.rb": "3616dacf58febcd4944945d3c2647efe",
+  "lib/puppet/parser/functions/is_ipv4_address.rb": "7930d25d23d92f0e5cb81f93315cea16",
+  "lib/puppet/parser/functions/is_ipv6_address.rb": "c206564af3a738e504afca2284497d3c",
+  "lib/puppet/parser/functions/is_mac_address.rb": "ce813427e763d0405931dc216e51bca2",
+  "lib/puppet/parser/functions/is_numeric.rb": "4bd1a47192ce4040810819789fbf3147",
+  "lib/puppet/parser/functions/is_string.rb": "cf06fecd6147bea77d406a189b649f81",
+  "lib/puppet/parser/functions/join.rb": "338cfe4797a5b41d34d0dcdceb4cff2f",
+  "lib/puppet/parser/functions/join_keys_to_values.rb": "86e4211f195c4c9d92c5e3806789a561",
+  "lib/puppet/parser/functions/keys.rb": "1702d1c00a24ca4e9ba6a4f36c4ec808",
+  "lib/puppet/parser/functions/load_module_metadata.rb": "4972bafc84e5b7ce4a00cbee21aece18",
+  "lib/puppet/parser/functions/loadjson.rb": "442e1250912a44965637782998776ef6",
+  "lib/puppet/parser/functions/loadyaml.rb": "8ad8f48f3649b39bdeca825a61d68e9e",
+  "lib/puppet/parser/functions/lstrip.rb": "078230c59baa5ebb433d1ddc2ebd808b",
+  "lib/puppet/parser/functions/max.rb": "c9acf0c8bd3902ec613844fac4eb0201",
+  "lib/puppet/parser/functions/member.rb": "ddd3572cb73353e4cfd95bcea423030b",
+  "lib/puppet/parser/functions/merge.rb": "fecd4133ce85334adf93332fdc9f65f1",
+  "lib/puppet/parser/functions/min.rb": "9016deb88938647bd52faf8cdea6f83c",
+  "lib/puppet/parser/functions/num2bool.rb": "60e725ab19cffcd745a0b904a7a59d6b",
+  "lib/puppet/parser/functions/parsejson.rb": "fee0dc33cd6e18b0d9a5fe8befb66cd2",
+  "lib/puppet/parser/functions/parseyaml.rb": "f4b67d011970c1799bc6fb36a3caf1f2",
+  "lib/puppet/parser/functions/pick.rb": "502384aedc46dd5987fe31c494f48e61",
+  "lib/puppet/parser/functions/pick_default.rb": "acf85e30452afb8a1811a4ca8557f188",
+  "lib/puppet/parser/functions/prefix.rb": "6912509e79ebdff5f9b4e7d630442157",
+  "lib/puppet/parser/functions/private.rb": "a1f44a1c32da00aa14f474f4f303be87",
+  "lib/puppet/parser/functions/pry.rb": "970544bf6308b7b6902b936063a45109",
+  "lib/puppet/parser/functions/pw_hash.rb": "07fea662493e5b2ffcf37dbb4c4e74b9",
+  "lib/puppet/parser/functions/range.rb": "38f7ebcf5a66954f9127756d32291534",
+  "lib/puppet/parser/functions/regexpescape.rb": "d7d22f987d616f2b5ec9d967f1528f53",
+  "lib/puppet/parser/functions/reject.rb": "9847dac360af182c4880dece7b4bc034",
+  "lib/puppet/parser/functions/reverse.rb": "2d1045255bbe50fc6d4cd97ad4a6eec3",
+  "lib/puppet/parser/functions/round.rb": "aaf276b15f731cf44da7a69621cd3b96",
+  "lib/puppet/parser/functions/rstrip.rb": "1be3bf1eff074c784e980cda2c146683",
+  "lib/puppet/parser/functions/seeded_rand.rb": "4f45ef0723411ff8281aaf093f0fabc2",
+  "lib/puppet/parser/functions/shell_escape.rb": "6e51793b8483eb6bfc4be98b438fd47e",
+  "lib/puppet/parser/functions/shell_join.rb": "4fbe23ff73932f65db696f106517887e",
+  "lib/puppet/parser/functions/shell_split.rb": "cb851119ee167ccb12930c53e94333cc",
+  "lib/puppet/parser/functions/shuffle.rb": "6b16497151e961fbdb6e00ec70d6bbe9",
+  "lib/puppet/parser/functions/size.rb": "e3a0aa89c776b592ed24c1dd27773e33",
+  "lib/puppet/parser/functions/sort.rb": "ea24d1e27954b6ee69d30f3fce391b65",
+  "lib/puppet/parser/functions/squeeze.rb": "e42e1d5ec9a23443d14ff07512fd695f",
+  "lib/puppet/parser/functions/str2bool.rb": "9fac94e3e949b2a4406ac2d22510b06e",
+  "lib/puppet/parser/functions/str2saltedsha512.rb": "d4443e8985b4ce6f6e925c6f46d8456c",
+  "lib/puppet/parser/functions/strftime.rb": "d17fc58b649eb6b7315752b853cd7f3b",
+  "lib/puppet/parser/functions/strip.rb": "011469a450ae484f199c09f55f3ab809",
+  "lib/puppet/parser/functions/suffix.rb": "1893244c6bb354a6b1093f65041c643c",
+  "lib/puppet/parser/functions/swapcase.rb": "d1a53787b35ae9a5a643c49f4e0975a8",
+  "lib/puppet/parser/functions/time.rb": "4a0ec2a06a1361dbf3cd11a07aa57a71",
+  "lib/puppet/parser/functions/to_bytes.rb": "55a65ad70ea78983e7c1d6d565094c1f",
+  "lib/puppet/parser/functions/try_get_value.rb": "b039b960b07a21b935baf6c78fb94612",
+  "lib/puppet/parser/functions/type.rb": "3115a269dc87e6cdb586d6cf4c2b0529",
+  "lib/puppet/parser/functions/type3x.rb": "7a72502f0291c66b0e4ce76e33e481c7",
+  "lib/puppet/parser/functions/union.rb": "690e5c15a1e7b95ab4b90ee18eb48f81",
+  "lib/puppet/parser/functions/unique.rb": "e448da2c183c0e19bd6e64bc423a749f",
+  "lib/puppet/parser/functions/unix2dos.rb": "0aa6e66d1c47ca0bb417e248b01f6f1b",
+  "lib/puppet/parser/functions/upcase.rb": "55ef15d383673d44a1848833a46cfd11",
+  "lib/puppet/parser/functions/uriescape.rb": "f2facfe201658a65a7e81199cdd1bef7",
+  "lib/puppet/parser/functions/validate_absolute_path.rb": "892faf0e74b99b11190ec7fc4b78a893",
+  "lib/puppet/parser/functions/validate_array.rb": "9518be91bab77e56be711d1498d119b9",
+  "lib/puppet/parser/functions/validate_augeas.rb": "c5bbf1bc42b7ea024e48ab12b46f55e9",
+  "lib/puppet/parser/functions/validate_bool.rb": "bea67f1a0f5fc23ee8b632000cfa63db",
+  "lib/puppet/parser/functions/validate_cmd.rb": "dbb22e68eca3f6be63fb49b465b1d611",
+  "lib/puppet/parser/functions/validate_domain_name.rb": "04f4b1d0be9a8a12d278f0b044f78427",
+  "lib/puppet/parser/functions/validate_email_address.rb": "6dc01f14c43fdff19106a2388d01b51a",
+  "lib/puppet/parser/functions/validate_hash.rb": "80f7cfb430818e1497d3b12769d8f9c4",
+  "lib/puppet/parser/functions/validate_integer.rb": "edb176a717c4af6cd50d2d26e4da149d",
+  "lib/puppet/parser/functions/validate_ip_address.rb": "55d0f019803d687bf95bcc64e8751ba5",
+  "lib/puppet/parser/functions/validate_ipv4_address.rb": "94843b876cc92414b29223f7ac3cc3b6",
+  "lib/puppet/parser/functions/validate_ipv6_address.rb": "6c10396f466f64a6f897d1be4291dd4a",
+  "lib/puppet/parser/functions/validate_numeric.rb": "092cce5ed9d3a73319c48cdf9a2a822e",
+  "lib/puppet/parser/functions/validate_re.rb": "df6a2cc342dad63d008ef257fde9038a",
+  "lib/puppet/parser/functions/validate_slength.rb": "b20959e080f36bf320eacb472d125741",
+  "lib/puppet/parser/functions/validate_string.rb": "0239e1697134605a6385ff8c9bdc066b",
+  "lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb": "b16e5ebaeb497e1639c7bf78d61c2b45",
+  "lib/puppet/parser/functions/values.rb": "793ec0d600822461829eda4abcd89f9c",
+  "lib/puppet/parser/functions/values_at.rb": "d03bb02de4bf80ecd1846a4e6dc99ce8",
+  "lib/puppet/parser/functions/zip.rb": "aef1ee868716d07b01e605ae6c4741cc",
+  "lib/puppet/provider/file_line/ruby.rb": "06dd4b2bd0037fcdc8382fcd4214dda3",
+  "lib/puppet/type/anchor.rb": "95867e600863019b08990277c4254cac",
+  "lib/puppet/type/file_line.rb": "208655541a332e54e2d9abac0e328d33",
+  "locales/config.yaml": "d3795b3334faf13674a5d1e3759064ac",
   "locales/ja/puppetlabs-stdlib.po": "805e5d893d2025ad57da8ec0614a6753",
   "locales/puppetlabs-stdlib.pot": "23c892ac0683aef4b09aabe0037750ae",
   "manifests/init.pp": "9560a09f657d7eebbfdb920cefcc1d4f",
   "manifests/stages.pp": "72eb4fa624474faf23b39e57cf1590bd",
-  "metadata.json": "86d062cb2511c91431543d66efbdff00",
-  "readmes/README_ja_JP.md": "173d377936c83b2cd622bb471d154a02",
-  "spec/acceptance/abs_spec.rb": "5b60756b2b4da28314025f51989592d7",
-  "spec/acceptance/anchor_spec.rb": "0fdbe266d8b7c3dc172e338b978109ba",
-  "spec/acceptance/any2array_spec.rb": "444cfd34154539d896e5ef1488386372",
-  "spec/acceptance/base64_spec.rb": "6a1dd4144ba354f9bed14eb70f7d2cba",
-  "spec/acceptance/bool2num_spec.rb": "edc9cb8b89b95410326475d27ce74bd5",
-  "spec/acceptance/build_csv.rb": "f28ef587de764ade1513091c4906412c",
-  "spec/acceptance/capitalize_spec.rb": "4bb6471ec3a8a07260da8e249fae6ccd",
-  "spec/acceptance/ceiling_spec.rb": "46489eef94aa21bb1560383bb17d7d02",
-  "spec/acceptance/chomp_spec.rb": "8372fe8a875b1a599a89df1191f43bc0",
-  "spec/acceptance/chop_spec.rb": "d73d1c7c6a44df65677362bd2899bbc1",
-  "spec/acceptance/clamp_spec.rb": "8afaae07bf89e0af35474da489fd590f",
-  "spec/acceptance/concat_spec.rb": "bad5f40e0a501b436ec4264cd278290b",
-  "spec/acceptance/count_spec.rb": "f8abd435b077edd06ad76a96a2e610c0",
-  "spec/acceptance/deep_merge_spec.rb": "5f16342cb8c1b52d6a08717a2ef87117",
-  "spec/acceptance/defined_with_params_spec.rb": "8b47a7255b9d662009217f3cfd17ca03",
-  "spec/acceptance/delete_at_spec.rb": "b0c853ffe5fc121e051233d62f6e72b3",
-  "spec/acceptance/delete_spec.rb": "6ccb838a13037a56d1413aecb4fdac00",
-  "spec/acceptance/delete_undef_values_spec.rb": "7d849a978d3ecdaaf5e922acc6038ad8",
-  "spec/acceptance/delete_values_spec.rb": "b9f3dbffbb89fec32c6a5b2bd3b20901",
-  "spec/acceptance/deprecation_spec.rb": "cadc56a94cbc2f13965d698f581f582d",
-  "spec/acceptance/difference_spec.rb": "2f4e8ddd760f2d4dc9a4fb7b653e982f",
-  "spec/acceptance/dirname_spec.rb": "76e6b66474f070d8a89f3fe5bd187e85",
-  "spec/acceptance/downcase_spec.rb": "53f0f5b1867e0fd87ba59833c18b5ca2",
-  "spec/acceptance/empty_spec.rb": "be8a610f87790a321dbd4cc0542e2885",
-  "spec/acceptance/ensure_resource_spec.rb": "c0193d79f1db1985d313bedb93a4c7ae",
-  "spec/acceptance/flatten_spec.rb": "3ab1f9c9e761e5d758eeee7a2e32f295",
-  "spec/acceptance/floor_spec.rb": "4a20f6fc7142ef9357c8d18a408b5e52",
-  "spec/acceptance/fqdn_rand_string_spec.rb": "7744b45e282013c5fe637dbaf42f85b9",
-  "spec/acceptance/fqdn_rotate_spec.rb": "366816bb1d3102f64025d61e22eec79c",
-  "spec/acceptance/get_module_path_spec.rb": "d5d2258b2345359d1e51a638b97523cb",
-  "spec/acceptance/getparam_spec.rb": "d4037f1f546cf7a3e7dcabe787e637b5",
-  "spec/acceptance/getvar_spec.rb": "8451bced69bfd5599a552ddf49976d98",
-  "spec/acceptance/grep_spec.rb": "5e6650532658915d1004a6e6c0f1229d",
-  "spec/acceptance/has_interface_with_spec.rb": "e028fc7fc1023293ba32c48c9f46752a",
-  "spec/acceptance/has_ip_address_spec.rb": "f3443be46277f6084ca8e531562d8ac7",
-  "spec/acceptance/has_ip_network_spec.rb": "fa7a38450bef7e4408deb6b978d5a42f",
-  "spec/acceptance/has_key_spec.rb": "68e42fb69d15f27916e7943ab727afc6",
-  "spec/acceptance/hash_spec.rb": "1e8ff803d76d8f9e506c8a366a93ad90",
-  "spec/acceptance/intersection_spec.rb": "755c135f67811666b3c5152c5c5349c2",
-  "spec/acceptance/is_a_spec.rb": "4cdd8df78a6285de21d634c032e5a7c9",
-  "spec/acceptance/is_array_spec.rb": "1de1fb0b55759d4012033ae3ce0723c2",
-  "spec/acceptance/is_bool_spec.rb": "9984cd966d81c217f8ff4e252a4a66d1",
-  "spec/acceptance/is_domain_name_spec.rb": "948dc0c7372027e8f2bb9db85b8d66b2",
-  "spec/acceptance/is_float_spec.rb": "731d9b71e7b4ee5055339d08b2b5f707",
-  "spec/acceptance/is_function_available_spec.rb": "413964bfe8e18c34d8809590afcc4118",
-  "spec/acceptance/is_hash_spec.rb": "9095a364cba82a95a1edd0f92d2218c7",
-  "spec/acceptance/is_integer_spec.rb": "bc4e7192073531638be9f8a4d391a827",
-  "spec/acceptance/is_ip_address_spec.rb": "c2ee8738d62b4c9d42b3ef1a1b8573fc",
-  "spec/acceptance/is_ipv4_address_spec.rb": "09f6f3ad6a1c0a9e5dcfaab34a081ffc",
-  "spec/acceptance/is_ipv6_address_spec.rb": "d19a98176b2b7367e740d338df08c2ae",
-  "spec/acceptance/is_mac_address_spec.rb": "b53f033cc4943a19f597895df0b5210a",
-  "spec/acceptance/is_numeric_spec.rb": "95ecae5adde23e6b61cd090704c4572d",
-  "spec/acceptance/is_string_spec.rb": "d9ad89b30aff62aea4fb805c991c6abf",
-  "spec/acceptance/join_keys_to_values_spec.rb": "908f62013e1d797ddc0ba68c0fb7913b",
-  "spec/acceptance/join_spec.rb": "5609c646859140109af4ae1c63cc69d2",
-  "spec/acceptance/keys_spec.rb": "15edb2f0a5630dfadd9bd6c038e5cf95",
-  "spec/acceptance/loadjson_spec.rb": "7bf8eb220ed02b77e9956dade1acfcb3",
-  "spec/acceptance/loadyaml_spec.rb": "3810faad7411bc1d9c9274671bb68a9a",
-  "spec/acceptance/lstrip_spec.rb": "27a6e2c9e2afc5b3e0e98301798a80ad",
-  "spec/acceptance/max_spec.rb": "c39a2006dacdbd24a8acc5dc25f1a9f3",
-  "spec/acceptance/member_spec.rb": "10b9635c1daf636d66aabea6ff796e6a",
-  "spec/acceptance/merge_spec.rb": "a1502ebd4d069c5f818f7fd8da79e02d",
-  "spec/acceptance/min_spec.rb": "a6e73a33255bc202de93fd8fe679c510",
+  "metadata.json": "1be898fdb374bd36f05aa6dd4f4ab3c4",
+  "readmes/README_ja_JP.md": "36810eaee0543bb5c7a446c6fd576811",
+  "spec/acceptance/abs_spec.rb": "320dc9b8ecf5cc434942db3c76cc44c8",
+  "spec/acceptance/anchor_spec.rb": "96b18124a8bd485928ef49ac82072789",
+  "spec/acceptance/any2array_spec.rb": "8071bc5d9616d73d29c252ca3f919300",
+  "spec/acceptance/base64_spec.rb": "817503716d7df9052ca3730a8d3fa1f5",
+  "spec/acceptance/bool2num_spec.rb": "2adb07b2abf9fab7845f8e93d63cfe0e",
+  "spec/acceptance/build_csv.rb": "0d4e10040cb934a78c523bebda8a2362",
+  "spec/acceptance/capitalize_spec.rb": "3956adeac93418b6702811b83a6e1dd1",
+  "spec/acceptance/ceiling_spec.rb": "2e913e0bc8a92eaa92ceaa5ec91f3b54",
+  "spec/acceptance/chomp_spec.rb": "8a27b04bf893da4acd02334a03cdc51b",
+  "spec/acceptance/chop_spec.rb": "d79ff0a335e2648e468af137560c15f7",
+  "spec/acceptance/clamp_spec.rb": "35aa8410bbd283546b3325c90c394521",
+  "spec/acceptance/concat_spec.rb": "0432bcd648b43d2b9fe539543cddfadd",
+  "spec/acceptance/count_spec.rb": "67c9f9083e980ab397b3d259367ac201",
+  "spec/acceptance/deep_merge_spec.rb": "a29b282369d829b04784c2b7035a66b0",
+  "spec/acceptance/defined_with_params_spec.rb": "f136180ec4f44e2f49ed15944a5d4a51",
+  "spec/acceptance/delete_at_spec.rb": "a6bae7649fcfe02eaf58660a81660a9d",
+  "spec/acceptance/delete_spec.rb": "69ff71ade09add15063a1375b49d7ad9",
+  "spec/acceptance/delete_undef_values_spec.rb": "258ca3da1b06afc1e6d8588eed92e8f2",
+  "spec/acceptance/delete_values_spec.rb": "3a15a34628df45f6a2f25ebf14e3e4f1",
+  "spec/acceptance/deprecation_spec.rb": "3298d3fc62c4f18211add9ed273df85f",
+  "spec/acceptance/difference_spec.rb": "e6a0ebbdfffcd374520d40fce11d957b",
+  "spec/acceptance/dirname_spec.rb": "84cad3f9b2bb6d7e36fbf8b8df1be77b",
+  "spec/acceptance/downcase_spec.rb": "f57a4296899bbd732f1c3ed438601c7f",
+  "spec/acceptance/empty_spec.rb": "b89067b0975336683a38bf20a6a1f036",
+  "spec/acceptance/ensure_resource_spec.rb": "d09c350ba1d0bf7ff14bacf4f1c8e487",
+  "spec/acceptance/flatten_spec.rb": "54da51ee7665de8b56252d20215a3c30",
+  "spec/acceptance/floor_spec.rb": "2faea9ed579f7e9f3b045bed2c99fe62",
+  "spec/acceptance/fqdn_rand_string_spec.rb": "33d5fa38b5f880157ea69dd25a12a332",
+  "spec/acceptance/fqdn_rotate_spec.rb": "c280ce28ba57b9d67a3e3b1a0c14f342",
+  "spec/acceptance/get_module_path_spec.rb": "cb34a578c336f8572835520425878d5d",
+  "spec/acceptance/getparam_spec.rb": "eaa6149d19c6082d7d6cb7f81c1aa342",
+  "spec/acceptance/getvar_spec.rb": "afe43ffe3e071e0c1d18b679f714fdfc",
+  "spec/acceptance/grep_spec.rb": "b74c67c94d39a49e9ee395a6c5fc9c9d",
+  "spec/acceptance/has_interface_with_spec.rb": "36e2cc57fb3f9044e2b93fa98eb436ab",
+  "spec/acceptance/has_ip_address_spec.rb": "da00303c038e758115e96a0fb65ab9c5",
+  "spec/acceptance/has_ip_network_spec.rb": "c4991bb6905d4aeba6bab1c9f7cc3fa5",
+  "spec/acceptance/has_key_spec.rb": "d4eb28efd599e1eac485bf9f6ca930d3",
+  "spec/acceptance/hash_spec.rb": "0736319571163989e4df71dcff017fd1",
+  "spec/acceptance/intersection_spec.rb": "8bd80ad4ebf9627add63f257bf0674e4",
+  "spec/acceptance/is_a_spec.rb": "ecca7dbb41739ebffcefccc2cb85722d",
+  "spec/acceptance/is_array_spec.rb": "b5baf237a47ace8d53c3748c3432f226",
+  "spec/acceptance/is_bool_spec.rb": "fa53d0fc3486fc6473184105fad31f2e",
+  "spec/acceptance/is_domain_name_spec.rb": "963998fd1d72750dd800c8227fa9354c",
+  "spec/acceptance/is_float_spec.rb": "4f4d179d4e4ca3b6f38ccca6bb855a3f",
+  "spec/acceptance/is_function_available_spec.rb": "83bb5c733cf1dd2c15fa2f3add9ce61e",
+  "spec/acceptance/is_hash_spec.rb": "2bfe3af74c15731b2ab251bbaf386245",
+  "spec/acceptance/is_integer_spec.rb": "f68672a767a6216e3502fc08e61f4a01",
+  "spec/acceptance/is_ip_address_spec.rb": "680bcb2199c16d346a65c29c6042148c",
+  "spec/acceptance/is_ipv4_address_spec.rb": "5bbb9b312267da1a2124558867d0cec3",
+  "spec/acceptance/is_ipv6_address_spec.rb": "05e45351f00b3c4fbfc7ec78bb9f93c6",
+  "spec/acceptance/is_mac_address_spec.rb": "d6279ad39509c73429f2e60a342f8a51",
+  "spec/acceptance/is_numeric_spec.rb": "a4b6c6d0b4570672f4cf8ecea3324d9f",
+  "spec/acceptance/is_string_spec.rb": "1faf6b5fc01a5924077449b3ecf22cbb",
+  "spec/acceptance/join_keys_to_values_spec.rb": "d8e6a7575e96e33e44ded6c1ef4d329c",
+  "spec/acceptance/join_spec.rb": "a0db319d437e05e97608cea0525d11e2",
+  "spec/acceptance/keys_spec.rb": "5712c1b5fdbb268369923d4f3a7e4a5c",
+  "spec/acceptance/loadjson_spec.rb": "c4a2bebd9648f8843cd394fc78691cb7",
+  "spec/acceptance/loadyaml_spec.rb": "641cee5b4c85bb01033c75bc5cc9678e",
+  "spec/acceptance/lstrip_spec.rb": "e1730ce36754f397ce8b75b4fb367e73",
+  "spec/acceptance/max_spec.rb": "eecd12858eb839a5a6335e2092b093c4",
+  "spec/acceptance/member_spec.rb": "92facc113e77834516361f7e91a6b07a",
+  "spec/acceptance/merge_spec.rb": "a2d398f1b407736d576a01a350a7b378",
+  "spec/acceptance/min_spec.rb": "4b47af34106bc46990b72479b760a06f",
   "spec/acceptance/nodesets/centos-7-x64.yml": "a713f3abd3657f0ae2878829badd23cd",
   "spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39",
   "spec/acceptance/nodesets/default.yml": "b42da5a1ea0c964567ba7495574b8808",
   "spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae",
   "spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df",
   "spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58",
-  "spec/acceptance/num2bool_spec.rb": "33ab633c5a6aa1e5e9c0cac9ec23c0d5",
-  "spec/acceptance/parsejson_spec.rb": "56353143de570034f59a87244bb9ff7b",
-  "spec/acceptance/parseyaml_spec.rb": "a564b2217350398d8a3f1b212d0c2ada",
-  "spec/acceptance/pick_default_spec.rb": "bc3512e0cc3bc34da5f44ae18573af5d",
-  "spec/acceptance/pick_spec.rb": "661747652e50bb522ad0c627fb8c3c58",
-  "spec/acceptance/prefix_spec.rb": "2b9df68e18e16144caa4440fd6acaa01",
-  "spec/acceptance/pw_hash_spec.rb": "979f0d209f1ef227a31d27a452fc2ed3",
-  "spec/acceptance/range_spec.rb": "f913a26f4bbe8b9432b6cb80a3b6d1ed",
-  "spec/acceptance/reject_spec.rb": "c63eb909288cf2210f72d3afa1e07b32",
-  "spec/acceptance/reverse_spec.rb": "eca705328f8e246a648e3f62434e662a",
-  "spec/acceptance/rstrip_spec.rb": "bad1e42f66d07b5d09ca1133b392bf6a",
-  "spec/acceptance/shuffle_spec.rb": "adc420bc01d83dde117b04baa4a5e2d8",
-  "spec/acceptance/size_spec.rb": "d923ec158f5c2275b9823dd118edd953",
-  "spec/acceptance/sort_spec.rb": "3ac4acd4233fbe624d926604d58acea6",
-  "spec/acceptance/squeeze_spec.rb": "2270c35766a5162cd732f0f761f0dc34",
-  "spec/acceptance/str2bool_spec.rb": "73ca9cbf9079ef52de10f90cb871e80c",
-  "spec/acceptance/str2saltedsha512_spec.rb": "1e89299c3802ba386589a5133a07dccc",
-  "spec/acceptance/strftime_spec.rb": "6cdfc95c02af2419eb14d173a23df678",
-  "spec/acceptance/strip_spec.rb": "711b6b73fce659ab83956c4454500e55",
-  "spec/acceptance/suffix_spec.rb": "c2ca0539e9e7b71f36ff470d3c18b303",
-  "spec/acceptance/swapcase_spec.rb": "30290d4378f19fa8bac4bc3347a36298",
-  "spec/acceptance/time_spec.rb": "74b6d4f21d46ca612a98efed9c48944c",
-  "spec/acceptance/to_bytes_spec.rb": "ff7d57f85cf1e211b0998235636edfd9",
-  "spec/acceptance/try_get_value_spec.rb": "8b62b969ece6f02c65f0cf3d365324b1",
-  "spec/acceptance/type_spec.rb": "909aa4d0c2463b04a3d3ff72cb0d4b42",
-  "spec/acceptance/union_spec.rb": "41b8705ac890ddd915a5f6c8b33620cd",
-  "spec/acceptance/unique_spec.rb": "0108f76cc12ecb0551a37a002a9bda85",
-  "spec/acceptance/upcase_spec.rb": "30721f352edd513a0cc36c94aa0fe760",
-  "spec/acceptance/uriescape_spec.rb": "69857543c97c35b23094cc6da0828055",
-  "spec/acceptance/validate_absolute_path_spec.rb": "b7f57e45a4d4d2a187bf9db99c481f98",
-  "spec/acceptance/validate_array_spec.rb": "ec0db1f08eb8d64fec1025b65b544365",
-  "spec/acceptance/validate_augeas_spec.rb": "744354dd9726be3624db10935ae2b13f",
-  "spec/acceptance/validate_bool_spec.rb": "950632bafc509e1965cd6a57646d87f6",
-  "spec/acceptance/validate_cmd_spec.rb": "1605939801210b1a53dc8873492551e0",
-  "spec/acceptance/validate_hash_spec.rb": "b79b1ef06301e1b97863281e3c419b0e",
-  "spec/acceptance/validate_ipv4_address_spec.rb": "547520f1ad1d55c52a257f4fb85ecc33",
-  "spec/acceptance/validate_ipv6_address_spec.rb": "feedad9317be19409e351011c7b852b9",
-  "spec/acceptance/validate_re_spec.rb": "bcc18798eccca866883b965baefc3cc9",
-  "spec/acceptance/validate_slength_spec.rb": "29311e9e910bba57a86be9a4893b43e5",
-  "spec/acceptance/validate_string_spec.rb": "cd36b419ebb8630618ec795781081101",
-  "spec/acceptance/values_at_spec.rb": "17e39ac5e094fb05522cb363e12186ab",
-  "spec/acceptance/values_spec.rb": "25d5abaffd9a108a52cdb156b5120e85",
-  "spec/acceptance/zip_spec.rb": "30ac38a83f8e92d642a20b53c5b66292",
-  "spec/aliases/absolute_path_spec.rb": "4326af270230f6d1aef6b1c68a31c53b",
-  "spec/aliases/absolutepath_spec.rb": "7a65a2c6269390f88ca0d3325b34c947",
-  "spec/aliases/array_spec.rb": "09c3559333ec646387e4141ed37d671e",
-  "spec/aliases/bool_spec.rb": "c3f734df3cd334860bba95386b8e8ba6",
-  "spec/aliases/float_spec.rb": "c7ff160684d35446f7147569e3d03556",
-  "spec/aliases/hash_spec.rb": "8b0753fbb41a41655235f999a8cd8a17",
-  "spec/aliases/httpsurl_spec.rb": "49fa0c1da3f055228aaa7ab12471f126",
-  "spec/aliases/httpurl_spec.rb": "fe92b61091197895e9e0070adcaec1e9",
-  "spec/aliases/integer_spec.rb": "90430f55eeeb94f23776c22316617214",
-  "spec/aliases/ip_address.rb": "297c6577c0763f5121f9ca9c19718dfe",
-  "spec/aliases/ipv4_spec.rb": "8f3be58256671754f32287609c7a64ba",
-  "spec/aliases/ipv6_spec.rb": "68bc3bdf8f2dbb049f8f8daf93d78e82",
-  "spec/aliases/numeric_spec.rb": "23df37b6393b5b643098cc08d22e95fd",
-  "spec/aliases/string_spec.rb": "c87ba7843251b97a7aa0b24437237787",
-  "spec/aliases/unixpath_spec.rb": "1fac6f23e14c3589d26284a081c25c77",
-  "spec/aliases/windowspath_spec.rb": "4a3aec398b2c6ae86cb6d68ac5e8ab06",
+  "spec/acceptance/num2bool_spec.rb": "a1c7ae1ae573238474264f512ceac029",
+  "spec/acceptance/parsejson_spec.rb": "703943409a4942e143a9ee64428137d2",
+  "spec/acceptance/parseyaml_spec.rb": "4c423fec2126c06d73b680ccedb2d92a",
+  "spec/acceptance/pick_default_spec.rb": "74ef7cc0cff5613e2f5bb51860cc78f5",
+  "spec/acceptance/pick_spec.rb": "883435ee18338b44d8a809df948f013a",
+  "spec/acceptance/prefix_spec.rb": "6e3763b5c18208441b21d2f6eae24339",
+  "spec/acceptance/pw_hash_spec.rb": "14bbe22f9eb59c4010abd33db766b2ab",
+  "spec/acceptance/range_spec.rb": "d875cff37547b97946bebb726918c9d6",
+  "spec/acceptance/reject_spec.rb": "844ab5a15688cf0d4777f78f1ba94513",
+  "spec/acceptance/reverse_spec.rb": "3b1bb403962eedbdbc86f02c396bada0",
+  "spec/acceptance/rstrip_spec.rb": "4497598e178e70e906311ed45dcc9a26",
+  "spec/acceptance/shuffle_spec.rb": "c3541f8e2612d38aa11cb848ba5c2fd6",
+  "spec/acceptance/size_spec.rb": "c74418e929f607652e8c3b973a12d17a",
+  "spec/acceptance/sort_spec.rb": "828bc21cb73e63676cb19d66b64f9e47",
+  "spec/acceptance/squeeze_spec.rb": "1f6dd45cab59278b021a3c8ee931a988",
+  "spec/acceptance/str2bool_spec.rb": "875a523687b93ab94169ca06b02d8fc2",
+  "spec/acceptance/str2saltedsha512_spec.rb": "d7552194362956fd86e7be11c49d75e9",
+  "spec/acceptance/strftime_spec.rb": "009ef42851b32aa797cdea874bf9e3cc",
+  "spec/acceptance/strip_spec.rb": "8e7d9e5b028c831f9982b77eed7d4961",
+  "spec/acceptance/suffix_spec.rb": "3fc89836a92965f8093187554099bc5a",
+  "spec/acceptance/swapcase_spec.rb": "9b90e7d7d441e998a7946fb33a7d9edd",
+  "spec/acceptance/time_spec.rb": "b262929e40fb53bbaabca8fda696c5b3",
+  "spec/acceptance/to_bytes_spec.rb": "0907f39eb1815eb766e18d458a44a967",
+  "spec/acceptance/try_get_value_spec.rb": "2dfffd91ac418d5429b32ddb4cdb236c",
+  "spec/acceptance/type3x_spec.rb": "fa30d2d82906b774d69109ad08f963b4",
+  "spec/acceptance/type_spec.rb": "1d55a0ad8635c239a33a1d107bda5404",
+  "spec/acceptance/union_spec.rb": "7fc2a6f6b6c4c2abb625926cd9013cca",
+  "spec/acceptance/unique_spec.rb": "66bf8230e4a8a9ae15a8d2850ceb281b",
+  "spec/acceptance/upcase_spec.rb": "e5975b83f4ada72bcdbae15d872596aa",
+  "spec/acceptance/uriescape_spec.rb": "29ce7eea67a8b400c2f2f6d9e63390f6",
+  "spec/acceptance/validate_absolute_path_spec.rb": "96150e35fd107582636420289240a1e9",
+  "spec/acceptance/validate_array_spec.rb": "50273b0f02c5c45d52386d501f025712",
+  "spec/acceptance/validate_augeas_spec.rb": "006d3658397e85dd497d7c612cbb3ae5",
+  "spec/acceptance/validate_bool_spec.rb": "448cc97e9b277cea82a6aa15cb40cc88",
+  "spec/acceptance/validate_cmd_spec.rb": "c42681ac8aed0ca83577c0205fec6aa9",
+  "spec/acceptance/validate_hash_spec.rb": "e0c2114c7c365a90230335a2e8d9d817",
+  "spec/acceptance/validate_ipv4_address_spec.rb": "233a114fc42a9a138902531d8b5b2b50",
+  "spec/acceptance/validate_ipv6_address_spec.rb": "215aed228a0c626ee321212534b31264",
+  "spec/acceptance/validate_re_spec.rb": "10eb1f29d0cd62dfafef9f99939cbc81",
+  "spec/acceptance/validate_slength_spec.rb": "6c82dcb830e1d2cf66b60c425e5aa27b",
+  "spec/acceptance/validate_string_spec.rb": "3e4d023775e7b11de5d1deabf4bb4e39",
+  "spec/acceptance/values_at_spec.rb": "25ab415d4a3b2bbbf225f1e3410978dc",
+  "spec/acceptance/values_spec.rb": "7cd9f430afad102cae1feb5d4a6cc743",
+  "spec/acceptance/zip_spec.rb": "fc7b9e42b408d0fe2171b4eabfcfd585",
+  "spec/default_facts.yml": "d4442f09ee2f33f2d55f078d0ee2634f",
   "spec/fixtures/dscacheutil/root": "e1a7622f55f3d1be258c9a5b16b474be",
   "spec/fixtures/lsuser/root": "2ed657fa157372a81634539bb1a56be8",
-  "spec/fixtures/test/manifests/absolute_path.pp": "79e9da69f05adc0e1ed41c20bf14e95f",
-  "spec/fixtures/test/manifests/absolutepath.pp": "8561fa141028cd38d0b8409cd69a1372",
-  "spec/fixtures/test/manifests/array.pp": "0e1d4146a9b2dd56063b2cab6f3d7571",
-  "spec/fixtures/test/manifests/bool.pp": "cf75826f36025bd73ff7f479acf7196d",
-  "spec/fixtures/test/manifests/deftype.pp": "b9dbd15e3f4a2dd53aac7f26322abf0c",
-  "spec/fixtures/test/manifests/ensure_resources.pp": "3265ae7af9382cfe7d9a13527265dcc9",
-  "spec/fixtures/test/manifests/float.pp": "132f9a63e60bba2fba68be83208c2e28",
-  "spec/fixtures/test/manifests/hash.pp": "84d647482ef0c7dc35348c13fb0ca23e",
-  "spec/fixtures/test/manifests/httpsurl.pp": "9047fc382d215ae55c065b0798a82a2d",
-  "spec/fixtures/test/manifests/httpurl.pp": "7165bf5607a4808f3da3f9baca911240",
-  "spec/fixtures/test/manifests/integer.pp": "3cb3807714ddcde25cd8eeca61581e3b",
-  "spec/fixtures/test/manifests/ip_address.pp": "78deea27fe1ff9e85c360eced4d2c256",
-  "spec/fixtures/test/manifests/ipv4.pp": "b4f0dfe6ae06d4f8b284d24e55f6a6a2",
-  "spec/fixtures/test/manifests/ipv6.pp": "4764f683b6013556e20d8669b21b5bdc",
-  "spec/fixtures/test/manifests/numeric.pp": "bffd26d7c0bb53628369f42c14b342cb",
-  "spec/fixtures/test/manifests/string.pp": "27b69c1eb36250bfbd474a0ef9ba847b",
-  "spec/fixtures/test/manifests/unixpath.pp": "fd062024efdf731e19026901d3fcc075",
-  "spec/fixtures/test/manifests/windowspath.pp": "7f942ec8f883a3ac0fcaf960ea24b7d8",
-  "spec/functions/abs_spec.rb": "7c0ebbd787b788d32b9bb21fe9061a2f",
-  "spec/functions/any2array_spec.rb": "22b7ce032a34d02b6858360025eb7644",
-  "spec/functions/any2bool_spec.rb": "d090dde9be26601a38980e8f77fa5970",
-  "spec/functions/assert_private_spec.rb": "a7e79ac7a1b28610a0e57e38e913c9fa",
-  "spec/functions/base64_spec.rb": "fa279d9a4f3060ee3f467e35b050d528",
-  "spec/functions/basename_spec.rb": "4aec9efc4fc6ed35de82d93b34dc0fab",
-  "spec/functions/bool2num_spec.rb": "6609136ff067b90d41cf27bf8838c3ea",
-  "spec/functions/bool2str_spec.rb": "52560617234393f960aedb496b49a628",
-  "spec/functions/camelcase_spec.rb": "4a13d3323535291fef3f40a96710acdb",
-  "spec/functions/capitalize_spec.rb": "31a8d497b274653d5ede70a0187d4053",
-  "spec/functions/ceiling_spec.rb": "47bd74569f8979d9195df06a863de93b",
-  "spec/functions/chomp_spec.rb": "8be3a83a34945dcaa6e8e193cf2751e4",
-  "spec/functions/chop_spec.rb": "8e1f661e93dd87b8bbeebe293fe16612",
-  "spec/functions/clamp_spec.rb": "65dab1e9aceb2cb4e41ef9c0c65a7ba3",
-  "spec/functions/concat_spec.rb": "4161a254ff4c21497e61a62ce84dafe8",
-  "spec/functions/convert_base_spec.rb": "f031e84b18cb010bc6233be3e4bcff83",
-  "spec/functions/count_spec.rb": "14ab4e4b10fe33d69d0662357cd4bf8b",
-  "spec/functions/deep_merge_spec.rb": "3d77b59573eae569e445b425e7dad120",
-  "spec/functions/defined_with_params_spec.rb": "c592e82de04ab45222b36478ee7040e6",
-  "spec/functions/delete_at_spec.rb": "188a3143799bd5cf121982883c7dc1c8",
-  "spec/functions/delete_regex_spec.rb": "c049a3926aded4b6a804f1c824c57d2f",
-  "spec/functions/delete_spec.rb": "d7c589404fdc3a6b65da7ecf1f7e0b02",
-  "spec/functions/delete_undef_values_spec.rb": "a2c138145333e1873ee4bf23d091f86a",
-  "spec/functions/delete_values_spec.rb": "e20b68a589002f1e2b52873d3dbcfb49",
-  "spec/functions/deprecation_spec.rb": "f5d7355b687eaaa15c20fdb214671c2a",
-  "spec/functions/difference_spec.rb": "66ba399c0bace1a131ecdb365e0afd4e",
-  "spec/functions/dig44_spec.rb": "89631bb7282f7d3c9b75d79f48446c65",
-  "spec/functions/dig_spec.rb": "61708160da38852c3c78bc8563e0fcb2",
-  "spec/functions/dirname_spec.rb": "e80baeab6a166284f5069263fb5e37b7",
-  "spec/functions/dos2unix_spec.rb": "d0cfe5fe19d2bf33320e6f47789826c6",
-  "spec/functions/downcase_spec.rb": "e2c24d41c6fb840f7b66c5205c942780",
-  "spec/functions/empty_spec.rb": "e6d06c193869ce8c97d3e67d5c5c5b4f",
-  "spec/functions/ensure_packages_spec.rb": "da640bb4a2831976fbe208d48b176e52",
-  "spec/functions/ensure_resource_spec.rb": "e1ebbf9475781d86b58541a5846eda0b",
-  "spec/functions/ensure_resources_spec.rb": "d94a7d25f2a7e7a7719cdb6f626b3368",
-  "spec/functions/flatten_spec.rb": "5d59251fa8da0e4c8a376a513a25bc7a",
-  "spec/functions/floor_spec.rb": "7d110b1f994432e1c6c7c004a3dedbe4",
-  "spec/functions/fqdn_rand_string_spec.rb": "950a33e5ad8056fbfe564ec7e3b9a583",
-  "spec/functions/fqdn_rotate_spec.rb": "83f00ce0c48dec632e1aaa8192bb51cf",
-  "spec/functions/fqdn_uuid_spec.rb": "1b2980fcbecc4b51bdc6de01e9b001b7",
-  "spec/functions/get_module_path_spec.rb": "ef22bd80ce5dedb069830d5aa10572c1",
-  "spec/functions/getparam_spec.rb": "359d7c9349ec0e5666bb38e2d9224621",
-  "spec/functions/getvar_spec.rb": "3c7884e012bdb596df3d0640533dab96",
-  "spec/functions/glob_spec.rb": "98e054f995a0d38002d9373b5e6acbc0",
-  "spec/functions/grep_spec.rb": "0e917284860c5f96fdf56301012ba199",
-  "spec/functions/has_interface_with_spec.rb": "473c000e461c3497f8461eb17cf73430",
-  "spec/functions/has_ip_address_spec.rb": "7b36b993ea32757e74be9909906bd165",
-  "spec/functions/has_ip_network_spec.rb": "7086a27623ba91c5ff069397a32172c4",
-  "spec/functions/has_key_spec.rb": "eaa046db8632d6f76893e4b9df7b3e31",
-  "spec/functions/hash_spec.rb": "53a059e13781fac6b4f8eb660655d58f",
-  "spec/functions/intersection_spec.rb": "e906cb8ceb39b644b4b338adcd4dda26",
-  "spec/functions/is_a_spec.rb": "7d6322426d629e5302c52455d9c4cd55",
-  "spec/functions/is_array_spec.rb": "26d7eab025f333d2c4a8baf89ef4e36e",
-  "spec/functions/is_bool_spec.rb": "40569a4cdb50af0cc21ad749ac18e6ef",
-  "spec/functions/is_domain_name_spec.rb": "4ea3825d5b77a5d75eab8228dcc738f9",
-  "spec/functions/is_email_address_spec.rb": "699c4573dfd00db8993a18afc0eaf875",
-  "spec/functions/is_float_spec.rb": "8aedd9e622cd1b861d99523532dc4fc1",
-  "spec/functions/is_function_available.rb": "f8ab234d536532c3629ff6a5068e7877",
-  "spec/functions/is_hash_spec.rb": "11563529f0f1f821769edb3131277100",
-  "spec/functions/is_integer_spec.rb": "8b888debc828b0b1441b023050e0ce8c",
-  "spec/functions/is_ip_address_spec.rb": "04a15328803bb47ae431eff63aa555df",
-  "spec/functions/is_ipv4_address_spec.rb": "339b8c79925bb70c0de19468d58ab64a",
-  "spec/functions/is_ipv6_address_spec.rb": "9743a0f2bfda70ace128d2f476a208b9",
-  "spec/functions/is_mac_address_spec.rb": "532b8c4c63b37849e7fb9122d163ae3a",
-  "spec/functions/is_numeric_spec.rb": "cb846f44e8f6d79161686d7b3729967c",
-  "spec/functions/is_string_spec.rb": "56f34694781dfcf774e43bca06057fec",
-  "spec/functions/join_keys_to_values_spec.rb": "f99dff6550fdb7c245ed4dcaca0a16a3",
-  "spec/functions/join_spec.rb": "e190fbce526b3f4f7bb8aac029338ece",
-  "spec/functions/keys_spec.rb": "fba0bfa928b5684d5c918d6c06edd06d",
-  "spec/functions/length.rb": "c07a267ccccc4b4edbbfad155dc21475",
-  "spec/functions/load_module_metadata_spec.rb": "431fbe84d627a5c4398f432caaec96f8",
-  "spec/functions/loadjson_spec.rb": "76cbe175c90a596892b799d8e4d599e5",
-  "spec/functions/loadyaml_spec.rb": "60e283bc07adc67bc2c934424bf01b8d",
-  "spec/functions/lstrip_spec.rb": "892229ce8657490c72fc860fb0dda1b6",
-  "spec/functions/max_spec.rb": "47de8d59070d8d51b2184731f5d1aa43",
-  "spec/functions/member_spec.rb": "6a988e6368c1ce090b47fe41efbc041c",
-  "spec/functions/merge_spec.rb": "f71b782bf0f2331737b1873602fc96d2",
-  "spec/functions/min_spec.rb": "8b38e2a989912406cd2c57dcd3a460c4",
-  "spec/functions/num2bool_spec.rb": "7c4fd30e41a11b1bd0d9e5233340f16b",
-  "spec/functions/parsejson_spec.rb": "958db1dde2f2244f458c399e0c3231e0",
-  "spec/functions/parseyaml_spec.rb": "19a2add90ca08d5a17c4e3aff89fe3c0",
-  "spec/functions/pick_default_spec.rb": "ab9ef2e9111cfd2709313e0e3c3befa2",
-  "spec/functions/pick_spec.rb": "786044a71e3bd673212949c12f37b10f",
-  "spec/functions/prefix_spec.rb": "2402d2ad5108050bb5c20b3ea58b64be",
-  "spec/functions/private_spec.rb": "f404771c4590a0cd7ce61ddff8f3eb7b",
-  "spec/functions/pw_hash_spec.rb": "f4bd9cf588d8ec5b930224dc171ee884",
-  "spec/functions/range_spec.rb": "d3af56cc8a137059423f8738e343ccff",
-  "spec/functions/regexpescape_spec.rb": "ce027e1b99674f39de8ddffcfed8396e",
-  "spec/functions/reject_spec.rb": "8ecbca64a9817ebef76be96dcf6cdeeb",
-  "spec/functions/reverse_spec.rb": "e40754fd34e96ac206308958504ae315",
-  "spec/functions/round_spec.rb": "cd598812ce87c7aa52ccc8824e0b4fb2",
-  "spec/functions/rstrip_spec.rb": "748f4587c12b5a590b985f111e282a8d",
-  "spec/functions/seeded_rand_spec.rb": "eb56445d10962d81ed935b53826da349",
-  "spec/functions/shell_escape_spec.rb": "bf108573c041f0c228f6d47d367d0aa3",
-  "spec/functions/shell_join_spec.rb": "92f31bd98d6e8e30e5f758f50bcb8a75",
-  "spec/functions/shell_split_spec.rb": "430f58733cc7855e56bfc918971b3fc1",
-  "spec/functions/shuffle_spec.rb": "be5d43184f2ca42db4f452085a4730fd",
-  "spec/functions/size_spec.rb": "f5e35878331bb12d9639522e38cc81c8",
-  "spec/functions/sort_spec.rb": "d9533dd37c6263b92895f7eba8485248",
-  "spec/functions/squeeze_spec.rb": "ffcf3b44cbdd45e14eb1173d2b7d1d99",
-  "spec/functions/str2bool_spec.rb": "607b25fb0badd0da5acb86c63437c8be",
-  "spec/functions/str2saltedsha512_spec.rb": "07586b0026757cd39229c12c7221808b",
-  "spec/functions/strftime_spec.rb": "67d8d376dd3ee8afdd47b5a7ddd53d7f",
-  "spec/functions/strip_spec.rb": "023132b8bd0820da254f74c6fe31bb80",
-  "spec/functions/suffix_spec.rb": "dfe26a61bf0185291b6ae868e9d0de20",
-  "spec/functions/swapcase_spec.rb": "90bace1b004aa63d46eb6481c6dce2b1",
-  "spec/functions/time_spec.rb": "6dc8f5b42cf89345d2de424bfe19be90",
-  "spec/functions/to_bytes_spec.rb": "b771f8490d922de46a519e407d358139",
-  "spec/functions/try_get_value_spec.rb": "b917b899f5d29764dd4b1b07e07ec6ce",
-  "spec/functions/type3x_spec.rb": "eed4ce3a2bc92d14effedefef9690654",
-  "spec/functions/type_of_spec.rb": "83755d9390b9c00e086a007edff7fd9b",
-  "spec/functions/type_spec.rb": "7a61b4af7d3d83be590d783a7e5e80f8",
-  "spec/functions/union_spec.rb": "a290a38e443b856a476d14d4b1dc72fb",
-  "spec/functions/unique_spec.rb": "8c569613c4f9e006162c03c9f1c49082",
-  "spec/functions/unix2dos_spec.rb": "628c8a0c608d1fa0dd09bd1b5af97c1f",
-  "spec/functions/upcase_spec.rb": "4f0461a20c03d618f0c18da39bebcf65",
-  "spec/functions/uriescape_spec.rb": "1458afbe7e7e11dcaad8d295a7f2be59",
-  "spec/functions/validate_absolute_path_spec.rb": "5adbf0a0ac8b23e86195deaf3e4bd371",
-  "spec/functions/validate_array_spec.rb": "3aa76f3731754c637acc94b59c79efb0",
-  "spec/functions/validate_augeas_spec.rb": "d598e89a23912be9f24d39b809f30b47",
-  "spec/functions/validate_bool_spec.rb": "d1b43cd294d0588ac6d67d5d3c77a42a",
-  "spec/functions/validate_cmd_spec.rb": "34a4e623ab0ce7d4c218a837f896c1ea",
-  "spec/functions/validate_domain_name_spec.rb": "7feb0dd8e0dad614ff8dc69e44d5f99f",
-  "spec/functions/validate_email_address_spec.rb": "1296f9934d102258091379ee07f9a2a8",
-  "spec/functions/validate_hash_spec.rb": "0b3ac3f7262f13ef14e3df937c8d104c",
-  "spec/functions/validate_integer_spec.rb": "ec55ab34e3ec4f09722349cd6aac77a6",
-  "spec/functions/validate_ip_address_spec.rb": "ba8c92e30f1af9e6839a2901e002c3f3",
-  "spec/functions/validate_ipv4_address_spec.rb": "d5d956651629f95ea531ac03b71e247b",
-  "spec/functions/validate_ipv6_address_spec.rb": "7ee0d6097666558d8627de424c26ef75",
-  "spec/functions/validate_legacy_spec.rb": "a1a3af70e71d0a6b848d75c518949b3b",
-  "spec/functions/validate_numeric_spec.rb": "c2f01b9c9aeae75683563ef7d3951bbb",
-  "spec/functions/validate_re_spec.rb": "27bcf99cd815b755548cd3979753b2f3",
-  "spec/functions/validate_slength_spec.rb": "c292023b2e61298499ff1f791fc03005",
-  "spec/functions/validate_string_spec.rb": "bc6735359ada0b3ccf69f515231e3808",
-  "spec/functions/validate_x509_rsa_key_pair_spec.rb": "24810bdb8ac473ae1168f1b2c5708170",
-  "spec/functions/values_at_spec.rb": "866ba43a4b606f6e9e72ac91c07408bd",
-  "spec/functions/values_spec.rb": "6b8f39665cb8fdb03658d838e50b55b0",
-  "spec/functions/zip_spec.rb": "986defd43a001ff28fe7c90b0366812e",
-  "spec/monkey_patches/alias_should_to_must.rb": "b19ee31563afb91a72f9869f9d7362ff",
-  "spec/monkey_patches/publicize_methods.rb": "c690e444b77c871375d321e413e28ca1",
-  "spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07",
-  "spec/spec_helper_acceptance.rb": "cd589056b52031da19d9c31ed86ea922",
-  "spec/spec_helper_local.rb": "1e3ad3c06a11cbcb813dc1d31973cbda",
-  "spec/support/shared_data.rb": "9758f8ba2958965d287387a2513dac73",
-  "spec/unit/facter/facter_dot_d_spec.rb": "420339a544851f2c7ee6fa4c651bdce8",
-  "spec/unit/facter/package_provider_spec.rb": "3a6ba799822fbcabc9adab5880260b7a",
-  "spec/unit/facter/pe_version_spec.rb": "d0fa6c0d5b01a4b9fd36ed4168635e9f",
-  "spec/unit/facter/root_home_spec.rb": "036c160d5543f4f3e80a300a3a170b77",
-  "spec/unit/facter/service_provider_spec.rb": "a97efb411817a44c511cd6cd79d9af8c",
-  "spec/unit/facter/util/puppet_settings_spec.rb": "6f9df9b10a1b39245ecdf002616a4122",
-  "spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb": "0145a78254ea716e5e7600d9464318a8",
-  "spec/unit/puppet/parser/functions/is_absolute_path_spec.rb": "52f8d3b9011fb1fd8a2a429fe8b2ae08",
-  "spec/unit/puppet/provider/file_line/ruby_spec.rb": "d9c828057ce07546df1d5da6806120f2",
-  "spec/unit/puppet/type/anchor_spec.rb": "06a669dffa44d716bf19b4e7f5f1d75d",
-  "spec/unit/puppet/type/file_line_spec.rb": "83e11166de4abe69cdf0dc7450e79778",
+  "spec/fixtures/test/manifests/base32.pp": "2662eb916f3830689f40decfe8fddae8",
+  "spec/fixtures/test/manifests/base64.pp": "935f9c1b4ac741c58b7abd49d3cfb794",
+  "spec/fixtures/test/manifests/deftype.pp": "1f2e86fa39604fdfde8fd20b9ae92813",
+  "spec/fixtures/test/manifests/ensure_resources.pp": "898c473ba5641313294827f4b4845bd6",
+  "spec/functions/abs_spec.rb": "0821179e4127a8754ccf509c759b7c41",
+  "spec/functions/any2array_spec.rb": "8ca97ceb68a60ff5c4ade6e6aa7b81df",
+  "spec/functions/any2bool_spec.rb": "48b23ce295c256aa14cfeac0501cc3a5",
+  "spec/functions/assert_private_spec.rb": "d48bc3c4ed2115c18859b2db1490795c",
+  "spec/functions/base64_spec.rb": "5083c40b825f86863cc2950d97d3807b",
+  "spec/functions/basename_spec.rb": "beeae06a6fc449d44352031e4a61e900",
+  "spec/functions/bool2num_spec.rb": "bb82d4eed099e97c5af545cdce3445d6",
+  "spec/functions/bool2str_spec.rb": "286b56a5bab37d4849e10b7f0f9630ed",
+  "spec/functions/camelcase_spec.rb": "e4693de9fcd022bc9c798e27bf1c11ae",
+  "spec/functions/capitalize_spec.rb": "be58e5ff4956bcca07055d66369021d2",
+  "spec/functions/ceiling_spec.rb": "b3a9f9285b217d9eb407981e39a7552f",
+  "spec/functions/chomp_spec.rb": "746af6dc903bb7f20ef801a1ab3bc40e",
+  "spec/functions/chop_spec.rb": "fc59485a227d36556f88a77e53bcfde4",
+  "spec/functions/clamp_spec.rb": "8094bc19ff0fe82dfd0a072b654bf318",
+  "spec/functions/concat_spec.rb": "e21069451db12fb90e30a2c2f01879df",
+  "spec/functions/convert_base_spec.rb": "534bd90106b2c58f736b897974c5a10a",
+  "spec/functions/count_spec.rb": "d5990b080447cff101f05d8aeb1e6df6",
+  "spec/functions/deep_merge_spec.rb": "2bb3422045040c4dac2ad75fbae07995",
+  "spec/functions/defined_with_params_spec.rb": "b4e13e71b935fd4823321b297abfb3e9",
+  "spec/functions/delete_at_spec.rb": "eeb300241f56b186138510969cfc6088",
+  "spec/functions/delete_regex_spec.rb": "3004d1f3a40297da06816c9a40ebbcd7",
+  "spec/functions/delete_spec.rb": "16b01482d05b790b53718b0436cf31b3",
+  "spec/functions/delete_undef_values_spec.rb": "f19b0b244f0483f25fac1dbde5f5568b",
+  "spec/functions/delete_values_spec.rb": "a61b115f69844f7f416d3c2e9dfa308e",
+  "spec/functions/deprecation_spec.rb": "a8c77ef118546f3a9bacbe3e71fa1f16",
+  "spec/functions/difference_spec.rb": "a5d33319d500e4752714ac83bee4d35d",
+  "spec/functions/dig44_spec.rb": "818be861d447c8efcc84f4d8f94f0546",
+  "spec/functions/dig_spec.rb": "ac6671760e3864540aa0790ee37bd5ab",
+  "spec/functions/dirname_spec.rb": "23220e14486056dd9dcce127aa9ada16",
+  "spec/functions/dos2unix_spec.rb": "f7f10a39d4d4d42bef7a1bc99d97ea1c",
+  "spec/functions/downcase_spec.rb": "f9afb4203c5587ad9082801e02547f98",
+  "spec/functions/empty_spec.rb": "5b10598d2782eb25b10e4dd9e186aca0",
+  "spec/functions/ensure_packages_spec.rb": "aa087a5474ffe29d3a8a6f5e8bf5aacb",
+  "spec/functions/ensure_resource_spec.rb": "e3762777948cf285c5c2ce806ef1992b",
+  "spec/functions/ensure_resources_spec.rb": "9222a26a12afacf5e31ae19174a534fd",
+  "spec/functions/extname_spec.rb": "1b8fff4c728711931b66d36caabae937",
+  "spec/functions/flatten_spec.rb": "f40671d863548ea6626a79c184cd69fd",
+  "spec/functions/floor_spec.rb": "b7eeadfab998dd364cf92e8b13981a8a",
+  "spec/functions/fqdn_rand_string_spec.rb": "91371725b89be5b026a7d9a179066021",
+  "spec/functions/fqdn_rotate_spec.rb": "e940b050175501f857efcb1b279f53a4",
+  "spec/functions/fqdn_uuid_spec.rb": "60526a453f556867b369496ca1215a86",
+  "spec/functions/get_module_path_spec.rb": "2d22d3b677b3fe67337d6d9e88994cc9",
+  "spec/functions/getparam_spec.rb": "807694642f3ebdfafca4c8f0eca4c062",
+  "spec/functions/getvar_spec.rb": "f4b6e5e025feb8ef1a1425d85c615ae0",
+  "spec/functions/glob_spec.rb": "537139a45aa1acfb605aa0cb6b598b73",
+  "spec/functions/grep_spec.rb": "c8bd616f1d4940261e8a9f7b05254528",
+  "spec/functions/has_interface_with_spec.rb": "d484da75727170eb3ff22bbc71394fd1",
+  "spec/functions/has_ip_address_spec.rb": "811d63a9c87a1de43a18d07c8ee5a796",
+  "spec/functions/has_ip_network_spec.rb": "9ec0c0c607a60d2dde3a66fc969e4478",
+  "spec/functions/has_key_spec.rb": "d4d97da7d35a794e72d1bbc5e0a4838f",
+  "spec/functions/hash_spec.rb": "a9d483dfbd3f2d66b457851ff3144b1a",
+  "spec/functions/intersection_spec.rb": "72688d38e9301d9e15bae6bb3f7d8568",
+  "spec/functions/is_a_spec.rb": "e657f393cc3572883aa2ab872840f4bf",
+  "spec/functions/is_array_spec.rb": "9e9bc571ecb67b57ad0033da1e02a578",
+  "spec/functions/is_bool_spec.rb": "598acad9be16faa86a4370d7646b06d9",
+  "spec/functions/is_domain_name_spec.rb": "0e2cf9c9410827484ee3652591757faf",
+  "spec/functions/is_email_address_spec.rb": "f3e60f28e9d66d7707a434a8edc79900",
+  "spec/functions/is_float_spec.rb": "344ff678f331307c20f3c5b7dba89f55",
+  "spec/functions/is_function_available_spec.rb": "0f46d970fca74c87dbcbbaa588b6dc37",
+  "spec/functions/is_hash_spec.rb": "cec4b5638ea3f871350a055cee98ea11",
+  "spec/functions/is_integer_spec.rb": "0ba7bc665d334191a838bd34f6c97a75",
+  "spec/functions/is_ip_address_spec.rb": "704138919636e1b758417d561042f7bc",
+  "spec/functions/is_ipv4_address_spec.rb": "fa7ed52ae8e95eb53640ddedfb75c776",
+  "spec/functions/is_ipv6_address_spec.rb": "3e58b90f1e6cd581a3744856e1f82b48",
+  "spec/functions/is_mac_address_spec.rb": "be6fc820b9583aa23730581a7fd0218b",
+  "spec/functions/is_numeric_spec.rb": "57302fc9c642e6d9d0299b403f8ff082",
+  "spec/functions/is_string_spec.rb": "aa2821208c0f039d748b871a6a6560af",
+  "spec/functions/join_keys_to_values_spec.rb": "a365b021aea1a0a54f27b24b0b1d3f24",
+  "spec/functions/join_spec.rb": "2c1da15b52b6a9cea55825328f2e0ada",
+  "spec/functions/keys_spec.rb": "185acb2eeb716cf93c99cbbd41327224",
+  "spec/functions/length_spec.rb": "2f9edfc8fbb4058a267bd00674cad654",
+  "spec/functions/load_module_metadata_spec.rb": "2419390d7e41728aa460ef46cc06319f",
+  "spec/functions/loadjson_spec.rb": "12019b907452e777eacedb8b974abdae",
+  "spec/functions/loadyaml_spec.rb": "0a6dd0a389c49f90d61f915b6718411a",
+  "spec/functions/lstrip_spec.rb": "552c469f04c8de63b6c8cefb0280cba3",
+  "spec/functions/max_spec.rb": "e82809c424860b8d94ef8af70abd4891",
+  "spec/functions/member_spec.rb": "f82cacb72d59a306ffe262b2382c7f19",
+  "spec/functions/merge_spec.rb": "48761dac5afc99bd381f76f88927cdb0",
+  "spec/functions/min_spec.rb": "4e8d5f82ad27d8f5b8c3ae1595aa56a1",
+  "spec/functions/num2bool_spec.rb": "fe3c3dbec9787622850175db510fe4f0",
+  "spec/functions/os_version_gte_spec.rb": "175b70864c196b0c99473b2206d1b09b",
+  "spec/functions/parsejson_spec.rb": "70b494139e7289908b6adb36ea8f3bed",
+  "spec/functions/parseyaml_spec.rb": "aace674f64e4629e6377276b307ea723",
+  "spec/functions/pick_default_spec.rb": "43306416fdac7e7a3378fe51cb9bf9e7",
+  "spec/functions/pick_spec.rb": "856384e60757e1d94ca3aef161be3d0a",
+  "spec/functions/prefix_spec.rb": "5e6eb13f3f9834e975152812f22f2e99",
+  "spec/functions/private_spec.rb": "dbb87b05cdabb852a4abcb373303da50",
+  "spec/functions/pw_hash_spec.rb": "d9bdce271d38ce6ec1d8258e807a7c67",
+  "spec/functions/range_spec.rb": "4351efcda0bdf89d9fc4b533ab085e66",
+  "spec/functions/regexpescape_spec.rb": "2e36ec5d28cb6deb264cf50356ba52c3",
+  "spec/functions/reject_spec.rb": "6b083c5d8519eb2af796150596e659de",
+  "spec/functions/reverse_spec.rb": "dbabe39664d7323a99e25c248e2c0ae8",
+  "spec/functions/round_spec.rb": "9dbb5c89f9c4fc56588830acbf38e713",
+  "spec/functions/rstrip_spec.rb": "c96cc66210bbd5fa4914ed9080e91fd5",
+  "spec/functions/seeded_rand_spec.rb": "d0473836456fa59f0a4ded16057d75aa",
+  "spec/functions/seeded_rand_string_spec.rb": "3388ad5479b51a87a9ff1f7539ee11fb",
+  "spec/functions/shell_escape_spec.rb": "513534e47818ce650b343985febedf9e",
+  "spec/functions/shell_join_spec.rb": "d9861fe1324a239784873ee9eeadfe7c",
+  "spec/functions/shell_split_spec.rb": "f6ab347d718d140ffdcccd0590c889d8",
+  "spec/functions/shuffle_spec.rb": "3c775cb2fae13839f477cbec188eea1a",
+  "spec/functions/size_spec.rb": "dc4aa41250a64e728ce8135e888e3081",
+  "spec/functions/sort_spec.rb": "e63f4b92a90d5e9c7e541a41dc89df12",
+  "spec/functions/sprintf_hash_spec.rb": "1b014e8c0a44b935ec0c045e275ad6b3",
+  "spec/functions/squeeze_spec.rb": "fa3531e7cd49989b1ece7d48ccd10255",
+  "spec/functions/str2bool_spec.rb": "d099ca74f02ac231f699e59d7a41bafb",
+  "spec/functions/str2saltedsha512_spec.rb": "815dfb2f7c65f81769c117129e45bf85",
+  "spec/functions/strftime_spec.rb": "7f57c8b5350e9bfd4eb0f414f9192778",
+  "spec/functions/strip_spec.rb": "1212eef324f730400c8a62d9db95a22c",
+  "spec/functions/suffix_spec.rb": "5e2834f3885002c9ff9ac20dd6333415",
+  "spec/functions/swapcase_spec.rb": "d0dc69eda3fcdf043cc116ccb6ee3b28",
+  "spec/functions/time_spec.rb": "0d1032f734d35e53ee33904d17465cbc",
+  "spec/functions/to_bytes_spec.rb": "dbc093a1a72429a0a67e784ecabc100a",
+  "spec/functions/to_json_pretty_spec.rb": "42d902947a4afc3708846d3864a5f5a4",
+  "spec/functions/to_json_spec.rb": "1e2d9917ddf37af4e241b89bd9e009e3",
+  "spec/functions/to_yaml_spec.rb": "1c3302e5d19b2ae929ecdf44668b0492",
+  "spec/functions/try_get_value_spec.rb": "53ab2e553ae441821ad02be3c952a34a",
+  "spec/functions/type3x_spec.rb": "9898ca5ab31f4fded1a5d38767e7e981",
+  "spec/functions/type_of_spec.rb": "ecfeb9d47e54f5aae421f7855853d47a",
+  "spec/functions/type_spec.rb": "7c70254652b2e46ef7c80dce5667c32b",
+  "spec/functions/union_spec.rb": "c3bf55649e068b810e72cbb5bfcf7cbb",
+  "spec/functions/unique_spec.rb": "c596db252b2730fe4a603900110f3b03",
+  "spec/functions/unix2dos_spec.rb": "77e6d0e7c703576924981038472c8e4e",
+  "spec/functions/upcase_spec.rb": "363e49846e4ca0a3a6eca2c19e0f2c04",
+  "spec/functions/uriescape_spec.rb": "d0730544b94c15d63e99e7ed50c13e92",
+  "spec/functions/validate_absolute_path_spec.rb": "a549c5e4697689c8d68d69df43c0cf10",
+  "spec/functions/validate_array_spec.rb": "c890aabc47c35316deeed9921a941020",
+  "spec/functions/validate_augeas_spec.rb": "4bf035ec4548a00d42f73643374d6f58",
+  "spec/functions/validate_bool_spec.rb": "5e835885844167c3d5a31172a5c9f422",
+  "spec/functions/validate_cmd_spec.rb": "179e570e9aec94c5dcaf337a6b431d20",
+  "spec/functions/validate_domain_name_spec.rb": "611f3b301003d11a6a55e293dc3a8e5c",
+  "spec/functions/validate_email_address_spec.rb": "8bac32b793f1e4264ae32df975d4d893",
+  "spec/functions/validate_hash_spec.rb": "5eccbe065b5eda4c5e01278b4bf78d44",
+  "spec/functions/validate_integer_spec.rb": "10affb4021ea0c64e54d4f6bcaf70c78",
+  "spec/functions/validate_ip_address_spec.rb": "dd1abc13784514aa328e44bf2057561a",
+  "spec/functions/validate_ipv4_address_spec.rb": "a9aeef982051cbeabe1b4f279d3e13d2",
+  "spec/functions/validate_ipv6_address_spec.rb": "4bdd3a680ec2d256a9187c174e32f9ba",
+  "spec/functions/validate_legacy_spec.rb": "f5b522d41c65a8a52a0b4f0056b68da6",
+  "spec/functions/validate_numeric_spec.rb": "36891aa54f3b0f3d6c70758ccd2e3ac7",
+  "spec/functions/validate_re_spec.rb": "440d0abad99b0c898aa541d5b5037098",
+  "spec/functions/validate_slength_spec.rb": "4a4440cf424665ccc8b09cfaca52517c",
+  "spec/functions/validate_string_spec.rb": "898fb0e2be0336414aabdfa6202b97f6",
+  "spec/functions/validate_x509_rsa_key_pair_spec.rb": "d73371004571f46dda1837dec3661d39",
+  "spec/functions/values_at_spec.rb": "9b0d8851c3b1ef74dbbfcacd68c033ef",
+  "spec/functions/values_spec.rb": "debbd0e2c93ddf45adfeae82caa2b50f",
+  "spec/functions/zip_spec.rb": "da07c5877fe4318e53c215e981a2ee92",
+  "spec/monkey_patches/alias_should_to_must.rb": "3455626d32375d114ee5622e19a1fa6c",
+  "spec/monkey_patches/publicize_methods.rb": "d2ae9210754b0a4eae0d6bf33737fe90",
+  "spec/spec_helper.rb": "a0540643c8838d5b6677f18e7d5423ea",
+  "spec/spec_helper_acceptance.rb": "d37250e62078059e9ac11bbe6d77356a",
+  "spec/spec_helper_local.rb": "5644c5ce611a9e131cf37106e2a8b841",
+  "spec/support/shared_data.rb": "dfe4cbdbe2833d670a89bcdf3163839b",
+  "spec/type_aliases/absolute_path_spec.rb": "a03a9c6fe2e3e6fbb23cd62c263032c2",
+  "spec/type_aliases/array_spec.rb": "5a7a5be96ccb1347a5a806ef436064e6",
+  "spec/type_aliases/base32_spec.rb": "0468562ed8bffb61bd867b5880941c7a",
+  "spec/type_aliases/base64_spec.rb": "bf479faed128ad00993a88ad390639e9",
+  "spec/type_aliases/bool_spec.rb": "798d1fb0b43cdc7c560ba8b61fb742e6",
+  "spec/type_aliases/compat__ip_address.rb": "7ee3a1f901e33a5a72632cd390629450",
+  "spec/type_aliases/compat__ipv4_spec.rb": "d091b3dcd1fc3a30fe080d9b53a69014",
+  "spec/type_aliases/compat__ipv6_spec.rb": "08005590462f404047995ec86a80e85c",
+  "spec/type_aliases/filemode_spec.rb": "5a42362fc453ab543b8c7e44192e6756",
+  "spec/type_aliases/filesource_spec.rb": "641b9fd2855c4a45b34bc2f4b3d2001b",
+  "spec/type_aliases/float_spec.rb": "e566885fdf22399a54450022bfbfd31a",
+  "spec/type_aliases/fqdn_spec.rb": "21965142591e1fa04c057616caa168f4",
+  "spec/type_aliases/hash_spec.rb": "1b8c49a76db8b5ef44f0f0a8e56c5eb3",
+  "spec/type_aliases/host_spec.rb": "501b84bf281625804d830eb20daf46e3",
+  "spec/type_aliases/httpsurl_spec.rb": "9b2e7d9fc1a0b804d213b1804b175467",
+  "spec/type_aliases/httpurl_spec.rb": "e1063021f8c212933abd560a25cb98b8",
+  "spec/type_aliases/integer_spec.rb": "8f66ae64602543d65e4b784527bf1463",
+  "spec/type_aliases/ip_address_nosubnet_spec.rb": "9d196b9b9522a91ac2bc3a67ccd02d5f",
+  "spec/type_aliases/ip_address_spec.rb": "ae9c24b0ee7d77b967b93ffb13fb67bb",
+  "spec/type_aliases/ip_address_v4_nosubnet_spec.rb": "c30a31b7bcb92eed728be5fef7b45724",
+  "spec/type_aliases/ip_address_v4_spec.rb": "0aacb3967d4ca3a7f8bc3a17e93f141f",
+  "spec/type_aliases/ip_address_v6_alternative_spec.rb": "17da75c696f406ffbd4829a13828fcc5",
+  "spec/type_aliases/ip_address_v6_cidr_spec.rb": "68d397e1c958e018a0537bcabca23d8c",
+  "spec/type_aliases/ip_address_v6_compressed_spec.rb": "508f6e102bbc3c7af4bd24df5e640f40",
+  "spec/type_aliases/ip_address_v6_full_spec.rb": "35ff79b1855e77ffff7c38599cfafaa2",
+  "spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb": "020fc117a134398818910b41a76094aa",
+  "spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb": "f97969e6cdae00e5a1ffbbd71ba7e08e",
+  "spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb": "c5fad1a8e5fee0cfac3ee9f1b5083804",
+  "spec/type_aliases/ip_address_v6_spec.rb": "74a4c54bf8fffc4ebc3e33c12b085640",
+  "spec/type_aliases/numeric_spec.rb": "06ae28964dfad6ca60ac59468c33104b",
+  "spec/type_aliases/port__privileged_spec.rb": "531e8567e3251548324088e1cdac29d6",
+  "spec/type_aliases/port__unprivileged_spec.rb": "ec5aa19f8bfb62307617c0e9b002475d",
+  "spec/type_aliases/port_spec.rb": "6fff6e2cfc7b91e49b6dd169629f8a53",
+  "spec/type_aliases/string_spec.rb": "458ac453f5870066824b6a11ec49f9ae",
+  "spec/type_aliases/unixpath_spec.rb": "04e31be6626f96e605459b4ce8c94395",
+  "spec/type_aliases/windowspath_spec.rb": "a1473316f1745fa3e20be83a2eb026c7",
+  "spec/unit/facter/facter_dot_d_spec.rb": "3853da05ad110c512bbbacce81e17176",
+  "spec/unit/facter/package_provider_spec.rb": "c23d89ad7313f647f917d8a945815693",
+  "spec/unit/facter/pe_version_spec.rb": "f013e4ef5aa532fc2af19ddf3a82cf48",
+  "spec/unit/facter/root_home_spec.rb": "5e8ad2acdfc42674a5f96f4152faab6b",
+  "spec/unit/facter/service_provider_spec.rb": "15ad81eb65f2c87f3e7147da43b91a81",
+  "spec/unit/facter/util/puppet_settings_spec.rb": "f9b29b26e2232cd428d694095e1bb700",
+  "spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb": "c572341a1324a519b14ea6a6981f6a51",
+  "spec/unit/puppet/parser/functions/is_absolute_path_spec.rb": "258f55b8c9563bad0aaa9e98df4d6fc6",
+  "spec/unit/puppet/provider/file_line/ruby_spec.rb": "f5aca0856046c760832822816c44c705",
+  "spec/unit/puppet/provider/file_line/ruby_spec_alter.rb": "afa3589fb59f743bb8c2242c294951b2",
+  "spec/unit/puppet/provider/file_line/ruby_spec_use_cases.rb": "13d2c5198ca879f29d70ca230288b1e8",
+  "spec/unit/puppet/type/anchor_spec.rb": "5f67ab4f4a0cfc40cd2fcdb3f148f026",
+  "spec/unit/puppet/type/file_line_spec.rb": "92c3ac78210f730fc2135e012ded86bb",
   "types/absolutepath.pp": "3ae6f48dd95835df87c5dacea13c88d2",
-  "types/compat/absolute_path.pp": "6d0e102d1098d85d97c8f13051cb2c10",
+  "types/base32.pp": "c1e7d9939641c49af90b07043a52112e",
+  "types/base64.pp": "6e61a5c608ab2147fdf295f97b1052c9",
+  "types/compat/absolute_path.pp": "c500d00e471fa7684abce8c67e2a0a3e",
   "types/compat/array.pp": "43c41022dd743d55c8e9e82ce3ed741c",
   "types/compat/bool.pp": "6e0cd7b2a7e1b9efaa0e273937211e58",
   "types/compat/float.pp": "fd134a0e0e1abd420cec2107780a7afa",
   "types/compat/hash.pp": "3535d98f0f3eaec44d443190f258e9ba",
-  "types/compat/integer.pp": "e85a20e42b3afaf5ec0718a8d9f9c5e3",
+  "types/compat/integer.pp": "d73ad743def0a4e754cbf2e82d5c6b5d",
   "types/compat/ip_address.pp": "d42c7435de30a469a71b69c45d642da7",
-  "types/compat/ipv4.pp": "c84eb3764f45b256a09be68afe61b749",
-  "types/compat/ipv6.pp": "d3c0fada5425d576aeca14ddbee78653",
-  "types/compat/numeric.pp": "f864539d78e95dabf0bab361b4ccc042",
+  "types/compat/ipv4.pp": "962713ea8483c01f2188f87fac1fefa8",
+  "types/compat/ipv6.pp": "bc2c5d46bb49c5180c70c64a8a9ee6ea",
+  "types/compat/numeric.pp": "b9543932cda152dfc2cb7fb554a307f7",
   "types/compat/re.pp": "70b05d4697e61f9af0c212ba063f395d",
   "types/compat/string.pp": "b9a179664c85e121aa0277021627d126",
-  "types/httpsurl.pp": "108225d0273e17d541b239882287ed15",
-  "types/httpurl.pp": "4ba64825b11af75997c59b5acf07c62d",
-  "types/mac.pp": "b6b9a7148111578052bdb34e7ef0ce19",
-  "types/unixpath.pp": "5fc80523e7f474dd84056c44fafd9544",
+  "types/ensure/service.pp": "efa28f903420bb9555910c27a9b810e8",
+  "types/filemode.pp": "3645997b51880205b2272d44d8f04368",
+  "types/filesource.pp": "6cf279ac41a7c44589eedb5a20f0f7ab",
+  "types/fqdn.pp": "f6fb6bf625dab3bd0ab63a1ff7983fb8",
+  "types/host.pp": "69260768a909759bdc31aeaae58d449e",
+  "types/httpsurl.pp": "0355078bb141e257d019dced8d84c729",
+  "types/httpurl.pp": "9928cc404a6d62ef9784ffe2488cfb66",
+  "types/ip/address/nosubnet.pp": "e7c5a338634dfd0eea60cf36092f3fd8",
+  "types/ip/address/v4/cidr.pp": "97c96e70c823cae39d4593d59d4ce037",
+  "types/ip/address/v4/nosubnet.pp": "9590ebd639bc47fd25288d32dee5405d",
+  "types/ip/address/v4.pp": "18165fd02c81c08dff234f83d50662a0",
+  "types/ip/address/v6/alternative.pp": "98d1336a9328653fa5d6d45b72aab76c",
+  "types/ip/address/v6/cidr.pp": "5a09a1ba5e9e75b850a9341ebf0e95ff",
+  "types/ip/address/v6/compressed.pp": "e6daf1c302c84d7f2060a4e8468624a6",
+  "types/ip/address/v6/full.pp": "90527ba76faec01d42f302a754c9ce3c",
+  "types/ip/address/v6/nosubnet/alternative.pp": "b9a6cd5a4c2a2e8013022fd4cfd11a3e",
+  "types/ip/address/v6/nosubnet/compressed.pp": "ca2f53bcc3f659d994a6e0d3fe17861e",
+  "types/ip/address/v6/nosubnet/full.pp": "5fa0bb70ed3e72ac52738ba182f22c1c",
+  "types/ip/address/v6/nosubnet.pp": "612651452cd225ade84fe31750d02903",
+  "types/ip/address/v6.pp": "1f3c0aa34dbc083d26f135246c8576eb",
+  "types/ip/address.pp": "9929a758afc9469acbcff0c2050bb0ab",
+  "types/mac.pp": "6c4a697bca8a68bdc6db1394108df6d0",
+  "types/port/privileged.pp": "c4ce776dd07a3c8dd3379db8cd49e32a",
+  "types/port/unprivileged.pp": "85359128fa9261fe8bf58c8525574404",
+  "types/port.pp": "b1edd08c4eff860b3ea8bd84cd48ba81",
+  "types/unixpath.pp": "b64a48701e7adfda45d31fd80bee4ad0",
   "types/windowspath.pp": "4c1eda331ecb43de98c29ed22d0ad448"
 }
\ No newline at end of file
index 5c5fb1f..5025ed9 100644 (file)
 # The cache is stored in $libdir/facts_dot_d.cache as a mode
 # 600 file and will have the end result of not calling your
 # fact scripts more often than is needed
-
 class Facter::Util::DotD
   require 'yaml'
 
-  def initialize(dir="/etc/facts.d", cache_file=File.join(Puppet[:libdir], "facts_dot_d.cache"))
+  def initialize(dir = '/etc/facts.d', cache_file = File.join(Puppet[:libdir], 'facts_dot_d.cache'))
     @dir = dir
     @cache_file = cache_file
     @cache = nil
-    @types = {".txt" => :txt, ".json" => :json, ".yaml" => :yaml}
+    @types = { '.txt' => :txt, '.json' => :json, '.yaml' => :yaml }
   end
 
   def entries
-    Dir.entries(@dir).reject { |f| f =~ /^\.|\.ttl$/ }.sort.map { |f| File.join(@dir, f) }
+    Dir.entries(@dir).reject { |f| f =~ %r{^\.|\.ttl$} }.sort.map { |f| File.join(@dir, f) }
   rescue
     []
   end
@@ -35,17 +34,17 @@ class Facter::Util::DotD
 
     type = :script if type == :unknown && File.executable?(file)
 
-    return type
+    type
   end
 
   def txt_parser(file)
     File.readlines(file).each do |line|
-      if line =~ /^([^=]+)=(.+)$/
-        var = $1; val = $2
+      next unless line =~ %r{^([^=]+)=(.+)$}
+      var = Regexp.last_match(1)
+      val = Regexp.last_match(2)
 
-        Facter.add(var) do
-          setcode { val }
-        end
+      Facter.add(var) do
+        setcode { val }
       end
     end
   rescue StandardError => e
@@ -60,7 +59,7 @@ class Facter::Util::DotD
       raise
     end
 
-    JSON.load(File.read(file)).each_pair do |f, v|
+    JSON.parse(File.read(file)).each_pair do |f, v|
       Facter.add(f) do
         setcode { v }
       end
@@ -85,7 +84,9 @@ class Facter::Util::DotD
     result = cache_lookup(file)
     ttl = cache_time(file)
 
-    unless result
+    if result
+      Facter.debug("Using cached data for #{file}")
+    else
       result = Facter::Util::Resolution.exec(file)
 
       if ttl > 0
@@ -93,17 +94,15 @@ class Facter::Util::DotD
         cache_store(file, result)
         cache_save!
       end
-    else
-      Facter.debug("Using cached data for #{file}")
     end
 
     result.split("\n").each do |line|
-      if line =~ /^(.+)=(.+)$/
-        var = $1; val = $2
+      next unless line =~ %r{^(.+)=(.+)$}
+      var = Regexp.last_match(1)
+      val = Regexp.last_match(2)
 
-        Facter.add(var) do
-          setcode { val }
-        end
+      Facter.add(var) do
+        setcode { val }
       end
     end
   rescue StandardError => e
@@ -113,15 +112,15 @@ class Facter::Util::DotD
 
   def cache_save!
     cache = load_cache
-    File.open(@cache_file, "w", 0600) { |f| f.write(YAML.dump(cache)) }
-  rescue
+    File.open(@cache_file, 'w', 0o600) { |f| f.write(YAML.dump(cache)) }
+  rescue # rubocop:disable Lint/HandleExceptions
   end
 
   def cache_store(file, data)
     load_cache
 
-    @cache[file] = {:data => data, :stored => Time.now.to_i}
-  rescue
+    @cache[file] = { :data => data, :stored => Time.now.to_i }
+  rescue # rubocop:disable Lint/HandleExceptions
   end
 
   def cache_lookup(file)
@@ -131,21 +130,18 @@ class Facter::Util::DotD
 
     ttl = cache_time(file)
 
-    if cache[file]
-      now = Time.now.to_i
+    return nil unless cache[file]
+    now = Time.now.to_i
 
-      return cache[file][:data] if ttl == -1
-      return cache[file][:data] if (now - cache[file][:stored]) <= ttl
-      return nil
-    else
-      return nil
-    end
+    return cache[file][:data] if ttl == -1
+    return cache[file][:data] if (now - cache[file][:stored]) <= ttl
+    return nil
   rescue
     return nil
   end
 
   def cache_time(file)
-    meta = file + ".ttl"
+    meta = file + '.ttl'
 
     return File.read(meta).chomp.to_i
   rescue
@@ -153,13 +149,11 @@ class Facter::Util::DotD
   end
 
   def load_cache
-    unless @cache
-      if File.exist?(@cache_file)
-        @cache = YAML.load_file(@cache_file)
-      else
-        @cache = {}
-      end
-    end
+    @cache ||= if File.exist?(@cache_file)
+                 YAML.load_file(@cache_file)
+               else
+                 {}
+               end
 
     return @cache
   rescue
@@ -172,28 +166,26 @@ class Facter::Util::DotD
       type = fact_type(fact)
       parser = "#{type}_parser"
 
-      if respond_to?("#{type}_parser")
-        Facter.debug("Parsing #{fact} using #{parser}")
+      next unless respond_to?("#{type}_parser")
+      Facter.debug("Parsing #{fact} using #{parser}")
 
-        send(parser, fact)
-      end
+      send(parser, fact)
     end
   end
 end
 
-
-mdata = Facter.version.match(/(\d+)\.(\d+)\.(\d+)/)
+mdata = Facter.version.match(%r{(\d+)\.(\d+)\.(\d+)})
 if mdata
-  (major, minor, patch) = mdata.captures.map { |v| v.to_i }
+  (major, minor, _patch) = mdata.captures.map { |v| v.to_i }
   if major < 2
     # Facter 1.7 introduced external facts support directly
-    unless major == 1 and minor > 6
-      Facter::Util::DotD.new("/etc/facter/facts.d").create
-      Facter::Util::DotD.new("/etc/puppetlabs/facter/facts.d").create
+    unless major == 1 && minor > 6
+      Facter::Util::DotD.new('/etc/facter/facts.d').create
+      Facter::Util::DotD.new('/etc/puppetlabs/facter/facts.d').create
 
       # Windows has a different configuration directory that defaults to a vendor
       # specific sub directory of the %COMMON_APPDATA% directory.
-      if Dir.const_defined? 'COMMON_APPDATA' then
+      if Dir.const_defined? 'COMMON_APPDATA' # rubocop:disable Metrics/BlockNesting : Any attempt to alter this breaks it
         windows_facts_dot_d = File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'facter', 'facts.d')
         Facter::Util::DotD.new(windows_facts_dot_d).create
       end
index 3a9117f..0aec171 100644 (file)
@@ -12,7 +12,7 @@ require 'puppet/type/package'
 
 Facter.add(:package_provider) do
   setcode do
-    if defined? Gem and Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6')
+    if defined? Gem && Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6')
       Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s
     else
       Puppet::Type.type(:package).newpackage(:name => 'dummy')[:provider].to_s
index c9f2181..594f9dc 100644 (file)
@@ -8,11 +8,11 @@
 #
 # Caveats:
 #
-Facter.add("pe_version") do
+Facter.add('pe_version') do
   setcode do
-    puppet_ver = Facter.value("puppetversion")
-    if puppet_ver != nil
-      pe_ver = puppet_ver.match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
+    puppet_ver = Facter.value('puppetversion')
+    if !puppet_ver.nil?
+      pe_ver = puppet_ver.match(%r{Puppet Enterprise (\d+\.\d+\.\d+)})
       pe_ver[1] if pe_ver
     else
       nil
@@ -20,9 +20,9 @@ Facter.add("pe_version") do
   end
 end
 
-Facter.add("is_pe") do
+Facter.add('is_pe') do
   setcode do
-    if Facter.value(:pe_version).to_s.empty? then
+    if Facter.value(:pe_version).to_s.empty?
       false
     else
       true
@@ -30,28 +30,31 @@ Facter.add("is_pe") do
   end
 end
 
-Facter.add("pe_major_version") do
+Facter.add('pe_major_version') do
   confine :is_pe => true
   setcode do
-    if pe_version = Facter.value(:pe_version)
+    pe_version = Facter.value(:pe_version)
+    if pe_version
       pe_version.to_s.split('.')[0]
     end
   end
 end
 
-Facter.add("pe_minor_version") do
+Facter.add('pe_minor_version') do
   confine :is_pe => true
   setcode do
-    if pe_version = Facter.value(:pe_version)
+    pe_version = Facter.value(:pe_version)
+    if pe_version
       pe_version.to_s.split('.')[1]
     end
   end
 end
 
-Facter.add("pe_patch_version") do
+Facter.add('pe_patch_version') do
   confine :is_pe => true
   setcode do
-    if pe_version = Facter.value(:pe_version)
+    pe_version = Facter.value(:pe_version)
+    if pe_version
       pe_version.to_s.split('.')[2]
     end
   end
index eac9e97..b932189 100644 (file)
@@ -13,10 +13,9 @@ rescue LoadError => e
   # #4248). It should (in the future) but for the time being we need to be
   # defensive which is what this rescue block is doing.
   rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
-  load rb_file if File.exists?(rb_file) or raise e
+  load rb_file if File.exist?(rb_file) || raise(e)
 end
 
-
 # These will be nil if Puppet is not available.
 Facter.add(:puppet_vardir) do
   setcode do
index 87c7657..d4add7b 100644 (file)
@@ -1,30 +1,29 @@
 # A facter fact to determine the root home directory.
 # This varies on PE supported platforms and may be
 # reconfigured by the end user.
-
 module Facter::Util::RootHome
   class << self
-  def get_root_home
-    root_ent = Facter::Util::Resolution.exec("getent passwd root")
+  def returnt_root_home
+    root_ent = Facter::Util::Resolution.exec('getent passwd root')
     # The home directory is the sixth element in the passwd entry
     # If the platform doesn't have getent, root_ent will be nil and we should
     # return it straight away.
-    root_ent && root_ent.split(":")[5]
+    root_ent && root_ent.split(':')[5]
   end
   end
 end
 
 Facter.add(:root_home) do
-  setcode { Facter::Util::RootHome.get_root_home }
+  setcode { Facter::Util::RootHome.returnt_root_home }
 end
 
 Facter.add(:root_home) do
   confine :kernel => :darwin
   setcode do
-    str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root")
+    str = Facter::Util::Resolution.exec('dscacheutil -q user -a name root')
     hash = {}
     str.split("\n").each do |pair|
-      key,value = pair.split(/:/)
+      key, value = pair.split(%r{:})
       hash[key] = value
     end
     hash['dir'].strip
@@ -35,10 +34,10 @@ Facter.add(:root_home) do
   confine :kernel => :aix
   root_home = nil
   setcode do
-    str = Facter::Util::Resolution.exec("lsuser -c -a home root")
+    str = Facter::Util::Resolution.exec('lsuser -c -a home root')
     str && str.split("\n").each do |line|
-      next if line =~ /^#/
-      root_home = line.split(/:/)[1]
+      next if line =~ %r{^#}
+      root_home = line.split(%r{:})[1]
     end
     root_home
   end
index 1ad9452..d12e92c 100644 (file)
@@ -1,21 +1,16 @@
-module Facter
-  module Util
-    module PuppetSettings
-      # This method is intended to provide a convenient way to evaluate a
-      # Facter code block only if Puppet is loaded.  This is to account for the
-      # situation where the fact happens to be in the load path, but Puppet is
-      # not loaded for whatever reason.  Perhaps the user is simply running
-      # facter without the --puppet flag and they happen to be working in a lib
-      # directory of a module.
-      def self.with_puppet
-        begin
-          Module.const_get("Puppet")
-        rescue NameError
-          nil
-        else
-          yield
-        end
-      end
-    end
+# A method to evaluate a Facter code block if puppet is loaded.
+module Facter::Util::PuppetSettings
+  # This method is intended to provide a convenient way to evaluate a
+  # Facter code block only if Puppet is loaded.  This is to account for the
+  # situation where the fact happens to be in the load path, but Puppet is
+  # not loaded for whatever reason.  Perhaps the user is simply running
+  # facter without the --puppet flag and they happen to be working in a lib
+  # directory of a module.
+  def self.with_puppet
+    Module.const_get('Puppet')
+  rescue NameError
+    nil
+  else
+    yield
   end
 end
index 39d9bc7..af6109d 100644 (file)
@@ -1,4 +1,7 @@
-# Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method  It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message), :off (no message / error is displayed) and :warning (default, outputs a warning)  *Type*: String, String.
+# Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once.
+# The msg is the message text including any positional information that is formatted by the user/caller of the method.
+# It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message),
+#   :off (no message / error is displayed) and :warning (default, outputs a warning)  *Type*: String, String.
 #
 
 Puppet::Functions.create_function(:deprecation) do
@@ -8,7 +11,7 @@ Puppet::Functions.create_function(:deprecation) do
   end
 
   def deprecation(key, message)
-    if defined? Puppet::Pops::PuppetStack.stacktrace()
+    if defined? Puppet::Pops::PuppetStack.stacktrace
       stacktrace = Puppet::Pops::PuppetStack.stacktrace()
       file = stacktrace[0]
       line = stacktrace[1]
@@ -16,10 +19,10 @@ Puppet::Functions.create_function(:deprecation) do
     end
     # depending on configuration setting of strict
     case Puppet.settings[:strict]
-    when :off
+    when :off # rubocop:disable Lint/EmptyWhen : Is required to prevent false errors
       # do nothing
     when :error
-      fail("deprecation. #{key}. #{message}")
+      raise("deprecation. #{key}. #{message}")
     else
       unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false'
         Puppet.deprecation_warning(message, key)
index dfb048b..48736ad 100644 (file)
@@ -19,9 +19,9 @@ Puppet::Functions.create_function(:fact) do
   end
 
   def to_dot_syntax(array_path)
-    array_path.map do |string|
-      string.include?('.') ? %Q{"#{string}"} : string
-    end.join('.')
+    array_path.map { |string|
+      string.include?('.') ? %("#{string}") : string
+    }.join('.')
   end
 
   def fact(fact_name)
@@ -30,21 +30,20 @@ Puppet::Functions.create_function(:fact) do
     # Transform the dot-notation string into an array of paths to walk. Make
     # sure to correctly extract double-quoted values containing dots as single
     # elements in the path.
-    path = fact_name.scan(/([^."]+)|(?:")([^"]+)(?:")/).map {|x| x.compact.first }
+    path = fact_name.scan(%r{([^."]+)|(?:")([^"]+)(?:")}).map { |x| x.compact.first }
 
     walked_path = []
     path.reduce(facts) do |d, k|
       return nil if d.nil? || k.nil?
 
-      case
-      when d.is_a?(Array)
+      if d.is_a?(Array)
         begin
           result = d[Integer(k)]
-        rescue ArgumentError => e
+        rescue ArgumentError => e # rubocop:disable Lint/UselessAssignment : Causes errors if assigment is removed.
           Puppet.warning("fact request for #{fact_name} returning nil: '#{to_dot_syntax(walked_path)}' is an array; cannot index to '#{k}'")
           result = nil
         end
-      when d.is_a?(Hash)
+      elsif d.is_a?(Hash)
         result = d[k]
       else
         Puppet.warning("fact request for #{fact_name} returning nil: '#{to_dot_syntax(walked_path)}' is not a collection; cannot walk to '#{k}'")
index da98b03..24b9744 100644 (file)
@@ -25,7 +25,7 @@ Puppet::Functions.create_function(:is_a) do
     param 'Type', :type
   end
 
-  def is_a(value, type)
+  def is_a(value, type) # rubocop:disable Style/PredicateName : Used in to many other places to rename at this time, attempting to refactor caused Rubocop to crash.
     # See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression
     Puppet::Pops::Types::TypeCalculator.instance?(type, value)
   end
index b61064a..c9d92eb 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_absolute_path) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_absolute_path', "This method is deprecated, please use match expressions with Stdlib::Compat::Absolute_Path instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_absolute_path", args)
+    call_function('deprecation', 'is_absolute_path', 'This method is deprecated, please use match expressions with Stdlib::Compat::Absolute_Path instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_absolute_path', args)
   end
 end
index a29fe8a..fdc60dd 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_array) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_array', "This method is deprecated, please use match expressions with Stdlib::Compat::Array instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_array", args)
+    call_function('deprecation', 'is_array', 'This method is deprecated, please use match expressions with Stdlib::Compat::Array instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_array', args)
   end
 end
index 6e2c22b..1672f0a 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_bool) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_bool', "This method is deprecated, please use match expressions with Stdlib::Compat::Bool instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_bool", args)
+    call_function('deprecation', 'is_bool', 'This method is deprecated, please use match expressions with Stdlib::Compat::Bool instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_bool', args)
   end
 end
index c91aa5d..03e94d3 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_float) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_float', "This method is deprecated, please use match expressions with Stdlib::Compat::Float instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_float", args)
+    call_function('deprecation', 'is_float', 'This method is deprecated, please use match expressions with Stdlib::Compat::Float instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_float', args)
   end
 end
index 4c72037..1ab67e7 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_ip_address) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_ip_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ip_address instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_ip_address", args)
+    call_function('deprecation', 'is_ip_address', 'This method is deprecated, please use match expressions with Stdlib::Compat::Ip_address instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_ip_address', args)
   end
 end
index 97b01ae..034f9ba 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_ipv4_address) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv4 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_ipv4_address", args)
+    call_function('deprecation', 'is_ipv4_address', 'This method is deprecated, please use match expressions with Stdlib::Compat::Ipv4 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_ipv4_address', args)
   end
 end
index be0c98a..c8fb3ab 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_ipv6_address) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv6 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_ipv6_address", args)
+    call_function('deprecation', 'is_ipv4_address', 'This method is deprecated, please use match expressions with Stdlib::Compat::Ipv6 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_ipv6_address', args)
   end
 end
index f5e9d41..79a6bbf 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_numeric) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_numeric', "This method is deprecated, please use match expressions with Stdlib::Compat::Numeric instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_numeric", args)
+    call_function('deprecation', 'is_numeric', 'This method is deprecated, please use match expressions with Stdlib::Compat::Numeric instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_numeric', args)
   end
 end
index a05a796..a32216c 100644 (file)
@@ -3,13 +3,15 @@ Puppet::Functions.create_function(:is_string) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'is_string', "This method is deprecated, please use match expressions with Stdlib::Compat::String instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
-    scope.send("function_is_string", args)
+    call_function('deprecation', 'is_string', 'This method is deprecated, please use match expressions with Stdlib::Compat::String instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.')
+    scope.send('function_is_string', args)
   end
 end
index 86e735c..ccd662a 100644 (file)
@@ -1,14 +1,19 @@
-#A function to eventually replace the old size() function for stdlib - The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution. 
+# A function to eventually replace the old size() function for stdlib
+# The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution.
+#
+# Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+# will be used instead of this function.
+#
 Puppet::Functions.create_function(:length) do
   dispatch :length do
     param 'Variant[String,Array,Hash]', :value
   end
-  def  length(value)
+  def length(value)
     if value.is_a?(String)
       result = value.length
     elsif value.is_a?(Array) || value.is_a?(Hash)
       result = value.size
     end
-    return result
+    result
   end
 end
index 01f1f49..5bed6d5 100644 (file)
@@ -10,7 +10,7 @@
 # See the documentation for "The Puppet Type System" for more information about types.
 # See the `assert_type()` function for flexible ways to assert the type of a value.
 #
-# The built-in type() function in puppet is generally preferred over this function 
+# The built-in type() function in puppet is generally preferred over this function
 # this function is provided for backwards compatibility.
 Puppet::Functions.create_function(:type_of) do
   def type_of(value)
index a3c696d..44f600f 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_absolute_path) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_absolute_path', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_absolute_path", args)
+    call_function('deprecation', 'validate_absolute_path', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_absolute_path', args)
   end
 end
index f59c6b4..2bedd3f 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_array) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_array', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_array", args)
+    call_function('deprecation', 'validate_array', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_array', args)
   end
 end
index 5cfb2ac..907eed3 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_bool) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_bool', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_bool", args)
+    call_function('deprecation', 'validate_bool', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_bool', args)
   end
 end
index 89ad9ab..c6a61a4 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_hash) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_hash', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_hash", args)
+    call_function('deprecation', 'validate_hash', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_hash', args)
   end
 end
index 475ea0f..487dcf7 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_integer) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_integer', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_integer", args)
+    call_function('deprecation', 'validate_integer', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_integer', args)
   end
 end
index 1521c08..68e7f7f 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_ip_address) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_ip_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_ip_address", args)
+    call_function('deprecation', 'validate_ip_address', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_ip_address', args)
   end
 end
index fe66ab3..caeeaca 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_ipv4_address) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_ipv4_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_ipv4_address", args)
+    call_function('deprecation', 'validate_ipv4_address', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_ipv4_address', args)
   end
 end
index 7cc3cbd..c035357 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_ipv6_address) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff
+  #   -c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_ipv6_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_ipv6_address", args)
+    call_function('deprecation', 'validate_ipv6_address', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_ipv6_address', args)
   end
 end
index c9d1f56..21646ad 100644 (file)
@@ -17,7 +17,8 @@ Puppet::Functions.create_function(:validate_legacy) do
     repeated_param 'Any', :args
   end
 
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-
+  #   c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
@@ -48,12 +49,11 @@ Puppet::Functions.create_function(:validate_legacy) do
 
   def previous_validation(scope, function_name, value, *prev_args)
     # Call the previous validation function and catch any errors. Return true if no errors are thrown.
-    begin
-      scope.send("function_#{function_name}".to_s, [value, *prev_args])
-      true
-    rescue Puppet::ParseError
-      false
-    end
+
+    scope.send("function_#{function_name}".to_s, [value, *prev_args])
+    true
+  rescue Puppet::ParseError
+    false
   end
 
   def assert_type(type, value)
index 3052d35..3adb0a8 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_numeric) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-
+  #   c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_numeric', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_numeric", args)
+    call_function('deprecation', 'validate_numeric', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_numeric', args)
   end
 end
index 19443a8..d357aab 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_re) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-
+  #   c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_re', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_re", args)
+    call_function('deprecation', 'validate_re', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Pattern[]. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_re', args)
   end
 end
index 584232a..ad6f7b3 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_slength) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-
+  #   c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_slength', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_slength", args)
+    call_function('deprecation', 'validate_slength', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with String[]. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_slength', args)
   end
 end
index 91ff004..a908c19 100644 (file)
@@ -3,13 +3,16 @@ Puppet::Functions.create_function(:validate_string) do
     param 'Any', :scope
     repeated_param 'Any', :args
   end
-  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
+  # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-
+  #   c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
   def call(scope, *args)
     manipulated_args = [scope] + args
     self.class.dispatcher.dispatch(self, scope, manipulated_args)
   end
+
   def deprecation_gen(scope, *args)
-    call_function('deprecation', 'validate_string', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.")
-    scope.send("function_validate_string", args)
+    call_function('deprecation', 'validate_string', 'This method is deprecated, please use the stdlib validate_legacy function,
+                    with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.')
+    scope.send('function_validate_string', args)
   end
 end
index 222a902..59e468e 100644 (file)
@@ -1,23 +1,25 @@
 #
 # abs.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:abs, :type => :rvalue, :doc => <<-EOS
+  newfunction(:abs, :type => :rvalue, :doc => <<-DOC
     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|
 
-    raise(Puppet::ParseError, "abs(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
+
+    raise(Puppet::ParseError, "abs(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
     # Numbers in Puppet are often string-encoded which is troublesome ...
     if value.is_a?(String)
-      if value.match(/^-?(?:\d+)(?:\.\d+){1}$/)
+      if value =~ %r{^-?(?:\d+)(?:\.\d+){1}$}
         value = value.to_f
-      elsif value.match(/^-?\d+$/)
+      elsif value =~ %r{^-?\d+$}
         value = value.to_i
       else
         raise(Puppet::ParseError, 'abs(): Requires float or integer to work with')
index e71407e..8358a6f 100644 (file)
@@ -1,31 +1,45 @@
 #
 # any2array.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
-This converts any object to an array containing that object. Empty argument
-lists are converted to an empty array. Arrays are left untouched. Hashes are
-converted to arrays of alternating keys and values.
-    EOS
-  ) do |arguments|
+  newfunction(:any2array, :type => :rvalue, :doc => <<-DOC
+    This converts any object to an array containing that object. Empty argument
+    lists are converted to an empty array. Arrays are left untouched. Hashes are
+    converted to arrays of alternating keys and values.
+
+    Note that since Puppet 5.0.0 it is possible to create new data types for almost any
+    datatype using the type system and the built-in
+    [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple)
+    function is used to create a new Array..
+
+        $hsh = {'key' => 42, 'another-key' => 100}
+        notice(Array($hsh))
+
+    Would notice `[['key', 42], ['another-key', 100]]`
+
+    The Array data type also has a special mode to "create an array if not already an array"
+
+        notice(Array({'key' => 42, 'another-key' => 100}, true))
+
+    Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being
+    transformed into an array.
+  DOC
+             ) do |arguments|
 
     if arguments.empty?
-        return []
+      return []
     end
 
-    if arguments.length == 1
-        if arguments[0].kind_of?(Array)
-            return arguments[0]
-        elsif arguments[0].kind_of?(Hash)
-            result = []
-            arguments[0].each do |key, value|
-                result << key << value
-            end
-            return result
-        end
+    return arguments unless arguments.length == 1
+    return arguments[0] if arguments[0].is_a?(Array)
+    return [] if arguments == ['']
+    if arguments[0].is_a?(Hash)
+      result = []
+      arguments[0].each do |key, value|
+        result << key << value
+      end
+      return result
     end
-
     return arguments
   end
 end
index 17612bf..8f6d5d8 100644 (file)
@@ -1,30 +1,32 @@
 #
 # any2bool.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:any2bool, :type => :rvalue, :doc => <<-EOS
-This converts 'anything' to a boolean. In practise it does the following:
+  newfunction(:any2bool, :type => :rvalue, :doc => <<-DOC
+    This converts 'anything' to a boolean. In practise it does the following:
+
+    * Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true
+    * Strings such as 0,F,f,N,n,FALSE,no,'false' will return false
+    * Booleans will just return their original value
+    * Number (or a string representation of a number) > 0 will return true, otherwise false
+    * undef will return false
+    * Anything else will return true
 
-* Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true
-* Strings such as 0,F,f,N,n,FALSE,no,'false' will return false
-* Booleans will just return their original value
-* Number (or a string representation of a number) > 0 will return true, otherwise false
-* undef will return false
-* Anything else will return true
-    EOS
-  ) do |arguments|
+    Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
+    function.
+  DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "any2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "any2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     # If argument is already Boolean, return it
-    if !!arguments[0] == arguments[0]
+    if !!arguments[0] == arguments[0] # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean
       return arguments[0]
     end
 
     arg = arguments[0]
 
-    if arg == nil
+    if arg.nil?
       return false
     end
 
@@ -32,22 +34,22 @@ This converts 'anything' to a boolean. In practise it does the following:
       return false
     end
 
-    valid_float = !!Float(arg) rescue false
+    valid_float = begin
+                    !!Float(arg) # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean
+                  rescue
+                    false
+                  end
 
     if arg.is_a?(Numeric)
-      return function_num2bool( [ arguments[0] ] )
+      return function_num2bool([arguments[0]])
     end
 
     if arg.is_a?(String)
-      if valid_float
-        return function_num2bool( [ arguments[0] ] )
-      else
-        return function_str2bool( [ arguments[0] ] )
-      end
+      return function_num2bool([arguments[0]]) if valid_float
+      return function_str2bool([arguments[0]])
     end
 
     return true
-
   end
 end
 
index 62e2c6b..9cdebb9 100644 (file)
@@ -1,20 +1,19 @@
 #
 # assert_private.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:assert_private, :doc => <<-'EOS'
+  newfunction(:assert_private, :doc => <<-DOC
     Sets the current class or definition as private.
     Calling the class or definition from outside the current module will fail.
-    EOS
-  ) do |args|
+    DOC
+             ) do |args|
 
     raise(Puppet::ParseError, "assert_private(): Wrong number of arguments given (#{args.size}}) for 0 or 1)") if args.size > 1
 
     scope = self
     if scope.lookupvar('module_name') != scope.lookupvar('caller_module_name')
       message = nil
-      if args[0] and args[0].is_a? String
+      if args[0] && args[0].is_a?(String)
         message = args[0]
       else
         manifest_name = scope.source.name
index d610146..d77db8b 100644 (file)
@@ -1,10 +1,6 @@
-
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
-
 module Puppet::Parser::Functions
-
-  newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
-
+  newfunction(:base64, :type => :rvalue, :doc => <<-'DOC') do |args|
     Base64 encode or decode a string based on the command and the string submitted
 
     Usage:
@@ -17,53 +13,62 @@ module Puppet::Parser::Functions
       $encodestring = base64('encode', 'thestring', $method)
       $decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
 
-    ENDHEREDOC
+    Note: Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings.
+    See the `new()` function for the Binary and String types for documentation. Also see `binary_file()`
+    function for reading a file with binary (non UTF-8) content.
+
+       # encode a string as if it was binary
+       $encodestring = String(Binary('thestring', '%s'))
+       # decode a Binary assuming it is an UTF-8 String
+       $decodestring = String(Binary("dGhlc3RyaW5n"), "%s")
+
+    DOC
 
     require 'base64'
 
-    raise Puppet::ParseError, ("base64(): Wrong number of arguments (#{args.length}; must be >= 2)") unless args.length >= 2
+    raise Puppet::ParseError, "base64(): Wrong number of arguments (#{args.length}; must be >= 2)" unless args.length >= 2
 
-    actions = ['encode','decode']
+    actions = ['encode', 'decode']
 
     unless actions.include?(args[0])
-      raise Puppet::ParseError, ("base64(): the first argument must be one of 'encode' or 'decode'")
+      raise Puppet::ParseError, "base64(): the first argument must be one of 'encode' or 'decode'"
     end
 
     unless args[1].is_a?(String)
-      raise Puppet::ParseError, ("base64(): the second argument must be a string to base64")
+      raise Puppet::ParseError, 'base64(): the second argument must be a string to base64'
     end
 
-    method = ['default','strict','urlsafe']
+    method = ['default', 'strict', 'urlsafe']
 
-    if args.length <= 2
-      chosenMethod = 'default'
-    else
-      chosenMethod = args[2]
-    end
+    chosen_method = if args.length <= 2
+                      'default'
+                    else
+                      args[2]
+                    end
 
-    unless method.include?(chosenMethod)
-      raise Puppet::ParseError, ("base64(): the third argument must be one of 'default', 'strict', or 'urlsafe'")
+    unless method.include?(chosen_method)
+      raise Puppet::ParseError, "base64(): the third argument must be one of 'default', 'strict', or 'urlsafe'"
     end
 
     case args[0]
-      when 'encode'
-        case chosenMethod
-          when 'default'
-            result = Base64.encode64(args[1])
-          when 'strict'
-            result = Base64.strict_encode64(args[1])
-          when 'urlsafe'
-            result = Base64.urlsafe_encode64(args[1])
-        end
-      when 'decode'
-        case chosenMethod
-          when 'default'
-            result = Base64.decode64(args[1])
-          when 'strict'
-            result = Base64.strict_decode64(args[1])
-          when 'urlsafe'
-            result = Base64.urlsafe_decode64(args[1])
-        end
+    when 'encode'
+      case chosen_method
+      when 'default'
+        result = Base64.encode64(args[1])
+      when 'strict'
+        result = Base64.strict_encode64(args[1])
+      when 'urlsafe'
+        result = Base64.urlsafe_encode64(args[1])
+      end
+    when 'decode'
+      case chosen_method
+      when 'default'
+        result = Base64.decode64(args[1])
+      when 'strict'
+        result = Base64.strict_decode64(args[1])
+      when 'urlsafe'
+        result = Base64.urlsafe_decode64(args[1])
+      end
     end
 
     return result
index f7e4438..b717fa1 100644 (file)
@@ -1,30 +1,20 @@
+#
+# basename.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:basename, :type => :rvalue, :doc => <<-EOS
+  newfunction(:basename, :type => :rvalue, :doc => <<-DOC
     Strips directory (and optional suffix) from a filename
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
-    if arguments.size < 1 then
-      raise(Puppet::ParseError, "basename(): No arguments given")
-    elsif arguments.size > 2 then
-      raise(Puppet::ParseError, "basename(): Too many arguments given (#{arguments.size})")
-    else
-
-      unless arguments[0].is_a?(String)
-        raise(Puppet::ParseError, 'basename(): Requires string as first argument')
-      end
-
-      if arguments.size == 1 then
-        rv = File.basename(arguments[0])
-      elsif arguments.size == 2 then
-
-        unless arguments[1].is_a?(String)
-          raise(Puppet::ParseError, 'basename(): Requires string as second argument')
-        end
-
-        rv = File.basename(arguments[0], arguments[1])
-      end
+    raise(Puppet::ParseError, 'basename(): No arguments given') if arguments.empty?
+    raise(Puppet::ParseError, "basename(): Too many arguments given (#{arguments.size})") if arguments.size > 2
+    raise(Puppet::ParseError, 'basename(): Requires string as first argument') unless arguments[0].is_a?(String)
 
+    rv = File.basename(arguments[0]) if arguments.size == 1
+    if arguments.size == 2
+      raise(Puppet::ParseError, 'basename(): Requires string as second argument') unless arguments[1].is_a?(String)
+      rv = File.basename(arguments[0], arguments[1])
     end
 
     return rv
index 92e4dde..115467e 100644 (file)
@@ -1,17 +1,26 @@
 #
 # bool2num.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
+  newfunction(:bool2num, :type => :rvalue, :doc => <<-DOC
     Converts a boolean to a number. Converts the values:
       false, f, 0, n, and no to 0
       true, t, 1, y, and yes to 1
     Requires a single boolean or string as an input.
-    EOS
-  ) do |arguments|
 
-    raise(Puppet::ParseError, "bool2num(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    Note that since Puppet 5.0.0 it is possible to create new data types for almost any
+    datatype using the type system and the built-in
+    [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric),
+    [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and
+    [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float)
+    function are used to convert to numeric values.
+
+        notice(Integer(false)) # Notices 0
+        notice(Float(true))    # Notices 1.0
+    DOC
+             ) do |arguments|
+
+    raise(Puppet::ParseError, "bool2num(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = function_str2bool([arguments[0]])
 
index 37d4a4e..be25e0a 100644 (file)
@@ -1,9 +1,8 @@
 #
 # bool2str.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS
+  newfunction(:bool2str, :type => :rvalue, :doc => <<-DOC
     Converts a boolean to a string using optionally supplied arguments. The
     optional second and third arguments represent what true and false will be
     converted to respectively. If only one argument is given, it will be
@@ -16,10 +15,21 @@ module Puppet::Parser::Functions
     bool2str(false, 't', 'f')         => 'f'
 
     Requires a single boolean as an input.
-    EOS
-  ) do |arguments|
 
-    unless arguments.size == 1 or arguments.size == 3
+    Note that since Puppet 5.0.0 it is possible to create new data types for almost any
+    datatype using the type system and the built-in
+    [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string)
+    function is used to convert to String with many different format options.
+
+        notice(String(false))         # Notices 'false'
+        notice(String(true))          # Notices 'true'
+        notice(String(false, '%y'))   # Notices 'yes'
+        notice(String(true, '%y'))    # Notices 'no'
+
+    DOC
+             ) do |arguments|
+
+    unless arguments.size == 1 || arguments.size == 3
       raise(Puppet::ParseError, "bool2str(): Wrong number of arguments given (#{arguments.size} for 3)")
     end
 
@@ -33,8 +43,8 @@ module Puppet::Parser::Functions
       raise(Puppet::ParseError, 'bool2str(): Requires a boolean to work with')
     end
 
-    unless [true_string, false_string].all?{|x| x.kind_of?(String)}
-      raise(Puppet::ParseError, "bool2str(): Requires strings to convert to" )
+    unless [true_string, false_string].all? { |x| x.is_a?(String) }
+      raise(Puppet::ParseError, 'bool2str(): Requires strings to convert to')
     end
 
     return value ? true_string : false_string
index 085b3c6..3c887e2 100644 (file)
@@ -2,14 +2,16 @@
 #  camelcase.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:camelcase, :type => :rvalue, :doc => <<-EOS
-Converts the case of a string or all strings in an array to camel case.
-    EOS
-  ) do |arguments|
+  newfunction(:camelcase, :type => :rvalue, :doc => <<-DOC
+    Converts the case of a string or all strings in an array to camel case.
+
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+  DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "camelcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "camelcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
     klass = value.class
@@ -18,12 +20,12 @@ Converts the case of a string or all strings in an array to camel case.
       raise(Puppet::ParseError, 'camelcase(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? i.split('_').map{|e| e.capitalize}.join : i }
-    else
-      result = value.split('_').map{|e| e.capitalize}.join
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? i.split('_').map { |e| e.capitalize }.join : i }
+             else
+               value.split('_').map { |e| e.capitalize }.join
+             end
 
     return result
   end
index 096bc5d..2493bc8 100644 (file)
@@ -2,15 +2,17 @@
 #  capitalize.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
+  newfunction(:capitalize, :type => :rvalue, :doc => <<-DOC
     Capitalizes the first letter of a string or array of strings.
     Requires either a single string or an array as an input.
-    EOS
-  ) do |arguments|
 
-    raise(Puppet::ParseError, "capitalize(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
+
+    raise(Puppet::ParseError, "capitalize(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -18,12 +20,12 @@ module Puppet::Parser::Functions
       raise(Puppet::ParseError, 'capitalize(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? i.capitalize : i }
-    else
-      result = value.capitalize
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? i.capitalize : i }
+             else
+               value.capitalize
+             end
 
     return result
   end
index bec4266..fe4b768 100644 (file)
@@ -1,15 +1,21 @@
+#
+#  ceiling.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:ceiling, :type => :rvalue, :doc => <<-EOS
+  newfunction(:ceiling, :type => :rvalue, :doc => <<-DOC
     Returns the smallest integer greater or equal to the argument.
     Takes a single numeric value as an argument.
-    EOS
-  ) do |arguments|
+
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "ceiling(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     begin
       arg = Float(arguments[0])
-    rescue TypeError, ArgumentError => e
+    rescue TypeError, ArgumentError => _e
       raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arguments[0]} for Numeric)")
     end
 
index f9da50f..b7b309c 100644 (file)
@@ -1,16 +1,18 @@
 #
 #  chomp.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
+  newfunction(:chomp, :type => :rvalue, :doc => <<-DOC
     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
-  ) do |arguments|
 
-    raise(Puppet::ParseError, "chomp(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
+
+    raise(Puppet::ParseError, "chomp(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -18,12 +20,12 @@ module Puppet::Parser::Functions
       raise(Puppet::ParseError, 'chomp(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
-    else
-      result = value.chomp
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? i.chomp : i }
+             else
+               value.chomp
+             end
 
     return result
   end
index 809349d..39a9ee7 100644 (file)
@@ -1,18 +1,20 @@
 #
 #  chop.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
+  newfunction(:chop, :type => :rvalue, :doc => <<-DOC
     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
-  ) do |arguments|
 
-    raise(Puppet::ParseError, "chop(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
+
+    raise(Puppet::ParseError, "chop(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -20,12 +22,12 @@ module Puppet::Parser::Functions
       raise(Puppet::ParseError, 'chop(): Requires either an array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? i.chop : i }
-    else
-      result = value.chop
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? i.chop : i }
+             else
+               value.chop
+             end
 
     return result
   end
index c4503fe..cbc67dc 100644 (file)
@@ -1,12 +1,14 @@
 #
 # clamp.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS
+  newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-DOC
     Clamps value to a range.
-    EOS
-  ) do |args|
+
+    Note: From Puppet 6.0.0 this can be done with only core Puppet like this:
+      [$minval, $maxval, $value_to_clamp].sort[1]
+    DOC
+             ) do |args|
 
     args.flatten!
 
@@ -15,15 +17,15 @@ module Puppet::Parser::Functions
     # check values out
     args.each do |value|
       case [value.class]
-        when [String]
-          raise(Puppet::ParseError, "clamp(): Required explicit numeric (#{value}:String)") unless value =~ /^\d+$/
-        when [Hash]
-          raise(Puppet::ParseError, "clamp(): The Hash type is not allowed (#{value})")
+      when [String]
+        raise(Puppet::ParseError, "clamp(): Required explicit numeric (#{value}:String)") unless value =~ %r{^\d+$}
+      when [Hash]
+        raise(Puppet::ParseError, "clamp(): The Hash type is not allowed (#{value})")
       end
     end
 
     # convert to numeric each element
     # then sort them and get a middle value
-    args.map{ |n| n.to_i }.sort[1]
+    args.map { |n| n.to_i }.sort[1]
   end
 end
index 0a49cfe..136f402 100644 (file)
@@ -1,20 +1,23 @@
 #
 # concat.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:concat, :type => :rvalue, :doc => <<-EOS
-Appends the contents of multiple arrays into array 1.
+  newfunction(:concat, :type => :rvalue, :doc => <<-DOC
+    Appends the contents of multiple arrays into array 1.
+
+    *Example:*
+
+        concat(['1','2','3'],['4','5','6'],['7','8','9'])
 
-*Example:*
+    Would result in:
 
-    concat(['1','2','3'],['4','5','6'],['7','8','9'])
+      ['1','2','3','4','5','6','7','8','9']
 
-Would result in:
+    Note: Since Puppet 4.0 concatenation of arrays and hashes can be done with the + operator.
 
-  ['1','2','3','4','5','6','7','8','9']
-    EOS
-  ) do |arguments|
+      ['1','2','3'] + ['4','5','6'] + ['7','8','9']
+  DOC
+             ) do |arguments|
 
     # Check that more than 2 arguments have been given ...
     raise(Puppet::ParseError, "concat(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2
@@ -30,7 +33,7 @@ Would result in:
     arguments.shift
 
     arguments.each do |x|
-      result = result + (x.is_a?(Array) ? x : [x])
+      result += (x.is_a?(Array) ? x : [x])
     end
 
     return result
index 0fcbafe..da5ff26 100644 (file)
@@ -1,7 +1,8 @@
+#
+# convert_base.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args|
-
+  newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'DOC') do |args|
     Converts a given integer or base 10 string representing an integer to a specified base, as a string.
 
     Usage:
@@ -9,26 +10,31 @@ module Puppet::Parser::Functions
       $binary_repr = convert_base(5, 2)  # $binary_repr is now set to "101"
       $hex_repr = convert_base("254", "16")  # $hex_repr is now set to "fe"
 
-    ENDHEREDOC
+     Note: Since Puppet 4.5.0 this can be done with String.new() and its many formatting options:
+
+       $binary_repr = String(5, '%b') # results in "101"
+       $hex_repr = String(254, "%x")  # results in "fe"
+       $hex_repr = String(254, "%#x")  # results in "0xfe"
+    DOC
 
-    raise Puppet::ParseError, ("convert_base(): First argument must be either a string or an integer") unless (args[0].is_a?(Integer) or args[0].is_a?(String))
-    raise Puppet::ParseError, ("convert_base(): Second argument must be either a string or an integer") unless (args[1].is_a?(Integer) or args[1].is_a?(String))
+    raise Puppet::ParseError, 'convert_base(): First argument must be either a string or an integer' unless args[0].is_a?(Integer) || args[0].is_a?(String)
+    raise Puppet::ParseError, 'convert_base(): Second argument must be either a string or an integer' unless args[1].is_a?(Integer) || args[1].is_a?(String)
 
     if args[0].is_a?(String)
-      raise Puppet::ParseError, ("convert_base(): First argument must be an integer or a string corresponding to an integer in base 10") unless args[0] =~ /^[0-9]+$/
+      raise Puppet::ParseError, 'convert_base(): First argument must be an integer or a string corresponding to an integer in base 10' unless args[0] =~ %r{^[0-9]+$}
     end
 
     if args[1].is_a?(String)
-      raise Puppet::ParseError, ("convert_base(): First argument must be an integer or a string corresponding to an integer in base 10") unless args[1] =~ /^[0-9]+$/
+      raise Puppet::ParseError, 'convert_base(): First argument must be an integer or a string corresponding to an integer in base 10' unless args[1] =~ %r{^[0-9]+$}
     end
 
     number_to_convert = args[0]
     new_base = args[1]
 
-    number_to_convert = number_to_convert.to_i()
-    new_base = new_base.to_i()
+    number_to_convert = number_to_convert.to_i
+    new_base = new_base.to_i
 
-    raise Puppet::ParseError, ("convert_base(): base must be at least 2 and must not be greater than 36") unless new_base >= 2 and new_base <= 36
+    raise Puppet::ParseError, 'convert_base(): base must be at least 2 and must not be greater than 36' unless new_base >= 2 && new_base <= 36
 
     return number_to_convert.to_s(new_base)
   end
index cef2637..71999a8 100644 (file)
@@ -1,21 +1,36 @@
+#
+# count.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
-Takes an array as first argument and an optional second argument.
-Count the number of elements in array that matches second argument.
-If called with only an array it counts the number of elements that are not nil/undef.
-    EOS
-  ) do |args|
-
-    if (args.size > 2) then
+  newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-DOC
+    Takes an array as first argument and an optional second argument.
+    Count the number of elements in array that is equal to the second argument.
+    If called with only an array, it counts the number of elements that are not nil/undef/empty-string.
+
+    Note: equality is tested with a Ruby method and it is therefore subject to what Ruby considers
+    to be equal. For strings this means that equality is case sensitive.
+
+    In Puppet core, counting can be done in general by using a combination of the core functions
+    filter() (since Puppet 4.0.0) and length() (since Puppet 5.5.0, before that in stdlib).
+    Example below shows counting values that are not undef.
+
+      notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)
+
+    Would notice the value 2.
+
+  DOC
+             ) do |args|
+
+    if args.size > 2
       raise(ArgumentError, "count(): Wrong number of arguments given #{args.size} for 1 or 2.")
     end
 
     collection, item = args
 
-    if item then
+    if item
       collection.count item
     else
-      collection.count { |obj| obj != nil && obj != :undef && obj != '' }
+      collection.count { |obj| !obj.nil? && obj != :undef && obj != '' }
     end
   end
 end
index 6df32e9..dd70c61 100644 (file)
@@ -1,5 +1,8 @@
+#
+# deep_merge.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:deep_merge, :type => :rvalue, :doc => <<-'DOC') do |args|
     Recursively merges two or more hashes together and returns the resulting hash.
 
     For example:
@@ -13,14 +16,14 @@ module Puppet::Parser::Functions
     When there is a duplicate key that is a hash, they are recursively merged.
     When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
 
-    ENDHEREDOC
+    DOC
 
     if args.length < 2
-      raise Puppet::ParseError, ("deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)")
+      raise Puppet::ParseError, "deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)"
     end
 
-    deep_merge = Proc.new do |hash1,hash2|
-      hash1.merge(hash2) do |key,old_value,new_value|
+    deep_merge = proc do |hash1, hash2|
+      hash1.merge(hash2) do |_key, old_value, new_value|
         if old_value.is_a?(Hash) && new_value.is_a?(Hash)
           deep_merge.call(old_value, new_value)
         else
@@ -29,9 +32,9 @@ module Puppet::Parser::Functions
       end
     end
 
-    result = Hash.new
+    result = {}
     args.each do |arg|
-      next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
+      next if arg.is_a?(String) && arg.empty? # empty string is synonym for puppet's undef
       # If the argument was not a hash, skip it.
       unless arg.is_a?(Hash)
         raise Puppet::ParseError, "deep_merge: unexpected argument type #{arg.class}, only expects hash arguments"
@@ -39,6 +42,6 @@ module Puppet::Parser::Functions
 
       result = deep_merge.call(result, arg)
     end
-    return( result )
+    return(result)
   end
 end
index c45a9df..fb0cd8c 100644 (file)
@@ -3,24 +3,24 @@ require 'puppet/parser/functions'
 
 Puppet::Parser::Functions.newfunction(:defined_with_params,
                                       :type => :rvalue,
-                                      :doc => <<-'ENDOFDOC'
-Takes a resource reference and an optional hash of attributes.
+                                      :doc => <<-'DOC'
+    Takes a resource reference and an optional hash of attributes.
 
-Returns true if a resource with the specified attributes has already been added
-to the catalog, and false otherwise.
+    Returns true if a resource with the specified attributes has already been added
+    to the catalog, and false otherwise.
 
-    user { 'dan':
-      ensure => present,
-    }
+        user { 'dan':
+          ensure => present,
+        }
 
-    if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
-      user { 'dan': ensure => present, }
-    }
-ENDOFDOC
-) do |vals|
+        if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
+          user { 'dan': ensure => present, }
+        }
+DOC
+                                     ) do |vals|
   reference, params = vals
   raise(ArgumentError, 'Must specify a reference') unless reference
-  if (! params) || params == ''
+  if !params || params == ''
     params = {}
   end
   ret = false
@@ -31,19 +31,20 @@ ENDOFDOC
       type_name, title = Puppet::Resource.type_and_title(reference, nil)
       type = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type_or_class(find_global_scope, type_name.downcase)
     elsif reference.is_a?(Puppet::Resource)
-      type = reference.resource_type
+      type = reference.type
       title = reference.title
     else
       raise(ArgumentError, "Reference is not understood: '#{reference.class}'")
     end
-    #end workaround
+    # end workaround
   else
     type = reference.to_s
     title = nil
   end
 
-  if resource = findresource(type, title)
-    matches = params.collect do |key, value|
+  resource = findresource(type, title)
+  if resource
+    matches = params.map do |key, value|
       # eql? avoids bugs caused by monkeypatching in puppet
       resource_is_undef = resource[key].eql?(:undef) || resource[key].nil?
       value_is_undef = value.eql?(:undef) || value.nil?
index 9dd5164..d3fddd8 100644 (file)
@@ -1,39 +1,54 @@
 #
 # delete.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:delete, :type => :rvalue, :doc => <<-EOS
-Deletes all instances of a given element from an array, substring from a
-string, or key from a hash.
+  newfunction(:delete, :type => :rvalue, :doc => <<-DOC
+    Deletes all instances of a given element from an array, substring from a
+    string, or key from a hash.
+
+    *Examples:*
+
+        delete(['a','b','c','b'], 'b')
+        Would return: ['a','c']
+
+        delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
+        Would return: {'a'=>1,'c'=>3}
+
+        delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
+        Would return: {'a'=>1}
+
+        delete('abracadabra', 'bra')
+        Would return: 'acada'
+
+    Note that from Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash:
+
+        ['a', 'b', 'c', 'b'] - 'b'
+        # would return ['a', 'c']
 
-*Examples:*
+        {'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
+        # would return {'a' => '1'}
 
-    delete(['a','b','c','b'], 'b')
-    Would return: ['a','c']
+    A global delete from a string can be performed with the regsubst() function:
 
-    delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
-    Would return: {'a'=>1,'c'=>3}
+        'abracadabra'.regsubst(/bra/, '', 'G')
+        # would return 'acada'
 
-    delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
-    Would return: {'a'=>1}
+    In general, the filter() function can filter out entries from arrays and hashes based on keys and/or values.
 
-    delete('abracadabra', 'bra')
-    Would return: 'acada'
-  EOS
-  ) do |arguments|
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "delete(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2
 
     collection = arguments[0].dup
     Array(arguments[1]).each do |item|
       case collection
-        when Array, Hash
-          collection.delete item
-        when String
-          collection.gsub! item, ''
-        else
-          raise(TypeError, "delete(): First argument must be an Array, String, or Hash. Given an argument of class #{collection.class}.")
+      when Array, Hash
+        collection.delete item
+      when String
+        collection.gsub! item, ''
+      else
+        raise(TypeError, "delete(): First argument must be an Array, String, or Hash. Given an argument of class #{collection.class}.")
       end
     end
     collection
index daf3721..0a1a940 100644 (file)
@@ -1,18 +1,28 @@
 #
 # delete_at.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS
-Deletes a determined indexed value from an array.
+  newfunction(:delete_at, :type => :rvalue, :doc => <<-DOC
+    Deletes a determined indexed value from an array.
+
+    *Examples:*
+
+        delete_at(['a','b','c'], 1)
+
+    Would return: ['a','c']
+
+    Note that since Puppet 4 this can be done in general with the filter function:
 
-*Examples:*
+        ['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }
 
-    delete_at(['a','b','c'], 1)
+    Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]:
 
-Would return: ['a','c']
-    EOS
-  ) do |arguments|
+        $array[0, -1] # the same as all the values
+        $array[2, -1] # all but the first 2 elements
+        $array[0, -3] # all but the last 2 elements
+        $array[1, -2] # all but the first and last element
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "delete_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
 
@@ -24,7 +34,7 @@ Would return: ['a','c']
 
     index = arguments[1]
 
-    if index.is_a?(String) and not index.match(/^\d+$/)
+    if index.is_a?(String) && !index.match(%r{^\d+$})
       raise(Puppet::ParseError, 'delete_at(): You must provide non-negative numeric index')
     end
 
index e5dc1fd..8093896 100644 (file)
@@ -2,39 +2,44 @@
 #  delete_regex.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:delete_regex, :type => :rvalue, :doc => <<-EOS
-deletes all instances of a given element that match a regular expression
-from an array or key from a hash. Multiple regular expressions are assumed
-to be matched as an OR.
+  newfunction(:delete_regex, :type => :rvalue, :doc => <<-DOC
+    deletes all instances of a given element that match a regular expression
+    from an array or key from a hash. Multiple regular expressions are assumed
+    to be matched as an OR.
+
+    *Examples:*
+
+        delete_regex(['a','b','c','b'], 'b')
+        Would return: ['a','c']
+
+        delete_regex(['a','b','c','b'], ['b', 'c'])
+        Would return: ['a']
 
-*Examples:*
+        delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
+        Would return: {'a'=>1,'c'=>3}
 
-    delete_regex(['a','b','c','b'], 'b')
-    Would return: ['a','c']
+        delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
+        Would return: {'b'=>2,'c'=>3}
 
-    delete_regex(['a','b','c','b'], ['b', 'c'])
-    Would return: ['a']
+     Note that since Puppet 4 this can be done in general with the filter function:
 
-    delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
-    Would return: {'a'=>1,'c'=>3}
+        ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ }
+        # Would return: ['aaa', 'aca']
 
-    delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
-    Would return: {'b'=>2,'c'=>3}
 
-  EOS
-  ) do |arguments|
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "delete_regex(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2
 
     collection = arguments[0].dup
     Array(arguments[1]).each do |item|
       case collection
-        when Array, Hash, String
-          collection.reject! { |coll_item| (coll_item =~ %r{\b#{item}\b}) }
-        else
-          raise(TypeError, "delete_regex(): First argument must be an Array, Hash, or String. Given an argument of class #{collection.class}.")
+      when Array, Hash, String
+        collection.reject! { |coll_item| (coll_item =~ %r{\b#{item}\b}) }
+      else
+        raise(TypeError, "delete_regex(): First argument must be an Array, Hash, or String. Given an argument of class #{collection.class}.")
       end
     end
     collection
index 00bd252..9e04082 100644 (file)
@@ -1,30 +1,39 @@
+#
+# delete_undef_values.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS
-Returns a copy of input hash or array with all undefs deleted.
+  newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-DOC
+    Returns a copy of input hash or array with all undefs deleted.
 
-*Examples:*
+    *Examples:*
 
-    $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
+        $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
 
-Would return: {a => 'A', b => '', d => false}
+    Would return: {a => 'A', b => '', d => false}
 
-    $array = delete_undef_values(['A','',undef,false])
+        $array = delete_undef_values(['A','',undef,false])
 
-Would return: ['A','',false]
+    Would return: ['A','',false]
 
-      EOS
-    ) do |args|
+    Note that since Puppet 4.0.0 the equivalent can be performed with the filter() function in Puppet:
 
-    raise(Puppet::ParseError, "delete_undef_values(): Wrong number of arguments given (#{args.size})") if args.size < 1
+        $array.filter |$val| { $val =~ NotUndef }
+        $hash.filter |$key, $val| { $val =~ NotUndef }
 
-    unless args[0].is_a? Array or args[0].is_a? Hash
+      DOC
+             ) do |args|
+
+    raise(Puppet::ParseError, "delete_undef_values(): Wrong number of arguments given (#{args.size})") if args.empty?
+
+    unless args[0].is_a?(Array) || args[0].is_a?(Hash)
       raise(Puppet::ParseError, "delete_undef_values(): expected an array or hash, got #{args[0]} type  #{args[0].class} ")
     end
     result = args[0].dup
     if result.is_a?(Hash)
-      result.delete_if {|key, val| val.equal? :undef}
+      result.delete_if { |_, val| val.equal?(:undef) || val.nil? }
     elsif result.is_a?(Array)
       result.delete :undef
+      result.delete nil
     end
     result
   end
index e799aef..f98f247 100644 (file)
@@ -1,23 +1,31 @@
+#
+# delete_values.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS
-Deletes all instances of a given value from a hash.
+  newfunction(:delete_values, :type => :rvalue, :doc => <<-DOC
+    Deletes all instances of a given value from a hash.
 
-*Examples:*
+    *Examples:*
 
-    delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
+        delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
 
-Would return: {'a'=>'A','c'=>'C','B'=>'D'}
+    Would return: {'a'=>'A','c'=>'C','B'=>'D'}
 
-      EOS
-    ) do |arguments|
+    Note that since Puppet 4.0.0 the equivalent can be performed with the filter() function in Puppet:
+
+        $array.filter |$val| { $val != 'B' }
+        $hash.filter |$key, $val| { $val != 'B' }
+
+      DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "delete_values(): Wrong number of arguments given (#{arguments.size} of 2)") if arguments.size != 2
 
     hash, item = arguments
 
-    if not hash.is_a?(Hash)
+    unless hash.is_a?(Hash)
       raise(TypeError, "delete_values(): First argument must be a Hash. Given an argument of class #{hash.class}.")
     end
-    hash.dup.delete_if { |key, val| item == val }
+    hash.dup.delete_if { |_key, val| item == val }
   end
 end
index 39d306a..01f0deb 100644 (file)
@@ -1,15 +1,18 @@
+#
+# deprecation.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:deprecation, :doc => <<-EOS
+  newfunction(:deprecation, :doc => <<-DOC
   Function to print deprecation warnings (this is the 3.X version of it), The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method.).
-EOS
-  ) do |arguments|
+DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "deprecation: Wrong number of arguments given (#{arguments.size} for 2)") unless arguments.size == 2
 
     key = arguments[0]
     message = arguments[1]
 
-    if ENV['STDLIB_LOG_DEPRECATIONS'] == "true"
+    if ENV['STDLIB_LOG_DEPRECATIONS'] == 'true'
       warning("deprecation. #{key}. #{message}")
     end
   end
index c9ac478..360c1e3 100644 (file)
@@ -1,20 +1,25 @@
 #
 # difference.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:difference, :type => :rvalue, :doc => <<-EOS
-This function returns the difference between two arrays.
-The returned array is a copy of the original array, removing any items that
-also appear in the second array.
+  newfunction(:difference, :type => :rvalue, :doc => <<-DOC
+    This function returns the difference between two arrays.
+    The returned array is a copy of the original array, removing any items that
+    also appear in the second array.
+
+    *Examples:*
+
+        difference(["a","b","c"],["b","c","d"])
+
+    Would return: ["a"]
 
-*Examples:*
+    Note: Since Puppet 4 the minus (-) operator in the Puppet language does the same thing:
 
-    difference(["a","b","c"],["b","c","d"])
+      ['a', 'b', 'c'] - ['b', 'c', 'd']
+      # would return ['a']
 
-Would return: ["a"]
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
     # Two arguments are required
     raise(Puppet::ParseError, "difference(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2
index 34fa701..75e83aa 100644 (file)
@@ -1,14 +1,13 @@
 #
 # dig.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:dig, :type => :rvalue, :doc => <<-EOS
+  newfunction(:dig, :type => :rvalue, :doc => <<-DOC
     DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.
-    EOS
-  ) do |arguments|
-    warning("dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.")
-    if ! Puppet::Parser::Functions.autoloader.loaded?(:dig44)
+    DOC
+             ) do |arguments|
+    warning('dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.')
+    unless Puppet::Parser::Functions.autoloader.loaded?(:dig44)
       Puppet::Parser::Functions.autoloader.load(:dig44)
     end
     function_dig44(arguments)
index 21c0a8c..91724f4 100644 (file)
@@ -1,69 +1,64 @@
 #
 # dig44.rb
 #
-
 module Puppet::Parser::Functions
   newfunction(
-      :dig44,
-      :type => :rvalue,
-      :arity => -2,
-      :doc => <<-eos
-DEPRECATED: This function has been replaced in puppet 4.5.0.
+    :dig44,
+    :type => :rvalue,
+    :arity => -2,
+    :doc => <<-DOC
+    DEPRECATED: This function has been replaced in Puppet 4.5.0.
 
-Looks up into a complex structure of arrays and hashes and returns a value
-or the default value if nothing was found.
+    Looks up into a complex structure of arrays and hashes and returns a value
+    or the default value if nothing was found.
 
-Key can contain slashes to describe path components. The function will go down
-the structure and try to extract the required value.
+    Key can contain slashes to describe path components. The function will go down
+    the structure and try to extract the required value.
 
-$data = {
-  'a' => {
-    'b' => [
-      'b1',
-      'b2',
-      'b3',
-    ]
-  }
-}
+    $data = {
+      'a' => {
+        'b' => [
+          'b1',
+          'b2',
+          'b3',
+        ]
+      }
+    }
 
-$value = dig44($data, ['a', 'b', '2'], 'not_found')
-=> $value = 'b3'
+    $value = dig44($data, ['a', 'b', '2'], 'not_found')
+    => $value = 'b3'
 
-a -> first hash key
-b -> second hash key
-2 -> array index starting with 0
+    a -> first hash key
+    b -> second hash key
+    2 -> array index starting with 0
 
-not_found -> (optional) will be returned if there is no value or the path
-did not match. Defaults to nil.
+    not_found -> (optional) will be returned if there is no value or the path
+    did not match. Defaults to nil.
 
-In addition to the required "key" argument, the function accepts a default
-argument. It will be returned if no value was found or a path component is
-missing. And the fourth argument can set a variable path separator.
-  eos
+    In addition to the required "key" argument, the function accepts a default
+    argument. It will be returned if no value was found or a path component is
+    missing. And the fourth argument can set a variable path separator.
+  DOC
   ) do |arguments|
     # Two arguments are required
     raise(Puppet::ParseError, "dig44(): Wrong number of arguments given (#{arguments.size} for at least 2)") if arguments.size < 2
 
     data, path, default = *arguments
 
-    unless data.is_a?(Hash) or data.is_a?(Array)
-      raise(Puppet::ParseError, "dig44(): first argument must be a hash or an array, given #{data.class.name}")
-    end
-
-    unless path.is_a? Array
-      raise(Puppet::ParseError, "dig44(): second argument must be an array, given #{path.class.name}")
-    end
+    raise(Puppet::ParseError, "dig44(): first argument must be a hash or an array, given #{data.class.name}") unless data.is_a?(Hash) || data.is_a?(Array)
+    raise(Puppet::ParseError, "dig44(): second argument must be an array, given #{path.class.name}") unless path.is_a? Array
 
     value = path.reduce(data) do |structure, key|
-      if structure.is_a? Hash or structure.is_a? Array
-        if structure.is_a? Array
-          key = Integer key rescue break
+      break unless structure.is_a?(Hash) || structure.is_a?(Array)
+      if structure.is_a? Array
+        begin
+          key = Integer key
+        rescue
+          break
         end
-        break if structure[key].nil? or structure[key] == :undef
-        structure[key]
-      else
-        break
       end
+      break if structure[key].nil? || structure[key] == :undef
+      structure[key]
     end
     value.nil? ? default : value
   end
index 40b300d..54bd9b6 100644 (file)
@@ -1,18 +1,25 @@
+#
+# dirname.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
+  newfunction(:dirname, :type => :rvalue, :doc => <<-DOC
     Returns the dirname of a path.
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
-    if arguments.size < 1 then
-      raise(Puppet::ParseError, "dirname(): No arguments given")
+    if arguments.empty?
+      raise(Puppet::ParseError, 'dirname(): No arguments given')
     end
-    if arguments.size > 1 then
+    if arguments.size > 1
       raise(Puppet::ParseError, "dirname(): Too many arguments given (#{arguments.size})")
     end
     unless arguments[0].is_a?(String)
       raise(Puppet::ParseError, 'dirname(): Requires string as argument')
     end
+    # undef is converted to an empty string ''
+    if arguments[0].empty?
+      raise(Puppet::ParseError, 'dirname(): Requires a non-empty string as argument')
+    end
 
     return File.dirname(arguments[0])
   end
index ccac899..32722ba 100644 (file)
@@ -1,15 +1,15 @@
 # Custom Puppet function to convert dos to unix format
 module Puppet::Parser::Functions
-  newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-EOS
+  newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-DOC
     Returns the Unix version of the given string.
     Takes a single string argument.
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
     unless arguments[0].is_a?(String)
       raise(Puppet::ParseError, 'dos2unix(): Requires string as argument')
     end
 
-    arguments[0].gsub(/\r\n/, "\n")
+    arguments[0].gsub(%r{\r\n}, "\n")
   end
 end
index ab04f8a..0c76375 100644 (file)
@@ -2,14 +2,16 @@
 #  downcase.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:downcase, :type => :rvalue, :doc => <<-EOS
-Converts the case of a string or all strings in an array to lower case.
-    EOS
-  ) do |arguments|
+  newfunction(:downcase, :type => :rvalue, :doc => <<-DOC
+    Converts the case of a string or all strings in an array to lower case.
+
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+  DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "downcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "downcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -17,12 +19,12 @@ Converts the case of a string or all strings in an array to lower case.
       raise(Puppet::ParseError, 'downcase(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? i.downcase : i }
-    else
-      result = value.downcase
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? i.downcase : i }
+             else
+               value.downcase
+             end
 
     return result
   end
index 4f77ad3..e0b9838 100644 (file)
@@ -1,28 +1,25 @@
 #
 # empty.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:empty, :type => :rvalue, :doc => <<-EOS
-Returns true if the variable is empty.
-    EOS
-  ) do |arguments|
+  newfunction(:empty, :type => :rvalue, :doc => <<-DOC
+    Returns true if the variable is empty.
 
-    raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+  DOC
+             ) do |arguments|
 
+    raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String) || value.is_a?(Numeric)
       raise(Puppet::ParseError, 'empty(): Requires either array, hash, string or integer to work with')
     end
 
-    if value.is_a?(Numeric)
-      return false
-    else
-      result = value.empty?
-
-      return result
-    end
+    return false if value.is_a?(Numeric)
+    result = value.empty?
+    return result
   end
 end
 
index 1f8a454..f412b01 100644 (file)
@@ -1,24 +1,23 @@
 #
 # enclose_ipv6.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-EOS
-Takes an array of ip addresses and encloses the ipv6 addresses with square brackets.
-    EOS
-  ) do |arguments|
+  newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-DOC
+    Takes an array of ip addresses and encloses the ipv6 addresses with square brackets.
+  DOC
+             ) do |arguments|
 
     require 'ipaddr'
 
-    rescuable_exceptions = [ ArgumentError ]
+    rescuable_exceptions = [ArgumentError]
     if defined?(IPAddr::InvalidAddressError)
-           rescuable_exceptions << IPAddr::InvalidAddressError
+      rescuable_exceptions << IPAddr::InvalidAddressError
     end
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "enclose_ipv6(): Wrong number of arguments given #{arguments.size} for 1")
     end
-    unless arguments[0].is_a?(String) or arguments[0].is_a?(Array) then
+    unless arguments[0].is_a?(String) || arguments[0].is_a?(Array)
       raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type given #{arguments[0].class} expected String or Array")
     end
 
@@ -32,7 +31,7 @@ Takes an array of ip addresses and encloses the ipv6 addresses with square brack
         rescue *rescuable_exceptions
           raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument given #{val} is not an ip address.")
         end
-        val = "[#{ip.to_s}]" if ip.ipv6?
+        val = "[#{ip}]" if ip.ipv6?
       end
       result << val
     end
index 1bf8bf1..f91e3e1 100644 (file)
@@ -1,20 +1,16 @@
 #
 # ensure_packages.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS
-Takes a list of packages and only installs them if they don't already exist.
-It optionally takes a hash as a second parameter that will be passed as the
-third argument to the ensure_resource() function.
-    EOS
-  ) do |arguments|
+  newfunction(:ensure_packages, :type => :statement, :doc => <<-DOC
+    Takes a list of packages and only installs them if they don't already exist.
+    It optionally takes a hash as a second parameter that will be passed as the
+    third argument to the ensure_resource() function.
+  DOC
+             ) do |arguments|
 
-    if arguments.size > 2 or arguments.size == 0
-      raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments given (#{arguments.size} for 1 or 2)")
-    elsif arguments.size == 2 and !arguments[1].is_a?(Hash)
-      raise(Puppet::ParseError, 'ensure_packages(): Requires second argument to be a Hash')
-    end
+    raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments given (#{arguments.size} for 1 or 2)") if arguments.size > 2 || arguments.empty?
+    raise(Puppet::ParseError, 'ensure_packages(): Requires second argument to be a Hash') if arguments.size == 2 && !arguments[1].is_a?(Hash)
 
     if arguments[0].is_a?(Hash)
       if arguments[1]
@@ -27,7 +23,7 @@ third argument to the ensure_resource() function.
       end
 
       Puppet::Parser::Functions.function(:ensure_resources)
-      function_ensure_resources(['package', arguments[0].dup, defaults ])
+      function_ensure_resources(['package', arguments[0].dup, defaults])
     else
       packages = Array(arguments[0])
 
@@ -41,12 +37,10 @@ third argument to the ensure_resource() function.
       end
 
       Puppet::Parser::Functions.function(:ensure_resource)
-      packages.each { |package_name|
-      raise(Puppet::ParseError, 'ensure_packages(): Empty String provided for package name') if package_name.length == 0
-      if !findresource("Package[#{package_name}]")
-        function_ensure_resource(['package', package_name, defaults ])
+      packages.each do |package_name|
+        raise(Puppet::ParseError, 'ensure_packages(): Empty String provided for package name') if package_name.empty?
+        function_ensure_resource(['package', package_name, defaults])
       end
-    }
     end
   end
 end
index 1ba6a44..d28ed9d 100644 (file)
@@ -3,29 +3,29 @@ require 'puppet/parser/functions'
 
 Puppet::Parser::Functions.newfunction(:ensure_resource,
                                       :type => :statement,
-                                      :doc => <<-'ENDOFDOC'
-Takes a resource type, title, and a list of attributes that describe a
-resource.
+                                      :doc => <<-'DOC'
+    Takes a resource type, title, and a list of attributes that describe a
+    resource.
 
-    user { 'dan':
-      ensure => present,
-    }
+        user { 'dan':
+          ensure => present,
+        }
 
-This example only creates the resource if it does not already exist:
+    This example only creates the resource if it does not already exist:
 
-    ensure_resource('user', 'dan', {'ensure' => 'present' })
+        ensure_resource('user', 'dan', {'ensure' => 'present' })
 
-If the resource already exists but does not match the specified parameters,
-this function will attempt to recreate the resource leading to a duplicate
-resource definition error.
+    If the resource already exists but does not match the specified parameters,
+    this function will attempt to recreate the resource leading to a duplicate
+    resource definition error.
 
-An array of resources can also be passed in and each will be created with
-the type and parameters specified if it doesn't already exist.
+    An array of resources can also be passed in and each will be created with
+    the type and parameters specified if it doesn't already exist.
 
-    ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
+        ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
 
-ENDOFDOC
-) do |vals|
+DOC
+                                     ) do |vals|
   type, title, params = vals
   raise(ArgumentError, 'Must specify a type') unless type
   raise(ArgumentError, 'Must specify a title') unless title
index b3c51e6..642247c 100644 (file)
@@ -2,53 +2,49 @@ require 'puppet/parser/functions'
 
 Puppet::Parser::Functions.newfunction(:ensure_resources,
                                       :type => :statement,
-                                      :doc => <<-'ENDOFDOC'
-Takes a resource type, title (only hash), and a list of attributes that describe a
-resource.
+                                      :doc => <<-'DOC'
+    Takes a resource type, title (only hash), and a list of attributes that describe a
+    resource.
 
-    user { 'dan':
-      gid => 'mygroup',
-      ensure => present,
-    }
+        user { 'dan':
+          gid => 'mygroup',
+          ensure => present,
+        }
 
-An hash of resources should be passed in and each will be created with
-the type and parameters specified if it doesn't already exist.
+    An hash of resources should be passed in and each will be created with
+    the type and parameters specified if it doesn't already exist.
 
-    ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } ,  'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
+        ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } ,  'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
 
-From Hiera Backend:
+    From Hiera Backend:
 
-userlist:
-  dan:
-    gid: 'mygroup'
- uid: '600'
-  alex:
- gid: 'mygroup'
+    userlist:
+      dan:
+        gid: 'mygroup'
    uid: '600'
+      alex:
    gid: 'mygroup'
 
-Call:
-ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
-
-ENDOFDOC
-) do |vals|
+    Call:
+    ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
+DOC
+                                     ) do |vals|
   type, title, params = vals
   raise(ArgumentError, 'Must specify a type') unless type
   raise(ArgumentError, 'Must specify a title') unless title
   params ||= {}
 
-  if title.is_a?(Hash)
-    resource_hash = title.dup
-    resources = resource_hash.keys
-
-    Puppet::Parser::Functions.function(:ensure_resource)
-    resources.each { |resource_name|
-    if resource_hash[resource_name]
-        params_merged = params.merge(resource_hash[resource_name])
-    else
-        params_merged = params
-    end
-    function_ensure_resource([ type, resource_name, params_merged ])
-    }
-  else
-       raise(Puppet::ParseError, 'ensure_resources(): Requires second argument to be a Hash')
+  raise(Puppet::ParseError, 'ensure_resources(): Requires second argument to be a Hash') unless title.is_a?(Hash)
+  resource_hash = title.dup
+  resources = resource_hash.keys
+
+  Puppet::Parser::Functions.function(:ensure_resource)
+  resources.each do |resource_name|
+    params_merged = if resource_hash[resource_name]
+                      params.merge(resource_hash[resource_name])
+                    else
+                      params
+                    end
+    function_ensure_resource([type, resource_name, params_merged])
   end
 end
index 4401bdb..6be5962 100644 (file)
@@ -1,19 +1,21 @@
 #
 # flatten.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:flatten, :type => :rvalue, :doc => <<-EOS
-This function flattens any deeply nested arrays and returns a single flat array
-as a result.
+  newfunction(:flatten, :type => :rvalue, :doc => <<-DOC
+    This function flattens any deeply nested arrays and returns a single flat array
+    as a result.
+
+    *Examples:*
 
-*Examples:*
+        flatten(['a', ['b', ['c']]])
 
-    flatten(['a', ['b', ['c']]])
+    Would return: ['a','b','c']
 
-Would return: ['a','b','c']
-    EOS
-  ) do |arguments|
+    Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "flatten(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
index 9e4b504..df132fc 100644 (file)
@@ -1,15 +1,21 @@
+#
+# floor.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:floor, :type => :rvalue, :doc => <<-EOS
+  newfunction(:floor, :type => :rvalue, :doc => <<-DOC
     Returns the largest integer less or equal to the argument.
     Takes a single numeric value as an argument.
-    EOS
-  ) do |arguments|
+
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "floor(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     begin
       arg = Float(arguments[0])
-    rescue TypeError, ArgumentError => e
+    rescue TypeError, ArgumentError => _e
       raise(Puppet::ParseError, "floor(): Wrong argument type given (#{arguments[0]} for Numeric)")
     end
 
index 2bb1287..ee45236 100644 (file)
@@ -1,4 +1,4 @@
-Puppet::Parser::Functions::newfunction(
+Puppet::Parser::Functions.newfunction(
   :fqdn_rand_string,
   :arity => -2,
   :type => :rvalue,
@@ -12,23 +12,24 @@ Puppet::Parser::Functions::newfunction(
   string from this function, but a given node's result will be the same every
   time unless its hostname changes.) Adding a SEED can be useful if you need
   more than one unrelated string. CHARSET will default to alphanumeric if
-  `undef` or an empty string.") do |args|
-    raise(ArgumentError, "fqdn_rand_string(): wrong number of arguments (0 for 1)") if args.size == 0
-    Puppet::Parser::Functions.function('is_integer')
-    raise(ArgumentError, "fqdn_rand_string(): first argument must be a positive integer") unless function_is_integer([args[0]]) and args[0].to_i > 0
-    raise(ArgumentError, "fqdn_rand_string(): second argument must be undef or a string") unless args[1].nil? or args[1].is_a? String
+  `undef` or an empty string.",
+) do |args|
+  raise(ArgumentError, 'fqdn_rand_string(): wrong number of arguments (0 for 1)') if args.empty?
+  Puppet::Parser::Functions.function('is_integer')
+  raise(ArgumentError, 'fqdn_rand_string(): first argument must be a positive integer') unless function_is_integer([args[0]]) && args[0].to_i > 0
+  raise(ArgumentError, 'fqdn_rand_string(): second argument must be undef or a string') unless args[1].nil? || args[1].is_a?(String)
 
-    Puppet::Parser::Functions.function('fqdn_rand')
+  Puppet::Parser::Functions.function('fqdn_rand')
 
-    length = args.shift.to_i
-    charset = args.shift.to_s.chars.to_a
+  length = args.shift.to_i
+  charset = args.shift.to_s.chars.to_a
 
-    charset = (0..9).map { |i| i.to_s } + ('A'..'Z').to_a + ('a'..'z').to_a if charset.empty?
+  charset = (0..9).map { |i| i.to_s } + ('A'..'Z').to_a + ('a'..'z').to_a if charset.empty?
 
-    rand_string = ''
-    for current in 1..length
-      rand_string << charset[function_fqdn_rand([charset.size, (args + [current.to_s]).join(':')]).to_i]
-    end
+  rand_string = ''
+  for current in 1..length # rubocop:disable Style/For : An each loop would not work correctly in this circumstance
+    rand_string << charset[function_fqdn_rand([charset.size, (args + [current.to_s]).join(':')]).to_i]
+  end
 
-    rand_string
+  rand_string
 end
index 05bdcc7..879e44b 100644 (file)
@@ -1,7 +1,6 @@
 #
 # fqdn_rotate.rb
 #
-
 Puppet::Parser::Functions.newfunction(
   :fqdn_rotate,
   :type => :rvalue,
@@ -13,49 +12,48 @@ Puppet::Parser::Functions.newfunction(
   the value of SEED for repeatable randomness. (That is, each node will
   get a different random rotation from this function, but a given node's
   result will be the same every time unless its hostname changes.) Adding
-  a SEED can be useful if you need more than one unrelated rotation.") do |args|
+  a SEED can be useful if you need more than one unrelated rotation.",
+) do |args|
+
+  raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments given (#{args.size} for 1)") if args.empty?
 
-    raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments given (#{args.size} for 1)") if args.size < 1
+  value = args.shift
+  require 'digest/md5'
 
-    value = args.shift
-    require 'digest/md5'
+  unless value.is_a?(Array) || value.is_a?(String)
+    raise(Puppet::ParseError, 'fqdn_rotate(): Requires either array or string to work with')
+  end
 
-    unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'fqdn_rotate(): Requires either array or string to work with')
-    end
+  result = value.clone
 
-    result = value.clone
+  string = value.is_a?(String) ? true : false
 
-    string = value.is_a?(String) ? true : false
+  # Check whether it makes sense to rotate ...
+  return result if result.size <= 1
 
-    # Check whether it makes sense to rotate ...
-    return result if result.size <= 1
+  # We turn any string value into an array to be able to rotate ...
+  result = string ? result.split('') : result
 
-    # We turn any string value into an array to be able to rotate ...
-    result = string ? result.split('') : result
+  elements = result.size
 
-    elements = result.size
+  seed = Digest::MD5.hexdigest([lookupvar('::fqdn'), args].join(':')).hex
+  # deterministic_rand() was added in Puppet 3.2.0; reimplement if necessary
+  if Puppet::Util.respond_to?(:deterministic_rand)
+    offset = Puppet::Util.deterministic_rand(seed, elements).to_i
+  else
+    return offset = Random.new(seed).rand(elements) if defined?(Random) == 'constant' && Random.class == Class
 
-    seed = Digest::MD5.hexdigest([lookupvar('::fqdn'),args].join(':')).hex
-    # deterministic_rand() was added in Puppet 3.2.0; reimplement if necessary
-    if Puppet::Util.respond_to?(:deterministic_rand)
-      offset = Puppet::Util.deterministic_rand(seed, elements).to_i
-    else
-      if defined?(Random) == 'constant' && Random.class == Class
-        offset = Random.new(seed).rand(elements)
-      else
-        old_seed = srand(seed)
-        offset = rand(elements)
-        srand(old_seed)
-      end
-    end
-    offset.times {
-       result.push result.shift
-    }
+    old_seed = srand(seed)
+    offset = rand(elements)
+    srand(old_seed)
+  end
+  offset.times do
+    result.push result.shift
+  end
 
-    result = string ? result.join : result
+  result = string ? result.join : result
 
-    return result
+  return result
 end
 
 # vim: set ts=2 sw=2 et :
index 30205d0..5080e8e 100644 (file)
@@ -1,8 +1,9 @@
 require 'digest/sha1'
-
+#
+# fqdn_uuid.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:fqdn_uuid, :type => :rvalue, :doc => <<-END) do |args|
-
+  newfunction(:fqdn_uuid, :type => :rvalue, :doc => <<-DOC) do |args|
     Creates a UUID based on a given string, assumed to be the FQDN
 
     For example, to generate a UUID based on the FQDN of a system:
@@ -31,17 +32,11 @@ module Puppet::Parser::Functions
     No verification is present at the moment as whether the domain name given
     is in fact a correct fully-qualified domain name.  Therefore any arbitrary
     string and/or alpha-numeric value can subside for a domain name.
-    EOS
+    DOC
 
-    END
-
-    if args.length == 0
-      raise(ArgumentError, "fqdn_uuid: No arguments given")
-    elsif args.length == 1
-      fqdn = args[0]
-    else
-      raise(ArgumentError, "fqdn_uuid: Too many arguments given (#{args.length})")
-    end
+    raise(ArgumentError, 'fqdn_uuid: No arguments given') if args.empty?
+    raise(ArgumentError, "fqdn_uuid: Too many arguments given (#{args.length})") unless args.length == 1
+    fqdn = args[0]
 
     # Code lovingly taken from
     # https://github.com/puppetlabs/marionette-collective/blob/master/lib/mcollective/ssl.rb
@@ -51,22 +46,21 @@ module Puppet::Parser::Functions
     #  6ba7b810-9dad-11d1-80b4-00c04fd430c8
     #
     uuid_name_space_dns = [0x6b,
-      0xa7,
-      0xb8,
-      0x10,
-      0x9d,
-      0xad,
-      0x11,
-      0xd1,
-      0x80,
-      0xb4,
-      0x00,
-      0xc0,
-      0x4f,
-      0xd4,
-      0x30,
-      0xc8
-    ].map {|b| b.chr}.join
+                           0xa7,
+                           0xb8,
+                           0x10,
+                           0x9d,
+                           0xad,
+                           0x11,
+                           0xd1,
+                           0x80,
+                           0xb4,
+                           0x00,
+                           0xc0,
+                           0x4f,
+                           0xd4,
+                           0x30,
+                           0xc8].map { |b| b.chr }.join
 
     sha1 = Digest::SHA1.new
     sha1.update(uuid_name_space_dns)
@@ -83,7 +77,7 @@ module Puppet::Parser::Functions
     bytes[8] &= 0x3f
     bytes[8] |= 0x80
 
-    bytes = [4, 2, 2, 2, 6].collect do |i|
+    bytes = [4, 2, 2, 2, 6].map do |i|
       bytes.slice!(0, i).pack('C*').unpack('H*')
     end
 
index 1421b91..3ec6ccd 100644 (file)
@@ -1,17 +1,21 @@
+#
+# get_module_path.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:get_module_path, :type =>:rvalue, :doc => <<-EOT
+  newfunction(:get_module_path, :type => :rvalue, :doc => <<-DOC
     Returns the absolute path of the specified module for the current
     environment.
 
     Example:
       $module_path = get_module_path('stdlib')
-  EOT
-  ) do |args|
-    raise(Puppet::ParseError, "get_module_path(): Wrong number of arguments, expects one") unless args.size == 1
-    if module_path = Puppet::Module.find(args[0], compiler.environment.to_s)
-      module_path.path
-    else
-      raise(Puppet::ParseError, "Could not find module #{args[0]} in environment #{compiler.environment}")
-    end
+
+    Note that since Puppet 5.4.0 the function `module_directory()` in Puppet does the same thing and will return
+    the path to the first found module if given multiple values or an array.
+  DOC
+             ) do |args|
+    raise(Puppet::ParseError, 'get_module_path(): Wrong number of arguments, expects one') unless args.size == 1
+    module_path = Puppet::Module.find(args[0], compiler.environment.to_s)
+    raise(Puppet::ParseError, "Could not find module #{args[0]} in environment #{compiler.environment}") unless module_path
+    module_path.path
   end
 end
index 0a5cbe0..95981b3 100644 (file)
@@ -3,31 +3,50 @@ require 'puppet/parser/functions'
 
 Puppet::Parser::Functions.newfunction(:getparam,
                                       :type => :rvalue,
-                                      :doc => <<-'ENDOFDOC'
-Takes a resource reference and name of the parameter and
-returns value of resource's parameter.
+                                      :doc => <<-'DOC'
+    Takes a resource reference and name of the parameter and
+    returns value of resource's parameter. Note that user defined
+    resource types are evaluated lazily.
 
-*Examples:*
+    *Examples:*
 
-    define example_resource($param) {
-    }
+        # define a resource type with a parameter
+        define example_resource($param) {
+        }
 
-    example_resource { "example_resource_instance":
-        param => "param_value"
-    }
+        # declare an instance of that type
+        example_resource { "example_resource_instance":
+            param => "'the value we are getting in this example''"
+        }
 
-    getparam(Example_resource["example_resource_instance"], "param")
+        # Because of order of evaluation, a second definition is needed
+        # that will be evaluated after the first resource has been declared
+        #
+        define example_get_param {
+          # This will notice the value of the parameter
+          notice(getparam(Example_resource["example_resource_instance"], "param"))
+        }
 
-Would return: param_value
-ENDOFDOC
-) do |vals|
+        # Declare an instance of the second resource type - this will call notice
+        example_get_param { 'show_notify': }
+
+    Would notice: 'the value we are getting in this example'
+
+    Note that since Puppet 4.0.0 it is possible to get a parameter value by using its data type
+    and the [ ] operator. The example below is equivalent to a call to getparam():
+
+        Example_resource['example_resource_instance']['param']
+
+  DOC
+                                     ) do |vals|
   reference, param = vals
   raise(ArgumentError, 'Must specify a reference') unless reference
-  raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String
+  raise(ArgumentError, 'Must specify name of a parameter') unless param && param.instance_of?(String)
 
   return '' if param.empty?
 
-  if resource = findresource(reference.to_s)
+  resource = findresource(reference.to_s)
+  if resource
     return resource[param] unless resource[param].nil?
   end
 
index 3af8d48..fddbd82 100644 (file)
@@ -1,7 +1,10 @@
+#
+# getvar.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
-    Lookup a variable in a remote namespace.
+  newfunction(:getvar, :type => :rvalue, :doc => <<-'DOC') do |args|
+    Lookup a variable in a given namespace.
+    Returns undef if variable does not exist.
 
     For example:
 
@@ -13,23 +16,26 @@ module Puppet::Parser::Functions
         $datalocation = 'site::data'
         $bar = getvar("${datalocation}::bar")
         # Equivalent to $bar = $site::data::bar
-    ENDHEREDOC
+
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function. The new function also has support for
+    digging into a structured value. See the built-in
+    [`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) function
+    DOC
 
     unless args.length == 1
-      raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)")
+      raise Puppet::ParseError, "getvar(): wrong number of arguments (#{args.length}; must be 1)"
     end
 
     begin
       result = nil
       catch(:undefined_variable) do
-        result = self.lookupvar("#{args[0]}")
+        result = lookupvar((args[0]).to_s)
       end
 
-      # avoid relying on incosistent behaviour around ruby return values from catch
+      # avoid relying on inconsistent behaviour around ruby return values from catch
       result
-    rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
+    rescue Puppet::ParseError # rubocop:disable Lint/HandleExceptions : Eat the exception if strict_variables = true is set
     end
-
   end
-
 end
index 54cdda6..e9d35b2 100644 (file)
@@ -1,21 +1,24 @@
 #
 #  glob.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:glob, :type => :rvalue, :doc => <<-'EOS'
+  newfunction(:glob, :type => :rvalue, :doc => <<-'DOC'
     Returns an Array of file entries of a directory or an Array of directories.
     Uses same patterns as Dir#glob
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "glob(): Wrong number of arguments given " +
-      "(#{arguments.size} for 1)") unless arguments.size == 1
+    unless arguments.size == 1
+      raise(Puppet::ParseError, 'glob(): Wrong number of arguments given ' \
+        "(#{arguments.size} for 1)")
+    end
 
     pattern = arguments[0]
 
-    raise(Puppet::ParseError, 'glob(): Requires either array or string ' +
-      'to work') unless pattern.is_a?(String) || pattern.is_a?(Array)
+    unless pattern.is_a?(String) || pattern.is_a?(Array)
+      raise(Puppet::ParseError, 'glob(): Requires either array or string ' \
+        'to work')
+    end
 
     Dir.glob(pattern)
   end
index c611a7e..b6881bf 100644 (file)
@@ -1,23 +1,26 @@
 #
 # grep.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:grep, :type => :rvalue, :doc => <<-EOS
-This function searches through an array and returns any elements that match
-the provided regular expression.
+  newfunction(:grep, :type => :rvalue, :doc => <<-DOC
+    This function searches through an array and returns any elements that match
+    the provided regular expression.
+
+    *Examples:*
 
-*Examples:*
+        grep(['aaa','bbb','ccc','aaaddd'], 'aaa')
 
-    grep(['aaa','bbb','ccc','aaaddd'], 'aaa')
+    Would return:
 
-Would return:
+        ['aaa','aaaddd']
 
-    ['aaa','aaaddd']
-    EOS
-  ) do |arguments|
+    Note that since Puppet 4.0.0, the filter() function in Puppet can do the same:
 
-    if (arguments.size != 2) then
+        ['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }
+    DOC
+             ) do |arguments|
+
+    if arguments.size != 2
       raise(Puppet::ParseError, "grep(): Wrong number of arguments given #{arguments.size} for 2")
     end
 
@@ -25,7 +28,6 @@ Would return:
     pattern = Regexp.new(arguments[1])
 
     a.grep(pattern)
-
   end
 end
 
index f6cb74b..44005d0 100644 (file)
@@ -1,30 +1,29 @@
 #
 # has_interface_with
 #
-
 module Puppet::Parser::Functions
-  newfunction(:has_interface_with, :type => :rvalue, :doc => <<-EOS
-Returns boolean based on kind and value:
-  * macaddress
-  * netmask
-  * ipaddress
-  * network
+  newfunction(:has_interface_with, :type => :rvalue, :doc => <<-DOC
+    Returns boolean based on kind and value:
+      * macaddress
+      * netmask
+      * ipaddress
+      * network
 
-has_interface_with("macaddress", "x:x:x:x:x:x")
-has_interface_with("ipaddress", "127.0.0.1")    => true
-etc.
+    has_interface_with("macaddress", "x:x:x:x:x:x")
+    has_interface_with("ipaddress", "127.0.0.1")    => true
+    etc.
 
-If no "kind" is given, then the presence of the interface is checked:
-has_interface_with("lo")                        => true
-    EOS
-  ) do |args|
+    If no "kind" is given, then the presence of the interface is checked:
+    has_interface_with("lo")                        => true
+    DOC
+             ) do |args|
 
-    raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments given (#{args.size} for 1 or 2)") if args.size < 1 or args.size > 2
+    raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments given (#{args.size} for 1 or 2)") if args.empty? || args.size > 2
 
     interfaces = lookupvar('interfaces')
 
     # If we do not have any interfaces, then there are no requested attributes
-    return false if (interfaces == :undefined || interfaces.nil?)
+    return false if interfaces == :undefined || interfaces.nil?
 
     interfaces = interfaces.split(',')
 
@@ -41,7 +40,7 @@ has_interface_with("lo")                        => true
       catch :undefined_variable do
         factval = lookupvar(kind)
       end
-    rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
+    rescue Puppet::ParseError # rubocop:disable Lint/HandleExceptions : Eat the exception if strict_variables = true is set
     end
     if factval == value
       return true
@@ -57,7 +56,7 @@ has_interface_with("lo")                        => true
         catch :undefined_variable do
           factval = lookupvar("#{kind}_#{iface}")
         end
-      rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
+      rescue Puppet::ParseError # rubocop:disable Lint/HandleExceptions : Eat the exception if strict_variables = true is set
       end
       if value == factval
         result = true
index a0071c8..5f14ee2 100644 (file)
@@ -1,15 +1,14 @@
 #
 # has_ip_address
 #
-
 module Puppet::Parser::Functions
-  newfunction(:has_ip_address, :type => :rvalue, :doc => <<-EOS
-Returns true if the client has the requested IP address on some interface.
+  newfunction(:has_ip_address, :type => :rvalue, :doc => <<-DOC
+    Returns true if the client has the requested IP address on some interface.
 
-This function iterates through the 'interfaces' fact and checks the
-'ipaddress_IFACE' facts, performing a simple string comparison.
-    EOS
-  ) do |args|
+    This function iterates through the 'interfaces' fact and checks the
+    'ipaddress_IFACE' facts, performing a simple string comparison.
+    DOC
+             ) do |args|
 
     raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1
 
@@ -17,7 +16,6 @@ This function iterates through the 'interfaces' fact and checks the
       unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with)
 
     function_has_interface_with(['ipaddress', args[0]])
-
   end
 end
 
index b02c0c0..65f2789 100644 (file)
@@ -1,15 +1,14 @@
 #
 # has_ip_network
 #
-
 module Puppet::Parser::Functions
-  newfunction(:has_ip_network, :type => :rvalue, :doc => <<-EOS
-Returns true if the client has an IP address within the requested network.
+  newfunction(:has_ip_network, :type => :rvalue, :doc => <<-DOC
+    Returns true if the client has an IP address within the requested network.
 
-This function iterates through the 'interfaces' fact and checks the
-'network_IFACE' facts, performing a simple string comparision.
-    EOS
-  ) do |args|
+    This function iterates through the 'interfaces' fact and checks the
+    'network_IFACE' facts, performing a simple string comparision.
+    DOC
+             ) do |args|
 
     raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1
 
@@ -17,7 +16,6 @@ This function iterates through the 'interfaces' fact and checks the
       unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with)
 
     function_has_interface_with(['network', args[0]])
-
   end
 end
 
index 4657cc2..8bf74f0 100644 (file)
@@ -1,6 +1,8 @@
+#
+# has_key.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:has_key, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:has_key, :type => :rvalue, :doc => <<-'DOC') do |args|
     Determine if a hash has a certain key value.
 
     Example:
@@ -13,16 +15,20 @@ module Puppet::Parser::Functions
           notice('this will be printed')
         }
 
-    ENDHEREDOC
+    Note: Since Puppet 4.0.0 this can be achieved in the Puppet language with the following equivalent expression:
+
+       $my_hash = {'key_one' => 'value_one'}
+       if 'key_one' in $my_hash {
+         notice('this will be printed')
+       }
+    DOC
 
     unless args.length == 2
-      raise Puppet::ParseError, ("has_key(): wrong number of arguments (#{args.length}; must be 2)")
+      raise Puppet::ParseError, "has_key(): wrong number of arguments (#{args.length}; must be 2)"
     end
     unless args[0].is_a?(Hash)
       raise Puppet::ParseError, "has_key(): expects the first argument to be a hash, got #{args[0].inspect} which is of type #{args[0].class}"
     end
-    args[0].has_key?(args[1])
-
+    args[0].key?(args[1])
   end
-
 end
index 22763f3..0162e83 100644 (file)
@@ -1,20 +1,26 @@
 #
 # hash.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:hash, :type => :rvalue, :doc => <<-EOS
-This function converts an array into a hash.
+  newfunction(:hash, :type => :rvalue, :doc => <<-DOC
+    This function converts an array into a hash.
+
+    *Examples:*
+
+        hash(['a',1,'b',2,'c',3])
 
-*Examples:*
+    Would return: {'a'=>1,'b'=>2,'c'=>3}
 
-    hash(['a',1,'b',2,'c',3])
+    Note: Since Puppet 5.0.0 type conversions can in general be performed by using the Puppet Type System.
+    See the function new() in Puppet for a wide range of available type conversions.
+    This example shows the equivalent expression in the Puppet language:
 
-Would return: {'a'=>1,'b'=>2,'c'=>3}
-    EOS
-  ) do |arguments|
+        Hash(['a',1,'b',2,'c',3])
+        Hash([['a',1],['b',2],['c',3]])
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     array = arguments[0]
 
index 8a438f4..0c16722 100644 (file)
@@ -1,18 +1,16 @@
 #
 # intersection.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:intersection, :type => :rvalue, :doc => <<-EOS
-This function returns an array of the intersection of two.
-
-*Examples:*
+  newfunction(:intersection, :type => :rvalue, :doc => <<-DOC
+    This function returns an array of the intersection of two.
 
-    intersection(["a","b","c"],["b","c","d"])  # returns ["b","c"]
-    intersection(["a","b","c"],[1,2,3,4])      # returns [] (true, when evaluated as a Boolean)
+    *Examples:*
 
-    EOS
-  ) do |arguments|
+        intersection(["a","b","c"],["b","c","d"])  # returns ["b","c"]
+        intersection(["a","b","c"],[1,2,3,4])      # returns [] (true, when evaluated as a Boolean)
+    DOC
+             ) do |arguments|
 
     # Two arguments are required
     raise(Puppet::ParseError, "intersection(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2
index e64777f..06e9465 100644 (file)
@@ -1,5 +1,8 @@
+#
+# is_absolute_path.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:is_absolute_path, :type => :rvalue, :arity => 1, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:is_absolute_path, :type => :rvalue, :arity => 1, :doc => <<-'DOC') do |args|
     Returns boolean true if the string represents an absolute path in the filesystem.  This function works
     for windows and unix style paths.
 
@@ -22,16 +25,17 @@ module Puppet::Parser::Functions
         $undefined = undef
         is_absolute_path($undefined)
 
-  ENDHEREDOC
-    function_deprecation([:is_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
+  DOC
+    function_deprecation([:is_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function,
+                           with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
     require 'puppet/util'
 
     path = args[0]
     # This logic was borrowed from
     # [lib/puppet/file_serving/base.rb](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_serving/base.rb)
     # Puppet 2.7 and beyond will have Puppet::Util.absolute_path? Fall back to a back-ported implementation otherwise.
-    if Puppet::Util.respond_to?(:absolute_path?) then
-      value = (Puppet::Util.absolute_path?(path, :posix) or Puppet::Util.absolute_path?(path, :windows))
+    if Puppet::Util.respond_to?(:absolute_path?)
+      value = (Puppet::Util.absolute_path?(path, :posix) || Puppet::Util.absolute_path?(path, :windows))
     else
       # This code back-ported from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path?
       # Determine in a platform-specific way whether a path is absolute. This
@@ -40,10 +44,10 @@ module Puppet::Parser::Functions
       slash = '[\\\\/]'
       name = '[^\\\\/]+'
       regexes = {
-        :windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
-        :posix => %r!^/!
+        :windows => %r{^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))}i,
+        :posix => %r{^/},
       }
-      value = (!!(path =~ regexes[:posix])) || (!!(path =~ regexes[:windows]))
+      value = !!(path =~ regexes[:posix]) || !!(path =~ regexes[:windows]) # rubocop:disable Style/DoubleNegation : No alternative known
     end
     value
   end
index a33afe4..620f4f7 100644 (file)
@@ -1,16 +1,16 @@
 #
 # is_array.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_array, :type => :rvalue, :doc => <<-EOS
-Returns true if the variable passed to this function is an array.
-    EOS
-  ) do |arguments|
+  newfunction(:is_array, :type => :rvalue, :doc => <<-DOC
+    Returns true if the variable passed to this function is an array.
+    DOC
+             ) do |arguments|
 
-    function_deprecation([:is_array, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_array, 'This method is deprecated, please use the stdlib validate_legacy function,
+                           with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.'])
 
-    raise(Puppet::ParseError, "is_array(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "is_array(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     type = arguments[0]
 
index 2ebe430..d0e0026 100644 (file)
@@ -1,14 +1,14 @@
 #
 # is_bool.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS
-Returns true if the variable passed to this function is a boolean.
-    EOS
-  ) do |arguments|
+  newfunction(:is_bool, :type => :rvalue, :doc => <<-DOC
+    Returns true if the variable passed to this function is a boolean.
+    DOC
+             ) do |arguments|
 
-    function_deprecation([:is_bool, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_bool, 'This method is deprecated, please use the stdlib validate_legacy function,
+                          with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.'])
 
     raise(Puppet::ParseError, "is_bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
index 247db3b..d80689a 100644 (file)
@@ -1,14 +1,13 @@
 #
 # is_domain_name.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS
-Returns true if the string passed to this function is a syntactically correct domain name.
-    EOS
-  ) do |arguments|
+  newfunction(:is_domain_name, :type => :rvalue, :doc => <<-DOC
+    Returns true if the string passed to this function is a syntactically correct domain name.
+    DOC
+             ) do |arguments|
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
@@ -18,9 +17,9 @@ Returns true if the string passed to this function is a syntactically correct do
     domain = arguments[0].dup
 
     # Limits (rfc1035, 3.1)
-    domain_max_length=255
-    label_min_length=1
-    label_max_length=63
+    domain_max_length = 255
+    label_min_length = 1
+    label_max_length = 63
 
     # Allow ".", it is the top level domain
     return true if domain == '.'
@@ -34,7 +33,7 @@ Returns true if the string passed to this function is a syntactically correct do
 
     # The top level domain must be alphabetic if there are multiple labels.
     # See rfc1123, 2.1
-    return false if domain.include? '.' and not /\.[A-Za-z]+$/.match(domain)
+    return false if domain.include?('.') && !%r{\.[A-Za-z]+$}.match(domain)
 
     # Check each label in the domain
     labels = domain.split('.')
@@ -43,10 +42,9 @@ Returns true if the string passed to this function is a syntactically correct do
       break if label.length > label_max_length
       break if label[-1..-1] == '-'
       break if label[0..0] == '-'
-      break unless /^[a-z\d-]+$/i.match(label)
+      break unless %r{^[a-z\d-]+$}i =~ label
     end
     return vlabels == labels
-
   end
 end
 
index bcd7921..f656468 100644 (file)
@@ -1,11 +1,10 @@
 #
 # is_email_address.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_email_address, :type => :rvalue, :doc => <<-EOS
-Returns true if the string passed to this function is a valid email address.
-    EOS
+  newfunction(:is_email_address, :type => :rvalue, :doc => <<-DOC
+    Returns true if the string passed to this function is a valid email address.
+    DOC
              ) do |arguments|
     if arguments.size != 1
       raise(Puppet::ParseError, "is_email_address(): Wrong number of arguments given #{arguments.size} for 1")
@@ -13,7 +12,7 @@ Returns true if the string passed to this function is a valid email address.
 
     # Taken from http://emailregex.com/ (simpler regex)
     valid_email_regex = %r{\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z}
-    return (arguments[0] =~ valid_email_regex) == 0
+    return (arguments[0] =~ valid_email_regex) == 0 # rubocop:disable Style/NumericPredicate : Changing to '.zero?' breaks the code
   end
 end
 
index aa84a2b..89994d2 100644 (file)
@@ -1,30 +1,26 @@
 #
 # is_float.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_float, :type => :rvalue, :doc => <<-EOS
-Returns true if the variable passed to this function is a float.
-    EOS
-  ) do |arguments|
+  newfunction(:is_float, :type => :rvalue, :doc => <<-DOC
+    Returns true if the variable passed to this function is a float.
+    DOC
+             ) do |arguments|
 
-    function_deprecation([:is_float, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Float. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_float, 'This method is deprecated, please use the stdlib validate_legacy function,
+                          with Stdlib::Compat::Float. There is further documentation for validate_legacy function in the README.'])
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_float(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     value = arguments[0]
 
     # Only allow Numeric or String types
-    return false unless value.is_a?(Numeric) or value.is_a?(String)
-
-    if value != value.to_f.to_s and !value.is_a? Float then
-      return false
-    else
-      return true
-    end
+    return false unless value.is_a?(Numeric) || value.is_a?(String)
 
+    return false if value != value.to_f.to_s && !value.is_a?(Float)
+    return true
   end
 end
 
index 50cd5e1..e02aa53 100644 (file)
@@ -1,16 +1,15 @@
 #
 # is_function_available.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS
-This function accepts a string as an argument, determines whether the
-Puppet runtime has access to a function by that name.  It returns a
-true if the function exists, false if not.
-    EOS
-  ) do |arguments|
+  newfunction(:is_function_available, :type => :rvalue, :doc => <<-DOC
+    This function accepts a string as an argument, determines whether the
+    Puppet runtime has access to a function by that name.  It returns a
+    true if the function exists, false if not.
+    DOC
+             ) do |arguments|
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
@@ -18,7 +17,7 @@ true if the function exists, false if not.
     return false unless arguments[0].is_a?(String)
 
     function = Puppet::Parser::Functions.function(arguments[0].to_sym)
-    function.is_a?(String) and not function.empty?
+    function.is_a?(String) && !function.empty?
   end
 end
 
index 3162f7d..dc03653 100644 (file)
@@ -1,12 +1,11 @@
 #
 # is_hash.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_hash, :type => :rvalue, :doc => <<-EOS
-Returns true if the variable passed to this function is a hash.
-    EOS
-  ) do |arguments|
+  newfunction(:is_hash, :type => :rvalue, :doc => <<-DOC
+    Returns true if the variable passed to this function is a hash.
+    DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "is_hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
index 8965b15..7444cac 100644 (file)
@@ -1,21 +1,21 @@
 #
 # is_integer.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS
-Returns true if the variable passed to this function is an Integer or
-a decimal (base 10) integer in String form. The string may
-start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not
-be followed by other digits as this indicates that the value is octal (base 8).
+  newfunction(:is_integer, :type => :rvalue, :doc => <<-DOC
+    Returns true if the variable passed to this function is an Integer or
+    a decimal (base 10) integer in String form. The string may
+    start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not
+    be followed by other digits as this indicates that the value is octal (base 8).
 
-If given any other argument `false` is returned.
-    EOS
-  ) do |arguments|
+    If given any other argument `false` is returned.
+    DOC
+             ) do |arguments|
 
-    function_deprecation([:is_integer, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_integer, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.'])
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_integer(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
@@ -35,11 +35,8 @@ If given any other argument `false` is returned.
     # 47291
     numeric = %r{^-?(?:(?:[1-9]\d*)|0)$}
 
-    if value.is_a? Integer or (value.is_a? String and value.match numeric)
-      return true
-    else
-      return false
-    end
+    return true if value.is_a?(Integer) || (value.is_a?(String) && value.match(numeric))
+    return false
   end
 end
 
index 79ddb98..6ce993a 100644 (file)
@@ -1,18 +1,18 @@
 #
 # is_ip_address.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS
-Returns true if the string passed to this function is a valid IP address.
-    EOS
-  ) do |arguments|
+  newfunction(:is_ip_address, :type => :rvalue, :doc => <<-DOC
+    Returns true if the string passed to this function is a valid IP address.
+    DOC
+             ) do |arguments|
 
     require 'ipaddr'
 
-    function_deprecation([:is_ip_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_address. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_ip_address, 'This method is deprecated, please use the stdlib validate_legacy function,
+                           with Stdlib::Compat::Ip_address. There is further documentation for validate_legacy function in the README.'])
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
@@ -22,11 +22,8 @@ Returns true if the string passed to this function is a valid IP address.
       return false
     end
 
-    if ip.ipv4? or ip.ipv6? then
-      return true
-    else
-      return false
-    end
+    return true if ip.ipv4? || ip.ipv6?
+    return false
   end
 end
 
index 91869b6..7f2241b 100644 (file)
@@ -1,18 +1,18 @@
 #
 # is_ipv4_address.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_ipv4_address, :type => :rvalue, :doc => <<-EOS
-Returns true if the string passed to this function is a valid IPv4 address.
-    EOS
-  ) do |arguments|
+  newfunction(:is_ipv4_address, :type => :rvalue, :doc => <<-DOC
+    Returns true if the string passed to this function is a valid IPv4 address.
+    DOC
+             ) do |arguments|
 
     require 'ipaddr'
 
-    function_deprecation([:is_ipv4_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_ipv4_address, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Ipv4. There is further documentation for validate_legacy function in the README.'])
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_ipv4_address(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
index 4d96202..35be026 100644 (file)
@@ -1,18 +1,18 @@
 #
 # is_ipv6_address.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_ipv6_address, :type => :rvalue, :doc => <<-EOS
-Returns true if the string passed to this function is a valid IPv6 address.
-    EOS
-  ) do |arguments|
+  newfunction(:is_ipv6_address, :type => :rvalue, :doc => <<-DOC
+    Returns true if the string passed to this function is a valid IPv6 address.
+    DOC
+             ) do |arguments|
 
-    function_deprecation([:is_ipv6_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_ipv6_address, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Ipv6. There is further documentation for validate_legacy function in the README.'])
 
     require 'ipaddr'
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_ipv6_address(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
index 5993ed2..597c928 100644 (file)
@@ -1,25 +1,21 @@
 #
 # is_mac_address.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS
-Returns true if the string passed to this function is a valid mac address.
-    EOS
-  ) do |arguments|
+  newfunction(:is_mac_address, :type => :rvalue, :doc => <<-DOC
+    Returns true if the string passed to this function is a valid mac address.
+    DOC
+             ) do |arguments|
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     mac = arguments[0]
 
-    if /^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$/i.match(mac) then
-      return true
-    else
-      return false
-    end
-
+    return true if %r{^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$}i =~ mac
+    return true if %r{^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){19}$}i =~ mac
+    return false
   end
 end
 
index 7800edd..e127705 100644 (file)
@@ -1,32 +1,32 @@
 #
 # is_numeric.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS
-Returns true if the given argument is a Numeric (Integer or Float),
-or a String containing either a valid integer in decimal base 10 form, or
-a valid floating point string representation.
+  newfunction(:is_numeric, :type => :rvalue, :doc => <<-DOC
+    Returns true if the given argument is a Numeric (Integer or Float),
+    or a String containing either a valid integer in decimal base 10 form, or
+    a valid floating point string representation.
 
-The function recognizes only decimal (base 10) integers and float but not
-integers in hex (base 16) or octal (base 8) form.
+    The function recognizes only decimal (base 10) integers and float but not
+    integers in hex (base 16) or octal (base 8) form.
 
-The string representation may start with a '-' (minus). If a decimal '.' is used,
-it must be followed by at least one digit.
+    The string representation may start with a '-' (minus). If a decimal '.' is used,
+    it must be followed by at least one digit.
 
-Valid examples:
+    Valid examples:
 
-  77435
-  10e-12
-  -8475
-  0.2343
-  -23.561e3
-    EOS
-  ) do |arguments|
+      77435
+      10e-12
+      -8475
+      0.2343
+      -23.561e3
+    DOC
+             ) do |arguments|
 
-    function_deprecation([:is_numeric, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_numeric, 'This method is deprecated, please use the stdlib validate_legacy function,
+                          with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.'])
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
@@ -41,19 +41,19 @@ Valid examples:
     # if there is no risk to declare them inside of the module
     # Puppet::Parser::Functions
 
-    # TODO decide if this should be used
+    # TODO: decide if this should be used
     # HEX numbers like
     # 0xaa230F
     # 0X1234009C
     # 0x0012
     # -12FcD
-    #numeric_hex = %r{^-?0[xX][0-9A-Fa-f]+$}
+    # numeric_hex = %r{^-?0[xX][0-9A-Fa-f]+$}
 
-    # TODO decide if this should be used
+    # TODO: decide if this should be used
     # OCTAL numbers like
     # 01234567
     # -045372
-    #numeric_oct = %r{^-?0[1-7][0-7]*$}
+    # numeric_oct = %r{^-?0[1-7][0-7]*$}
 
     # Integer/Float numbers like
     # -0.1234568981273
@@ -61,11 +61,11 @@ Valid examples:
     # 42.12345e-12
     numeric = %r{^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$}
 
-    if value.is_a? Numeric or (value.is_a? String and (
-      value.match(numeric) #or
-    #  value.match(numeric_hex) or
-    #  value.match(numeric_oct)
-    ))
+    if value.is_a?(Numeric) || (value.is_a?(String) &&
+      value.match(numeric) # or
+                                 #  value.match(numeric_hex) or
+                                 #  value.match(numeric_oct)
+                               )
       return true
     else
       return false
index 0ed6aec..f7b1b14 100644 (file)
@@ -1,23 +1,23 @@
 #
 # is_string.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:is_string, :type => :rvalue, :doc => <<-EOS
-Returns true if the variable passed to this function is a string.
-    EOS
-  ) do |arguments|
+  newfunction(:is_string, :type => :rvalue, :doc => <<-DOC
+    Returns true if the variable passed to this function is a string.
+    DOC
+             ) do |arguments|
 
-    function_deprecation([:is_string, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:is_string, 'This method is deprecated, please use the stdlib validate_legacy function,
+                          with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.'])
 
-    raise(Puppet::ParseError, "is_string(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "is_string(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     type = arguments[0]
 
     # when called through the v4 API shim, undef gets translated to nil
     result = type.is_a?(String) || type.nil?
 
-    if result and (type == type.to_f.to_s or type == type.to_i.to_s) then
+    if result && (type == type.to_f.to_s || type == type.to_i.to_s)
       return false
     end
 
index 1c17997..d2d7019 100644 (file)
@@ -1,21 +1,23 @@
 #
 # join.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:join, :type => :rvalue, :doc => <<-EOS
-This function joins an array into a string using a separator.
+  newfunction(:join, :type => :rvalue, :doc => <<-DOC
+    This function joins an array into a string using a separator.
+
+    *Examples:*
 
-*Examples:*
+        join(['a','b','c'], ",")
 
-    join(['a','b','c'], ",")
+    Would result in: "a,b,c"
 
-Would result in: "a,b,c"
-    EOS
-  ) do |arguments|
+    Note: from Puppet 5.4.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
     # Technically we support two arguments but only first is mandatory ...
-    raise(Puppet::ParseError, "join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     array = arguments[0]
 
index d8966ba..99876d0 100644 (file)
@@ -1,25 +1,29 @@
 #
-# join.rb
+# join_keys_to_values.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS
-This function joins each key of a hash to that key's corresponding value with a
-separator. Keys are cast to strings. If values are arrays, multiple keys
-are added for each element. The return value is an array in
-which each element is one joined key/value pair.
+  newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-DOC
+    This function joins each key of a hash to that key's corresponding value with a
+    separator. Keys are cast to strings. If values are arrays, multiple keys
+    are added for each element. The return value is an array in
+    which each element is one joined key/value pair.
+
+    *Examples:*
 
-*Examples:*
+        join_keys_to_values({'a'=>1,'b'=>2}, " is ")
 
-    join_keys_to_values({'a'=>1,'b'=>2}, " is ")
+    Would result in: ["a is 1","b is 2"]
 
-Would result in: ["a is 1","b is 2"]
+        join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")
 
-    join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")
+    Would result in: ["a is 1","b is 2","b is 3"]
 
-Would result in: ["a is 1","b is 2","b is 3"]
-    EOS
-  ) do |arguments|
+    Note: Since Puppet 5.0.0 - for more detailed control over the formatting (including indentations and
+    line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual
+    formatting of values in the array) - see the `new` function for `String` and its formatting
+    options for `Array` and `Hash`.
+    DOC
+             ) do |arguments|
 
     # Validate the number of arguments.
     if arguments.size != 2
@@ -28,25 +32,26 @@ Would result in: ["a is 1","b is 2","b is 3"]
 
     # Validate the first argument.
     hash = arguments[0]
-    if not hash.is_a?(Hash)
+    unless hash.is_a?(Hash)
       raise(TypeError, "join_keys_to_values(): The first argument must be a hash, but a #{hash.class} was given.")
     end
 
     # Validate the second argument.
     separator = arguments[1]
-    if not separator.is_a?(String)
+    unless separator.is_a?(String)
       raise(TypeError, "join_keys_to_values(): The second argument must be a string, but a #{separator.class} was given.")
     end
 
     # Join the keys to their values.
-    hash.map do |k,v|
+    hash.map { |k, v|
       if v.is_a?(Array)
         v.map { |va| String(k) + separator + String(va) }
+      elsif String(v) == 'undef'
+        String(k)
       else
         String(k) + separator + String(v)
       end
-    end.flatten
-
+    }.flatten
   end
 end
 
index 199e319..f3663b7 100644 (file)
@@ -1,14 +1,16 @@
 #
 # keys.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:keys, :type => :rvalue, :doc => <<-EOS
-Returns the keys of a hash as an array.
-    EOS
-  ) do |arguments|
+  newfunction(:keys, :type => :rvalue, :doc => <<-DOC
+    Returns the keys of a hash as an array.
+
+    Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     hash = arguments[0]
 
index c9b8488..f9a39de 100644 (file)
@@ -1,22 +1,23 @@
+#
+# load_module_metadata.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:load_module_metadata, :type => :rvalue, :doc => <<-EOT
-  EOT
-  ) do |args|
-    raise(Puppet::ParseError, "load_module_metadata(): Wrong number of arguments, expects one or two") unless [1,2].include?(args.size)
+  newfunction(:load_module_metadata, :type => :rvalue, :doc => <<-DOC
+    This function loads the metadata of a given module.
+  DOC
+             ) do |args|
+    raise(Puppet::ParseError, 'load_module_metadata(): Wrong number of arguments, expects one or two') unless [1, 2].include?(args.size)
     mod = args[0]
     allow_empty_metadata = args[1]
     module_path = function_get_module_path([mod])
     metadata_json = File.join(module_path, 'metadata.json')
 
-    metadata_exists = File.exists?(metadata_json)
+    metadata_exists = File.exists?(metadata_json) # rubocop:disable Lint/DeprecatedClassMethods : Changing to .exist? breaks the code
     if metadata_exists
       metadata = PSON.load(File.read(metadata_json))
     else
-      if allow_empty_metadata
-        metadata = {}
-      else
-        raise(Puppet::ParseError, "load_module_metadata(): No metadata.json file for module #{mod}")
-      end
+      metadata = {}
+      raise(Puppet::ParseError, "load_module_metadata(): No metadata.json file for module #{mod}") unless allow_empty_metadata
     end
 
     return metadata
index 3a3372b..f022bcd 100644 (file)
@@ -1,34 +1,58 @@
+#
+# loadjson.rb
+#
+
 module Puppet::Parser::Functions
-  newfunction(:loadjson, :type => :rvalue, :arity => -2, :doc => <<-'ENDHEREDOC') do |args|
-Load a JSON file containing an array, string, or hash, and return the data
-in the corresponding native data type.
-The second parameter is the default value. It will be returned if the file
-was not found or could not be parsed.
+  newfunction(:loadjson, :type => :rvalue, :arity => -2, :doc => <<-'DOC') do |args|
+    Load a JSON file containing an array, string, or hash, and return the data
+    in the corresponding native data type.
+    The first parameter can be a file path or a URL.
+    The second parameter is the default value. It will be returned if the file
+    was not found or could not be parsed.
 
-For example:
+    For example:
 
-    $myhash = loadjson('/etc/puppet/data/myhash.json')
-    $myhash = loadjson('no-file.json', {'default' => 'value'})
-  ENDHEREDOC
+        $myhash = loadjson('/etc/puppet/data/myhash.json')
+        $myhash = loadjson('https://example.local/my_hash.json')
+        $myhash = loadjson('https://username:password@example.local/my_hash.json')
+        $myhash = loadjson('no-file.json', {'default' => 'value'})
+  DOC
 
     raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1
-
-    if File.exists?(args[0])
-      begin
-        content = File.read(args[0])
-        PSON::load(content) || args[1]
-      rescue Exception => e
-        if args[1]
-          args[1]
+    require 'open-uri'
+    begin
+      if args[0].start_with?('http://', 'https://')
+        username = ''
+        password = ''
+        if (match = args[0].match(%r{(http\://|https\://)(.*):(.*)@(.*)}))
+          # If URL is in the format of https://username:password@example.local/my_hash.yaml
+          protocol, username, password, path = match.captures
+          url = "#{protocol}#{path}"
+        elsif (match = args[0].match(%r{(http\:\/\/|https\:\/\/)(.*)@(.*)}))
+          # If URL is in the format of https://username@example.local/my_hash.yaml
+          protocol, username, path = match.captures
+          url = "#{protocol}#{path}"
         else
-          raise e
+          url = args[0]
         end
+        begin
+          contents = OpenURI.open_uri(url, :http_basic_authentication => [username, password])
+        rescue OpenURI::HTTPError => err
+          res = err.io
+          warning("Can't load '#{url}' HTTP Error Code: '#{res.status[0]}'")
+          args[1]
+        end
+        PSON.load(contents) || args[1]
+      elsif File.exists?(args[0]) # rubocop:disable Lint/DeprecatedClassMethods : Changing to .exist? breaks the code
+        content = File.read(args[0])
+        PSON.load(content) || args[1]
+      else
+        warning("Can't load '#{args[0]}' File does not exist!")
+        args[1]
       end
-    else
-      warning("Can't load '#{args[0]}' File does not exist!")
+    rescue StandardError => e
+      raise e unless args[1]
       args[1]
     end
-
   end
-
 end
index 9696362..a49ae2c 100644 (file)
@@ -1,34 +1,57 @@
+#
+# loadyaml.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:loadyaml, :type => :rvalue, :arity => -2, :doc => <<-'ENDHEREDOC') do |args|
-Load a YAML file containing an array, string, or hash, and return the data
-in the corresponding native data type.
-The second parameter is the default value. It will be returned if the file
-was not found or could not be parsed.
+  newfunction(:loadyaml, :type => :rvalue, :arity => -2, :doc => <<-'DOC') do |args|
+    Load a YAML file containing an array, string, or hash, and return the data
+    in the corresponding native data type.
+    The first parameter can be a file path or a URL.
+    The second parameter is the default value. It will be returned if the file
+    was not found or could not be parsed.
 
-For example:
+    For example:
 
-    $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
-    $myhash = loadyaml('no-file.yaml', {'default' => 'value'})
-  ENDHEREDOC
+        $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
+        $myhash = loadyaml('https://example.local/my_hash.yaml')
+        $myhash = loadyaml('https://username:password@example.local/my_hash.yaml')
+        $myhash = loadyaml('no-file.yaml', {'default' => 'value'})
+  DOC
 
     raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1
     require 'yaml'
-
-    if File.exists?(args[0])
-      begin
-        YAML::load_file(args[0]) || args[1]
-      rescue Exception => e
-        if args[1]
-          args[1]
+    require 'open-uri'
+    begin
+      if args[0].start_with?('http://', 'https://')
+        username = ''
+        password = ''
+        if (match = args[0].match(%r{(http\://|https\://)(.*):(.*)@(.*)}))
+          # If URL is in the format of https://username:password@example.local/my_hash.yaml
+          protocol, username, password, path = match.captures
+          url = "#{protocol}#{path}"
+        elsif (match = args[0].match(%r{(http\:\/\/|https\:\/\/)(.*)@(.*)}))
+          # If URL is in the format of https://username@example.local/my_hash.yaml
+          protocol, username, path = match.captures
+          url = "#{protocol}#{path}"
         else
-          raise e
+          url = args[0]
+        end
+        begin
+          contents = OpenURI.open_uri(url, :http_basic_authentication => [username, password])
+        rescue OpenURI::HTTPError => err
+          res = err.io
+          warning("Can't load '#{url}' HTTP Error Code: '#{res.status[0]}'")
+          args[1]
         end
+        YAML.safe_load(contents) || args[1]
+      elsif File.exists?(args[0]) # rubocop:disable Lint/DeprecatedClassMethods : Changing to .exist? breaks the code
+        YAML.load_file(args[0]) || args[1]
+      else
+        warning("Can't load '#{args[0]}' File does not exist!")
+        args[1]
       end
-    else
-      warning("Can't load '#{args[0]}' File does not exist!")
+    rescue StandardError => e
+      raise e unless args[1]
       args[1]
     end
-
   end
-
 end
index 9a9ee29..99874e4 100644 (file)
@@ -1,14 +1,16 @@
 #
 #  lstrip.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS
-Strips leading spaces to the left of a string.
-    EOS
-  ) do |arguments|
+  newfunction(:lstrip, :type => :rvalue, :doc => <<-DOC
+    Strips leading spaces to the left of a string.
+
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "lstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "lstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -16,12 +18,12 @@ Strips leading spaces to the left of a string.
       raise(Puppet::ParseError, 'lstrip(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? i.lstrip : i }
-    else
-      result = value.lstrip
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? i.lstrip : i }
+             else
+               value.lstrip
+             end
 
     return result
   end
index 758c42c..4715dcd 100644 (file)
@@ -1,16 +1,22 @@
+#
+# max.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:max, :type => :rvalue, :doc => <<-EOS
+  newfunction(:max, :type => :rvalue, :doc => <<-DOC
     Returns the highest value of all arguments.
     Requires at least one argument.
-    EOS
-  ) do |args|
 
-    raise(Puppet::ParseError, "max(): Wrong number of arguments need at least one") if args.size == 0
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |args|
+
+    raise(Puppet::ParseError, 'max(): Wrong number of arguments need at least one') if args.empty?
 
     # Sometimes we get numbers as numerics and sometimes as strings.
     # We try to compare them as numbers when possible
-    return args.max do |a,b|
-      if a.to_s =~ /\A-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then
+    return args.max do |a, b|
+      if a.to_s =~ %r{\A-?\d+(.\d+)?\z} && b.to_s =~ %r{\A-?\d+(.\d+)?\z}
         a.to_f <=> b.to_f
       else
         a.to_s <=> b.to_s
index fb93452..8154f3b 100644 (file)
@@ -1,34 +1,45 @@
+# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
+# TODO(Krzysztof Wilczynski): Support for strings and hashes too ...
 #
 # member.rb
 #
+module Puppet::Parser::Functions
+  newfunction(:member, :type => :rvalue, :doc => <<-DOC
+    This function determines if a variable is a member of an array.
+    The variable can be a string, fixnum, or array.
 
-# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
-# TODO(Krzysztof Wilczynski): Support for strings and hashes too ...
+    *Examples:*
 
-module Puppet::Parser::Functions
-  newfunction(:member, :type => :rvalue, :doc => <<-EOS
-This function determines if a variable is a member of an array.
-The variable can be a string, fixnum, or array.
+        member(['a','b'], 'b')
 
-*Examples:*
+    Would return: true
 
-    member(['a','b'], 'b')
+        member(['a', 'b', 'c'], ['a', 'b'])
 
-Would return: true
+    would return: true
 
-    member(['a', 'b', 'c'], ['a', 'b'])
+        member(['a','b'], 'c')
 
-would return: true
+    Would return: false
 
-    member(['a','b'], 'c')
+        member(['a', 'b', 'c'], ['d', 'b'])
 
-Would return: false
+    would return: false
 
-    member(['a', 'b', 'c'], ['d', 'b'])
+    Note: Since Puppet 4.0.0 the same can be performed in the Puppet language. For single values
+    the operator `in` can be used:
 
-would return: false
-    EOS
-  ) do |arguments|
+        'a' in ['a', 'b']  # true
+
+    And for arrays by using operator `-` to compute a diff:
+
+        ['d', 'b'] - ['a', 'b', 'c'] == []  # false because 'd' is not subtracted
+        ['a', 'b'] - ['a', 'b', 'c'] == []  # true because both 'a' and 'b' are subtracted
+
+    Also note that since Puppet 5.2.0 the general form of testing content of an array or hash is to use the built-in
+    `any` and `all` functions.
+    DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "member(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
 
@@ -38,16 +49,15 @@ would return: false
       raise(Puppet::ParseError, 'member(): Requires array to work with')
     end
 
-    unless arguments[1].is_a? String or arguments[1].is_a? Fixnum or arguments[1].is_a? Array
+    unless arguments[1].is_a?(String) || arguments[1].is_a?(Integer) || arguments[1].is_a?(Array)
       raise(Puppet::ParseError, 'member(): Item to search for must be a string, fixnum, or array')
     end
 
-    if arguments[1].is_a? String or arguments[1].is_a? Fixnum
-      item = [arguments[1]]
-    else
-      item = arguments[1]
-    end
-
+    item = if arguments[1].is_a?(String) || arguments[1].is_a?(Integer)
+             [arguments[1]]
+           else
+             arguments[1]
+           end
 
     raise(Puppet::ParseError, 'member(): You must provide item to search for within array given') if item.respond_to?('empty?') && item.empty?
 
index 1b39f20..1ca8257 100644 (file)
@@ -1,5 +1,8 @@
+#
+# merge.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:merge, :type => :rvalue, :doc => <<-'DOC') do |args|
     Merges two or more hashes together and returns the resulting hash.
 
     For example:
@@ -12,17 +15,20 @@ module Puppet::Parser::Functions
 
     When there is a duplicate key, the key in the rightmost hash will "win."
 
-    ENDHEREDOC
+    Note that since Puppet 4.0.0 the same merge can be achieved with the + operator.
+
+        $merged_hash = $hash1 + $hash2
+    DOC
 
     if args.length < 2
-      raise Puppet::ParseError, ("merge(): wrong number of arguments (#{args.length}; must be at least 2)")
+      raise Puppet::ParseError, "merge(): wrong number of arguments (#{args.length}; must be at least 2)"
     end
 
     # The hash we accumulate into
-    accumulator = Hash.new
+    accumulator = {}
     # Merge into the accumulator hash
     args.each do |arg|
-      next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
+      next if arg.is_a?(String) && arg.empty? # empty string is synonym for puppet's undef
       unless arg.is_a?(Hash)
         raise Puppet::ParseError, "merge: unexpected argument type #{arg.class}, only expects hash arguments"
       end
index f10a2b2..ed4be5b 100644 (file)
@@ -1,16 +1,22 @@
+#
+# min.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:min, :type => :rvalue, :doc => <<-EOS
+  newfunction(:min, :type => :rvalue, :doc => <<-DOC
     Returns the lowest value of all arguments.
     Requires at least one argument.
-    EOS
-  ) do |args|
 
-    raise(Puppet::ParseError, "min(): Wrong number of arguments need at least one") if args.size == 0
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |args|
+
+    raise(Puppet::ParseError, 'min(): Wrong number of arguments need at least one') if args.empty?
 
     # Sometimes we get numbers as numerics and sometimes as strings.
     # We try to compare them as numbers when possible
-    return args.min do |a,b|
-      if a.to_s =~ /\A^-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then
+    return args.min do |a, b|
+      if a.to_s =~ %r{\A^-?\d+(.\d+)?\z} && b.to_s =~ %r{\A-?\d+(.\d+)?\z}
         a.to_f <=> b.to_f
       else
         a.to_s <=> b.to_s
index 9ad59b2..5e0f494 100644 (file)
@@ -1,21 +1,26 @@
 #
 # num2bool.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS
-This function converts a number or a string representation of a number into a
-true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0
-become true.
-    EOS
-  ) do |arguments|
+  newfunction(:num2bool, :type => :rvalue, :doc => <<-DOC
+    This function converts a number or a string representation of a number into a
+    true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0
+    become true.
+
+    Note that since Puppet 5.0.0 the same can be achieved with the Puppet Type System.
+    See the new() function in Puppet for the many available type conversions.
+
+        Boolean(0) # false
+        Boolean(1) # true
+    DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "num2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     number = arguments[0]
 
     case number
-    when Numeric
+    when Numeric # rubocop:disable Lint/EmptyWhen : Required for the module to work
       # Yay, it's a number
     when String
       begin
index f7c2896..4cc43e6 100644 (file)
@@ -1,28 +1,23 @@
 #
 # parsejson.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS
-This function accepts JSON as a string and converts it into the correct
-Puppet structure.
+  newfunction(:parsejson, :type => :rvalue, :doc => <<-DOC
+    This function accepts JSON as a string and converts it into the correct
+    Puppet structure.
 
-The optional second argument can be used to pass a default value that will
-be returned if the parsing of YAML string have failed.
-  EOS
-  ) do |arguments|
+    The optional second argument can be used to pass a default value that will
+    be returned if the parsing of YAML string have failed.
+  DOC
+             ) do |arguments|
     raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1
 
     begin
-      PSON::load(arguments[0]) || arguments[1]
+      PSON.load(arguments[0]) || arguments[1]
     rescue StandardError => e
-      if arguments[1]
-        arguments[1]
-      else
-        raise e
-      end
+      raise e unless arguments[1]
+      arguments[1]
     end
-
   end
 end
 
index ba9d98a..7f857ca 100644 (file)
@@ -1,32 +1,27 @@
 #
 # parseyaml.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS
-This function accepts YAML as a string and converts it into the correct
-Puppet structure.
+  newfunction(:parseyaml, :type => :rvalue, :doc => <<-DOC
+    This function accepts YAML as a string and converts it into the correct
+    Puppet structure.
 
-The optional second argument can be used to pass a default value that will
-be returned if the parsing of YAML string have failed.
-  EOS
-  ) do |arguments|
+    The optional second argument can be used to pass a default value that will
+    be returned if the parsing of YAML string have failed.
+  DOC
+             ) do |arguments|
     raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1
     require 'yaml'
 
     begin
-      YAML::load(arguments[0]) || arguments[1]
+      YAML.load(arguments[0]) || arguments[1] # rubocop:disable Security/YAMLLoad : using YAML.safe_load causes the code to break
       # in ruby 1.9.3 Psych::SyntaxError is a RuntimeException
       # this still needs to catch that and work also on rubies that
       # do not have Psych available.
-    rescue StandardError, Psych::SyntaxError => e
-      if arguments[1]
-        arguments[1]
-      else
-        raise e
-      end
+    rescue StandardError, Psych::SyntaxError => e # rubocop:disable Lint/ShadowedException : See above
+      raise e unless arguments[1]
+      arguments[1]
     end
-
   end
 end
 
index fdd0aef..38ce5cd 100644 (file)
@@ -1,29 +1,26 @@
+#
+# pick.rb
+#
 module Puppet::Parser::Functions
- newfunction(:pick, :type => :rvalue, :doc => <<-EOS
+  newfunction(:pick, :type => :rvalue, :doc => <<-DOC
+    This function is similar to a coalesce function in SQL in that it will return
+    the first value in a list of values that is not undefined or an empty string.
+    Typically, this function is used to check for a value in the Puppet
+    Dashboard/Enterprise Console, and failover to a default value like the following:
 
-This function is similar to a coalesce function in SQL in that it will return
-the first value in a list of values that is not undefined or an empty string
-(two things in Puppet that will return a boolean false value). Typically,
-this function is used to check for a value in the Puppet Dashboard/Enterprise
-Console, and failover to a default value like the following:
+      $real_jenkins_version = pick($::jenkins_version, '1.449')
 
-  $real_jenkins_version = pick($::jenkins_version, '1.449')
-
-The value of $real_jenkins_version will first look for a top-scope variable
-called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
-Enterprise Console are brought into Puppet as top-scope variables), and,
-failing that, will use a default value of 1.449.
-
-EOS
-) do |args|
-   args = args.compact
-   args.delete(:undef)
-   args.delete(:undefined)
-   args.delete("")
-   if args[0].to_s.empty? then
-     fail Puppet::ParseError, "pick(): must receive at least one non empty value"
-   else
-     return args[0]
-   end
- end
+    The value of $real_jenkins_version will first look for a top-scope variable
+    called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
+    Enterprise Console are brought into Puppet as top-scope variables), and,
+    failing that, will use a default value of 1.449.
+DOC
+             ) do |args|
+    args = args.compact
+    args.delete(:undef)
+    args.delete(:undefined)
+    args.delete('')
+    raise Puppet::ParseError, 'pick(): must receive at least one non empty value' if args[0].to_s.empty?
+    return args[0]
+  end
 end
index 36e33ab..0d499fb 100644 (file)
@@ -1,35 +1,35 @@
+#
+# pick_default.rb
+#
 module Puppet::Parser::Functions
- newfunction(:pick_default, :type => :rvalue, :doc => <<-EOS
+  newfunction(:pick_default, :type => :rvalue, :doc => <<-DOC
+    This function is similar to a coalesce function in SQL in that it will return
+    the first value in a list of values that is not undefined or an empty string
+    If no value is found, it will return the last argument.
 
-This function is similar to a coalesce function in SQL in that it will return
-the first value in a list of values that is not undefined or an empty string
-(two things in Puppet that will return a boolean false value). If no value is
-found, it will return the last argument.
+    Typically, this function is used to check for a value in the Puppet
+    Dashboard/Enterprise Console, and failover to a default value like the
+    following:
 
-Typically, this function is used to check for a value in the Puppet
-Dashboard/Enterprise Console, and failover to a default value like the
-following:
+      $real_jenkins_version = pick_default($::jenkins_version, '1.449')
 
-  $real_jenkins_version = pick_default($::jenkins_version, '1.449')
+    The value of $real_jenkins_version will first look for a top-scope variable
+    called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
+    Enterprise Console are brought into Puppet as top-scope variables), and,
+    failing that, will use a default value of 1.449.
 
-The value of $real_jenkins_version will first look for a top-scope variable
-called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
-Enterprise Console are brought into Puppet as top-scope variables), and,
-failing that, will use a default value of 1.449.
-
-Note that, contrary to the pick() function, the pick_default does not fail if
-all arguments are empty. This allows pick_default to use an empty value as
-default.
-
-EOS
-) do |args|
-   fail "Must receive at least one argument." if args.empty?
-   default = args.last
-   args = args[0..-2].compact
-   args.delete(:undef)
-   args.delete(:undefined)
-   args.delete("")
-   args << default
-   return args[0]
- end
+    Note that, contrary to the pick() function, the pick_default does not fail if
+    all arguments are empty. This allows pick_default to use an empty value as
+    default.
+DOC
+             ) do |args|
+    raise 'Must receive at least one argument.' if args.empty?
+    default = args.last
+    args = args[0..-2].compact
+    args.delete(:undef)
+    args.delete(:undefined)
+    args.delete('')
+    args << default
+    return args[0]
+  end
 end
index b1c1e35..f1e1234 100644 (file)
@@ -1,25 +1,29 @@
 #
 # prefix.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:prefix, :type => :rvalue, :doc => <<-EOS
-This function applies a prefix to all elements in an array or a hash.
+  newfunction(:prefix, :type => :rvalue, :doc => <<-DOC
+    This function applies a prefix to all elements in an array or a hash.
+
+    *Examples:*
+
+        prefix(['a','b','c'], 'p')
 
-*Examples:*
+    Will return: ['pa','pb','pc']
 
-    prefix(['a','b','c'], 'p')
+    Note that since Puppet 4.0.0 the general way to modify values is in array is by using the map
+    function in Puppet. This example does the same as the example above:
 
-Will return: ['pa','pb','pc']
-    EOS
-  ) do |arguments|
+        ['a', 'b', 'c'].map |$x| { "p${x}" }
+    DOC
+             ) do |arguments|
 
     # Technically we support two arguments but only first is mandatory ...
-    raise(Puppet::ParseError, "prefix(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "prefix(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     enumerable = arguments[0]
 
-    unless enumerable.is_a?(Array) or enumerable.is_a?(Hash)
+    unless enumerable.is_a?(Array) || enumerable.is_a?(Hash)
       raise Puppet::ParseError, "prefix(): expected first argument to be an Array or a Hash, got #{enumerable.inspect}"
     end
 
@@ -31,18 +35,18 @@ Will return: ['pa','pb','pc']
       end
     end
 
-    if enumerable.is_a?(Array)
-      # Turn everything into string same as join would do ...
-      result = enumerable.collect do |i|
-        i = i.to_s
-        prefix ? prefix + i : i
-      end
-    else
-      result = Hash[enumerable.map do |k,v|
-        k = k.to_s
-        [ prefix ? prefix + k : k, v ]
-      end]
-    end
+    result = if enumerable.is_a?(Array)
+               # Turn everything into string same as join would do ...
+               enumerable.map do |i|
+                 i = i.to_s
+                 prefix ? prefix + i : i
+               end
+             else
+               Hash[enumerable.map do |k, v|
+                 k = k.to_s
+                 [prefix ? prefix + k : k, v]
+               end]
+             end
 
     return result
   end
index 3b00ba1..5e0b7c5 100644 (file)
@@ -1,17 +1,16 @@
 #
 # private.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:private, :doc => <<-'EOS'
+  newfunction(:private, :doc => <<-'DOC'
     DEPRECATED: Sets the current class or definition as private.
     Calling the class or definition from outside the current module will fail.
-  EOS
-  ) do |args|
-    warning("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
-    if !Puppet::Parser::Functions.autoloader.loaded?(:assert_private)
+  DOC
+             ) do |args|
+    warning("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : Cannot shorten this line
+    unless Puppet::Parser::Functions.autoloader.loaded?(:assert_private)
       Puppet::Parser::Functions.autoloader.load(:assert_private)
     end
-    function_assert_private([(args[0] unless args.size < 1)])
+    function_assert_private([(args[0] unless args.empty?)])
   end
 end
index c18ef7e..17b3bc7 100644 (file)
@@ -1,16 +1,15 @@
 #
 # pry.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:pry, :type => :statement, :doc => <<-EOS
-This function invokes a pry debugging session in the current scope object. This is useful for debugging manifest code at specific points during a compilation.
+  newfunction(:pry, :type => :statement, :doc => <<-DOC
+    This function invokes a pry debugging session in the current scope object. This is useful for debugging manifest code at specific points during a compilation.
 
-*Examples:*
+    *Examples:*
 
-    pry()
-    EOS
-  ) do |arguments|
+        pry()
+    DOC
+             ) do |arguments|
     begin
       require 'pry'
     rescue LoadError
index 0deeb3a..eaf1d74 100644 (file)
@@ -1,7 +1,5 @@
-
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
-
-Puppet::Parser::Functions::newfunction(
+Puppet::Parser::Functions.newfunction(
   :pw_hash,
   :type => :rvalue,
   :arity => 3,
@@ -25,42 +23,40 @@ Puppet::Parser::Functions::newfunction(
 
   Note: this uses the Puppet Master's implementation of crypt(3). If your
   environment contains several different operating systems, ensure that they
-  are compatible before using this function.") do |args|
-    raise ArgumentError, "pw_hash(): wrong number of arguments (#{args.size} for 3)" if args.size != 3
-    args.map! do |arg|
-      if arg.is_a? Puppet::Pops::Types::PSensitiveType::Sensitive
-        arg.unwrap
-      else
-        arg
-      end
-    end
-    raise ArgumentError, "pw_hash(): first argument must be a string" unless args[0].is_a? String or args[0].nil?
-    raise ArgumentError, "pw_hash(): second argument must be a string" unless args[1].is_a? String
-    hashes = { 'md5'     => '1',
-               'sha-256' => '5',
-               'sha-512' => '6' }
-    hash_type = hashes[args[1].downcase]
-    raise ArgumentError, "pw_hash(): #{args[1]} is not a valid hash type" if hash_type.nil?
-    raise ArgumentError, "pw_hash(): third argument must be a string" unless args[2].is_a? String
-    raise ArgumentError, "pw_hash(): third argument must not be empty" if args[2].empty?
-    raise ArgumentError, "pw_hash(): characters in salt must be in the set [a-zA-Z0-9./]" unless args[2].match(/\A[a-zA-Z0-9.\/]+\z/)
-
-    password = args[0]
-    return nil if password.nil? or password.empty?
-
-    salt = "$#{hash_type}$#{args[2]}"
-
-    # handle weak implementations of String#crypt
-    if 'test'.crypt('$1$1') != '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
-      # JRuby < 1.7.17
-      if RUBY_PLATFORM == 'java'
-        # puppetserver bundles Apache Commons Codec
-        org.apache.commons.codec.digest.Crypt.crypt(password.to_java_bytes, salt)
-      else
-        # MS Windows and other systems that don't support enhanced salts
-        raise Puppet::ParseError, 'system does not support enhanced salts'
-      end
+  are compatible before using this function.",
+) do |args|
+  raise ArgumentError, "pw_hash(): wrong number of arguments (#{args.size} for 3)" if args.size != 3
+  args.map! do |arg|
+    if (defined? Puppet::Pops::Types::PSensitiveType::Sensitive) && (arg.is_a? Puppet::Pops::Types::PSensitiveType::Sensitive)
+      arg.unwrap
     else
-      password.crypt(salt)
+      arg
     end
+  end
+  raise ArgumentError, 'pw_hash(): first argument must be a string' unless args[0].is_a?(String) || args[0].nil?
+  raise ArgumentError, 'pw_hash(): second argument must be a string' unless args[1].is_a? String
+  hashes = { 'md5'     => '1',
+             'sha-256' => '5',
+             'sha-512' => '6' }
+  hash_type = hashes[args[1].downcase]
+  raise ArgumentError, "pw_hash(): #{args[1]} is not a valid hash type" if hash_type.nil?
+  raise ArgumentError, 'pw_hash(): third argument must be a string' unless args[2].is_a? String
+  raise ArgumentError, 'pw_hash(): third argument must not be empty' if args[2].empty?
+  raise ArgumentError, 'pw_hash(): characters in salt must be in the set [a-zA-Z0-9./]' unless args[2] =~ %r{\A[a-zA-Z0-9./]+\z}
+
+  password = args[0]
+  return nil if password.nil? || password.empty?
+
+  salt = "$#{hash_type}$#{args[2]}"
+
+  # handle weak implementations of String#crypt
+  if 'test'.crypt('$1$1') != '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
+    # JRuby < 1.7.17
+    # MS Windows and other systems that don't support enhanced salts
+    raise Puppet::ParseError, 'system does not support enhanced salts' unless RUBY_PLATFORM == 'java'
+    # puppetserver bundles Apache Commons Codec
+    org.apache.commons.codec.digest.Crypt.crypt(password.to_java_bytes, salt)
+  else
+    password.crypt(salt)
+  end
 end
index 72c373a..31baee5 100644 (file)
@@ -1,43 +1,46 @@
 #
 # range.rb
 #
-
 # TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ...
-
 module Puppet::Parser::Functions
-  newfunction(:range, :type => :rvalue, :doc => <<-EOS
-When given range in the form of (start, stop) it will extrapolate a range as
-an array.
+  newfunction(:range, :type => :rvalue, :doc => <<-DOC
+    When given range in the form of (start, stop) it will extrapolate a range as
+    an array.
+
+    *Examples:*
 
-*Examples:*
+        range("0", "9")
 
-    range("0", "9")
+    Will return: [0,1,2,3,4,5,6,7,8,9]
 
-Will return: [0,1,2,3,4,5,6,7,8,9]
+        range("00", "09")
 
-    range("00", "09")
+    Will return: [0,1,2,3,4,5,6,7,8,9] (Zero padded strings are converted to
+    integers automatically)
 
-Will return: [0,1,2,3,4,5,6,7,8,9] (Zero padded strings are converted to
-integers automatically)
+        range("a", "c")
 
-    range("a", "c")
+    Will return: ["a","b","c"]
 
-Will return: ["a","b","c"]
+        range("host01", "host10")
+    Will return: ["host01", "host02", ..., "host09", "host10"]
+    NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail.
 
-    range("host01", "host10")
-Will return: ["host01", "host02", ..., "host09", "host10"]
-NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail.
+    Passing a third argument will cause the generated range to step by that
+    interval, e.g.
 
-Passing a third argument will cause the generated range to step by that
-interval, e.g.
+        range("0", "9", "2")
 
-    range("0", "9", "2")
+    Will return: [0,2,4,6,8]
 
-Will return: [0,2,4,6,8]
-    EOS
-  ) do |arguments|
+    The Puppet Language support Integer and Float ranges by using the type system. Those are suitable for
+    iterating a given number of times. Also see the step() function in Puppet for skipping values.
 
-    raise(Puppet::ParseError, 'range(): Wrong number of arguments given (0 for 1)') if arguments.size == 0
+        Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9
+    DOC
+             ) do |arguments|
+
+    raise(Puppet::ParseError, 'range(): Wrong number of arguments given (0 for 1)') if arguments.empty?
 
     if arguments.size > 1
       start = arguments[0]
@@ -49,13 +52,14 @@ Will return: [0,2,4,6,8]
     else # arguments.size == 1
       value = arguments[0]
 
-      if m = value.match(/^(\w+)(\.\.\.?|\-)(\w+)$/)
+      m = value.match(%r{^(\w+)(\.\.\.?|\-)(\w+)$})
+      if m
         start = m[1]
         stop  = m[3]
 
         type = m[2]
         step = 1
-      elsif value.match(/^.+$/)
+      elsif value =~ %r{^.+$}
         raise(Puppet::ParseError, "range(): Unable to compute range from the value: #{value}")
       else
         raise(Puppet::ParseError, "range(): Unknown range format: #{value}")
@@ -63,7 +67,7 @@ Will return: [0,2,4,6,8]
     end
 
     # If we were given an integer, ensure we work with one
-    if start.to_s.match(/^\d+$/)
+    if start.to_s =~ %r{^\d+$}
       start = start.to_i
       stop  = stop.to_i
     else
@@ -72,9 +76,9 @@ Will return: [0,2,4,6,8]
     end
 
     range = case type
-      when /^(\.\.|\-)$/ then (start .. stop)
-      when '...'         then (start ... stop) # Exclusive of last element
-    end
+            when %r{^(..|-)$} then (start..stop)
+            when '...' then (start...stop) # Exclusive of last element
+            end
 
     result = range.step(step).to_a
 
index 2cfa3bb..647d865 100644 (file)
@@ -2,11 +2,11 @@
 #  regexpescape.rb
 #
 module Puppet::Parser::Functions
-  newfunction(:regexpescape, :type => :rvalue, :doc => <<-EOS
+  newfunction(:regexpescape, :type => :rvalue, :doc => <<-DOC
     Regexp escape a string or array of strings.
     Requires either a single string or an array as an input.
-    EOS
-  ) do |arguments| # rubocop:disable Style/ClosingParenthesisIndentation
+    DOC
+  ) do |arguments| # rubocop:disable Layout/ClosingParenthesisIndentation
     raise(Puppet::ParseError, "regexpescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
@@ -17,7 +17,7 @@ module Puppet::Parser::Functions
 
     result = if value.is_a?(Array)
                # Numbers in Puppet are often string-encoded which is troublesome ...
-               value.collect { |i| i.is_a?(String) ? Regexp.escape(i) : i }
+               value.map { |i| i.is_a?(String) ? Regexp.escape(i) : i }
              else
                Regexp.escape(value)
              end
index 1953ffc..392f62e 100644 (file)
@@ -1,24 +1,28 @@
 #
 # reject.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args|
-This function searches through an array and rejects all elements that match
-the provided regular expression.
+  newfunction(:reject, :type => :rvalue, :doc => <<-DOC) do |args|
+    This function searches through an array and rejects all elements that match
+    the provided regular expression.
+
+    *Examples:*
+
+        reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
 
-*Examples:*
+    Would return:
 
-    reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
+        ['bbb','ccc']
 
-Would return:
+    Note that since Puppet 4.0.0 the same is in general done with the filter function. Here is the
+    equivalence of the reject() function:
 
-    ['bbb','ccc']
-EOS
+        ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ /aaa/ }
+DOC
 
-    if (args.size != 2)
+    if args.size != 2
       raise Puppet::ParseError,
-        "reject(): Wrong number of arguments given #{args.size} for 2"
+            "reject(): Wrong number of arguments given #{args.size} for 2"
     end
 
     ary = args[0]
index aca98ce..9f7db8b 100644 (file)
@@ -1,14 +1,15 @@
 #
 # reverse.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:reverse, :type => :rvalue, :doc => <<-EOS
-Reverses the order of a string or array.
-    EOS
-  ) do |arguments|
+  newfunction(:reverse, :type => :rvalue, :doc => <<-DOC
+    Reverses the order of a string or array.
+
+    Note that the same can be done with the reverse_each() function in Puppet.
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "reverse(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "reverse(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
index 489c301..aaef51a 100644 (file)
@@ -1,23 +1,24 @@
 #
 # round.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:round, :type => :rvalue, :doc => <<-EOS
-  Rounds a number to the nearest integer
+  newfunction(:round, :type => :rvalue, :doc => <<-DOC
+    Rounds a number to the nearest integer
 
-  *Examples:*
+    *Examples:*
 
-  round(2.9)
+    round(2.9)
 
-  returns: 3
+    returns: 3
 
-  round(2.4)
+    round(2.4)
 
-  returns: 2
+    returns: 2
 
-  EOS
-  ) do |args|
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+  DOC
+             ) do |args|
 
     raise Puppet::ParseError, "round(): Wrong number of arguments given #{args.size} for 1" if args.size != 1
     raise Puppet::ParseError, "round(): Expected a Numeric, got #{args[0].class}" unless args[0].is_a? Numeric
index e24abd5..e2cee40 100644 (file)
@@ -1,14 +1,16 @@
 #
 #  rstrip.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS
-Strips leading spaces to the right of the string.
-    EOS
-  ) do |arguments|
+  newfunction(:rstrip, :type => :rvalue, :doc => <<-DOC
+    Strips leading spaces to the right of the string.
+
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "rstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "rstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -16,11 +18,11 @@ Strips leading spaces to the right of the string.
       raise(Puppet::ParseError, 'rstrip(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      result = value.collect { |i| i.is_a?(String) ? i.rstrip : i }
-    else
-      result = value.rstrip
-    end
+    result = if value.is_a?(Array)
+               value.map { |i| i.is_a?(String) ? i.rstrip : i }
+             else
+               value.rstrip
+             end
 
     return result
   end
index 44e27b8..0120b87 100644 (file)
@@ -1,22 +1,24 @@
-Puppet::Parser::Functions::newfunction(
+#
+# seeded_rand.rb
+#
+Puppet::Parser::Functions.newfunction(
   :seeded_rand,
   :arity => 2,
   :type => :rvalue,
-  :doc => <<-EOS
-Usage: `seeded_rand(MAX, SEED)`. MAX must be a positive integer; SEED is any string.
+  :doc => <<-DOC
+    Usage: `seeded_rand(MAX, SEED)`. MAX must be a positive integer; SEED is any string.
 
-Generates a random whole number greater than or equal to 0 and less
-than MAX, using the value of SEED for repeatable randomness.  If SEED
-starts with "$fqdn:", this is behaves the same as `fqdn_rand`.
-
-EOS
+    Generates a random whole number greater than or equal to 0 and less
+    than MAX, using the value of SEED for repeatable randomness.  If SEED
+    starts with "$fqdn:", this is behaves the same as `fqdn_rand`.
+DOC
 ) do |args|
   require 'digest/md5'
 
-  raise(ArgumentError, "seeded_rand(): first argument must be a positive integer") unless function_is_integer([args[0]]) and args[0].to_i > 0
-  raise(ArgumentError, "seeded_rand(): second argument must be a string") unless args[1].is_a? String
+  raise(ArgumentError, 'seeded_rand(): first argument must be a positive integer') unless function_is_integer([args[0]]) && args[0].to_i > 0
+  raise(ArgumentError, 'seeded_rand(): second argument must be a string') unless args[1].is_a? String
 
   max = args[0].to_i
   seed = Digest::MD5.hexdigest(args[1]).hex
-  Puppet::Util.deterministic_rand(seed,max)
+  Puppet::Util.deterministic_rand(seed, max)
 end
index 7306b7c..96fea20 100644 (file)
@@ -1,19 +1,17 @@
+require 'shellwords'
 #
 # shell_escape.rb
 #
-
-require 'shellwords'
-
 module Puppet::Parser::Functions
-  newfunction(:shell_escape, :type => :rvalue, :doc => <<-EOS
-Escapes a string so that it can be safely used in a Bourne shell command line.
+  newfunction(:shell_escape, :type => :rvalue, :doc => <<-DOC
+    Escapes a string so that it can be safely used in a Bourne shell command line.
 
-Note that the resulting string should be used unquoted and is not intended for use in double quotes nor in single
-quotes.
+    Note that the resulting string should be used unquoted and is not intended for use in double quotes nor in single
+    quotes.
 
-This function behaves the same as ruby's Shellwords.shellescape() function.
-  EOS
-  ) do |arguments|
+    This function behaves the same as ruby's Shellwords.shellescape() function.
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "shell_escape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
index 682ed8d..0a037c1 100644 (file)
@@ -1,23 +1,22 @@
+
+require 'shellwords'
 #
 # shell_join.rb
 #
-
-require 'shellwords'
-
 module Puppet::Parser::Functions
-  newfunction(:shell_join, :type => :rvalue, :doc => <<-EOS
-Builds a command line string from the given array of strings. Each array item is escaped for Bourne shell. All items are
-then joined together, with a single space in between.
+  newfunction(:shell_join, :type => :rvalue, :doc => <<-DOC
+    Builds a command line string from the given array of strings. Each array item is escaped for Bourne shell. All items are
+    then joined together, with a single space in between.
 
-This function behaves the same as ruby's Shellwords.shelljoin() function
-  EOS
-  ) do |arguments|
+    This function behaves the same as ruby's Shellwords.shelljoin() function
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "shell_join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     array = arguments[0]
 
-    raise Puppet::ParseError, ("First argument is not an Array: #{array.inspect}") unless array.is_a?(Array)
+    raise Puppet::ParseError, "First argument is not an Array: #{array.inspect}" unless array.is_a?(Array)
 
     # explicit conversion to string is required for ruby 1.9
     array = array.map { |item| item.to_s }
index 09e6e78..9dcf958 100644 (file)
@@ -1,16 +1,14 @@
+require 'shellwords'
 #
 # shell_split.rb
 #
-
-require 'shellwords'
-
 module Puppet::Parser::Functions
-  newfunction(:shell_split, :type => :rvalue, :doc => <<-EOS
-Splits a string into an array of tokens in the same way the Bourne shell does.
+  newfunction(:shell_split, :type => :rvalue, :doc => <<-DOC
+    Splits a string into an array of tokens in the same way the Bourne shell does.
 
-This function behaves the same as ruby's Shellwords.shellsplit() function
-  EOS
-  ) do |arguments|
+    This function behaves the same as ruby's Shellwords.shellsplit() function
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "shell_split(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
index 942cbce..5e6d93b 100644 (file)
@@ -1,14 +1,13 @@
 #
 # shuffle.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:shuffle, :type => :rvalue, :doc => <<-EOS
-Randomizes the order of a string or array elements.
-    EOS
-  ) do |arguments|
+  newfunction(:shuffle, :type => :rvalue, :doc => <<-DOC
+    Randomizes the order of a string or array elements.
+  DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "shuffle(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "shuffle(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
index b503aa0..2002a3d 100644 (file)
@@ -1,14 +1,16 @@
 #
 # size.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:size, :type => :rvalue, :doc => <<-EOS
-Returns the number of elements in a string, an array or a hash
-    EOS
-  ) do |arguments|
+  newfunction(:size, :type => :rvalue, :doc => <<-DOC
+    Returns the number of elements in a string, an array or a hash
+
+    Note that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions
+    of Puppet < 5.4.0 use the stdlib length() function.
+  DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     item = arguments[0]
 
@@ -28,7 +30,6 @@ Returns the number of elements in a string, an array or a hash
         Float(item)
 
         raise(Puppet::ParseError, 'size(): Requires either string, array or hash to work with')
-
       rescue ArgumentError
         result = item.size
       end
index d7792f5..65308da 100644 (file)
@@ -2,25 +2,25 @@
 #  sort.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:sort, :type => :rvalue, :doc => <<-EOS
-Sorts strings and arrays lexically.
-    EOS
-  ) do |arguments|
+  newfunction(:sort, :type => :rvalue, :doc => <<-DOC
+    Sorts strings and arrays lexically.
+
+    Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this.
+  DOC
+             ) do |arguments|
 
-    if (arguments.size != 1) then
+    if arguments.size != 1
       raise(Puppet::ParseError, "sort(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     value = arguments[0]
 
-    if value.is_a?(Array) then
+    if value.is_a?(Array)
       value.sort
-    elsif value.is_a?(String) then
-      value.split("").sort.join("")
+    elsif value.is_a?(String)
+      value.split('').sort.join('')
     end
-
   end
 end
 
index f5757d1..eaa1404 100644 (file)
@@ -1,34 +1,30 @@
 #
 # squeeze.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS
-Returns a new string where runs of the same character that occur in this set are replaced by a single character.
-    EOS
-  ) do |arguments|
+  newfunction(:squeeze, :type => :rvalue, :doc => <<-DOC
+    Returns a new string where runs of the same character that occur in this set are replaced by a single character.
+  DOC
+             ) do |arguments|
 
-    if ((arguments.size != 2) and (arguments.size != 1)) then
+    if (arguments.size != 2) && (arguments.size != 1)
       raise(Puppet::ParseError, "squeeze(): Wrong number of arguments given #{arguments.size} for 2 or 1")
     end
 
     item = arguments[0]
     squeezeval = arguments[1]
 
-    if item.is_a?(Array) then
-      if squeezeval then
-        item.collect { |i| i.squeeze(squeezeval) }
+    if item.is_a?(Array)
+      if squeezeval
+        item.map { |i| i.squeeze(squeezeval) }
       else
-        item.collect { |i| i.squeeze }
+        item.map { |i| i.squeeze }
       end
+    elsif squeezeval
+      item.squeeze(squeezeval)
     else
-      if squeezeval then
-        item.squeeze(squeezeval)
-      else
-        item.squeeze
-      end
+      item.squeeze
     end
-
   end
 end
 
index 38ad1ce..5f8b8fe 100644 (file)
@@ -1,21 +1,23 @@
 #
 # str2bool.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS
-This converts a string to a boolean. This attempt to convert strings that
-contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things
-like: 0, F,f, N,n, false, FALSE, no to 'false'.
-    EOS
-  ) do |arguments|
+  newfunction(:str2bool, :type => :rvalue, :doc => <<-DOC
+    This converts a string to a boolean. This attempt to convert strings that
+    contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things
+    like: 0, F,f, N,n, false, FALSE, no to 'false'.
+
+    Note that since Puppet 5.0.0 the Boolean data type can convert strings to a Boolean value.
+    See the function new() in Puppet for details what the Boolean data type supports.
+  DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "str2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "str2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     string = arguments[0]
 
     # If string is already Boolean, return it
-    if !!string == string
+    if !!string == string # rubocop:disable Style/DoubleNegation : No viable alternative
       return string
     end
 
@@ -25,17 +27,17 @@ like: 0, F,f, N,n, false, FALSE, no to 'false'.
 
     # We consider all the yes, no, y, n and so on too ...
     result = case string
-      #
-      # This is how undef looks like in Puppet ...
-      # We yield false in this case.
-      #
-      when /^$/, '' then false # Empty string will be false ...
-      when /^(1|t|y|true|yes)$/i  then true
-      when /^(0|f|n|false|no)$/i  then false
-      when /^(undef|undefined)$/ then false # This is not likely to happen ...
-      else
-        raise(Puppet::ParseError, 'str2bool(): Unknown type of boolean given')
-    end
+             #
+             # This is how undef looks like in Puppet ...
+             # We yield false in this case.
+             #
+             when %r{^$}, '' then false # Empty string will be false ...
+             when %r{^(1|t|y|true|yes)$}i  then true
+             when %r{^(0|f|n|false|no)$}i  then false
+             when %r{^(undef|undefined)$} then false # This is not likely to happen ...
+             else
+               raise(Puppet::ParseError, 'str2bool(): Unknown type of boolean given')
+             end
 
     return result
   end
index 0410c62..4d62008 100644 (file)
@@ -2,15 +2,14 @@
 #  str2saltedsha512.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS
-This converts a string to a salted-SHA512 password hash (which is used for
-OS X versions >= 10.7). Given any simple string, you will get a hex version
-of a salted-SHA512 password hash that can be inserted into your Puppet
-manifests as a valid password attribute.
-    EOS
-  ) do |arguments|
+  newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-DOC
+    This converts a string to a salted-SHA512 password hash (which is used for
+    OS X versions >= 10.7). Given any simple string, you will get a hex version
+    of a salted-SHA512 password hash that can be inserted into your Puppet
+    manifests as a valid password attribute.
+    DOC
+             ) do |arguments|
     require 'digest/sha2'
 
     raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments passed (#{arguments.size} but we require 1)") if arguments.size != 1
@@ -22,7 +21,7 @@ manifests as a valid password attribute.
     end
 
     seedint    = rand(2**31 - 1)
-    seedstring = Array(seedint).pack("L")
+    seedstring = Array(seedint).pack('L')
     saltedpass = Digest::SHA512.digest(seedstring + password)
     (seedstring + saltedpass).unpack('H*')[0]
   end
index deae329..045d256 100644 (file)
@@ -2,77 +2,79 @@
 #  strftime.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:strftime, :type => :rvalue, :doc => <<-EOS
-This function returns formatted time.
-
-*Examples:*
-
-To return the time since epoch:
-
-    strftime("%s")
-
-To return the date:
-
-    strftime("%Y-%m-%d")
-
-*Format meaning:*
-
-    %a - The abbreviated weekday name (``Sun'')
-    %A - The  full  weekday  name (``Sunday'')
-    %b - The abbreviated month name (``Jan'')
-    %B - The  full  month  name (``January'')
-    %c - The preferred local date and time representation
-    %C - Century (20 in 2009)
-    %d - Day of the month (01..31)
-    %D - Date (%m/%d/%y)
-    %e - Day of the month, blank-padded ( 1..31)
-    %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
-    %h - Equivalent to %b
-    %H - Hour of the day, 24-hour clock (00..23)
-    %I - Hour of the day, 12-hour clock (01..12)
-    %j - Day of the year (001..366)
-    %k - hour, 24-hour clock, blank-padded ( 0..23)
-    %l - hour, 12-hour clock, blank-padded ( 0..12)
-    %L - Millisecond of the second (000..999)
-    %m - Month of the year (01..12)
-    %M - Minute of the hour (00..59)
-    %n - Newline (\n)
-    %N - Fractional seconds digits, default is 9 digits (nanosecond)
-            %3N  millisecond (3 digits)
-            %6N  microsecond (6 digits)
-            %9N  nanosecond (9 digits)
-    %p - Meridian indicator (``AM''  or  ``PM'')
-    %P - Meridian indicator (``am''  or  ``pm'')
-    %r - time, 12-hour (same as %I:%M:%S %p)
-    %R - time, 24-hour (%H:%M)
-    %s - Number of seconds since 1970-01-01 00:00:00 UTC.
-    %S - Second of the minute (00..60)
-    %t - Tab character (\t)
-    %T - time, 24-hour (%H:%M:%S)
-    %u - Day of the week as a decimal, Monday being 1. (1..7)
-    %U - Week  number  of the current year,
-            starting with the first Sunday as the first
-            day of the first week (00..53)
-    %v - VMS date (%e-%b-%Y)
-    %V - Week number of year according to ISO 8601 (01..53)
-    %W - Week  number  of the current year,
-            starting with the first Monday as the first
-            day of the first week (00..53)
-    %w - Day of the week (Sunday is 0, 0..6)
-    %x - Preferred representation for the date alone, no time
-    %X - Preferred representation for the time alone, no date
-    %y - Year without a century (00..99)
-    %Y - Year with century
-    %z - Time zone as  hour offset from UTC (e.g. +0900)
-    %Z - Time zone name
-    %% - Literal ``%'' character
-    EOS
-  ) do |arguments|
+  newfunction(:strftime, :type => :rvalue, :doc => <<-DOC
+    This function returns formatted time.
+
+    Note that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this
+    function. It also supports the Timestamp and Timespan data types in the Puppet language.
+
+    *Examples:*
+
+    To return the time since epoch:
+
+        strftime("%s")
+
+    To return the date:
+
+        strftime("%Y-%m-%d")
+
+    *Format meaning:*
+
+        %a - The abbreviated weekday name (``Sun'')
+        %A - The  full  weekday  name (``Sunday'')
+        %b - The abbreviated month name (``Jan'')
+        %B - The  full  month  name (``January'')
+        %c - The preferred local date and time representation
+        %C - Century (20 in 2009)
+        %d - Day of the month (01..31)
+        %D - Date (%m/%d/%y)
+        %e - Day of the month, blank-padded ( 1..31)
+        %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
+        %h - Equivalent to %b
+        %H - Hour of the day, 24-hour clock (00..23)
+        %I - Hour of the day, 12-hour clock (01..12)
+        %j - Day of the year (001..366)
+        %k - hour, 24-hour clock, blank-padded ( 0..23)
+        %l - hour, 12-hour clock, blank-padded ( 0..12)
+        %L - Millisecond of the second (000..999)
+        %m - Month of the year (01..12)
+        %M - Minute of the hour (00..59)
+        %n - Newline (\n)
+        %N - Fractional seconds digits, default is 9 digits (nanosecond)
+                %3N  millisecond (3 digits)
+                %6N  microsecond (6 digits)
+                %9N  nanosecond (9 digits)
+        %p - Meridian indicator (``AM''  or  ``PM'')
+        %P - Meridian indicator (``am''  or  ``pm'')
+        %r - time, 12-hour (same as %I:%M:%S %p)
+        %R - time, 24-hour (%H:%M)
+        %s - Number of seconds since 1970-01-01 00:00:00 UTC.
+        %S - Second of the minute (00..60)
+        %t - Tab character (\t)
+        %T - time, 24-hour (%H:%M:%S)
+        %u - Day of the week as a decimal, Monday being 1. (1..7)
+        %U - Week  number  of the current year,
+                starting with the first Sunday as the first
+                day of the first week (00..53)
+        %v - VMS date (%e-%b-%Y)
+        %V - Week number of year according to ISO 8601 (01..53)
+        %W - Week  number  of the current year,
+                starting with the first Monday as the first
+                day of the first week (00..53)
+        %w - Day of the week (Sunday is 0, 0..6)
+        %x - Preferred representation for the date alone, no time
+        %X - Preferred representation for the time alone, no date
+        %y - Year without a century (00..99)
+        %Y - Year with century
+        %z - Time zone as  hour offset from UTC (e.g. +0900)
+        %Z - Time zone name
+        %% - Literal ``%'' character
+    DOC
+             ) do |arguments|
 
     # Technically we support two arguments but only first is mandatory ...
-    raise(Puppet::ParseError, "strftime(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "strftime(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     format = arguments[0]
 
@@ -84,7 +86,7 @@ To return the date:
     time = Time.new
 
     # There is probably a better way to handle Time Zone ...
-    if time_zone and not time_zone.empty?
+    if time_zone && !time_zone.empty?
       original_zone = ENV['TZ']
 
       local_time = time.clone
index 9e8366f..59d15a3 100644 (file)
@@ -1,21 +1,23 @@
 #
 #  strip.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:strip, :type => :rvalue, :doc => <<-EOS
-This function removes leading and trailing whitespace from a string or from
-every string inside an array.
+  newfunction(:strip, :type => :rvalue, :doc => <<-DOC
+    This function removes leading and trailing whitespace from a string or from
+    every string inside an array.
+
+    *Examples:*
 
-*Examples:*
+        strip("    aaa   ")
 
-    strip("    aaa   ")
+    Would result in: "aaa"
 
-Would result in: "aaa"
-    EOS
-  ) do |arguments|
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "strip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "strip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -23,11 +25,11 @@ Would result in: "aaa"
       raise(Puppet::ParseError, 'strip(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      result = value.collect { |i| i.is_a?(String) ? i.strip : i }
-    else
-      result = value.strip
-    end
+    result = if value.is_a?(Array)
+               value.map { |i| i.is_a?(String) ? i.strip : i }
+             else
+               value.strip
+             end
 
     return result
   end
index 7c5057d..72ff08d 100644 (file)
@@ -1,26 +1,31 @@
 #
 # suffix.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:suffix, :type => :rvalue, :doc => <<-EOS
-This function applies a suffix to all elements in an array, or to the keys
-in a hash.
+  newfunction(:suffix, :type => :rvalue, :doc => <<-DOC
+    This function applies a suffix to all elements in an array, or to the keys
+    in a hash.
+
+    *Examples:*
+
+        suffix(['a','b','c'], 'p')
 
-*Examples:*
+    Will return: ['ap','bp','cp']
 
-    suffix(['a','b','c'], 'p')
+    Note that since Puppet 4.0.0 the general way to modify values is in array is by using the map
+    function in Puppet. This example does the same as the example above:
 
-Will return: ['ap','bp','cp']
-    EOS
-  ) do |arguments|
+        ['a', 'b', 'c'].map |$x| { "${x}p" }
+
+    DOC
+             ) do |arguments|
 
     # Technically we support two arguments but only first is mandatory ...
-    raise(Puppet::ParseError, "suffix(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "suffix(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     enumerable = arguments[0]
 
-    unless enumerable.is_a?(Array) or enumerable.is_a?(Hash)
+    unless enumerable.is_a?(Array) || enumerable.is_a?(Hash)
       raise Puppet::ParseError, "suffix(): expected first argument to be an Array or a Hash, got #{enumerable.inspect}"
     end
 
@@ -32,18 +37,18 @@ Will return: ['ap','bp','cp']
       end
     end
 
-    if enumerable.is_a?(Array)
-      # Turn everything into string same as join would do ...
-      result = enumerable.collect do |i|
-        i = i.to_s
-        suffix ? i + suffix : i
-      end
-    else
-      result = Hash[enumerable.map do |k,v|
-        k = k.to_s
-        [ suffix ? k + suffix : k, v ]
-      end]
-    end
+    result = if enumerable.is_a?(Array)
+               # Turn everything into string same as join would do ...
+               enumerable.map do |i|
+                 i = i.to_s
+                 suffix ? i + suffix : i
+               end
+             else
+               Hash[enumerable.map do |k, v|
+                 k = k.to_s
+                 [suffix ? k + suffix : k, v]
+               end]
+             end
 
     return result
   end
index f3276fb..e8a5d9a 100644 (file)
@@ -2,20 +2,19 @@
 #  swapcase.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS
-This function will swap the existing case of a string.
+  newfunction(:swapcase, :type => :rvalue, :doc => <<-DOC
+    This function will swap the existing case of a string.
 
-*Examples:*
+    *Examples:*
 
-    swapcase("aBcD")
+        swapcase("aBcD")
 
-Would result in: "AbCd"
-    EOS
-  ) do |arguments|
+    Would result in: "AbCd"
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "swapcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "swapcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -23,12 +22,12 @@ Would result in: "AbCd"
       raise(Puppet::ParseError, 'swapcase(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? i.swapcase : i }
-    else
-      result = value.swapcase
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? i.swapcase : i }
+             else
+               value.swapcase
+             end
 
     return result
   end
index d7780c8..9f2e3c8 100644 (file)
@@ -1,30 +1,36 @@
 #
 # time.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:time, :type => :rvalue, :doc => <<-EOS
-This function will return the current time since epoch as an integer.
+  newfunction(:time, :type => :rvalue, :doc => <<-DOC
+    This function will return the current time since epoch as an integer.
+
+    *Examples:*
+
+        time()
+
+    Will return something like: 1311972653
 
-*Examples:*
+    Note that since Puppet 4.8.0 the Puppet language has the data types Timestamp (a point in time) and
+    Timespan (a duration). The following example is equivalent to calling time() without
+    any arguments:
 
-    time()
+        Timestamp()
 
-Will return something like: 1311972653
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
     # The Time Zone argument is optional ...
     time_zone = arguments[0] if arguments[0]
 
-    if (arguments.size != 0) and (arguments.size != 1) then
+    if !arguments.empty? && (arguments.size != 1)
       raise(Puppet::ParseError, "time(): Wrong number of arguments given #{arguments.size} for 0 or 1")
     end
 
     time = Time.new
 
     # There is probably a better way to handle Time Zone ...
-    if time_zone and not time_zone.empty?
+    if time_zone && !time_zone.empty?
       original_zone = ENV['TZ']
 
       local_time = time.clone
index bf72503..bff24b0 100644 (file)
@@ -1,11 +1,14 @@
+#
+# to_bytes.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS
+  newfunction(:to_bytes, :type => :rvalue, :doc => <<-DOC
     Converts the argument into bytes, for example 4 kB becomes 4096.
     Takes a single string value as an argument.
     These conversions reflect a layperson's understanding of
     1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB.
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
@@ -13,17 +16,17 @@ module Puppet::Parser::Functions
 
     return arg if arg.is_a? Numeric
 
-    value,prefix = */([0-9.e+-]*)\s*([^bB]?)/.match(arg)[1,2]
+    value, prefix = *%r{([0-9.e+-]*)\s*([^bB]?)}.match(arg)[1, 2]
 
     value = value.to_f
     case prefix
     when '' then return value.to_i
-    when 'k' then return (value*(1<<10)).to_i
-    when 'M' then return (value*(1<<20)).to_i
-    when 'G' then return (value*(1<<30)).to_i
-    when 'T' then return (value*(1<<40)).to_i
-    when 'P' then return (value*(1<<50)).to_i
-    when 'E' then return (value*(1<<60)).to_i
+    when 'k' then return (value * (1 << 10)).to_i
+    when 'M' then return (value * (1 << 20)).to_i
+    when 'G' then return (value * (1 << 30)).to_i
+    when 'T' then return (value * (1 << 40)).to_i
+    when 'P' then return (value * (1 << 50)).to_i
+    when 'E' then return (value * (1 << 60)).to_i
     else raise Puppet::ParseError, "to_bytes(): Unknown prefix #{prefix}"
     end
   end
index fc19a23..34f9476 100644 (file)
@@ -1,43 +1,46 @@
+#
+# try_get_value.rb
+#
 module Puppet::Parser::Functions
   newfunction(
-      :try_get_value,
-      :type => :rvalue,
-      :arity => -2,
-      :doc => <<-eos
-DEPRECATED: this function is deprecated, please use dig() instead.
-
-Looks up into a complex structure of arrays and hashes and returns a value
-or the default value if nothing was found.
-
-Key can contain slashes to describe path components. The function will go down
-the structure and try to extract the required value.
-
-$data = {
-  'a' => {
-    'b' => [
-      'b1',
-      'b2',
-      'b3',
-    ]
-  }
-}
-
-$value = try_get_value($data, 'a/b/2', 'not_found', '/')
-=> $value = 'b3'
-
-a -> first hash key
-b -> second hash key
-2 -> array index starting with 0
-
-not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil.
-/ -> (optional) path delimiter. Defaults to '/'.
-
-In addition to the required "key" argument, "try_get_value" accepts default
-argument. It will be returned if no value was found or a path component is
-missing. And the fourth argument can set a variable path separator.
-  eos
+    :try_get_value,
+    :type => :rvalue,
+    :arity => -2,
+    :doc => <<-DOC
+      DEPRECATED: this function is deprecated, please use dig() instead.
+
+      Looks up into a complex structure of arrays and hashes and returns a value
+      or the default value if nothing was found.
+
+      Key can contain slashes to describe path components. The function will go down
+      the structure and try to extract the required value.
+
+      $data = {
+        'a' => {
+          'b' => [
+            'b1',
+            'b2',
+            'b3',
+          ]
+        }
+      }
+
+      $value = try_get_value($data, 'a/b/2', 'not_found', '/')
+      => $value = 'b3'
+
+      a -> first hash key
+      b -> second hash key
+      2 -> array index starting with 0
+
+      not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil.
+      / -> (optional) path delimiter. Defaults to '/'.
+
+      In addition to the required "key" argument, "try_get_value" accepts default
+      argument. It will be returned if no value was found or a path component is
+      missing. And the fourth argument can set a variable path separator.
+    DOC
   ) do |args|
-    warning("try_get_value() DEPRECATED: this function is deprecated, please use dig() instead.")
+    warning('try_get_value() DEPRECATED: this function is deprecated, please use dig() instead.')
     data = args[0]
     path = args[1] || ''
     default = args[2]
@@ -47,7 +50,7 @@ missing. And the fourth argument can set a variable path separator.
     end
 
     separator = args[3] || '/'
-    path = path.split(separator).map{ |key| key =~ /^\d+$/ ? key.to_i : key }
+    path = path.split(separator).map { |key| (key =~ %r{^\d+$}) ? key.to_i : key }
     function_dig([data, path, default])
   end
 end
index 016529b..9fcae7a 100644 (file)
@@ -1,18 +1,17 @@
 #
 # type.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:type, :type => :rvalue, :doc => <<-EOS
-  DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.
-    EOS
-  ) do |args|
+  newfunction(:type, :type => :rvalue, :doc => <<-DOC
+    DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.
+  DOC
+             ) do |args|
 
-    warning("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
-    if ! Puppet::Parser::Functions.autoloader.loaded?(:type3x)
+    warning("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : Cannot reduce line length
+    unless Puppet::Parser::Functions.autoloader.loaded?(:type3x)
       Puppet::Parser::Functions.autoloader.load(:type3x)
     end
-    function_type3x(args + [false])
+    function_type3x(args)
   end
 end
 
index b17380e..950171d 100644 (file)
@@ -1,28 +1,27 @@
 #
 # type3x.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:type3x, :type => :rvalue, :doc => <<-EOS
-DEPRECATED: This function will be removed when puppet 3 support is dropped; please migrate to the new parser's typing system.
+  newfunction(:type3x, :type => :rvalue, :doc => <<-DOC
+    DEPRECATED: This function will be removed when Puppet 3 support is dropped; please migrate to the new parser's typing system.
 
-Returns the type when passed a value. Type can be one of:
+    Returns the type when passed a value. Type can be one of:
 
-* string
-* array
-* hash
-* float
-* integer
-* boolean
-    EOS
-  ) do |args|
-    raise(Puppet::ParseError, "type3x(): Wrong number of arguments given (#{args.size} for 1)") if args.size < 1
+    * string
+    * array
+    * hash
+    * float
+    * integer
+    * boolean
+  DOC
+             ) do |args|
+    raise(Puppet::ParseError, "type3x(): Wrong number of arguments given (#{args.size} for 1)") unless args.size == 1
 
     value = args[0]
 
     klass = value.class
 
-    if not [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass)
+    unless [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass) # rubocop:disable Lint/UnifiedInteger
       raise(Puppet::ParseError, 'type3x(): Unknown type')
     end
 
@@ -30,16 +29,16 @@ Returns the type when passed a value. Type can be one of:
 
     # We note that Integer is the parent to Bignum and Fixnum ...
     result = case klass
-      when /^(?:Big|Fix)num$/ then 'integer'
-      when /^(?:True|False)Class$/ then 'boolean'
-      else klass
-    end
-
-    if result == "String" then
-      if value == value.to_i.to_s then
-        result = "Integer"
-      elsif value == value.to_f.to_s then
-        result = "Float"
+             when %r{^(?:Big|Fix)num$} then 'integer'
+             when %r{^(?:True|False)Class$} then 'boolean'
+             else klass
+             end
+
+    if result == 'String'
+      if value == value.to_i.to_s
+        result = 'Integer'
+      elsif value == value.to_f.to_s
+        result = 'Float'
       end
     end
 
index abe2dc8..ed57bc5 100644 (file)
@@ -1,18 +1,17 @@
 #
 # union.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:union, :type => :rvalue, :doc => <<-EOS
-This function returns a union of two or more arrays.
+  newfunction(:union, :type => :rvalue, :doc => <<-DOC
+    This function returns a union of two or more arrays.
 
-*Examples:*
+    *Examples:*
 
-    union(["a","b","c"],["b","c","d"])
+        union(["a","b","c"],["b","c","d"])
 
-Would return: ["a","b","c","d"]
-    EOS
-  ) do |arguments|
+    Would return: ["a","b","c","d"]
+    DOC
+             ) do |arguments|
 
     # Check that 2 or more arguments have been given ...
     raise(Puppet::ParseError, "union(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2
index 1e2a895..301f6a4 100644 (file)
@@ -1,34 +1,33 @@
 #
 # unique.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:unique, :type => :rvalue, :doc => <<-EOS
-This function will remove duplicates from strings and arrays.
+  newfunction(:unique, :type => :rvalue, :doc => <<-DOC
+    This function will remove duplicates from strings and arrays.
 
-*Examples:*
+    *Examples:*
 
-    unique("aabbcc")
+        unique("aabbcc")
 
-Will return:
+    Will return:
 
-    abc
+        abc
 
-You can also use this with arrays:
+    You can also use this with arrays:
 
-    unique(["a","a","b","b","c","c"])
+        unique(["a","a","b","b","c","c"])
 
-This returns:
+    This returns:
 
-    ["a","b","c"]
-    EOS
-  ) do |arguments|
+        ["a","b","c"]
+    DOC
+             ) do |arguments|
 
     if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0
       function_deprecation([:unique, 'This method is deprecated, please use the core puppet unique function. There is further documentation for the function in the release notes of Puppet 5.0.'])
     end
 
-    raise(Puppet::ParseError, "unique(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "unique(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
index 0bd9cd1..8123797 100644 (file)
@@ -1,15 +1,15 @@
 # Custom Puppet function to convert unix to dos format
 module Puppet::Parser::Functions
-  newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-EOS
+  newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-DOC
     Returns the DOS version of the given string.
     Takes a single string argument.
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
     unless arguments[0].is_a?(String)
       raise(Puppet::ParseError, 'unix2dos(): Requires string as argument')
     end
 
-    arguments[0].gsub(/\r*\n/, "\r\n")
+    arguments[0].gsub(%r{\r*\n}, "\r\n")
   end
 end
index e847e51..563efe4 100644 (file)
@@ -2,20 +2,22 @@
 #  upcase.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-
 module Puppet::Parser::Functions
-  newfunction(:upcase, :type => :rvalue, :doc => <<-EOS
-Converts a string or an array of strings to uppercase.
+  newfunction(:upcase, :type => :rvalue, :doc => <<-DOC
+    Converts a string or an array of strings to uppercase.
+
+    *Examples:*
 
-*Examples:*
+        upcase("abcd")
 
-    upcase("abcd")
+    Will return:
 
-Will return:
+        ABCD
 
-    ABCD
-  EOS
-  ) do |arguments|
+    Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+  DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "upcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
@@ -27,7 +29,7 @@ Will return:
 
     if value.is_a?(Array)
       # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| function_upcase([i]) }
+      result = value.map { |i| function_upcase([i]) }
     elsif value.is_a?(Hash)
       result = {}
       value.each_pair do |k, v|
index 4c5c400..8bcd586 100644 (file)
@@ -1,17 +1,16 @@
+require 'uri'
 #
 #  uriescape.rb
 #  Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
 #
-require 'uri'
-
 module Puppet::Parser::Functions
-  newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS
+  newfunction(:uriescape, :type => :rvalue, :doc => <<-DOC
     Urlencodes a string or array of strings.
     Requires either a single string or an array as an input.
-    EOS
-  ) do |arguments|
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "uriescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "uriescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     value = arguments[0]
 
@@ -19,12 +18,12 @@ module Puppet::Parser::Functions
       raise(Puppet::ParseError, 'uriescape(): Requires either array or string to work with')
     end
 
-    if value.is_a?(Array)
-      # Numbers in Puppet are often string-encoded which is troublesome ...
-      result = value.collect { |i| i.is_a?(String) ? URI.escape(i) : i }
-    else
-      result = URI.escape(value)
-    end
+    result = if value.is_a?(Array)
+               # Numbers in Puppet are often string-encoded which is troublesome ...
+               value.map { |i| i.is_a?(String) ? URI.escape(i) : i }
+             else
+               URI.escape(value)
+             end
 
     return result
   end
index c73f3df..0db10c3 100644 (file)
@@ -1,5 +1,8 @@
+#
+# validate_absolute_path.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:validate_absolute_path, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_absolute_path, :doc => <<-'DOC') do |args|
     Validate the string represents an absolute path in the filesystem.  This function works
     for windows and unix style paths.
 
@@ -24,15 +27,12 @@ module Puppet::Parser::Functions
         $undefined = undef
         validate_absolute_path($undefined)
 
-    ENDHEREDOC
-
-    # The deprecation function was being called twice, as validate_absolute_path calls is_absolute_path. I have removed it from here so it only calls deprecation once within is_absolute_path.
-    # function_deprecation([:validate_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
+    DOC
 
     require 'puppet/util'
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_absolute_path(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_absolute_path(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
@@ -40,13 +40,13 @@ module Puppet::Parser::Functions
       candidates = arg
       # if arg is just a string with a path to test, convert it to an array
       # to avoid test code duplication
-      unless arg.is_a?(Array) then
-        candidates = Array.new(1,arg)
+      unless arg.is_a?(Array)
+        candidates = Array.new(1, arg)
       end
       # iterate over all paths within the candidates array
       candidates.each do |path|
         unless function_is_absolute_path([path])
-          raise Puppet::ParseError, ("#{path.inspect} is not an absolute path.")
+          raise Puppet::ParseError, "#{path.inspect} is not an absolute path."
         end
       end
     end
index 3bf3983..1120ce8 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_array.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_array, :doc => <<-'DOC') do |args|
     Validate that all passed values are array data structures. Abort catalog
     compilation if any value fails this check.
 
@@ -16,20 +18,19 @@ module Puppet::Parser::Functions
         $undefined = undef
         validate_array($undefined)
 
-    ENDHEREDOC
+    DOC
 
-    function_deprecation([:validate_array, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_array, 'This method is deprecated, please use the stdlib validate_legacy function,
+      with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.'])
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_array(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_array(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
       unless arg.is_a?(Array)
-        raise Puppet::ParseError, ("#{arg.inspect} is not an Array.  It looks to be a #{arg.class}")
+        raise Puppet::ParseError, "#{arg.inspect} is not an Array.  It looks to be a #{arg.class}"
       end
     end
-
   end
-
 end
index 2196c3e..97f3127 100644 (file)
@@ -1,7 +1,10 @@
 require 'tempfile'
 
+#
+# validate_augaes.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:validate_augeas, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_augeas, :doc => <<-'DOC') do |args|
     Perform validation of a string using an Augeas lens
     The first argument of this function should be a string to
     test, and the second argument should be the name of the Augeas lens to use.
@@ -29,24 +32,24 @@ module Puppet::Parser::Functions
 
         validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
 
-    ENDHEREDOC
+    DOC
     unless Puppet.features.augeas?
-      raise Puppet::ParseError, ("validate_augeas(): this function requires the augeas feature. See http://docs.puppetlabs.com/guides/augeas.html#pre-requisites for how to activate it.")
+      raise Puppet::ParseError, 'validate_augeas(): this function requires the augeas feature. See http://docs.puppetlabs.com/guides/augeas.html#pre-requisites for how to activate it.'
     end
 
-    if (args.length < 2) or (args.length > 4) then
-      raise Puppet::ParseError, ("validate_augeas(): wrong number of arguments (#{args.length}; must be 2, 3, or 4)")
+    if (args.length < 2) || (args.length > 4)
+      raise Puppet::ParseError, "validate_augeas(): wrong number of arguments (#{args.length}; must be 2, 3, or 4)"
     end
 
     msg = args[3] || "validate_augeas(): Failed to validate content against #{args[1].inspect}"
 
     require 'augeas'
-    aug = Augeas::open(nil, nil, Augeas::NO_MODL_AUTOLOAD)
+    aug = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD)
     begin
       content = args[0]
 
       # Test content in a temporary file
-      tmpfile = Tempfile.new("validate_augeas")
+      tmpfile = Tempfile.new('validate_augeas')
       begin
         tmpfile.write(content)
       ensure
@@ -58,14 +61,14 @@ module Puppet::Parser::Functions
       aug.transform(
         :lens => lens,
         :name => 'Validate_augeas',
-        :incl => tmpfile.path
+        :incl => tmpfile.path,
       )
       aug.load!
 
       unless aug.match("/augeas/files#{tmpfile.path}//error").empty?
         error = aug.get("/augeas/files#{tmpfile.path}//error/message")
         msg += " with error: #{error}"
-        raise Puppet::ParseError, (msg)
+        raise Puppet::ParseError, msg
       end
 
       # Launch unit tests
@@ -73,7 +76,7 @@ module Puppet::Parser::Functions
       aug.defvar('file', "/files#{tmpfile.path}")
       tests.each do |t|
         msg += " testing path #{t}"
-        raise Puppet::ParseError, (msg) unless aug.match(t).empty?
+        raise Puppet::ParseError, msg unless aug.match(t).empty?
       end
     ensure
       aug.close
index 49075b8..d3bf3d0 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_bool.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_bool, :doc => <<-'DOC') do |args|
     Validate that all passed values are either true or false. Abort catalog
     compilation if any value fails this check.
 
@@ -17,21 +19,16 @@ module Puppet::Parser::Functions
         validate_bool("true")
         validate_bool($some_array)
 
-    ENDHEREDOC
-
-    # The deprecation function was being called twice, as validate_bool calls is_bool. I have removed it from here so it only calls deprecation once within is_bool.
-    # function_deprecation([:validate_bool, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.'])
+    DOC
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_bool(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
       unless function_is_bool([arg])
-        raise Puppet::ParseError, ("#{arg.inspect} is not a boolean.  It looks to be a #{arg.class}")
+        raise Puppet::ParseError, "#{arg.inspect} is not a boolean.  It looks to be a #{arg.class}"
       end
     end
-
   end
-
 end
index 685162b..dbea604 100644 (file)
@@ -1,8 +1,11 @@
 require 'puppet/util/execution'
 require 'tempfile'
 
+#
+# validate_cmd.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:validate_cmd, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_cmd, :doc => <<-'DOC') do |args|
     Perform validation of a string with an external command.
     The first argument of this function should be a string to
     test, and the second argument should be a path to a test command
@@ -23,9 +26,9 @@ module Puppet::Parser::Functions
         # % as file location
         validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
 
-    ENDHEREDOC
-    if (args.length < 2) or (args.length > 3) then
-      raise Puppet::ParseError, ("validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)")
+    DOC
+    if (args.length < 2) || (args.length > 3)
+      raise Puppet::ParseError, "validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)"
     end
 
     msg = args[2] || "validate_cmd(): failed to validate content with command #{args[1].inspect}"
@@ -34,16 +37,16 @@ module Puppet::Parser::Functions
     checkscript = args[1]
 
     # Test content in a temporary file
-    tmpfile = Tempfile.new("validate_cmd")
+    tmpfile = Tempfile.new('validate_cmd')
     begin
       tmpfile.write(content)
       tmpfile.close
 
-      if checkscript =~ /\s%(\s|$)/
-        check_with_correct_location = checkscript.gsub(/%/,tmpfile.path)
-      else
-        check_with_correct_location = "#{checkscript} #{tmpfile.path}"
-      end
+      check_with_correct_location = if checkscript =~ %r{\s%(\s|$)}
+                                      checkscript.gsub(%r{%}, tmpfile.path)
+                                    else
+                                      "#{checkscript} #{tmpfile.path}"
+                                    end
 
       if Puppet::Util::Execution.respond_to?('execute')
         Puppet::Util::Execution.execute(check_with_correct_location)
index c3fad78..c479dfb 100644 (file)
@@ -1,5 +1,8 @@
+#
+# validate_domain_name.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:validate_domain_name, :doc => <<-ENDHEREDOC
+  newfunction(:validate_domain_name, :doc => <<-DOC
     Validate that all values passed are syntactically correct domain names.
     Fail compilation if any value fails this check.
 
@@ -17,8 +20,8 @@ module Puppet::Parser::Functions
         validate_domain_name('-foo.example.com')
         validate_domain_name('www.example.2com')
 
-    ENDHEREDOC
-  ) do |args|
+    DOC
+             ) do |args|
 
     rescuable_exceptions = [ArgumentError]
 
index ddd0d25..a039f51 100644 (file)
@@ -1,5 +1,8 @@
+#
+# validate_email_address.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:validate_email_address, :doc => <<-ENDHEREDOC
+  newfunction(:validate_email_address, :doc => <<-DOC
     Validate that all values passed are valid email addresses.
     Fail compilation if any value fails this check.
     The following values will pass:
@@ -10,7 +13,7 @@ module Puppet::Parser::Functions
     The following values will fail, causing compilation to abort:
     $some_array = [ 'bad_email@/d/efdf.com' ]
     validate_email_address($some_array)
-    ENDHEREDOC
+    DOC
              ) do |args|
     rescuable_exceptions = [ArgumentError]
 
index fcdc7e1..0460cf3 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_hash.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_hash, :doc => <<-'DOC') do |args|
     Validate that all passed values are hash data structures. Abort catalog
     compilation if any value fails this check.
 
@@ -16,20 +18,19 @@ module Puppet::Parser::Functions
         $undefined = undef
         validate_hash($undefined)
 
-    ENDHEREDOC
+    DOC
 
-    function_deprecation([:validate_hash, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_hash, 'This method is deprecated, please use the stdlib validate_legacy function,
+                          with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.'])
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_hash(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
       unless arg.is_a?(Hash)
-        raise Puppet::ParseError, ("#{arg.inspect} is not a Hash.  It looks to be a #{arg.class}")
+        raise Puppet::ParseError, "#{arg.inspect} is not a Hash.  It looks to be a #{arg.class}"
       end
     end
-
   end
-
 end
index 2ae0293..fc50bdc 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_interger.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_integer, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_integer, :doc => <<-'DOC') do |args|
     Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail.
 
     The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
@@ -51,12 +53,13 @@ module Puppet::Parser::Functions
     Plus all of the above, but with incorrect combinations of negative integer values.
     Plus all of the above, but with non-integer items in arrays or maximum / minimum argument.
 
-    ENDHEREDOC
+    DOC
 
-    function_deprecation([:validate_integer, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_integer, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.'])
 
     # tell the user we need at least one, and optionally up to two other parameters
-    raise Puppet::ParseError, "validate_integer(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless args.length > 0 and args.length < 4
+    raise Puppet::ParseError, "validate_integer(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless !args.empty? && args.length < 4
 
     input, max, min = *args
 
@@ -64,7 +67,7 @@ module Puppet::Parser::Functions
     if args.length > 1
       max = max.to_s
       # allow max to be empty (or undefined) if we have a minimum set
-      if args.length > 2 and max == ''
+      if args.length > 2 && max == ''
         max = nil
       else
         begin
@@ -89,18 +92,18 @@ module Puppet::Parser::Functions
     end
 
     # ensure that min < max
-    if min and max and min > max
+    if min && max && min > max
       raise Puppet::ParseError, "validate_integer(): Expected second argument to be larger than third argument, got #{max} < #{min}"
     end
 
     # create lamba validator function
-    validator = lambda do |num|
+    validator = ->(num) do
       # check input < max
-      if max and num > max
+      if max && num > max
         raise Puppet::ParseError, "validate_integer(): Expected #{input.inspect} to be smaller or equal to #{max}, got #{input.inspect}."
       end
       # check input > min (this will only be checked if no exception has been raised before)
-      if min and num < min
+      if min && num < min
         raise Puppet::ParseError, "validate_integer(): Expected #{input.inspect} to be greater or equal to #{min}, got #{input.inspect}."
       end
     end
index 5d80cfb..af835ad 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_ip_address.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_ip_address, :doc => <<-ENDHEREDOC
+  newfunction(:validate_ip_address, :doc => <<-DOC
     Validate that all values passed are valid IP addresses,
     regardless they are IPv4 or IPv6
     Fail compilation if any value fails this check.
@@ -17,20 +19,21 @@ module Puppet::Parser::Functions
     The following values will fail, causing compilation to abort:
     $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
     validate_ip_address($some_array)
-    ENDHEREDOC
-  ) do |args|
+    DOC
+             ) do |args|
 
-    require "ipaddr"
-    rescuable_exceptions = [ ArgumentError ]
+    require 'ipaddr'
+    rescuable_exceptions = [ArgumentError]
 
-    function_deprecation([:validate_ip_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_address. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_ip_address, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Ip_address. There is further documentation for validate_legacy function in the README.'])
 
     if defined?(IPAddr::InvalidAddressError)
       rescuable_exceptions << IPAddr::InvalidAddressError
     end
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_ip_address(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_ip_address(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
@@ -39,14 +42,12 @@ module Puppet::Parser::Functions
       end
 
       begin
-        unless IPAddr.new(arg).ipv4? or IPAddr.new(arg).ipv6?
+        unless IPAddr.new(arg).ipv4? || IPAddr.new(arg).ipv6?
           raise Puppet::ParseError, "#{arg.inspect} is not a valid IP address."
         end
       rescue *rescuable_exceptions
         raise Puppet::ParseError, "#{arg.inspect} is not a valid IP address."
       end
     end
-
   end
-
 end
index 0660abd..1ac303f 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_ipv4_address.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_ipv4_address, :doc => <<-ENDHEREDOC
+  newfunction(:validate_ipv4_address, :doc => <<-DOC
     Validate that all values passed are valid IPv4 addresses.
     Fail compilation if any value fails this check.
 
@@ -15,20 +17,21 @@ module Puppet::Parser::Functions
     $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
     validate_ipv4_address($some_array)
 
-    ENDHEREDOC
-  ) do |args|
+    DOC
+             ) do |args|
 
-    function_deprecation([:validate_ipv4_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_ipv4_address, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Ipv4. There is further documentation for validate_legacy function in the README.'])
 
-    require "ipaddr"
-    rescuable_exceptions = [ ArgumentError ]
+    require 'ipaddr'
+    rescuable_exceptions = [ArgumentError]
 
     if defined?(IPAddr::InvalidAddressError)
       rescuable_exceptions << IPAddr::InvalidAddressError
     end
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_ipv4_address(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_ipv4_address(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
@@ -44,7 +47,5 @@ module Puppet::Parser::Functions
         raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv4 address."
       end
     end
-
   end
-
 end
index f5dd9e5..88c133c 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_ipv7_address.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_ipv6_address, :doc => <<-ENDHEREDOC
+  newfunction(:validate_ipv6_address, :doc => <<-DOC
     Validate that all values passed are valid IPv6 addresses.
     Fail compilation if any value fails this check.
 
@@ -16,20 +18,21 @@ module Puppet::Parser::Functions
     $some_array = [ true, false, "garbage string", "1.2.3.4" ]
     validate_ipv6_address($some_array)
 
-    ENDHEREDOC
-  ) do |args|
+    DOC
+             ) do |args|
 
-    function_deprecation([:validate_ipv6_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_ipv6_address, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Ipv6. There is further documentation for validate_legacy function in the README.'])
 
-    require "ipaddr"
-    rescuable_exceptions = [ ArgumentError ]
+    require 'ipaddr'
+    rescuable_exceptions = [ArgumentError]
 
     if defined?(IPAddr::InvalidAddressError)
       rescuable_exceptions << IPAddr::InvalidAddressError
     end
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_ipv6_address(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_ipv6_address(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
@@ -45,7 +48,5 @@ module Puppet::Parser::Functions
         raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv6 address."
       end
     end
-
   end
-
 end
index 4205b30..803e6f0 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_numeric.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_numeric, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_numeric, :doc => <<-'DOC') do |args|
     Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail.
 
     The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
@@ -13,12 +15,13 @@ module Puppet::Parser::Functions
 
     For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too.
 
-    ENDHEREDOC
+    DOC
 
-    function_deprecation([:validate_numeric, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_numeric, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.'])
 
     # tell the user we need at least one, and optionally up to two other parameters
-    raise Puppet::ParseError, "validate_numeric(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless args.length > 0 and args.length < 4
+    raise Puppet::ParseError, "validate_numeric(): Wrong number of arguments; must be 1, 2 or 3, got #{args.length}" unless !args.empty? && args.length < 4
 
     input, max, min = *args
 
@@ -26,7 +29,7 @@ module Puppet::Parser::Functions
     if args.length > 1
       max = max.to_s
       # allow max to be empty (or undefined) if we have a minimum set
-      if args.length > 2 and max == ''
+      if args.length > 2 && max == ''
         max = nil
       else
         begin
@@ -51,18 +54,18 @@ module Puppet::Parser::Functions
     end
 
     # ensure that min < max
-    if min and max and min > max
+    if min && max && min > max
       raise Puppet::ParseError, "validate_numeric(): Expected second argument to be larger than third argument, got #{max} < #{min}"
     end
 
     # create lamba validator function
-    validator = lambda do |num|
+    validator = ->(num) do
       # check input < max
-      if max and num > max
+      if max && num > max
         raise Puppet::ParseError, "validate_numeric(): Expected #{input.inspect} to be smaller or equal to #{max}, got #{input.inspect}."
       end
       # check input > min (this will only be checked if no exception has been raised before)
-      if min and num < min
+      if min && num < min
         raise Puppet::ParseError, "validate_numeric(): Expected #{input.inspect} to be greater or equal to #{min}, got #{input.inspect}."
       end
     end
index 0ac83dd..88f23fc 100644 (file)
@@ -1,5 +1,8 @@
+#
+# validate.rb
+#
 module Puppet::Parser::Functions
-  newfunction(:validate_re, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_re, :doc => <<-'DOC') do |args|
     Perform simple validation of a string against one or more regular
     expressions. The first argument of this function should be a string to
     test, and the second argument should be a stringified regular expression
@@ -28,11 +31,12 @@ module Puppet::Parser::Functions
 
         validate_re("${::operatingsystemmajrelease}", '^[57]$')
 
-    ENDHEREDOC
+    DOC
 
-    function_deprecation([:validate_re, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Re. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_re, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::Re. There is further documentation for validate_legacy function in the README.'])
 
-    if (args.length < 2) or (args.length > 3) then
+    if (args.length < 2) || (args.length > 3)
       raise Puppet::ParseError, "validate_re(): wrong number of arguments (#{args.length}; must be 2 or 3)"
     end
 
@@ -45,6 +49,5 @@ module Puppet::Parser::Functions
     raise Puppet::ParseError, msg unless [args[1]].flatten.any? do |re_str|
       args[0] =~ Regexp.compile(re_str)
     end
-
   end
 end
index 383855c..db5010e 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_slength.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_slength, :doc => <<-'DOC') do |args|
     Validate that the first argument is a string (or an array of strings), and
     less/equal to than the length of the second argument. An optional third
     parameter can be given the minimum length. It fails if the first
@@ -19,11 +21,12 @@ module Puppet::Parser::Functions
       validate_slength(["discombobulate","thermometer"],5)
       validate_slength(["discombobulate","moo"],17,10)
 
-    ENDHEREDOC
+    DOC
 
-    function_deprecation([:validate_slength, 'This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_slength, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with String[]. There is further documentation for validate_legacy function in the README.'])
 
-    raise Puppet::ParseError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 or args.length == 3
+    raise Puppet::ParseError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 || args.length == 3
 
     input, max_length, min_length = *args
 
@@ -38,17 +41,17 @@ module Puppet::Parser::Functions
       begin
         min_length = Integer(min_length)
         raise ArgumentError if min_length < 0
-    rescue ArgumentError, TypeError
+      rescue ArgumentError, TypeError
         raise Puppet::ParseError, "validate_slength(): Expected third argument to be unset or a positive Numeric, got #{min_length}:#{min_length.class}"
       end
     else
       min_length = 0
     end
 
-    raise Puppet::ParseError, "validate_slength(): Expected second argument to be equal to or larger than third argument" unless max_length >= min_length
+    raise Puppet::ParseError, 'validate_slength(): Expected second argument to be equal to or larger than third argument' unless max_length >= min_length
 
-    validator = lambda do |str|
-      unless str.length <= max_length and str.length >= min_length
+    validator = ->(str) do
+      unless str.length <= max_length && str.length >= min_length
         raise Puppet::ParseError, "validate_slength(): Expected length of #{input.inspect} to be between #{min_length} and #{max_length}, was #{input.length}"
       end
     end
@@ -58,11 +61,8 @@ module Puppet::Parser::Functions
       validator.call(input)
     when Array
       input.each_with_index do |arg, pos|
-        if arg.is_a? String
-          validator.call(arg)
-        else
-          raise Puppet::ParseError, "validate_slength(): Expected element at array position #{pos} to be a String, got #{arg.class}"
-        end
+        raise Puppet::ParseError, "validate_slength(): Expected element at array position #{pos} to be a String, got #{arg.class}" unless arg.is_a? String
+        validator.call(arg)
       end
     else
       raise Puppet::ParseError, "validate_slength(): Expected first argument to be a String or Array, got #{input.class}"
index 6675d86..c2847b6 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_String.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_string, :doc => <<-'ENDHEREDOC') do |args|
+  newfunction(:validate_string, :doc => <<-'DOC') do |args|
     Validate that all passed values are string data structures. Abort catalog
     compilation if any value fails this check.
 
@@ -21,21 +23,20 @@ module Puppet::Parser::Functions
           fail('...')
         }
 
-    ENDHEREDOC
+    DOC
 
-    function_deprecation([:validate_string, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.'])
+    function_deprecation([:validate_string, 'This method is deprecated, please use the stdlib validate_legacy function,
+                            with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.'])
 
-    unless args.length > 0 then
-      raise Puppet::ParseError, ("validate_string(): wrong number of arguments (#{args.length}; must be > 0)")
+    if args.empty?
+      raise Puppet::ParseError, "validate_string(): wrong number of arguments (#{args.length}; must be > 0)"
     end
 
     args.each do |arg|
       # when called through the v4 API shim, undef gets translated to nil
       unless arg.is_a?(String) || arg.nil?
-        raise Puppet::ParseError, ("#{arg.inspect} is not a string.  It looks to be a #{arg.class}")
+        raise Puppet::ParseError, "#{arg.inspect} is not a string.  It looks to be a #{arg.class}"
       end
     end
-
   end
-
 end
index fc9f23f..ea69dc4 100644 (file)
@@ -1,6 +1,8 @@
+#
+# validate_x509_rsa_key_pair.rb
+#
 module Puppet::Parser::Functions
-
-  newfunction(:validate_x509_rsa_key_pair, :doc => <<-ENDHEREDOC
+  newfunction(:validate_x509_rsa_key_pair, :doc => <<-DOC
     Validates a PEM-formatted X.509 certificate and RSA private key using
     OpenSSL. Verifies that the certficate's signature was created from the
     supplied key.
@@ -9,16 +11,16 @@ module Puppet::Parser::Functions
 
     validate_x509_rsa_key_pair($cert, $key)
 
-    ENDHEREDOC
-  ) do |args|
+    DOC
+             ) do |args|
 
     require 'openssl'
 
     NUM_ARGS = 2 unless defined? NUM_ARGS
 
-    unless args.length == NUM_ARGS then
+    unless args.length == NUM_ARGS
       raise Puppet::ParseError,
-        ("validate_x509_rsa_key_pair(): wrong number of arguments (#{args.length}; must be #{NUM_ARGS})")
+            "validate_x509_rsa_key_pair(): wrong number of arguments (#{args.length}; must be #{NUM_ARGS})"
     end
 
     args.each do |arg|
@@ -40,8 +42,7 @@ module Puppet::Parser::Functions
     end
 
     unless cert.verify(key)
-      raise Puppet::ParseError, "Certificate signature does not match supplied key"
+      raise Puppet::ParseError, 'Certificate signature does not match supplied key'
     end
   end
-
 end
index 0ca236c..91a0cb9 100644 (file)
@@ -1,27 +1,29 @@
 #
 # values.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:values, :type => :rvalue, :doc => <<-EOS
-When given a hash this function will return the values of that hash.
+  newfunction(:values, :type => :rvalue, :doc => <<-DOC
+    When given a hash this function will return the values of that hash.
+
+    *Examples:*
 
-*Examples:*
+        $hash = {
+          'a' => 1,
+          'b' => 2,
+          'c' => 3,
+        }
+        values($hash)
 
-    $hash = {
-      'a' => 1,
-      'b' => 2,
-      'c' => 3,
-    }
-    values($hash)
+    This example would return:
 
-This example would return:
+        [1,2,3]
 
-    [1,2,3]
-    EOS
-  ) do |arguments|
+    Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
+    will be used instead of this function.
+    DOC
+             ) do |arguments|
 
-    raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     hash = arguments[0]
 
index 04a3d1a..cf53fa0 100644 (file)
@@ -1,33 +1,39 @@
 #
 # values_at.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:values_at, :type => :rvalue, :doc => <<-EOS
-Finds value inside an array based on location.
+  newfunction(:values_at, :type => :rvalue, :doc => <<-DOC
+    Finds value inside an array based on location.
+
+    The first argument is the array you want to analyze, and the second element can
+    be a combination of:
+
+    * A single numeric index
+    * A range in the form of 'start-stop' (eg. 4-9)
+    * An array combining the above
 
-The first argument is the array you want to analyze, and the second element can
-be a combination of:
+    *Examples*:
 
-* A single numeric index
-* A range in the form of 'start-stop' (eg. 4-9)
-* An array combining the above
+        values_at(['a','b','c'], 2)
 
-*Examples*:
+    Would return ['c'].
 
-    values_at(['a','b','c'], 2)
+        values_at(['a','b','c'], ["0-1"])
 
-Would return ['c'].
+    Would return ['a','b'].
 
-    values_at(['a','b','c'], ["0-1"])
+        values_at(['a','b','c','d','e'], [0, "2-3"])
 
-Would return ['a','b'].
+    Would return ['a','c','d'].
 
-    values_at(['a','b','c','d','e'], [0, "2-3"])
+    Note that since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language.
+    A negative value is taken to be "from the end" of the array:
 
-Would return ['a','c','d'].
-    EOS
-  ) do |arguments|
+        ['a', 'b', 'c', 'd'][1, 2]   # results in ['b', 'c']
+        ['a', 'b', 'c', 'd'][2, -1]  # results in ['c', 'd']
+        ['a', 'b', 'c', 'd'][1, -2]  # results in ['b', 'c']
+    DOC
+             ) do |arguments|
 
     raise(Puppet::ParseError, "values_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
 
@@ -37,38 +43,35 @@ Would return ['a','c','d'].
       raise(Puppet::ParseError, 'values_at(): Requires array to work with')
     end
 
-    indices = [arguments.shift].flatten() # Get them all ... Pokemon ...
+    indices = [arguments.shift].flatten # Get them all ... Pokemon ...
 
-    if not indices or indices.empty?
+    if !indices || indices.empty?
       raise(Puppet::ParseError, 'values_at(): You must provide at least one positive index to collect')
     end
 
-    result       = []
     indices_list = []
 
     indices.each do |i|
       i = i.to_s
-      if m = i.match(/^(\d+)(\.\.\.?|\-)(\d+)$/)
+      m = i.match(%r{^(\d+)(\.\.\.?|\-)(\d+)$})
+      if m
         start = m[1].to_i
         stop  = m[3].to_i
 
         type = m[2]
 
-        if start > stop
-          raise(Puppet::ParseError, 'values_at(): Stop index in given indices range is smaller than the start index')
-        elsif stop > array.size - 1 # First element is at index 0 is it not?
-          raise(Puppet::ParseError, 'values_at(): Stop index in given indices range exceeds array size')
-        end
+        raise(Puppet::ParseError, 'values_at(): Stop index in given indices range is smaller than the start index') if start > stop
+        raise(Puppet::ParseError, 'values_at(): Stop index in given indices range exceeds array size') if stop > array.size - 1 # First element is at index 0 is it not?
 
         range = case type
-          when /^(\.\.|\-)$/ then (start .. stop)
-          when /^(\.\.\.)$/  then (start ... stop) # Exclusive of last element ...
-        end
+                when %r{^(\.\.|\-)$} then (start..stop)
+                when %r{^(\.\.\.)$}  then (start...stop) # Exclusive of last element ...
+                end
 
-        range.each { |i| indices_list << i.to_i }
+        range.each { |i| indices_list << i.to_i } # rubocop:disable Lint/ShadowingOuterLocalVariable : Value is meant to be shadowed
       else
         # Only positive numbers allowed in this case ...
-        if not i.match(/^\d+$/)
+        unless i =~ %r{^\d+$}
           raise(Puppet::ParseError, 'values_at(): Unknown format of given index')
         end
 
@@ -84,7 +87,7 @@ Would return ['a','c','d'].
     end
 
     # We remove nil values as they make no sense in Puppet DSL ...
-    result = indices_list.collect { |i| array[i] }.compact
+    result = indices_list.map { |i| array[i] }.compact
 
     return result
   end
index 13e24b6..87a89f8 100644 (file)
@@ -1,20 +1,19 @@
 #
 # zip.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:zip, :type => :rvalue, :doc => <<-EOS
-Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments.
+  newfunction(:zip, :type => :rvalue, :doc => <<-DOC
+    Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments.
 
-*Example:*
+    *Example:*
 
-    zip(['1','2','3'],['4','5','6'])
+        zip(['1','2','3'],['4','5','6'])
 
-Would result in:
+    Would result in:
 
-    ["1", "4"], ["2", "5"], ["3", "6"]
-    EOS
-  ) do |arguments|
+        ["1", "4"], ["2", "5"], ["3", "6"]
+    DOC
+             ) do |arguments|
 
     # Technically we support three arguments but only first is mandatory ...
     raise(Puppet::ParseError, "zip(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
@@ -22,7 +21,7 @@ Would result in:
     a = arguments[0]
     b = arguments[1]
 
-    unless a.is_a?(Array) and b.is_a?(Array)
+    unless a.is_a?(Array) && b.is_a?(Array)
       raise(Puppet::ParseError, 'zip(): Requires array to work with')
     end
 
index 16f2709..8423300 100644 (file)
@@ -8,30 +8,46 @@ Puppet::Type.type(:file_line).provide(:ruby) do
         lines_count += 1
       end
     end
-    if resource[:match] == nil
-      found = lines_count > 0
-    else
-      match_count = count_matches(new_match_regex)
-      if resource[:append_on_no_match].to_s == 'false'
-        found = true
-      elsif resource[:replace].to_s == 'true'
-        found = lines_count > 0 && lines_count == match_count
-      else
-        found = match_count > 0
-      end
-    end
-    found
+    return found = lines_count > 0 if resource[:match].nil?
+
+    match_count = count_matches(new_match_regex)
+    found = if resource[:ensure] == :present
+              if match_count.zero?
+                if lines_count.zero? && resource[:append_on_no_match].to_s == 'false'
+                  true # lies, but gets the job done
+                elsif lines_count.zero? && resource[:append_on_no_match].to_s != 'false'
+                  false
+                else
+                  true
+                end
+              elsif resource[:replace_all_matches_not_matching_line].to_s == 'true'
+                false # maybe lies, but knows there's still work to do
+              elsif lines_count.zero?
+                resource[:replace].to_s == 'false'
+              else
+                true
+              end
+            elsif match_count.zero?
+              if lines_count.zero?
+                false
+              else
+                true
+              end
+            elsif lines_count.zero?
+              resource[:match_for_absence].to_s == 'true'
+            else
+              true
+            end
   end
 
   def create
-    unless resource[:replace].to_s != 'true' && count_matches(new_match_regex) > 0
-      if resource[:match]
-        handle_create_with_match
-      elsif resource[:after]
-        handle_create_with_after
-      else
-        handle_append_line
-      end
+    return if resource[:replace].to_s != 'true' && count_matches(new_match_regex) > 0
+    if resource[:match]
+      handle_create_with_match
+    elsif resource[:after]
+      handle_create_with_after
+    else
+      handle_append_line
     end
   end
 
@@ -51,12 +67,11 @@ Puppet::Type.type(:file_line).provide(:ruby) do
     #  file; for now assuming that this type is only used on
     #  small-ish config files that can fit into memory without
     #  too much trouble.
-    begin
-      @lines ||= File.readlines(resource[:path], :encoding => resource[:encoding])
-    rescue TypeError => e
-      # Ruby 1.8 doesn't support open_args
-      @lines ||= File.readlines(resource[:path])
-    end
+
+    @lines ||= File.readlines(resource[:path], :encoding => resource[:encoding])
+  rescue TypeError => _e
+    # Ruby 1.8 doesn't support open_args
+    @lines ||= File.readlines(resource[:path])
   end
 
   def new_after_regex
@@ -68,30 +83,35 @@ Puppet::Type.type(:file_line).provide(:ruby) do
   end
 
   def count_matches(regex)
-    lines.select{ |line| line.match(regex) }.size
+    lines.select { |line|
+      if resource[:replace_all_matches_not_matching_line].to_s == 'true'
+        line.match(regex) unless line.chomp == resource[:line]
+      else
+        line.match(regex)
+      end
+    }.size
   end
 
-  def handle_create_with_match()
+  def handle_create_with_match
     after_regex = new_after_regex
     match_regex = new_match_regex
     match_count = count_matches(new_match_regex)
 
     if match_count > 1 && resource[:multiple].to_s != 'true'
-     raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"
+      raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"
     end
 
     File.open(resource[:path], 'w') do |fh|
       lines.each do |line|
         fh.puts(match_regex.match(line) ? resource[:line] : line)
-        if match_count == 0 && after_regex
-          if after_regex.match(line)
-            fh.puts(resource[:line])
-            match_count += 1 # Increment match_count to indicate that the new line has been inserted.
-          end
+        next unless match_count.zero? && after_regex
+        if after_regex.match(line)
+          fh.puts(resource[:line])
+          match_count += 1 # Increment match_count to indicate that the new line has been inserted.
         end
       end
 
-      if (match_count == 0)
+      if match_count.zero?
         fh.puts(resource[:line])
       end
     end
@@ -105,7 +125,7 @@ Puppet::Type.type(:file_line).provide(:ruby) do
       raise Puppet::Error, "#{after_count} lines match pattern '#{resource[:after]}' in file '#{resource[:path]}'. One or no line must match the pattern."
     end
 
-    File.open(resource[:path],'w') do |fh|
+    File.open(resource[:path], 'w') do |fh|
       lines.each do |line|
         fh.puts(line)
         if after_regex.match(line)
@@ -113,7 +133,7 @@ Puppet::Type.type(:file_line).provide(:ruby) do
         end
       end
 
-      if (after_count == 0)
+      if after_count.zero?
         fh.puts(resource[:line])
       end
     end
@@ -123,25 +143,26 @@ Puppet::Type.type(:file_line).provide(:ruby) do
     match_regex = new_match_regex
     match_count = count_matches(match_regex)
     if match_count > 1 && resource[:multiple].to_s != 'true'
-     raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"
+      raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"
     end
 
     local_lines = lines
-    File.open(resource[:path],'w') do |fh|
-      fh.write(local_lines.reject{ |line| match_regex.match(line) }.join(''))
+    File.open(resource[:path], 'w') do |fh|
+      fh.write(local_lines.reject { |line| match_regex.match(line) }.join(''))
     end
   end
 
   def handle_destroy_line
     local_lines = lines
-    File.open(resource[:path],'w') do |fh|
-      fh.write(local_lines.reject{ |line| line.chomp == resource[:line] }.join(''))
+    File.open(resource[:path], 'w') do |fh|
+      fh.write(local_lines.reject { |line| line.chomp == resource[:line] }.join(''))
     end
   end
 
   def handle_append_line
-    File.open(resource[:path],'w') do |fh|
-      lines.each do |line|
+    local_lines = lines
+    File.open(resource[:path], 'w') do |fh|
+      local_lines.each do |line|
         fh.puts(line)
       end
       fh.puts(resource[:line])
index fe1e5aa..60cfa64 100644 (file)
@@ -1,5 +1,5 @@
 Puppet::Type.newtype(:anchor) do
-  desc <<-'ENDOFDESC'
+  desc <<-'DESCRIPTION'
   A simple resource type intended to be used as an anchor in a composite class.
 
   In Puppet 2.6, when a class declares another class, the resources in the
@@ -32,10 +32,10 @@ Puppet::Type.newtype(:anchor) do
       class { 'ntp': } -> class { 'mcollective': }
       class { 'mcollective': } -> class { 'ntp': }
 
-  ENDOFDESC
+  DESCRIPTION
 
   newparam :name do
-    desc "The name of the anchor resource."
+    desc 'The name of the anchor resource.'
   end
 
   def refresh
index b2357b8..14650fe 100644 (file)
@@ -1,6 +1,5 @@
 Puppet::Type.newtype(:file_line) do
-
-  desc <<-EOT
+  desc <<-DOC
     Ensures that a given line is contained within a file.  The implementation
     matches the full line, including whitespace at the beginning and end.  If
     the line is not contained in the given file, Puppet will append the line to
@@ -34,12 +33,16 @@ Puppet::Type.newtype(:file_line) do
     In this code example match will look for a line beginning with export
     followed by HTTP_PROXY and replace it with the value in line.
 
-    Match Example With `ensure => absent`:
+    Examples With `ensure => absent`:
+
+    This type has two behaviors when `ensure => absent` is set.
+
+    One possibility is to set `match => ...` and `match_for_absence => true`,
+    as in the following example:
 
         file_line { 'bashrc_proxy':
           ensure            => absent,
           path              => '/etc/bashrc',
-          line              => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
           match             => '^export\ HTTP_PROXY\=',
           match_for_absence => true,
         }
@@ -48,11 +51,27 @@ Puppet::Type.newtype(:file_line) do
     followed by HTTP_PROXY and delete it.  If multiple lines match, an
     error will be raised unless the `multiple => true` parameter is set.
 
+    Note that the `line => ...` parameter would be accepted BUT IGNORED in
+    the above example.
+
+    The second way of using `ensure => absent` is to specify a `line => ...`,
+    and no match:
+
+        file_line { 'bashrc_proxy':
+          ensure => absent,
+          path   => '/etc/bashrc',
+          line   => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+        }
+
+    Note that when ensuring lines are absent this way, the default behavior
+    this time is to always remove all lines matching, and this behavior
+    can't be disabled.
+
     Encoding example:
 
         file_line { "XScreenSaver":
           ensure   => present,
-          path     => '/root/XScreenSaver'
+          path     => '/root/XScreenSaver',
           line     => "*lock: 10:00:00",
           match    => '^*lock:',
           encoding => "iso-8859-1",
@@ -66,7 +85,7 @@ Puppet::Type.newtype(:file_line) do
 
     **Autorequires:** If Puppet is managing the file that will contain the line
     being managed, the file_line resource will autorequire that file.
-  EOT
+  DOC
 
   ensurable do
     defaultvalues
@@ -78,29 +97,29 @@ Puppet::Type.newtype(:file_line) do
   end
 
   newparam(:match) do
-    desc 'An optional ruby regular expression to run against existing lines in the file.' +
-         ' If a match is found, we replace that line rather than adding a new line.' +
-         ' A regex comparison is performed against the line value and if it does not' +
+    desc 'An optional ruby regular expression to run against existing lines in the file.' \
+         ' If a match is found, we replace that line rather than adding a new line.' \
+         ' A regex comparison is performed against the line value and if it does not' \
          ' match an exception will be raised.'
   end
 
   newparam(:match_for_absence) do
-    desc 'An optional value to determine if match should be applied when ensure => absent.' +
-         ' If set to true and match is set, the line that matches match will be deleted.' +
-         ' If set to false (the default), match is ignored when ensure => absent.' +
+    desc 'An optional value to determine if match should be applied when ensure => absent.' \
+         ' If set to true and match is set, the line that matches match will be deleted.' \
+         ' If set to false (the default), match is ignored when ensure => absent.' \
          ' When `ensure => present`, match_for_absence is ignored.'
     newvalues(true, false)
     defaultto false
   end
 
   newparam(:multiple) do
-    desc 'An optional value to determine if match can change multiple lines.' +
+    desc 'An optional value to determine if match can change multiple lines.' \
          ' If set to false, an exception will be raised if more than one line matches'
     newvalues(true, false)
   end
 
   newparam(:after) do
-    desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)' +
+    desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)' \
          ' This is also takes a regex.'
   end
 
@@ -131,6 +150,13 @@ Puppet::Type.newtype(:file_line) do
     defaultto true
   end
 
+  newparam(:replace_all_matches_not_matching_line) do
+    desc 'Configures the behavior of replacing all lines in a file which match the `match` parameter regular expression, regardless of whether the specified line is already present in the file.'
+
+    newvalues(true, false)
+    defaultto false
+  end
+
   newparam(:encoding) do
     desc 'For files that are not UTF-8 encoded, specify encoding such as iso-8859-1'
     defaultto 'UTF-8'
@@ -148,13 +174,19 @@ Puppet::Type.newtype(:file_line) do
   end
 
   validate do
+    if self[:replace_all_matches_not_matching_line].to_s == 'true' && self[:multiple].to_s == 'false'
+      raise(Puppet::Error, 'multiple must be true when replace_all_matches_not_matching_line is true')
+    end
+    if self[:replace_all_matches_not_matching_line].to_s == 'true' && self[:replace].to_s == 'false'
+      raise(Puppet::Error, 'replace must be true when replace_all_matches_not_matching_line is true')
+    end
     unless self[:line]
-      unless (self[:ensure].to_s == 'absent') and (self[:match_for_absence].to_s == 'true') and self[:match]
-        raise(Puppet::Error, "line is a required attribute")
+      unless (self[:ensure].to_s == 'absent') && (self[:match_for_absence].to_s == 'true') && self[:match]
+        raise(Puppet::Error, 'line is a required attribute')
       end
     end
     unless self[:path]
-      raise(Puppet::Error, "path is a required attribute")
+      raise(Puppet::Error, 'path is a required attribute')
     end
   end
 end
index 1ee70ab..66abac1 100644 (file)
@@ -22,4 +22,5 @@ gettext:
   # Patterns for +Dir.glob+ used to find all files that might contain
   # translatable content, relative to the project root directory
   source_files:
+      - './lib/**/*.rb'
   
index 0526272..48a794b 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "puppetlabs-stdlib",
-  "version": "4.19.0",
+  "version": "5.2.0",
   "author": "puppetlabs",
   "summary": "Standard library of resources for Puppet modules.",
   "license": "Apache-2.0",
@@ -15,7 +15,6 @@
     {
       "operatingsystem": "RedHat",
       "operatingsystemrelease": [
-        "4",
         "5",
         "6",
         "7"
@@ -24,7 +23,6 @@
     {
       "operatingsystem": "CentOS",
       "operatingsystemrelease": [
-        "4",
         "5",
         "6",
         "7"
@@ -33,7 +31,6 @@
     {
       "operatingsystem": "OracleLinux",
       "operatingsystemrelease": [
-        "4",
         "5",
         "6",
         "7"
@@ -42,8 +39,6 @@
     {
       "operatingsystem": "Scientific",
       "operatingsystemrelease": [
-        "4",
-        "5",
         "6",
         "7"
       ]
     {
       "operatingsystem": "SLES",
       "operatingsystemrelease": [
-        "10 SP4",
-        "11 SP1",
-        "12"
+        "11",
+        "12",
+        "15"
       ]
     },
     {
       "operatingsystem": "Debian",
       "operatingsystemrelease": [
-        "6",
-        "7",
-        "8"
+        "8",
+        "9"
       ]
     },
     {
       "operatingsystem": "Ubuntu",
       "operatingsystemrelease": [
         "14.04",
-        "16.04"
+        "16.04",
+        "18.04"
       ]
     },
     {
     {
       "operatingsystem": "Windows",
       "operatingsystemrelease": [
-        "Server 2003",
-        "Server 2003 R2",
-        "Server 2008",
-        "Server 2008 R2",
-        "Server 2012",
-        "Server 2012 R2",
+        "2008",
+        "2008 R2",
+        "2012",
+        "2012 R2",
+        "2016",
         "7",
-        "8"
+        "8.1",
+        "10"
       ]
     },
     {
   "requirements": [
     {
       "name": "puppet",
-      "version_requirement": ">=2.7.20 < 6.0.0"
+      "version_requirement": ">= 2.7.20 < 7.0.0"
     }
   ],
-  "description": "Standard Library for Puppet Modules"
+  "description": "Standard Library for Puppet Modules",
+  "pdk-version": "1.7.1",
+  "template-url": "https://github.com/puppetlabs/pdk-templates/",
+  "template-ref": "heads/master-0-g6814a87"
 }
index ae74d25..21aee12 100644 (file)
@@ -2,28 +2,28 @@
 
 #### 目次
 
-1. [モジュールの説明 - モジュールの機能とその有益性](#モジュールの説明)
-1. [セットアップ - stdlib導入の基本](#セットアップ)
-1. [使用 - 設定オプションと追加機能](#使用)
-1. [リファレンス - モジュールの機能と動作について](#リファレンス)
-    1. [クラス](#クラス)
-    1. [å®\9a義ã\82¿ã\82¤ã\83\97](#å®\9a義ã\82¿ã\82¤ã\83\97)
-    1. [データタイプ](#データタイプ)
+1. [説明 - モジュールの機能とその有益性](#module-description)
+1. [セットアップ - stdlib導入の基本](#setup)
+1. [使用方法 - 設定オプションと追加機能](#usage)
+1. [参考 - モジュールの機能と動作について](#reference)
+    1. [クラス](#classes)
+    1. [å®\9a義ã\81§ã\81\8dã\82\8bã\82¿ã\82¤ã\83\97](#defined-types)
+    1. [データタイプ](#data-types)
     1. [Facts](#facts)
-    1. [関数](#関数)
-1. [制約 - OS互換性など](#制約)
-1. [開発 - モジュール貢献についてのガイド](#開発)
-1. [コントリビュータ](#コントリビュータ)
+    1. [関数](#functions)
+1. [制約事項 - OSの互換性など](#limitations)
+1. [開発 - モジュール貢献についてのガイド](#development)
+1. [コントリビュータ](#contributors)
 
 
-## モジュールの説明
+## モジュールの概要
 
\81\93ã\81®ã\83¢ã\82¸ã\83¥ã\83¼ã\83«ã\81§ã\81¯ã\80\81Puppetã\83¢ã\82¸ã\83¥ã\83¼ã\83«ã\81®ã\83ªã\82½ã\83¼ã\82¹ã\81® 標準ライブラリを提供しています。Puppetモジュールでは、この標準ライブラリを広く使用しています。stdlibモジュールは、以下のリソースをPuppetに追加します。
\81\93ã\81®ã\83¢ã\82¸ã\83¥ã\83¼ã\83«ã\81§ã\81¯ã\80\81Puppetã\83¢ã\82¸ã\83¥ã\83¼ã\83«ã\83ªã\82½ã\83¼ã\82¹ã\81®標準ライブラリを提供しています。Puppetモジュールでは、この標準ライブラリを広く使用しています。stdlibモジュールは、以下のリソースをPuppetに追加します。
 
  * ステージ
  * Facts
  * 関数
- * å®\9a義ã\82¿ã\82¤ã\83\97
+ * å®\9a義ã\81\95ã\82\8cã\81\9få\9e\8b
  * データタイプ
  * プロバイダ
 
 
 ## セットアップ
 
-stdlibモジュールを[インストール](https://docs.puppet.com/puppet/latest/modules_installing.html)し、この標準ライブラリの関数、Facts、リソースをPuppetに追加します。
+stdlibモジュールを[インストール](https://puppet.com/docs/puppet/latest/modules_installing.html)し、この標準ライブラリの関数、Facts、リソースをPuppetに追加します。
 
-stdlibに依存するモジュールを記述する場合は、必ずmetadata.jsonで[依存関係を特定](https://docs.puppet.com/puppet/latest/modules_metadata.html#specifying-dependencies)してください。
+stdlibに依存するモジュールを記述する場合は、必ずmetadata.jsonで[依存関係を特定](https://puppet.com/docs/puppet/latest/modules_metadata.html#specifying-dependencies-in-modules)してください。
 
-## 使用
+## 使用方法
 
 stdlibのほとんどの機能は、Puppetに自動的にロードされます。Puppetで標準化されたランステージを使用するには、`include stdlib`を用いてマニフェスト内でこのクラスを宣言してください。
 
@@ -43,7 +43,7 @@ stdlibのほとんどの機能は、Puppetに自動的にロードされます
 
 `stdlib::stages`クラスは、インフラストラクチャ、言語ランタイム、アプリケーションレイヤの配備に関する各種のランステージを宣言します。ハイレベルステージは、以下のとおりです(順番どおり)。
 
-  * setup
+  * セットアップ
   * main
   * runtime
   * setup_infra
@@ -63,12 +63,12 @@ node default {
 
 ## リファレンス
 
-* [パブリッククラス][]
-* [プライベートクラス][]
-* [å®\9a義ã\82¿ã\82¤ã\83\97][]
-* [データタイプ][]
-* [Facts][]
-* [関数][]
+* [パブリッククラス](#public-classes)
+* [プライベートクラス](#private-classes)
+* [å®\9a義ã\81\95ã\82\8cã\81\9få\9e\8b](#defined-types)
+* [データタイプ](#data-types)
+* [Facts](#facts)
+* [関数](#functions)
 
 ### クラス
 
@@ -80,7 +80,7 @@ node default {
 
 * `stdlib::stages`: Puppetのランステージの標準セットを管理します。
 
-### å®\9a義ã\82¿ã\82¤ã\83\97
+### å®\9a義ã\81\95ã\82\8cã\81\9få\9e\8b
 
 #### `file_line`
 
@@ -115,19 +115,51 @@ file_line { 'bashrc_proxy':
 
 上の例では、`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が行内の値に置き換えられます。
 
- `ensure => absent`を用いたマッチ例:
+マッチ例:
+
+```puppet
+file_line { 'bashrc_proxy':
+  ensure             => present,
+  path               => '/etc/bashrc',
+  line               => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+  match              => '^export\ HTTP_PROXY\=',
+  append_on_no_match => false,
+}
+```
+
+このコードの例では、`match`によってexportで始まり'HTTP_PROXY'が続く行が検索され、その行が行内の値に置き換えられます。マッチするものが見つからない場合、ファイルは変更されません。
+
+ `ensure => absent`の例:
+
+`ensure => absent`を設定する場合に、このタイプの動作には2通りがあります。
+
+1つは`match => ...`と`match_for_absence => true`の設定です。`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が削除されます。複数の行がマッチし、`multiple => true`パラメータが設定されていない場合は、エラーが生じます。
+
+この例で`line => ...`パラメータは承認されますが無視されます。
+
+例: 
 
 ```puppet
 file_line { 'bashrc_proxy':
   ensure            => absent,
   path              => '/etc/bashrc',
-  line              => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
   match             => '^export\ HTTP_PROXY\=',
   match_for_absence => true,
 }
 ```
 
-上の例では、`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が削除されます。複数の行がマッチし、`multiple => true`パラメータが設定されていない場合は、エラーが生じます。
+`ensure => absent`を設定する場合のもう1つの動作は、`line => ...`の指定と一致なしです。行が存在しないことを確認した場合のデフォルトの動作では、マッチするすべての行を削除します。この動作を無効にすることはできません。
+
+例: 
+
+```puppet
+file_line { 'bashrc_proxy':
+  ensure => absent,
+  path   => '/etc/bashrc',
+  line   => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+}
+```
+
 
 エンコード例:
 
@@ -145,89 +177,97 @@ file_line { "XScreenSaver":
 
 **Autorequire:** Puppetが管理しているファイルに、管理対象となる行が含まれている場合は、`file_line`リソースと当該ファイルの暗黙的な依存関係が設定されます。
 
-##### パラメータ
+**パラメータ** 
 
 パラメータは、別途説明がない限り、すべてオプションです。
 
-* `after`
-
-  このパラメータで指定された行の後に、Puppetが正規表現を用いて新規の行を追加します(既存の行が規定の位置に追加されます)。
-
-  値: 正規表現を含む文字列
-  
-  デフォルト値: `undef`
-  
-* `encoding`
-  
-  適正なファイルエンコードを指定します。
-
-  値: 有効なRuby文字エンコードを指定する文字列
-  
-  デフォルト: 'UTF-8'
-
-* `ensure`: リソースが存在するかどうかを指定します。
-
-  値: 'present'、'absent'
-  
-  デフォルト値: 'present'
-  
-* `line`
-
-  **必須**
-  
-  `path`パラメータにより位置を示されたファイルに追加する行を設定します。
-    
-  値: 文字列
-  
-* `match`
-
-  ファイル内の既存の行と比較する正規表現を指定します。マッチが見つかった場合、新規の行を追加するかわりに、置き換えられます。正規表現の比較は行の値に照らして行われ、マッチしない場合は、例外が発生します。
-  
-  値: 正規表現を含む文字列
-  
-  デフォルト値: `undef`
-  
-
-* `match_for_absence`
-
-  `ensure => absent`の場合にマッチを適用するかどうかを指定します。`true`に設定してマッチを設定すると、マッチする行が削除されます。`false`に設定すると(デフォルト)、`ensure => absent`の場合にマッチが無視され、代わりに`line`の値が使用されます。`ensure => present`になっている場合は、このパラメータは無視されます。
-  
-  ブーリアン
-  
-  デフォルト値: `false`
-  
-* `multiple`
-
-  `match`および`after`により複数の行を変更できるかどうかを指定します。`false`に設定すると、複数の行がマッチする場合に例外が発生します。
-  
-  値: `true`、`false`
-  
-  デフォルト値: `false`
-  
-  
-* `name`
-
-  リソースの名称として使用する名前を指定します。リソースのnamevarをリソースの規定の`title`と異なるものにしたい場合は、`name`で名前を指定します。 
-  
-  値: 文字列
-  
-  デフォルト値: タイトルの値
-  
-* `path`
-
-  **必須**
-  
-  `line`で指定された行を確保するファイルを指定します。 
-  
-  値: 当該ファイルの絶対パスを指定する文字列
-  
-* `replace`
-
-  `match`パラメータとマッチする既存の行を上書きするかどうかを指定します。`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。
-  
-  ブーリアン
-  
-  デフォルト値: `true`
+##### `after`
+
+このパラメータで指定された行の後に、Puppetが正規表現を用いて新規の行を追加します(既存の行が規定の位置に追加されます)。
+
+値: 正規表現を含む文字列
+
+デフォルト値: `undef`。
+
+##### `encoding`
+
+適正なファイルエンコードを指定します。
+
+値: 有効なRuby文字エンコードを指定する文字列
+
+デフォルト: 'UTF-8'
+
+##### `ensure`: リソースが存在するかどうかを指定します。
+
+値: 'present'、'absent'
+
+デフォルト値: 'present'。
+
+##### `line`
+
+**必須**
+
+`path`パラメータにより位置を示されたファイルに追加する行を設定します。
+
+値: 文字列
+
+##### `match`
+
+ファイル内の既存の行と比較する正規表現を指定します。マッチが見つかった場合、新規の行を追加する代わりに、置き換えられます。
+
+値: 正規表現を含む文字列
+
+デフォルト値: `undef`。
+
+
+##### `match_for_absence`
+
+`ensure => absent`の場合にマッチを適用するかどうかを指定します。`true`に設定してマッチを設定すると、マッチする行が削除されます。`false`に設定すると(デフォルト)、`ensure => absent`の場合にマッチが無視され、代わりに`line`の値が使用されます。`ensure => present`になっている場合は、このパラメータは無視されます。
+
+ブーリアン。
+
+デフォルト値: `false`。
+
+##### `multiple`
+
+`match`および`after`により複数の行を変更できるかどうかを指定します。`false`に設定すると、file_lineは1つの行のみ置き換えることができますが、複数の行を置き換えようとするとエラーが発生します。`true`に設定すると、file_lineは1つまたは複数の行を置き換えることができます。
+
+値: `true`、`false`。
+
+デフォルト値: `false`。
+
+
+##### `name`
+
+リソースの名称として使用する名前を指定します。リソースのnamevarをリソースの規定の`title`と異なるものにしたい場合は、`name`で名前を指定します。
+
+値: 文字列
+
+デフォルト値: タイトルの値
+
+##### `path`
+
+**必須**
+
+`line`で指定された行を確保するファイルを指定します。
+
+値: 当該ファイルの絶対パスを指定する文字列
+
+##### `replace`
+
+`match`パラメータとマッチする既存の行をリソースで上書きするかどうかを指定します。`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。
+
+`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。
+
+ブーリアン。
+
+デフォルト値: `true`。
+
+##### `replace_all_matches_not_matching_line`
+
+`line`がファイルにすでに存在する場合でも、`match`パラメータに一致するすべての行が置き換えられます。
+
+デフォルト値: `false`。
 
 ### データタイプ
 
@@ -255,14 +295,34 @@ C:\\WINDOWS\\System32
 ../relative_path
 ```
 
+#### `Stdlib::Ensure::Service`
+
+サービスリソースの使用可能なensure値と一致します。
+
+使用可能なインプット例:
+
+```shell
+stopped
+running
+```
+
+使用不可能なインプット例:
+
+```shell
+true
+false
+```
+
 #### `Stdlib::Httpsurl`
 
-HTTPS URLに一致します。
+HTTPS URLに一致します。この一致では、大文字と小文字は区別されません。
 
 使用可能なインプット例:
 
 ```shell
 https://hello.com
+
+HTTPS://HELLO.COM
 ```
 
 使用不可能なインプット例:
@@ -273,7 +333,7 @@ httds://notquiteright.org`
 
 #### `Stdlib::Httpurl`
 
-HTTPSã\81\8aã\82\88ã\81³HTTP URLã\81®ä¸¡æ\96¹ã\81«ä¸\80è\87´ã\81\97ã\81¾ã\81\99
+HTTPSã\81¨HTTPã\81®ä¸¡æ\96¹ã\81®URLã\81«ä¸\80è\87´ã\81\97ã\81¾ã\81\99ã\80\82ã\81\93ã\81®ä¸\80è\87´ã\81§ã\81¯ã\80\81大æ\96\87å­\97ã\81¨å°\8fæ\96\87å­\97ã\81¯å\8cºå\88¥ã\81\95ã\82\8cã\81¾ã\81\9bã\82\93
 
 使用可能なインプット例:
 
@@ -281,6 +341,8 @@ HTTPSおよびHTTP URLの両方に一致します。
 https://hello.com
 
 http://hello.com
+
+HTTP://HELLO.COM
 ```
 
 使用不可能なインプット例:
@@ -289,9 +351,13 @@ http://hello.com
 httds://notquiteright.org
 ```
 
+#### `Stdlib::MAC`
+
+[RFC5342](https://tools.ietf.org/html/rfc5342)で定義されるMACアドレスに一致します。
+
 #### `Stdlib::Unixpath`
 
-Unixオペレーティングシステムのパスに一致します。
+Unixオペレーティングシステムの絶対パスに一致します。
 
 使用可能なインプット例:
 
@@ -305,13 +371,45 @@ Unixオペレーティングシステムのパスに一致します。
 
 ```shell
 C:/whatever
+
+some/path
+
+../some/other/path
+```
+
+#### `Stdlib::Filemode`
+
+1から4までの数字とシンボリックファイルモードからなる8進ファイルモードに一致します。
+
+使用可能なインプット例:
+
+```shell
+0644
+```
+
+```shell
+1777
+```
+
+```shell
+a=Xr,g=w
+```
+
+使用不可能なインプット例:
+
+```shell
+x=r,a=wx
+```
+
+```shell
+0999
 ```
 
 #### `Stdlib::Windowspath`
 
 Windowsオペレーティングシステムのパスに一致します。
 
-使用可能なインプット例: 
+使用可能なインプット例:
 
 ```shell
 C:\\WINDOWS\\System32
@@ -321,12 +419,277 @@ C:\\
 \\\\host\\windows
 ```
 
-使用不可能なインプット例:
+有効な値: Windowsのファイルパスに一致します。
+
+#### `Stdlib::Filesource`
+
+Puppetファイルタイプのソースパラメータの有効な値のパスに一致します。
+
+使用可能なインプット例:
 
 ```shell
-/usr2/username/bin:/usr/local/bin:/usr/bin:.
+http://example.com
+
+https://example.com
+
+file:///hello/bla
+```
+
+有効な値: ファイルパス。
+
+#### `Stdlib::Fqdn`
+
+完全修飾ドメイン名(FQDN)のパスに一致します。
+
+使用可能なインプット例:
+
+```shell
+localhost
+
+example.com
+
+www.example.com
+```
+有効な値: サーバーのドメイン名。
+
+#### `Stdlib::Host`
+
+有効なホストに一致します。これには、有効なipv4、ipv6、またはfqdnを含みます。
+
+使用可能なインプット例:
+
+```shell
+localhost
+
+www.example.com
+
+192.0.2.1
+```
+
+有効な値: IPアドレスまたはドメイン名。
+
+#### `Stdlib::Port`
+
+有効なTCP/UDPポート番号に一致します。
+
+使用可能なインプット例:
+
+```shell
+80
+
+443
+
+65000
+```
+
+有効な値: 整数。
+
+#### `Stdlib::Port::Privileged`
+
+有効なTCP/UDP特権ポート(1024未満)に一致します。
+
+使用可能なインプット例:
+
+```shell
+80
+
+443
+
+1023
+```
+
+有効な値: 1024未満の数。
+
+#### `Stdlib::Port::Unprivileged`
+
+有効なTCP/UDP特権ポート(1024以上)に一致します。
+
+使用可能なインプット例:
+
+```shell
+1024
+
+1337
+
+65000
+
+```
+
+有効な値: 1024以上の数。
+
+#### `Stdlib::Base32`
+
+有効なbase32文字列のパスに一致します。
+
+使用可能なインプット例:
+
+```shell
+ASDASDDASD3453453
+
+asdasddasd3453453=
+
+ASDASDDASD3453453==
 ```
 
+有効な値: base32文字列。
+
+#### `Stdlib::Base64`
+
+有効なbase64文字列のパスに一致します。
+
+使用可能なインプット例:
+
+```shell
+asdasdASDSADA342386832/746+=
+
+asdasdASDSADA34238683274/6+
+
+asdasdASDSADA3423868327/46+==
+```
+
+有効な値: base64文字列。
+
+#### `Stdlib::Ipv4`
+
+有効なIPv4アドレスに一致します。
+
+使用可能なインプット例:
+
+```shell
+0.0.0.0
+
+192.0.2.1
+
+127.0.0.1
+```
+
+有効な値: IPv4アドレス。
+
+#### `Stdlib::Ipv6`
+
+有効なIPv6アドレスに一致します。
+
+使用可能なインプット例:
+
+```shell
+2001:0db8:85a3:0000:0000:8a2e:0370:7334
+
+2001:db8::
+
+2001:db8::80
+```
+
+有効な値: IPv6アドレス。
+
+#### `Stdlib::Ip_address`
+
+有効なIPv4またはIPv6アドレスに一致します。
+
+使用可能なインプット例:
+
+```shell
+0.0.0.0
+
+127.0.0.1
+
+fe80:0000:0000:0000:0204:61ff:fe9d:f156
+```
+
+有効な値: IPアドレス。
+
+#### `Stdlib::IP::Address`
+
+IPv4とIPv6両方のアドレスを含む、任意のIPアドレスに一致します。CIDRフォーマットのIPv4アドレスで使用されるアドレスプレフィックスの有無に関わらず一致します。
+
+例:
+
+```
+'127.0.0.1' =~ Stdlib::IP::Address                                # true
+'10.1.240.4/24' =~ Stdlib::IP::Address                            # true
+'52.10.10.141' =~ Stdlib::IP::Address                             # true
+'192.168.1' =~ Stdlib::IP::Address                                # false
+'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address  # true
+'FF01:0:0:0:0:0:0:101' =~ Stdlib::IP::Address                     # true
+```
+
+#### `Stdlib::IP::Address::V4`
+
+CIDRプレフィックスの有無に関わらず、ドット区切りの4つの10進数で表現されたIPv4アドレスで構成される任意の文字列に一致します。省略形(192.168.1など)には一致しません。省略形はドキュメンテーションが不十分で、サポートにばらつきがあるためです。
+
+例:
+
+```
+'127.0.0.1' =~ Stdlib::IP::Address::V4                                # true
+'10.1.240.4/24' =~ Stdlib::IP::Address::V4                            # true
+'192.168.1' =~ Stdlib::IP::Address::V4                                # false
+'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address::V4  # false
+'12AB::CD30:192.168.0.1' =~ Stdlib::IP::Address::V4                   # false
+```
+
+有効な値: IPv4アドレス。
+
+#### `Stdlib::IP::Address::V6`
+
+アドレスプレフィックスの有無に関わらず、RFC 2373に規定された任意のフォーマットで記述されたIPv6アドレスを構成する任意の文字列に一致します。
+
+例:
+
+```
+'127.0.0.1' =~ Stdlib::IP::Address::V6                                # false
+'10.1.240.4/24' =~ Stdlib::IP::Address::V6                            # false
+'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address::V6  # true
+'FF01:0:0:0:0:0:0:101' =~ Stdlib::IP::Address::V6                     # true
+'FF01::101' =~ Stdlib::IP::Address::V6                                # true
+```
+
+有効な値: IPv6アドレス。
+
+#### `Stdlib::IP::Address::Nosubnet`
+
+`Stdlib::IP::Address`エイリアスと同じものに一致しますが、アドレスプレフィックスを含むアドレスには一致しません(たとえば、'192.168.0.6'には一致しますが、'192.168.0.6/24'には一致しません)。
+
+有効な値: サブネットを持たないIPアドレス。
+
+#### `Stdlib::IP::Address::V4::CIDR`
+
+CIDR形式のIPv4アドレスに一致します。アドレスにアドレスプレフィックスが含まれている場合にのみ一致します(例えば、'192.168.0.6/24'には一致しますが、'192.168.0.6'には一致しません)。
+
+有効な値: CIDRが提供されたIPv4アドレス、たとえば'192.186.8.101/105'など。これは、'192.186.8.101'~'192.168.8.105'を含むすべてに一致します。
+
+#### `Stdlib::IP::Address::V4::Nosubnet`
+
+アドレスプレフィックスを含まないIPv4アドレスに一致します(たとえば、'192.168.0.6'には一致しますが、'192.168.0.6/24'には一致しません)。
+
+有効な値: サブネットを持たないIPv4アドレス。
+
+#### `Stdlib::IP::Address::V6::Full`
+
+[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.2に規定された「好ましい形式」のIPv6アドレスに一致します。[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.3に規定されたアドレスプレフィックスの有無に関わらず一致します。
+
+#### `Stdlib::IP::Address::V6::Alternate`
+
+[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.2に規定された「代替形式」(最後の2つの16ビット断片をドット区切りの4つの10進数で表現できる)のIPv6アドレスに一致します。[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.3に規定されたアドレスプレフィックスの有無に関わらず一致します。
+
+#### `Stdlib::IP::Address::V6::Compressed`
+
+[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.2に規定された0を圧縮する記法である`::`を含む可能性のあるIPv6アドレスに一致します。[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.3に規定されたアドレスプレフィックスの有無に関わらず一致します。
+
+#### `Stdlib::IP::Address::V6::Nosubnet`
+
+`Stdlib::IP::Address::V6::Nosubnet::Full`、`Stdlib::IP::Address::V6::Nosubnet::Alternate`、および`Stdlib::IP::Address::V6::Nosubnet::Compressed`を許可するエイリアス。
+
+#### `Stdlib::IP::Address::V6::Nosubnet::Full`
+
+[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.2.1に規定された「好ましい形式」のIPv6アドレスに一致します。[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.3に規定されたアドレスプレフィックスを持つアドレスには一致しません。
+
+#### `Stdlib::IP::Address::V6::Nosubnet::Alternate`
+
+[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.2.1に規定された「代替形式」(最後の2つの16ビット断片をドット区切りの4つの10進数で表現できる)のIPv6アドレスに一致します。[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.3に規定されたアドレスプレフィックスを持たないアドレスにのみ一致します。
+
+#### `Stdlib::IP::Address::V6::Nosubnet::Compressed`
+
+[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.2.2に規定された0を圧縮する記法である`::`を含む可能性のあるIPv6アドレスに一致します。[RFC 2373](https://www.ietf.org/rfc/rfc2373.txt)の2.3に規定されたアドレスプレフィックスを持たないアドレスにのみ一致します。
+
 ### Facts
 
 #### `package_provider`
@@ -379,6 +742,8 @@ Puppetがこのシステムのサービス管理に使用するデフォルト
 
 #### `abs`
 
+**非推奨:** この関数は、Puppet 6.0.0で、内蔵の[`abs`](https://puppet.com/docs/puppet/latest/function.html#abs)関数に置き換えられました。
+
 数字の絶対値を返します。たとえば、'-34.56'は'34.56'になります。
 
 引数: 整数値または浮動小数点値のいずれかの単一の引数。
@@ -389,6 +754,19 @@ Puppetがこのシステムのサービス管理に使用するデフォルト
 
 任意のオブジェクトを、そのオブジェクトを含む配列に変換します。空の引数リストは空の配列に変換されます。ハッシュは、キーと値が交互になった配列に変換されます。配列は変換されません。
 
+Puppet 5.0.0以降では、タイプシステムを使用してほとんどすべてのデータタイプの新しい値を作成できます。内蔵の[`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple)関数を使用して新しい配列を作成できます。
+
+    $hsh = {'key' => 42, 'another-key' => 100}
+    notice(Array($hsh))
+
+`[['key', 42], ['another-key', 100]]`を通知します
+
+配列のデータタイプには、"まだ配列でない場合は配列を作成する"という特別なモードもあります。
+
+    notice(Array({'key' => 42, 'another-key' => 100}, true))
+
+`true`フラグはハッシュが配列に変換されないようにするため、`[{'key' => 42, 'another-key' => 100}]`を通知します。
+
 *タイプ*: 右辺値
 
 #### `any2bool`
@@ -402,6 +780,8 @@ Puppetがこのシステムのサービス管理に使用するデフォルト
 * undef値は`false`を返します。
 * それ以外はすべて`true`を返します。
 
+詳細については、内蔵の[`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)を参照してください。
+
 *タイプ*: 右辺値
 
 #### `assert_private`
@@ -424,30 +804,41 @@ assert_private("You're not supposed to do that!")
 
 下位互換性を得るには、`method`を`default`に設定します(指定されていない場合)。
 
-*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+> **注:** この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+Puppet 4.8.0以降では、ベース64 でエンコードされた文字列の生成に、`バイナリ`データタイプを使用できます。
+
+詳細については、内蔵の[`String.new`](https://puppet.com/docs/puppet/latest/function.html#binary-value-to-string)関数と[`Binary.new`](https://puppet.com/docs/puppet/latest/function.html#creating-a-binary)関数を参照してください。
+
+バイナリ(非UTF-8)コンテンツを含むファイルの読み取りについては、内蔵の[`binary_file`](https://puppet.com/docs/puppet/latest/function.html#binary_file)関数を参照してください。
+
+    # encode a string as if it was binary
+    $encodestring = String(Binary('thestring', '%s'))
+    # decode a Binary assuming it is an UTF-8 String
+    $decodestring = String(Binary("dGhlc3RyaW5n"), "%s")
 
 **例:**
 
 ```puppet
 base64('encode', 'hello')
 base64('encode', 'hello', 'default')
-# リターン: "aGVsbG8=\n"
+# return: "aGVsbG8=\n"
 
 base64('encode', 'hello', 'strict')
-# リターン: "aGVsbG8="
+# return: "aGVsbG8="
 
 base64('decode', 'aGVsbG8=')
 base64('decode', 'aGVsbG8=\n')
 base64('decode', 'aGVsbG8=', 'default')
 base64('decode', 'aGVsbG8=\n', 'default')
 base64('decode', 'aGVsbG8=', 'strict')
-# リターン: "hello"
+# return: "hello"
 
 base64('encode', 'https://puppetlabs.com', 'urlsafe')
-# リターン: "aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ=="
+# return: "aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ=="
 
 base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe')
-# リターン: "https://puppetlabs.com"
+# return: "https://puppetlabs.com"
 ```
 
 *タイプ*: 右辺値
@@ -456,9 +847,11 @@ base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe')
 
 パスの`basename`を返します。オプションの引数で拡張子が外れます。例:
 
-  * ('/path/to/a/file.ext')は'file.ext'を返します。
-  * ('relative/path/file.ext')は'file.ext'を返します。
-  * ('/path/to/a/file.ext', '.ext')は'file'を返します。
+```puppet
+basename('/path/to/a/file.ext')            => 'file.ext'
+basename('relative/path/file.ext')         => 'file.ext'
+basename('/path/to/a/file.ext', '.ext')    => 'file'
+```
 
 *タイプ*: 右辺値
 
@@ -468,10 +861,16 @@ base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe')
 
 * `false`、'f'、'0'、'n'、'no'を0に変換します。
 * `true`、't'、'1'、'y'、'yes'を1に変換します。
-  
-  引数: インプットとして、単一のブーリアンまたは文字列。
-  
-  *タイプ*: 右辺値
+
+引数: インプットとして、単一のブーリアンまたは文字列。
+
+Puppet 5.0.0以降では、 タイプシステムを使用しているほとんどすべてのデータタイプに関して値を作成できます。内蔵の[`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric)、 [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer)、および[`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float)
+の各関数を使用して数値に変換できます。
+
+    notice(Integer(false)) # Notices 0
+    notice(Float(true))    # Notices 1.0
+
+*タイプ*: 右辺値
 
 #### `bool2str`
 
@@ -487,20 +886,34 @@ bool2str(false, 't', 'f')         => 'f'
 
 引数: ブーリアン。
 
+Since Puppet 5.0.0, you can create new values for almost any
+data type using the type system — you can use the built-in
+[`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string)
+function to convert to String, with many different format options:
+
+    notice(String(false))         # Notices 'false'
+    notice(String(true))          # Notices 'true'
+    notice(String(false, '%y'))   # Notices 'yes'
+    notice(String(true, '%y'))    # Notices 'no'
+
 *タイプ*: 右辺値
 
 #### `camelcase`
 
+**非推奨:**この関数は、Puppet 6.0.0で、内蔵の[`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase)関数に置き換えられました。
+
 配列内の1つの文字列またはすべての文字列の大文字と小文字の別をCamelCase(大小文字混在)に変換します。
 
 引数: 配列または文字列のいずれか。受け取ったものと同じタイプの引数を返しますが、CamelCaseの形式で返します。
 
 *注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
 
- *タイプ*: 右辺値
+*タイプ*: 右辺値
 
 #### `capitalize`
 
+**非推奨:**この関数は、Puppet 6.0.0で、内蔵の[`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize)関数に置き換えられました。
+
 文字列または複数文字列の配列の最初の文字を大文字にし、各文字列の残りの文字を小文字にします。
 
 引数: インプットとして、単一文字列または配列。*タイプ*: 右辺値
@@ -509,6 +922,8 @@ bool2str(false, 't', 'f')         => 'f'
 
 #### `ceiling`
 
+**非推奨:**この関数は、Puppet 6.0.0で、内蔵の[`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling)関数に置き換えられました。
+
 引数以上の最小整数を返します。
 
 引数: 単一の数値。
@@ -517,6 +932,8 @@ bool2str(false, 't', 'f')         => 'f'
 
 #### `chomp`
 
+**非推奨:**この関数は、Puppet 6.0.0で、内蔵の[`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp)関数に置き換えられました。
+
 文字列または複数文字列の配列の最後から、レコード分離文字を削除します。たとえば、'hello\n'は'hello'になります。
 
 引数: 単一の文字または配列。
@@ -525,6 +942,8 @@ bool2str(false, 't', 'f')         => 'f'
 
 #### `chop`
 
+**非推奨:**この関数は、Puppet 6.0.0で、内蔵の[`chop`](https://puppet.com/docs/puppet/latest/function.html#chop)関数に置き換えられました。
+
 最後の文字を削除した新しい文字列を返します。文字列が'\r\n'で終わる場合は、両方の文字が削除されます。`chop`を空文字列に適用すると、空文字列が返されます。レコード分離文字のみを削除する場合は、`chomp`関数を使用してください。
 
 引数: インプットとして、文字列または複数文字列の配列。
@@ -538,8 +957,12 @@ bool2str(false, 't', 'f')         => 'f'
   * `clamp('24', [575, 187])`は187を返します。
   * `clamp(16, 88, 661)`は88を返します。
   * `clamp([4, 3, '99'])`は4を返します。
-  
-引数: 文字列、配列、数字。 
+
+引数: 文字列、配列、数字。
+
+Puppet 6.0.0以降では、内蔵の関数を使用して同じ結果を得ることができます。
+
+    [$minval, $maxval, $value_to_clamp].sort[1]
 
 *タイプ*: 右辺値
 
@@ -550,6 +973,12 @@ bool2str(false, 't', 'f')         => 'f'
   * `concat(['1','2','3'],'4')`は['1','2','3','4']を返します。
   * `concat(['1','2','3'],'4',['5','6','7'])`は['1','2','3','4','5','6','7']を返します。
 
+Puppet 4.0以降では、配列の連結とハッシュのマージのために`+`演算子を使い、`<<`演算子を使って追加することができます。
+
+    ['1','2','3'] + ['4','5','6'] + ['7','8','9'] # returns ['1','2','3','4','5','6','7','8','9']
+    [1, 2, 3] << 4 # returns [1, 2, 3, 4]
+    [1, 2, 3] << [4, 5] # returns [1, 2, 3, [4, 5]]
+
 *タイプ*: 右辺値
 
 #### `convert_base`
@@ -559,9 +988,30 @@ bool2str(false, 't', 'f')         => 'f'
   * `convert_base(5, 2)`は'101'になります。
   * `convert_base('254', '16')`は'fe'になります。
 
+Puppet 4.5.0以降では、内蔵の[`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string)関数を使って、さまざまな形式のオプションでこれを行うことができます。
+
+    $binary_repr = String(5, '%b') # results in "101"
+    $hex_repr = String(254, '%x')  # results in "fe"
+    $hex_repr = String(254, '%#x') # results in "0xfe"
+
 #### `count`
 
-配列のみで呼び出した場合は、空または`undef`**ではない**要素の数をカウントします。第2の引数を用いて呼び出した場合は、第2の引数にマッチする配列内の要素の数をカウントします。
+配列を最初の引数とオプションの2番目の引数と解釈します。
+2番目の引数に等しい配列内の要素の数をカウントします。
+配列のみで呼び出された場合は、nil/undef/empty-string以外の要素の数をカウントします。
+
+> **注意**: 等値はRubyメソッドでテストされます。これはRubyが
+等値とみなす対象になります。文字列の場合、等値は大文字と小文字を区別します。
+
+Puppetコアでは、 内蔵の
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) (Puppet 4.0.0以降)および
+[`length`](https://puppet.com/docs/puppet/latest/function.html#length) (Puppet 5.5.0以降、それ以前ではstdlib)の各関数の組み合わせを使用してカウントが行われます。
+
+この例では、`undef`でない値のカウントを行う方法を示しています。
+
+    notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)
+
+2を通知します。
 
 *タイプ*: 右辺値
 
@@ -605,13 +1055,30 @@ if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
 
 配列から任意の要素のインスタンスを、文字列からサブストリングを、またはハッシュからキーをすべて削除します。
 
-例:
+例: 
 
 * `delete(['a','b','c','b'], 'b')`は['a','c']を返します。
 * `delete('abracadabra', 'bra')`は'acada'を返します。
 * `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])`は{'a'=> 1}を返します。
 * `delete(['ab', 'b'], 'b')`は['ab']を返します。
 
+Puppet 4.0.0以降では、マイナス(`-`)演算子によって、配列から値を削除し、ハッシュからキーを削除します。
+
+    ['a', 'b', 'c', 'b'] - 'b'
+    # would return ['a', 'c']
+
+    {'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
+    # would return {'a' => '1'}
+
+内蔵の
+[`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst)関数で、文字列からグローバル削除を実行できます。
+
+    'abracadabra'.regsubst(/bra/, '', 'G')
+    #は、'acada'を返します。
+
+通常、内蔵の
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) 関数によって、キーと値との組み合わせに基づき、配列とハッシュからエントリをフィルタリングできます。
+
 *タイプ*: 右辺値
 
 #### `delete_at`
@@ -620,6 +1087,21 @@ if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
 
 例: `delete_at(['a','b','c'], 1)`は['a','c']を返します。
 
+Puppet 4以降では、内蔵の
+[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter)関数を使って、これを行うことができます。
+
+    ['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 } # returns ['a', 'c']
+    ['a', 'b', 'c', 'd'].filter |$pos, $val | { $pos % 2 != 0 } # returns ['b', 'd']
+
+あるいは、配列の最初もしくは最後から、または両端から同時に削除したい場合は、スライス演算子`[ ]`を使用します。
+
+    $array[0, -1] # すべての値と同じ
+    $array[2, -1] # 最初の2つの要素を除くすべて
+    $array[0, -3] # 最後の2つの要素を除くすべて
+
+    $array[1, -2] # 最初と最後の要素を除くすべて
+
+
 *タイプ*: 右辺値
 
 #### `delete_regex`
@@ -636,26 +1118,41 @@ if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
 * `delete_regex(['abf', 'ab', 'ac'], '^ab.*')`は['ac']を返します。
 * `delete_regex(['ab', 'b'], 'b')`は['ab']を返します。
 
+Puppet 4.0.0以降では、内蔵の[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter)関数で同等の処理を行います。
+
+    ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ }
+    # ['aaa', 'aca']を返します
+
 *タイプ*: 右辺値
 
 #### `delete_values`
 
 任意の値のインスタンスをハッシュからすべて削除します。
 
-例:
+例: 
 
 * `delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')`は{'a'=>'A','c'=>'C','B'=>'D'}を返します。
 
+Puppet 4.0.0以降では、内蔵の[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter)関数で同等の処理を行います。
+
+    $array.filter |$val| { $val != 'B' }
+    $hash.filter |$key, $val| { $val != 'B' }
+
 *タイプ*: 右辺値
 
 #### `delete_undef_values`
 
 `undef`値のインスタンスをアレイまたはハッシュからすべて削除します。
 
-例:
+例: 
 
 * `$hash = delete_undef_values({a=>'A', b=>'', c=>`undef`, d => false})`は{a => 'A', b => '', d => false}を返します。
 
+Puppet 4.0.0以降では、内蔵の[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter)関数で同等の処理を行います。
+
+    $array.filter |$val| { $val =~ NotUndef }
+    $hash.filter |$key, $val| { $val =~ NotUndef }
+
 *タイプ*: 右辺値
 
 #### `deprecation`
@@ -677,9 +1174,9 @@ deprecation(key, message)
 
 Puppetの他の設定は、stdlibの`deprecation`関数に影響を与えます。
 
-* [`disable_warnings`](https://docs.puppet.com/puppet/latest/reference/configuration.html#disablewarnings)
-* [`max_deprecations`](https://docs.puppet.com/puppet/latest/reference/configuration.html#maxdeprecations)
-* [`strict`](https://docs.puppet.com/puppet/latest/reference/configuration.html#strict):
+* [`disable_warnings`](https://puppet.com/docs/puppet/latest/configuration.html#disablewarnings)
+* [`max_deprecations`](https://puppet.com/docs/puppet/latest/configuration.html#maxdeprecations)
+* [`strict`](https://puppet.com/docs/puppet/latest/configuration.html#strict):
 
     * `error`: 非推奨メッセージにより、ただちに機能しなくなります。
     * `off`: メッセージがアウトプットされません。
@@ -690,7 +1187,7 @@ Puppetの他の設定は、stdlibの`deprecation`関数に影響を与えます
   非推奨警告を記録するかどうかを指定します。これは特に、自動テストの際、移行の準備ができる前にログに情報が氾濫するのを避けるうえで役立ちます。
 
   この変数はブーリアンで、以下の効果があります:
-  
+
   * `true`: 警告を記録します。
   * `false`: 警告は記録されません。
   * 値を設定しない場合: Puppet 4は警告を出しますが、Puppet 3は出しません。
@@ -699,15 +1196,20 @@ Puppetの他の設定は、stdlibの`deprecation`関数に影響を与えます
 
 2つの配列の間の差異を返します。返される配列はオリジナル配列のコピーで、第2の配列にも見られるアイテムがあれば、それが取り除かれます。
 
-例:
+例: 
 
 * `difference(["a","b","c"],["b","c","d"])`は["a"]を返します。
 
+Puppet 4以降では、Puppet言語のマイナス(`-`)演算子は同じことを行います。
+
+    ['a', 'b', 'c'] - ['b', 'c', 'd']
+    # ['a']を返します
+
 *タイプ*: 右辺値
 
 #### `dig`
 
-> 非推奨: この関数は、Puppet 4.5.0で、内蔵の[`dig`](https://docs.puppet.com/puppet/latest/function.html#dig)関数に置き換えられました。下位互換性を得るには、[`dig44()`](#dig44)を使用するか、新しいバージョンを使用してください。
+**非推奨:**この関数は、Puppet 4.5.0で、内蔵の[`dig`](https://puppet.com/docs/puppet/latest/function.html#dig)関数に置き換えられました。下位互換性を得るには、[`dig44()`](#dig44)を使用するか、新しいバージョンを使用してください。
 
 パスを含むキー配列を通じて、複数レイヤーのハッシュおよびアレイ内の値を探します。この関数は各パスコンポーネントにより構造内を移動し、パスの最後で値を返すよう試みます。
 
@@ -727,11 +1229,11 @@ $data = {
 $value = dig($data, ['a', 'b', 2])
 # $value = 'b3'
 
-# 可能なすべてのオプションを使用
+# with all possible options
 $value = dig($data, ['a', 'b', 2], 'not_found')
 # $value = 'b3'
 
-# デフォルト値を使用
+# using the default value
 $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
 # $value = 'not_found'
 ```
@@ -740,7 +1242,7 @@ $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
 2. **['a', 'b', 2]** パス配列。
 3. **'not_found'** デフォルト値。何も見つからない場合に返されます。
 
-デフォルト値: `undef`
+デフォルト値: `undef`
 
 *タイプ*: 右辺値
 
@@ -764,11 +1266,11 @@ $data = {
 $value = dig44($data, ['a', 'b', 2])
 # $value = 'b3'
 
-# 可能なすべてのオプションを使用
+# with all possible options
 $value = dig44($data, ['a', 'b', 2], 'not_found')
 # $value = 'b3'
 
-# デフォルト値を使用
+# using the default value
 $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
 # $value = 'not_found'
 ```
@@ -791,7 +1293,7 @@ $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
 与えられた文字列のUnixバージョンを返します。クロスプラットフォームテンプレートでファイルリソースを使用する場合に非常に役立ちます。
 
 ```puppet
-file{$config_file:
+file { $config_file:
   ensure  => file,
   content => dos2unix(template('my_module/settings.conf.erb')),
 }
@@ -803,6 +1305,8 @@ file{$config_file:
 
 #### `downcase`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase)関数に置き換えられました。
+
 配列内の1つの文字列またはすべての文字列の大文字と小文字の別を、小文字に変換します。
 
 *注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
@@ -811,6 +1315,8 @@ file{$config_file:
 
 #### `empty`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`empty`](https://puppet.com/docs/puppet/latest/function.html#empty)関数に置き換えられました。
+
 引数が要素を含まない配列かハッシュ、または空文字列である場合に、`true`を返します。引数が数値の場合に`false`を返します。
 
 *タイプ*: 右辺値
@@ -895,7 +1401,34 @@ userlist:
 ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
 ```
 
-### `flatten`
+#### `fact`
+
+指定されたfactの値を返します。構造化されたfactを参照する場合にドット表記を使用することができます。指定されたfactが存在しない場合は、Undefを返します。
+
+使用例:
+
+```puppet
+fact('kernel')
+fact('osfamily')
+fact('os.architecture')
+```
+
+配列のインデックス: 
+
+```puppet
+$first_processor  = fact('processors.models.0')
+$second_processor = fact('processors.models.1')
+```
+
+名前に「.」を含むfact:
+
+```puppet
+fact('vmware."VRA.version"')
+```
+
+#### `flatten`
+
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten)関数に置き換えられました。
 
 ネストの深いアレイを平坦化し、結果として単一のフラット配列を返します。
 
@@ -905,6 +1438,8 @@ ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
 
 #### `floor`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`floor`](https://puppet.com/docs/puppet/latest/function.html#floor)関数に置き換えられました。
+
 引数以下の最大整数を返します。
 
 引数: 単一の数値。
@@ -974,38 +1509,61 @@ DNSネームスペースのFQDN文字列をもとに、[RFC 4122](https://tools.
 $module_path = get_module_path('stdlib')
 ```
 
+Puppet 5.4.0以降では、内蔵の [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory)関数は同じことを行い、複数の値または配列が与えられている場合、最初に見つかったモジュールへのパスを返します。
+
 *タイプ*: 右辺値
 
 #### `getparam`
-
 リソースのパラメータの値を返します。
 
 引数: リソースリファレンスおよびパラメータの名前。
 
-たとえば、以下の場合は'param_value'を返します:
+> 注意: ユーザ定義のリソースタイプは遅れて評価されます。
+
+*例:*
 
 ```puppet
+# define a resource type with a parameter
 define example_resource($param) {
 }
 
+# declare an instance of that type
 example_resource { "example_resource_instance":
-  param => "param_value"
+    param => "'the value we are getting in this example''"
+}
+
+# Because of order of evaluation, a second definition is needed
+# that will be evaluated after the first resource has been declared
+#
+define example_get_param {
+  # This will notice the value of the parameter
+  notice(getparam(Example_resource["example_resource_instance"], "param"))
 }
 
-getparam(Example_resource["example_resource_instance"], "param")
+# Declare an instance of the second resource type - this will call notice
+example_get_param { 'show_notify': }
 ```
 
-*タイプ*: 右辺値
+'この例で取得している値'を通知します
+
+Puppet 4.0.0以降では、データタイプ
+と[ ]演算子を使用してパラメータ値を取得できます。次の例は、getparam()の呼び出しと同じです。
+
+```puppet
+Example_resource['example_resource_instance']['param']
+```
 
 #### `getvar`
+**非推奨:** この関数は、Puppet 6.0.0で、内蔵の[`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar)
+関数に置き換えられました。新しいバージョンでも、構造化された値への掘り下げがサポートされます。
 
 リモートネームスペースの変数を調べます。
 
-例:
+例: 
 
 ```puppet
 $foo = getvar('site::data::foo')
-# $foo = $site::data::fooã\81«ç\9b¸å½\93
+# $foo = $site::data::fooã\81¨å\90\8cç­\89
 ```
 
 この関数は、ネームスペースそのものが文字列に保存されている場合に役立ちます:
@@ -1013,7 +1571,7 @@ $foo = getvar('site::data::foo')
 ```puppet
 $datalocation = 'site::data'
 $bar = getvar("${datalocation}::bar")
-# $bar = $site::data::barに相当
+# Equivalent to $bar = $site::data::bar
 ```
 
 *タイプ*: 右辺値
@@ -1036,6 +1594,10 @@ $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf'])
 
 たとえば、`grep(['aaa','bbb','ccc','aaaddd'], 'aaa')`は['aaa','aaaddd']を返します。
 
+Puppet 4.0.0以降では、内蔵の[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter)関数は同じことを行います。正規表現とは対照的に、どのロジックでもフィルタリングに使用できます。
+
+    ['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }
+
 *タイプ*: 右辺値
 
 #### `has_interface_with`
@@ -1079,6 +1641,7 @@ has_interface_with("lo")                        => true
 *タイプ*: 右辺値
 
 #### `has_key`
+**非推奨:** この関数は、内蔵の`in`演算子に置き換えられました。
 
 ハッシュに特定のキー値があるかどうかを判定します。
 
@@ -1094,13 +1657,25 @@ if has_key($my_hash, 'key_one') {
 }
 ```
 
+Puppet 4.0.0以降では、これは、Puppet言語において、次の同等の式を用いて実現できます。
+
+    $my_hash = {'key_one' => 'value_one'}
+    if 'key_one' in $my_hash {
+      notice('this will be printed')
+    }
+
 *タイプ*: 右辺値
 
 #### `hash`
 
+**非推奨:** この関数は、ほとんどすべてのデータタイプの新しい値を作成する内蔵の機能に置き換えられました。
+Puppetに内蔵の[`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct)関数を参照してください。
+
 配列をハッシュに変換します。
 
-たとえば、`hash(['a',1,'b',2,'c',3])`は{'a'=>1,'b'=>2,'c'=>3}を返します。
+例えば(非推奨)、`hash(['a',1,'b',2,'c',3])`は、 {'a'=>1,'b'=>2,'c'=>3}を返します。
+
+例えば(内蔵)、`Hash(['a',1,'b',2,'c',3])`は、{'a'=>1,'b'=>2,'c'=>3}を返します。
 
 *タイプ*: 右辺値
 
@@ -1132,12 +1707,12 @@ if $baz.is_a(String) {
 }
 ```
 
-* タイプに関する詳細は、[Puppetタイプシステム](https://docs.puppetlabs.com/latest/type.html#about-resource-types)を参照してください。
-* 値のタイプを特定する各種の方法については、[`assert_type()`](https://docs.puppetlabs.com/latest/function.html#asserttype)関数を参照してください。
+* タイプに関する詳細は、[Puppetタイプシステム](https://puppet.com/docs/puppet/latest/lang_data.html)を参照してください。
+* 値のタイプを特定する各種の方法については、[`assert_type()`](https://puppet.com/docs/puppet/latest/function.html#asserttype)関数を参照してください。
 
 #### `is_absolute_path`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 与えられたパスが絶対パスである場合に`true`を返します。
 
@@ -1145,7 +1720,7 @@ if $baz.is_a(String) {
 
 #### `is_array`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された変数が配列である場合に`true`を返します。
 
@@ -1153,7 +1728,7 @@ if $baz.is_a(String) {
 
 #### `is_bool`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された変数がブーリアンである場合に`true`を返します。
 
@@ -1161,15 +1736,22 @@ if $baz.is_a(String) {
 
 #### `is_domain_name`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された文字列が構文的に正しいドメイン名である場合に`true`を返します。
 
 *タイプ*: 右辺値
 
+#### `is_email_address`
+
+この関数に渡された文字列が有効なメールアドレスである場合にtrueを返します。
+
+*タイプ*: 右辺値
+
+
 #### `is_float`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された変数がフロート型である場合に`true`を返します。
 
@@ -1177,7 +1759,7 @@ if $baz.is_a(String) {
 
 #### `is_function_available`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 文字列を引数として受け入れ、Puppetランタイムがその名前を用いて関数にアクセスできるかどうかを判定します。関数が存在する場合は`true`、存在しない場合は`false`を返します。
 
@@ -1185,7 +1767,7 @@ if $baz.is_a(String) {
 
 #### `is_hash`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された変数がハッシュである場合に`true`を返します。
 
@@ -1193,7 +1775,7 @@ if $baz.is_a(String) {
 
 #### `is_integer`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この文字列に返された変数が整数である場合に`true`を返します。
 
@@ -1201,7 +1783,7 @@ if $baz.is_a(String) {
 
 #### `is_ip_address`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された文字列が有効なIPアドレスである場合に`true`を返します。
 
@@ -1209,7 +1791,7 @@ if $baz.is_a(String) {
 
 #### `is_ipv6_address`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された文字列が有効なIPv6アドレスである場合に`true`を返します。
 
@@ -1217,7 +1799,7 @@ if $baz.is_a(String) {
 
 #### `is_ipv4_address`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された文字列が有効なIPv4アドレスである場合に`true`を返します。
 
@@ -1231,7 +1813,7 @@ if $baz.is_a(String) {
 
 #### `is_numeric`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された変数が数字である場合に`true`を返します。
 
@@ -1239,7 +1821,7 @@ if $baz.is_a(String) {
 
 #### `is_string`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 この関数に渡された変数が文字列である場合に`true`を返します。
 
@@ -1247,28 +1829,37 @@ if $baz.is_a(String) {
 
 #### `join`
 
+**非推奨:** この関数は、Puppet 5.5.0で、内蔵の[`join`](https://puppet.com/docs/puppet/latest/function.html#join)関数に置き換えられました。
+
 区切り文字を用いて、配列を文字列に結合します。たとえば、`join(['a','b','c'], ",")`は"a,b,c"になります。
 
 *タイプ*: 右辺値
 
 #### `join_keys_to_values`
 
-区切り文字を用いて、ハッシュの各キーをそのキーに対応する値と結合し、結果を文字列として返します。 
+区切り文字を用いて、ハッシュの各キーをそのキーに対応する値と結合し、結果を文字列として返します。
 
 値が配列の場合は、キーは各要素の前に置かれます。返される値は、平坦化した配列になります。
 
 たとえば、`join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")`は["a is 1","b is 2","b is 3"]になります。
 
+Puppet 5.0.0以降では、書式の制御が強化されています(インデントや改行、配列とハッシュエントリ、ハッシュエントリのキー/値の間の区切り、配列における値の個々の
+書式など)。内蔵の[`String.new`](https://docs.puppet.com/puppet/latest/function.html#conversion-to-string)関数、および`配列`と`ハッシュ`の書式設定オプションを参照してください。
+
 *タイプ*: 右辺値
 
 #### `keys`
 
+**非推奨:** この関数は、Puppet 5.5.0で、内蔵の[`keys`](https://puppet.com/docs/puppet/latest/function.html#keys)関数に置き換えられました。
+
 ハッシュのキーを配列として返します。
 
 *タイプ*: 右辺値
 
 #### `length`
 
+**非推奨:** この関数は、Puppet 5.5.0で、内蔵の[`length`](https://puppet.com/docs/puppet/latest/function.html#length)関数に置き換えられました。
+
 与えられた文字列、配列、ハッシュの長さを返します。廃止された`size()`関数に代わるものです。
 
 *タイプ*: 右辺値
@@ -1277,7 +1868,7 @@ if $baz.is_a(String) {
 
 配列、文字列、ハッシュを含むYAMLファイルをロードし、対応するネイティブデータタイプでデータを返します。
 
-例:
+例: 
 
 ```puppet
 $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
@@ -1285,7 +1876,7 @@ $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
 
 第2のパラメータは、ファイルが見つからなかった場合、または構文解析できなかった場合に返されます。
 
-例:
+例: 
 
 ```puppet
 $myhash = loadyaml('no-file.yaml', {'default'=>'value'})
@@ -1297,7 +1888,9 @@ $myhash = loadyaml('no-file.yaml', {'default'=>'value'})
 
 配列、文字列、ハッシュを含むJSONファイルをロードし、対応するネイティブデータタイプでデータを返します。
 
-例:
+例: 
+
+最初のパラメータは、絶対ファイルパスまたはURLです。
 
 ```puppet
 $myhash = loadjson('/etc/puppet/data/myhash.json')
@@ -1305,7 +1898,7 @@ $myhash = loadjson('/etc/puppet/data/myhash.json')
 
 第2のパラメータは、ファイルが見つからなかった場合、または構文解析できなかった場合に返されます。
 
-例:
+例: 
 
 ```puppet
   $myhash = loadjson('no-file.json', {'default'=>'value'})
@@ -1327,7 +1920,7 @@ notify { $metadata['author']: }
 ```
 $metadata = load_module_metadata('mysql', true)
 if empty($metadata) {
-  notify { "This module does not have a metadata.json file.": }
+  notify { "このモジュールにはmetadata.jsonファイルがありません。": }
 }
 ```
 
@@ -1335,12 +1928,16 @@ if empty($metadata) {
 
 #### `lstrip`
 
+**非推奨:** この関数は、Puppet 6.0.0で、内蔵の[`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) 関数に置き換えられました。
+
 文字列の左側のスペースを取り除きます。
 
 *タイプ*: 右辺値
 
 #### `max`
 
+**非推奨:** この関数は、Puppet 6.0.0で、内蔵の[`max`](https://puppet.com/docs/puppet/latest/function.html#max) 関数に置き換えられました。
+
 すべての引数の最大値を返します。少なくとも1つの引数が必要です。
 
 引数: 数字または数字を表す文字列。
@@ -1355,6 +1952,18 @@ if empty($metadata) {
 
 *注*: この関数は、ネスト化した配列には対応していません。最初の引数にネスト化した配列が含まれている場合は、再帰的処理は行われません。
 
+Puppet 4.0.0以降では、Puppet言語において同じことを実行できます。値が単一の場合には、
+`in`演算子を使用します。
+
+    'a' in ['a', 'b']  # true
+
+また、配列の場合には、`-`演算子を使用してdiffを計算します。
+
+    ['d', 'b'] - ['a', 'b', 'c'] == []  # 'd'が減算されないため、false
+    ['a', 'b'] - ['a', 'b', 'c'] == []  # 'a'と'b'の両方が減算されるため、true
+
+また、Puppet 5.2.0以降では、配列やハッシュの内容をテストする一般的な形式は、内蔵されている[`any`](https://puppet.com/docs/puppet/latest/function.html#any)および[`all`](https://puppet.com/docs/puppet/latest/function.html#all)の各関数を使用することです。
+
 *タイプ*: 右辺値
 
 #### `merge`
@@ -1367,16 +1976,22 @@ if empty($metadata) {
 $hash1 = {'one' => 1, 'two' => 2}
 $hash2 = {'two' => 'dos', 'three' => 'tres'}
 $merged_hash = merge($hash1, $hash2)
-# 得られるハッシュは、以下に相当します:
+# The resulting hash is equivalent to:
 # $merged_hash =  {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
 ```
 
 重複キーが存在する場合は、最右のハッシュのキーが上位になります。
 
+Puppet 4.0.0以降では、+ 演算子を使用して同じマージを実行することができます。
+
+    $merged_hash = $hash1 + $hash2
+
 *タイプ*: 右辺値
 
 #### `min`
 
+**非推奨:** この関数は、Puppet 6.0.0で、内蔵の[`min`](https://puppet.com/docs/puppet/latest/function.html#min)関数に置き換えられました。
+
 すべての引数の最小値を返します。少なくとも1つの引数が必要です。
 
 引数: 数字または数字を表す文字列。
@@ -1387,6 +2002,13 @@ $merged_hash = merge($hash1, $hash2)
 
 数字または数字の文字列表現を正当なブーリアンに変換します。0または非数字は`false`になります。0より大きい数字は`true`になります。
 
+Puppet 5.0.0以降では、タイプシステムを使用して同じことが行えます。
+利用可能な多くのタイプ変換については、Puppetの[`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) 
+関数を参照してください。
+
+    Boolean(0) # false
+    Boolean(1) # true
+
 *タイプ*: 右辺値
 
 #### `parsejson`
@@ -1407,7 +2029,7 @@ YAMLの文字列を正確なPuppet構造に変換します。
 * 第1の引数として、変換されるYAML文字列。
 * オプションで、第2のエラーとして、変換に失敗した場合に返される結果。
 
-*タイプ*: 右辺値 
+*タイプ*: 右辺値
 
 #### `pick`
 
@@ -1429,11 +2051,16 @@ $real_jenkins_version = pick($::jenkins_version, '1.449')
 
 配列のすべての要素、またはハッシュのキーに接頭辞を適用します。
 
-例:
+例: 
 
 * `prefix(['a','b','c'], 'p')`は['pa','pb','pc']を返します。
 * `prefix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')`は{'pa'=>'b','pb'=>'c','pc'=>'d'}を返します。
 
+Puppet 4.0.0以降では、内蔵の[`map`](https://docs.puppet.com/puppet/latest/function.html#map)関数を使用して配列の値を変更します。
+この例は、上記の最初の例と同じです。
+
+        ['a', 'b', 'c'].map |$x| { "p${x}" }
+
 *タイプ*: 右辺値
 
 #### `pry`
@@ -1480,8 +2107,8 @@ crypt関数を用いてパスワードをハッシュします。ほとんどの
 
 非整数文字列を使用できます:
 
-* `range("a", "c")`は["a","b","c"]を返します。
-* `range("host01", "host10")`は["host01", "host02", ..., "host09", "host10"]を返します。
+* `range("a", "c")`は["a","b","c"]を返します。
+* `range("host01", "host10")`は["host01", "host02", ..., "host09", "host10"]を返します。
 
 末尾のゼロを明示的に含める必要があります。そうでないと、下層のRuby関数が適切に機能しません。
 
@@ -1489,6 +2116,12 @@ crypt関数を用いてパスワードをハッシュします。ほとんどの
 
 * `range("0", "9", "2")`は["0","2","4","6","8"]を返します。
 
+> 注意: Puppet言語では、タイプシステムを使用して、`整数`と`フロート`の範囲をサポートしています。これらは、指定された回数の反復に適しています。
+
+値のスキップについては、Puppetに内蔵の[`step`](https://docs.puppet.com/puppet/latest/function.html#step)関数を参照してください。
+
+   整数[0, 9]。それぞれの|$x| { notice($x) } #は、0, 1, 2, ... 9を通知します。
+
 *タイプ*: 右辺値
 
 #### `regexpescape`
@@ -1503,16 +2136,32 @@ crypt関数を用いてパスワードをハッシュします。ほとんどの
 
 たとえば、`reject(['aaa','bbb','ccc','aaaddd'], 'aaa')`は['bbb','ccc']を返します。
 
+Puppet 4.0.0以降では、Puppetに内蔵の[`filter`](https://docs.puppet.com/puppet/latest/function.html#filter)関数にも同じことが当てはまります。
+stdlibの`reject`関数に相当します。
+
+    ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ /aaa/ }
+
 *タイプ*: 右辺値
 
 #### `reverse`
 
 文字列または配列の順序を逆転します。
 
+> *注意*: Puppetでは、内蔵の[`reverse_each`](https://docs.puppet.com/puppet/latest/function.html#reverse_each)関数を使って同じことが行えます。
+
+
+#### `round`
+
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`round`](https://puppet.com/docs/puppet/latest/function.html#round)関数に置き換えられました。
+
+数値を最も近い整数に丸めます。
+
 *タイプ*: 右辺値
 
 #### `rstrip`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`rstrip`](https://puppet.com/docs/puppet/latest/function.html#`rstrip`)関数に置き換えられました。
+
 文字列の右側のスペースを取り除きます。
 
 *タイプ*: 右辺値
@@ -1523,11 +2172,15 @@ crypt関数を用いてパスワードをハッシュします。ほとんどの
 
 *タイプ*: 右辺値
 
+#### `seeded_rand_string`
+
+(シード値に基づいて)一貫性のあるランダムな文字列を生成します。異なるホストに一致するパスワードを生成する場合に便利です。
+
 #### `shell_escape`
 
 文字列をエスケープし、Bourneシェルコマンドラインで安全に使用できるようにします。得られる文字列はクォートなしで使用する必要があり、ダブルクォートまたはシングルクォートでの使用は意図されていません。この関数は、Rubyの`Shellwords.shellescape()`関数と同様に挙動します。[Rubyドキュメント](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellescape)を参照してください。
 
-例:
+例: 
 
 ```puppet
 shell_escape('foo b"ar') => 'foo\ b\"ar'
@@ -1539,7 +2192,7 @@ shell_escape('foo b"ar') => 'foo\ b\"ar'
 
 与えられた文字列の配列からコマンドライン文字列を構築します。各配列アイテムが、Bourneシェルで使用できるようにエスケープされます。その後、すべてのアイテムがまとめられ、間にシングルスペースが配されます。この関数は、Rubyの`Shellwords.shelljoin()`関数と同様に挙動します。[Rubyドキュメント](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shelljoin)を参照してください。
 
-例:
+例: 
 
 ```puppet
 shell_join(['foo bar', 'ba"z']) => 'foo\ bar ba\"z'
@@ -1567,17 +2220,39 @@ shell_split('foo\ bar ba\"z') => ['foo bar', 'ba"z']
 
 #### `size`
 
+**非推奨:** この関数は、Puppet 6.0.0で、内蔵の[`size`](https://puppet.com/docs/puppet/latest/function.html#size) 関数に置き換えられました(`サイズ`は、`長さ`のエイリアスです)。
+
 文字列、配列、ハッシュの要素数を返します。この関数は、今後のリリースでは廃止されます。Puppet 4では、`length`関数を使用してください。
 
 *タイプ*: 右辺値
 
+#### `sprintf_hash`
+
+**非推奨:** Puppet 4.10.10および5.3.4では、内蔵の[`sprintf`](https://docs.puppet.com/puppet/latest/function.html#sprintf)関数を使って同じ機能を達成できます。この関数は、今後のリリースでは削除されます。
+
+名前が指定されたテキストのリファレンスでprintfスタイルのフォーマットを実行します。
+
+最初のパラメータは、ハッシュ内での残りのパラメータのフォーマット方法を記述するフォーマット文字列です。詳細については、Rubyの[`Kernel::sprintf`](https://ruby-doc.org/core-2.4.2/Kernel.html#method-i-sprintf)機能のマニュアルを参照してください。
+
+例: 
+
+```puppet
+$output = sprintf_hash('String: %<foo>s / number converted to binary: %<number>b',
+                       { 'foo' => 'a string', 'number' => 5 })
+# $output = 'String: a string / number converted to binary: 101'
+```
+
+*Type*: rvalue
+
 #### `sort`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`sort`](https://puppet.com/docs/puppet/latest/function.html#sort)関数に置き換えられました。
+
 文字列と配列を語彙的に分類します。
 
 *タイプ*: 右辺値
 
-*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+>*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
 
 #### `squeeze`
 
@@ -1589,6 +2264,13 @@ shell_split('foo\ bar ba\"z') => ['foo bar', 'ba"z']
 
 特定の文字列をブーリアンに変換します。値'1'、'true'、't'、'y'、'yes'を含む文字列は`true`に変換されます。値'0'、'false'、'f'、'n'、'no'を含む文字列、および空文字列または未定義文字列は`false`に変換されます。その他の値の場合、エラーが生じます。このチェックでは、大文字と小文字は区別されません。
 
+Puppet 5.0.0以降では、タイプシステムを使用して同じことが行えます。
+利用可能な多くのタイプ変換については、Puppetの[`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) 
+関数を参照してください。
+
+    Boolean('false'), Boolean('n'), Boolean('no') # すべてfalse
+    Boolean('true'), Boolean('y'), Boolean('yes') # すべてtrue
+
 *タイプ*: 右辺値
 
 #### `str2saltedsha512`
@@ -1597,10 +2279,12 @@ OS Xバージョン10.7以上で使用されるソルト付きSHA512パスワー
 
 *タイプ*: 右辺値
 
-*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+>*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
 
 #### `strftime`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`strftime`](https://puppet.com/docs/puppet/latest/function.html#`strftime`)関数に置き換えられました。
+
 フォーマットされた時刻を返します。
 
 たとえば、`strftime("%s")`はUnixエポックからの経過時間を返し、`strftime("%Y-%m-%d")`は日付を返します。
@@ -1609,11 +2293,11 @@ OS Xバージョン10.7以上で使用されるソルト付きSHA512パスワー
 
 *タイプ*: 右辺値
 
-*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+>*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
 
 *フォーマット:*
 
-* `%a`: 曜日の名称の短縮形('Sun')
+*  `%a`: 曜日の名称の短縮形('Sun')
 * `%A`: 曜日の完全な名称('Sunday')
 * `%b`: 月の名称の短縮形('Jan')
 * `%B`: 月の完全な名称('January')
@@ -1661,6 +2345,8 @@ OS Xバージョン10.7以上で使用されるソルト付きSHA512パスワー
 
 #### `strip`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`strip`](https://puppet.com/docs/puppet/latest/function.html#`strip`)関数に置き換えられました。
+
 1つの文字列、または配列内のすべての文字列から、冒頭および末尾の空白を削除します。たとえば、`strip("    aaa   ")`は"aaa"になります。
 
 *タイプ*: 右辺値
@@ -1669,11 +2355,15 @@ OS Xバージョン10.7以上で使用されるソルト付きSHA512パスワー
 
 配列のすべての要素、またはハッシュのすべてのキーに接尾辞を適用します。
 
-例:
+例: 
 
 * `suffix(['a','b','c'], 'p')`は['ap','bp','cp']を返します。
 * `suffix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')`は{'ap'=>'b','bp'=>'c','cp'=>'d'}を返します。
 
+Puppet 4.0.0以降では、内蔵の[`map`](https://docs.puppet.com/puppet/latest/function.html#map)関数を使用して配列の値を変更します。この例は、上記の最初の例と同じです。
+
+    ['a', 'b', 'c'].map |$x| { "${x}p" }
+
 *タイプ*: 右辺値
 
 #### `swapcase`
@@ -1682,7 +2372,7 @@ OS Xバージョン10.7以上で使用されるソルト付きSHA512パスワー
 
 *タイプ*: 右辺値
 
-*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+>*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
 
 #### `time`
 
@@ -1690,29 +2380,57 @@ OS Xバージョン10.7以上で使用されるソルト付きSHA512パスワー
 
 たとえば、`time()`は'1311972653'などを返します。
 
+Puppet 4.8.0以降、Puppet言語には、``Timestamp` (時点)と`Timespan` (期間)の各データタイプがあります。次の例は、引数なしで`time()`を呼び出すのと同じです。
+
+タイムスタンプ()
+
 *タイプ*: 右辺値
 
 #### `to_bytes`
 
 引数をバイトに変換します。
 
-たとえば、"4 kB"は"4096"になります。 
+たとえば、"4 kB"は"4096"になります。
 
 引数: 単一の文字列。
 
 *タイプ*: 右辺値
 
+#### `to_json`
+
+入力値をJSON形式の文字列に変換します。
+
+例えば、`{ "key" => "value" }`は`{"key":"value"}`になります。
+
+*タイプ*: 右辺値
+
+#### `to_json_pretty`
+
+入力値を整形されたJSON形式の文字列に変換します。
+
+例えば、`{ "key" => "value" }`は`{\n  \"key\": \"value\"\n}`になります。
+
+*タイプ*: 右辺値
+
+#### `to_yaml`
+
+入力値をYAML形式の文字列に変換します。
+
+例えば、`{ "key" => "value" }`は`"---\nkey: value\n"`になります。
+
+*タイプ*: 右辺値
+
 #### `try_get_value`
 
 **非推奨:** `dig()`に置き換えられました。
 
 ハッシュおよび配列の複数レイヤー内の値を取得します。
 
-引数: 
+引数:
 
 * 第1の引数として、パスを含む文字列。この引数は、ゼロではじまり、パス区切り文字(デフォルトは"/")で区切ったハッシュキーまたは配列インデックスの文字列として提示してください。この関数は各パスコンポーネントにより構造内を移動し、パスの最後で値を返すよう試みます。
 
-*デフォルトの第2の引数。パスが正しくない場合や、値が見つからない場合、その他のエラーが生じた場合は、この引数が返されます。
+* デフォルトの第2の引数。パスが正しくない場合や、値が見つからない場合、その他のエラーが生じた場合は、この引数が返されます。
 * 最後の引数として、パス区切り文字。
 
 ```ruby
@@ -1729,15 +2447,15 @@ $data = {
 $value = try_get_value($data, 'a/b/2')
 # $value = 'b3'
 
-# 可能なすべてのオプションを使用
+# with all possible options
 $value = try_get_value($data, 'a/b/2', 'not_found', '/')
 # $value = 'b3'
 
-# デフォルト値を使用
+# using the default value
 $value = try_get_value($data, 'a/b/c/d', 'not_found')
 # $value = 'not_found'
 
-# カスタム区切りを使用
+# using custom separator
 $value = try_get_value($data, 'a|b', [], '|')
 # $value = ['b1','b2','b3']
 ```
@@ -1753,7 +2471,7 @@ $value = try_get_value($data, 'a|b', [], '|')
 
 #### `type3x`
 
-**非推奨**。この関数は、今後のリリースで廃止されます。 
+**非推奨:**この関数は、今後のリリースで廃止されます。 
 
 与えられた値のタイプを説明する文字列を返します。タイプとしては、文字列、配列、ハッシュ、フロート、整数、ブーリアンが可能です。Puppet 4では、この代わりに新しいタイプシステムを使用してください。
 
@@ -1770,7 +2488,7 @@ $value = try_get_value($data, 'a|b', [], '|')
 
 #### `type_of`
 
-この関数は下位互換性を得るために提供されていますが、Puppetで提供されている内蔵の[type()関数](https://docs.puppet.com/puppet/latest/reference/function.html#type)の使用を推奨します。
+この関数は下位互換性を得るために提供されていますが、Puppetで提供されている内蔵の[type()関数](https://puppet.com/docs/puppet/latest/function.html#type)の使用を推奨します。
 
 与えられた値のリテラル型を返します。Puppet 4が必要です。`if type_of($some_value) <= Array[String] { ... }`のように(これは`if $some_value =~ Array[String] { ... }`に相当します)、`<=`を用いたタイプの比較に役立ちます。
 
@@ -1799,7 +2517,7 @@ $value = try_get_value($data, 'a|b', [], '|')
 *タイプ*: 右辺値
 
 ```puppet
-file{$config_file:
+file { $config_file:
   ensure  => file,
   content => unix2dos(template('my_module/settings.conf.erb')),
 }
@@ -1809,6 +2527,8 @@ file{$config_file:
 
 #### `upcase`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`upcase`](https://puppet.com/docs/puppet/latest/function.html#upcase)関数に置き換えられました。
+
 オブジェクト、配列、オブジェクトのハッシュを大文字に変換します。変換されるオブジェクトは、大文字化に対応するものでなければなりません。
 
 たとえば、`upcase('abcd')`は'ABCD'を返します。
@@ -1819,13 +2539,13 @@ file{$config_file:
 
 #### `uriescape`
 
-文字列または文字列の配列をURLエンコードします。 
+文字列または文字列の配列をURLエンコードします。
 
 引数: 単一の文字列または文字列の配列。
 
 *タイプ*: 右辺値
 
-*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+>*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
 
 #### `validate_absolute_path`
 
@@ -1860,7 +2580,7 @@ validate_absolute_path($undefined)
 
 #### `validate_array`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 渡されたすべての値が配列データ構造であることを確認します。このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
 
@@ -1913,10 +2633,9 @@ validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers
 
 #### `validate_bool`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
-渡されたすべての値が`true`または`false`のいずれかであることを確認します。 
-このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
+渡されたすべての値が`true`または`false`であることを確認します。このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
 
 以下の値が渡されます:
 
@@ -1947,20 +2666,67 @@ validate_bool($some_array)
 * オプションの第3の引数として、ユーザに表示するエラーメッセージ。
 
 ```puppet
-# デフォルトのパス末尾
+# Defaults to end of path
 validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
 ```
 
 ```puppet
-# ファイルロケーションとして%を使用
+# % as file location
 validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
 ```
 
 *タイプ*: ステートメント
 
+#### `validate_domain_name`
+
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
+
+渡されたすべての値が構文的に正しいドメイン名であることを確認します。このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
+
+以下の値が渡されます:
+
+~~~
+$my_domain_name = 'server.domain.tld'
+validate_domain_name($my_domain_name)
+validate_domain_name('domain.tld', 'puppet.com', $my_domain_name)
+~~~
+
+以下の値が不合格となり、コンパイルが中止されます: 
+
+~~~
+validate_domain_name(1)
+validate_domain_name(true)
+validate_domain_name('invalid domain')
+validate_domain_name('-foo.example.com')
+validate_domain_name('www.example.2com')
+~~~
+
+*タイプ*: ステートメント
+
+#### `validate_email_address`
+
+渡されたすべての値が有効なメールアドレスであることを確認します。このチェックで不合格となった値がある場合、コンパイルが失敗します。
+
+以下の値が渡されます:
+
+~~~
+$my_email = "waldo@gmail.com"
+validate_email_address($my_email)
+validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email)
+~~~
+
+以下の値が不合格となり、コンパイルが中止されます: 
+
+~~~
+$some_array = [ 'bad_email@/d/efdf.com' ]
+validate_email_address($some_array)
+~~~
+
+*タイプ*: ステートメント
+
 #### `validate_hash`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 渡されたすべての値がハッシュデータ構造であることを確認します。このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
 
@@ -1984,7 +2750,7 @@ validate_hash($undefined)
 
 #### `validate_integer`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 整数または整数の配列を確認します。いずれかがチェックで不合格になった場合には、カタログコンパイルが中止されます。
 
@@ -1992,7 +2758,7 @@ validate_hash($undefined)
 
 * 第1の引数として、整数または整数の配列。
 * オプションの第2の引数として、最大値。第1の引数(のすべての要素)は、この最大値以下でなければなりません。
-* ã\82ªã\83\97ã\82·ã\83§ã\83³ã\81®ç¬¬3ã\81®å¼\95æ\95°ã\81¨ã\81\97ã\81¦ã\80\81æ\9c\80å°\8få\80¤ã\80\82第1ã\81®å¼\95æ\95°(ã\81®ã\81\99ã\81¹ã\81¦ã\81®è¦\81ç´ )ã\81¯ã\80\81ã\81\93ã\81®æ\9c\80å°\8få\80¤ä»¥ä¸\8aã\81§ã\81ªã\81\91ã\82\8cã\81°ã\81ªã\82\8aã\81¾ã\81\9bã\82\93ã\80\82 
+* ã\82ªã\83\97ã\82·ã\83§ã\83³ã\81®ç¬¬3ã\81®å¼\95æ\95°ã\81¨ã\81\97ã\81¦ã\80\81æ\9c\80å°\8få\80¤ã\80\82第1ã\81®å¼\95æ\95°(ã\81®ã\81\99ã\81¹ã\81¦ã\81®è¦\81ç´ )ã\81¯ã\80\81ã\81\93ã\81®æ\9c\80大å\80¤ä»¥ä¸\8aã\81§ã\81ªã\81\91ã\82\8cã\81°ã\81ªã\82\8aã\81¾ã\81\9bã\82\93ã\80\82
 
 第1の引数が整数または整数の配列でない場合や、第2または第3の引数が整数に変換できない場合は、この関数は失敗になります。ただし、最小値が与えられている場合は(この場合に限られます)、第2の引数を空文字列または`undef`にすることが可能です。これは、最小チェックを確実に行うためのプレースホルダーとして機能します。
 
@@ -2044,9 +2810,9 @@ validate_integer(1, 3, true)
 
 #### `validate_ip_address`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
-IPv4アドレスかIPv6アドレスかにかかわらず、引数がIPアドレスであることを確認します。また、ネットマスクによりIPアドレスを確認します。 
+IPv4アドレスかIPv6アドレスかにかかわらず、引数がIPアドレスであることを確認します。また、ネットマスクによりIPアドレスを確認します。
 
 引数: IPアドレスを指定する文字列。
 
@@ -2091,7 +2857,7 @@ validate_ip_address('260.2.32.43')
 例:
 
 ```puppet
-validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."])
+validate_legacy('Optional[String]', 'validate_re', 'Value to be validated', ["."])
 ```
 
 この関数は、Puppet 3形式の引数確認(stdlibの`validate_*`関数を使用)からPuppet 4データタイプへのモジュールのアップデートに対応しており、Puppet 3形式の確認に頼っている場合も機能性が中断することはありません。
@@ -2102,14 +2868,14 @@ validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."
 
 Puppet 4を使用している場合、`validate_legacy`関数を使えば、非推奨のPuppet 3の`validate_*`関数を探し、分離することができます。これらの関数は、stdlibバージョン4.13時点で非推奨になっており、今後のstdlibバージョンでは削除されます。
 
-Puppet 4では、[データタイプ](https://docs.puppet.com/puppet/latest/reference/lang_data.html)を用いた改良版の定義タイプチェックが可能です。データタイプでは、Puppet 3の`validate_*`関数で見られた、矛盾につながるいくつかの問題を回避できます。たとえば、[validate_numeric](#validate_numeric)では、数字だけでなく、数字の配列や数字のように見える文字列も意図せず許可されていました。
+Puppet 4では、[データタイプ](https://puppet.com/docs/puppet/latest/lang_data.html)を用いた改良版のユーザ定義タイプのチェックが可能です。データタイプでは、Puppet 3の`validate_*`関数で見られた、不整合につながるいくつかの問題を回避できます。例えば、[validate_numeric](#validate_numeric)では、数字だけでなく、数字の配列や数字のように見える文字列も意図に反して許可されていました。
 
 Puppet 4とともに、非推奨の `validate_*`関数を用いたモジュールを使用している場合は、非推奨メッセージが表示されることがあります。`validate_legacy`関数を使えば、そうした差異を可視化し、より明快なPuppet 4構文に簡単に移行することができます。
 
 表示される非推奨メッセージは、使用しているモジュールやデータによって異なることがあります。以下の非推奨メッセージは、Puppet 4でのみデフォルトで表示されます:
 
 * `Notice: Accepting previously invalid value for target type '<type>'`: このメッセージは、情報提供の目的のみで表示されるものです。使用している値は、新形式で許可されていますが、旧確認関数では無効となります。
-* `Warning: This method is deprecated, please use the stdlib validate_legacy function`: モジュールがまだ`validate_legacy`にアップグレードされていません。[deprecation](#deprecation)オプションを使用してさしあたり警告を解除するか、モジュールの開発者によりフィックスを提出してください。この問題の解決方法については、以下の[モジュール開発者へ](#モジュール開発者へ)を参照してください。
+* `Warning: This method is deprecated, please use the stdlib validate_legacy function`: モジュールがまだ`validate_legacy`にアップグレードされていません。[deprecation](#deprecation)オプションを使用してさしあたり警告を解除するか、モジュールの開発者に修正版を提出させてください。この問題の解決方法については、以下の[モジュール開発者へ](#モジュール開発者へ)を参照してください。
 * `Warning: validate_legacy(<function>) expected <type> value, got <actual type>_`: コードが渡す値は、Puppet 3形式の確認では認められますが、次バージョンのモジュールでは認められません。ほとんどの場合、数字またはブーリアンからクォートを削除すれば、この問題を解決することができます。
 * `Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, validate_legacy(<function>) expected <type> value, got <actual type>`: コードの渡す値は、新形式の確認でも旧形式の確認でも認められません。
 
@@ -2117,14 +2883,14 @@ Puppet 4とともに、非推奨の `validate_*`関数を用いたモジュー
 
 `validate_legacy`関数は、モジュールユーザの使用している機能を中断させずに、 Puppet 3形式の確認からPuppet 4形式の確認に移行するのに役立ちます。
 
-Puppet 4形式の確認に移行すれば、[データタイプ](https://docs.puppet.com/puppet/latest/reference/lang_data.html)を用いた、より明確な定義タイプチェックが可能になります。Puppet 3の`validate_*` 関数の多くは、確認という点で驚くほど多くの穴があります。たとえば、[validate_numeric](#validate_numeric)では、細部をコントロールできないため、数字だけでなく、数字の配列や数字のように見える文字列も許可されます。 
+Puppet 4形式の確認に移行すれば、[データタイプ](https://puppet.com/docs/puppet/latest/lang_data.html)を用いた、より明確なユーザ定義タイプのチェックが可能になります。Puppet 3の`validate_*` 関数の多くは、確認という点で驚くほど多くの穴があります。例えば、[validate_numeric](#validate_numeric)では、細部をコントロールできないため、数字だけでなく、数字の配列や数字のように見える文字列も許可されます。
 
 クラスおよび定義タイプの各パラメータについて、使用する新しいPuppet 4データタイプを選択してください。たいていの場合、新しいデータタイプにより、元の`validate_*`関数とは異なる値のセットを使用できるようになります。以下のような状況になります:
 
 |              | `validate_` pass | `validate_` fail |
 | ------------ | ---------------- | ---------------- |
-| ã\83\9eã\83\83ã\83\81ã\82¿ã\82¤ã\83\97 | ã\83\91ã\82¹             | ã\83\91ã\82¹ã\80\81é\80\9aå\91\8a     |
-| 失敗タイプ   | パス、非推奨 | 失敗             |
+| ã\82¿ã\82¤ã\83\97ã\81«ä¸\80è\87´ã\81\97ã\81¾ã\81\99 | æ\88\90å\8a\9f             | æ\88\90å\8a\9fã\80\81é\80\9aç\9f¥     |
+| タイプの失敗   | 成功、廃止予定 | 失敗             |
 
 現在のところ、確認後のコードでも、すべての可能な値に対処する必要がありますが、新形式にマッチする値のみを渡すように、コードのユーザがマニフェストを変更することができます。
 
@@ -2140,7 +2906,7 @@ class example($value) {
 得られる確認コードは、以下のようになります:
 
 ```puppet
-class example(
+クラスの例(
   Variant[Stdlib::Compat::Numeric, Numeric] $value
 ) {
   validate_legacy(Numeric, 'validate_numeric', $value)
@@ -2160,7 +2926,7 @@ class example(
 
 #### `validate_numeric`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 数値または数値の配列や文字列を確認します。いずれかがチェックに失敗した場合には、カタログコンパイルが中止されます。
 
@@ -2178,7 +2944,7 @@ class example(
 
 #### `validate_re`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 1つまたは複数の正規表現に照らして、文字列の簡単な確認を行います。
 
@@ -2219,7 +2985,7 @@ validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not ma
 
 #### `validate_slength`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 文字列(または文字列の配列)が指定した長さ以下であることを確認します。
 
@@ -2249,7 +3015,7 @@ validate_slength(["discombobulate","moo"],17,10)
 
 #### `validate_string`
 
-**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+**非推奨:**今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。
 
 渡したすべての値が文字列データ構造であることを確認します。このチェックに失敗した値がある場合は、カタログコンパイルが中止されます。
 
@@ -2267,7 +3033,7 @@ validate_string(true)
 validate_string([ 'some', 'array' ])
 ```
 
-*注:* validate_string(`undef`)は、このバージョンの関数APIでは失敗しません。
+注:* validate_string(`undef`)は、このバージョンの関数APIでは失敗しません。
 
 代わりに、以下を使用してください:
 
@@ -2281,8 +3047,7 @@ validate_string([ 'some', 'array' ])
 
 #### `validate_x509_rsa_key_pair`
 
-OpenSSLにより、PEMフォーマットされたX.509認証およびプライベートキーを確認します。
-認証の署名が提供されたキーから作成されたものであることを確認します。
+OpenSSLにより、PEMフォーマットされたX.509認証および秘密鍵を確認します。認証の署名が提供された鍵から作成されたものであることを確認します。
 
 このチェックに失敗した値がある場合は、カタログコンパイルが中止されます。
 
@@ -2299,6 +3064,8 @@ validate_x509_rsa_key_pair($cert, $key)
 
 #### `values`
 
+**非推奨:**この関数は、Puppet 5.5.0で、内蔵の[`values`](https://puppet.com/docs/puppet/latest/function.html#values)関数に置き換えられました。
+
 与えられたハッシュの値を返します。
 
 たとえば、`$hash = {'a'=1, 'b'=2, 'c'=3} values($hash)`を与えると、[1,2,3]を返します。
@@ -2317,31 +3084,42 @@ validate_x509_rsa_key_pair($cert, $key)
   * 'start-stop'の形式での範囲(4-9など)。
   * 上記を組み合わせた配列。
 
-例:
+例: 
 
 * `values_at(['a','b','c'], 2)`は['c']を返します。
 * `values_at(['a','b','c'], ["0-1"])`は['a','b']を返します。
 * `values_at(['a','b','c','d','e'], [0, "2-3"])`は['a','c','d']を返します。
 
+Puppet 4.0.0以降では、インデックスで配列をスライスし、言語で直接カウントすることができます。
+負の値は、配列の"最後から"と解釈されます。例えば、次のようになります。
+
+```puppet
+['a', 'b', 'c', 'd'][1, 2]   # results in ['b', 'c']
+['a', 'b', 'c', 'd'][2, -1]  # results in ['c', 'd']
+['a', 'b', 'c', 'd'][1, -2]  # results in ['b', 'c']
+```
+
 *タイプ*: 右辺値
 
 #### `zip`
 
 与えられた第1の配列から1つの要素をとり、与えられた第2の配列の対応する要素と結合します。これにより、n-要素配列のシーケンスが生成されます。*n*は、引数の数より1大きくなります。たとえば、`zip(['1','2','3'],['4','5','6'])`は["1", "4"], ["2", "5"], ["3", "6"]を返します。*タイプ*: 右辺値。
 
-## 制約
+## 制約事項
 
 Puppet Enterprise 3.7では、stdlibモジュールがPEに含まれていません。PEユーザは、Puppetと互換性のあるstdlibの最新リリースをインストールする必要があります。
 
+サポートされているオペレーティングシステムの一覧については、[metadata.json](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/metadata.json)を参照してください。
+
 ### バージョン互換性
 
 バージョン | Puppet 2.6 | Puppet 2.7 | Puppet 3.x | Puppet 4.x |
 :---------------|:-----:|:---:|:---:|:----:
-**stdlib 2.x**  | **あり** | **あり** | なし | なし
-**stdlib 3.x**  | ã\81ªã\81\97    | **ã\81\82ã\82\8a**  | **ã\81\82ã\82\8a** | ã\81ªã\81\97
-**stdlib 4.x**  | ã\81ªã\81\97    | **ã\81\82ã\82\8a**  | **ã\81\82ã\82\8a** | ã\81ªã\81\97
-**stdlib 4.6+**  | ã\81ªã\81\97    | **ã\81\82ã\82\8a**  | **ã\81\82ã\82\8a** | **ã\81\82ã\82\8a**
-**stdlib 5.x**  | ã\81ªã\81\97    | ã\81ªã\81\97  | **ã\81\82ã\82\8a**  | **ã\81\82ã\82\8a**
+**stdlib 2.x**  | **yes** | **yes** | いいえ | いいえ
+**stdlib 3.x**  | ã\81\84ã\81\84ã\81\88    | **yes**  | **yes** | ã\81\84ã\81\84ã\81\88
+**stdlib 4.x**  | ã\81\84ã\81\84ã\81\88    | **yes**  | **yes** | ã\81\84ã\81\84ã\81\88
+**stdlib 4.6+**  | ã\81\84ã\81\84ã\81\88    | **yes**  | **yes** | **yes**
+**stdlib 5.x**  | ã\81\84ã\81\84ã\81\88    | ã\81\84ã\81\84ã\81\88  | **yes**  | **yes**
 
 **stdlib 5.x**:  stdlib 5.xのリリース時には、Puppet 2.7.xのサポートが廃止されます。[この説明](https://github.com/puppetlabs/puppetlabs-stdlib/pull/176#issuecomment-30251414)を参照してください。
 
@@ -2349,9 +3127,9 @@ Puppet Enterprise 3.7では、stdlibモジュールがPEに含まれていませ
 
 Puppet ForgeのPuppet Labsモジュールはオープンプロジェクトで、良い状態に保つためには、コミュニティの貢献が必要不可欠です。Puppetが役に立つはずでありながら、私たちがアクセスできないプラットフォームやハードウェア、ソフトウェア、デプロイ構成は無数にあります。私たちの目標は、できる限り簡単に変更に貢献し、みなさまの環境で私たちのモジュールが機能できるようにすることにあります。最高の状態を維持できるようにするために、コントリビュータが従う必要のあるいくつかのガイドラインが存在します。詳細については、[モジュールコントリビューションガイド](https://docs.puppetlabs.com/forge/contributing.html)を参照してください。
 
-このモジュールのバグの報告または調査は、
+このモジュールの一部に関するバグの報告または調査は、
 [http://tickets.puppetlabs.com/browse/MODULES](http://tickets.puppetlabs.com/browse/MODULES)からお願いします。
 
 ## コントリビュータ
 
-コントリビュータのリストは、[https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors](https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors)で見ることができます。
\ No newline at end of file
+コントリビュータのリストは、[https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors](https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors)で見ることができます。
old mode 100755 (executable)
new mode 100644 (file)
index 5af436f..e3d904a
@@ -1,29 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'abs function' do
+describe 'abs function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'should accept a string' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $input  = '-34.56'
       $output = abs($input)
       notify { "$output": }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: 34.56/)
+    DOC
+    it 'accepts a string' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: 34.56})
       end
     end
 
-    it 'should accept a float' do
-      pp = <<-EOS
-      $input  = -34.56
+    pp2 = <<-DOC
+      $input  = -35.46
       $output = abs($input)
       notify { "$output": }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: 34.56/)
+    DOC
+    it 'accepts a float' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: 35.46})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 24a9064..3cf0c92
@@ -2,8 +2,7 @@ require 'spec_helper_acceptance'
 
 describe 'anchor type' do
   describe 'success' do
-    it 'should effect proper chaining of resources' do
-      pp = <<-EOS
+    pp = <<-DOC
       class anchored {
         anchor { 'anchored::begin': }
         ~> anchor { 'anchored::end': }
@@ -16,10 +15,10 @@ describe 'anchor type' do
       }
 
       include anchorrefresh
-      EOS
-
+    DOC
+    it 'effects proper chaining of resources' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Anchor\[final\]: Triggered 'refresh'/)
+        expect(r.stdout).to match(%r{Anchor\[final\]: Triggered 'refresh'})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 8a13911..2f1ae4e
@@ -1,36 +1,32 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'any2array function' do
   describe 'success' do
-    it 'should create an empty array' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $input = ''
       $output = any2array($input)
       validate_array($output)
       notify { "Output: ${output}": }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: Output: /)
+    DOC
+    it 'creates an empty array' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: Output: })
       end
     end
 
-    it 'should leave arrays modified' do
-      pp = <<-EOS
-      $input = ['test', 'array']
+    pp2 = <<-DOC
+      $input = ['array', 'test']
       $output = any2array($input)
       validate_array($output)
       notify { "Output: ${output}": }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
+    DOC
+    it 'leaves arrays modified' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: Output: (\[|)array(,\s|)test(\]|)})
       end
     end
 
-    it 'should turn a hash into an array' do
-      pp = <<-EOS
+    pp3 = <<-DOC
       $input = {'test' => 'array'}
       $output = any2array($input)
 
@@ -39,10 +35,10 @@ describe 'any2array function' do
       validate_string($output[0])
       validate_string($output[1])
       notify { "Output: ${output}": }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
+    DOC
+    it 'turns a hash into an array' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: Output: (\[|)test(,\s|)array(\]|)})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index e9096a7..5cc4d62
@@ -1,17 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'base64 function' do
   describe 'success' do
-    it 'should encode then decode a string' do
-      pp = <<-EOS
+    pp = <<-DOC
       $encodestring = base64('encode', 'thestring')
       $decodestring = base64('decode', $encodestring)
       notify { $decodestring: }
-      EOS
-
+    DOC
+    it 'encodes then decode a string' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/thestring/)
+        expect(r.stdout).to match(%r{thestring})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index c69acc6..bf6611e
@@ -1,32 +1,29 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'bool2num function' do
   describe 'success' do
     ['false', 'f', '0', 'n', 'no'].each do |bool|
-      it "should convert a given boolean, #{bool}, to 0" do
-        pp = <<-EOS
+      pp1 = <<-DOC
         $input = "#{bool}"
         $output = bool2num($input)
         notify { "$output": }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/Notice: 0/)
+      DOC
+      it "should convert a given boolean, #{bool}, to 0" do
+        apply_manifest(pp1, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{Notice: 0})
         end
       end
     end
 
     ['true', 't', '1', 'y', 'yes'].each do |bool|
-      it "should convert a given boolean, #{bool}, to 1" do
-        pp = <<-EOS
+      pp2 = <<-DOC
         $input = "#{bool}"
         $output = bool2num($input)
         notify { "$output": }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/Notice: 1/)
+      DOC
+      it "should convert a given boolean, #{bool}, to 1" do
+        apply_manifest(pp2, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{Notice: 1})
         end
       end
     end
old mode 100755 (executable)
new mode 100644 (file)
index 62ecbf1..9059858
@@ -1,83 +1,89 @@
-#!/usr/bin/env ruby
 # vim: set sw=2 sts=2 et tw=80 :
 require 'rspec'
 
-#XXX Super ugly hack to keep from starting beaker nodes
+# XXX Super ugly hack to keep from starting beaker nodes
 module Kernel
   # make an alias of the original require
-  alias_method :original_require, :require
+  alias original_require require
   # rewrite require
-  def require name
+  def require(name)
     original_require name if name != 'spec_helper_acceptance'
   end
 end
-UNSUPPORTED_PLATFORMS = []
-def fact(*args) [] end
-#XXX End hax
+UNSUPPORTED_PLATFORMS = [].freeze
+def fact(*_args)
+  []
+end
+# XXX End hax
 
 # Get a list of functions for test coverage
-function_list = Dir[File.join(File.dirname(__FILE__),"..","..","lib","puppet","parser","functions","*.rb")].collect do |function_rb|
-  File.basename(function_rb,".rb")
+function_list = Dir[File.join(File.dirname(__FILE__), '..', '..', 'lib', 'puppet', 'parser', 'functions', '*.rb')].map do |function_rb|
+  File.basename(function_rb, '.rb')
 end
 
 ## Configure rspec to parse tests
 options = RSpec::Core::ConfigurationOptions.new(['spec/acceptance'])
-configuration = RSpec::configuration
-world = RSpec::world
+configuration = RSpec.configuration
+world = RSpec.world
 options.parse_options
 options.configure(configuration)
 configuration.load_spec_files
 
 ## Collect up tests and example groups into a hash
 def get_tests(children)
-  children.inject({}) do |memo,c|
-    memo[c.description] = Hash.new
-    memo[c.description]["groups"] = get_tests(c.children) unless c.children.empty?
-    memo[c.description]["tests"] = c.examples.collect { |e|
-      e.description unless e.pending?
-    }.compact unless c.examples.empty?
-    memo[c.description]["pending_tests"] = c.examples.collect { |e|
+  children.each_with_object({}) do |c, memo|
+    memo[c.description] = {}
+    memo[c.description]['groups'] = get_tests(c.children) unless c.children.empty?
+    unless c.examples.empty?
+      memo[c.description]['tests'] = c.examples.map { |e|
+        e.description unless e.pending?
+      }.compact
+    end
+    next if c.examples.empty?
+    memo[c.description]['pending_tests'] = c.examples.map { |e|
       e.description if e.pending?
-    }.compact unless c.examples.empty?
-    memo
+    }.compact
   end
 end
 
-def count_test_types_in(type,group)
+def count_test_types_in(type, group)
   return 0 if group.nil?
-  group.inject(0) do |m,(k,v)|
+  group.reduce(0) do |m, (k, v)|
     m += v.length if k == type
     m += count_tests_in(v) if v.is_a?(Hash)
     m
   end
 end
+
 def count_tests_in(group)
-  count_test_types_in('tests',group)
+  count_test_types_in('tests', group)
 end
+
 def count_pending_tests_in(group)
-  count_test_types_in('pending_tests',group)
+  count_test_types_in('pending_tests', group)
 end
 
 # Convert tests hash to csv format
-def to_csv(function_list,tests)
-  function_list.collect do |function_name|
-    if v = tests["#{function_name} function"]
-      positive_tests = count_tests_in(v["groups"]["success"])
-      negative_tests = count_tests_in(v["groups"]["failure"])
+def to_csv(function_list, tests)
+  function_list.map { |function_name|
+    v = tests["#{function_name} function"]
+    if v
+      positive_tests = count_tests_in(v['groups']['success'])
+      negative_tests = count_tests_in(v['groups']['failure'])
       pending_tests  =
-        count_pending_tests_in(v["groups"]["failure"]) +
-        count_pending_tests_in(v["groups"]["failure"])
+        count_pending_tests_in(v['groups']['failure']) +
+        count_pending_tests_in(v['groups']['failure'])
     else
       positive_tests = 0
       negative_tests = 0
       pending_tests  = 0
     end
-    sprintf("%-25s, %-9d, %-9d, %-9d", function_name,positive_tests,negative_tests,pending_tests)
-  end.compact
+    '%-25s, %-9d, %-9d, %-9d' % [function_name, positive_tests, negative_tests, pending_tests]
+  }.compact
 end
 
 tests = get_tests(world.example_groups)
-csv = to_csv(function_list,tests)
-percentage_tested = "#{tests.count*100/function_list.count}%"
-printf("%-25s,  %-9s, %-9s, %-9s\n","#{percentage_tested} have tests.","Positive","Negative","Pending")
+csv = to_csv(function_list, tests)
+percentage_tested = "#{tests.count * 100 / function_list.count}%"
+printf("%-25s,  %-9s, %-9s, %-9s\n", "#{percentage_tested} have tests.", 'Positive', 'Negative', 'Pending')
 puts csv
old mode 100755 (executable)
new mode 100644 (file)
index 03d01a8..e3081e3
@@ -1,32 +1,29 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'capitalize function' do
+describe 'capitalize function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'should capitalize the first letter of a string' do
-      pp = <<-EOS
-      $input = 'this is a string'
-      $output = capitalize($input)
-      notify { $output: }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: This is a string/)
+    pp1 = <<-DOC
+        $input = 'this is a string'
+        $output = capitalize($input)
+        notify { $output: }
+    DOC
+    it 'capitalizes the first letter of a string' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: This is a string})
       end
     end
 
-    it 'should capitalize the first letter of an array of strings' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $input = ['this', 'is', 'a', 'string']
       $output = capitalize($input)
       notify { $output: }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: This/)
-        expect(r.stdout).to match(/Notice: Is/)
-        expect(r.stdout).to match(/Notice: A/)
-        expect(r.stdout).to match(/Notice: String/)
+    DOC
+    regex_array = [%r{Notice: This}, %r{Notice: Is}, %r{Notice: A}, %r{Notice: String}]
+    it 'capitalizes the first letter of an array of strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        regex_array.each do |i|
+          expect(r.stdout).to match(i)
+        end
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 895e4a0..782096a
@@ -1,34 +1,32 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'ceiling function' do
+describe 'ceiling function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'ceilings floats' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = 12.8
       $b = 13
       $o = ceiling($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'ceilings floats' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'ceilings integers' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = 7
       $b = 7
       $o = ceiling($a)
       if $o == $b {
-        notify { 'output correct': }
+        notify { 'output is correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'ceilings integers' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output is correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 56e0876..7fe9b1b
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'chomp function' do
+describe 'chomp function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'should eat the newline' do
-      pp = <<-EOS
+    pp = <<-DOC
       $input = "test\n"
       if size($input) != 5 {
         fail("Size of ${input} is not 5.")
@@ -13,8 +11,8 @@ describe 'chomp function' do
       if size($output) != 4 {
         fail("Size of ${input} is not 4.")
       }
-      EOS
-
+    DOC
+    it 'eats the newline' do
       apply_manifest(pp, :catch_failures => true)
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 0993806..4def10b
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'chop function' do
+describe 'chop function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'should eat the last character' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $input = "test"
       if size($input) != 4 {
         fail("Size of ${input} is not 4.")
@@ -13,13 +11,12 @@ describe 'chop function' do
       if size($output) != 3 {
         fail("Size of ${input} is not 3.")
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'eats the last character' do
+      apply_manifest(pp1, :catch_failures => true)
     end
 
-    it 'should eat the last two characters of \r\n' do
-      pp = <<-'EOS'
+    pp2 = <<-'DOC'
       $input = "test\r\n"
       if size($input) != 6 {
         fail("Size of ${input} is not 6.")
@@ -28,18 +25,17 @@ describe 'chop function' do
       if size($output) != 4 {
         fail("Size of ${input} is not 4.")
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'eats the last two characters of \r\n' do
+      apply_manifest(pp2, :catch_failures => true)
     end
 
-    it 'should not fail on empty strings' do
-      pp = <<-EOS
+    pp3 = <<-DOC
       $input = ""
       $output = chop($input)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'does not fail on empty strings' do
+      apply_manifest(pp3, :catch_failures => true)
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index e8ccb96..9885f56
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'clamp function' do
   describe 'success' do
-    it 'clamps list of values' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $x = 17
       $y = 225
       $z = 155
@@ -12,24 +10,24 @@ describe 'clamp function' do
       if $o == $z {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'clamps list of values' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'clamps array of values' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = [7, 19, 66]
       $b = 19
       $o = clamp($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'clamps array of values' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 8d184d1..391b848
@@ -1,43 +1,41 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'concat function' do
   describe 'success' do
-    it 'should concat one array to another' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $output = concat(['1','2','3'],['4','5','6'])
       validate_array($output)
       if size($output) != 6 {
         fail("${output} should have 6 elements.")
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'concats one array to another' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'should concat arrays and primitives to array' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $output = concat(['1','2','3'],'4','5','6',['7','8','9'])
       validate_array($output)
       if size($output) != 9 {
         fail("${output} should have 9 elements.")
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'concats arrays and primitives to array' do
+      apply_manifest(pp2, :catch_failures => true)
     end
-    it 'should concat multiple arrays to one' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $output = concat(['1','2','3'],['4','5','6'],['7','8','9'])
       validate_array($output)
       if size($output) != 9 {
         fail("${output} should have 9 elements.")
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'concats multiple arrays to one' do
+      apply_manifest(pp3, :catch_failures => true)
     end
-    it 'should concat hash arguments' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
       validate_array($output)
       if size($output) != 2 {
@@ -46,9 +44,9 @@ describe 'concat function' do
       if $output[1] != {"c" => "d", "e" => "f"} {
         fail("${output} does not have the expected hash for the second element.")
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'concats hash arguments' do
+      apply_manifest(pp4, :catch_failures => true)
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 18c039d..c134836
@@ -1,29 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'count function' do
   describe 'success' do
-    it 'should count elements in an array' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $input = [1,2,3,4]
       $output = count($input)
       notify { "$output": }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: 4/)
+    DOC
+    it 'counts elements in an array' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: 4})
       end
     end
 
-    it 'should count elements in an array that match a second argument' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $input = [1,1,1,2]
       $output = count($input, 1)
       notify { "$output": }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: 3/)
+    DOC
+    it 'counts elements in an array that match a second argument' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: 3})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 8222f24..29a2c79
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'deep_merge function' do
   describe 'success' do
-    it 'should deep merge two hashes' do
-      pp = <<-EOS
+    pp = <<-DOC
       $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
       $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
       $merged_hash = deep_merge($hash1, $hash2)
@@ -12,8 +10,8 @@ describe 'deep_merge function' do
       if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } {
         fail("Hash was incorrectly merged.")
       }
-      EOS
-
+    DOC
+    it 'deeps merge two hashes' do
       apply_manifest(pp, :catch_failures => true)
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index a332bd6..d8e5c8c
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'defined_with_params function' do
   describe 'success' do
-    it 'should successfully notify' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       user { 'dan':
         ensure => present,
       }
@@ -12,10 +10,29 @@ describe 'defined_with_params function' do
       if defined_with_params(User[dan], {'ensure' => 'present' }) {
         notify { 'User defined with ensure=>present': }
       }
-      EOS
+    DOC
+    it 'successfullies checks a type' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: User defined with ensure=>present})
+      end
+    end
+
+    pp2 = <<-DOC
+      class foo (
+        $bar,
+      ) {}
 
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: User defined with ensure=>present/)
+      class { 'foo':
+        bar => 'baz',
+      }
+
+      if defined_with_params(Class[foo], { 'bar' => 'baz' }) {
+        notify { 'Class foo defined with bar=>baz': }
+      }
+    DOC
+    it 'successfullies checks a class' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: Class foo defined with bar=>baz})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index d4f852a..6a34e21
@@ -1,18 +1,16 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'delete_at function' do
   describe 'success' do
-    it 'should delete elements of the array' do
-      pp = <<-EOS
+    pp = <<-DOC
       $output = delete_at(['a','b','c','b'], 1)
       if $output == ['a','c','b'] {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'deletes elements of the array' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index f85b093..70877cb
@@ -1,18 +1,16 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'delete function' do
-  describe 'success' do
-    it 'should delete elements of the array' do
-      pp = <<-EOS
+  pp = <<-DOC
       $output = delete(['a','b','c','b'], 'b')
       if $output == ['a','c'] {
         notify { 'output correct': }
       }
-      EOS
-
+  DOC
+  describe 'success' do
+    it 'deletes elements of the array' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index af45a92..418c959
@@ -1,18 +1,16 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'delete_undef_values function' do
   describe 'success' do
-    it 'should delete elements of the array' do
-      pp = <<-EOS
+    pp = <<-DOC
       $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
       if $output == { a => 'A', b => '', d => false } {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'deletes elements of the array' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 04b6920..634d319
@@ -1,20 +1,18 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'delete_values function' do
   describe 'success' do
-    it 'should delete elements of the hash' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' }
       $b = { 'a' => 'A', 'B' => 'C' }
       $o = delete_values($a, 'B')
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'deletes elements of the hash' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
index 7a0b34c..9f25449 100644 (file)
@@ -1,13 +1,11 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'deprecation function' do
-
-  if fact('operatingsystem') == 'windows'
-    test_file = 'C:/deprecation'
-    else
-    test_file = "/tmp/deprecation"
-  end
+  test_file = if fact('operatingsystem') == 'windows'
+                'C:/deprecation'
+              else
+                '/tmp/deprecation'
+              end
 
   # It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format
   add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
@@ -17,86 +15,78 @@ describe 'deprecation function' do
     apply_manifest(remove_file_manifest)
   end
 
-  context 'with --strict=error', if: get_puppet_version =~ /^4/ do
-    before :all do
-      @result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
-    end
+  context 'with --strict=error', :if => return_puppet_version =~ %r{^4} do
+    let(:result) { on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
 
     after :all do
       apply_manifest(remove_file_manifest)
     end
 
-    it "should return an error" do
-      expect(@result.exit_code).to eq(1)
+    it 'returns an error' do
+      expect(result.exit_code).to eq(1)
     end
 
-    it "should show the error message" do
-      expect(@result.stderr).to match(/deprecation. key. message/)
+    it 'shows the error message' do
+      expect(result.stderr).to match(%r{deprecation. key. message})
     end
 
-    describe file("#{test_file}") do
+    describe file(test_file.to_s) do
       it { is_expected.not_to be_file }
     end
   end
 
-  context 'with --strict=warning', if: get_puppet_version =~ /^4/ do
-    before :all do
-      @result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
-    end
+  context 'with --strict=warning', :if => return_puppet_version =~ %r{^4} do
+    let(:result) { on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
 
     after :all do
       apply_manifest(remove_file_manifest)
     end
 
-    it "should not return an error" do
-      expect(@result.exit_code).to eq(0)
+    it 'does not return an error' do
+      expect(result.exit_code).to eq(0)
     end
 
-    it "should show the error message" do
-      expect(@result.stderr).to match(/Warning: message/)
+    it 'shows the error message' do
+      expect(result.stderr).to match(%r{Warning: message})
     end
 
-    describe file("#{test_file}") do
+    describe file(test_file.to_s) do
       it { is_expected.to be_file }
     end
   end
 
-  context 'with --strict=off', if: get_puppet_version =~ /^4/ do
-    before :all do
-      @result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
-    end
+  context 'with --strict=off', :if => return_puppet_version =~ %r{^4} do
+    let(:result) { on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
 
     after :all do
       apply_manifest(remove_file_manifest)
     end
 
-    it "should not return an error" do
-      expect(@result.exit_code).to eq(0)
+    it 'does not return an error' do
+      expect(result.exit_code).to eq(0)
     end
 
-    it "should not show the error message" do
-      expect(@result.stderr).not_to match(/Warning: message/)
+    it 'does not show the error message' do
+      expect(result.stderr).not_to match(%r{Warning: message})
     end
 
-    describe file("#{test_file}") do
+    describe file(test_file.to_s) do
       it { is_expected.to be_file }
     end
   end
 
-  context 'puppet 3 test', if: get_puppet_version =~ /^3/ do
-    before :all do
-      @result = on(default, puppet('apply', '--parser=future', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
-    end
+  context 'puppet 3 test', :if => return_puppet_version =~ %r{^3} do
+    let(:result) { on(default, puppet('apply', '--parser=future', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
+
     after :all do
       apply_manifest(remove_file_manifest)
     end
 
-    it "should return a deprecation error" do
-      expect(@result.stderr).to match(/Warning: message/)
+    it 'returns a deprecation error' do
+      expect(result.stderr).to match(%r{Warning: message})
     end
-    it "should pass without error" do
-      expect(@result.exit_code).to eq(0)
+    it 'passes without error' do
+      expect(result.exit_code).to eq(0)
     end
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index 68f6bbe..7988f69
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'difference function' do
   describe 'success' do
-    it 'returns non-duplicates in the first array' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = ['a','b','c']
       $b = ['b','c','d']
       $c = ['a']
@@ -12,10 +10,10 @@ describe 'difference function' do
       if $o == $c {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'returns non-duplicates in the first array' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index db83f0f..a532e11
@@ -1,37 +1,34 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'dirname function' do
   describe 'success' do
-    context 'absolute path' do
-      it 'returns the dirname' do
-        pp = <<-EOS
+    context 'with absolute path' do
+      pp1 = <<-DOC
         $a = '/path/to/a/file.txt'
         $b = '/path/to/a'
         $o = dirname($a)
         if $o == $b {
           notify { 'output correct': }
         }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/Notice: output correct/)
+      DOC
+      it 'returns the dirname' do
+        apply_manifest(pp1, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{Notice: output correct})
         end
       end
     end
-    context 'relative path' do
-      it 'returns the dirname' do
-        pp = <<-EOS
+    context 'with relative path' do
+      pp2 = <<-DOC
         $a = 'path/to/a/file.txt'
         $b = 'path/to/a'
         $o = dirname($a)
         if $o == $b {
           notify { 'output correct': }
         }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/Notice: output correct/)
+      DOC
+      it 'returns the dirname' do
+        apply_manifest(pp2, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{Notice: output correct})
         end
       end
     end
old mode 100755 (executable)
new mode 100644 (file)
index 300bcfa..053a16f
@@ -1,34 +1,32 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'downcase function' do
+describe 'downcase function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'returns the downcase' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = 'AOEU'
       $b = 'aoeu'
       $o = downcase($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'returns the downcase' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'doesn\'t affect lowercase words' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = 'aoeu aoeu'
       $b = 'aoeu aoeu'
       $o = downcase($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'doesn\'t affect lowercase words' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 97b7333..c5c63c0
@@ -1,48 +1,46 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'empty function' do
+describe 'empty function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   describe 'success' do
-    it 'recognizes empty strings' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ''
       $b = true
       $o = empty($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'recognizes empty strings' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'recognizes non-empty strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = 'aoeu'
       $b = false
       $o = empty($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'recognizes non-empty strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'handles numerical values' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = 7
       $b = false
       $o = empty($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'handles numerical values' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 93f25dd..21e73d3
@@ -1,25 +1,24 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'ensure_resource function' do
   describe 'success' do
-    it 'ensures a resource already declared' do
-      apply_manifest('')
-      pp = <<-EOS
+    pp1 = <<-DOC
       notify { "test": loglevel => 'err' }
       ensure_resource('notify', 'test', { 'loglevel' => 'err' })
-      EOS
+    DOC
+    it 'ensures a resource already declared' do
+      apply_manifest('')
 
-      apply_manifest(pp, :expect_changes => true)
+      apply_manifest(pp1, :expect_changes => true)
     end
 
+    pp2 = <<-DOC
+      ensure_resource('notify', 'test', { 'loglevel' => 'err' })
+    DOC
     it 'ensures a undeclared resource' do
       apply_manifest('')
-      pp = <<-EOS
-      ensure_resource('notify', 'test', { 'loglevel' => 'err' })
-      EOS
 
-      apply_manifest(pp, :expect_changes => true)
+      apply_manifest(pp2, :expect_changes => true)
     end
     it 'takes defaults arguments'
   end
old mode 100755 (executable)
new mode 100644 (file)
index 289eec9..79d4854
@@ -1,34 +1,32 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'flatten function' do
+describe 'flatten function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   describe 'success' do
-    it 'flattens arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["a","b",["c",["d","e"],"f","g"]]
       $b = ["a","b","c","d","e","f","g"]
       $o = flatten($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'flattens arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'does not affect flat arrays' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = ["a","b","c","d","e","f","g"]
       $b = ["a","b","c","d","e","f","g"]
       $o = flatten($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'does not affect flat arrays' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 8259d2a..fde6d8e
@@ -1,34 +1,32 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'floor function' do
+describe 'floor function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'floors floats' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = 12.8
       $b = 12
       $o = floor($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'floors floats' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'floors integers' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = 7
       $b = 7
       $o = floor($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'floors integers' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
index af1b2a9..5916553 100644 (file)
@@ -1,60 +1,58 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'fqdn_rand_string function' do
   describe 'success' do
-    include_context "with faked facts"
+    include_context 'with faked facts'
     context "when the FQDN is 'fakehost.localdomain'" do
       before :each do
-        fake_fact("fqdn", "fakehost.localdomain")
+        fake_fact('fqdn', 'fakehost.localdomain')
       end
 
-      it 'generates random alphanumeric strings' do
-        pp = <<-eos
+      pp1 = <<-PUPPETCODE
         $l = 10
         $o = fqdn_rand_string($l)
         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
-        eos
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"/)
+      PUPPETCODE
+      it 'generates random alphanumeric strings' do
+        apply_manifest(pp1, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"})
         end
       end
-      it 'generates random alphanumeric strings with custom charsets' do
-        pp = <<-eos
+
+      pp2 = <<-PUPPETCODE
         $l = 10
         $c = '0123456789'
         $o = fqdn_rand_string($l, $c)
         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
-        eos
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rand_string is "(7203048515|2383756694)"/)
+      PUPPETCODE
+      it 'generates random alphanumeric strings with custom charsets' do
+        apply_manifest(pp2, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rand_string is "(7203048515|2383756694)"})
         end
       end
-      it 'generates random alphanumeric strings with custom seeds' do
-        pp = <<-eos
+
+      pp3 = <<-PUPPETCODE
         $l = 10
         $s = 'seed'
         $o = fqdn_rand_string($l, undef, $s)
         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
-        eos
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"/)
+      PUPPETCODE
+      it 'generates random alphanumeric strings with custom seeds' do
+        apply_manifest(pp3, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"})
         end
       end
-      it 'generates random alphanumeric strings with custom charsets and seeds' do
-        pp = <<-eos
+
+      pp4 = <<-PUPPETCODE
         $l = 10
         $c = '0123456789'
         $s = 'seed'
         $o = fqdn_rand_string($l, $c, $s)
         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
-        eos
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rand_string is "(3104058232|7100592312)"/)
+      PUPPETCODE
+      it 'generates random alphanumeric strings with custom charsets and seeds' do
+        apply_manifest(pp4, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rand_string is "(3104058232|7100592312)"})
         end
       end
     end
old mode 100755 (executable)
new mode 100644 (file)
index 66e94a9..99f315e
@@ -1,58 +1,56 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'fqdn_rotate function' do
   describe 'success' do
-    include_context "with faked facts"
+    include_context 'with faked facts'
     context "when the FQDN is 'fakehost.localdomain'" do
       before :each do
-        fake_fact("fqdn", "fakehost.localdomain")
+        fake_fact('fqdn', 'fakehost.localdomain')
       end
 
-      it 'rotates arrays' do
-        pp = <<-EOS
+      pp1 = <<-DOC
         $a = ['a','b','c','d']
         $o = fqdn_rotate($a)
         notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rotate is \["d", "a", "b", "c"\]/)
+      DOC
+      it 'rotates arrays' do
+        apply_manifest(pp1, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rotate is \["d", "a", "b", "c"\]})
         end
       end
-      it 'rotates arrays with custom seeds' do
-        pp = <<-EOS
+
+      pp2 = <<-DOC
         $a = ['a','b','c','d']
         $s = 'seed'
         $o = fqdn_rotate($a, $s)
         notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
+      DOC
+      it 'rotates arrays with custom seeds' do
+        apply_manifest(pp2, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rotate is \["c", "d", "a", "b"\]})
         end
       end
-      it 'rotates strings' do
-        pp = <<-EOS
+
+      pp3 = <<-DOC
         $a = 'abcd'
         $o = fqdn_rotate($a)
         notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rotate is "dabc"/)
+      DOC
+      it 'rotates strings' do
+        apply_manifest(pp3, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rotate is "dabc"})
         end
       end
-      it 'rotates strings with custom seeds' do
-        pp = <<-EOS
+
+      pp4 = <<-DOC
         $a = 'abcd'
         $s = 'seed'
         $o = fqdn_rotate($a, $s)
         notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
-        EOS
-
-        apply_manifest(pp, :catch_failures => true) do |r|
-          expect(r.stdout).to match(/fqdn_rotate is "cdab"/)
+      DOC
+      it 'rotates strings with custom seeds' do
+        apply_manifest(pp4, :catch_failures => true) do |r|
+          expect(r.stdout).to match(%r{fqdn_rotate is "cdab"})
         end
       end
     end
old mode 100755 (executable)
new mode 100644 (file)
index 3d10251..f9b169c
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'get_module_path function' do
   describe 'success' do
-    it 'get_module_paths dne' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = $::is_pe ? {
         'true'  => '/etc/puppetlabs/puppet/modules/dne',
         'false' => '/etc/puppet/modules/dne',
@@ -15,8 +13,8 @@ describe 'get_module_path function' do
       } else {
         notify { "failed; module path is '$o'": }
       }
-      EOS
-
+    DOC
+    it 'get_module_paths dne' do
       apply_manifest(pp, :expect_failures => true)
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index bd12154..6ed2257
@@ -1,19 +1,17 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'getparam function' do
   describe 'success' do
-    it 'getparam a notify' do
-      pp = <<-EOS
+    pp = <<-DOC
       notify { 'rspec':
         message => 'custom rspec message',
       }
       $o = getparam(Notify['rspec'], 'message')
       notice(inline_template('getparam is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'getparam a notify' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/getparam is "custom rspec message"/)
+        expect(r.stdout).to match(%r{getparam is "custom rspec message"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 605cdce..0b14afb
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'getvar function' do
   describe 'success' do
-    it 'getvars from classes' do
-      pp = <<-EOS
+    pp = <<-DOC
       class a::data { $foo = 'aoeu' }
       include a::data
       $b = 'aoeu'
@@ -12,10 +10,10 @@ describe 'getvar function' do
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'getvars from classes' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 7c35ee4..1fe2027
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'grep function' do
   describe 'success' do
-    it 'greps arrays' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = ['aaabbb','bbbccc','dddeee']
       $b = 'bbb'
       $c = ['aaabbb','bbbccc']
@@ -12,10 +10,10 @@ describe 'grep function' do
       if $o == $c {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'greps arrays' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index fd33af5..d16dc1d
@@ -1,32 +1,30 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do
   describe 'success' do
-    it 'has_interface_with existing ipaddress' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = $::ipaddress
       $o = has_interface_with('ipaddress', $a)
       notice(inline_template('has_interface_with is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/has_interface_with is true/)
+    DOC
+    it 'has_interface_with existing ipaddress' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{has_interface_with is true})
       end
     end
-    it 'has_interface_with absent ipaddress' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = '128.0.0.1'
       $o = has_interface_with('ipaddress', $a)
       notice(inline_template('has_interface_with is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/has_interface_with is false/)
+    DOC
+    it 'has_interface_with absent ipaddress' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{has_interface_with is false})
       end
     end
-    it 'has_interface_with existing interface' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       if $osfamily == 'Solaris' or $osfamily == 'Darwin' {
         $a = 'lo0'
       }elsif $osfamily == 'windows' {
@@ -40,10 +38,10 @@ describe 'has_interface_with function', :unless => ((fact('osfamily') == 'window
       }
       $o = has_interface_with($a)
       notice(inline_template('has_interface_with is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/has_interface_with is true/)
+    DOC
+    it 'has_interface_with existing interface' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{has_interface_with is true})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 878d921..13cdd77
@@ -1,28 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do
   describe 'success' do
-    it 'has_ip_address existing ipaddress' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = '127.0.0.1'
       $o = has_ip_address($a)
       notice(inline_template('has_ip_address is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/has_ip_address is true/)
+    DOC
+    it 'has_ip_address existing ipaddress' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{has_ip_address is true})
       end
     end
-    it 'has_ip_address absent ipaddress' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = '128.0.0.1'
       $o = has_ip_address($a)
       notice(inline_template('has_ip_address is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/has_ip_address is false/)
+    DOC
+    it 'has_ip_address absent ipaddress' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{has_ip_address is false})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index f7a7d35..e18f050
@@ -1,28 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do
   describe 'success' do
-    it 'has_ip_network existing ipaddress' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = '127.0.0.0'
       $o = has_ip_network($a)
       notice(inline_template('has_ip_network is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/has_ip_network is true/)
+    DOC
+    it 'has_ip_network existing ipaddress' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{has_ip_network is true})
       end
     end
-    it 'has_ip_network absent ipaddress' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = '128.0.0.0'
       $o = has_ip_network($a)
       notice(inline_template('has_ip_network is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/has_ip_network is false/)
+    DOC
+    it 'has_ip_network absent ipaddress' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{has_ip_network is false})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 661c122..9da69c2
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'has_key function' do
   describe 'success' do
-    it 'has_keys in hashes' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
       $b = 'bbb'
       $c = true
@@ -12,14 +10,14 @@ describe 'has_key function' do
       if $o == $c {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'has_keys in hashes' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'has_keys not in hashes' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
       $b = 'ccc'
       $c = false
@@ -27,10 +25,10 @@ describe 'has_key function' do
       if $o == $c {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'has_keys not in hashes' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 85da50b..82e9245
@@ -1,20 +1,18 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'hash function' do
   describe 'success' do
-    it 'hashs arrays' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = ['aaa','bbb','bbb','ccc','ddd','eee']
       $b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' }
       $o = hash($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'hashs arrays' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
     it 'handles odd-length arrays'
old mode 100755 (executable)
new mode 100644 (file)
index 02d4e7d..75dfe87
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'intersection function' do
   describe 'success' do
-    it 'intersections arrays' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = ['aaa','bbb','ccc']
       $b = ['bbb','ccc','ddd','eee']
       $c = ['bbb','ccc']
@@ -12,10 +10,10 @@ describe 'intersection function' do
       if $o == $c {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'intersections arrays' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
     it 'intersections empty arrays'
index fb0019a..449e3e7 100644 (file)
@@ -1,29 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-if get_puppet_version =~ /^4/
+if return_puppet_version =~ %r{^4}
   describe 'is_a function' do
-    it 'should match a string' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       if 'hello world'.is_a(String) {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'matches a string' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
 
-    it 'should not match a integer as string' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       if 5.is_a(String) {
         notify { 'output wrong': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).not_to match(/Notice: output wrong/)
+    DOC
+    it 'does not match a integer as string' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).not_to match(%r{Notice: output wrong})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 1a83417..408ff1e
@@ -1,62 +1,60 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_array function' do
   describe 'success' do
-    it 'is_arrays arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa','bbb','ccc']
       $b = true
       $o = is_array($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_arrays arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_arrays empty arrays' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = []
       $b = true
       $o = is_array($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_arrays empty arrays' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_arrays strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "aoeu"
       $b = false
       $o = is_array($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_arrays strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_arrays hashes' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = {'aaa'=>'bbb'}
       $b = false
       $o = is_array($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_arrays hashes' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 823cb46..e9dab73
@@ -1,76 +1,74 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_bool function' do
   describe 'success' do
-    it 'is_bools arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa','bbb','ccc']
       $b = false
       $o = is_bool($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_bools arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_bools true' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = true
       $b = true
       $o = is_bool($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_bools true' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_bools false' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = false
       $b = true
       $o = is_bool($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_bools false' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_bools strings' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = "true"
       $b = false
       $o = is_bool($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_bools strings' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_bools hashes' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $a = {'aaa'=>'bbb'}
       $b = false
       $o = is_bool($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_bools hashes' do
+      apply_manifest(pp5, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 884b0bc..b33eb7a
@@ -1,78 +1,76 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_domain_name function' do
   describe 'success' do
-    it 'is_domain_names arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa.com','bbb','ccc']
       $o = is_domain_name($a)
       notice(inline_template('is_domain_name is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_domain_name is false/)
+    DOC
+    it 'is_domain_names arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_domain_name is false})
       end
     end
-    it 'is_domain_names true' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = true
       $o = is_domain_name($a)
       notice(inline_template('is_domain_name is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_domain_name is false/)
+    DOC
+    it 'is_domain_names true' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_domain_name is false})
       end
     end
-    it 'is_domain_names false' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = false
       $o = is_domain_name($a)
       notice(inline_template('is_domain_name is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_domain_name is false/)
+    DOC
+    it 'is_domain_names false' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_domain_name is false})
       end
     end
-    it 'is_domain_names strings with hyphens' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = "3foo-bar.2bar-fuzz.com"
       $b = true
       $o = is_domain_name($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_domain_names strings with hyphens' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_domain_names strings beginning with hyphens' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $a = "-bar.2bar-fuzz.com"
       $b = false
       $o = is_domain_name($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_domain_names strings beginning with hyphens' do
+      apply_manifest(pp5, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_domain_names hashes' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $a = {'aaa'=>'www.com'}
       $o = is_domain_name($a)
       notice(inline_template('is_domain_name is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_domain_name is false/)
+    DOC
+    it 'is_domain_names hashes' do
+      apply_manifest(pp6, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_domain_name is false})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 0b38d94..524f338
@@ -1,81 +1,79 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_float function' do
   describe 'success' do
-    it 'is_floats arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa.com','bbb','ccc']
       $o = is_float($a)
       notice(inline_template('is_float is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_float is false/)
+    DOC
+    it 'is_floats arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_float is false})
       end
     end
-    it 'is_floats true' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = true
       $o = is_float($a)
       notice(inline_template('is_float is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_float is false/)
+    DOC
+    it 'is_floats true' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_float is false})
       end
     end
-    it 'is_floats strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "3.5"
       $b = true
       $o = is_float($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_floats strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_floats floats' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = 3.5
       $b = true
       $o = is_float($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_floats floats' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_floats integers' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $a = 3
       $b = false
       $o = is_float($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_floats integers' do
+      apply_manifest(pp5, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_floats hashes' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $a = {'aaa'=>'www.com'}
       $o = is_float($a)
       notice(inline_template('is_float is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_float is false/)
+    DOC
+    it 'is_floats hashes' do
+      apply_manifest(pp6, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_float is false})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index f8191ee..8bb63f2
@@ -1,53 +1,51 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_function_available function' do
   describe 'success' do
-    it 'is_function_availables arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['fail','include','require']
       $o = is_function_available($a)
       notice(inline_template('is_function_available is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_function_available is false/)
+    DOC
+    it 'is_function_availables arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_function_available is false})
       end
     end
-    it 'is_function_availables true' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = true
       $o = is_function_available($a)
       notice(inline_template('is_function_available is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_function_available is false/)
+    DOC
+    it 'is_function_availables true' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_function_available is false})
       end
     end
-    it 'is_function_availables strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "fail"
       $b = true
       $o = is_function_available($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_function_availables strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_function_availables function_availables' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = "is_function_available"
       $o = is_function_available($a)
       notice(inline_template('is_function_available is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_function_available is true/)
+    DOC
+    it 'is_function_availables function_availables' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_function_available is true})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 64f016c..c5f6b2e
@@ -1,59 +1,57 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_hash function' do
   describe 'success' do
-    it 'is_hashs arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa','bbb','ccc']
       $o = is_hash($a)
       notice(inline_template('is_hash is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_hash is false/)
+    DOC
+    it 'is_hashs arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_hash is false})
       end
     end
-    it 'is_hashs empty hashs' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = {}
       $b = true
       $o = is_hash($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_hashs empty hashs' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_hashs strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "aoeu"
       $b = false
       $o = is_hash($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_hashs strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_hashs hashes' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = {'aaa'=>'bbb'}
       $b = true
       $o = is_hash($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_hashs hashes' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 7333687..45a8c2b
@@ -1,90 +1,88 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_integer function' do
   describe 'success' do
-    it 'is_integers arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa.com','bbb','ccc']
       $b = false
       $o = is_integer($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_integers arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_integers true' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = true
       $b = false
       $o = is_integer($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_integers true' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_integers strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "3"
       $b = true
       $o = is_integer($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_integers strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_integers floats' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = 3.5
       $b = false
       $o = is_integer($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_integers floats' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_integers integers' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $a = 3
       $b = true
       $o = is_integer($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_integers integers' do
+      apply_manifest(pp5, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_integers hashes' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $a = {'aaa'=>'www.com'}
       $b = false
       $o = is_integer($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_integers hashes' do
+      apply_manifest(pp6, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 2c62c77..e528fe5
@@ -1,76 +1,74 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_ip_address function' do
   describe 'success' do
-    it 'is_ip_addresss ipv4' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = '1.2.3.4'
       $b = true
       $o = is_ip_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ip_addresss ipv4' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ip_addresss ipv6' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
       $b = true
       $o = is_ip_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ip_addresss ipv6' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ip_addresss ipv6 compressed' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "fe00::1"
       $b = true
       $o = is_ip_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ip_addresss ipv6 compressed' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ip_addresss strings' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = "aoeu"
       $b = false
       $o = is_ip_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ip_addresss strings' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ip_addresss ipv4 out of range' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $a = '1.2.3.400'
       $b = false
       $o = is_ip_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ip_addresss ipv4 out of range' do
+      apply_manifest(pp5, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index abe26d8..04cb45f
@@ -1,48 +1,46 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_ipv4_address function' do
   describe 'success' do
-    it 'is_ipv4_addresss' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = '1.2.3.4'
       $b = true
       $o = is_ipv4_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ipv4_addresss' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ipv4_addresss strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "aoeu"
       $b = false
       $o = is_ipv4_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ipv4_addresss strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ipv4_addresss ipv4 out of range' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = '1.2.3.400'
       $b = false
       $o = is_ipv4_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ipv4_addresss ipv4 out of range' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 73a3fa4..03e5dd1
@@ -1,62 +1,60 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_ipv6_address function' do
   describe 'success' do
-    it 'is_ipv6_addresss' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
       $b = true
       $o = is_ipv6_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ipv6_addresss' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ipv6_addresss ipv6 compressed' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "fe00::1"
       $b = true
       $o = is_ipv6_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ipv6_addresss ipv6 compressed' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ipv6_addresss strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "aoeu"
       $b = false
       $o = is_ipv6_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ipv6_addresss strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_ipv6_addresss ip out of range' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = 'fe80:0000:cd12:d123:e2f8:47ff:fe09:gggg'
       $b = false
       $o = is_ipv6_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_ipv6_addresss ip out of range' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 617bef6..8e96abf
@@ -1,34 +1,46 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_mac_address function' do
   describe 'success' do
-    it 'is_mac_addresss a mac' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = '00:a0:1f:12:7f:a0'
       $b = true
       $o = is_mac_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_mac_addresss a mac' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_mac_addresss a mac out of range' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = '00:a0:1f:12:7f:g0'
       $b = false
       $o = is_mac_address($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
+    DOC
+    it 'is_mac_addresss a mac out of range' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
+      end
+    end
 
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    pp3 = <<-DOC
+      $a = '80:00:02:09:fe:80:00:00:00:00:00:00:00:24:65:ff:ff:91:a3:12'
+      $b = true
+      $o = is_mac_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+    DOC
+    it 'is_mac_addresss a 20-octet mac' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 7e65384..4ec7f0c
@@ -1,90 +1,88 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_numeric function' do
   describe 'success' do
-    it 'is_numerics arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa.com','bbb','ccc']
       $b = false
       $o = is_numeric($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_numerics arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_numerics true' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = true
       $b = false
       $o = is_numeric($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_numerics true' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_numerics strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "3"
       $b = true
       $o = is_numeric($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_numerics strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_numerics floats' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = 3.5
       $b = true
       $o = is_numeric($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_numerics floats' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_numerics integers' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $a = 3
       $b = true
       $o = is_numeric($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_numerics integers' do
+      apply_manifest(pp5, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_numerics hashes' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $a = {'aaa'=>'www.com'}
       $b = false
       $o = is_numeric($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_numerics hashes' do
+      apply_manifest(pp6, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index bee5e01..e3ab31a
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'is_string function' do
   describe 'success' do
-    it 'is_strings arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa.com','bbb','ccc']
       $b = false
       $o = is_string($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_strings arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_strings true' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = true
       $b = false
       $o = is_string($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_strings true' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_strings strings' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "aoeu"
       $o = is_string($a)
       notice(inline_template('is_string is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_string is true/)
+    DOC
+    it 'is_strings strings' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_string is true})
       end
     end
-    it 'is_strings number strings' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = "3"
       $o = is_string($a)
       notice(inline_template('is_string is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_string is false/)
+    DOC
+    it 'is_strings number strings' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_string is false})
       end
     end
-    it 'is_strings floats' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $a = 3.5
       $b = false
       $o = is_string($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_strings floats' do
+      apply_manifest(pp5, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_strings integers' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $a = 3
       $b = false
       $o = is_string($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_strings integers' do
+      apply_manifest(pp6, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_strings hashes' do
-      pp = <<-EOS
+
+    pp7 = <<-DOC
       $a = {'aaa'=>'www.com'}
       $b = false
       $o = is_string($a)
       if $o == $b {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'is_strings hashes' do
+      apply_manifest(pp7, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
-    it 'is_strings undef' do
-      pp = <<-EOS
+
+    pp8 = <<-DOC
       $a = undef
       $o = is_string($a)
       notice(inline_template('is_string is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/is_string is true/)
+    DOC
+    it 'is_strings undef' do
+      apply_manifest(pp8, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{is_string is true})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index ae6947e..a9f30e3
@@ -1,18 +1,16 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'join_keys_to_values function' do
   describe 'success' do
-    it 'join_keys_to_valuess hashes' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = {'aaa'=>'bbb','ccc'=>'ddd'}
       $b = ':'
       $o = join_keys_to_values($a,$b)
       notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>'))
-      EOS
-
+    DOC
+    it 'join_keys_to_valuess hashes' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]/)
+        expect(r.stdout).to match(%r{join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]})
       end
     end
     it 'handles non hashes'
old mode 100755 (executable)
new mode 100644 (file)
index 75b88d8..233b953
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'join function' do
+describe 'join function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   describe 'success' do
-    it 'joins arrays' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = ['aaa','bbb','ccc']
       $b = ':'
       $c = 'aaa:bbb:ccc'
@@ -12,10 +10,10 @@ describe 'join function' do
       if $o == $c {
         notify { 'output correct': }
       }
-      EOS
-
+    DOC
+    it 'joins arrays' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
     it 'handles non arrays'
old mode 100755 (executable)
new mode 100644 (file)
index 65bfe28..9c4122c
@@ -1,17 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'keys function' do
+describe 'keys function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   describe 'success' do
-    it 'keyss hashes' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = {'aaa'=>'bbb','ccc'=>'ddd'}
       $o = keys($a)
       notice(inline_template('keys is <%= @o.sort.inspect %>'))
-      EOS
-
+    DOC
+    it 'keyss hashes' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/keys is \["aaa", "ccc"\]/)
+        expect(r.stdout).to match(%r{keys is \["aaa", "ccc"\]})
       end
     end
     it 'handles non hashes'
index ebd5307..31d015a 100644 (file)
@@ -1,48 +1,44 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 tmpdir = default.tmpdir('stdlib')
 
 describe 'loadjson function' do
   describe 'success' do
-    it 'loadjsons array of values' do
-      shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/testjson.json")
-      pp = <<-EOS
-      $o = loadjson('#{tmpdir}/testjson.json')
+    shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/test1json.json")
+    pp1 = <<-DOC
+      $o = loadjson('#{tmpdir}/test1json.json')
       notice(inline_template('loadjson[aaa] is <%= @o["aaa"].inspect %>'))
       notice(inline_template('loadjson[bbb] is <%= @o["bbb"].inspect %>'))
       notice(inline_template('loadjson[ccc] is <%= @o["ccc"].inspect %>'))
       notice(inline_template('loadjson[ddd] is <%= @o["ddd"].inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/loadjson\[aaa\] is 1/)
-        expect(r.stdout).to match(/loadjson\[bbb\] is 2/)
-        expect(r.stdout).to match(/loadjson\[ccc\] is 3/)
-        expect(r.stdout).to match(/loadjson\[ddd\] is 4/)
+    DOC
+    regex_array = [%r{loadjson\[aaa\] is 1}, %r{loadjson\[bbb\] is 2}, %r{loadjson\[ccc\] is 3}, %r{loadjson\[ddd\] is 4}]
+    it 'loadjsons array of values' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        regex_array.each do |i|
+          expect(r.stdout).to match(i)
+        end
       end
     end
 
-    it 'returns the default value if there is no file to load' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $o = loadjson('#{tmpdir}/no-file.json', {'default' => 'value'})
       notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/loadjson\[default\] is "value"/)
+    DOC
+    it 'returns the default value if there is no file to load' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{loadjson\[default\] is "value"})
       end
     end
 
-    it 'returns the default value if the file was parsed with an error' do
-      shell("echo '!' > #{tmpdir}/testjson.json")
-      pp = <<-EOS
-      $o = loadjson('#{tmpdir}/testjson.json', {'default' => 'value'})
+    shell("echo '!' > #{tmpdir}/test2json.json")
+    pp3 = <<-DOC
+      $o = loadjson('#{tmpdir}/test2json.json', {'default' => 'value'})
       notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/loadjson\[default\] is "value"/)
+    DOC
+    it 'returns the default value if the file was parsed with an error' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{loadjson\[default\] is "value"})
       end
     end
   end
index 57fb8cb..f55274c 100644 (file)
@@ -1,52 +1,48 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 tmpdir = default.tmpdir('stdlib')
 
 describe 'loadyaml function' do
   describe 'success' do
-    it 'loadyamls array of values' do
-      shell("echo '---
+    shell("echo '---
       aaa: 1
       bbb: 2
       ccc: 3
-      ddd: 4' > #{tmpdir}/testyaml.yaml")
-      pp = <<-EOS
-      $o = loadyaml('#{tmpdir}/testyaml.yaml')
+      ddd: 4' > #{tmpdir}/test1yaml.yaml")
+    pp1 = <<-DOC
+      $o = loadyaml('#{tmpdir}/test1yaml.yaml')
       notice(inline_template('loadyaml[aaa] is <%= @o["aaa"].inspect %>'))
       notice(inline_template('loadyaml[bbb] is <%= @o["bbb"].inspect %>'))
       notice(inline_template('loadyaml[ccc] is <%= @o["ccc"].inspect %>'))
       notice(inline_template('loadyaml[ddd] is <%= @o["ddd"].inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/loadyaml\[aaa\] is 1/)
-        expect(r.stdout).to match(/loadyaml\[bbb\] is 2/)
-        expect(r.stdout).to match(/loadyaml\[ccc\] is 3/)
-        expect(r.stdout).to match(/loadyaml\[ddd\] is 4/)
+    DOC
+    regex_array = [%r{loadyaml\[aaa\] is 1}, %r{loadyaml\[bbb\] is 2}, %r{loadyaml\[ccc\] is 3}, %r{loadyaml\[ddd\] is 4}]
+    it 'loadyamls array of values' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        regex_array.each do |i|
+          expect(r.stdout).to match(i)
+        end
       end
     end
 
-    it 'returns the default value if there is no file to load' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $o = loadyaml('#{tmpdir}/no-file.yaml', {'default' => 'value'})
       notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/loadyaml\[default\] is "value"/)
+    DOC
+    it 'returns the default value if there is no file to load' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{loadyaml\[default\] is "value"})
       end
     end
 
-    it 'returns the default value if the file was parsed with an error' do
-      shell("echo '!' > #{tmpdir}/testyaml.yaml")
-      pp = <<-EOS
-      $o = loadyaml('#{tmpdir}/testyaml.yaml', {'default' => 'value'})
+    shell("echo '!' > #{tmpdir}/test2yaml.yaml")
+    pp3 = <<-DOC
+      $o = loadyaml('#{tmpdir}/test2yaml.yaml', {'default' => 'value'})
       notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/loadyaml\[default\] is "value"/)
+    DOC
+    it 'returns the default value if the file was parsed with an error' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{loadyaml\[default\] is "value"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index eba5d0d..1621c57
@@ -1,29 +1,27 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'lstrip function' do
+describe 'lstrip function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'lstrips arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["  the   ","   public   ","   art","galleries   "]
       # Anagram: Large picture halls, I bet
       $o = lstrip($a)
       notice(inline_template('lstrip is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/lstrip is \["the   ", "public   ", "art", "galleries   "\]/)
+    DOC
+    it 'lstrips arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{lstrip is \["the   ", "public   ", "art", "galleries   "\]})
       end
     end
-    it 'lstrips strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "   blowzy night-frumps vex'd jack q   "
       $o = lstrip($a)
       notice(inline_template('lstrip is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/lstrip is "blowzy night-frumps vex'd jack q   "/)
+    DOC
+    it 'lstrips strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{lstrip is "blowzy night-frumps vex'd jack q   "})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 3caa813..3958a70
@@ -1,16 +1,14 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'max function' do
+describe 'max function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'maxs arrays' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = max("the","public","art","galleries")
       notice(inline_template('max is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'maxs arrays' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/max is "the"/)
+        expect(r.stdout).to match(%r{max is "the"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 2bcadd3..ebadeb4
@@ -1,17 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'member function' do
   shared_examples 'item found' do
-    it 'should output correctly' do
+    it 'outputs correctly' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
   end
   describe 'success' do
-    it 'members arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ['aaa','bbb','ccc']
       $b = 'ccc'
       $c = true
@@ -19,30 +17,35 @@ describe 'member function' do
       if $o == $c {
         notify { 'output correct': }
       }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Notice: output correct/)
+    DOC
+    it 'members arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{Notice: output correct})
       end
     end
+
     describe 'members array of integers' do
-      it_should_behave_like 'item found' do
-        let(:pp) { <<-EOS
-      if member( [1,2,3,4], 4 ){
-        notify { 'output correct': }
-      }
-        EOS
-        }
+      let(:pp) do
+        <<-DOC
+            if member( [1,2,3,4], 4 ){
+              notify { 'output correct': }
+            }
+        DOC
+      end
+
+      it_behaves_like 'item found' do
       end
     end
     describe 'members of mixed array' do
-      it_should_behave_like 'item found' do
-        let(:pp) { <<-EOS
-      if member( ['a','4',3], 'a' ){
-        notify { 'output correct': }
-}
-        EOS
-        }
+      let(:pp) do
+        <<-DOC
+            if member( ['a','4',3], 'a' ){
+              notify { 'output correct': }
+            }
+        DOC
+      end
+
+      it_behaves_like 'item found' do
       end
     end
     it 'members arrays without members'
old mode 100755 (executable)
new mode 100644 (file)
index 814db4e..17e2b9e
@@ -1,22 +1,21 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'merge function' do
   describe 'success' do
-    it 'should merge two hashes' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
       $b = {'two' => 'dos', 'three' => { 'five' => 5 } }
       $o = merge($a, $b)
       notice(inline_template('merge[one]   is <%= @o["one"].inspect %>'))
       notice(inline_template('merge[two]   is <%= @o["two"].inspect %>'))
       notice(inline_template('merge[three] is <%= @o["three"].inspect %>'))
-      EOS
-
+    DOC
+    regex_array = [%r{merge\[one\]   is ("1"|1)}, %r{merge\[two\]   is "dos"}, %r{merge\[three\] is {"five"=>("5"|5)}}]
+    it 'merges two hashes' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/merge\[one\]   is ("1"|1)/)
-        expect(r.stdout).to match(/merge\[two\]   is "dos"/)
-        expect(r.stdout).to match(/merge\[three\] is {"five"=>("5"|5)}/)
+        regex_array.each do |i|
+          expect(r.stdout).to match(i)
+        end
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 7b18fac..ea96060
@@ -1,16 +1,14 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'min function' do
+describe 'min function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'mins arrays' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = min("the","public","art","galleries")
       notice(inline_template('min is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'mins arrays' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/min is "art"/)
+        expect(r.stdout).to match(%r{min is "art"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 00d0ddc..d95cb93
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'num2bool function' do
   describe 'success' do
-    it 'bools positive numbers and numeric strings as true' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = 1
       $b = "1"
       $c = "50"
@@ -14,16 +12,17 @@ describe 'num2bool function' do
       notice(inline_template('a is <%= @ao.inspect %>'))
       notice(inline_template('b is <%= @bo.inspect %>'))
       notice(inline_template('c is <%= @co.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/a is true/)
-        expect(r.stdout).to match(/b is true/)
-        expect(r.stdout).to match(/c is true/)
+    DOC
+    regex_array_true = [%r{a is true}, %r{b is true}, %r{c is true}]
+    it 'bools positive numbers and numeric strings as true' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        regex_array_true.each do |i|
+          expect(r.stdout).to match(i)
+        end
       end
     end
-    it 'bools negative numbers as false' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = 0
       $b = -0.1
       $c = ["-50","1"]
@@ -33,44 +32,45 @@ describe 'num2bool function' do
       notice(inline_template('a is <%= @ao.inspect %>'))
       notice(inline_template('b is <%= @bo.inspect %>'))
       notice(inline_template('c is <%= @co.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/a is false/)
-        expect(r.stdout).to match(/b is false/)
-        expect(r.stdout).to match(/c is false/)
+    DOC
+    regex_array_false = [%r{a is false}, %r{b is false}, %r{c is false}]
+    it 'bools negative numbers as false' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        regex_array_false.each do |i|
+          expect(r.stdout).to match(i)
+        end
       end
     end
   end
+
   describe 'failure' do
-    it 'fails on words' do
-      pp = <<-EOS
+    pp3 = <<-DOC
       $a = "a"
       $ao = num2bool($a)
       notice(inline_template('a is <%= @ao.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/)
+    DOC
+    it 'fails on words' do
+      expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{not look like a number})
     end
 
-    it 'fails on numberwords' do
-      pp = <<-EOS
+    pp4 = <<-DOC
       $b = "1b"
       $bo = num2bool($b)
       notice(inline_template('b is <%= @bo.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/)
-
+    DOC
+    it 'fails on numberwords' do
+      expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{not look like a number})
     end
 
-    it 'fails on non-numeric/strings' do
-      pending "The function will call .to_s.to_i on anything not a Numeric or
-      String, and results in 0. Is this intended?"
-      pp = <<-EOS
+    pp5 = <<-DOC # rubocop:disable Lint/UselessAssignment
       $c = {"c" => "-50"}
       $co = num2bool($c)
       notice(inline_template('c is <%= @co.inspect %>'))
-      EOS
-      expect(apply_manifest(ppc :expect_failures => true).stderr).to match(/Unable to parse/)
+    DOC
+    it 'fails on non-numeric/strings' do
+      pending "The function will call .to_s.to_i on anything not a Numeric or
+      String, and results in 0. Is this intended?"
+      expect(apply_manifest(pp5(:expect_failures => true)).stderr).to match(%r{Unable to parse})
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 52133e4..8a19907
@@ -1,54 +1,49 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'parsejson function' do
   describe 'success' do
-    it 'parses valid json' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = '{"hunter": "washere", "tests": "passing"}'
       $ao = parsejson($a)
       $tests = $ao['tests']
       notice(inline_template('tests are <%= @tests.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/tests are "passing"/)
+    DOC
+    it 'parses valid json' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{tests are "passing"})
       end
     end
   end
 
   describe 'failure' do
-    it 'raises error on incorrect json' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $a = '{"hunter": "washere", "tests": "passing",}'
       $ao = parsejson($a, 'tests are using the default value')
       notice(inline_template('a is <%= @ao.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/tests are using the default value/)
+    DOC
+    it 'raises error on incorrect json - default value is used' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{tests are using the default value})
       end
     end
 
-    it 'raises error on incorrect json' do
-      pp = <<-EOS
+    pp3 = <<-DOC
       $a = '{"hunter": "washere", "tests": "passing",}'
       $ao = parsejson($a)
       notice(inline_template('a is <%= @ao.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/expected next name/)
+    DOC
+    it 'raises error on incorrect json' do
+      apply_manifest(pp3, :expect_failures => true) do |r|
+        expect(r.stderr).to match(%r{expected next name})
       end
     end
 
-    it 'raises error on incorrect number of arguments' do
-      pp = <<-EOS
+    pp4 = <<-DOC
       $o = parsejson()
-      EOS
-
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/wrong number of arguments/i)
+    DOC
+    it 'raises error on incorrect number of arguments' do
+      apply_manifest(pp4, :expect_failures => true) do |r|
+        expect(r.stderr).to match(%r{wrong number of arguments}i)
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index acbda46..4cdf36d
@@ -1,57 +1,51 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'parseyaml function' do
   describe 'success' do
-    it 'parses valid yaml' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = "---\nhunter: washere\ntests: passing\n"
       $o = parseyaml($a)
       $tests = $o['tests']
       notice(inline_template('tests are <%= @tests.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/tests are "passing"/)
+    DOC
+    it 'parses valid yaml' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{tests are "passing"})
       end
     end
   end
 
   describe 'failure' do
-    it 'returns the default value on incorrect yaml' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $a = "---\nhunter: washere\ntests: passing\n:"
       $o = parseyaml($a, {'tests' => 'using the default value'})
       $tests = $o['tests']
       notice(inline_template('tests are <%= @tests.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/tests are "using the default value"/)
+    DOC
+    it 'returns the default value on incorrect yaml' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{tests are "using the default value"})
       end
     end
 
-    it 'raises error on incorrect yaml' do
-      pp = <<-EOS
+    pp3 = <<-DOC
       $a = "---\nhunter: washere\ntests: passing\n:"
       $o = parseyaml($a)
       $tests = $o['tests']
       notice(inline_template('tests are <%= @tests.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/(syntax error|did not find expected key)/)
+    DOC
+    it 'raises error on incorrect yaml' do
+      apply_manifest(pp3, :expect_failures => true) do |r|
+        expect(r.stderr).to match(%r{(syntax error|did not find expected key)})
       end
     end
 
-
-    it 'raises error on incorrect number of arguments' do
-      pp = <<-EOS
+    pp4 = <<-DOC
       $o = parseyaml()
-      EOS
-
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/wrong number of arguments/i)
+    DOC
+    it 'raises error on incorrect number of arguments' do
+      apply_manifest(pp4, :expect_failures => true) do |r|
+        expect(r.stderr).to match(%r{wrong number of arguments}i)
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index e7e25ab..82b7ea5
@@ -1,53 +1,50 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'pick_default function' do
   describe 'success' do
-    it 'pick_defaults a default value' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = undef
       $o = pick_default($a, 'default')
       notice(inline_template('picked is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/picked is "default"/)
+    DOC
+    it 'pick_defaults a default value' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{picked is "default"})
       end
     end
-    it 'pick_defaults with no value' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = undef
       $b = undef
       $o = pick_default($a,$b)
       notice(inline_template('picked is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/picked is ""/)
+    DOC
+    it 'pick_defaults with no value' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{picked is ""})
       end
     end
-    it 'pick_defaults the first set value' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = "something"
       $b = "long"
       $o = pick_default($a, $b, 'default')
       notice(inline_template('picked is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/picked is "something"/)
+    DOC
+    it 'pick_defaults the first set value' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{picked is "something"})
       end
     end
   end
   describe 'failure' do
-    it 'raises error with no values' do
-      pp = <<-EOS
+    pp4 = <<-DOC
       $o = pick_default()
       notice(inline_template('picked is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/Must receive at least one argument/)
+    DOC
+    it 'raises error with no values' do
+      apply_manifest(pp4, :expect_failures => true) do |r|
+        expect(r.stderr).to match(%r{Must receive at least one argument})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index c70b2d9..14834b4
@@ -1,43 +1,41 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'pick function' do
   describe 'success' do
-    it 'picks a default value' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = undef
       $o = pick($a, 'default')
       notice(inline_template('picked is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/picked is "default"/)
+    DOC
+    it 'picks a default value' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{picked is "default"})
       end
     end
-    it 'picks the first set value' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "something"
       $b = "long"
       $o = pick($a, $b, 'default')
       notice(inline_template('picked is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/picked is "something"/)
+    DOC
+    it 'picks the first set value' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{picked is "something"})
       end
     end
   end
+
   describe 'failure' do
-    it 'raises error with all undef values' do
-      pp = <<-EOS
+    pp3 = <<-DOC
       $a = undef
       $b = undef
       $o = pick($a, $b)
       notice(inline_template('picked is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/must receive at least one non empty value/)
+    DOC
+    it 'raises error with all undef values' do
+      apply_manifest(pp3, :expect_failures => true) do |r|
+        expect(r.stderr).to match(%r{must receive at least one non empty value})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 58c691d..9a37fb3
@@ -1,36 +1,34 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'prefix function' do
   describe 'success' do
-    it 'prefixes array of values' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $o = prefix(['a','b','c'],'p')
       notice(inline_template('prefix is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/prefix is \["pa", "pb", "pc"\]/)
+    DOC
+    it 'prefixes array of values' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{prefix is \["pa", "pb", "pc"\]})
       end
     end
-    it 'prefixs with empty array' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $o = prefix([],'p')
       notice(inline_template('prefix is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/prefix is \[\]/)
+    DOC
+    it 'prefixs with empty array' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{prefix is \[\]})
       end
     end
-    it 'prefixs array of values with undef' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $o = prefix(['a','b','c'], undef)
       notice(inline_template('prefix is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/prefix is \["a", "b", "c"\]/)
+    DOC
+    it 'prefixs array of values with undef' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{prefix is \["a", "b", "c"\]})
       end
     end
   end
index 829d087..9c0d716 100644 (file)
@@ -1,28 +1,25 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 # Windows and OS X do not have useful implementations of crypt(3)
-describe 'pw_hash function', :unless => (['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do
+describe 'pw_hash function', :unless => ['windows', 'Darwin', 'SLES'].include?(fact('operatingsystem')) do
   describe 'success' do
-    it 'hashes passwords' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $o = pw_hash('password', 'sha-512', 'salt')
       notice(inline_template('pw_hash is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."/)
+    DOC
+    it 'hashes passwords' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."})
       end
     end
 
-    it 'returns nil if no password is provided' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $o = pw_hash('', 'sha-512', 'salt')
       notice(inline_template('pw_hash is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/pw_hash is nil/)
+    DOC
+    it 'returns nil if no password is provided' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{pw_hash is nil})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index f57f884..a5a7d22
@@ -1,26 +1,24 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'range function' do
   describe 'success' do
-    it 'ranges letters' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $o = range('a','d')
       notice(inline_template('range is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/range is \["a", "b", "c", "d"\]/)
+    DOC
+    it 'ranges letters' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{range is \["a", "b", "c", "d"\]})
       end
     end
-    it 'ranges letters with a step' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $o = range('a','d', '2')
       notice(inline_template('range is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/range is \["a", "c"\]/)
+    DOC
+    it 'ranges letters with a step' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{range is \["a", "c"\]})
       end
     end
     it 'ranges letters with a negative step'
old mode 100755 (executable)
new mode 100644 (file)
index ce4342d..753dd78
@@ -1,36 +1,34 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'reject function' do
   describe 'success' do
-    it 'rejects array of values' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
       notice(inline_template('reject is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/reject is \["bbb", "ccc"\]/)
+    DOC
+    it 'rejects array of values' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{reject is \["bbb", "ccc"\]})
       end
     end
-    it 'rejects with empty array' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $o = reject([],'aaa')
       notice(inline_template('reject is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/reject is \[\]/)
+    DOC
+    it 'rejects with empty array' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{reject is \[\]})
       end
     end
-    it 'rejects array of values with undef' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $o = reject(['aaa','bbb','ccc','aaaddd'], undef)
       notice(inline_template('reject is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/reject is \[\]/)
+    DOC
+    it 'rejects array of values with undef' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{reject is \[\]})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 3b5dfad..393fc30
@@ -1,18 +1,16 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'reverse function' do
   describe 'success' do
-    it 'reverses strings' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = "the public art galleries"
       # Anagram: Large picture halls, I bet
       $o = reverse($a)
       notice(inline_template('reverse is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/reverse is "seirellag tra cilbup eht"/)
+    DOC
+    it 'reverses strings' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{reverse is "seirellag tra cilbup eht"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 150dac1..b7aebda
@@ -1,29 +1,27 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'rstrip function' do
+describe 'rstrip function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'rstrips arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["  the   ","   public   ","   art","galleries   "]
       # Anagram: Large picture halls, I bet
       $o = rstrip($a)
       notice(inline_template('rstrip is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/rstrip is \["  the", "   public", "   art", "galleries"\]/)
+    DOC
+    it 'rstrips arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{rstrip is \["  the", "   public", "   art", "galleries"\]})
       end
     end
-    it 'rstrips strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "   blowzy night-frumps vex'd jack q   "
       $o = rstrip($a)
       notice(inline_template('rstrip is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/rstrip is "   blowzy night-frumps vex'd jack q"/)
+    DOC
+    it 'rstrips strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{rstrip is "   blowzy night-frumps vex'd jack q"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 0738383..d8c03a2
@@ -1,29 +1,27 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'shuffle function' do
   describe 'success' do
-    it 'shuffles arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["1", "2", "3", "4", "5", "6", "7", "8", "the","public","art","galleries"]
       # Anagram: Large picture halls, I bet
       $o = shuffle($a)
       notice(inline_template('shuffle is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to_not match(/shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]/)
+    DOC
+    it 'shuffles arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).not_to match(%r{shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]})
       end
     end
-    it 'shuffles strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "blowzy night-frumps vex'd jack q"
       $o = shuffle($a)
       notice(inline_template('shuffle is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to_not match(/shuffle is "blowzy night-frumps vex'd jack q"/)
+    DOC
+    it 'shuffles strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).not_to match(%r{shuffle is "blowzy night-frumps vex'd jack q"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 6390c20..e84e665
@@ -1,50 +1,48 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'size function' do
+describe 'size function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'single string size' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = 'discombobulate'
       $o = size($a)
       notice(inline_template('size is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/size is 14/)
+    DOC
+    it 'single string size' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{size is 14})
       end
     end
-    it 'with empty string' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = ''
       $o = size($a)
       notice(inline_template('size is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/size is 0/)
+    DOC
+    it 'with empty string' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{size is 0})
       end
     end
-    it 'with undef' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $a = undef
       $o = size($a)
       notice(inline_template('size is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/size is 0/)
+    DOC
+    it 'with undef' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{size is 0})
       end
     end
-    it 'strings in array' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $a = ['discombobulate', 'moo']
       $o = size($a)
       notice(inline_template('size is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/size is 2/)
+    DOC
+    it 'strings in array' do
+      apply_manifest(pp4, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{size is 2})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index e7ff7f7..8c4a3ab
@@ -1,29 +1,27 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'sort function' do
+describe 'sort function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'sorts arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["the","public","art","galleries"]
       # Anagram: Large picture halls, I bet
       $o = sort($a)
       notice(inline_template('sort is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/sort is \["art", "galleries", "public", "the"\]/)
+    DOC
+    it 'sorts arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{sort is \["art", "galleries", "public", "the"\]})
       end
     end
-    it 'sorts strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "blowzy night-frumps vex'd jack q"
       $o = sort($a)
       notice(inline_template('sort is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/sort is "    '-abcdefghijklmnopqrstuvwxyz"/)
+    DOC
+    it 'sorts strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{sort is "    '-abcdefghijklmnopqrstuvwxyz"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 3324691..c3be9db
@@ -1,42 +1,39 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'squeeze function' do
   describe 'success' do
-    it 'squeezes arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       # Real words!
       $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
       $o = squeeze($a)
       notice(inline_template('squeeze is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]/)
+    DOC
+    it 'squeezes arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]})
       end
     end
+
     it 'squeezez arrays with an argument'
-    it 'squeezes strings' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
       $o = squeeze($a)
       notice(inline_template('squeeze is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/squeeze is "wales laparohysterosalpingophorectomy br godeship"/)
+    DOC
+    it 'squeezes strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{squeeze is "wales laparohysterosalpingophorectomy br godeship"})
       end
     end
 
-    it 'squeezes strings with an argument' do
-      pp = <<-EOS
+    pp3 = <<-DOC
       $a = "countessship duchessship governessship hostessship"
       $o = squeeze($a, 's')
       notice(inline_template('squeeze is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/squeeze is "counteship ducheship governeship hosteship"/)
+    DOC
+    it 'squeezes strings with an argument' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{squeeze is "counteship ducheship governeship hosteship"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 9a8c06c..809456a
@@ -1,16 +1,14 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'str2bool function' do
   describe 'success' do
-    it 'works with "y"' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = str2bool('y')
       notice(inline_template('str2bool is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'works with "y"' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/str2bool is true/)
+        expect(r.stdout).to match(%r{str2bool is true})
       end
     end
     it 'works with "Y"'
old mode 100755 (executable)
new mode 100644 (file)
index 5f03924..4e38e07
@@ -1,16 +1,14 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'str2saltedsha512 function' do
   describe 'success' do
-    it 'works with "y"' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = str2saltedsha512('password')
       notice(inline_template('str2saltedsha512 is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'works with "y"' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/str2saltedsha512 is "[a-f0-9]{136}"/)
+        expect(r.stdout).to match(%r{str2saltedsha512 is "[a-f0-9]{136}"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 38521b0..4ba2c6a
@@ -1,16 +1,14 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'strftime function' do
+describe 'strftime function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '4.8.0') < 0 do
   describe 'success' do
-    it 'gives the Century' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = strftime('%C')
       notice(inline_template('strftime is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'gives the Century' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/strftime is "20"/)
+        expect(r.stdout).to match(%r{strftime is "20"})
       end
     end
     it 'takes a timezone argument'
old mode 100755 (executable)
new mode 100644 (file)
index 05cd395..67a939a
@@ -1,29 +1,27 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'strip function' do
+describe 'strip function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'strips arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["  the   ","   public   ","   art","galleries   "]
       # Anagram: Large picture halls, I bet
       $o = strip($a)
       notice(inline_template('strip is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/strip is \["the", "public", "art", "galleries"\]/)
+    DOC
+    it 'strips arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{strip is \["the", "public", "art", "galleries"\]})
       end
     end
-    it 'strips strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "   blowzy night-frumps vex'd jack q   "
       $o = strip($a)
       notice(inline_template('strip is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/strip is "blowzy night-frumps vex'd jack q"/)
+    DOC
+    it 'strips strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{strip is "blowzy night-frumps vex'd jack q"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 60a6264..6b04095
@@ -1,36 +1,34 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'suffix function' do
   describe 'success' do
-    it 'suffixes array of values' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $o = suffix(['a','b','c'],'p')
       notice(inline_template('suffix is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/suffix is \["ap", "bp", "cp"\]/)
+    DOC
+    it 'suffixes array of values' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{suffix is \["ap", "bp", "cp"\]})
       end
     end
-    it 'suffixs with empty array' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $o = suffix([],'p')
       notice(inline_template('suffix is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/suffix is \[\]/)
+    DOC
+    it 'suffixs with empty array' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{suffix is \[\]})
       end
     end
-    it 'suffixs array of values with undef' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $o = suffix(['a','b','c'], undef)
       notice(inline_template('suffix is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/suffix is \["a", "b", "c"\]/)
+    DOC
+    it 'suffixs array of values with undef' do
+      apply_manifest(pp3, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{suffix is \["a", "b", "c"\]})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 9f94c0d..1d606f0
@@ -1,16 +1,14 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'swapcase function' do
   describe 'success' do
-    it 'works with strings' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = swapcase('aBcD')
       notice(inline_template('swapcase is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'works with strings' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/swapcase is "AbCd"/)
+        expect(r.stdout).to match(%r{swapcase is "AbCd"})
       end
     end
     it 'works with arrays'
old mode 100755 (executable)
new mode 100644 (file)
index dae1166..b0a4564
@@ -1,31 +1,27 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'time function' do
   describe 'success' do
-    it 'gives the time' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $o = time()
       notice(inline_template('time is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        m = r.stdout.match(/time is (\d+)\D/)
-
+    DOC
+    it 'gives the time' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        m = r.stdout.match(%r{time is (\d+)\D})
         # When I wrote this test
-        expect(Integer(m[1])).to be > 1398894170
+        expect(Integer(m[1])).to be > 1_398_894_170
       end
     end
-    it 'takes a timezone argument' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $o = time('UTC')
       notice(inline_template('time is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        m = r.stdout.match(/time is (\d+)\D/)
-
-        expect(Integer(m[1])).to be > 1398894170
+    DOC
+    it 'takes a timezone argument' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        m = r.stdout.match(%r{time is (\d+)\D})
+        expect(Integer(m[1])).to be > 1_398_894_170
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index b1015a3..f042fe0
@@ -1,17 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'to_bytes function' do
   describe 'success' do
-    it 'converts kB to B' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = to_bytes('4 kB')
       notice(inline_template('to_bytes is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'converts kB to B' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        m = r.stdout.match(/to_bytes is (\d+)\D/)
-        expect(m[1]).to eq("4096")
+        m = r.stdout.match(%r{to_bytes is (\d+)\D})
+        expect(m[1]).to eq('4096')
       end
     end
     it 'works without the B in unit'
old mode 100755 (executable)
new mode 100644 (file)
index 716241c..1112813
@@ -1,46 +1,43 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'try_get_value function' do
   describe 'success' do
-    it 'gets a value' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $data = {
         'a' => { 'b' => 'passing'}
       }
 
       $tests = try_get_value($data, 'a/b')
       notice(inline_template('tests are <%= @tests.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/tests are "passing"/)
+    DOC
+    it 'gets a value' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{tests are "passing"})
       end
     end
   end
+
   describe 'failure' do
-    it 'uses a default value' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $data = {
         'a' => { 'b' => 'passing'}
       }
 
       $tests = try_get_value($data, 'c/d', 'using the default value')
       notice(inline_template('tests are <%= @tests.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/using the default value/)
+    DOC
+    it 'uses a default value' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{using the default value})
       end
     end
 
-    it 'raises error on incorrect number of arguments' do
-      pp = <<-EOS
+    pp = <<-DOC
       $o = try_get_value()
-      EOS
-
+    DOC
+    it 'raises error on incorrect number of arguments' do
       apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/wrong number of arguments/i)
+        expect(r.stderr).to match(%r{wrong number of arguments}i)
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 5cc9470..7b6e1fb
@@ -1,29 +1,27 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'type function' do
   describe 'success' do
-    it 'types arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["the","public","art","galleries"]
       # Anagram: Large picture halls, I bet
       $o = type($a)
       notice(inline_template('type is <%= @o.to_s %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/type is Tuple\[String.*, String.*, String.*, String.*\]/)
+    DOC
+    it 'types arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{type is Tuple\[String.*, String.*, String.*, String.*\]})
       end
     end
-    it 'types strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "blowzy night-frumps vex'd jack q"
       $o = type($a)
       notice(inline_template('type is <%= @o.to_s %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/type is String/)
+    DOC
+    it 'types strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{type is String})
       end
     end
     it 'types hashes'
old mode 100755 (executable)
new mode 100644 (file)
index 7229bf5..e1b3d9a
@@ -1,20 +1,18 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'union function' do
   describe 'success' do
-    it 'unions arrays' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = ["the","public"]
       $b = ["art"]
       $c = ["galleries"]
       # Anagram: Large picture halls, I bet
       $o = union($a,$b,$c)
       notice(inline_template('union is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'unions arrays' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/union is \["the", "public", "art", "galleries"\]/)
+        expect(r.stdout).to match(%r{union is \["the", "public", "art", "galleries"\]})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 7fb5eca..614eae5
@@ -1,28 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'unique function' do
   describe 'success' do
-    it 'uniques arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["wallless", "wallless", "brrr", "goddessship"]
       $o = unique($a)
       notice(inline_template('unique is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/unique is \["wallless", "brrr", "goddessship"\]/)
+    DOC
+    it 'uniques arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{unique is \["wallless", "brrr", "goddessship"\]})
       end
     end
-    it 'uniques strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
       $o = unique($a)
       notice(inline_template('unique is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/unique is "wales prohytingcmbd"/)
+    DOC
+    it 'uniques strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{unique is "wales prohytingcmbd"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 1782309..fda444b
@@ -1,28 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'upcase function' do
+describe 'upcase function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
   describe 'success' do
-    it 'upcases arrays' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
       $o = upcase($a)
       notice(inline_template('upcase is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]/)
+    DOC
+    it 'upcases arrays' do
+      apply_manifest(pp1, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]})
       end
     end
-    it 'upcases strings' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
       $o = upcase($a)
       notice(inline_template('upcase is <%= @o.inspect %>'))
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"/)
+    DOC
+    it 'upcases strings' do
+      apply_manifest(pp2, :catch_failures => true) do |r|
+        expect(r.stdout).to match(%r{upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index e123425..9553625
@@ -1,17 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'uriescape function' do
   describe 'success' do
-    it 'uriescape strings' do
-      pp = <<-EOS
+    pp = <<-DOC
       $a = ":/?#[]@!$&'()*+,;= \\\"{}"
       $o = uriescape($a)
       notice(inline_template('uriescape is <%= @o.inspect %>'))
-      EOS
-
+    DOC
+    it 'uriescape strings' do
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"/)
+        expect(r.stdout).to match(%r{uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"})
       end
     end
     it 'does nothing if a string is already safe'
old mode 100755 (executable)
new mode 100644 (file)
index 880850d..9fa0f80
@@ -1,25 +1,13 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_absolute_path function' do
   describe 'success' do
-    %w{
-      C:/
-      C:\\\\
-      C:\\\\WINDOWS\\\\System32
-      C:/windows/system32
-      X:/foo/bar
-      X:\\\\foo\\\\bar
-      /var/tmp
-      /var/lib/puppet
-      /var/opt/../lib/puppet
-    }.each do |path|
-      it "validates a single argument #{path}" do
-        pp = <<-EOS
+    ['C:/', 'C:\\\\', 'C:\\\\WINDOWS\\\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\\\foo\\\\bar', '/var/tmp', '/var/lib/puppet', '/var/opt/../lib/puppet'].each do |path|
+      pp = <<-DOC
         $one = '#{path}'
         validate_absolute_path($one)
-        EOS
-
+      DOC
+      it "validates a single argument #{path}" do
         apply_manifest(pp, :catch_failures => true)
       end
     end
old mode 100755 (executable)
new mode 100644 (file)
index a76321d..87016c2
@@ -1,33 +1,31 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_array function' do
   describe 'success' do
-    it 'validates a single argument' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = ['a', 'b']
       validate_array($one)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a single argument' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates an multiple arguments' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = ['a', 'b']
       $two = [['c'], 'd']
       validate_array($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates an multiple arguments' do
+      apply_manifest(pp2, :catch_failures => true)
     end
     [
       %{validate_array({'a' => 'hash' })},
       %{validate_array('string')},
       %{validate_array(false)},
-      %{validate_array(undef)}
+      %{validate_array(undef)},
     ].each do |pp|
       it "rejects #{pp.inspect}" do
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/is not an Array\.  It looks to be a/)
+        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(%r{is not an Array\.  It looks to be a})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index be213d3..9a59f38
@@ -1,4 +1,3 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do
@@ -6,54 +5,53 @@ describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows')
     it 'installs augeas for tests'
   end
   describe 'success' do
-    context 'valid inputs with no 3rd argument' do
+    context 'with valid inputs with no 3rd argument' do
       {
         'root:x:0:0:root:/root:/bin/bash\n'                        => 'Passwd.lns',
-        'proc /proc   proc    nodev,noexec,nosuid     0       0\n' => 'Fstab.lns'
-      }.each do |line,lens|
-        it "validates a single argument for #{lens}" do
-          pp = <<-EOS
+        'proc /proc   proc    nodev,noexec,nosuid     0       0\n' => 'Fstab.lns',
+      }.each do |line, lens|
+        pp1 = <<-DOC
           $line = "#{line}"
           $lens = "#{lens}"
           validate_augeas($line, $lens)
-          EOS
-
-          apply_manifest(pp, :catch_failures => true)
+        DOC
+        it "validates a single argument for #{lens}" do
+          apply_manifest(pp1, :catch_failures => true)
         end
       end
     end
-    context 'valid inputs with 3rd and 4th arguments' do
-      it "validates a restricted value" do
-        line        = 'root:x:0:0:root:/root:/bin/barsh\n'
-        lens        = 'Passwd.lns'
-        restriction = '$file/*[shell="/bin/barsh"]'
-        pp = <<-EOS
+
+    context 'with valid inputs with 3rd and 4th arguments' do
+      line        = 'root:x:0:0:root:/root:/bin/barsh\n'
+      lens        = 'Passwd.lns'
+      restriction = '$file/*[shell="/bin/barsh"]'
+      pp2 = <<-DOC
         $line        = "#{line}"
         $lens        = "#{lens}"
         $restriction = ['#{restriction}']
         validate_augeas($line, $lens, $restriction, "my custom failure message")
-        EOS
-
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/)
+      DOC
+      it 'validates a restricted value' do
+        expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{my custom failure message})
       end
     end
-    context 'invalid inputs' do
+
+    context 'with invalid inputs' do
       {
         'root:x:0:0:root' => 'Passwd.lns',
-        '127.0.1.1'       => 'Hosts.lns'
-      }.each do |line,lens|
-        it "validates a single argument for #{lens}" do
-          pp = <<-EOS
+        '127.0.1.1'       => 'Hosts.lns',
+      }.each do |line, lens|
+        pp3 = <<-DOC
           $line = "#{line}"
           $lens = "#{lens}"
           validate_augeas($line, $lens)
-          EOS
-
-          apply_manifest(pp, :expect_failures => true)
+        DOC
+        it "validates a single argument for #{lens}" do
+          apply_manifest(pp3, :expect_failures => true)
         end
       end
     end
-    context 'garbage inputs' do
+    context 'with garbage inputs' do
       it 'raises an error on invalid inputs'
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 993f9ef..fb3ec14
@@ -1,33 +1,31 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_bool function' do
   describe 'success' do
-    it 'validates a single argument' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = true
       validate_bool($one)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a single argument' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates an multiple arguments' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = true
       $two = false
       validate_bool($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates an multiple arguments' do
+      apply_manifest(pp2, :catch_failures => true)
     end
     [
       %{validate_bool('true')},
       %{validate_bool('false')},
       %{validate_bool([true])},
-      %{validate_bool(undef)}
-    ].each do |pp|
-      it "rejects #{pp.inspect}" do
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/is not a boolean\.  It looks to be a/)
+      %{validate_bool(undef)},
+    ].each do |pp3|
+      it "rejects #{pp3.inspect}" do
+        expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{is not a boolean\.  It looks to be a})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 5fc7b94..a846b53
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_cmd function' do
   describe 'success' do
-    it 'validates a true command' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = 'foo'
       if $::osfamily == 'windows' {
         $two = 'echo' #shell built-in
@@ -12,12 +10,12 @@ describe 'validate_cmd function' do
         $two = '/bin/echo'
       }
       validate_cmd($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a true command' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates a fail command' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = 'foo'
       if $::osfamily == 'windows' {
         $two = 'C:/aoeu'
@@ -25,12 +23,12 @@ describe 'validate_cmd function' do
         $two = '/bin/aoeu'
       }
       validate_cmd($one,$two)
-      EOS
-
-      apply_manifest(pp, :expect_failures => true)
+    DOC
+    it 'validates a fail command' do
+      apply_manifest(pp2, :expect_failures => true)
     end
-    it 'validates a fail command with a custom error message' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $one = 'foo'
       if $::osfamily == 'windows' {
         $two = 'C:/aoeu'
@@ -38,10 +36,10 @@ describe 'validate_cmd function' do
         $two = '/bin/aoeu'
       }
       validate_cmd($one,$two,"aoeu is dvorak")
-      EOS
-
-      apply_manifest(pp, :expect_failures => true) do |output|
-        expect(output.stderr).to match(/aoeu is dvorak/)
+    DOC
+    it 'validates a fail command with a custom error message' do
+      apply_manifest(pp3, :expect_failures => true) do |output|
+        expect(output.stderr).to match(%r{aoeu is dvorak})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index fc0f079..c349020
@@ -1,33 +1,32 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_hash function' do
   describe 'success' do
-    it 'validates a single argument' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = { 'a' => 1 }
       validate_hash($one)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a single argument' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates an multiple arguments' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = { 'a' => 1 }
       $two = { 'b' => 2 }
       validate_hash($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates an multiple arguments' do
+      apply_manifest(pp2, :catch_failures => true)
     end
+
     [
       %{validate_hash('{ "not" => "hash" }')},
       %{validate_hash('string')},
       %{validate_hash(["array"])},
-      %{validate_hash(undef)}
-    ].each do |pp|
-      it "rejects #{pp.inspect}" do
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(//)
+      %{validate_hash(undef)},
+    ].each do |pp3|
+      it "rejects #{pp3.inspect}" do
+        expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 67d3139..3ea165a
@@ -1,24 +1,22 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_ipv4_address function' do
   describe 'success' do
-    it 'validates a single argument' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = '1.2.3.4'
       validate_ipv4_address($one)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a single argument' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates an multiple arguments' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = '1.2.3.4'
       $two = '5.6.7.8'
       validate_ipv4_address($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates an multiple arguments' do
+      apply_manifest(pp2, :catch_failures => true)
     end
   end
   describe 'failure' do
old mode 100755 (executable)
new mode 100644 (file)
index eaa845d..c329331
@@ -1,24 +1,22 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_ipv6_address function' do
   describe 'success' do
-    it 'validates a single argument' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = '3ffe:0505:0002::'
       validate_ipv6_address($one)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a single argument' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates an multiple arguments' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = '3ffe:0505:0002::'
       $two = '3ffe:0505:0001::'
       validate_ipv6_address($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates an multiple arguments' do
+      apply_manifest(pp2, :catch_failures => true)
     end
   end
   describe 'failure' do
old mode 100755 (executable)
new mode 100644 (file)
index eefb286..2d2291c
@@ -1,45 +1,44 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_re function' do
   describe 'success' do
-    it 'validates a string' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = 'one'
       $two = '^one$'
       validate_re($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a string' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates an array' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = 'one'
       $two = ['^one$', '^two']
       validate_re($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates an array' do
+      apply_manifest(pp2, :catch_failures => true)
     end
-    it 'validates a failed array' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $one = 'one'
       $two = ['^two$', '^three']
       validate_re($one,$two)
-      EOS
-
-      apply_manifest(pp, :expect_failures => true)
+    DOC
+    it 'validates a failed array' do
+      apply_manifest(pp3, :expect_failures => true)
     end
-    it 'validates a failed array with a custom error message' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $one = '3.4.3'
       $two = '^2.7'
       validate_re($one,$two,"The $puppetversion fact does not match 2.7")
-      EOS
-
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/does not match/)
+    DOC
+    it 'validates a failed array with a custom error message' do
+      expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{does not match})
     end
   end
+
   describe 'failure' do
     it 'handles improper number of arguments'
     it 'handles improper argument types'
old mode 100755 (executable)
new mode 100644 (file)
index c29fd23..afbb97b
@@ -1,63 +1,61 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_slength function' do
   describe 'success' do
-    it 'validates a single string max' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = 'discombobulate'
       $two = 17
       validate_slength($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a single string max' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates multiple string maxes' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = ['discombobulate', 'moo']
       $two = 17
       validate_slength($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates multiple string maxes' do
+      apply_manifest(pp2, :catch_failures => true)
     end
-    it 'validates min/max of  strings in array' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $one = ['discombobulate', 'moo']
       $two = 17
       $three = 3
       validate_slength($one,$two,$three)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates min/max of  strings in array' do
+      apply_manifest(pp3, :catch_failures => true)
     end
-    it 'validates a single string max of incorrect length' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $one = 'discombobulate'
       $two = 1
       validate_slength($one,$two)
-      EOS
-
-      apply_manifest(pp, :expect_failures => true)
+    DOC
+    it 'validates a single string max of incorrect length' do
+      apply_manifest(pp4, :expect_failures => true)
     end
-    it 'validates multiple string maxes of incorrect length' do
-      pp = <<-EOS
+
+    pp5 = <<-DOC
       $one = ['discombobulate', 'moo']
       $two = 3
       validate_slength($one,$two)
-      EOS
-
-      apply_manifest(pp, :expect_failures => true)
+    DOC
+    it 'validates multiple string maxes of incorrect length' do
+      apply_manifest(pp5, :expect_failures => true)
     end
-    it 'validates multiple strings min/maxes of incorrect length' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $one = ['discombobulate', 'moo']
       $two = 17
       $three = 10
       validate_slength($one,$two,$three)
-      EOS
-
-      apply_manifest(pp, :expect_failures => true)
+    DOC
+    it 'validates multiple strings min/maxes of incorrect length' do
+      apply_manifest(pp6, :expect_failures => true)
     end
   end
   describe 'failure' do
old mode 100755 (executable)
new mode 100644 (file)
index f04608d..d141f59
@@ -1,39 +1,38 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'validate_string function' do
   describe 'success' do
-    it 'validates a single argument' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = 'string'
       validate_string($one)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates a single argument' do
+      apply_manifest(pp1, :catch_failures => true)
     end
-    it 'validates an multiple arguments' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = 'string'
       $two = 'also string'
       validate_string($one,$two)
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
+    DOC
+    it 'validates an multiple arguments' do
+      apply_manifest(pp2, :catch_failures => true)
     end
-    it 'validates undef' do
-      pp = <<-EOS
-      validate_string(undef)
-      EOS
 
-      apply_manifest(pp, :catch_failures => true)
+    pp3 = <<-DOC
+      validate_string(undef)
+    DOC
+    it 'validates undef' do
+      apply_manifest(pp3, :catch_failures => true)
     end
-    it 'validates a non-string' do
-      {
-        %{validate_string({ 'a' => 'hash' })} => "Hash",
-        %{validate_string(['array'])}         => "Array",
-        %{validate_string(false)}             => "FalseClass",
-      }.each do |pp,type|
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+
+    {
+      %{validate_string({ 'a' => 'hash' })} => 'Hash',
+      %{validate_string(['array'])}         => 'Array',
+      %{validate_string(false)}             => 'FalseClass',
+    }.each do |pp4, type|
+      it "validates a non-string: #{pp4.inspect}" do
+        expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{a #{type}})
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index eb0bf4f..ffd6f4c
@@ -1,69 +1,67 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'values_at function' do
   describe 'success' do
-    it 'returns a specific value' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = ['a','b','c','d','e']
       $two = 1
       $output = values_at($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b"\]/)
+    DOC
+    it 'returns a specific value' do
+      expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\["b"\]})
     end
-    it 'returns a specific negative index value' do
-      pending("negative numbers don't work")
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = ['a','b','c','d','e']
       $two = -1
       $output = values_at($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["e"\]/)
+    DOC
+    it 'returns a specific negative index value' do
+      pending("negative numbers don't work")
+      expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\["e"\]})
     end
-    it 'returns a range of values' do
-      pp = <<-EOS
+
+    pp3 = <<-DOC
       $one = ['a','b','c','d','e']
       $two = "1-3"
       $output = values_at($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d"\]/)
+    DOC
+    it 'returns a range of values' do
+      expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\["b", "c", "d"\]})
     end
-    it 'returns a negative specific value and range of values' do
-      pp = <<-EOS
+
+    pp4 = <<-DOC
       $one = ['a','b','c','d','e']
       $two = ["1-3",0]
       $output = values_at($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d", "a"\]/)
+    DOC
+    it 'returns a negative specific value and range of values' do
+      expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\["b", "c", "d", "a"\]})
     end
   end
+
   describe 'failure' do
-    it 'handles improper number of arguments' do
-      pp = <<-EOS
+    pp5 = <<-DOC
       $one = ['a','b','c','d','e']
       $output = values_at($one)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/)
+    DOC
+    it 'handles improper number of arguments' do
+      expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
     end
-    it 'handles non-indicies arguments' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $one = ['a','b','c','d','e']
       $two = []
       $output = values_at($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/at least one positive index/)
+    DOC
+    it 'handles non-indicies arguments' do
+      expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{at least one positive index})
     end
 
     it 'detects index ranges smaller than the start range'
old mode 100755 (executable)
new mode 100644 (file)
index cef1c9d..b450dc7
@@ -1,10 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'values function' do
+describe 'values function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   describe 'success' do
-    it 'returns an array of values' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $arg = {
         'a' => 1,
         'b' => 2,
@@ -12,19 +10,20 @@ describe 'values function' do
       }
       $output = values($arg)
       notice(inline_template('<%= @output.sort.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
+    DOC
+    it 'returns an array of values' do
+      expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[1, 2, 3\]})
     end
   end
+
   describe 'failure' do
-    it 'handles non-hash arguments' do
-      pp = <<-EOS
+    pp2 = <<-DOC
       $arg = "foo"
       $output = values($arg)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires hash/)
+    DOC
+    it 'handles non-hash arguments' do
+      expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash})
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index ae22896..57adfa7
@@ -1,67 +1,71 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
 describe 'zip function' do
   describe 'success' do
-    it 'zips two arrays of numbers together' do
-      pp = <<-EOS
+    pp1 = <<-DOC
       $one = [1,2,3,4]
       $two = [5,6,7,8]
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/)
+    DOC
+    it 'zips two arrays of numbers together' do
+      expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]})
     end
-    it 'zips two arrays of numbers & bools together' do
-      pp = <<-EOS
+
+    pp2 = <<-DOC
       $one = [1,2,"three",4]
       $two = [true,true,false,false]
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/)
+    DOC
+    it 'zips two arrays of numbers & bools together' do
+      expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]})
     end
-    it 'zips two arrays of numbers together and flattens them' do
-      # XXX This only tests the argument `true`, even though the following are valid:
-      # 1 t y true yes
-      # 0 f n false no
-      # undef undefined
-      pp = <<-EOS
+
+    # XXX This only tests the argument `true`, even though the following are valid:
+    # 1 t y true yes
+    # 0 f n false no
+    # undef undefined
+    pp3 = <<-DOC
       $one = [1,2,3,4]
       $two = [5,6,7,8]
       $output = zip($one,$two,true)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/)
+    DOC
+    it 'zips two arrays of numbers together and flattens them' do
+      expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\[1, 5, 2, 6, 3, 7, 4, 8\]})
     end
-    it 'handles unmatched length' do
-      # XXX Is this expected behavior?
-      pp = <<-EOS
+
+    # XXX Is this expected behavior?
+    pp4 = <<-DOC
       $one = [1,2]
       $two = [5,6,7,8]
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/)
+    DOC
+    it 'handles unmatched length' do
+      expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\]\]})
     end
   end
+
   describe 'failure' do
-    it 'handles improper number of arguments' do
-      pp = <<-EOS
+    pp5 = <<-DOC
       $one = [1,2]
       $output = zip($one)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/)
+    DOC
+    it 'handles improper number of arguments' do
+      expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
     end
-    it 'handles improper argument types' do
-      pp = <<-EOS
+
+    pp6 = <<-DOC
       $one = "a string"
       $two = [5,6,7,8]
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
-      EOS
-      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires array/)
+    DOC
+    it 'handles improper argument types' do
+      expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{Requires array})
     end
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/aliases/absolute_path_spec.rb b/3rdparty/modules/stdlib/spec/aliases/absolute_path_spec.rb
deleted file mode 100644 (file)
index 308a3aa..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::absolute_path', type: :class do
-    describe 'valid paths handling' do
-      %w{
-        C:/
-        C:\\
-        C:\\WINDOWS\\System32
-        C:/windows/system32
-        X:/foo/bar
-        X:\\foo\\bar
-        \\\\host\\windows
-        //host/windows
-        /
-        /var/tmp
-        /var/opt/../lib/puppet
-        /var/opt//lib/puppet
-        /var/ůťƒ8
-        /var/ネット
-      }.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'invalid path handling' do
-      context 'garbage inputs' do
-        [
-          nil,
-          [ nil ],
-          [ nil, nil ],
-          { 'foo' => 'bar' },
-          { },
-          '',
-        ].each do |value|
-          describe value.inspect do
-            let(:params) {{ value: value }}
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Compat::Absolute_path/) }
-          end
-        end
-      end
-
-      context 'relative paths' do
-        %w{
-          relative1
-          .
-          ..
-          ./foo
-          ../foo
-          etc/puppetlabs/puppet
-          opt/puppet/bin
-          relative\\windows
-          \var\ůťƒ8
-          \var\ネット
-        }.each do |value|
-          describe value.inspect do
-            let(:params) {{ value: value }}
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Compat::Absolute_path/) }
-          end
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/absolutepath_spec.rb b/3rdparty/modules/stdlib/spec/aliases/absolutepath_spec.rb
deleted file mode 100644 (file)
index ff23dc0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::absolutepath', type: :class do
-    describe 'valid handling' do
-      %w{
-        /usr2/username/bin:/usr/local/bin:/usr/bin:.
-        C:/
-        C:\\
-        C:\\WINDOWS\\System32
-        C:/windows/system32
-        X:/foo/bar
-        X:\\foo\\bar
-        \\\\host\\windows
-        //host/windows
-        /var/tmp
-        /var/opt/../lib/puppet
-        /var/opt//lib/puppet
-      }.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'invalid path handling' do
-      context 'garbage inputs' do
-        [
-          nil,
-          [ nil ],
-          [ nil, nil ],
-          { 'foo' => 'bar' },
-          { },
-          '',
-          "*/Users//nope",
-          "\\Users/hc/wksp/stdlib",
-          "C:noslashes",
-          "\\var\\tmp"
-        ].each do |value|
-          describe value.inspect do
-            let(:params) {{ value: value }}
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for.*Variant/) }
-          end
-        end
-      end
-
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/array_spec.rb b/3rdparty/modules/stdlib/spec/aliases/array_spec.rb
deleted file mode 100644 (file)
index 89cc2af..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::array', type: :class do
-    describe 'accepts arrays' do
-      [
-        [],
-        ['one'],
-        [1],
-        [{}],
-        [[]],
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'rejects other values' do
-      [
-        '',
-        'one',
-        '1',
-        {},
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Array/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/bool_spec.rb b/3rdparty/modules/stdlib/spec/aliases/bool_spec.rb
deleted file mode 100644 (file)
index b84ab51..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::bool', type: :class do
-    describe 'accepts booleans' do
-      [
-        true,
-        false,
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'rejects other values' do
-      [
-        [1],
-        [{}],
-        [true],
-        'true',
-        'false',
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Bool/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/float_spec.rb b/3rdparty/modules/stdlib/spec/aliases/float_spec.rb
deleted file mode 100644 (file)
index 84e1934..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::float', type: :class do
-    describe 'accepts floats' do
-      [
-        3.7,
-        '3.7',
-        -3.7,
-        '-342.2315e-12',
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'rejects other values' do
-      [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3, '3', -3, '-3'].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects.*Float.*Pattern/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/hash_spec.rb b/3rdparty/modules/stdlib/spec/aliases/hash_spec.rb
deleted file mode 100644 (file)
index 6e5060d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::hash', type: :class do
-    describe 'accepts hashes' do
-      [
-        {},
-        {'one' => "two"},
-        {'wan' => 3},
-        {'001' => "helly"},
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-    describe 'rejects other values' do
-      [
-        '',
-        'one',
-        '1',
-        [],
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Hash/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/httpsurl_spec.rb b/3rdparty/modules/stdlib/spec/aliases/httpsurl_spec.rb
deleted file mode 100644 (file)
index 3e51118..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::httpsurl', type: :class do
-    describe 'valid handling' do
-      %w{
-        https://hello.com
-        https://notcreative.org
-        https://notexciting.co.uk
-        https://graphemica.com/❤
-        https://graphemica.com/緩
-      }.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'invalid path handling' do
-      context 'garbage inputs' do
-        [
-          nil,
-          [ nil ],
-          [ nil, nil ],
-          { 'foo' => 'bar' },
-          { },
-          '',
-          "httds://notquiteright.org",
-          "hptts:/nah",
-          "https;//notrightbutclose.org",
-          "http://graphemica.com/❤",
-           "http://graphemica.com/緩"
-        ].each do |value|
-          describe value.inspect do
-            let(:params) {{ value: value }}
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::HTTPSUrl/) }
-          end
-        end
-      end
-
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/httpurl_spec.rb b/3rdparty/modules/stdlib/spec/aliases/httpurl_spec.rb
deleted file mode 100644 (file)
index fd49a47..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::httpurl', type: :class do
-    describe 'valid handling' do
-      %w{
-        https://hello.com
-        https://notcreative.org
-        https://canstillaccepthttps.co.uk
-        http://anhttp.com
-        http://runningoutofideas.gov
-        http://
-        http://graphemica.com/❤
-        http://graphemica.com/緩
-      }.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'invalid path handling' do
-      context 'garbage inputs' do
-        [
-          nil,
-          [ nil ],
-          [ nil, nil ],
-          { 'foo' => 'bar' },
-          { },
-          '',
-          "httds://notquiteright.org",
-          "hptts:/nah",
-          "https;//notrightbutclose.org",
-          "hts://graphemica.com/❤",
-          "https:graphemica.com/緩"
-        ].each do |value|
-          describe value.inspect do
-            let(:params) {{ value: value }}
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::HTTPUrl/) }
-          end
-        end
-      end
-
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/integer_spec.rb b/3rdparty/modules/stdlib/spec/aliases/integer_spec.rb
deleted file mode 100644 (file)
index 9cf0357..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::integer', type: :class do
-    describe 'accepts integers' do
-      [
-        3,
-        '3',
-        -3,
-        '-3',
-        "123\nfoo",
-        "foo\n123",
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'rejects other values' do
-      [ "foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Integer = Variant\[Integer, Pattern\[.*\], Array\[.*\]\] value/) }
-          else
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) }
-          end
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/ip_address.rb b/3rdparty/modules/stdlib/spec/aliases/ip_address.rb
deleted file mode 100644 (file)
index 67a555c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::ip_address', type: :class do
-    describe 'accepts ipv4 and ipv6 addresses' do
-      [
-        '224.0.0.0',
-        '255.255.255.255',
-        '0.0.0.0',
-        '192.88.99.0',
-        '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
-        'fa76:8765:34ac:0823:ab76:eee9:0987:1111'
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-    describe 'rejects other values' do
-      [
-        'nope',
-        '77',
-        '4.4.4',
-        '2001:0db8:85a3:000000:0000:8a2e:0370:7334'
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/ipv4_spec.rb b/3rdparty/modules/stdlib/spec/aliases/ipv4_spec.rb
deleted file mode 100644 (file)
index 6a503ad..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::ipv4', type: :class do
-    describe 'accepts ipv4 addresses' do
-      SharedData::IPV4_PATTERNS.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-    describe 'rejects other values' do
-      SharedData::IPV4_NEGATIVE_PATTERNS.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Compat::Ipv4/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/ipv6_spec.rb b/3rdparty/modules/stdlib/spec/aliases/ipv6_spec.rb
deleted file mode 100644 (file)
index ae90f42..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::ipv6', type: :class do
-    describe 'accepts ipv6 addresses' do
-      [
-        '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
-        'fa76:8765:34ac:0823:ab76:eee9:0987:1111',
-        'fe80:0000:0000:0000:0204:61ff:fe9d:f156',
-        'fe80:0:0:0:204:61ff:fe9d:f156',
-        'fe80::204:61ff:fe9d:f156',
-        'fe80:0:0:0:0204:61ff:254.157.241.86',
-        '::1',
-        'fe80::',
-        '2001::',
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-    describe 'rejects other values' do
-      [
-        'nope',
-        '77',
-        '4.4.4',
-        '2000:7334',
-        '::ffff:2.3.4',
-        '::ffff:257.1.2.3',
-        '::ffff:12345678901234567890.1.26',
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Compat::Ipv6/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/numeric_spec.rb b/3rdparty/modules/stdlib/spec/aliases/numeric_spec.rb
deleted file mode 100644 (file)
index 09c28ec..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::numeric', type: :class do
-    describe 'accepts numerics' do
-      [
-        3,
-        '3',
-        -3,
-        '-3',
-        3.7,
-        '3.7',
-        -3.7,
-        '-342.2315e-12',
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'rejects other values' do
-      [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x' ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects.*Numeric.*Pattern.*Array/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/string_spec.rb b/3rdparty/modules/stdlib/spec/aliases/string_spec.rb
deleted file mode 100644 (file)
index 4fc8ce6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::string', type: :class do
-    describe 'accepts strings' do
-      [
-        '',
-        'one',
-        nil,
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'rejects other values' do
-      [
-        [],
-        {},
-        1,
-        true,
-      ].each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile.and_raise_error(/parameter 'value' expects a (?:value of type Undef or )?.*String/) }
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/unixpath_spec.rb b/3rdparty/modules/stdlib/spec/aliases/unixpath_spec.rb
deleted file mode 100644 (file)
index 6aecfe7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::unixpath', type: :class do
-    describe 'valid handling' do
-      %w{
-        /usr2/username/bin:/usr/local/bin:/usr/bin:.
-        /var/tmp
-        /Users/helencampbell/workspace/puppetlabs-stdlib
-        /var/ůťƒ8
-        /var/ネット
-        /var//tmp
-        /var/../tmp
-      }.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'invalid path handling' do
-      context 'garbage inputs' do
-        [
-          nil,
-          [ nil ],
-          [ nil, nil ],
-          { 'foo' => 'bar' },
-          { },
-          '',
-          "C:/whatever",
-          "\\var\\tmp",
-          "\\Users/hc/wksp/stdlib",
-          "*/Users//nope",
-          "var\ůťƒ8",
-          "var\ネット"
-        ].each do |value|
-          describe value.inspect do
-            let(:params) {{ value: value }}
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Unixpath/) }
-          end
-        end
-      end
-
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/aliases/windowspath_spec.rb b/3rdparty/modules/stdlib/spec/aliases/windowspath_spec.rb
deleted file mode 100644 (file)
index c20e373..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'spec_helper'
-
-if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
-  describe 'test::windowspath', type: :class do
-    describe 'valid handling' do
-      %w{
-        C:\\
-        C:\\WINDOWS\\System32
-        C:/windows/system32
-        X:/foo/bar
-        X:\\foo\\bar
-        \\\\host\\windows
-        X:/var/ůťƒ8
-        X:/var/ネット
-      }.each do |value|
-        describe value.inspect do
-          let(:params) {{ value: value }}
-          it { is_expected.to compile }
-        end
-      end
-    end
-
-    describe 'invalid path handling' do
-      context 'garbage inputs' do
-        [
-          nil,
-          [ nil ],
-          [ nil, nil ],
-          { 'foo' => 'bar' },
-          { },
-          '',
-          "httds://notquiteright.org",
-          "/usr2/username/bin:/usr/local/bin:/usr/bin:.",
-          "C;//notright/here",
-          "C:noslashes",
-          "C:ネット",
-          "C:ůťƒ8"
-        ].each do |value|
-          describe value.inspect do
-            let(:params) {{ value: value }}
-            it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Windowspath/) }
-          end
-        end
-      end
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolute_path.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolute_path.pp
deleted file mode 100644 (file)
index d77f6bd..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::Compat::Absolute_path type alias
-class test::absolute_path(
-  Stdlib::Compat::Absolute_path $value,
-  ) {
-    notice("Success")
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolutepath.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolutepath.pp
deleted file mode 100644 (file)
index 8321471..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::Absolutepath type. Not to be confused with Stdlib::Compat::Absolute_path.
-class test::absolutepath(
-    Stdlib::Absolutepath $value,
-    ) {
-  notice("Success")
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/array.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/array.pp
deleted file mode 100644 (file)
index 84b6a5b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Class to test the Stdlib::Compat::Array type alias
-class test::array(
-  Stdlib::Compat::Array $value,
-  ) {
-
-    notice("Success")
-
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/bool.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/bool.pp
deleted file mode 100644 (file)
index ab5b5ea..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Class to test the Stdlib::Compat::Bool type alias
-class test::bool(
-  Stdlib::Compat::Bool $value,
-  ) {
-
-    notice("Success")
-
-}
index 825f8fe..362d155 100644 (file)
@@ -1,3 +1,4 @@
-define test::deftype($param = 'foo') {
-  notify { "deftype: $title": }
+# Class to test deftype
+define test::deftype( $param = 'foo' ) {
+  notify { "deftype: ${title}": }
 }
index bd26002..5f444c0 100644 (file)
@@ -1,4 +1,4 @@
 # A helper class to test the ensure_resources function
-class test::ensure_resources($resource_type, $title_hash, $attributes_hash) {
+class test::ensure_resources( $resource_type, $title_hash, $attributes_hash ) {
   ensure_resources($resource_type, $title_hash, $attributes_hash)
 }
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/float.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/float.pp
deleted file mode 100644 (file)
index 03a603d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Class to test the Stdlib::Compat::Float type alias
-class test::float(
-  Stdlib::Compat::Float $value,
-  ) {
-
-    notice("Success")
-
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/hash.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/hash.pp
deleted file mode 100644 (file)
index c243570..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Class to test the Stdlib::Compat::Hash type alias
-class test::hash(
-    Stdlib::Compat::Hash $value,
-    ) {
-
-  notice("Success")
-
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpsurl.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpsurl.pp
deleted file mode 100644 (file)
index 9d6b92d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::HTTPSUrl type alias
-class test::httpsurl(
-    Stdlib::HTTPSUrl $value,
-    ) {
-  notice("Success")
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpurl.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpurl.pp
deleted file mode 100644 (file)
index abf869e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::HTTPUrl type alias
-class test::httpurl(
-    Stdlib::HTTPUrl $value,
-    ) {
-  notice("Success")
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/integer.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/integer.pp
deleted file mode 100644 (file)
index a4f26df..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Class to test the Stdlib::Compat::Integer type alias
-class test::integer(
-  Stdlib::Compat::Integer $value,
-  ) {
-
-    notice("Success")
-
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ip_address.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ip_address.pp
deleted file mode 100644 (file)
index bbbd804..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::Compat::Ip_address type alias
-class test::ip_address(
-  Stdlib::Compat::Ip_address $value,
-  ) {
-    notice("Success")
-  }
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv4.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv4.pp
deleted file mode 100644 (file)
index 2e8022d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::Compat::Ipv4 type alias
-class test::ipv4(
-  Stdlib::Compat::Ipv4 $value,
-  ) {
-    notice("Success")
-  }
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv6.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv6.pp
deleted file mode 100644 (file)
index 7912fd6..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::Compat::Ipv6 type alias
-class test::ipv6(
-  Stdlib::Compat::Ipv6 $value,
-  ) {
-  notice("Success")
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/numeric.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/numeric.pp
deleted file mode 100644 (file)
index 2657ebc..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Class to test the Stdlib::Compat::Numeric type alias
-class test::numeric(
-  Stdlib::Compat::Numeric $value,
-  ) {
-
-    notice("Success")
-
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/string.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/string.pp
deleted file mode 100644 (file)
index 6508c70..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Class to test the Stdlib::Compat::String type alias
-class test::string(
-  Stdlib::Compat::String $value,
-  ) {
-
-    notice("Success")
-
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/unixpath.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/unixpath.pp
deleted file mode 100644 (file)
index 9311109..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::Unixpath type alias
-class test::unixpath(
-    Stdlib::Unixpath $value,
-    ) {
-  notice("Success")
-}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/windowspath.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/windowspath.pp
deleted file mode 100644 (file)
index af93ed3..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Class to test the Stdlib::Windowspath type alias
-class test::windowspath(
-    Stdlib::Windowspath $value,
-    ) {
-  notice("Success")
-}
old mode 100755 (executable)
new mode 100644 (file)
index 7d2257b..2d18332
@@ -1,30 +1,46 @@
 require 'spec_helper'
+if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0
+  describe 'abs' do
+    it { is_expected.not_to eq(nil) }
 
-describe 'abs' do
-  it { is_expected.not_to eq(nil) }
+    describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do
+      it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+      it {
+        pending('Current implementation ignores parameters after the first.')
+        is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
+      }
+    end
 
-  describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it {
-      pending("Current implementation ignores parameters after the first.")
-      is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
-    }
-  end
+    describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do
+      it {
+        pending 'the puppet 6 implementation'
+        is_expected.to run.with_params.and_raise_error(ArgumentError)
+      }
+      it {
+        pending 'the puppet 6 implementation'
+        is_expected.to run.with_params(1, 2).and_raise_error(ArgumentError)
+      }
+      it {
+        pending 'the puppet 6 implementation'
+        is_expected.to run.with_params([]).and_raise_error(ArgumentError)
+      }
+      it {
+        pending 'the puppet 6 implementation'
+        is_expected.to run.with_params({}).and_raise_error(ArgumentError)
+      }
+      it {
+        pending 'the puppet 6 implementation'
+        is_expected.to run.with_params(true).and_raise_error(ArgumentError)
+      }
+    end
 
-  describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params().and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params([]).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params({}).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) }
+    it { is_expected.to run.with_params(-34).and_return(34) }
+    it { is_expected.to run.with_params('-34').and_return(34) }
+    it { is_expected.to run.with_params(34).and_return(34) }
+    it { is_expected.to run.with_params('34').and_return(34) }
+    it { is_expected.to run.with_params(-34.5).and_return(34.5) }
+    it { is_expected.to run.with_params('-34.5').and_return(34.5) }
+    it { is_expected.to run.with_params(34.5).and_return(34.5) }
+    it { is_expected.to run.with_params('34.5').and_return(34.5) }
   end
-
-  it { is_expected.to run.with_params(-34).and_return(34) }
-  it { is_expected.to run.with_params("-34").and_return(34) }
-  it { is_expected.to run.with_params(34).and_return(34) }
-  it { is_expected.to run.with_params("34").and_return(34) }
-  it { is_expected.to run.with_params(-34.5).and_return(34.5) }
-  it { is_expected.to run.with_params("-34.5").and_return(34.5) }
-  it { is_expected.to run.with_params(34.5).and_return(34.5) }
-  it { is_expected.to run.with_params("34.5").and_return(34.5) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 631657f..a795672
@@ -1,8 +1,9 @@
 require 'spec_helper'
 
-describe "any2array" do
+describe 'any2array' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_return([]) }
+  it { is_expected.to run.with_params.and_return([]) }
+  it { is_expected.to run.with_params('').and_return([]) }
   it { is_expected.to run.with_params(true).and_return([true]) }
   it { is_expected.to run.with_params('one').and_return(['one']) }
   it { is_expected.to run.with_params('one', 'two').and_return(['one', 'two']) }
@@ -10,8 +11,7 @@ describe "any2array" do
   it { is_expected.to run.with_params(['one']).and_return(['one']) }
   it { is_expected.to run.with_params(['one', 'two']).and_return(['one', 'two']) }
   it { is_expected.to run.with_params({}).and_return([]) }
-  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) }
-  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) }
+  it { is_expected.to run.with_params('key' => 'value').and_return(['key', 'value']) }
 
   it { is_expected.to run.with_params('‰').and_return(['‰']) }
   it { is_expected.to run.with_params('竹').and_return(['竹']) }
old mode 100755 (executable)
new mode 100644 (file)
index 9d351ce..4de9d21
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'any2bool' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   it { is_expected.to run.with_params(true).and_return(true) }
   it { is_expected.to run.with_params(false).and_return(false) }
@@ -10,33 +10,32 @@ describe 'any2bool' do
   it { is_expected.to run.with_params('1.5').and_return(true) }
 
   describe 'when testing stringy values that mean "true"' do
-    [ 'TRUE','1', 't', 'y', 'true', 'yes'].each do |value|
+    ['TRUE', '1', 't', 'y', 'true', 'yes'].each do |value|
       it { is_expected.to run.with_params(value).and_return(true) }
     end
   end
 
   describe 'when testing stringy values that mean "false"' do
-    [ 'FALSE','', '0', 'f', 'n', 'false', 'no', 'undef', 'undefined', nil, :undef ].each do |value|
+    ['FALSE', '', '0', 'f', 'n', 'false', 'no', 'undef', 'undefined', nil, :undef].each do |value|
       it { is_expected.to run.with_params(value).and_return(false) }
     end
   end
 
   describe 'when testing numeric values that mean "true"' do
-    [ 1,'1',1.5, '1.5'].each do |value|
+    [1, '1', 1.5, '1.5'].each do |value|
       it { is_expected.to run.with_params(value).and_return(true) }
     end
   end
 
   describe 'when testing numeric that mean "false"' do
-    [ -1, '-1', -1.5, '-1.5', '0', 0 ].each do |value|
+    [-1, '-1', -1.5, '-1.5', '0', 0].each do |value|
       it { is_expected.to run.with_params(value).and_return(false) }
     end
   end
 
   describe 'everything else returns true' do
-    [ [], {}, ['1'], [1], {:one => 1} ].each do |value|
+    [[], {}, ['1'], [1], { :one => 1 }].each do |value|
       it { is_expected.to run.with_params(value).and_return(true) }
     end
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index 355e0dd..ee7db0b
@@ -2,40 +2,37 @@ require 'spec_helper'
 
 describe 'assert_private' do
   context 'when called from inside module' do
-    it "should not fail" do
-      scope.expects(:lookupvar).with('module_name').returns('foo')
-      scope.expects(:lookupvar).with('caller_module_name').returns('foo')
+    it 'does not fail' do
+      expect(scope).to receive(:lookupvar).with('module_name').and_return('foo')
+      expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('foo')
 
-      is_expected.to run.with_params()
+      is_expected.to run.with_params
     end
   end
 
-  context "when called from private class" do
-    before :each do
-      scope.expects(:lookupvar).with('module_name').returns('foo')
-      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
-    end
-
-    it "should fail with a class error message" do
-      scope.source.expects(:name).returns('foo::baz')
-      scope.source.expects(:type).returns('hostclass')
+  context 'when called from private class' do
+    it 'fails with a class error message' do
+      expect(scope).to receive(:lookupvar).with('module_name').and_return('foo')
+      expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar')
+      expect(scope.source).to receive(:name).and_return('foo::baz')
+      expect(scope.source).to receive(:type).and_return('hostclass')
 
-      is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Class foo::baz is private/)
+      is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Class foo::baz is private})
     end
 
-    context "with an explicit failure message" do
-      it { is_expected.to run.with_params('failure message!').and_raise_error(Puppet::ParseError, /failure message!/) }
+    it 'fails with an explicit failure message' do
+      is_expected.to run.with_params('failure message!').and_raise_error(Puppet::ParseError, %r{failure message!})
     end
   end
 
-  context "when called from private definition" do
-    it "should fail with a class error message" do
-      scope.expects(:lookupvar).with('module_name').returns('foo')
-      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
-      scope.source.expects(:name).returns('foo::baz')
-      scope.source.expects(:type).returns('definition')
+  context 'when called from private definition' do
+    it 'fails with a class error message' do
+      expect(scope).to receive(:lookupvar).with('module_name').and_return('foo')
+      expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar')
+      expect(scope.source).to receive(:name).and_return('foo::baz')
+      expect(scope.source).to receive(:type).and_return('definition')
 
-      is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Definition foo::baz is private/)
+      is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Definition foo::baz is private})
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 842a37a..dafab36
@@ -2,36 +2,59 @@ require 'spec_helper'
 
 describe 'base64' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params("one").and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /first argument must be one of/) }
-  it { is_expected.to run.with_params("encode", ["two"]).and_raise_error(Puppet::ParseError, /second argument must be a string/) }
-  it { is_expected.to run.with_params("encode", 2).and_raise_error(Puppet::ParseError, /second argument must be a string/) }
-  it { is_expected.to run.with_params("encode", "thestring", "three").and_raise_error(Puppet::ParseError, /third argument must be one of/) }
-  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n", "strict").and_raise_error(ArgumentError) }
-
-  it { is_expected.to run.with_params("encode", "thestring").and_return("dGhlc3RyaW5n\n") }
-  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n").and_return("thestring") }
-  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n").and_return("thestring") }
-
-  it { is_expected.to run.with_params("encode", "thestring", "default").and_return("dGhlc3RyaW5n\n") }
-  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n", "default").and_return("thestring") }
-  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n", "default").and_return("thestring") }
-
-  it { is_expected.to run.with_params("encode", "thestring", "strict").and_return("dGhlc3RyaW5n") }
-  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n", "strict").and_return("thestring") }
-
-  it { is_expected.to run.with_params("encode", "a very long string that will cause the base64 encoder to produce output with multiple lines").and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n") }
-  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
-  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
-
-  it { is_expected.to run.with_params("encode", "a very long string that will cause the base64 encoder to produce output with multiple lines", "strict").and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==") }
-  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
-  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==", "strict").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
-
-  it { is_expected.to run.with_params("encode", "https://www.google.com.tw/?gws_rd=ssl#q=hello+world", "urlsafe").and_return("aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk") }
-  it { is_expected.to run.with_params("decode", "aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk", "urlsafe").and_return("https://www.google.com.tw/?gws_rd=ssl#q=hello+world") }
-
-  it { is_expected.to run.with_params("encode", "https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add", "urlsafe").and_return("aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=") }
-  it { is_expected.to run.with_params("decode", "aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=", "urlsafe").and_return("https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add") }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{first argument must be one of}) }
+  it { is_expected.to run.with_params('encode', ['two']).and_raise_error(Puppet::ParseError, %r{second argument must be a string}) }
+  it { is_expected.to run.with_params('encode', 2).and_raise_error(Puppet::ParseError, %r{second argument must be a string}) }
+  it { is_expected.to run.with_params('encode', 'thestring', 'three').and_raise_error(Puppet::ParseError, %r{third argument must be one of}) }
+  it { is_expected.to run.with_params('decode', "dGhlc3RyaW5n\n", 'strict').and_raise_error(ArgumentError) }
+
+  it { is_expected.to run.with_params('encode', 'thestring').and_return("dGhlc3RyaW5n\n") }
+  it { is_expected.to run.with_params('decode', 'dGhlc3RyaW5n').and_return('thestring') }
+  it { is_expected.to run.with_params('decode', "dGhlc3RyaW5n\n").and_return('thestring') }
+
+  it { is_expected.to run.with_params('encode', 'thestring', 'default').and_return("dGhlc3RyaW5n\n") }
+  it { is_expected.to run.with_params('decode', 'dGhlc3RyaW5n', 'default').and_return('thestring') }
+  it { is_expected.to run.with_params('decode', "dGhlc3RyaW5n\n", 'default').and_return('thestring') }
+
+  it { is_expected.to run.with_params('encode', 'thestring', 'strict').and_return('dGhlc3RyaW5n') }
+  it { is_expected.to run.with_params('decode', 'dGhlc3RyaW5n', 'strict').and_return('thestring') }
+
+  it {
+    is_expected.to run.with_params('encode', 'a very long string that will cause the base64 encoder to produce output with multiple lines')
+                      .and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n")
+  }
+  it {
+    is_expected.to run.with_params('decode', "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n")
+                      .and_return('a very long string that will cause the base64 encoder to produce output with multiple lines')
+  }
+  it {
+    is_expected.to run.with_params('decode', 'YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==')
+                      .and_return('a very long string that will cause the base64 encoder to produce output with multiple lines')
+  }
+  it {
+    is_expected.to run.with_params('encode', 'a very long string that will cause the base64 encoder to produce output with multiple lines', 'strict')
+                      .and_return('YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==')
+  }
+  it {
+    is_expected.to run.with_params('decode', 'YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==', 'strict')
+                      .and_return('a very long string that will cause the base64 encoder to produce output with multiple lines')
+  }
+  it {
+    is_expected.to run.with_params('encode', 'https://www.google.com.tw/?gws_rd=ssl#q=hello+world', 'urlsafe')
+                      .and_return('aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk')
+  }
+  it {
+    is_expected.to run.with_params('decode', 'aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk', 'urlsafe')
+                      .and_return('https://www.google.com.tw/?gws_rd=ssl#q=hello+world')
+  }
+  it {
+    is_expected.to run.with_params('encode', 'https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add', 'urlsafe')
+                      .and_return('aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=')
+  }
+  it {
+    is_expected.to run.with_params('decode', 'aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=', 'urlsafe')
+                      .and_return('https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add')
+  }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 3e02b01..6957133
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'basename' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) }
@@ -12,7 +12,7 @@ describe 'basename' do
   it { is_expected.to run.with_params('relative_path/to/a/file.ext', '.ext').and_return('file') }
   it { is_expected.to run.with_params('scheme:///path/to/a/file.ext').and_return('file.ext') }
 
-  context 'should run with UTF8 and double byte characters' do
+  context 'with UTF8 and double byte characters' do
     it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('竹.ext') }
     it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ', '.ㄘ').and_return('竹') }
   end
old mode 100755 (executable)
new mode 100644 (file)
index e506859..3ba5e2c
@@ -2,13 +2,13 @@ require 'spec_helper'
 
 describe 'bool2num' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
 
-  [ true, 'true', AlsoString.new('true') ].each do |truthy|
+  [true, 'true', AlsoString.new('true')].each do |truthy|
     it { is_expected.to run.with_params(truthy).and_return(1) }
   end
 
-  [ false, 'false', AlsoString.new('false') ].each do |falsey|
+  [false, 'false', AlsoString.new('false')].each do |falsey|
     it { is_expected.to run.with_params(falsey).and_return(0) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 23a754b..8d8f9b5
@@ -2,16 +2,15 @@ require 'spec_helper'
 
 describe 'bool2str' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
-  [ 'true', 'false', nil, :undef, ''].each do |invalid|
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
+  ['true', 'false', nil, :undef, ''].each do |invalid|
     it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError) }
   end
   it { is_expected.to run.with_params(true, 'yes', 'no', 'maybe').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(true, 'maybe').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(true, 0, 1).and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params(true).and_return("true") }
-  it { is_expected.to run.with_params(false).and_return("false") }
-  it { is_expected.to run.with_params(true, 'yes', 'no').and_return("yes") }
-  it { is_expected.to run.with_params(false, 'yes', 'no').and_return("no") }
-
+  it { is_expected.to run.with_params(true).and_return('true') }
+  it { is_expected.to run.with_params(false).and_return('false') }
+  it { is_expected.to run.with_params(true, 'yes', 'no').and_return('yes') }
+  it { is_expected.to run.with_params(false, 'yes', 'no').and_return('no') }
 end
old mode 100755 (executable)
new mode 100644 (file)
index c78aa62..e0e4003
@@ -1,17 +1,17 @@
 require 'spec_helper'
 
-describe 'camelcase' do
+describe 'camelcase', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params("abc").and_return("Abc") }
-  it { is_expected.to run.with_params("aa_bb_cc").and_return("AaBbCc") }
-  it { is_expected.to run.with_params("_aa__bb__cc_").and_return("AaBbCc") }
-  it { is_expected.to run.with_params("100").and_return("100") }
-  it { is_expected.to run.with_params("1_00").and_return("100") }
-  it { is_expected.to run.with_params("_").and_return("") }
-  it { is_expected.to run.with_params("").and_return("") }
+  it { is_expected.to run.with_params('abc').and_return('Abc') }
+  it { is_expected.to run.with_params('aa_bb_cc').and_return('AaBbCc') }
+  it { is_expected.to run.with_params('_aa__bb__cc_').and_return('AaBbCc') }
+  it { is_expected.to run.with_params('100').and_return('100') }
+  it { is_expected.to run.with_params('1_00').and_return('100') }
+  it { is_expected.to run.with_params('_').and_return('') }
+  it { is_expected.to run.with_params('').and_return('') }
   it { is_expected.to run.with_params([]).and_return([]) }
-  it { is_expected.to run.with_params(["abc", "aa_bb_cc"]).and_return(["Abc", "AaBbCc"]) }
-  it { is_expected.to run.with_params(["abc", 1, "aa_bb_cc"]).and_return(["Abc", 1, "AaBbCc"]) }
+  it { is_expected.to run.with_params(['abc', 'aa_bb_cc']).and_return(['Abc', 'AaBbCc']) }
+  it { is_expected.to run.with_params(['abc', 1, 'aa_bb_cc']).and_return(['Abc', 1, 'AaBbCc']) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 7ce2e16..dd5fc35
@@ -1,15 +1,15 @@
 require 'spec_helper'
 
-describe 'capitalize' do
+describe 'capitalize', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params("one").and_return("One") }
-  it { is_expected.to run.with_params("one two").and_return("One two") }
-  it { is_expected.to run.with_params("ONE TWO").and_return("One two") }
+  it { is_expected.to run.with_params('one').and_return('One') }
+  it { is_expected.to run.with_params('one two').and_return('One two') }
+  it { is_expected.to run.with_params('ONE TWO').and_return('One two') }
 
-  it { is_expected.to run.with_params(AlsoString.new("one")).and_return("One") }
+  it { is_expected.to run.with_params(AlsoString.new('one')).and_return('One') }
   it { is_expected.to run.with_params([]).and_return([]) }
-  it { is_expected.to run.with_params(["one", "two"]).and_return(["One", "Two"]) }
-  it { is_expected.to run.with_params(["one", 1, "two"]).and_return(["One", 1, "Two"]) }
+  it { is_expected.to run.with_params(['one', 'two']).and_return(['One', 'Two']) }
+  it { is_expected.to run.with_params(['one', 1, 'two']).and_return(['One', 1, 'Two']) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 567426f..8150c6e
@@ -1,13 +1,12 @@
 require 'spec_helper'
 
-describe 'ceiling' do
+describe 'ceiling', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params("foo").and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(34).and_return(34) }
   it { is_expected.to run.with_params(-34).and_return(-34) }
   it { is_expected.to run.with_params(33.1).and_return(34) }
   it { is_expected.to run.with_params(-33.1).and_return(-33) }
 end
-
old mode 100755 (executable)
new mode 100644 (file)
index 56bd9b1..e6612e8
@@ -1,24 +1,24 @@
 require 'spec_helper'
 
-describe 'chomp' do
+describe 'chomp', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params("a", "b").and_raise_error(Puppet::ParseError)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError)
   }
-  it { is_expected.to run.with_params("one").and_return("one") }
-  it { is_expected.to run.with_params("one\n").and_return("one") }
+  it { is_expected.to run.with_params('one').and_return('one') }
+  it { is_expected.to run.with_params("one\n").and_return('one') }
   it { is_expected.to run.with_params("one\n\n").and_return("one\n") }
-  it { is_expected.to run.with_params(["one\n", "two", "three\n"]).and_return(["one", "two", "three"]) }
+  it { is_expected.to run.with_params(["one\n", 'two', "three\n"]).and_return(['one', 'two', 'three']) }
 
-  it { is_expected.to run.with_params(AlsoString.new("one")).and_return("one") }
-  it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") }
+  it { is_expected.to run.with_params(AlsoString.new('one')).and_return('one') }
+  it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return('one') }
   it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") }
-  it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "two", "three"]) }
+  it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'two', 'three']) }
 
-  context 'should run with UTF8 and double byte characters' do
+  context 'with UTF8 and double byte characters' do
     it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") }
     it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") }
   end
old mode 100755 (executable)
new mode 100644 (file)
index b70fc37..b33edb5
@@ -1,24 +1,24 @@
 require 'spec_helper'
 
-describe 'chop' do
+describe 'chop', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params("a", "b").and_raise_error(Puppet::ParseError)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError)
   }
-  it { is_expected.to run.with_params("one").and_return("on") }
-  it { is_expected.to run.with_params("one\n").and_return("one") }
+  it { is_expected.to run.with_params('one').and_return('on') }
+  it { is_expected.to run.with_params("one\n").and_return('one') }
   it { is_expected.to run.with_params("one\n\n").and_return("one\n") }
-  it { is_expected.to run.with_params(["one\n", "two", "three\n"]).and_return(["one", "tw", "three"]) }
+  it { is_expected.to run.with_params(["one\n", 'two', "three\n"]).and_return(['one', 'tw', 'three']) }
 
-  it { is_expected.to run.with_params(AlsoString.new("one")).and_return("on") }
-  it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") }
+  it { is_expected.to run.with_params(AlsoString.new('one')).and_return('on') }
+  it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return('one') }
   it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") }
-  it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "tw", "three"]) }
+  it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'tw', 'three']) }
 
-  context 'should run with UTF8 and double byte characters' do
+  context 'with UTF8 and double byte characters' do
     it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") }
     it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") }
   end
index 3e2fe7a..7f0de34 100644 (file)
@@ -2,11 +2,11 @@ require 'spec_helper'
 
 describe 'clamp' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params(12, 88, 71, 190).and_raise_error(Puppet::ParseError, /Wrong number of arguments, need three to clamp/) }
-  it { is_expected.to run.with_params('12string', 88, 15).and_raise_error(Puppet::ParseError, /Required explicit numeric/) }
-  it { is_expected.to run.with_params(1, 2, {'a' => 55}).and_raise_error(Puppet::ParseError, /The Hash type is not allowed/) }
+  it { is_expected.to run.with_params(12, 88, 71, 190).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, need three to clamp}) }
+  it { is_expected.to run.with_params('12string', 88, 15).and_raise_error(Puppet::ParseError, %r{Required explicit numeric}) }
+  it { is_expected.to run.with_params(1, 2, 'a' => 55).and_raise_error(Puppet::ParseError, %r{The Hash type is not allowed}) }
   it { is_expected.to run.with_params('24', [575, 187]).and_return(187) }
   it { is_expected.to run.with_params([4, 3, '99']).and_return(4) }
   it { is_expected.to run.with_params(16, 750, 88).and_return(88) }
old mode 100755 (executable)
new mode 100644 (file)
index 6ab1b6e..4c67b3f
@@ -2,28 +2,27 @@ require 'spec_helper'
 
 describe 'concat' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([1], [2], [3]).and_return([1, 2, 3]) }
-  it { is_expected.to run.with_params(['1','2','3'],['4','5','6']).and_return(['1','2','3','4','5','6']) }
-  it { is_expected.to run.with_params(['1','2','3'],'4').and_return(['1','2','3','4']) }
-  it { is_expected.to run.with_params(['1','2','3'],[['4','5'],'6']).and_return(['1','2','3',['4','5'],'6']) }
-  it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) }
-  it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) }
+  it { is_expected.to run.with_params(['1', '2', '3'], ['4', '5', '6']).and_return(['1', '2', '3', '4', '5', '6']) }
+  it { is_expected.to run.with_params(['1', '2', '3'], '4').and_return(['1', '2', '3', '4']) }
+  it { is_expected.to run.with_params(['1', '2', '3'], [['4', '5'], '6']).and_return(['1', '2', '3', ['4', '5'], '6']) }
+  it { is_expected.to run.with_params(['1', '2'], ['3', '4'], ['5', '6']).and_return(['1', '2', '3', '4', '5', '6']) }
+  it { is_expected.to run.with_params(['1', '2'], '3', '4', ['5', '6']).and_return(['1', '2', '3', '4', '5', '6']) }
 
-context 'should run with UTF8 and double byte characters' do
-  it { is_expected.to run.with_params([{"a" => "b"}], {"c" => "d", "e" => "f"}).and_return([{"a" => "b"}, {"c" => "d", "e" => "f"}]) }
-  it { is_expected.to run.with_params(['ấ','β','©'],['đ','ể','文字列']).and_return(['ấ','β','©','đ','ể','文字列']) }
-end
+  context 'with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params([{ 'a' => 'b' }], 'c' => 'd', 'e' => 'f').and_return([{ 'a' => 'b' }, { 'c' => 'd', 'e' => 'f' }]) }
+    it { is_expected.to run.with_params(['ấ', 'β', '©'], ['đ', 'ể', '文字列']).and_return(['ấ', 'β', '©', 'đ', 'ể', '文字列']) }
+  end
 
-  it "should leave the original array intact" do
-    argument1 = ['1','2','3']
-    original1 = argument1.dup
-    argument2 = ['4','5','6']
-    original2 = argument2.dup
-    result = subject.call([argument1,argument2])
-    expect(argument1).to eq(original1)
-    expect(argument2).to eq(original2)
+  arguments = [['1', '2', '3'], ['4', '5', '6']]
+  originals = [arguments[0].dup, arguments[1].dup]
+  it 'leaves the original array intact' do
+    _result = subject.execute(arguments[0], arguments[1])
+    arguments.each_with_index do |argument, index|
+      expect(argument).to eq(originals[index])
+    end
   end
 end
index 8ab2284..d1a6cef 100644 (file)
@@ -2,23 +2,23 @@ require 'spec_helper'
 
 describe 'convert_base' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
-  it { is_expected.to run.with_params("asdf").and_raise_error(ArgumentError) }
-  it { is_expected.to run.with_params("asdf","moo","cow").and_raise_error(ArgumentError) }
-  it { is_expected.to run.with_params(["1"],"2").and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) }
-  it { is_expected.to run.with_params("1",["2"]).and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) }
-  it { is_expected.to run.with_params("1",1).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) }
-  it { is_expected.to run.with_params("1",37).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params('asdf').and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params('asdf', 'moo', 'cow').and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params(['1'], '2').and_raise_error(Puppet::ParseError, %r{argument must be either a string or an integer}) }
+  it { is_expected.to run.with_params('1', ['2']).and_raise_error(Puppet::ParseError, %r{argument must be either a string or an integer}) }
+  it { is_expected.to run.with_params('1', 1).and_raise_error(Puppet::ParseError, %r{base must be at least 2 and must not be greater than 36}) }
+  it { is_expected.to run.with_params('1', 37).and_raise_error(Puppet::ParseError, %r{base must be at least 2 and must not be greater than 36}) }
 
-  it "should raise a ParseError if argument 1 is a string that does not correspond to an integer in base 10" do
-    is_expected.to run.with_params("ten",6).and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/)
+  it 'raises a ParseError if argument 1 is a string that does not correspond to an integer in base 10' do
+    is_expected.to run.with_params('ten', 6).and_raise_error(Puppet::ParseError, %r{argument must be an integer or a string corresponding to an integer in base 10})
   end
 
-  it "should raise a ParseError if argument 2 is a string and does not correspond to an integer in base 10" do
-    is_expected.to run.with_params(100,"hex").and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/)
+  it 'raises a ParseError if argument 2 is a string and does not correspond to an integer in base 10' do
+    is_expected.to run.with_params(100, 'hex').and_raise_error(Puppet::ParseError, %r{argument must be an integer or a string corresponding to an integer in base 10})
   end
 
-  it { is_expected.to run.with_params("11",'16').and_return('b') }
-  it { is_expected.to run.with_params("35",'36').and_return('z') }
+  it { is_expected.to run.with_params('11', '16').and_return('b') }
+  it { is_expected.to run.with_params('35', '36').and_return('z') }
   it { is_expected.to run.with_params(5, 2).and_return('101') }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 3854cb8..54e1491
@@ -2,22 +2,22 @@ require 'spec_helper'
 
 describe 'count' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
-  it { is_expected.to run.with_params("one").and_raise_error(ArgumentError) }
-  it { is_expected.to run.with_params("one", "two").and_return(1) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params('one').and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params('one', 'two').and_return(1) }
   it {
-    pending("should actually be like this, and not like above")
-    is_expected.to run.with_params("one", "two").and_raise_error(ArgumentError)
+    pending('should actually be like this, and not like above')
+    is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError)
   }
-  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(ArgumentError) }
-  it { is_expected.to run.with_params(["one", "two", "three"]).and_return(3) }
-  it { is_expected.to run.with_params(["one", "two", "two"], "two").and_return(2) }
-  it { is_expected.to run.with_params(["one", nil, "two"]).and_return(2) }
-  it { is_expected.to run.with_params(["one", "", "two"]).and_return(2) }
-  it { is_expected.to run.with_params(["one", :undef, "two"]).and_return(2) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) }
+  it { is_expected.to run.with_params(['one', 'two', 'two'], 'two').and_return(2) }
+  it { is_expected.to run.with_params(['one', nil, 'two']).and_return(2) }
+  it { is_expected.to run.with_params(['one', '', 'two']).and_return(2) }
+  it { is_expected.to run.with_params(['one', :undef, 'two']).and_return(2) }
 
-  it { is_expected.to run.with_params(["ổņ℮", "ŧщộ", "three"]).and_return(3) }
-  it { is_expected.to run.with_params(["ổņ℮", "ŧщộ", "ŧщộ"], "ŧщộ").and_return(2) }
-  it { is_expected.to run.with_params(["ổņ℮", nil, "ŧщộ"]).and_return(2) }
-  it { is_expected.to run.with_params(["ổņ℮", :undef, "ŧщộ"]).and_return(2) }
+  it { is_expected.to run.with_params(['ổņ℮', 'ŧщộ', 'three']).and_return(3) }
+  it { is_expected.to run.with_params(['ổņ℮', 'ŧщộ', 'ŧщộ'], 'ŧщộ').and_return(2) }
+  it { is_expected.to run.with_params(['ổņ℮', nil, 'ŧщộ']).and_return(2) }
+  it { is_expected.to run.with_params(['ổņ℮', :undef, 'ŧщộ']).and_return(2) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 819e025..489bca5
@@ -1,59 +1,58 @@
 require 'spec_helper'
 
 describe 'deep_merge' do
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params({ 'key' => 'value' }).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, /unexpected argument type String/) }
-  it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('key' => 'value').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, %r{unexpected argument type String}) }
+  it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, %r{unexpected argument}) }
   it { is_expected.to run.with_params({}, '').and_return({}) }
   it { is_expected.to run.with_params({}, {}).and_return({}) }
   it { is_expected.to run.with_params({}, {}, {}).and_return({}) }
   it { is_expected.to run.with_params({}, {}, {}, {}).and_return({}) }
-  it { is_expected.to run.with_params({'key' => 'value'}, '').and_return({'key' => 'value'}) }
-  it { is_expected.to run.with_params({'key1' => 'value1'}, {'key2' => 'value2' }).and_return({'key1' => 'value1', 'key2' => 'value2'}) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value') }
+  it { is_expected.to run.with_params({ 'key1' => 'value1' }, 'key2' => 'value2').and_return('key1' => 'value1', 'key2' => 'value2') }
 
   describe 'when arguments have key collisions' do
-    it 'should prefer values from the last hash' do
+    it 'prefers values from the last hash' do
       is_expected.to run \
-        .with_params(
-          {'key1' => 'value1', 'key2' => 'value2' },
-          {'key2' => 'replacement_value', 'key3' => 'value3'}) \
-        .and_return(
-          {'key1' => 'value1', 'key2' => 'replacement_value', 'key3' => 'value3'})
+        .with_params({ 'key1' => 'value1', 'key2' => 'value2' }, 'key2' => 'replacement_value', 'key3' => 'value3') \
+        .and_return('key1' => 'value1', 'key2' => 'replacement_value', 'key3' => 'value3')
     end
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1'}, {'key1' => 'value2'}, {'key1' => 'value3'}) \
-      .and_return({'key1' => 'value3' })
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1' }, { 'key1' => 'value2' }, 'key1' => 'value3') \
+        .and_return('key1' => 'value3')
     }
   end
 
   describe 'when arguments have subhashes' do
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1'}, {'key2' => 'value2', 'key3' => {'subkey1' => 'value4'}}) \
-      .and_return( {'key1' => 'value1', 'key2' => 'value2', 'key3' => {'subkey1' => 'value4'}})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1' }, 'key2' => 'value2', 'key3' => { 'subkey1' => 'value4' }) \
+        .and_return('key1' => 'value1', 'key2' => 'value2', 'key3' => { 'subkey1' => 'value4' })
     }
-    it { is_expected.to run \
-      .with_params({'key1' => {'subkey1' => 'value1'}}, {'key1' => {'subkey2' => 'value2'}}) \
-      .and_return( {'key1' => {'subkey1' => 'value1', 'subkey2' => 'value2'}})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => { 'subkey1' => 'value1' } }, 'key1' => { 'subkey2' => 'value2' }) \
+        .and_return('key1' => { 'subkey1' => 'value1', 'subkey2' => 'value2' })
     }
-    it { is_expected.to run \
-      .with_params({'key1' => {'subkey1' => {'subsubkey1' => 'value1'}}}, {'key1' => {'subkey1' => {'subsubkey1' => 'value2'}}}) \
-      .and_return( {'key1' => {'subkey1' => {'subsubkey1' => 'value2'}}})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => { 'subkey1' => { 'subsubkey1' => 'value1' } } }, 'key1' => { 'subkey1' => { 'subsubkey1' => 'value2' } }) \
+        .and_return('key1' => { 'subkey1' => { 'subsubkey1' => 'value2' } })
     }
   end
 
-  it 'should not change the original hashes' do
-    argument1 = { 'key1' => 'value1' }
-    original1 = argument1.dup
-    argument2 = { 'key2' => 'value2' }
-    original2 = argument2.dup
-
-    subject.call([argument1, argument2])
-    expect(argument1).to eq(original1)
-    expect(argument2).to eq(original2)
+  arguments = { 'key1' => 'value1' }, { 'key2' => 'value2' }
+  originals = [arguments[0].dup, arguments[1].dup]
+  it 'does not change the original hashes' do
+    subject.execute(arguments[0], arguments[1])
+    arguments.each_with_index do |argument, index|
+      expect(argument).to eq(originals[index])
+    end
   end
 
-  context 'should run with UTF8 and double byte characters' do
-    it { is_expected.to run.with_params({'ĸέỹ1' => 'ϋǻļủë1'}, {'この文字列' => '万' }).and_return({'ĸέỹ1' => 'ϋǻļủë1', 'この文字列' => '万'}) }
+  context 'with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params({ 'ĸέỹ1' => 'ϋǻļủë1' }, 'この文字列' => '万').and_return('ĸέỹ1' => 'ϋǻļủë1', 'この文字列' => '万') }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 491a03b..74f9a7c
@@ -2,17 +2,18 @@ require 'spec_helper'
 
 describe 'defined_with_params' do
   describe 'when no resource is specified' do
-    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
   end
   describe 'when compared against a resource with no attributes' do
     let :pre_condition do
       'user { "dan": }'
     end
+
     it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
     it { is_expected.to run.with_params('User[bob]', {}).and_return(false) }
-    it { is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) }
+    it { is_expected.to run.with_params('User[dan]', 'foo' => 'bar').and_return(false) }
 
-    context 'should run with UTF8 and double byte characters' do
+    context 'with UTF8 and double byte characters' do
       it { is_expected.to run.with_params('User[ĵĭмოү]', {}).and_return(false) }
       it { is_expected.to run.with_params('User[ポーラ]', {}).and_return(false) }
     end
@@ -22,35 +23,39 @@ describe 'defined_with_params' do
     let :pre_condition do
       'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
     end
+
     it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
     it { is_expected.to run.with_params('User[dan]', '').and_return(true) }
-    it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}).and_return(true) }
-    it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present', 'managehome' => false}).and_return(true) }
-    it { is_expected.to run.with_params('User[dan]', {'ensure' => 'absent', 'managehome' => false}).and_return(false) }
+    it { is_expected.to run.with_params('User[dan]', 'ensure' => 'present').and_return(true) }
+    it { is_expected.to run.with_params('User[dan]', 'ensure' => 'present', 'managehome' => false).and_return(true) }
+    it { is_expected.to run.with_params('User[dan]', 'ensure' => 'absent', 'managehome' => false).and_return(false) }
   end
 
   describe 'when passing undef values' do
     let :pre_condition do
       'file { "/tmp/a": ensure => present }'
     end
+    let(:is_puppet_6_or_greater) { Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') >= 0 }
+    let(:undef_value) { is_puppet_6_or_greater ? nil : :undef } # even if :undef would work on 6.0.1, :undef should not be used
 
     it { is_expected.to run.with_params('File[/tmp/a]', {}).and_return(true) }
-    it { is_expected.to run.with_params('File[/tmp/a]', { 'ensure' => 'present', 'owner' => :undef }).and_return(true) }
+    it { is_expected.to run.with_params('File[/tmp/a]', 'ensure' => 'present', 'owner' => undef_value).and_return(true) }
   end
 
   describe 'when the reference is a' do
     let :pre_condition do
       'user { "dan": }'
     end
-    context 'reference' do
+
+    context 'with reference' do
       it { is_expected.to run.with_params(Puppet::Resource.new('User[dan]'), {}).and_return(true) }
     end
     if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0
-      context 'array' do
+      context 'with array' do
         it 'fails' do
           expect {
-            subject.call([['User[dan]'], {}])
-          }.to raise_error ArgumentError, /not understood: 'Array'/
+            subject.execute(['User[dan]'], {})
+          }.to raise_error(ArgumentError, %r{not understood: 'Array'})
         end
       end
     end
@@ -58,11 +63,25 @@ describe 'defined_with_params' do
 
   describe 'when passed a defined type' do
     let :pre_condition do
-      'test::deftype { "foo": }'
+      'define test::deftype() { } test::deftype { "foo": }'
     end
+
     it { is_expected.to run.with_params('Test::Deftype[foo]', {}).and_return(true) }
     it { is_expected.to run.with_params('Test::Deftype[bar]', {}).and_return(false) }
     it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[foo]'), {}).and_return(true) }
     it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[bar]'), {}).and_return(false) }
   end
+
+  describe 'when passed a class' do
+    let :pre_condition do
+      'class test () { } class { "test": }'
+    end
+
+    it { is_expected.to run.with_params('Class[test]', {}).and_return(true) }
+    it { is_expected.to run.with_params('Class["bar"]', {}).and_return(false) }
+    it { is_expected.to run.with_params('Class[bar]', {}).and_return(false) }
+    it { is_expected.to run.with_params(Puppet::Resource.new('class', 'test'), {}).and_return(true) }
+    it { is_expected.to run.with_params(Puppet::Resource.new('Class["bar"]'), {}).and_return(false) }
+    it { is_expected.to run.with_params(Puppet::Resource.new('Class[bar]'), {}).and_return(false) }
+  end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 0471039..bc261c7
@@ -2,12 +2,12 @@ require 'spec_helper'
 
 describe 'delete_at' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 1).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(['one'], 'two').and_raise_error(Puppet::ParseError) }
   it {
-    pending("Current implementation ignores parameters after the first two.")
+    pending('Current implementation ignores parameters after the first two.')
     is_expected.to run.with_params(['one'], 0, 1).and_raise_error(Puppet::ParseError)
   }
 
@@ -18,13 +18,12 @@ describe 'delete_at' do
   it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) }
   it { is_expected.to run.with_params([0, 1, 2], -1).and_return([0, 1]) }
   it { is_expected.to run.with_params([0, 1, 2], -4).and_return([0, 1, 2]) }
-  it { is_expected.to run.with_params(["ƒờở", "βāř", "ьầż"], 1).and_return(["ƒờở", "ьầż"]) }
+  it { is_expected.to run.with_params(['ƒờở', 'βāř', 'ьầż'], 1).and_return(['ƒờở', 'ьầż']) }
 
-
-  it "should leave the original array intact" do
+  it 'leaves the original array intact' do
     argument = [1, 2, 3]
     original = argument.dup
-    result = subject.call([argument,2])
+    _result = subject.execute(argument, 2)
     expect(argument).to eq(original)
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index f27a946..ff21d31
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'delete_regex' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([], 'two') }
   it { is_expected.to run.with_params({}, 'two') }
@@ -28,27 +28,29 @@ describe 'delete_regex' do
   describe 'deleting from an array' do
     it { is_expected.to run.with_params({}, '').and_return({}) }
     it { is_expected.to run.with_params({}, 'key').and_return({}) }
-    it { is_expected.to run.with_params({'key' => 'value'}, 'key').and_return({}) }
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, 'key2') \
-      .and_return( {'key1' => 'value1', 'key3' => 'value3'})
+    it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return({}) }
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'key2') \
+        .and_return('key1' => 'value1', 'key3' => 'value3')
     }
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \
-      .and_return( {'key3' => 'value3'})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, ['key1', 'key2']) \
+        .and_return('key3' => 'value3')
     }
   end
 
-  it "should leave the original array intact" do
-    argument1 = ['one','two','three']
+  it 'leaves the original array intact' do
+    argument1 = ['one', 'two', 'three']
     original1 = argument1.dup
-    subject.call([argument1,'two'])
+    subject.execute(argument1, 'two')
     expect(argument1).to eq(original1)
   end
-  it "should leave the original hash intact" do
-    argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}
+  it 'leaves the original hash intact' do
+    argument1 = { 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }
     original1 = argument1.dup
-    subject.call([argument1,'key2'])
+    subject.execute(argument1, 'key2')
     expect(argument1).to eq(original1)
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 4e37865..df9ad52
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'delete' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([], 'two') }
   it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) }
@@ -40,37 +40,40 @@ describe 'delete' do
   describe 'deleting from an array' do
     it { is_expected.to run.with_params({}, '').and_return({}) }
     it { is_expected.to run.with_params({}, 'key').and_return({}) }
-    it { is_expected.to run.with_params({'key' => 'value'}, 'key').and_return({}) }
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, 'key2') \
-      .and_return( {'key1' => 'value1', 'key3' => 'value3'})
+    it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return({}) }
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'key2') \
+        .and_return('key1' => 'value1', 'key3' => 'value3')
     }
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \
-      .and_return( {'key3' => 'value3'})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, ['key1', 'key2']) \
+        .and_return('key3' => 'value3')
     }
-    it { is_expected.to run \
-      .with_params({'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3'}, ['ĸəұ1', 'ĸəұ2']) \
-      .and_return( {'ĸəұ3' => 'νãŀủĕ3'})
+    it {
+      is_expected.to run \
+        .with_params({ 'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3' }, ['ĸəұ1', 'ĸəұ2']) \
+        .and_return('ĸəұ3' => 'νãŀủĕ3')
     }
   end
 
-  it "should leave the original array intact" do
-    argument1 = ['one','two','three']
+  it 'leaves the original array intact' do
+    argument1 = ['one', 'two', 'three']
     original1 = argument1.dup
-    result = subject.call([argument1,'two'])
+    _result = subject.execute(argument1, 'two')
     expect(argument1).to eq(original1)
   end
-  it "should leave the original string intact" do
+  it 'leaves the original string intact' do
     argument1 = 'onetwothree'
     original1 = argument1.dup
-    result = subject.call([argument1,'two'])
+    _result = subject.execute(argument1, 'two')
     expect(argument1).to eq(original1)
   end
-  it "should leave the original hash intact" do
-    argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}
+  it 'leaves the original hash intact' do
+    argument1 = { 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }
     original1 = argument1.dup
-    result = subject.call([argument1,'key2'])
+    _result = subject.execute(argument1, 'key2')
     expect(argument1).to eq(original1)
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index c20cee2..813105e
@@ -1,28 +1,31 @@
 require 'spec_helper'
 
 describe 'delete_undef_values' do
+  let(:is_puppet_6) { Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') == 0 }
+
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
 
   describe 'when deleting from an array' do
-    [ :undef, '', nil ].each do |undef_value|
+    # Behavior is different in Puppet 6.0.0, and fixed in PUP-9180 in Puppet 6.0.1
+    [:undef, '', nil].each do |undef_value|
       describe "when undef is represented by #{undef_value.inspect}" do
-        before do
+        before(:each) do
           pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
-          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil
+          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == :undef && is_puppet_6
         end
         it { is_expected.to run.with_params([undef_value]).and_return([]) }
-        it { is_expected.to run.with_params(['one',undef_value,'two','three']).and_return(['one','two','three']) }
-        it { is_expected.to run.with_params(['ớņέ',undef_value,'ŧשּׁō','ŧħґëə']).and_return(['ớņέ','ŧשּׁō','ŧħґëə']) }
+        it { is_expected.to run.with_params(['one', undef_value, 'two', 'three']).and_return(['one', 'two', 'three']) }
+        it { is_expected.to run.with_params(['ớņέ', undef_value, 'ŧשּׁō', 'ŧħґëə']).and_return(['ớņέ', 'ŧשּׁō', 'ŧħґëə']) }
       end
 
-      it "should leave the original argument intact" do
-        argument = ['one',undef_value,'two']
+      it 'leaves the original argument intact' do
+        argument = ['one', undef_value, 'two']
         original = argument.dup
-        result = subject.call([argument,2])
+        _result = subject.execute(argument, 2)
         expect(argument).to eq(original)
       end
     end
@@ -31,27 +34,28 @@ describe 'delete_undef_values' do
   end
 
   describe 'when deleting from a hash' do
-    [ :undef, '', nil ].each do |undef_value|
+    [:undef, '', nil].each do |undef_value|
       describe "when undef is represented by #{undef_value.inspect}" do
-        before do
+        before(:each) do
           pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
-          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil
+          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == :undef && is_puppet_6
         end
-        it { is_expected.to run.with_params({'key' => undef_value}).and_return({}) }
-        it { is_expected.to run \
-          .with_params({'key1' => 'value1', 'undef_key' => undef_value, 'key2' => 'value2'}) \
-          .and_return({'key1' => 'value1', 'key2' => 'value2'})
+        it { is_expected.to run.with_params('key' => undef_value).and_return({}) }
+        it {
+          is_expected.to run \
+            .with_params('key1' => 'value1', 'undef_key' => undef_value, 'key2' => 'value2') \
+            .and_return('key1' => 'value1', 'key2' => 'value2')
         }
       end
 
-      it "should leave the original argument intact" do
+      it 'leaves the original argument intact' do
         argument = { 'key1' => 'value1', 'key2' => undef_value }
         original = argument.dup
-        result = subject.call([argument,2])
+        _result = subject.execute(argument, 2)
         expect(argument).to eq(original)
       end
     end
 
-    it { is_expected.to run.with_params({'key' => 'undef'}).and_return({'key' => 'undef'}) }
+    it { is_expected.to run.with_params('key' => 'undef').and_return('key' => 'undef') }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 329fa0b..fdd8ac4
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'delete_values' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
@@ -14,28 +14,32 @@ describe 'delete_values' do
 
   describe 'when deleting from a hash' do
     it { is_expected.to run.with_params({}, 'value').and_return({}) }
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1'}, 'non-existing value') \
-      .and_return({'key1' => 'value1'})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1' }, 'non-existing value') \
+        .and_return('key1' => 'value1')
     }
-    it { is_expected.to run \
-      .with_params({'ҝếỵ1 ' => 'νâĺūẹ1', 'ҝếỵ2' => 'value to delete'}, 'value to delete') \
-      .and_return({'ҝếỵ1 ' => 'νâĺūẹ1'})
+    it {
+      is_expected.to run \
+        .with_params({ 'ҝếỵ1 ' => 'νâĺūẹ1', 'ҝếỵ2' => 'value to delete' }, 'value to delete') \
+        .and_return('ҝếỵ1 ' => 'νâĺūẹ1')
     }
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1', 'key2' => 'νǎŀữ℮ ťớ đêłểťė'}, 'νǎŀữ℮ ťớ đêłểťė') \
-      .and_return({'key1' => 'value1'})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1', 'key2' => 'νǎŀữ℮ ťớ đêłểťė' }, 'νǎŀữ℮ ťớ đêłểťė') \
+        .and_return('key1' => 'value1')
     }
-    it { is_expected.to run \
-      .with_params({'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete'}, 'value to delete') \
-      .and_return({'key1' => 'value1'})
+    it {
+      is_expected.to run \
+        .with_params({ 'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete' }, 'value to delete') \
+        .and_return('key1' => 'value1')
     }
   end
 
-  it "should leave the original argument intact" do
+  it 'leaves the original argument intact' do
     argument = { 'key1' => 'value1', 'key2' => 'value2' }
     original = argument.dup
-    result = subject.call([argument, 'value2'])
+    _result = subject.execute(argument, 'value2')
     expect(argument).to eq(original)
   end
 end
index bde4e89..50203c9 100644 (file)
@@ -2,58 +2,71 @@ require 'spec_helper'
 
 if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
   describe 'deprecation' do
-    before(:each) {
+    before(:each) do
       # this is to reset the strict variable to default
       Puppet.settings[:strict] = :warning
-    }
+    end
 
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
 
-    it 'should display a single warning' do
-      Puppet.expects(:warning).with(includes('heelo'))
+    it 'displays a single warning' do
+      if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0
+        expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key')
+        expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.")
+      else
+        expect(Puppet).to receive(:warning).with(include('heelo')).once
+      end
       is_expected.to run.with_params('key', 'heelo')
     end
 
-    it 'should display a single warning, despite multiple calls' do
-      Puppet.expects(:warning).with(includes('heelo')).once
-      is_expected.to run.with_params('key', 'heelo')
-      is_expected.to run.with_params('key', 'heelo')
+    it 'displays a single warning, despite multiple calls' do
+      if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0
+        expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key').twice
+        expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.")
+      else
+        expect(Puppet).to receive(:warning).with(include('heelo')).once
+      end
+      (0..1).each do |_i|
+        is_expected.to run.with_params('key', 'heelo')
+      end
     end
 
-    it 'should fail twice with message, with multiple calls. when strict= :error' do
+    it 'fails twice with message, with multiple calls. when strict= :error' do
       Puppet.settings[:strict] = :error
-      Puppet.expects(:warning).with(includes('heelo')).never
-      is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
-      is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
+      expect(Puppet).to receive(:warning).with(include('heelo')).never
+      (0..1).each do |_i|
+        is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, %r{deprecation. key. heelo})
+      end
     end
 
-    it 'should display nothing, despite multiple calls. strict= :off' do
+    it 'displays nothing, despite multiple calls. strict= :off' do
       Puppet.settings[:strict] = :off
-      Puppet.expects(:warning).with(includes('heelo')).never
-      is_expected.to run.with_params('key', 'heelo')
-      is_expected.to run.with_params('key', 'heelo')
+      expect(Puppet).to receive(:warning).with(include('heelo')).never
+      (0..1).each do |_i|
+        is_expected.to run.with_params('key', 'heelo')
+      end
     end
 
-    after(:all) {
+    after(:each) do
       # this is to reset the strict variable to default
       Puppet.settings[:strict] = :warning
-    }
+    end
   end
 elsif Puppet.version.to_f < 4.0
   # Puppet version < 4 will use these tests.
   describe 'deprecation' do
-    after(:all) do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
-    before(:all) do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+    before(:each) do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
     end
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
-    it 'should display a single warning' do
-      scope.expects(:warning).with(includes('heelo'))
+    it 'displays a single warning' do
+      expect(scope).to receive(:warning).with(include('heelo'))
       is_expected.to run.with_params('key', 'heelo')
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 0ae3689..127e7b1
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'difference' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
@@ -19,5 +19,5 @@ describe 'difference' do
   it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one']) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one']) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['one']) }
-  it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3']) end
+  it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3']) end
 end
index a7b8a3d..2a9252c 100644 (file)
 require 'spec_helper'
 
 describe 'dig44' do
+  let(:undef_value) do
+    (Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0) ? :undef : nil
+  end
 
   let(:data) do
     {
-        'a' => {
-            'g' => '2',
-            'e' => [
-                'f0',
-                'f1',
-                {
-                    'x' => {
-                        'y' => 'z'
-                    }
-                },
-                'f3',
-            ]
-        },
-        'b' => true,
-        'c' => false,
-        'd' => '1',
-        'e' => :undef,
-        'f' => nil,
+      'a' => {
+        'g' => '2',
+        'e' => [
+          'f0',
+          'f1',
+          {
+            'x' => {
+              'y' => 'z',
+            },
+          },
+          'f3',
+        ],
+      },
+      'b' => true,
+      'c' => false,
+      'd' => '1',
+      'e' => undef_value,
+      'f' => nil,
     }
   end
 
   let(:utf8_data) do
     {
-        'ẵ' => {
-            'в' => [
-                '©',
-                'ĝ',
-                'に',
-            ]
-        }
+      'ẵ' => {
+        'в' => [
+          '©',
+          'ĝ',
+          'に',
+        ],
+      },
     }
   end
 
-  context 'single values' do
-    it 'should exist' do
+  context 'with single values' do
+    it 'exists' do
       is_expected.not_to be_nil
     end
 
-    it 'should require two arguments' do
-      is_expected.to run.with_params().and_raise_error(ArgumentError)
+    it 'requires two arguments' do
+      is_expected.to run.with_params.and_raise_error(ArgumentError)
     end
 
-    it 'should fail if the data is not a structure' do
+    it 'fails if the data is not a structure' do
       is_expected.to run.with_params('test', []).and_raise_error(Puppet::Error)
     end
 
-    it 'should fail if the path is not an array' do
+    it 'fails if the path is not an array' do
       is_expected.to run.with_params({}, '').and_raise_error(Puppet::Error)
     end
 
-    it 'should return the value if the value is string' do
+    it 'returns the value if the value is string' do
       is_expected.to run.with_params(data, ['d'], 'default').and_return('1')
     end
 
-    it 'should return true if the value is true' do
+    it 'returns true if the value is true' do
       is_expected.to run.with_params(data, ['b'], 'default').and_return(true)
     end
 
-    it 'should return false if the value is false' do
+    it 'returns false if the value is false' do
       is_expected.to run.with_params(data, ['c'], 'default').and_return(false)
     end
 
-    it 'should return the default if the value is nil' do
+    it 'returns the default if the value is nil' do
       is_expected.to run.with_params(data, ['f'], 'default').and_return('default')
     end
 
-    it 'should return the default if the value is :undef (same as nil)' do
+    it 'returns the default if the value is :undef (same as nil)' do
       is_expected.to run.with_params(data, ['e'], 'default').and_return('default')
     end
 
-    it 'should return the default if the path is not found' do
+    it 'returns the default if the path is not found' do
       is_expected.to run.with_params(data, ['missing'], 'default').and_return('default')
     end
   end
 
-  context 'structure values' do
-
-    it 'should be able to extract a deeply nested hash value' do
-      is_expected.to run.with_params(data, %w(a g), 'default').and_return('2')
+  context 'with structured values' do
+    it 'is able to extract a deeply nested hash value' do
+      is_expected.to run.with_params(data, ['a', 'g'], 'default').and_return('2')
     end
 
-    it 'should return the default value if the path is too long' do
-      is_expected.to run.with_params(data, %w(a g c d), 'default').and_return('default')
+    it 'returns the default value if the path is too long' do
+      is_expected.to run.with_params(data, ['a', 'g', 'c', 'd'], 'default').and_return('default')
     end
 
-    it 'should support an array index (number) in the path' do
+    it 'supports an array index (number) in the path' do
       is_expected.to run.with_params(data, ['a', 'e', 1], 'default').and_return('f1')
     end
 
-    it 'should support an array index (string) in the path' do
-      is_expected.to run.with_params(data, %w(a e 1), 'default').and_return('f1')
+    it 'supports an array index (string) in the path' do
+      is_expected.to run.with_params(data, ['a', 'e', '1'], 'default').and_return('f1')
     end
 
-    it 'should return the default value if an array index is not a number' do
-      is_expected.to run.with_params(data, %w(a b c), 'default').and_return('default')
+    it 'returns the default value if an array index is not a number' do
+      is_expected.to run.with_params(data, ['a', 'b', 'c'], 'default').and_return('default')
     end
 
-    it 'should return the default value if and index is out of array length' do
-      is_expected.to run.with_params(data, %w(a e 5), 'default').and_return('default')
+    it 'returns the default value if and index is out of array length' do
+      is_expected.to run.with_params(data, ['a', 'e', '5'], 'default').and_return('default')
     end
 
-    it 'should be able to path though both arrays and hashes' do
-      is_expected.to run.with_params(data, %w(a e 2 x y), 'default').and_return('z')
+    it 'is able to path though both arrays and hashes' do
+      is_expected.to run.with_params(data, ['a', 'e', '2', 'x', 'y'], 'default').and_return('z')
     end
 
-    it 'should return "nil" if value is not found and no default value is provided' do
-      is_expected.to run.with_params(data, %w(a 1)).and_return(nil)
+    it 'returns "nil" if value is not found and no default value is provided' do
+      is_expected.to run.with_params(data, ['a', '1']).and_return(nil)
     end
   end
 
-  context 'Internationalization (i18N) values' do
-
-    it 'should be able to return a unicode character' do
+  context 'with internationalization (i18N) values' do
+    it 'is able to return a unicode character' do
       is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 0]).and_return('©')
     end
 
-    it 'should be able to return a utf8 character' do
+    it 'is able to return a utf8 character' do
       is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 1]).and_return('ĝ')
     end
 
-    it 'should be able to return a double byte character' do
+    it 'is able to return a double byte character' do
       is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 2]).and_return('に')
     end
   end
index ad16fdd..ac2b6e4 100644 (file)
@@ -1,13 +1,12 @@
 require 'spec_helper'
 
 describe 'dig' do
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("dig")).to eq("function_dig")
+  it 'exists' do
+    expect(Puppet::Parser::Functions.function('dig')).to eq('function_dig')
   end
 
-  it "should give a deprecation warning when called" do
-    scope.expects(:warning).with("dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.")
+  it 'gives a deprecation warning when called' do
+    expect(scope).to receive(:warning).with('dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.')
     scope.function_dig([{}, []])
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index c494915..af2f476
@@ -2,16 +2,19 @@ require 'spec_helper'
 
 describe 'dirname' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(:undef).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(nil).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('/path/to/a') }
   it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('relative_path/to/a') }
 
-  context 'should run with UTF8 and double byte characters' do
+  context 'with UTF8 and double byte characters' do
     it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('scheme:///√ạĺűē') }
     it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ').and_return('ҝẽγ:/√ạĺűē') }
   end
index 97abae7..8677d8c 100644 (file)
@@ -1,13 +1,13 @@
 require 'spec_helper'
 
 describe 'dos2unix' do
-  context 'Checking parameter validity' do
+  context 'when checking parameter validity' do
     it { is_expected.not_to eq(nil) }
     it do
-      is_expected.to run.with_params.and_raise_error(ArgumentError, /Wrong number of arguments/)
+      is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments})
     end
     it do
-      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/)
+      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{Wrong number of arguments})
     end
     it do
       is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError)
@@ -20,28 +20,28 @@ describe 'dos2unix' do
     end
   end
 
-  context 'Converting from dos to unix format' do
+  context 'when converting from dos to unix format' do
     sample_text    = "Hello\r\nWorld\r\n"
     desired_output = "Hello\nWorld\n"
 
-    it 'should output unix format' do
-      should run.with_params(sample_text).and_return(desired_output)
+    it 'outputs unix format' do
+      is_expected.to run.with_params(sample_text).and_return(desired_output)
     end
   end
 
-  context 'Internationalization (i18N) values' do
+  context 'with internationalization (i18N) values' do
     sample_text_utf8    = "Ħ℮ļłǿ\r\nשׁөŕłđ\r\n"
     desired_output_utf8 = "Ħ℮ļłǿ\nשׁөŕłđ\n"
 
     sample_text_doublebyte    = "こんにちは\r\n世界\r\n"
     desired_output_doublebyte = "こんにちは\n世界\n"
 
-    it 'should output uft8 string' do
-      should run.with_params(sample_text_utf8).and_return(desired_output_utf8)
+    it 'outputs uft8 string' do
+      is_expected.to run.with_params(sample_text_utf8).and_return(desired_output_utf8)
     end
 
-    it 'should output double byte string' do
-      should run.with_params(sample_text_doublebyte).and_return(desired_output_doublebyte)
+    it 'outputs double byte string' do
+      is_expected.to run.with_params(sample_text_doublebyte).and_return(desired_output_doublebyte)
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index c594560..78bfec2
@@ -1,15 +1,15 @@
 require 'spec_helper'
 
-describe 'downcase' do
+describe 'downcase', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params("abc").and_return("abc") }
-  it { is_expected.to run.with_params("Abc").and_return("abc") }
-  it { is_expected.to run.with_params("ABC").and_return("abc") }
+  it { is_expected.to run.with_params('abc').and_return('abc') }
+  it { is_expected.to run.with_params('Abc').and_return('abc') }
+  it { is_expected.to run.with_params('ABC').and_return('abc') }
 
-  it { is_expected.to run.with_params(AlsoString.new("ABC")).and_return("abc") }
+  it { is_expected.to run.with_params(AlsoString.new('ABC')).and_return('abc') }
   it { is_expected.to run.with_params([]).and_return([]) }
-  it { is_expected.to run.with_params(["ONE", "TWO"]).and_return(["one", "two"]) }
-  it { is_expected.to run.with_params(["One", 1, "Two"]).and_return(["one", 1, "two"]) }
+  it { is_expected.to run.with_params(['ONE', 'TWO']).and_return(['one', 'two']) }
+  it { is_expected.to run.with_params(['One', 1, 'Two']).and_return(['one', 1, 'two']) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index a3a25d6..c6bf1e4
@@ -1,10 +1,10 @@
 require 'spec_helper'
 
-describe 'empty' do
+describe 'empty', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it {
-    pending("Current implementation ignores parameters after the first.")
+    pending('Current implementation ignores parameters after the first.')
     is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError)
   }
   it { is_expected.to run.with_params(0).and_return(false) }
@@ -18,5 +18,5 @@ describe 'empty' do
   it { is_expected.to run.with_params(['one']).and_return(false) }
 
   it { is_expected.to run.with_params({}).and_return(true) }
-  it { is_expected.to run.with_params({'key' => 'value'}).and_return(false) }
+  it { is_expected.to run.with_params('key' => 'value').and_return(false) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 190e580..6d1a841
@@ -2,70 +2,71 @@ require 'spec_helper'
 
 describe 'ensure_packages' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it {
-    pending("should not accept numbers as arguments")
+    pending('should not accept numbers as arguments')
     is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError)
   }
   it {
-    pending("should not accept numbers as arguments")
-    is_expected.to run.with_params(["packagename", 1]).and_raise_error(Puppet::ParseError)
+    pending('should not accept numbers as arguments')
+    is_expected.to run.with_params(['packagename', 1]).and_raise_error(Puppet::ParseError)
   }
-  it { is_expected.to run.with_params("packagename") }
-  it { is_expected.to run.with_params(["packagename1", "packagename2"]) }
+  it { is_expected.to run.with_params('packagename') }
+  it { is_expected.to run.with_params(['packagename1', 'packagename2']) }
 
-  context 'given a catalog with "package { puppet: ensure => absent }"' do
+  context 'when given a catalog with "package { puppet: ensure => absent }"' do
     let(:pre_condition) { 'package { puppet: ensure => absent }' }
 
     describe 'after running ensure_package("facter")' do
-      before { subject.call(['facter']) }
+      before(:each) { subject.execute('facter') }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('absent') }
-      it { expect(lambda { catalogue }).to contain_package('facter').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent') }
+      it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present') }
     end
 
     describe 'after running ensure_package("facter", { "provider" => "gem" })' do
-      before { subject.call(['facter', { "provider" => "gem" }]) }
+      before(:each) { subject.execute('facter', 'provider' => 'gem') }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('absent').without_provider() }
-      it { expect(lambda { catalogue }).to contain_package('facter').with_ensure('present').with_provider("gem") }
+      it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent').without_provider }
+      it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present').with_provider('gem') }
     end
   end
 
-  context 'given an empty packages array' do
+  context 'when given an empty packages array' do
     let(:pre_condition) { 'notify { "hi": } -> Package <| |>; $somearray = ["vim",""]; ensure_packages($somearray)' }
 
     describe 'after running ensure_package(["vim", ""])' do
-      it { expect { catalogue }.to raise_error(Puppet::ParseError, /Empty String provided/) }
+      it { expect { catalogue }.to raise_error(Puppet::ParseError, %r{Empty String provided}) }
     end
   end
 
-  context 'given hash of packages' do
-    before { subject.call([{"foo" => { "provider" => "rpm" }, "bar" => { "provider" => "gem" }}, { "ensure" => "present"}]) }
-    before { subject.call([{"パッケージ" => { "ensure" => "absent"}}]) }
-    before { subject.call([{"ρǻ¢κầģẻ" => { "ensure" => "absent"}}]) }
+  context 'when given hash of packages' do
+    before(:each) do
+      subject.execute({ 'foo' => { 'provider' => 'rpm' }, 'bar' => { 'provider' => 'gem' } }, 'ensure' => 'present')
+      subject.execute('パッケージ' => { 'ensure' => 'absent' })
+      subject.execute('ρǻ¢κầģẻ' => { 'ensure' => 'absent' })
+    end
 
     # this lambda is required due to strangeness within rspec-puppet's expectation handling
-    it { expect(lambda { catalogue }).to contain_package('foo').with({'provider' => 'rpm', 'ensure' => 'present'}) }
-    it { expect(lambda { catalogue }).to contain_package('bar').with({'provider' => 'gem', 'ensure' => 'present'}) }
+    it { expect(-> { catalogue }).to contain_package('foo').with('provider' => 'rpm', 'ensure' => 'present') }
+    it { expect(-> { catalogue }).to contain_package('bar').with('provider' => 'gem', 'ensure' => 'present') }
 
-    context 'should run with UTF8 and double byte characters' do
-    it { expect(lambda { catalogue }).to contain_package('パッケージ').with({'ensure' => 'absent'}) }
-    it { expect(lambda { catalogue }).to contain_package('ρǻ¢κầģẻ').with({'ensure' => 'absent'}) }
+    context 'with UTF8 and double byte characters' do
+      it { expect(-> { catalogue }).to contain_package('パッケージ').with('ensure' => 'absent') }
+      it { expect(-> { catalogue }).to contain_package('ρǻ¢κầģẻ').with('ensure' => 'absent') }
     end
   end
 
-  context 'given a catalog with "package { puppet: ensure => present }"' do
+  context 'when given a catalog with "package { puppet: ensure => present }"' do
     let(:pre_condition) { 'package { puppet: ensure => present }' }
 
     describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do
-      before { subject.call(['puppet', { "ensure" => "installed" }]) }
+      before(:each) { subject.execute('puppet', 'ensure' => 'installed') }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('present') }
     end
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index c847bf7..9bbfacc
@@ -2,8 +2,8 @@ require 'spec_helper'
 
 describe 'ensure_resource' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) }
-  it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a type}) }
+  it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, %r{Must specify a title}) }
   if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0
     it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(ArgumentError) }
   else
@@ -11,125 +11,139 @@ describe 'ensure_resource' do
   end
 
   it {
-    pending("should not accept numbers as arguments")
-    is_expected.to run.with_params(1,2,3).and_raise_error(Puppet::ParseError)
+    pending('should not accept numbers as arguments')
+    is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError)
   }
 
-  context 'given an empty catalog' do
+  context 'when given an empty catalog' do
     describe 'after running ensure_resource("user", "username1", {})' do
-      before { subject.call(['User', 'username1', {}]) }
+      before(:each) { subject.execute('User', 'username1', {}) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').without_ensure }
+      it { expect(-> { catalogue }).to contain_user('username1').without_ensure }
     end
 
     describe 'after running ensure_resource("user", "username1", { gid => undef })' do
-      before { subject.call(['User', 'username1', { 'gid' => :undef }]) }
+      before(:each) { subject.execute('User', 'username1', 'gid' => undef_value) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').without_ensure }
-      it { expect(lambda { catalogue }).to contain_user('username1').without_gid }
+      it { expect(-> { catalogue }).to contain_user('username1').without_ensure }
+      it { expect(-> { catalogue }).to contain_user('username1').without_gid }
     end
 
     describe 'after running ensure_resource("user", "username1", { ensure => present, gid => undef })' do
-      before { subject.call(['User', 'username1', { 'ensure' => 'present', 'gid' => :undef }]) }
+      before(:each) { subject.execute('User', 'username1', 'ensure' => 'present', 'gid' => undef_value) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
-      it { expect(lambda { catalogue }).to contain_user('username1').without_gid }
+      it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_user('username1').without_gid }
     end
 
     describe 'after running ensure_resource("test::deftype", "foo", {})' do
-      before { subject.call(['test::deftype', 'foo', {}]) }
+      let(:pre_condition) { 'define test::deftype { }' }
+
+      before(:each) { subject.execute('test::deftype', 'foo', {}) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure }
+      it { expect(-> { catalogue }).to contain_test__deftype('foo').without_ensure }
     end
   end
 
-  context 'given a catalog with UTF8 chars' do
+  context 'when given a catalog with UTF8 chars' do
     describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", {})' do
-      before { subject.call(['User', 'Şắოрŀễ Ţëם', {}]) }
+      before(:each) { subject.execute('User', 'Şắოрŀễ Ţëם', {}) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure }
+      it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure }
     end
 
     describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { gid => undef })' do
-      before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'gid' => :undef }]) }
+      before(:each) { subject.execute('User', 'Şắოрŀễ Ţëם', 'gid' => undef_value) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure }
-      it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid }
+      it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure }
+      it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid }
     end
 
     describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { ensure => present, gid => undef })' do
-      before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'ensure' => 'present', 'gid' => :undef }]) }
+      before(:each) { subject.execute('User', 'Şắოрŀễ Ţëם', 'ensure' => 'present', 'gid' => undef_value) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').with_ensure('present') }
-      it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid }
+      it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid }
     end
   end
 
-  context 'given a catalog with "user { username1: ensure => present }"' do
+  context 'when given a catalog with "user { username1: ensure => present }"' do
     let(:pre_condition) { 'user { username1: ensure => present }' }
 
     describe 'after running ensure_resource("user", "username1", {})' do
-      before { subject.call(['User', 'username1', {}]) }
+      before(:each) { subject.execute('User', 'username1', {}) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') }
     end
 
     describe 'after running ensure_resource("user", "username2", {})' do
-      before { subject.call(['User', 'username2', {}]) }
+      before(:each) { subject.execute('User', 'username2', {}) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
-      it { expect(lambda { catalogue }).to contain_user('username2').without_ensure }
+      it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_user('username2').without_ensure }
     end
 
     describe 'after running ensure_resource("user", "username1", { gid => undef })' do
-      before { subject.call(['User', 'username1', { 'gid' => :undef }]) }
+      before(:each) { subject.execute('User', 'username1', 'gid' => undef_value) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') }
     end
 
     describe 'after running ensure_resource("user", ["username1", "username2"], {})' do
-      before { subject.call(['User', ['username1', 'username2'], {}]) }
+      before(:each) { subject.execute('User', ['username1', 'username2'], {}) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
-      it { expect(lambda { catalogue }).to contain_user('username2').without_ensure }
+      it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') }
+      it { expect(-> { catalogue }).to contain_user('username2').without_ensure }
     end
 
     describe 'when providing already set params' do
       let(:params) { { 'ensure' => 'present' } }
-      before { subject.call(['User', ['username2', 'username3'], params]) }
+
+      before(:each) { subject.execute('User', ['username2', 'username3'], params) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_user('username1').with(params) }
-      it { expect(lambda { catalogue }).to contain_user('username2').with(params) }
+      it { expect(-> { catalogue }).to contain_user('username1').with(params) }
+      it { expect(-> { catalogue }).to contain_user('username2').with(params) }
     end
 
     context 'when trying to add params' do
-      it { is_expected.to run \
-        .with_params('User', 'username1', { 'ensure' => 'present', 'shell' => true }) \
-        .and_raise_error(Puppet::Resource::Catalog::DuplicateResourceError, /User\[username1\] is already declared/)
+      it {
+        is_expected.to run \
+          .with_params('User', 'username1', 'ensure' => 'present', 'shell' => true) \
+          .and_raise_error(Puppet::Resource::Catalog::DuplicateResourceError, %r{User\[username1\] is already declared})
       }
     end
   end
 
-  context 'given a catalog with "test::deftype { foo: }"' do
-    let(:pre_condition) { 'test::deftype { "foo": }' }
+  context 'when given a catalog with "test::deftype { foo: }"' do
+    let(:pre_condition) { 'define test::deftype { } test::deftype { "foo": }' }
 
     describe 'after running ensure_resource("test::deftype", "foo", {})' do
-      before { subject.call(['test::deftype', 'foo', {}]) }
+      before(:each) { subject.execute('test::deftype', 'foo', {}) }
 
       # this lambda is required due to strangeness within rspec-puppet's expectation handling
-      it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure }
+      it { expect(-> { catalogue }).to contain_test__deftype('foo').without_ensure }
+    end
+  end
+
+  if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0
+    def undef_value
+      :undef
+    end
+  else
+    def undef_value
+      nil
     end
   end
 end
index 7cca671..10a27bf 100644 (file)
@@ -2,24 +2,26 @@ require 'spec_helper'
 
 describe 'ensure_resources' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) }
-  it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a type}) }
+  it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, %r{Must specify a title}) }
 
   describe 'given a title hash of multiple resources' do
-    before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}}, {'ensure' => 'present'}]) }
+    before(:each) do
+      subject.execute('user', { 'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700' } }, 'ensure' => 'present')
+    end
 
     # this lambda is required due to strangeness within rspec-puppet's expectation handling
-    it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
-    it { expect(lambda { catalogue }).to contain_user('alex').with_ensure('present') }
-    it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) }
-    it { expect(lambda { catalogue }).to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700'}) }
+    it { expect(-> { catalogue }).to contain_user('dan').with_ensure('present') }
+    it { expect(-> { catalogue }).to contain_user('alex').with_ensure('present') }
+    it { expect(-> { catalogue }).to contain_user('dan').with('gid' => 'mygroup', 'uid' => '600') }
+    it { expect(-> { catalogue }).to contain_user('alex').with('gid' => 'mygroup', 'uid' => '700') }
   end
 
   describe 'given a title hash of a single resource' do
-    before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }}, {'ensure' => 'present'}]) }
+    before(:each) { subject.execute('user', { 'dan' => { 'gid' => 'mygroup', 'uid' => '600' } }, 'ensure' => 'present') }
 
     # this lambda is required due to strangeness within rspec-puppet's expectation handling
-    it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
-    it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) }
+    it { expect(-> { catalogue }).to contain_user('dan').with_ensure('present') }
+    it { expect(-> { catalogue }).to contain_user('dan').with('gid' => 'mygroup', 'uid' => '600') }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index b80f3c5..16109e3
@@ -1,15 +1,15 @@
 require 'spec_helper'
 
-describe 'flatten' do
+describe 'flatten', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([]).and_return([]) }
   it { is_expected.to run.with_params(['one']).and_return(['one']) }
   it { is_expected.to run.with_params([['one']]).and_return(['one']) }
-  it { is_expected.to run.with_params(["a","b","c","d","e","f","g"]).and_return(["a","b","c","d","e","f","g"]) }
-  it { is_expected.to run.with_params([["a","b",["c",["d","e"],"f","g"]]]).and_return(["a","b","c","d","e","f","g"]) }
-  it { is_expected.to run.with_params(["ã","β",["ĉ",["đ","ẽ","ƒ","ġ"]]]).and_return(["ã","β","ĉ","đ","ẽ","ƒ","ġ"]) }
+  it { is_expected.to run.with_params(['a', 'b', 'c', 'd', 'e', 'f', 'g']).and_return(['a', 'b', 'c', 'd', 'e', 'f', 'g']) }
+  it { is_expected.to run.with_params([['a', 'b', ['c', ['d', 'e'], 'f', 'g']]]).and_return(['a', 'b', 'c', 'd', 'e', 'f', 'g']) }
+  it { is_expected.to run.with_params(['ã', 'β', ['ĉ', ['đ', 'ẽ', 'ƒ', 'ġ']]]).and_return(['ã', 'β', 'ĉ', 'đ', 'ẽ', 'ƒ', 'ġ']) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 608c602..07d4ed3
@@ -1,9 +1,9 @@
 require 'spec_helper'
 
-describe 'floor' do
+describe 'floor', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
-  it { is_expected.to run.with_params("foo").and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(34).and_return(34) }
   it { is_expected.to run.with_params(-34).and_return(-34) }
index 861a59e..d5d3fbf 100644 (file)
@@ -2,47 +2,48 @@ require 'spec_helper'
 
 describe 'fqdn_rand_string' do
   let(:default_charset) { %r{\A[a-zA-Z0-9]{100}\z} }
+
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(0).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params(1.5).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params(-10).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params("-10").and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params("string").and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params([]).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params({}).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, /second argument must be undef or a string/) }
-  it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, /second argument must be undef or a string/) }
-  it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, /second argument must be undef or a string/) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(0).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params(1.5).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params(-10).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params('-10').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params('string').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params([]).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params({}).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, %r{second argument must be undef or a string}) }
+  it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, %r{second argument must be undef or a string}) }
+  it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, %r{second argument must be undef or a string}) }
   it { is_expected.to run.with_params(100).and_return(default_charset) }
-  it { is_expected.to run.with_params("100").and_return(default_charset) }
+  it { is_expected.to run.with_params('100').and_return(default_charset) }
   it { is_expected.to run.with_params(100, nil).and_return(default_charset) }
   it { is_expected.to run.with_params(100, '').and_return(default_charset) }
-  it { is_expected.to run.with_params(100, 'a').and_return(/\Aa{100}\z/) }
-  it { is_expected.to run.with_params(100, 'ab').and_return(/\A[ab]{100}\z/) }
-  it { is_expected.to run.with_params(100, 'ãβ').and_return(/\A[ãβ]{100}\z/) }
+  it { is_expected.to run.with_params(100, 'a').and_return(%r{\Aa{100}\z}) }
+  it { is_expected.to run.with_params(100, 'ab').and_return(%r{\A[ab]{100}\z}) }
+  it { is_expected.to run.with_params(100, 'ãβ').and_return(%r{\A[ãβ]{100}\z}) }
 
   it "provides the same 'random' value on subsequent calls for the same host" do
     expect(fqdn_rand_string(10)).to eql(fqdn_rand_string(10))
   end
 
-  it "considers the same host and same extra arguments to have the same random sequence" do
-    first_random = fqdn_rand_string(10, :extra_identifier => [1, "same", "host"])
-    second_random = fqdn_rand_string(10, :extra_identifier => [1, "same", "host"])
+  it 'considers the same host and same extra arguments to have the same random sequence' do
+    first_random = fqdn_rand_string(10, :extra_identifier => [1, 'same', 'host'])
+    second_random = fqdn_rand_string(10, :extra_identifier => [1, 'same', 'host'])
 
     expect(first_random).to eql(second_random)
   end
 
-  it "allows extra arguments to control the random value on a single host" do
-    first_random = fqdn_rand_string(10, :extra_identifier => [1, "different", "host"])
-    second_different_random = fqdn_rand_string(10, :extra_identifier => [2, "different", "host"])
+  it 'allows extra arguments to control the random value on a single host' do
+    first_random = fqdn_rand_string(10, :extra_identifier => [1, 'different', 'host'])
+    second_different_random = fqdn_rand_string(10, :extra_identifier => [2, 'different', 'host'])
 
     expect(first_random).not_to eql(second_different_random)
   end
 
-  it "should return different strings for different hosts" do
-    val1 = fqdn_rand_string(10, :host => "first.host.com")
-    val2 = fqdn_rand_string(10, :host => "second.host.com")
+  it 'returns different strings for different hosts' do
+    val1 = fqdn_rand_string(10, :host => 'first.host.com')
+    val2 = fqdn_rand_string(10, :host => 'second.host.com')
 
     expect(val1).not_to eql(val2)
   end
@@ -54,10 +55,10 @@ describe 'fqdn_rand_string' do
 
     # workaround not being able to use let(:facts) because some tests need
     # multiple different hostnames in one context
-    scope.stubs(:lookupvar).with("::fqdn", {}).returns(host)
+    allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host)
 
     function_args = [max]
-    if args.has_key?(:charset) or !extra.empty?
+    if args.key?(:charset) || !extra.empty?
       function_args << charset
     end
     function_args += extra
old mode 100755 (executable)
new mode 100644 (file)
index 7c1038a..7cd9f1d
@@ -2,9 +2,9 @@ require 'spec_helper'
 
 describe 'fqdn_rotate' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(0).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
-  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(0).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
   it { is_expected.to run.with_params('').and_return('') }
   it { is_expected.to run.with_params('a').and_return('a') }
   it { is_expected.to run.with_params('ã').and_return('ã') }
@@ -12,53 +12,51 @@ describe 'fqdn_rotate' do
   it { is_expected.to run.with_params([]).and_return([]) }
   it { is_expected.to run.with_params(['a']).and_return(['a']) }
 
-  it "should rotate a string and the result should be the same size" do
-    expect(fqdn_rotate("asdf").size).to eq(4)
+  it 'rotates a string and the result should be the same size' do
+    expect(fqdn_rotate('asdf').size).to eq(4)
   end
 
-  it "should rotate a string to give the same results for one host" do
-    val1 = fqdn_rotate("abcdefg", :host => 'one')
-    val2 = fqdn_rotate("abcdefg", :host => 'one')
+  it 'rotates a string to give the same results for one host' do
+    val1 = fqdn_rotate('abcdefg', :host => 'one')
+    val2 = fqdn_rotate('abcdefg', :host => 'one')
     expect(val1).to eq(val2)
   end
 
-  it "allows extra arguments to control the random rotation on a single host" do
-    val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "different", "host"])
-    val2 = fqdn_rotate("abcdefg", :extra_identifier => [2, "different", "host"])
+  it 'allows extra arguments to control the random rotation on a single host' do
+    val1 = fqdn_rotate('abcdefg', :extra_identifier => [1, 'different', 'host'])
+    val2 = fqdn_rotate('abcdefg', :extra_identifier => [2, 'different', 'host'])
     expect(val1).not_to eq(val2)
   end
 
-  it "considers the same host and same extra arguments to have the same random rotation" do
-    val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"])
-    val2 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"])
+  it 'considers the same host and same extra arguments to have the same random rotation' do
+    val1 = fqdn_rotate('abcdefg', :extra_identifier => [1, 'same', 'host'])
+    val2 = fqdn_rotate('abcdefg', :extra_identifier => [1, 'same', 'host'])
     expect(val1).to eq(val2)
   end
 
-  it "should rotate a string to give different values on different hosts" do
-    val1 = fqdn_rotate("abcdefg", :host => 'one')
-    val2 = fqdn_rotate("abcdefg", :host => 'two')
+  it 'rotates a string to give different values on different hosts' do
+    val1 = fqdn_rotate('abcdefg', :host => 'one')
+    val2 = fqdn_rotate('abcdefg', :host => 'two')
     expect(val1).not_to eq(val2)
   end
 
-  it "should accept objects which extend String" do
+  it 'accepts objects which extend String' do
     result = fqdn_rotate(AlsoString.new('asdf'))
     expect(result).to eq('dfas')
   end
 
-  it "should use the Puppet::Util.deterministic_rand function" do
-    if Puppet::Util.respond_to?(:deterministic_rand)
-      Puppet::Util.expects(:deterministic_rand).with(44489829212339698569024999901561968770,4)
-      fqdn_rotate("asdf")
-    else
-      skip 'Puppet::Util#deterministic_rand not available'
-    end
+  it 'uses the Puppet::Util.deterministic_rand function' do
+    skip 'Puppet::Util#deterministic_rand not available' unless Puppet::Util.respond_to?(:deterministic_rand)
+
+    expect(Puppet::Util).to receive(:deterministic_rand).with(44_489_829_212_339_698_569_024_999_901_561_968_770, 4)
+    fqdn_rotate('asdf')
   end
 
-  it "should not leave the global seed in a deterministic state" do
-    fqdn_rotate("asdf")
-    rand1 = rand()
-    fqdn_rotate("asdf")
-    rand2 = rand()
+  it 'does not leave the global seed in a deterministic state' do
+    fqdn_rotate('asdf')
+    rand1 = rand
+    fqdn_rotate('asdf')
+    rand2 = rand
     expect(rand1).not_to eql(rand2)
   end
 
@@ -68,7 +66,7 @@ describe 'fqdn_rotate' do
 
     # workaround not being able to use let(:facts) because some tests need
     # multiple different hostnames in one context
-    scope.stubs(:lookupvar).with("::fqdn").returns(host)
+    allow(scope).to receive(:lookupvar).with('::fqdn').and_return(host)
 
     function_args = [value] + extra
     scope.function_fqdn_rotate(function_args)
index d0c30d6..a6da6f2 100644 (file)
@@ -1,13 +1,12 @@
 require 'spec_helper'
 
 describe 'fqdn_uuid' do
-
-  context "Invalid parameters" do
-    it { should run.with_params().and_raise_error(ArgumentError, /No arguments given$/) }
+  context 'with invalid parameters' do
+    it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{No arguments given$}) }
   end
 
-  context "given string" do
-    it { should run.with_params('puppetlabs.com').and_return('9c70320f-6815-5fc5-ab0f-debe68bf764c') }
-    it { should run.with_params('google.com').and_return('64ee70a4-8cc1-5d25-abf2-dea6c79a09c8') }
+  context 'with given string' do
+    it { is_expected.to run.with_params('puppetlabs.com').and_return('9c70320f-6815-5fc5-ab0f-debe68bf764c') }
+    it { is_expected.to run.with_params('google.com').and_return('64ee70a4-8cc1-5d25-abf2-dea6c79a09c8') }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index a39e413..dd31c67
@@ -2,11 +2,12 @@ require 'spec_helper'
 
 describe 'get_module_path' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
-  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
-  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
-  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Could not find module}) }
 
+  # class Stubmodule
   class StubModule
     attr_reader :path
     def initialize(path)
@@ -15,33 +16,41 @@ describe 'get_module_path' do
   end
 
   describe 'when locating a module' do
-    let(:modulepath) { "/tmp/does_not_exist" }
-    let(:path_of_module_foo) { StubModule.new("/tmp/does_not_exist/foo") }
+    let(:modulepath) { '/tmp/does_not_exist' }
+    let(:path_of_module_foo) { StubModule.new('/tmp/does_not_exist/foo') }
 
-    before(:each) { Puppet[:modulepath] = modulepath }
-
-    context 'in the default environment' do
-      before(:each) { Puppet::Module.expects(:find).with('foo', 'rp_env').returns(path_of_module_foo) }
+    before(:each) do
+      Puppet[:modulepath] = modulepath
+    end
 
-      it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+    context 'when in the default environment' do
+      before(:each) do
+        allow(Puppet::Module).to receive(:find).with('foo', 'rp_env').and_return(path_of_module_foo)
+      end
+      it 'runs against foo' do
+        is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)
+      end
 
-      context 'when the modulepath is a list' do
-        before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' }
+      it 'when the modulepath is a list' do
+        Puppet[:modulepath] = modulepath + 'tmp/something_else'
 
-        it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+        is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)
       end
     end
 
-    context 'in a non-default default environment' do
+    context 'when in a non-default default environment' do
       let(:environment) { 'test' }
-      before(:each) { Puppet::Module.expects(:find).with('foo', 'test').returns(path_of_module_foo) }
 
-      it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
-
-      context 'when the modulepath is a list' do
-        before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' }
+      before(:each) do
+        allow(Puppet::Module).to receive(:find).with('foo', 'test').and_return(path_of_module_foo)
+      end
+      it 'runs against foo' do
+        is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)
+      end
 
-        it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+      it 'when the modulepath is a list' do
+        Puppet[:modulepath] = modulepath + 'tmp/something_else'
+        is_expected.to run.with_params('foo').and_return(path_of_module_foo.path)
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 522ed3b..3a3cc27
@@ -2,11 +2,11 @@ require 'spec_helper'
 
 describe 'getparam' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a reference/) }
-  it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, /Must specify name of a parameter/) }
-  it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
-  it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
-  it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a reference}) }
+  it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
+  it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
+  it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
+  it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
 
   describe 'when compared against a user resource with no params' do
     let(:pre_condition) { 'user { "one": }' }
@@ -30,6 +30,5 @@ describe 'getparam' do
 
     it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') }
     it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') }
-
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 55789d8..6c37baa
@@ -2,37 +2,44 @@ require 'spec_helper'
 
 describe 'getvar' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
 
-  it { is_expected.to run.with_params('$::foo').and_return(nil) }
+  describe 'before Puppet 6.0.0', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  end
+
+  describe 'from Puppet 6.0.0', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') >= 0 do
+    it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects between 1 and 2 arguments, got none}i) }
+    it { is_expected.to run.with_params('one', 'two').and_return('two') }
+    it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(ArgumentError, %r{expects between 1 and 2 arguments, got 3}i) }
+  end
 
-  context 'given variables in namespaces' do
-    let(:pre_condition) {
-      <<-'ENDofPUPPETcode'
+  it { is_expected.to run.with_params('::foo').and_return(nil) }
+
+  context 'with given variables in namespaces' do
+    let(:pre_condition) do
+      <<-PUPPETCODE
       class site::data { $foo = 'baz' }
       include site::data
-      ENDofPUPPETcode
-    }
+      PUPPETCODE
+    end
 
     it { is_expected.to run.with_params('site::data::foo').and_return('baz') }
     it { is_expected.to run.with_params('::site::data::foo').and_return('baz') }
     it { is_expected.to run.with_params('::site::data::bar').and_return(nil) }
   end
 
-  context 'given variables in namespaces' do
-    let(:pre_condition) {
-      <<-'ENDofPUPPETcode'
+  context 'with given variables in namespaces' do
+    let(:pre_condition) do
+      <<-PUPPETCODE
       class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' }
       class site::new { $item = '万Ü€‰' }
       include site::info
       include site::new
-      ENDofPUPPETcode
-    }
+      PUPPETCODE
+    end
 
     it { is_expected.to run.with_params('site::info::lock').and_return('ŧҺîš íš ắ śţřĭŋĝ') }
     it { is_expected.to run.with_params('::site::new::item').and_return('万Ü€‰') }
   end
 end
-
old mode 100755 (executable)
new mode 100644 (file)
index 06439da..209aca6
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'glob' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('').and_return([]) }
   it { is_expected.to run.with_params(['']).and_return([]) }
old mode 100755 (executable)
new mode 100644 (file)
index d2152b1..587e51b
@@ -2,17 +2,17 @@ require 'spec_helper'
 
 describe 'grep' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("grep does not actually check this, and raises NoMethodError instead")
-    is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+    pending('grep does not actually check this, and raises NoMethodError instead')
+    is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array})
   }
   it {
-    pending("grep does not actually check this, and raises NoMethodError instead")
-    is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+    pending('grep does not actually check this, and raises NoMethodError instead')
+    is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array})
   }
-  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params([], 'two').and_return([]) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['two']) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['two', 'three']) }
old mode 100755 (executable)
new mode 100644 (file)
index 7334d38..273ecb2
@@ -2,18 +2,19 @@ require 'spec_helper'
 
 describe 'has_interface_with' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   # We need to mock out the Facts so we can specify how we expect this function
   # to behave on different platforms.
-  context "On Mac OS X Systems" do
+  context 'when on Mac OS X Systems' do
     let(:facts) { { :interfaces => 'lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0' } }
+
     it { is_expected.to run.with_params('lo0').and_return(true) }
     it { is_expected.to run.with_params('lo').and_return(false) }
   end
 
-  context "On Linux Systems" do
+  context 'when on Linux Systems' do
     let(:facts) do
       {
         :interfaces => 'eth0,lo',
old mode 100755 (executable)
new mode 100644 (file)
index 42a5a79..33934f3
@@ -2,10 +2,10 @@ require 'spec_helper'
 
 describe 'has_ip_address' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
-  context "On Linux Systems" do
+  context 'when on Linux Systems' do
     let(:facts) do
       {
         :interfaces => 'eth0,lo',
old mode 100755 (executable)
new mode 100644 (file)
index 57cf613..cc6ff0b
@@ -2,10 +2,10 @@ require 'spec_helper'
 
 describe 'has_ip_network' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
-  context "On Linux Systems" do
+  context 'when on Linux Systems' do
     let(:facts) do
       {
         :interfaces => 'eth0,lo',
old mode 100755 (executable)
new mode 100644 (file)
index 0e0e1cc..6abebba
@@ -2,19 +2,19 @@ require 'spec_helper'
 
 describe 'has_key' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params("one").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) }
-  it { is_expected.to run.with_params(1, "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) }
-  it { is_expected.to run.with_params([], "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{expects the first argument to be a hash}) }
+  it { is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, %r{expects the first argument to be a hash}) }
+  it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, %r{expects the first argument to be a hash}) }
 
-  it { is_expected.to run.with_params({ 'key' => 'value' }, "key").and_return(true) }
-  it { is_expected.to run.with_params({}, "key").and_return(false) }
-  it { is_expected.to run.with_params({ 'key' => 'value'}, "not a key").and_return(false) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return(true) }
+  it { is_expected.to run.with_params({}, 'key').and_return(false) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, 'not a key').and_return(false) }
 
-  context 'should run with UTF8 and double byte characters' do
-    it { is_expected.to run.with_params({ 'κéỳ ' => '٧ậļųể' }, "κéỳ ").and_return(true) }
-    it { is_expected.to run.with_params({ 'キー' => '٧ậļųể' }, "キー").and_return(true) }
+  context 'with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params({ 'κéỳ ' => '٧ậļųể' }, 'κéỳ ').and_return(true) }
+    it { is_expected.to run.with_params({ 'キー' => '٧ậļųể' }, 'キー').and_return(true) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 092474b..2f78da4
@@ -2,14 +2,14 @@ require 'spec_helper'
 
 describe 'hash' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, /Unable to compute/) }
+  it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, %r{Unable to compute}) }
   it { is_expected.to run.with_params([]).and_return({}) }
-  it { is_expected.to run.with_params(['key1', 'value1']).and_return({ 'key1' => 'value1' }) }
-  it { is_expected.to run.with_params(['κ℮ұ1', '√āĺűẻ1']).and_return({ 'κ℮ұ1' => '√āĺűẻ1' }) }
-  it { is_expected.to run.with_params(['key1', 'value1', 'key2', 'value2']).and_return({ 'key1' => 'value1', 'key2' => 'value2' }) }
+  it { is_expected.to run.with_params(['key1', 'value1']).and_return('key1' => 'value1') }
+  it { is_expected.to run.with_params(['κ℮ұ1', '√āĺűẻ1']).and_return('κ℮ұ1' => '√āĺűẻ1') }
+  it { is_expected.to run.with_params(['key1', 'value1', 'key2', 'value2']).and_return('key1' => 'value1', 'key2' => 'value2') }
 end
old mode 100755 (executable)
new mode 100644 (file)
index ec368a5..0ea871f
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'intersection' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
   it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
@@ -18,5 +18,5 @@ describe 'intersection' do
   it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['two', 'three']) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['two', 'three']) }
-  it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return([]) end
+  it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return([]) end
 end
index 2d6cb46..a5fe590 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper'
 
-if ENV["FUTURE_PARSER"] == 'yes'
+if ENV['FUTURE_PARSER'] == 'yes'
   describe 'type_of' do
     pending 'teach rspec-puppet to load future-only functions under 3.7.5' do
       it { is_expected.not_to eq(nil) }
@@ -11,7 +11,7 @@ end
 if Puppet.version.to_f >= 4.0
   describe 'is_a' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
     it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) }
 
     it 'succeeds when comparing a string and a string' do
@@ -23,8 +23,10 @@ if Puppet.version.to_f >= 4.0
     end
 
     it 'suceeds when comparing an UTF8 and double byte characters' do
-      is_expected.to run.with_params('このテキスト', String).and_return(true)
-      is_expected.to run.with_params('ŧћịś ŧêχŧ', String).and_return(true)
+      comparison_array = ['このテキスト', 'ŧћịś ŧêχŧ']
+      comparison_array.each do |comparison_value|
+        is_expected.to run.with_params(comparison_value, String).and_return(true)
+      end
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index e89f54b..a24c2c7
@@ -1,12 +1,11 @@
 require 'spec_helper'
 
 describe 'is_array' do
-  
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
   it { is_expected.to run.with_params([]).and_return(true) }
   it { is_expected.to run.with_params(['one']).and_return(true) }
@@ -17,19 +16,19 @@ describe 'is_array' do
   it { is_expected.to run.with_params('one').and_return(false) }
   it { is_expected.to run.with_params(1).and_return(false) }
   it { is_expected.to run.with_params({}).and_return(false) }
-  context 'Checking for deprecation warning' do
-    after(:all) do
+  context 'with deprecation warning' do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
-    end 
+    end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params(['1.2.3.4']).and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params(['1.2.3.4']).and_return(true)
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index d21345c..2a8112e
@@ -1,10 +1,9 @@
 require 'spec_helper'
 
 describe 'is_bool' do
-  
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(true, false).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(true, false).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params(true).and_return(true) }
   it { is_expected.to run.with_params(false).and_return(true) }
   it { is_expected.to run.with_params([1]).and_return(false) }
@@ -13,21 +12,20 @@ describe 'is_bool' do
   it { is_expected.to run.with_params([true]).and_return(false) }
   it { is_expected.to run.with_params('true').and_return(false) }
   it { is_expected.to run.with_params('false').and_return(false) }
-  context 'Checking for deprecation warning' do
-    after(:all) do
+  context 'with deprecation warning' do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
-    end 
+    end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params(true).and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params(false).and_return(true)
     end
-  end 
+  end
 end
-
old mode 100755 (executable)
new mode 100644 (file)
index c1bf0e3..c2d5988
@@ -2,8 +2,8 @@ require 'spec_helper'
 
 describe 'is_domain_name' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params(1).and_return(false) }
   it { is_expected.to run.with_params([]).and_return(false) }
   it { is_expected.to run.with_params({}).and_return(false) }
@@ -28,7 +28,7 @@ describe 'is_domain_name' do
     it { is_expected.to run.with_params('www.foo-bar.example.com').and_return(true) }
     it { is_expected.to run.with_params('www.foo-bar.example.com.').and_return(true) }
     it { is_expected.to run.with_params('-foo.example.com').and_return(false) }
-    it { is_expected.to run.with_params('-foo.example.com').and_return(false) }
+    it { is_expected.to run.with_params('-foo.example.com.').and_return(false) }
   end
   # Values obtained from Facter values will be frozen strings
   # in newer versions of Facter:
old mode 100755 (executable)
new mode 100644 (file)
index 8b7b358..6c291e6
@@ -2,8 +2,8 @@ require 'spec_helper'
 
 describe 'is_email_address' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params('bob@gmail.com').and_return(true) }
   it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com').and_return(true) }
   it { is_expected.to run.with_params('peter.parker@gmail.com').and_return(true) }
old mode 100755 (executable)
new mode 100644 (file)
index af3322e..effb1da
@@ -1,11 +1,10 @@
 require 'spec_helper'
 
 describe 'is_float' do
-
   it { is_expected.not_to eq(nil) }
 
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   describe 'passing a string' do
     it { is_expected.to run.with_params('0.1').and_return(true) }
@@ -22,21 +21,20 @@ describe 'is_float' do
     it { is_expected.to run.with_params(1).and_return(false) }
   end
 
-  context 'Checking for deprecation warning' do
-    after(:all) do
+  context 'with deprecation warning' do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params(2.2).and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params(1.0).and_return(true)
     end
   end
-
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/is_function_available.rb b/3rdparty/modules/stdlib/spec/functions/is_function_available.rb
deleted file mode 100755 (executable)
index 44f08c0..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'spec_helper'
-
-describe 'is_function_available' do
-  it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('include').and_return(true) }
-  it { is_expected.to run.with_params('no_such_function').and_return(false) }
-end
old mode 100755 (executable)
new mode 100644 (file)
index c2599a0..3ef061d
@@ -2,8 +2,8 @@ require 'spec_helper'
 
 describe 'is_hash' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params('').and_return(false) }
   it { is_expected.to run.with_params({}).and_return(true) }
   it { is_expected.to run.with_params([]).and_return(false) }
old mode 100755 (executable)
new mode 100644 (file)
index 8118ef4..7e93005
@@ -1,11 +1,10 @@
 require 'spec_helper'
 
 describe 'is_integer' do
-  
   it { is_expected.not_to eq(nil) }
 
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   it { is_expected.to run.with_params(3).and_return(true) }
   it { is_expected.to run.with_params('3').and_return(true) }
@@ -17,7 +16,7 @@ describe 'is_integer' do
   it { is_expected.to run.with_params(3.7).and_return(false) }
   it { is_expected.to run.with_params('3.7').and_return(false) }
   it { is_expected.to run.with_params(-3.7).and_return(false) }
-  it { is_expected.to run.with_params('3.7').and_return(false) }
+  it { is_expected.to run.with_params('-3.7').and_return(false) }
 
   it { is_expected.to run.with_params('one').and_return(false) }
   it { is_expected.to run.with_params([]).and_return(false) }
@@ -28,21 +27,20 @@ describe 'is_integer' do
   it { is_expected.to run.with_params('0001234').and_return(false) }
   it { is_expected.to run.with_params("foo\nbar").and_return(false) }
 
-  context 'Checking for deprecation warning' do
-    after(:all) do
+  context 'with deprecation warning' do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params(50).and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params(50).and_return(true)
     end
-  end 
-
+  end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 39525d7..daa09db
@@ -2,8 +2,8 @@ require 'spec_helper'
 
 describe 'is_ip_address' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params('1.2.3.4').and_return(true) }
   it { is_expected.to run.with_params('1.2.3.255').and_return(true) }
   it { is_expected.to run.with_params('1.2.3.256').and_return(false) }
@@ -21,19 +21,19 @@ describe 'is_ip_address' do
   it { is_expected.to run.with_params({}).and_return(false) }
   it { is_expected.to run.with_params([]).and_return(false) }
 
-  context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+  context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params('1.2.3.4').and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params('1.2.3.4').and_return(true)
     end
-    after(:all) do 
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
   end
index 985260c..fddd351 100644 (file)
@@ -1,9 +1,8 @@
 require 'spec_helper'
 
 describe 'is_ipv4_address' do
-
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   SharedData::IPV4_PATTERNS.each do |value|
     it { is_expected.to run.with_params(value).and_return(true) }
@@ -13,19 +12,19 @@ describe 'is_ipv4_address' do
     it { is_expected.to run.with_params(value).and_return(false) }
   end
 
-  context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
-    after(:all) do
+  context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first).and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first).and_return(true)
     end
   end
index acd6a87..0aca0e3 100644 (file)
@@ -1,9 +1,8 @@
 require 'spec_helper'
 
 describe 'is_ipv6_address' do
-  
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true) }
   it { is_expected.to run.with_params('85a3:0000:0000:8a2e:0370:7334:100.100.100.100').and_return(true) }
   it { is_expected.to run.with_params('1.2.3').and_return(false) }
@@ -11,19 +10,19 @@ describe 'is_ipv6_address' do
   it { is_expected.to run.with_params('').and_return(false) }
   it { is_expected.to run.with_params('one').and_return(false) }
 
-  context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
-    after(:all) do
+  context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true)
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index c1e33b8..2f6602b
@@ -2,29 +2,30 @@ require 'spec_helper'
 
 describe 'is_mac_address' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params('00:a0:1f:12:7f:a0').and_return(true) }
   it { is_expected.to run.with_params('00:A0:1F:12:7F:A0').and_return(true) }
+  it { is_expected.to run.with_params('80:00:02:09:fe:80:00:00:00:00:00:00:00:24:65:ff:ff:91:a3:12').and_return(true) }
   it { is_expected.to run.with_params('00:00:00:00:00:0g').and_return(false) }
   it { is_expected.to run.with_params('').and_return(false) }
   it { is_expected.to run.with_params('one').and_return(false) }
 
-  context 'function can handle UTF8 and double byte characters' do
+  context 'with  UTF8 and double byte characters' do
     it { is_expected.to run.with_params('ƒốưř').and_return(false) }
     it { is_expected.to run.with_params('三+').and_return(false) }
   end
 
   it {
-    pending "should properly typecheck its arguments"
+    pending 'should properly typecheck its arguments'
     is_expected.to run.with_params(1).and_return(false)
   }
   it {
-    pending "should properly typecheck its arguments"
+    pending 'should properly typecheck its arguments'
     is_expected.to run.with_params({}).and_return(false)
   }
   it {
-    pending "should properly typecheck its arguments"
+    pending 'should properly typecheck its arguments'
     is_expected.to run.with_params([]).and_return(false)
   }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 5962d8a..f9c5180
@@ -1,21 +1,20 @@
 require 'spec_helper'
 
 describe 'is_numeric' do
-  
   it { is_expected.not_to eq(nil) }
 
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   it { is_expected.to run.with_params(3).and_return(true) }
   it { is_expected.to run.with_params('3').and_return(true) }
   it { is_expected.to run.with_params(-3).and_return(true) }
   it { is_expected.to run.with_params('-3').and_return(true) }
-  
+
   it { is_expected.to run.with_params(3.7).and_return(true) }
   it { is_expected.to run.with_params('3.7').and_return(true) }
   it { is_expected.to run.with_params(-3.7).and_return(true) }
-  it { is_expected.to run.with_params('3.7').and_return(true) }
+  it { is_expected.to run.with_params('-3.7').and_return(true) }
 
   it { is_expected.to run.with_params('-342.2315e-12').and_return(true) }
 
@@ -28,21 +27,20 @@ describe 'is_numeric' do
   it { is_expected.to run.with_params('0001234').and_return(false) }
   it { is_expected.to run.with_params(' - 1234').and_return(false) }
 
-  context 'Checking for deprecation warning' do
-    after(:all) do
+  context 'with deprecation warning' do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params(7).and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params(7).and_return(true)
     end
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index e92f85c..f3a7823
@@ -1,12 +1,11 @@
 require 'spec_helper'
 
 describe 'is_string' do
-
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
 
   it { is_expected.to run.with_params(3).and_return(false) }
@@ -17,7 +16,7 @@ describe 'is_string' do
   it { is_expected.to run.with_params(3.7).and_return(false) }
   it { is_expected.to run.with_params('3.7').and_return(false) }
   it { is_expected.to run.with_params(-3.7).and_return(false) }
-  it { is_expected.to run.with_params('3.7').and_return(false) }
+  it { is_expected.to run.with_params('-3.7').and_return(false) }
 
   it { is_expected.to run.with_params([]).and_return(false) }
   it { is_expected.to run.with_params([1]).and_return(false) }
@@ -27,21 +26,20 @@ describe 'is_string' do
   it { is_expected.to run.with_params('one').and_return(true) }
   it { is_expected.to run.with_params('0001234').and_return(true) }
 
-  context 'Checking for deprecation warning' do
-    after(:all) do
+  context 'with  deprecation warning' do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params('sponge').and_return(true)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params('bob').and_return(true)
     end
-  end 
-
+  end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 0a2a50c..97674ef
@@ -2,29 +2,33 @@ require 'spec_helper'
 
 describe 'join_keys_to_values' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Takes exactly two arguments/) }
-  it { is_expected.to run.with_params({}, '', '').and_raise_error(Puppet::ParseError, /Takes exactly two arguments/) }
-  it { is_expected.to run.with_params('one', '').and_raise_error(TypeError, /The first argument must be a hash/) }
-  it { is_expected.to run.with_params({}, 2).and_raise_error(TypeError, /The second argument must be a string/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Takes exactly two arguments}) }
+  it { is_expected.to run.with_params({}, '', '').and_raise_error(Puppet::ParseError, %r{Takes exactly two arguments}) }
+  it { is_expected.to run.with_params('one', '').and_raise_error(TypeError, %r{The first argument must be a hash}) }
+  it { is_expected.to run.with_params({}, 2).and_raise_error(TypeError, %r{The second argument must be a string}) }
 
   it { is_expected.to run.with_params({}, '').and_return([]) }
   it { is_expected.to run.with_params({}, ':').and_return([]) }
   it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return(['keyvalue']) }
   it { is_expected.to run.with_params({ 'key' => 'value' }, ':').and_return(['key:value']) }
 
-  context 'should run with UTF8 and double byte characters' do 
+  context 'with UTF8 and double byte characters' do
     it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, ':').and_return(['ҝẽγ:√ạĺűē']) }
-    it  { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, '万').and_return(['ҝẽγ万√ạĺűē']) }
+    it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, '万').and_return(['ҝẽγ万√ạĺűē']) }
   end
 
-  it { is_expected.to run.with_params({ 'key' => nil }, ':').and_return(['key:']) }
-  it 'should run join_keys_to_values(<hash with multiple keys>, ":") and return the proper array' do
-    result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }, ':'])
-    expect(result.sort).to eq(['key1:value1', 'key2:value2'].sort)
+  if Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') == 0
+    it { is_expected.to run.with_params({ 'key' => '' }, ':').and_return(['key:']) }
+  else
+    it { is_expected.to run.with_params({ 'key' => nil }, ':').and_return(['key:']) }
   end
-  it 'should run join_keys_to_values(<hash with array value>, " ") and return the proper array' do
-    result = subject.call([{ 'key1' => 'value1', 'key2' => ['value2', 'value3'] }, ' '])
-    expect(result.sort).to eq(['key1 value1', 'key2 value2', 'key2 value3'].sort)
+
+  it 'runs join_keys_to_values(<hash with multiple keys>, ":") and return the proper array' do
+    is_expected.to run.with_params({ 'key1' => 'value1', 'key2' => 'value2' }, ':').and_return(['key1:value1', 'key2:value2'])
   end
-end
 
+  it 'runs join_keys_to_values(<hash with array value>, " ") and return the proper array' do
+    expected_result = ['key1 value1', 'key2 value2', 'key2 value3']
+    is_expected.to run.with_params({ 'key1' => 'value1', 'key2' => ['value2', 'value3'] }, ' ').and_return(expected_result)
+  end
+end
old mode 100755 (executable)
new mode 100644 (file)
index 98852d5..264ebc9
@@ -1,14 +1,14 @@
 require 'spec_helper'
 
-describe 'join' do
+describe 'join', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the second.")
-    is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the second.')
+    is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Requires array to work with/) }
-  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /Requires string to work with/) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array to work with}) }
+  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{Requires string to work with}) }
 
   it { is_expected.to run.with_params([]).and_return('') }
   it { is_expected.to run.with_params([], ':').and_return('') }
old mode 100755 (executable)
new mode 100644 (file)
index fc7d6d8..2b538a0
@@ -1,23 +1,23 @@
 require 'spec_helper'
 
-describe 'keys' do
+describe 'keys', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
-  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
   it { is_expected.to run.with_params({}).and_return([]) }
-  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key']) }
-  it 'should return the array of keys' do
+  it { is_expected.to run.with_params('key' => 'value').and_return(['key']) }
+  it 'returns the array of keys' do
     result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }])
     expect(result).to match_array(['key1', 'key2'])
   end
 
-  it 'should run with UTF8 and double byte characters' do
+  it 'runs with UTF8 and double byte characters' do
     result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }])
     expect(result).to match_array(['ҝểү', 'キー'])
   end
diff --git a/3rdparty/modules/stdlib/spec/functions/length.rb b/3rdparty/modules/stdlib/spec/functions/length.rb
deleted file mode 100755 (executable)
index d1ab003..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'spec_helper'
-
-describe 'length' do
-  it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /'length' expects 1 argument, got none/) }
-  it { is_expected.to run.with_params([], 'extra').and_raise_error(ArgumentError, /'length' expects 1 argument, got 2/) }
-  it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Integer/) }
-  it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Boolean/) }
-  it { is_expected.to run.with_params('1').and_return(1) }
-  it { is_expected.to run.with_params('1.0').and_return(3) }
-  it { is_expected.to run.with_params([]).and_return(0) }
-  it { is_expected.to run.with_params(['a']).and_return(1) }
-  it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) }
-  it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) }
-
-  it { is_expected.to run.with_params({}).and_return(0) }
-  it { is_expected.to run.with_params({'1' => '2'}).and_return(1) }
-  it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) }
-  it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) }
-
-  it { is_expected.to run.with_params('').and_return(0) }
-  it { is_expected.to run.with_params('a').and_return(1) }
-  it { is_expected.to run.with_params('abc').and_return(3) }
-  it { is_expected.to run.with_params('abcd').and_return(4) }
-  it { is_expected.to run.with_params('万').and_return(1) }
-  it { is_expected.to run.with_params('āβćđ').and_return(4) }
-
-  context 'when using a class extending String' do
-    it 'should call its size method' do
-      value = AlsoString.new('asdfghjkl')
-      value.expects(:length).returns('foo')
-      expect(subject).to run.with_params(value).and_return('foo')
-    end
-  end
-end
old mode 100755 (executable)
new mode 100644 (file)
index 9496fcb..c5ea78a
@@ -2,60 +2,46 @@ require 'spec_helper'
 
 describe 'load_module_metadata' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
-  describe "when calling with valid arguments" do
+  describe 'when calling with valid arguments' do
     before :each do
-      allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}')
-      allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}')
+      allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"name": "puppetlabs-stdlib"}')
+      allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"name": "puppetlabs-stdlib"}')
     end
 
-    context "when calling with valid utf8 and double byte character arguments" do
+    context 'when calling with valid utf8 and double byte character arguments' do
       before :each do
-        allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš -
+        allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš -
 この文字"}')
-        allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš -
+        allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš -
 この文字"}')
       end
 
-    it "should json parse the file" do
-      if Puppet::Util::Platform.windows?
-        allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/')
-        allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(true)
-        allow(File).to receive(:read).with('C:/path/to/module/metadata.json').and_return('{"name": "spencer-science"}')
-      else
-        allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
-        allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true)
-        allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}')
-      end
+      let(:prefix) { 'C:' if Puppet::Util::Platform.windows? }
 
-      result = subject.call(['science'])
-      expect(result['name']).to eq('spencer-science')
-    end
+      it 'jsons parse the file' do
+        allow(scope).to receive(:function_get_module_path).with(['science']).and_return("#{prefix}/path/to/module/")
+        allow(File).to receive(:exists?).with("#{prefix}/path/to/module/metadata.json").and_return(true)
+        allow(File).to receive(:read).with("#{prefix}/path/to/module/metadata.json").and_return('{"name": "spencer-science"}')
 
-    it "should fail by default if there is no metadata.json" do
-      if Puppet::Util::Platform.windows?
-        allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/')
-        allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false)
-      else
-        allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
-        allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false)
+        result = subject.execute('science')
+        expect(result['name']).to eq('spencer-science')
       end
-      expect {subject.call(['science'])}.to raise_error(Puppet::ParseError)
-    end
 
-    it "should return nil if user allows empty metadata.json" do
-      if Puppet::Util::Platform.windows?
-        allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/')
-        allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false)
-      else
-        allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
-        allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false)
+      it 'fails by default if there is no metadata.json' do
+        allow(scope).to receive(:function_get_module_path).with(['science']).and_return("#{prefix}/path/to/module/")
+        allow(File).to receive(:exists?).with("#{prefix}/path/to/module/metadata.json").and_return(false)
+        expect { subject.call(['science']) }.to raise_error(Puppet::ParseError)
+      end
+
+      it 'returns nil if user allows empty metadata.json' do
+        allow(scope).to receive(:function_get_module_path).with(['science']).and_return("#{prefix}/path/to/module/")
+        allow(File).to receive(:exists?).with("#{prefix}/path/to/module/metadata.json").and_return(false)
+        result = subject.execute('science', true)
+        expect(result).to eq({})
       end
-      result = subject.call(['science', true])
-      expect(result).to eq({})
-    end
     end
   end
 end
index dbef805..e6e60f4 100644 (file)
@@ -2,65 +2,141 @@ require 'spec_helper'
 
 describe 'loadjson' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
 
-  describe "when calling with valid arguments" do
+  describe 'when calling with valid arguments' do
     before :each do
-      allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}')
-      allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}')
+      allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"name": "puppetlabs-stdlib"}')
+      allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"name": "puppetlabs-stdlib"}')
     end
 
     context 'when a non-existing file is specified' do
-      let(:filename) {
+      let(:filename) do
         if Puppet::Util::Platform.windows?
           'C:/tmp/doesnotexist'
         else
           '/tmp/doesnotexist'
         end
-      }
-      before {
+      end
+
+      before(:each) do
         allow(File).to receive(:exists?).with(filename).and_return(false).once
         allow(PSON).to receive(:load).never
-      }
-      it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
-      it { is_expected.to run.with_params(filename, {'đẽƒằưļŧ' => '٧ẵłựέ'}).and_return({'đẽƒằưļŧ' => '٧ẵłựέ'}) }
-      it { is_expected.to run.with_params(filename, {'デフォルト' => '値'}).and_return({'デフォルト' => '値'}) }
+      end
+      it { is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') }
+      it { is_expected.to run.with_params(filename, 'đẽƒằưļŧ' => '٧ẵłựέ').and_return('đẽƒằưļŧ' => '٧ẵłựέ') }
+      it { is_expected.to run.with_params(filename, 'デフォルト' => '値').and_return('デフォルト' => '値') }
     end
 
     context 'when an existing file is specified' do
-      let(:filename) {
+      let(:filename) do
         if Puppet::Util::Platform.windows?
           'C:/tmp/doesexist'
         else
           '/tmp/doesexist'
         end
-      }
-      let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} }
+      end
+      let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
       let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
-      before {
+
+      before(:each) do
         allow(File).to receive(:exists?).with(filename).and_return(true).once
         allow(File).to receive(:read).with(filename).and_return(json).once
         allow(File).to receive(:read).with(filename).and_return(json).once
         allow(PSON).to receive(:load).with(json).and_return(data).once
-      }
+      end
       it { is_expected.to run.with_params(filename).and_return(data) }
     end
 
     context 'when the file could not be parsed' do
-      let(:filename) {
+      let(:filename) do
         if Puppet::Util::Platform.windows?
           'C:/tmp/doesexist'
         else
           '/tmp/doesexist'
         end
-      }
+      end
       let(:json) { '{"key":"value"}' }
-      before {
+
+      before(:each) do
         allow(File).to receive(:exists?).with(filename).and_return(true).once
         allow(File).to receive(:read).with(filename).and_return(json).once
         allow(PSON).to receive(:load).with(json).once.and_raise StandardError, 'Something terrible have happened!'
+      end
+      it { is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') }
+    end
+
+    context 'when an existing URL is specified' do
+      let(:filename) do
+        'https://example.local/myhash.json'
+      end
+      let(:basic_auth) { { :http_basic_authentication => ['', ''] } }
+      let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
+      let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
+
+      it {
+        expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(json)
+        expect(PSON).to receive(:load).with(json).and_return(data).once
+        is_expected.to run.with_params(filename).and_return(data)
+      }
+    end
+
+    context 'when an existing URL (with username and password) is specified' do
+      let(:filename) do
+        'https://user1:pass1@example.local/myhash.json'
+      end
+      let(:url_no_auth) { 'https://example.local/myhash.json' }
+      let(:basic_auth) { { :http_basic_authentication => ['user1', 'pass1'] } }
+      let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
+      let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
+
+      it {
+        expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json)
+        expect(PSON).to receive(:load).with(json).and_return(data).once
+        is_expected.to run.with_params(filename).and_return(data)
+      }
+    end
+
+    context 'when an existing URL (with username) is specified' do
+      let(:filename) do
+        'https://user1@example.local/myhash.json'
+      end
+      let(:url_no_auth) { 'https://example.local/myhash.json' }
+      let(:basic_auth) { { :http_basic_authentication => ['user1', ''] } }
+      let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
+      let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
+
+      it {
+        expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json)
+        expect(PSON).to receive(:load).with(json).and_return(data).once
+        is_expected.to run.with_params(filename).and_return(data)
+      }
+    end
+
+    context 'when the URL output could not be parsed, with default specified' do
+      let(:filename) do
+        'https://example.local/myhash.json'
+      end
+      let(:basic_auth) { { :http_basic_authentication => ['', ''] } }
+      let(:json) { ',;{"key":"value"}' }
+
+      it {
+        expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(json)
+        expect(PSON).to receive(:load).with(json).once.and_raise StandardError, 'Something terrible have happened!'
+        is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value')
+      }
+    end
+
+    context 'when the URL does not exist, with default specified' do
+      let(:filename) do
+        'https://example.local/myhash.json'
+      end
+      let(:basic_auth) { { :http_basic_authentication => ['', ''] } }
+
+      it {
+        expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_raise OpenURI::HTTPError, '404 File not Found'
+        is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value')
       }
-      it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index e9428e3..d71fd32
@@ -2,35 +2,100 @@ require 'spec_helper'
 
 describe 'loadyaml' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
 
   context 'when a non-existing file is specified' do
     let(:filename) { '/tmp/doesnotexist' }
-    before {
-      File.expects(:exists?).with(filename).returns(false).once
-      YAML.expects(:load_file).never
-    }
-    it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
-    it { is_expected.to run.with_params(filename, {'đẽƒằưļŧ' => '٧ẵłựέ'}).and_return({'đẽƒằưļŧ' => '٧ẵłựέ'}) }
-    it { is_expected.to run.with_params(filename, {'デフォルト' => '値'}).and_return({'デフォルト' => '値'}) }
+
+    it "'default' => 'value'" do
+      expect(File).to receive(:exists?).with(filename).and_return(false).once
+      expect(YAML).to receive(:load_file).never
+      is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value')
+    end
   end
 
   context 'when an existing file is specified' do
     let(:filename) { '/tmp/doesexist' }
-    let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} }
-    before {
-      File.expects(:exists?).with(filename).returns(true).once
-      YAML.expects(:load_file).with(filename).returns(data).once
-    }
-    it { is_expected.to run.with_params(filename).and_return(data) }
+    let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
+
+    it "returns 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'" do
+      expect(File).to receive(:exists?).with(filename).and_return(true).once
+      expect(YAML).to receive(:load_file).with(filename).and_return(data).once
+      is_expected.to run.with_params(filename).and_return(data)
+    end
   end
 
   context 'when the file could not be parsed' do
     let(:filename) { '/tmp/doesexist' }
-    before {
-      File.expects(:exists?).with(filename).returns(true).once
-      YAML.stubs(:load_file).with(filename).once.raises StandardError, 'Something terrible have happened!'
+
+    it 'filename /tmp/doesexist' do
+      expect(File).to receive(:exists?).with(filename).and_return(true).once
+      allow(YAML).to receive(:load_file).with(filename).once.and_raise(StandardError, 'Something terrible have happened!')
+      is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value')
+    end
+  end
+
+  context 'when an existing URL is specified' do
+    let(:filename) { 'https://example.local/myhash.yaml' }
+    let(:basic_auth) { { :http_basic_authentication => ['', ''] } }
+    let(:yaml) { 'Dummy YAML' }
+    let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
+
+    it {
+      expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(yaml)
+      expect(YAML).to receive(:safe_load).with(yaml).and_return(data).once
+      is_expected.to run.with_params(filename).and_return(data)
+    }
+  end
+
+  context 'when an existing URL (with username and password) is specified' do
+    let(:filename) { 'https://user1:pass1@example.local/myhash.yaml' }
+    let(:url_no_auth) { 'https://example.local/myhash.yaml' }
+    let(:basic_auth) { { :http_basic_authentication => ['user1', 'pass1'] } }
+    let(:yaml) { 'Dummy YAML' }
+    let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
+
+    it {
+      expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(yaml)
+      expect(YAML).to receive(:safe_load).with(yaml).and_return(data).once
+      is_expected.to run.with_params(filename).and_return(data)
+    }
+  end
+
+  context 'when an existing URL (with username) is specified' do
+    let(:filename) { 'https://user1@example.local/myhash.yaml' }
+    let(:url_no_auth) { 'https://example.local/myhash.yaml' }
+    let(:basic_auth) { { :http_basic_authentication => ['user1', ''] } }
+    let(:yaml) { 'Dummy YAML' }
+    let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } }
+
+    it {
+      expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(yaml)
+      expect(YAML).to receive(:safe_load).with(yaml).and_return(data).once
+      is_expected.to run.with_params(filename).and_return(data)
+    }
+  end
+
+  context 'when an existing URL could not be parsed, with default specified' do
+    let(:filename) { 'https://example.local/myhash.yaml' }
+    let(:basic_auth) { { :http_basic_authentication => ['', ''] } }
+    let(:yaml) { 'Dummy YAML' }
+
+    it {
+      expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(yaml)
+      expect(YAML).to receive(:safe_load).with(yaml).and_raise StandardError, 'Cannot parse data'
+      is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value')
+    }
+  end
+
+  context 'when a URL does not exist, with default specified' do
+    let(:filename) { 'https://example.local/myhash.yaml' }
+    let(:basic_auth) { { :http_basic_authentication => ['', ''] } }
+    let(:yaml) { 'Dummy YAML' }
+
+    it {
+      expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_raise OpenURI::HTTPError, '404 File not Found'
+      is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value')
     }
-    it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index a5a09ed..ab2f6f0
@@ -1,14 +1,14 @@
 require 'spec_helper'
 
-describe 'lstrip' do
+describe 'lstrip', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
   it { is_expected.to run.with_params('').and_return('') }
   it { is_expected.to run.with_params(' ').and_return('') }
   it { is_expected.to run.with_params('     ').and_return('') }
old mode 100755 (executable)
new mode 100644 (file)
index 66fb0c8..88879d1
@@ -1,8 +1,8 @@
 require 'spec_helper'
 
-describe 'max' do
+describe 'max', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params(1).and_return(1) }
   it { is_expected.to run.with_params(1, 2).and_return(2) }
   it { is_expected.to run.with_params(1, 2, 3).and_return(3) }
old mode 100755 (executable)
new mode 100644 (file)
index 8988632..f548bb5
@@ -2,11 +2,11 @@ require 'spec_helper'
 
 describe 'member' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
   it { is_expected.to run.with_params([], '').and_return(false) }
   it { is_expected.to run.with_params([], ['']).and_return(false) }
old mode 100755 (executable)
new mode 100644 (file)
index 3b2e3ef..25e2658
@@ -2,9 +2,9 @@ require 'spec_helper'
 
 describe 'merge' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params({}, 'two').and_raise_error(Puppet::ParseError, /unexpected argument type String/) }
-  it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /unexpected argument type (Fixnum|Integer)/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params({}, 'two').and_raise_error(Puppet::ParseError, %r{unexpected argument type String}) }
+  it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{unexpected argument type (Fixnum|Integer)}) }
   it {
     pending 'should not special case this'
     is_expected.to run.with_params({}).and_return({})
@@ -14,12 +14,12 @@ describe 'merge' do
   describe 'should accept empty strings as puppet undef' do
     it { is_expected.to run.with_params({}, '').and_return({}) }
   end
-  it { is_expected.to run.with_params({ 'key' => 'value' }, {}).and_return({ 'key' => 'value' }) }
-  it { is_expected.to run.with_params({}, { 'key' => 'value' }).and_return({ 'key' => 'value' }) }
-  it { is_expected.to run.with_params({ 'key' => 'value1' }, { 'key' => 'value2' }).and_return({ 'key' => 'value2' }) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, {}).and_return('key' => 'value') }
+  it { is_expected.to run.with_params({}, 'key' => 'value').and_return('key' => 'value') }
+  it { is_expected.to run.with_params({ 'key' => 'value1' }, 'key' => 'value2').and_return('key' => 'value2') }
   it {
     is_expected.to run \
-      .with_params({ 'key1' => 'value1' }, { 'key2' => 'value2' }, { 'key3' => 'value3' }) \
-      .and_return({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' })
+      .with_params({ 'key1' => 'value1' }, { 'key2' => 'value2' }, 'key3' => 'value3') \
+      .and_return('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3')
   }
 end
old mode 100755 (executable)
new mode 100644 (file)
index c840a72..9e350d9
@@ -1,12 +1,13 @@
 require 'spec_helper'
 
-describe 'min' do
+describe 'min', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params(1).and_return(1) }
   it { is_expected.to run.with_params(1, 2).and_return(1) }
   it { is_expected.to run.with_params(1, 2, 3).and_return(1) }
   it { is_expected.to run.with_params(3, 2, 1).and_return(1) }
+  it { is_expected.to run.with_params(12, 8).and_return(8) }
   it { is_expected.to run.with_params('one').and_return('one') }
   it { is_expected.to run.with_params('one', 'two').and_return('one') }
   it { is_expected.to run.with_params('one', 'two', 'three').and_return('one') }
old mode 100755 (executable)
new mode 100644 (file)
index 494afff..60533e3
@@ -2,9 +2,9 @@ require 'spec_helper'
 
 describe 'num2bool' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('abc').and_raise_error(Puppet::ParseError, /does not look like a number/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('abc').and_raise_error(Puppet::ParseError, %r{does not look like a number}) }
   it { is_expected.to run.with_params(1).and_return(true) }
   it { is_expected.to run.with_params('1').and_return(true) }
   it { is_expected.to run.with_params(1.5).and_return(true) }
@@ -16,7 +16,7 @@ describe 'num2bool' do
   it { is_expected.to run.with_params(0).and_return(false) }
   it { is_expected.to run.with_params('0').and_return(false) }
   it { is_expected.to run.with_params([]).and_return(false) }
-  it { is_expected.to run.with_params('[]').and_raise_error(Puppet::ParseError, /does not look like a number/) }
+  it { is_expected.to run.with_params('[]').and_raise_error(Puppet::ParseError, %r{does not look like a number}) }
   it { is_expected.to run.with_params({}).and_return(false) }
-  it { is_expected.to run.with_params('{}').and_raise_error(Puppet::ParseError, /does not look like a number/) }
+  it { is_expected.to run.with_params('{}').and_raise_error(Puppet::ParseError, %r{does not look like a number}) }
 end
old mode 100755 (executable)
new mode 100644 (file)
index 7b07e49..d038584
@@ -1,69 +1,66 @@
 require 'spec_helper'
 
 describe 'parsejson' do
-  it 'should exist' do
+  it 'exists' do
     is_expected.not_to eq(nil)
   end
 
-  it 'should raise an error if called without any arguments' do
-    is_expected.to run.with_params().
-                       and_raise_error(/wrong number of arguments/i)
+  it 'raises an error if called without any arguments' do
+    is_expected.to run.with_params
+                      .and_raise_error(%r{wrong number of arguments}i)
   end
 
   context 'with correct JSON data' do
-
-    it 'should be able to parse JSON data with a Hash' do
-      is_expected.to run.with_params('{"a":"1","b":"2"}').
-                         and_return({'a'=>'1', 'b'=>'2'})
+    it 'is able to parse JSON data with a Hash' do
+      is_expected.to run.with_params('{"a":"1","b":"2"}')
+                        .and_return('a' => '1', 'b' => '2')
     end
 
-    it 'should be able to parse JSON data with an Array' do
-      is_expected.to run.with_params('["a","b","c"]').
-                         and_return(['a', 'b', 'c'])
+    it 'is able to parse JSON data with an Array' do
+      is_expected.to run.with_params('["a","b","c"]')
+                        .and_return(['a', 'b', 'c'])
     end
 
-    it 'should be able to parse empty JSON values' do
-      is_expected.to run.with_params('[]').
-                         and_return([])
-      is_expected.to run.with_params('{}').
-                         and_return({})
+    it 'is able to parse empty JSON values' do
+      actual_array = ['[]', '{}']
+      expected = [[], {}]
+      actual_array.each_with_index do |actual, index|
+        is_expected.to run.with_params(actual).and_return(expected[index])
+      end
     end
 
-    it 'should be able to parse JSON data with a mixed structure' do
-      is_expected.to run.with_params('{"a":"1","b":2,"c":{"d":[true,false]}}').
-                         and_return({'a' =>'1', 'b' => 2, 'c' => { 'd' => [true, false] } })
+    it 'is able to parse JSON data with a mixed structure' do
+      is_expected.to run.with_params('{"a":"1","b":2,"c":{"d":[true,false]}}')
+                        .and_return('a' => '1', 'b' => 2, 'c' => { 'd' => [true, false] })
     end
 
-    it 'should be able to parse JSON data with a UTF8 and double byte characters' do
-      is_expected.to run.with_params('{"×":"これ","ý":"記号","です":{"©":["Á","ß"]}}').
-          and_return({'×' =>'これ', 'ý' => '記号', 'です' => { '©' => ['Á', 'ß'] } })
+    it 'is able to parse JSON data with a UTF8 and double byte characters' do
+      is_expected.to run.with_params('{"×":"これ","ý":"記号","です":{"©":["Á","ß"]}}')
+                        .and_return('×' => 'これ', 'ý' => '記号', 'です' => { '©' => ['Á', 'ß'] })
     end
 
-    it 'should not return the default value if the data was parsed correctly' do
-      is_expected.to run.with_params('{"a":"1"}', 'default_value').
-                         and_return({'a' => '1'})
+    it 'does not return the default value if the data was parsed correctly' do
+      is_expected.to run.with_params('{"a":"1"}', 'default_value')
+                        .and_return('a' => '1')
     end
-
   end
 
   context 'with incorrect JSON data' do
-    it 'should raise an error with invalid JSON and no default' do
-      is_expected.to run.with_params('').
-                         and_raise_error(PSON::ParserError)
+    it 'raises an error with invalid JSON and no default' do
+      is_expected.to run.with_params('')
+                        .and_raise_error(PSON::ParserError)
     end
 
-    it 'should support a structure for a default value' do
-      is_expected.to run.with_params('', {'a' => '1'}).
-                         and_return({'a' => '1'})
+    it 'supports a structure for a default value' do
+      is_expected.to run.with_params('', 'a' => '1')
+                        .and_return('a' => '1')
     end
 
     ['', 1, 1.2, nil, true, false, [], {}, :yaml].each do |value|
       it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do
-        is_expected.to run.with_params(value, 'default_value').
-                           and_return('default_value')
+        is_expected.to run.with_params(value, 'default_value')
+                          .and_return('default_value')
       end
     end
-
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index c2a138c..e8d3f4e
@@ -1,86 +1,83 @@
 require 'spec_helper'
 
 describe 'parseyaml' do
-  it 'should exist' do
+  it 'exists' do
     is_expected.not_to eq(nil)
   end
 
-  it 'should raise an error if called without any arguments' do
-    is_expected.to run.with_params().
-                       and_raise_error(/wrong number of arguments/i)
+  it 'raises an error if called without any arguments' do
+    is_expected.to run.with_params
+                      .and_raise_error(%r{wrong number of arguments}i)
   end
 
   context 'with correct YAML data' do
-    it 'should be able to parse a YAML data with a String' do
-      is_expected.to run.with_params('--- just a string').
-                         and_return('just a string')
-      is_expected.to run.with_params('just a string').
-                         and_return('just a string')
+    it 'is able to parse a YAML data with a String' do
+      actual_array = ['--- just a string', 'just a string']
+      actual_array.each do |actual|
+        is_expected.to run.with_params(actual).and_return('just a string')
+      end
     end
 
-    it 'should be able to parse YAML data with a Hash' do
-      is_expected.to run.with_params("---\na: '1'\nb: '2'\n").
-                         and_return({'a' => '1', 'b' => '2'})
+    it 'is able to parse YAML data with a Hash' do
+      is_expected.to run.with_params("---\na: '1'\nb: '2'\n")
+                        .and_return('a' => '1', 'b' => '2')
     end
 
-    it 'should be able to parse YAML data with an Array' do
-      is_expected.to run.with_params("---\n- a\n- b\n- c\n").
-                         and_return(['a', 'b', 'c'])
+    it 'is able to parse YAML data with an Array' do
+      is_expected.to run.with_params("---\n- a\n- b\n- c\n")
+                        .and_return(['a', 'b', 'c'])
     end
 
-    it 'should be able to parse YAML data with a mixed structure' do
-      is_expected.to run.with_params("---\na: '1'\nb: 2\nc:\n  d:\n  - :a\n  - true\n  - false\n").
-                         and_return({'a' => '1', 'b' => 2, 'c' => {'d' => [:a, true, false]}})
+    it 'is able to parse YAML data with a mixed structure' do
+      is_expected.to run.with_params("---\na: '1'\nb: 2\nc:\n  d:\n  - :a\n  - true\n  - false\n")
+                        .and_return('a' => '1', 'b' => 2, 'c' => { 'd' => [:a, true, false] })
     end
 
-    it 'should be able to parse YAML data with a UTF8 and double byte characters' do
-      is_expected.to run.with_params("---\na: ×\nこれ: 記号\nです:\n  ©:\n  - Á\n  - ß\n").
-          and_return({"a"=>"×", "これ"=>"記号", "です"=>{"©"=>["Á", "ß"]} })
+    it 'is able to parse YAML data with a UTF8 and double byte characters' do
+      is_expected.to run.with_params("---\na: ×\nこれ: 記号\nです:\n  ©:\n  - Á\n  - ß\n")
+                        .and_return('a' => '×', 'これ' => '記号', 'です' => { '©' => ['Á', 'ß'] })
     end
 
-    it 'should not return the default value if the data was parsed correctly' do
-      is_expected.to run.with_params("---\na: '1'\n", 'default_value').
-                         and_return({'a' => '1'})
+    it 'does not return the default value if the data was parsed correctly' do
+      is_expected.to run.with_params("---\na: '1'\n", 'default_value')
+                        .and_return('a' => '1')
     end
-
   end
 
   context 'on a modern ruby', :unless => RUBY_VERSION == '1.8.7' do
-    it 'should raise an error with invalid YAML and no default' do
-      is_expected.to run.with_params('["one"').
-                         and_raise_error(Psych::SyntaxError)
+    it 'raises an error with invalid YAML and no default' do
+      is_expected.to run.with_params('["one"')
+                        .and_raise_error(Psych::SyntaxError)
     end
   end
 
-    context 'when running on ruby 1.8.7, which does not have Psych', :if => RUBY_VERSION == '1.8.7' do
-      it 'should raise an error with invalid YAML and no default' do
-        is_expected.to run.with_params('["one"').
-          and_raise_error(ArgumentError)
-      end
+  context 'when running on ruby 1.8.7, which does not have Psych', :if => RUBY_VERSION == '1.8.7' do
+    it 'raises an error with invalid YAML and no default' do
+      is_expected.to run.with_params('["one"')
+                        .and_raise_error(ArgumentError)
     end
+  end
 
   context 'with incorrect YAML data' do
-    it 'should support a structure for a default value' do
-      is_expected.to run.with_params('', {'a' => '1'}).
-                         and_return({'a' => '1'})
+    it 'supports a structure for a default value' do
+      is_expected.to run.with_params('', 'a' => '1')
+                        .and_return('a' => '1')
     end
 
     [1, 1.2, nil, true, false, [], {}, :yaml].each do |value|
       it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do
-        is_expected.to run.with_params(value, 'default_value').
-                           and_return('default_value')
+        is_expected.to run.with_params(value, 'default_value')
+                          .and_return('default_value')
       end
     end
 
     context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do
       ['---', '...', '*8', ''].each do |value|
         it "should return the default value for an incorrect #{value.inspect} string parameter" do
-          is_expected.to run.with_params(value, 'default_value').
-                             and_return('default_value')
+          is_expected.to run.with_params(value, 'default_value')
+                            .and_return('default_value')
         end
       end
     end
-
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index a7ffc86..29d7896
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 describe 'pick_default' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::Error, /Must receive at least one argument/) }
+  it { is_expected.to run.with_params.and_raise_error(RuntimeError, %r{Must receive at least one argument}) }
 
   it { is_expected.to run.with_params('one', 'two').and_return('one') }
   it { is_expected.to run.with_params('ớņệ', 'ťωơ').and_return('ớņệ') }
@@ -11,16 +11,30 @@ describe 'pick_default' do
   it { is_expected.to run.with_params(:undefined, 'two').and_return('two') }
   it { is_expected.to run.with_params(nil, 'two').and_return('two') }
 
-  [ '', :undef, :undefined, nil, {}, [], 1, 'default' ].each do |value|
+  ['', :undef, :undefined, nil, {}, [], 1, 'default'].each do |value|
     describe "when providing #{value.inspect} as default" do
       it { is_expected.to run.with_params('one', value).and_return('one') }
       it { is_expected.to run.with_params('ớņệ', value).and_return('ớņệ') }
       it { is_expected.to run.with_params([], value).and_return([]) }
       it { is_expected.to run.with_params({}, value).and_return({}) }
-      it { is_expected.to run.with_params(value, value).and_return(value) }
-      it { is_expected.to run.with_params(:undef, value).and_return(value) }
-      it { is_expected.to run.with_params(:undefined, value).and_return(value) }
-      it { is_expected.to run.with_params(nil, value).and_return(value) }
+      it { is_expected.to run.with_params(value, value).and_return(mapped_value(value)) }
+      it { is_expected.to run.with_params(:undef, value).and_return(mapped_value(value)) }
+      it { is_expected.to run.with_params(:undefined, value).and_return(mapped_value(value)) }
+      it { is_expected.to run.with_params(nil, value).and_return(mapped_value(value)) }
+    end
+  end
+
+  if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 ||
+     Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') == 0
+    def mapped_value(v)
+      v
+    end
+  else
+    def mapped_value(v)
+      # Puppet 6.0.0 will always map arguments the same way as the Puppet Language
+      # even if function is called from Ruby via call_function
+      # The 3x function API expects nil and :undef to be represented as empty string
+      (v.nil? || v == :undef) ? '' : v
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 438553b..d8c6fbf
@@ -2,16 +2,16 @@ require 'spec_helper'
 
 describe 'pick' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /must receive at least one non empty value/) }
-  it { is_expected.to run.with_params('', nil, :undef, :undefined).and_raise_error(Puppet::ParseError, /must receive at least one non empty value/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{must receive at least one non empty value}) }
+  it { is_expected.to run.with_params('', nil, :undef, :undefined).and_raise_error(Puppet::ParseError, %r{must receive at least one non empty value}) }
   it { is_expected.to run.with_params('one', 'two').and_return('one') }
   it { is_expected.to run.with_params('', 'two').and_return('two') }
   it { is_expected.to run.with_params(:undef, 'two').and_return('two') }
   it { is_expected.to run.with_params(:undefined, 'two').and_return('two') }
   it { is_expected.to run.with_params(nil, 'two').and_return('two') }
 
-  context 'should run with UTF8 and double byte characters' do
-  it { is_expected.to run.with_params(nil, 'このテキスト').and_return('このテキスト') }
-  it { is_expected.to run.with_params('', 'ŝẳмрłề џţƒ8 ţẽם', 'このテキスト').and_return('ŝẳмрłề џţƒ8 ţẽם') }
+  context 'with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params(nil, 'このテキスト').and_return('このテキスト') }
+    it { is_expected.to run.with_params('', 'ŝẳмрłề џţƒ8 ţẽם', 'このテキスト').and_return('ŝẳмрłề џţƒ8 ţẽם') }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 5510c58..1b771d9
@@ -2,13 +2,13 @@ require 'spec_helper'
 
 describe 'prefix' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the second.")
-    is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the second.')
+    is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /expected first argument to be an Array or a Hash/) }
-  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) }
+  it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{expected first argument to be an Array or a Hash}) }
+  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{expected second argument to be a String}) }
   it { is_expected.to run.with_params([]).and_return([]) }
   it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) }
   it { is_expected.to run.with_params(['ớņệ', 2]).and_return(['ớņệ', '2']) }
@@ -17,13 +17,13 @@ describe 'prefix' do
   it { is_expected.to run.with_params(['one'], 'pre').and_return(['preone']) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], 'pre').and_return(['preone', 'pretwo', 'prethree']) }
   it { is_expected.to run.with_params({}).and_return({}) }
-  it { is_expected.to run.with_params({ 'key1' => 'value1', 2 => 3}).and_return({ 'key1' => 'value1', '2' => 3 }) }
+  it { is_expected.to run.with_params('key1' => 'value1', 2 => 3).and_return('key1' => 'value1', '2' => 3) }
   it { is_expected.to run.with_params({}, '').and_return({}) }
-  it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return({ 'key' => 'value' }) }
-  it { is_expected.to run.with_params({ 'key' => 'value' }, 'pre').and_return({ 'prekey' => 'value' }) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value') }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, 'pre').and_return('prekey' => 'value') }
   it {
     is_expected.to run \
       .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'pre') \
-      .and_return({ 'prekey1' => 'value1', 'prekey2' => 'value2', 'prekey3' => 'value3' })
+      .and_return('prekey1' => 'value1', 'prekey2' => 'value2', 'prekey3' => 'value3')
   }
 end
index a13be64..cfd78c4 100644 (file)
@@ -1,56 +1,52 @@
 require 'spec_helper'
 
 describe 'private' do
-  it 'should issue a warning' do
-    scope.expects(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
+  it 'issues a warning' do
+    expect(scope).to receive(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : unable to cut line to required length
     begin
-      subject.call []
-    rescue
+      subject.execute
+    rescue # rubocop:disable Lint/HandleExceptions
       # ignore this
     end
   end
 
-  context "when called from inside module" do
-    it "should not fail" do
-      scope.expects(:lookupvar).with('module_name').returns('foo')
-      scope.expects(:lookupvar).with('caller_module_name').returns('foo')
+  context 'when called from inside module' do
+    it 'does not fail' do
+      expect(scope).to receive(:lookupvar).with('module_name').and_return('foo')
+      expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('foo')
       expect {
-        subject.call []
+        subject.execute
       }.not_to raise_error
     end
   end
 
-  context "with an explicit failure message" do
-    it "prints the failure message on error" do
-      scope.expects(:lookupvar).with('module_name').returns('foo')
-      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
+  context 'with an explicit failure message' do
+    it 'prints the failure message on error' do
+      expect(scope).to receive(:lookupvar).with('module_name').and_return('foo')
+      expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar')
       expect {
-        subject.call ['failure message!']
-      }.to raise_error Puppet::ParseError, /failure message!/
+        subject.execute('failure message!')
+      }.to raise_error(Puppet::ParseError, %r{failure message!})
     end
   end
 
-  context "when called from private class" do
-    it "should fail with a class error message" do
-      scope.expects(:lookupvar).with('module_name').returns('foo')
-      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
-      scope.source.expects(:name).returns('foo::baz')
-      scope.source.expects(:type).returns('hostclass')
-      expect {
-        subject.call []
-      }.to raise_error Puppet::ParseError, /Class foo::baz is private/
+  context 'when called from private class' do
+    it 'fails with a class error message' do
+      expect(scope).to receive(:lookupvar).with('module_name').and_return('foo')
+      expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar')
+      expect(scope.source).to receive(:name).and_return('foo::baz')
+      expect(scope.source).to receive(:type).and_return('hostclass')
+      expect { subject.execute }.to raise_error(Puppet::ParseError, %r{Class foo::baz is private})
     end
   end
 
-  context "when called from private definition" do
-    it "should fail with a class error message" do
-      scope.expects(:lookupvar).with('module_name').returns('foo')
-      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
-      scope.source.expects(:name).returns('foo::baz')
-      scope.source.expects(:type).returns('definition')
-      expect {
-        subject.call []
-      }.to raise_error Puppet::ParseError, /Definition foo::baz is private/
+  context 'when called from private definition' do
+    it 'fails with a class error message' do
+      expect(scope).to receive(:lookupvar).with('module_name').and_return('foo')
+      expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar')
+      expect(scope.source).to receive(:name).and_return('foo::baz')
+      expect(scope.source).to receive(:type).and_return('definition')
+      expect { subject.execute }.to raise_error(Puppet::ParseError, %r{Definition foo::baz is private})
     end
   end
 end
index 9e03464..31010d6 100644 (file)
@@ -1,25 +1,24 @@
 require 'spec_helper'
 
 describe 'pw_hash' do
-
   it { is_expected.not_to eq(nil) }
 
   context 'when there are less than 3 arguments' do
-    it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('password').and_raise_error(ArgumentError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('password', 'sha-256').and_raise_error(ArgumentError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('password').and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('password', 'sha-256').and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
   end
 
   context 'when there are more than 3 arguments' do
-    it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra').and_raise_error(ArgumentError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra', 'extra').and_raise_error(ArgumentError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra').and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra', 'extra').and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
   end
 
   context 'when the first argument is not a string' do
-    it { is_expected.to run.with_params([], 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
-    it { is_expected.to run.with_params({}, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
-    it { is_expected.to run.with_params(1, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
-    it { is_expected.to run.with_params(true, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
+    it { is_expected.to run.with_params([], 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) }
+    it { is_expected.to run.with_params({}, 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) }
+    it { is_expected.to run.with_params(1, 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) }
+    it { is_expected.to run.with_params(true, 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) }
   end
 
   context 'when the first argument is undefined' do
@@ -28,39 +27,39 @@ describe 'pw_hash' do
   end
 
   context 'when the second argument is not a string' do
-    it { is_expected.to run.with_params('password', [], 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
-    it { is_expected.to run.with_params('password', {}, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
-    it { is_expected.to run.with_params('password', 1, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
-    it { is_expected.to run.with_params('password', true, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
+    it { is_expected.to run.with_params('password', [], 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) }
+    it { is_expected.to run.with_params('password', {}, 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) }
+    it { is_expected.to run.with_params('password', 1, 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) }
+    it { is_expected.to run.with_params('password', true, 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) }
   end
 
   context 'when the second argument is not one of the supported hashing algorithms' do
-    it { is_expected.to run.with_params('password', 'no such algo', 'salt').and_raise_error(ArgumentError, /is not a valid hash type/) }
+    it { is_expected.to run.with_params('password', 'no such algo', 'salt').and_raise_error(ArgumentError, %r{is not a valid hash type}) }
   end
 
   context 'when the third argument is not a string' do
-    it { is_expected.to run.with_params('password', 'sha-256', []).and_raise_error(ArgumentError, /third argument must be a string/) }
-    it { is_expected.to run.with_params('password', 'sha-256', {}).and_raise_error(ArgumentError, /third argument must be a string/) }
-    it { is_expected.to run.with_params('password', 'sha-256', 1).and_raise_error(ArgumentError, /third argument must be a string/) }
-    it { is_expected.to run.with_params('password', 'sha-256', true).and_raise_error(ArgumentError, /third argument must be a string/) }
+    it { is_expected.to run.with_params('password', 'sha-256', []).and_raise_error(ArgumentError, %r{third argument must be a string}) }
+    it { is_expected.to run.with_params('password', 'sha-256', {}).and_raise_error(ArgumentError, %r{third argument must be a string}) }
+    it { is_expected.to run.with_params('password', 'sha-256', 1).and_raise_error(ArgumentError, %r{third argument must be a string}) }
+    it { is_expected.to run.with_params('password', 'sha-256', true).and_raise_error(ArgumentError, %r{third argument must be a string}) }
   end
 
   context 'when the third argument is empty' do
-    it { is_expected.to run.with_params('password', 'sha-512', '').and_raise_error(ArgumentError, /third argument must not be empty/) }
+    it { is_expected.to run.with_params('password', 'sha-512', '').and_raise_error(ArgumentError, %r{third argument must not be empty}) }
   end
 
   context 'when the third argument contains invalid characters' do
-    it { is_expected.to run.with_params('password', 'sha-512', 'one%').and_raise_error(ArgumentError, /characters in salt must be in the set/) }
+    it { is_expected.to run.with_params('password', 'sha-512', 'one%').and_raise_error(ArgumentError, %r{characters in salt must be in the set}) }
   end
 
   context 'when running on a platform with a weak String#crypt implementation' do
-    before(:each) { allow_any_instance_of(String).to receive(:crypt).with('$1$1').and_return('a bad hash') }
+    before(:each) { allow_any_instance_of(String).to receive(:crypt).with('$1$1').and_return('a bad hash') } # rubocop:disable RSpec/AnyInstance : Unable to find a viable replacement
 
-    it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_raise_error(Puppet::ParseError, /system does not support enhanced salts/) }
+    it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_raise_error(Puppet::ParseError, %r{system does not support enhanced salts}) }
   end
 
-  if RUBY_PLATFORM == 'java' or 'test'.crypt('$1$1') == '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
-    describe "on systems with enhanced salts support" do
+  if RUBY_PLATFORM == 'java' || 'test'.crypt('$1$1') == '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
+    describe 'on systems with enhanced salts support' do
       it { is_expected.to run.with_params('password', 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') }
       it { is_expected.to run.with_params('password', 'sha-256', 'salt').and_return('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1') }
       it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_return('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.') }
@@ -69,7 +68,10 @@ describe 'pw_hash' do
     if Puppet::Util::Package.versioncmp(Puppet.version, '4.7.0') >= 0
       describe 'when arguments are sensitive' do
         it { is_expected.to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('password'), 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') }
-        it { is_expected.to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('password'), 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt')).and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') }
+        it {
+          is_expected.to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('password'), 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt'))
+                            .and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0')
+        }
         it { is_expected.to run.with_params('password', 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt')).and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') }
       end
     end
old mode 100755 (executable)
new mode 100644 (file)
index ca569d5..7b9e6d4
@@ -4,28 +4,59 @@ describe 'range' do
   it { is_expected.not_to eq(nil) }
 
   describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
     it {
-      pending("Current implementation ignores parameters after the third.")
-      is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+      pending('Current implementation ignores parameters after the third.')
+      is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
     }
-    it { is_expected.to run.with_params('1..2..3').and_raise_error(Puppet::ParseError, /Unable to compute range/i) }
-    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Unknown range format/i) }
+    it { is_expected.to run.with_params('1..2..3').and_raise_error(Puppet::ParseError, %r{Unable to compute range}i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Unknown range format}i) }
   end
 
   describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params().and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params('').and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params({}).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params([]).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) }
-    it {                                        is_expected.to run.with_params(1, 2, 'foo').and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, []).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, {}).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, true).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(ArgumentError) }
-    it { pending "the puppet 4 implementation"; is_expected.to run.with_params('1..2..3').and_raise_error(ArgumentError) }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params.and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params('').and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params({}).and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params([]).and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params(true).and_raise_error(ArgumentError)
+    }
+    it {
+      is_expected.to run.with_params(1, 2, 'foo').and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params(1, 2, []).and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params(1, 2, {}).and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params(1, 2, true).and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(ArgumentError)
+    }
+    it {
+      pending 'the puppet 4 implementation'
+      is_expected.to run.with_params('1..2..3').and_raise_error(ArgumentError)
+    }
   end
 
   context 'with characters as bounds' do
@@ -111,16 +142,16 @@ describe 'range' do
 
   describe 'when passing mixed arguments as bounds' do
     it {
-      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially')
-      is_expected.to run.with_params('0', 'a').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/)
+      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length
+      is_expected.to run.with_params('0', 'a').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds})
     }
     it {
-      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially')
-      is_expected.to run.with_params(0, 'a').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/)
+      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length
+      is_expected.to run.with_params(0, 'a').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds})
     }
     it {
-      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially')
-      is_expected.to run.with_params('h0', 'ha').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/)
+      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length
+      is_expected.to run.with_params('h0', 'ha').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds})
     }
   end
 end
index 36dbe70..b60cb99 100644 (file)
@@ -3,37 +3,37 @@ require 'spec_helper'
 describe 'regexpescape' do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
     it {
-      pending("Current implementation ignores parameters after the first.")
-      is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+      pending('Current implementation ignores parameters after the first.')
+      is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
     }
-    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
   end
 
   describe 'handling normal strings' do
-    it 'should call ruby\'s Regexp.escape function' do
-      Regexp.expects(:escape).with('regexp_string').returns('escaped_regexp_string').once
+    it 'calls ruby\'s Regexp.escape function' do
+      expect(Regexp).to receive(:escape).with('regexp_string').and_return('escaped_regexp_string').once
       is_expected.to run.with_params('regexp_string').and_return('escaped_regexp_string')
     end
   end
 
   describe 'handling classes derived from String' do
-    it 'should call ruby\'s Regexp.escape function' do
+    it 'calls ruby\'s Regexp.escape function' do
       regexp_string = AlsoString.new('regexp_string')
-      Regexp.expects(:escape).with(regexp_string).returns('escaped_regexp_string').once
-      is_expected.to run.with_params(regexp_string).and_return("escaped_regexp_string")
+      expect(Regexp).to receive(:escape).with(regexp_string).and_return('escaped_regexp_string').once
+      is_expected.to run.with_params(regexp_string).and_return('escaped_regexp_string')
     end
   end
 
   describe 'strings in arrays handling' do
     it { is_expected.to run.with_params([]).and_return([]) }
-    it { is_expected.to run.with_params(['one*', "two"]).and_return(['one\*', "two"]) }
-    it { is_expected.to run.with_params(['one*', 1, true, {}, "two"]).and_return(['one\*', 1, true, {}, "two"]) }
+    it { is_expected.to run.with_params(['one*', 'two']).and_return(['one\*', 'two']) }
+    it { is_expected.to run.with_params(['one*', 1, true, {}, 'two']).and_return(['one\*', 1, true, {}, 'two']) }
 
-    context 'should run with UTF8 and double byte characters' do
+    context 'with UTF8 and double byte characters' do
       it { is_expected.to run.with_params(['ŏʼnε*']).and_return(['ŏʼnε\*']) }
       it { is_expected.to run.with_params(['インターネット*']).and_return(['インターネット\*']) }
     end
old mode 100755 (executable)
new mode 100644 (file)
index 86db7c7..b7f6d2e
@@ -2,16 +2,16 @@ require 'spec_helper'
 
 describe 'reject' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params([], 'pattern', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params([], 'pattern', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   it {
-    pending("reject does not actually check this, and raises NoMethodError instead")
-    is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+    pending('reject does not actually check this, and raises NoMethodError instead')
+    is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array})
   }
   it {
-    pending("reject does not actually check this, and raises NoMethodError instead")
-    is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+    pending('reject does not actually check this, and raises NoMethodError instead')
+    is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array})
   }
   it { is_expected.to run.with_params([], 'two').and_return([]) }
   it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) }
old mode 100755 (executable)
new mode 100644 (file)
index 79bc0ad..93a4e2a
@@ -2,14 +2,14 @@ require 'spec_helper'
 
 describe 'reverse' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
   it { is_expected.to run.with_params([]).and_return([]) }
   it { is_expected.to run.with_params(['a']).and_return(['a']) }
   it { is_expected.to run.with_params(['one']).and_return(['one']) }
@@ -24,9 +24,9 @@ describe 'reverse' do
   it { is_expected.to run.with_params('āβćđ').and_return('đćβā') }
 
   context 'when using a class extending String' do
-    it 'should call its reverse method' do
+    it 'calls its reverse method' do
       value = AlsoString.new('asdfghjkl')
-      value.expects(:reverse).returns('foo')
+      expect_any_instance_of(AlsoString).to receive(:reverse).and_return('foo') # rubocop:disable RSpec/AnyInstance
       expect(subject).to run.with_params(value).and_return('foo')
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 8b13478..fa8ebd5
@@ -1,6 +1,6 @@
 require 'spec_helper'
 
-describe 'round' do
+describe 'round', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
   it { is_expected.to run.with_params(34.3).and_return(34) }
   it { is_expected.to run.with_params(-34.3).and_return(-34) }
@@ -8,7 +8,7 @@ describe 'round' do
   it { is_expected.to run.with_params(-34.5).and_return(-35) }
   it { is_expected.to run.with_params(34.7).and_return(35) }
   it { is_expected.to run.with_params(-34.7).and_return(-35) }
-  it { is_expected.to run.with_params("test").and_raise_error Puppet::ParseError }
-  it { is_expected.to run.with_params("test", "best").and_raise_error Puppet::ParseError }
+  it { is_expected.to run.with_params('test').and_raise_error Puppet::ParseError }
+  it { is_expected.to run.with_params('test', 'best').and_raise_error Puppet::ParseError }
   it { is_expected.to run.with_params(3, 4).and_raise_error Puppet::ParseError }
 end
old mode 100755 (executable)
new mode 100644 (file)
index a7663e2..60776d8
@@ -1,14 +1,14 @@
 require 'spec_helper'
 
-describe 'rstrip' do
+describe 'rstrip', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
   it { is_expected.to run.with_params('').and_return('') }
   it { is_expected.to run.with_params(' ').and_return('') }
   it { is_expected.to run.with_params('     ').and_return('') }
index ac108f4..0bd8d6d 100644 (file)
@@ -2,41 +2,41 @@ require 'spec_helper'
 
 describe 'seeded_rand' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(0, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params(1.5, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params(-10, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params("-10", '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params("string", '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params([], '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params({}, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
-  it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, /second argument must be a string/) }
-  it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, /second argument must be a string/) }
-  it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, /second argument must be a string/) }
-
-  it "provides a random number strictly less than the given max" do
-    expect(seeded_rand(3, 'seed')).to satisfy {|n| n.to_i < 3 }
+  it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(0, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params(1.5, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params(-10, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params('-10', '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params('string', '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params([], '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params({}, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) }
+  it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, %r{second argument must be a string}) }
+  it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, %r{second argument must be a string}) }
+  it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, %r{second argument must be a string}) }
+
+  it 'provides a random number strictly less than the given max' do
+    expect(seeded_rand(3, 'seed')).to satisfy { |n| n.to_i < 3 } # rubocop:disable Lint/AmbiguousBlockAssociation : Cannot parenthesize without break code or violating other Rubocop rules
   end
 
-  it "provides a random number greater or equal to zero" do
-    expect(seeded_rand(3, 'seed')).to satisfy {|n| n.to_i >= 0 }
+  it 'provides a random number greater or equal to zero' do
+    expect(seeded_rand(3, 'seed')).to satisfy { |n| n.to_i >= 0 } # rubocop:disable Lint/AmbiguousBlockAssociation : Cannot parenthesize without break code or violating other Rubocop rules
   end
 
   it "provides the same 'random' value on subsequent calls for the same host" do
     expect(seeded_rand(10, 'seed')).to eql(seeded_rand(10, 'seed'))
   end
 
-  it "allows seed to control the random value on a single host" do
+  it 'allows seed to control the random value on a single host' do
     first_random = seeded_rand(1000, 'seed1')
     second_different_random = seeded_rand(1000, 'seed2')
 
     expect(first_random).not_to eql(second_different_random)
   end
 
-  it "should not return different values for different hosts" do
-    val1 = seeded_rand(1000, 'foo', :host => "first.host.com")
-    val2 = seeded_rand(1000, 'foo', :host => "second.host.com")
+  it 'does not return different values for different hosts' do
+    val1 = seeded_rand(1000, 'foo', :host => 'first.host.com')
+    val2 = seeded_rand(1000, 'foo', :host => 'second.host.com')
 
     expect(val1).to eql(val2)
   end
@@ -46,13 +46,13 @@ describe 'seeded_rand' do
 
     # workaround not being able to use let(:facts) because some tests need
     # multiple different hostnames in one context
-    scope.stubs(:lookupvar).with("::fqdn", {}).returns(host)
+    allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host)
 
     scope.function_seeded_rand([max, seed])
   end
 
-  context 'should run with UTF8 and double byte characters' do
-    it { is_expected.to run.with_params(1000, 'ǿňè')}
-    it { is_expected.to run.with_params(1000, '文字列')}
+  context 'with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params(1000, 'ǿňè') }
+    it { is_expected.to run.with_params(1000, '文字列') }
   end
 end
index 77917dd..ed63bc3 100644 (file)
@@ -4,8 +4,8 @@ describe 'shell_escape' do
   it { is_expected.not_to eq(nil) }
 
   describe 'signature validation' do
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
   describe 'stringification' do
@@ -16,12 +16,14 @@ describe 'shell_escape' do
   describe 'escaping' do
     it { is_expected.to run.with_params('foo').and_return('foo') }
     it { is_expected.to run.with_params('foo bar').and_return('foo\ bar') }
-    it { is_expected.to run.with_params('~`!@#$%^&*()_+-=[]\{}|;\':",./<>?')
-           .and_return('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') }
+    it {
+      is_expected.to run.with_params('~`!@#$%^&*()_+-=[]\{}|;\':",./<>?')
+                        .and_return('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?')
+    }
   end
 
-  context 'should run with UTF8 and double byte characters' do
-      it { is_expected.to run.with_params('スペー スを含むテ  キスト').and_return('\\ス\\ペ\\ー\\ \\ス\\を\\含\\む\\テ\\ \\ \\キ\\ス\\ト') }
-      it { is_expected.to run.with_params('μťƒ 8  ŧĕχť').and_return('\\μ\\ť\\ƒ\\ 8\\ \\ \\ŧ\\ĕ\\χ\\ť') }
+  context 'with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params('スペー スを含むテ  キスト').and_return('\\ス\\ペ\\ー\\ \\ス\\を\\含\\む\\テ\\ \\ \\キ\\ス\\ト') }
+    it { is_expected.to run.with_params('μťƒ 8  ŧĕχť').and_return('\\μ\\ť\\ƒ\\ 8\\ \\ \\ŧ\\ĕ\\χ\\ť') }
   end
 end
index 46305bf..a31352a 100644 (file)
@@ -4,20 +4,22 @@ describe 'shell_join' do
   it { is_expected.not_to eq(nil) }
 
   describe 'signature validation' do
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params(['foo'], ['bar']).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, /is not an Array/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params(['foo'], ['bar']).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, %r{is not an Array}i) }
   end
 
   describe 'shell argument joining' do
     it { is_expected.to run.with_params(['foo']).and_return('foo') }
     it { is_expected.to run.with_params(['foo', 'bar']).and_return('foo bar') }
     it { is_expected.to run.with_params(['foo', 'bar baz']).and_return('foo bar\ baz') }
-    it { is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?'])
-                            .and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') }
+    it {
+      is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?'])
+                        .and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?')
+    }
 
-  context 'should run with UTF8 and double byte characters' do
-      it { is_expected.to run.with_params(['μťƒ', '8',  'ŧĕχť']).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') }
+    context 'with UTF8 and double byte characters' do
+      it { is_expected.to run.with_params(['μťƒ', '8', 'ŧĕχť']).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') }
       it { is_expected.to run.with_params(['スペー', 'スを含むテ', ' キスト']).and_return('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト') }
     end
   end
index f8f9c90..4a72cab 100644 (file)
@@ -4,8 +4,8 @@ describe 'shell_split' do
   it { is_expected.not_to eq(nil) }
 
   describe 'signature validation' do
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
   describe 'stringification' do
@@ -16,14 +16,18 @@ describe 'shell_split' do
   describe 'shell line spliting' do
     it { is_expected.to run.with_params('foo').and_return(['foo']) }
     it { is_expected.to run.with_params('foo bar').and_return(['foo', 'bar']) }
-    it { is_expected.to run.with_params('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?')
-         .and_return(['~`!@#$%^&*()_+-=[]\{}|;\':",./<>?']) }
-    it { is_expected.to run.with_params('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?')
-         .and_return(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) }
+    it {
+      is_expected.to run.with_params('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?')
+                        .and_return(['~`!@#$%^&*()_+-=[]\{}|;\':",./<>?'])
+    }
+    it {
+      is_expected.to run.with_params('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?')
+                        .and_return(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?'])
+    }
 
-     context 'should run with UTF8 and double byte characters' do
-        it { is_expected.to run.with_params('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť').and_return(['μťƒ', '8',  'ŧĕχť']) }
-        it { is_expected.to run.with_params('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト').and_return(['スペー', 'スを含むテ', ' キスト']) }
+    context 'with UTF8 and double byte characters' do
+      it { is_expected.to run.with_params('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť').and_return(['μťƒ', '8', 'ŧĕχť']) }
+      it { is_expected.to run.with_params('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト').and_return(['スペー', 'スを含むテ', ' キスト']) }
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 4673daa..a3b68a8
@@ -2,14 +2,14 @@ require 'spec_helper'
 
 describe 'shuffle' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
 
   context 'when running with a specific seed' do
     # make tests deterministic
@@ -26,7 +26,7 @@ describe 'shuffle' do
     it { is_expected.to run.with_params('abc').and_return('bac') }
     it { is_expected.to run.with_params('abcd').and_return('dcba') }
 
-    context 'should run with UTF8 and double byte characters' do
+    context 'with UTF8 and double byte characters' do
       it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ģńş ůχţέƒŧí8ґŧŧ ') }
       it { is_expected.to run.with_params('日本語の文字列').and_return('字本日語文列の') }
     end
old mode 100755 (executable)
new mode 100644 (file)
index 2047423..69fdff2
@@ -1,25 +1,25 @@
 require 'spec_helper'
 
-describe 'size' do
+describe 'size', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Unknown type given/) }
-  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Unknown type given/) }
-  it { is_expected.to run.with_params('1').and_raise_error(Puppet::ParseError, /Requires either string, array or hash to work/) }
-  it { is_expected.to run.with_params('1.0').and_raise_error(Puppet::ParseError, /Requires either string, array or hash to work/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Unknown type given}) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Unknown type given}) }
+  it { is_expected.to run.with_params('1').and_raise_error(Puppet::ParseError, %r{Requires either string, array or hash to work}) }
+  it { is_expected.to run.with_params('1.0').and_raise_error(Puppet::ParseError, %r{Requires either string, array or hash to work}) }
   it { is_expected.to run.with_params([]).and_return(0) }
   it { is_expected.to run.with_params(['a']).and_return(1) }
   it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) }
   it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) }
 
   it { is_expected.to run.with_params({}).and_return(0) }
-  it { is_expected.to run.with_params({'1' => '2'}).and_return(1) }
-  it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) }
-  it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) }
+  it { is_expected.to run.with_params('1' => '2').and_return(1) }
+  it { is_expected.to run.with_params('1' => '2', '4' => '4').and_return(2) }
+  it { is_expected.to run.with_params('€' => '@', '竹' => 'ǿňè').and_return(2) }
 
   it { is_expected.to run.with_params('').and_return(0) }
   it { is_expected.to run.with_params('a').and_return(1) }
@@ -28,10 +28,10 @@ describe 'size' do
   it { is_expected.to run.with_params('万').and_return(1) }
   it { is_expected.to run.with_params('āβćđ').and_return(4) }
 
-  context 'when using a class extending String' do
-    it 'should call its size method' do
+  context 'when using a class extending String', :unless => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') == 0 do
+    it 'calls its size method' do
       value = AlsoString.new('asdfghjkl')
-      value.expects(:size).returns('foo')
+      expect(value).to receive(:size).and_return('foo')
       expect(subject).to run.with_params(value).and_return('foo')
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 9abd039..a9bdea3
@@ -1,13 +1,22 @@
 require 'spec_helper'
 
-describe 'sort' do
+describe 'sort', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { pending('stricter input checking'); is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /requires string or array/) }
-    it { pending('stricter input checking'); is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /requires string or array/) }
-    it { pending('stricter input checking'); is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /requires string or array/) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it {
+      pending('stricter input checking')
+      is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{requires string or array})
+    }
+    it {
+      pending('stricter input checking')
+      is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{requires string or array})
+    }
+    it {
+      pending('stricter input checking')
+      is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{requires string or array})
+    }
   end
 
   context 'when called with an array' do
old mode 100755 (executable)
new mode 100644 (file)
index b267d9a..ee144b3
@@ -2,8 +2,8 @@ require 'spec_helper'
 
 describe 'squeeze' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('', '', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('', '', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it { is_expected.to run.with_params(1).and_raise_error(NoMethodError) }
   it { is_expected.to run.with_params({}).and_raise_error(NoMethodError) }
   it { is_expected.to run.with_params(true).and_raise_error(NoMethodError) }
@@ -16,7 +16,7 @@ describe 'squeeze' do
     it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') }
   end
 
-  context 'should run with UTF8 and double byte characters' do
+  context 'with UTF8 and double byte characters' do
     it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậậậậ').and_return('ậ') }
     it { is_expected.to run.with_params('語語語語語語語', '語').and_return('語') }
     it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậ語語語語©©©©©', '©').and_return('ậậậậậậậậậậậậậậậậậ語語語語©') }
@@ -26,24 +26,24 @@ describe 'squeeze' do
     it {
       is_expected.to run \
         .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc']) \
-        .and_return( ['', 'a', 'a',         'abc'])
+        .and_return(['', 'a', 'a', 'abc'])
     }
     it {
       is_expected.to run \
         .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'a') \
-        .and_return( ['', 'a', 'a',         'abbbbbbbbbbcccccccccc'])
+        .and_return(['', 'a', 'a', 'abbbbbbbbbbcccccccccc'])
     }
     it {
       is_expected.to run \
         .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'b-c') \
-        .and_return( ['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc'])
+        .and_return(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc'])
     }
   end
 
   context 'when using a class extending String' do
-    it 'should call its squeeze method' do
+    it 'calls its squeeze method' do
       value = AlsoString.new('aaaaaaaaa')
-      value.expects(:squeeze).returns('foo')
+      expect_any_instance_of(AlsoString).to receive(:squeeze).and_return('foo') # rubocop:disable RSpec/AnyInstance
       expect(subject).to run.with_params(value).and_return('foo')
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 7d8c47c..fe43c4c
@@ -2,21 +2,21 @@ require 'spec_helper'
 
 describe 'str2bool' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params('true', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('true', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Unknown type of boolean given/) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Unknown type of boolean given}) }
 
   describe 'when testing values that mean "true"' do
-    [ 'TRUE','1', 't', 'y', 'true', 'yes', true ].each do |value|
+    ['TRUE', '1', 't', 'y', 'true', 'yes', true].each do |value|
       it { is_expected.to run.with_params(value).and_return(true) }
     end
   end
 
   describe 'when testing values that mean "false"' do
-    [ 'FALSE','', '0', 'f', 'n', 'false', 'no', false, 'undef', 'undefined' ].each do |value|
+    ['FALSE', '', '0', 'f', 'n', 'false', 'no', false, 'undef', 'undefined'].each do |value|
       it { is_expected.to run.with_params(value).and_return(false) }
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index 2e1e818..e7513c9
@@ -2,16 +2,25 @@ require 'spec_helper'
 
 describe 'str2saltedsha512' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('password', 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires a String argument/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('password', 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires a String argument}) }
 
   context 'when running with a specific seed' do
     # make tests deterministic
     before(:each) { srand(2) }
 
-    it { is_expected.to run.with_params('').and_return('0f8a612f4eeed08e47b3875d00f33c5688f7926298f2d9b5fe19d1323f910bc78b6f7b5892596d2fabaa65e7a8d99b3768c102610cf0432c4827eee01f09451e3fae4f7a') }
-    it { is_expected.to run.with_params('password').and_return('0f8a612f43134376566c5707718d600effcfb17581fc9d3fa64d7f447dfda317c174ffdb498d2c5bd5c2075dab41c9d7ada5afbdc6b55354980eb5ba61802371e6b64956') }
-    it { is_expected.to run.with_params('verylongpassword').and_return('0f8a612f7a448537540e062daa8621f9bae326ca8ccb899e1bdb10e7c218cebfceae2530b856662565fdc4d81e986fc50cfbbc46d50436610ed9429ff5e43f2c45b5d039') }
+    it {
+      is_expected.to run.with_params('')
+                        .and_return('0f8a612f4eeed08e47b3875d00f33c5688f7926298f2d9b5fe19d1323f910bc78b6f7b5892596d2fabaa65e7a8d99b3768c102610cf0432c4827eee01f09451e3fae4f7a')
+    }
+    it {
+      is_expected.to run.with_params('password')
+                        .and_return('0f8a612f43134376566c5707718d600effcfb17581fc9d3fa64d7f447dfda317c174ffdb498d2c5bd5c2075dab41c9d7ada5afbdc6b55354980eb5ba61802371e6b64956')
+    }
+    it {
+      is_expected.to run.with_params('verylongpassword')
+                        .and_return('0f8a612f7a448537540e062daa8621f9bae326ca8ccb899e1bdb10e7c218cebfceae2530b856662565fdc4d81e986fc50cfbbc46d50436610ed9429ff5e43f2c45b5d039')
+    }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 41cda6a..73c5c96
@@ -1,26 +1,26 @@
 require 'spec_helper'
 
-describe 'strftime' do
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("strftime")).to eq("function_strftime")
+describe 'strftime', :if => Puppet::Util::Package.versioncmp(Puppet.version, '4.8.0') < 0 do
+  it 'exists' do
+    expect(Puppet::Parser::Functions.function('strftime')).to eq('function_strftime')
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_strftime([]) }.to( raise_error(Puppet::ParseError))
+  it 'raises a ParseError if there is less than 1 arguments' do
+    expect { scope.function_strftime([]) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "using %s should be higher then when I wrote this test" do
-    result = scope.function_strftime(["%s"])
-    expect(result.to_i).to(be > 1311953157)
+  it 'using %s should be higher then when I wrote this test' do
+    result = scope.function_strftime(['%s'])
+    expect(result.to_i).to(be > 1_311_953_157)
   end
 
-  it "using %s should be greater than 1.5 trillion" do
-    result = scope.function_strftime(["%s"])
-    expect(result.to_i).to(be > 1500000000)
+  it 'using %s should be greater than 1.5 trillion' do
+    result = scope.function_strftime(['%s'])
+    expect(result.to_i).to(be > 1_500_000_000)
   end
 
-  it "should return a date when given %Y-%m-%d" do
-    result = scope.function_strftime(["%Y-%m-%d"])
-    expect(result).to match(/^\d{4}-\d{2}-\d{2}$/)
+  it 'returns a date when given %Y-%m-%d' do
+    result = scope.function_strftime(['%Y-%m-%d'])
+    expect(result).to match(%r{^\d{4}-\d{2}-\d{2}$})
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 18e943d..28f8d86
@@ -1,14 +1,14 @@
 require 'spec_helper'
 
-describe 'strip' do
+describe 'strip', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) }
   it { is_expected.to run.with_params('').and_return('') }
   it { is_expected.to run.with_params(' ').and_return('') }
   it { is_expected.to run.with_params('     ').and_return('') }
old mode 100755 (executable)
new mode 100644 (file)
index e0eafb1..bbd1186
@@ -2,13 +2,13 @@ require 'spec_helper'
 
 describe 'suffix' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the second.")
-    is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the second.')
+    is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /expected first argument to be an Array/) }
-  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) }
+  it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{expected first argument to be an Array}) }
+  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{expected second argument to be a String}) }
   it { is_expected.to run.with_params([]).and_return([]) }
   it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) }
   it { is_expected.to run.with_params([], '').and_return([]) }
@@ -21,20 +21,20 @@ describe 'suffix' do
     is_expected.to run.with_params({}).and_return({})
   }
   it {
-    is_expected.to run.with_params({ 'key1' => 'value1', 2 => 3}).and_return({ 'key1' => 'value1', '2' => 3 })
+    is_expected.to run.with_params('key1' => 'value1', 2 => 3).and_return('key1' => 'value1', '2' => 3)
   }
   it {
     is_expected.to run.with_params({}, '').and_return({})
   }
   it {
-    is_expected.to run.with_params({ 'key' => 'value' }, '').and_return({ 'key' => 'value' })
+    is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value')
   }
   it {
-    is_expected.to run.with_params({ 'key' => 'value' }, 'post').and_return({ 'keypost' => 'value' })
+    is_expected.to run.with_params({ 'key' => 'value' }, 'post').and_return('keypost' => 'value')
   }
   it {
     is_expected.to run \
       .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'post') \
-      .and_return({ 'key1post' => 'value1', 'key2post' => 'value2', 'key3post' => 'value3' })
+      .and_return('key1post' => 'value1', 'key2post' => 'value2', 'key3post' => 'value3')
   }
 end
old mode 100755 (executable)
new mode 100644 (file)
index c175a15..8370140
@@ -2,14 +2,14 @@ require 'spec_helper'
 
 describe 'swapcase' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
   describe 'with strings as inputs' do
     it { is_expected.to run.with_params('').and_return('') }
     it { is_expected.to run.with_params('one').and_return('ONE') }
@@ -34,7 +34,7 @@ describe 'swapcase' do
       it { is_expected.to run.with_params(['OnE', ['two']]).and_return(['oNe', ['two']]) }
     end
   end
-  it "should accept objects which extend String" do
-    is_expected.to run.with_params(AlsoString.new("OnE")).and_return('oNe')
+  it 'accepts objects which extend String' do
+    is_expected.to run.with_params(AlsoString.new('OnE')).and_return('oNe')
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index d157939..239e2ab
@@ -2,20 +2,20 @@ require 'spec_helper'
 
 describe 'time' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
   context 'when running at a specific time' do
-    before(:each) {
+    before(:each) do
       # get a value before stubbing the function
       test_time = Time.utc(2006, 10, 13, 8, 15, 11)
-      Time.expects(:new).with().returns(test_time).once
-    }
-    it { is_expected.to run.with_params().and_return(1160727311) }
-    it { is_expected.to run.with_params('').and_return(1160727311) }
-    it { is_expected.to run.with_params([]).and_return(1160727311) }
-    it { is_expected.to run.with_params({}).and_return(1160727311) }
-    it { is_expected.to run.with_params('foo').and_return(1160727311) }
-    it { is_expected.to run.with_params('UTC').and_return(1160727311) }
-    it { is_expected.to run.with_params('America/New_York').and_return(1160727311) }
+      allow(Time).to receive(:new).with(no_args).and_return(test_time).once
+    end
+    it { is_expected.to run.with_params.and_return(1_160_727_311) }
+    it { is_expected.to run.with_params('').and_return(1_160_727_311) }
+    it { is_expected.to run.with_params([]).and_return(1_160_727_311) }
+    it { is_expected.to run.with_params({}).and_return(1_160_727_311) }
+    it { is_expected.to run.with_params('foo').and_return(1_160_727_311) }
+    it { is_expected.to run.with_params('UTC').and_return(1_160_727_311) }
+    it { is_expected.to run.with_params('America/New_York').and_return(1_160_727_311) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 2be23ff..f3efd90
@@ -2,11 +2,11 @@ require 'spec_helper'
 
 describe 'to_bytes' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params('1', 'extras').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params([]).and_raise_error(TypeError, /(can't convert|no implicit conversion of) Array (in)?to String/) }
-  it { is_expected.to run.with_params({}).and_raise_error(TypeError, /(can't convert|no implicit conversion of) Hash (in)?to String/) }
-  it { is_expected.to run.with_params(true).and_raise_error(TypeError, /(can't convert|no implicit conversion of) (TrueClass|true) (in)?to String/) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params('1', 'extras').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params([]).and_raise_error(TypeError, %r{(can't convert|no implicit conversion of) Array (in)?to String}) }
+  it { is_expected.to run.with_params({}).and_raise_error(TypeError, %r{(can't convert|no implicit conversion of) Hash (in)?to String}) }
+  it { is_expected.to run.with_params(true).and_raise_error(TypeError, %r{(can't convert|no implicit conversion of) (TrueClass|true) (in)?to String}) }
 
   describe 'when passing numbers' do
     it { is_expected.to run.with_params(0).and_return(0) }
@@ -28,22 +28,20 @@ describe 'to_bytes' do
     describe 'with a unit' do
       it { is_expected.to run.with_params('1k').and_return(1024) }
       it { is_expected.to run.with_params('-1kB').and_return(-1024) }
-      it { is_expected.to run.with_params('1k').and_return(1024) }
-      it { is_expected.to run.with_params('1M').and_return(1024*1024) }
-      it { is_expected.to run.with_params('1G').and_return(1024*1024*1024) }
-      it { is_expected.to run.with_params('1T').and_return(1024*1024*1024*1024) }
-      it { is_expected.to run.with_params('1P').and_return(1024*1024*1024*1024*1024) }
-      it { is_expected.to run.with_params('1E').and_return(1024*1024*1024*1024*1024*1024) }
-      it { is_expected.to run.with_params('1.5e3M').and_return(1572864000) }
+      it { is_expected.to run.with_params('1M').and_return(1024 * 1024) }
+      it { is_expected.to run.with_params('1G').and_return(1024 * 1024 * 1024) }
+      it { is_expected.to run.with_params('1T').and_return(1024 * 1024 * 1024 * 1024) }
+      it { is_expected.to run.with_params('1P').and_return(1024 * 1024 * 1024 * 1024 * 1024) }
+      it { is_expected.to run.with_params('1E').and_return(1024 * 1024 * 1024 * 1024 * 1024 * 1024) }
+      it { is_expected.to run.with_params('1.5e3M').and_return(1_572_864_000) }
 
-      it { is_expected.to run.with_params('4k').and_return(4*1024) }
-      it { is_expected.to run.with_params('-4kB').and_return(4*-1024) }
-      it { is_expected.to run.with_params('4k').and_return(4*1024) }
-      it { is_expected.to run.with_params('4M').and_return(4*1024*1024) }
-      it { is_expected.to run.with_params('4G').and_return(4*1024*1024*1024) }
-      it { is_expected.to run.with_params('4T').and_return(4*1024*1024*1024*1024) }
-      it { is_expected.to run.with_params('4P').and_return(4*1024*1024*1024*1024*1024) }
-      it { is_expected.to run.with_params('4E').and_return(4*1024*1024*1024*1024*1024*1024) }
+      it { is_expected.to run.with_params('4k').and_return(4 * 1024) }
+      it { is_expected.to run.with_params('-4kB').and_return(4 * -1024) }
+      it { is_expected.to run.with_params('4M').and_return(4 * 1024 * 1024) }
+      it { is_expected.to run.with_params('4G').and_return(4 * 1024 * 1024 * 1024) }
+      it { is_expected.to run.with_params('4T').and_return(4 * 1024 * 1024 * 1024 * 1024) }
+      it { is_expected.to run.with_params('4P').and_return(4 * 1024 * 1024 * 1024 * 1024 * 1024) }
+      it { is_expected.to run.with_params('4E').and_return(4 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024) }
 
       # these are so wrong
       it { is_expected.to run.with_params('1.0001 k').and_return(1024) }
@@ -51,12 +49,12 @@ describe 'to_bytes' do
     end
 
     describe 'with a unknown unit' do
-      it { is_expected.to run.with_params('1KB').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
-      it { is_expected.to run.with_params('1K').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
-      it { is_expected.to run.with_params('1mb').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
-      it { is_expected.to run.with_params('1m').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
-      it { is_expected.to run.with_params('1%').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
-      it { is_expected.to run.with_params('1 p').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
+      it { is_expected.to run.with_params('1KB').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) }
+      it { is_expected.to run.with_params('1K').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) }
+      it { is_expected.to run.with_params('1mb').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) }
+      it { is_expected.to run.with_params('1m').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) }
+      it { is_expected.to run.with_params('1%').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) }
+      it { is_expected.to run.with_params('1 p').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) }
     end
   end
 
index 38c0efd..630296b 100644 (file)
 require 'spec_helper'
 
 describe 'try_get_value' do
-
   let(:data) do
     {
-        'a' => {
-            'g' => '2',
-            'e' => [
-                'f0',
-                'f1',
-                {
-                    'x' => {
-                        'y' => 'z'
-                    }
-                },
-                'f3',
-            ]
-        },
-        'b' => true,
-        'c' => false,
-        'd' => '1',
+      'a' => {
+        'g' => '2',
+        'e' => [
+          'f0',
+          'f1',
+          {
+            'x' => {
+              'y' => 'z',
+            },
+          },
+          'f3',
+        ],
+      },
+      'b' => true,
+      'c' => false,
+      'd' => '1',
     }
   end
 
-  context 'single values' do
-    it 'should exist' do
+  context 'with single values' do
+    it 'exists' do
       is_expected.not_to eq(nil)
     end
 
-    it 'should be able to return a single value' do
+    it 'is able to return a single value' do
       is_expected.to run.with_params('test').and_return('test')
     end
 
-    it 'should use the default value if data is a single value and path is present' do
+    it 'uses the default value if data is a single value and path is present' do
       is_expected.to run.with_params('test', 'path', 'default').and_return('default')
     end
 
-    it 'should return default if there is no data' do
+    it 'returns default if there is no data' do
       is_expected.to run.with_params(nil, nil, 'default').and_return('default')
     end
 
-    it 'should be able to use data structures as default values' do
+    it 'is able to use data structures as default values' do
       is_expected.to run.with_params('test', 'path', data).and_return(data)
     end
   end
 
-  context 'structure values' do
-    it 'should be able to extracts a single hash value' do
+  context 'with structure values' do
+    it 'is able to extracts a single hash value' do
       is_expected.to run.with_params(data, 'd', 'default').and_return('1')
     end
 
-    it 'should be able to extract a deeply nested hash value' do
+    it 'is able to extract a deeply nested hash value' do
       is_expected.to run.with_params(data, 'a/g', 'default').and_return('2')
     end
 
-    it 'should return the default value if the path is not found' do
+    it 'returns the default value if the path is not found' do
       is_expected.to run.with_params(data, 'missing', 'default').and_return('default')
     end
 
-    it 'should return the default value if the path is too long' do
+    it 'returns the default value if the path is too long' do
       is_expected.to run.with_params(data, 'a/g/c/d', 'default').and_return('default')
     end
 
-    it 'should support an array index in the path' do
+    it 'supports an array index in the path' do
       is_expected.to run.with_params(data, 'a/e/1', 'default').and_return('f1')
     end
 
-    it 'should return the default value if an array index is not a number' do
+    it 'returns the default value if an array index is not a number' do
       is_expected.to run.with_params(data, 'a/b/c', 'default').and_return('default')
     end
 
-    it 'should return the default value if and index is out of array length' do
+    it 'returns the default value if and index is out of array length' do
       is_expected.to run.with_params(data, 'a/e/5', 'default').and_return('default')
     end
 
-    it 'should be able to path though both arrays and hashes' do
+    it 'is able to path though both arrays and hashes' do
       is_expected.to run.with_params(data, 'a/e/2/x/y', 'default').and_return('z')
     end
 
-    it 'should be able to return "true" value' do
+    it 'is able to return "true" value: default' do
       is_expected.to run.with_params(data, 'b', 'default').and_return(true)
+    end
+
+    it 'is able to return "true" value' do
       is_expected.to run.with_params(data, 'm', true).and_return(true)
     end
 
-    it 'should be able to return "false" value' do
+    it 'is able to return "false" value: default' do
       is_expected.to run.with_params(data, 'c', 'default').and_return(false)
+    end
+
+    it 'is able to return "false" value' do
       is_expected.to run.with_params(data, 'm', false).and_return(false)
     end
 
-    it 'should return "nil" if value is not found and no default value is provided' do
+    it 'returns "nil" if value is not found and no default value is provided' do
       is_expected.to run.with_params(data, 'a/1').and_return(nil)
     end
 
-    it 'should be able to use a custom path separator' do
+    it 'is able to use a custom path separator' do
       is_expected.to run.with_params(data, 'a::g', 'default', '::').and_return('2')
+    end
+
+    it 'is able to use a custom path separator: default' do
       is_expected.to run.with_params(data, 'a::c', 'default', '::').and_return('default')
     end
   end
index c3eb1de..a53362d 100644 (file)
@@ -1,40 +1,40 @@
 require 'spec_helper'
 
 describe 'type3x' do
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("type3x")).to eq("function_type3x")
+  it 'exists' do
+    expect(Puppet::Parser::Functions.function('type3x')).to eq('function_type3x')
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_type3x([]) }.to( raise_error(Puppet::ParseError))
+  it 'raises a ParseError if there is less than 1 arguments' do
+    expect { scope.function_type3x([]) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should return string when given a string" do
-    result = scope.function_type3x(["aaabbbbcccc"])
+  it 'returns string when given a string' do
+    result = scope.function_type3x(['aaabbbbcccc'])
     expect(result).to(eq('string'))
   end
 
-  it "should return array when given an array" do
-    result = scope.function_type3x([["aaabbbbcccc","asdf"]])
+  it 'returns array when given an array' do
+    result = scope.function_type3x([['aaabbbbcccc', 'asdf']])
     expect(result).to(eq('array'))
   end
 
-  it "should return hash when given a hash" do
-    result = scope.function_type3x([{"a"=>1,"b"=>2}])
+  it 'returns hash when given a hash' do
+    result = scope.function_type3x([{ 'a' => 1, 'b' => 2 }])
     expect(result).to(eq('hash'))
   end
 
-  it "should return integer when given an integer" do
-    result = scope.function_type3x(["1"])
+  it 'returns integer when given an integer' do
+    result = scope.function_type3x(['1'])
     expect(result).to(eq('integer'))
   end
 
-  it "should return float when given a float" do
-    result = scope.function_type3x(["1.34"])
+  it 'returns float when given a float' do
+    result = scope.function_type3x(['1.34'])
     expect(result).to(eq('float'))
   end
 
-  it "should return boolean when given a boolean" do
+  it 'returns boolean when given a boolean' do
     result = scope.function_type3x([true])
     expect(result).to(eq('boolean'))
   end
index cc9ef78..4f55b2c 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper'
 
-if ENV["FUTURE_PARSER"] == 'yes'
+if ENV['FUTURE_PARSER'] == 'yes'
   describe 'type_of' do
     pending 'teach rspec-puppet to load future-only functions under 3.7.5' do
       it { is_expected.not_to eq(nil) }
@@ -11,7 +11,7 @@ end
 if Puppet.version.to_f >= 4.0
   describe 'type_of' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
     it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) }
 
     it 'gives the type of a string' do
old mode 100755 (executable)
new mode 100644 (file)
index 4288df0..e1d687b
@@ -1,41 +1,41 @@
 require 'spec_helper'
 
 describe 'type' do
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("type")).to eq("function_type")
+  it 'exists' do
+    expect(Puppet::Parser::Functions.function('type')).to eq('function_type')
   end
 
-  it "should give a deprecation warning when called" do
-    scope.expects(:warning).with("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
-    scope.function_type(["aoeu"])
+  it 'gives a deprecation warning when called' do
+    expect(scope).to receive(:warning).with("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : Unable to reduce to required length
+    scope.function_type(['aoeu'])
   end
 
-  it "should return string when given a string" do
-    result = scope.function_type(["aaabbbbcccc"])
+  it 'returns string when given a string' do
+    result = scope.function_type(['aaabbbbcccc'])
     expect(result).to(eq('string'))
   end
 
-  it "should return array when given an array" do
-    result = scope.function_type([["aaabbbbcccc","asdf"]])
+  it 'returns array when given an array' do
+    result = scope.function_type([['aaabbbbcccc', 'asdf']])
     expect(result).to(eq('array'))
   end
 
-  it "should return hash when given a hash" do
-    result = scope.function_type([{"a"=>1,"b"=>2}])
+  it 'returns hash when given a hash' do
+    result = scope.function_type([{ 'a' => 1, 'b' => 2 }])
     expect(result).to(eq('hash'))
   end
 
-  it "should return integer when given an integer" do
-    result = scope.function_type(["1"])
+  it 'returns integer when given an integer' do
+    result = scope.function_type(['1'])
     expect(result).to(eq('integer'))
   end
 
-  it "should return float when given a float" do
-    result = scope.function_type(["1.34"])
+  it 'returns float when given a float' do
+    result = scope.function_type(['1.34'])
     expect(result).to(eq('float'))
   end
 
-  it "should return boolean when given a boolean" do
+  it 'returns boolean when given a boolean' do
     result = scope.function_type([true])
     expect(result).to(eq('boolean'))
   end
old mode 100755 (executable)
new mode 100644 (file)
index 3f36f24..5492298
@@ -3,11 +3,11 @@ require 'spec_helper'
 describe 'union' do
   describe 'argument checking' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, /Every parameter must be an array/) }
-    it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, /Every parameter must be an array/) }
-    it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /Every parameter must be an array/) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) }
+    it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) }
+    it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) }
   end
 
   it { is_expected.to run.with_params([], []).and_return([]) }
@@ -21,5 +21,5 @@ describe 'union' do
   it { is_expected.to run.with_params(['one', 'two'], ['two', 'three'], ['one', 'three']).and_return(['one', 'two', 'three']) }
   it { is_expected.to run.with_params(['one', 'two'], ['three', 'four'], ['one', 'two', 'three'], ['four']).and_return(['one', 'two', 'three', 'four']) }
   it { is_expected.to run.with_params(['ốńə', 'ţשׂợ'], ['ŧĥяếệ', 'ƒởųŗ'], ['ốńə', 'ţשׂợ', 'ŧĥяếệ'], ['ƒởųŗ']).and_return(['ốńə', 'ţשׂợ', 'ŧĥяếệ', 'ƒởųŗ']) }
-  it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3', 1, 2]) end
+  it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3', 1, 2]) end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 76932ec..1cdb934
@@ -4,14 +4,14 @@ describe 'unique' do
   if Puppet.version.to_f < 5.0
     describe 'signature validation' do
       it { is_expected.not_to eq(nil) }
-      it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+      it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
       it {
-        pending("Current implementation ignores parameters after the first.")
-        is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+        pending('Current implementation ignores parameters after the first.')
+        is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
       }
-      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
     end
 
     context 'when called with an array' do
index 8537a26..a6af64f 100644 (file)
@@ -1,13 +1,13 @@
 require 'spec_helper'
 
 describe 'unix2dos' do
-  context 'Checking parameter validity' do
+  context 'when checking parameter validity' do
     it { is_expected.not_to eq(nil) }
     it do
-      is_expected.to run.with_params.and_raise_error(ArgumentError, /Wrong number of arguments/)
+      is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments})
     end
     it do
-      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/)
+      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{Wrong number of arguments})
     end
     it do
       is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError)
@@ -20,21 +20,21 @@ describe 'unix2dos' do
     end
   end
 
-  context 'Converting from unix to dos format' do
+  context 'when converting from unix to dos format' do
     sample_text    = "Hello\nWorld\n"
     desired_output = "Hello\r\nWorld\r\n"
 
-    it 'should output dos format' do
-      should run.with_params(sample_text).and_return(desired_output)
+    it 'outputs dos format' do
+      is_expected.to run.with_params(sample_text).and_return(desired_output)
     end
   end
 
-  context 'Converting from dos to dos format' do
+  context 'when converting from dos to dos format' do
     sample_text    = "Hello\r\nWorld\r\n"
     desired_output = "Hello\r\nWorld\r\n"
 
-    it 'should output dos format' do
-      should run.with_params(sample_text).and_return(desired_output)
+    it 'outputs dos format' do
+      is_expected.to run.with_params(sample_text).and_return(desired_output)
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 3b7b02d..5b5e426
@@ -1,26 +1,26 @@
 require 'spec_helper'
 
-describe 'upcase' do
+describe 'upcase', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires an array, hash or object that responds to upcase/) }
-    it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, /Requires an array, hash or object that responds to upcase/) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires an array, hash or object that responds to upcase}) }
+    it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, %r{Requires an array, hash or object that responds to upcase}) }
   end
 
   describe 'normal string handling' do
-    it { is_expected.to run.with_params("abc").and_return("ABC") }
-    it { is_expected.to run.with_params("Abc").and_return("ABC") }
-    it { is_expected.to run.with_params("ABC").and_return("ABC") }
+    it { is_expected.to run.with_params('abc').and_return('ABC') }
+    it { is_expected.to run.with_params('Abc').and_return('ABC') }
+    it { is_expected.to run.with_params('ABC').and_return('ABC') }
   end
 
   describe 'handling classes derived from String' do
-    it { is_expected.to run.with_params(AlsoString.new("ABC")).and_return("ABC") }
+    it { is_expected.to run.with_params(AlsoString.new('ABC')).and_return('ABC') }
   end
 
   describe 'strings in arrays handling' do
     it { is_expected.to run.with_params([]).and_return([]) }
-    it { is_expected.to run.with_params(["One", "twO"]).and_return(["ONE", "TWO"]) }
+    it { is_expected.to run.with_params(['One', 'twO']).and_return(['ONE', 'TWO']) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index f05ec08..fdc3e20
@@ -3,34 +3,34 @@ require 'spec_helper'
 describe 'uriescape' do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
     it {
-      pending("Current implementation ignores parameters after the first.")
-      is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+      pending('Current implementation ignores parameters after the first.')
+      is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
     }
-    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
-    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) }
   end
 
   describe 'handling normal strings' do
-    it 'should call ruby\'s URI.escape function' do
-      URI.expects(:escape).with('uri_string').returns('escaped_uri_string').once
-      is_expected.to run.with_params('uri_string').and_return('escaped_uri_string') 
+    it 'calls ruby\'s URI.escape function' do
+      expect(URI).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once
+      is_expected.to run.with_params('uri_string').and_return('escaped_uri_string')
     end
   end
 
   describe 'handling classes derived from String' do
-    it 'should call ruby\'s URI.escape function' do
+    it 'calls ruby\'s URI.escape function' do
       uri_string = AlsoString.new('uri_string')
-      URI.expects(:escape).with(uri_string).returns('escaped_uri_string').once
-      is_expected.to run.with_params(uri_string).and_return("escaped_uri_string") 
+      expect(URI).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once
+      is_expected.to run.with_params(uri_string).and_return('escaped_uri_string')
     end
   end
 
   describe 'strings in arrays handling' do
     it { is_expected.to run.with_params([]).and_return([]) }
-    it { is_expected.to run.with_params(["one}", "two"]).and_return(["one%7D", "two"]) }
-    it { is_expected.to run.with_params(["one}", 1, true, {}, "two"]).and_return(["one%7D", 1, true, {}, "two"]) }
+    it { is_expected.to run.with_params(['one}', 'two']).and_return(['one%7D', 'two']) }
+    it { is_expected.to run.with_params(['one}', 1, true, {}, 'two']).and_return(['one%7D', 1, true, {}, 'two']) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 9397da5..53a7feb
@@ -1,73 +1,51 @@
 require 'spec_helper'
 
 describe 'validate_absolute_path' do
-  after(:all) do
+  after(:each) do
     ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
   # Checking for deprecation warning
-  it 'should display a single deprecation' do
-    ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-    scope.expects(:warning).with(includes('This method is deprecated'))
+  it 'displays a single deprecation' do
+    ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+    expect(scope).to receive(:warning).with(include('This method is deprecated'))
     is_expected.to run.with_params('c:/')
   end
 
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
-  describe "valid paths handling" do
-    %w{
-      C:/
-      C:\\
-      C:\\WINDOWS\\System32
-      C:/windows/system32
-      X:/foo/bar
-      X:\\foo\\bar
-      \\\\host\\windows
-      //host/windows
-      /
-      /var/tmp
-      /var/opt/../lib/puppet
-    }.each do |path|
+  describe 'valid paths handling' do
+    ['C:/', 'C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', '//host/windows', '/', '/var/tmp', '/var/opt/../lib/puppet'].each do |path|
       it { is_expected.to run.with_params(path) }
       it { is_expected.to run.with_params(['/tmp', path]) }
     end
   end
 
   describe 'invalid path handling' do
-    context 'garbage inputs' do
+    context 'with garbage inputs' do
       [
         nil,
-        [ nil ],
-        [ nil, nil ],
+        [nil],
+        [nil, nil],
         { 'foo' => 'bar' },
-        { },
+        {},
         '',
       ].each do |path|
-        it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
-        it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
-        it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+        it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
+        it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
+        it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
       end
     end
 
-    context 'relative paths' do
-      %w{
-        relative1
-        .
-        ..
-        ./foo
-        ../foo
-        etc/puppetlabs/puppet
-        opt/puppet/bin
-        relative\\windows
-      }.each do |path|
-        it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
-        it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
-        it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+    context 'with relative paths' do
+      ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'opt/puppet/bin', 'relative\\windows'].each do |path|
+        it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
+        it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
+        it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) }
       end
     end
   end
 end
-
old mode 100755 (executable)
new mode 100644 (file)
index 409b3dc..c00d512
@@ -1,19 +1,18 @@
 require 'spec_helper'
 
 describe 'validate_array' do
-
   describe 'signature validation' do
-    after(:all) do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     it { is_expected.not_to eq(nil) }
     # Checking for deprecation warning
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params([])
     end
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
     describe 'valid inputs' do
       it { is_expected.to run.with_params([]) }
@@ -23,15 +22,14 @@ describe 'validate_array' do
     end
 
     describe 'invalid inputs' do
-      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not an Array/) }
-      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not an Array/) }
-      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not an Array/) }
-      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not an Array/) }
-      it { is_expected.to run.with_params([], {}).and_raise_error(Puppet::ParseError, /is not an Array/) }
-      it { is_expected.to run.with_params([], 1).and_raise_error(Puppet::ParseError, /is not an Array/) }
-      it { is_expected.to run.with_params([], true).and_raise_error(Puppet::ParseError, /is not an Array/) }
-      it { is_expected.to run.with_params([], 'one').and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not an Array}) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not an Array}) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not an Array}) }
+      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not an Array}) }
+      it { is_expected.to run.with_params([], {}).and_raise_error(Puppet::ParseError, %r{is not an Array}) }
+      it { is_expected.to run.with_params([], 1).and_raise_error(Puppet::ParseError, %r{is not an Array}) }
+      it { is_expected.to run.with_params([], true).and_raise_error(Puppet::ParseError, %r{is not an Array}) }
+      it { is_expected.to run.with_params([], 'one').and_raise_error(Puppet::ParseError, %r{is not an Array}) }
     end
   end
 end
-
old mode 100755 (executable)
new mode 100644 (file)
index 4236649..2dd0df8
@@ -1,21 +1,19 @@
 require 'spec_helper'
 
 describe 'validate_augeas' do
-  unless Puppet.features.augeas?
-    skip "ruby-augeas not installed"
-  else
+  if Puppet.features.augeas?
     describe 'signature validation' do
       it { is_expected.not_to eq(nil) }
-      it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-      it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-      it { is_expected.to run.with_params('', '', [], '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+      it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+      it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+      it { is_expected.to run.with_params('', '', [], '', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
       it { is_expected.to run.with_params('one', 'one', 'MSG to User', '4th arg').and_raise_error(NoMethodError) }
     end
 
     describe 'valid inputs' do
       inputs = [
-        [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns' ],
-        [ "proc /proc   proc    nodev,noexec,nosuid     0       0\n", 'Fstab.lns'],
+        ["root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns'],
+        ["proc /proc   proc    nodev,noexec,nosuid     0       0\n", 'Fstab.lns'],
       ]
 
       inputs.each do |input|
@@ -28,32 +26,32 @@ describe 'validate_augeas' do
       # don't specify an error message to display.  This is the behvior in
       # 2.2.x and prior.
       inputs = [
-        [ "root:x:0:0:root\n", 'Passwd.lns' ],
-        [ "127.0.1.1\n", 'Hosts.lns' ],
+        ["root:x:0:0:root\n", 'Passwd.lns'],
+        ["127.0.1.1\n", 'Hosts.lns'],
       ]
 
       inputs.each do |input|
-        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /validate_augeas.*?matched less than it should/) }
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, %r{validate_augeas.*?matched less than it should}) }
       end
     end
 
-    describe "when specifying nice error messages" do
+    describe 'when specifying nice error messages' do
       # The intent here is to make sure the function returns the 4th argument
       # in the exception thrown
       inputs = [
-        [ "root:x:0:0:root\n", 'Passwd.lns', [], 'Failed to validate passwd content' ],
-        [ "127.0.1.1\n", 'Hosts.lns', [], 'Wrong hosts content' ],
+        ["root:x:0:0:root\n", 'Passwd.lns', [], 'Failed to validate passwd content'],
+        ["127.0.1.1\n", 'Hosts.lns', [], 'Wrong hosts content'],
       ]
 
       inputs.each do |input|
-        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /#{input[3]}/) }
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, %r{#{input[3]}}) }
       end
     end
 
-    describe "matching additional tests" do
+    describe 'matching additional tests' do
       inputs = [
-        [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']],
-        [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']],
+        ["root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']],
+        ["root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']],
       ]
 
       inputs.each do |input|
@@ -61,15 +59,17 @@ describe 'validate_augeas' do
       end
     end
 
-    describe "failing additional tests" do
+    describe 'failing additional tests' do
       inputs = [
-        [ "foobar:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']],
-        [ "root:x:0:0:root:/root:/bin/sh\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']],
+        ["foobar:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']],
+        ["root:x:0:0:root:/root:/bin/sh\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']],
       ]
 
       inputs.each do |input|
-        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /testing path/) }
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, %r{testing path}) }
       end
     end
+  else
+    skip 'ruby-augeas not installed'
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 3074d88..e7ca1e2
@@ -1,20 +1,20 @@
 require 'spec_helper'
 
 describe 'validate_bool' do
-  after(:all) do
+  after(:each) do
     ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
   # Checking for deprecation warning
-  it 'should display a single deprecation' do
-    ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-    scope.expects(:warning).with(includes('This method is deprecated'))
+  it 'displays a single deprecation' do
+    ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+    expect(scope).to receive(:warning).with(include('This method is deprecated'))
     is_expected.to run.with_params(true)
   end
 
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
   describe 'acceptable values' do
@@ -24,13 +24,13 @@ describe 'validate_bool' do
   end
 
   describe 'validation failures' do
-    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a boolean/) }
-    it { is_expected.to run.with_params(true, 'one').and_raise_error(Puppet::ParseError, /is not a boolean/) }
-    it { is_expected.to run.with_params('one', false).and_raise_error(Puppet::ParseError, /is not a boolean/) }
-    it { is_expected.to run.with_params("true").and_raise_error(Puppet::ParseError, /is not a boolean/) }
-    it { is_expected.to run.with_params("false").and_raise_error(Puppet::ParseError, /is not a boolean/) }
-    it { is_expected.to run.with_params(true, "false").and_raise_error(Puppet::ParseError, /is not a boolean/) }
-    it { is_expected.to run.with_params("true", false).and_raise_error(Puppet::ParseError, /is not a boolean/) }
-    it { is_expected.to run.with_params("true", false, false, false, false, false).and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
+    it { is_expected.to run.with_params(true, 'one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
+    it { is_expected.to run.with_params('one', false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
+    it { is_expected.to run.with_params('true').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
+    it { is_expected.to run.with_params('false').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
+    it { is_expected.to run.with_params(true, 'false').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
+    it { is_expected.to run.with_params('true', false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
+    it { is_expected.to run.with_params('true', false, false, false, false, false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index c6559e8..91fd0d1
@@ -1,35 +1,41 @@
 require 'spec_helper'
 
 describe 'validate_cmd', :unless => Puppet::Util::Platform.windows? do
-  let(:touch) { File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' }
+  let(:touch) { File.exist?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' }
 
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
     it {
       pending('should implement stricter type checking')
-      is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /content must be a string/)
+      is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, %r{content must be a string})
     }
     it {
       pending('should implement stricter type checking')
-      is_expected.to run.with_params('', [], '').and_raise_error(Puppet::ParseError, /checkscript must be a string/)
+      is_expected.to run.with_params('', [], '').and_raise_error(Puppet::ParseError, %r{checkscript must be a string})
     }
     it {
       pending('should implement stricter type checking')
-      is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, /custom error message must be a string/)
+      is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, %r{custom error message must be a string})
     }
   end
 
   context 'when validation fails' do
     context 'with % placeholder' do
-      it { is_expected.to run.with_params('', "#{touch} % /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \S+ \/no\/such\/file' returned 1:.*(cannot touch|o such file or)/) }
-      it { is_expected.to run.with_params('', "#{touch} % /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
+      it {
+        is_expected.to run
+          .with_params('', "#{touch} % /no/such/file").and_raise_error(Puppet::ParseError, %r{Execution of '#{touch} \S+ \/no\/such\/file' returned 1:.*(cannot touch|o such file or)})
+      }
+      it { is_expected.to run.with_params('', "#{touch} % /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) }
     end
     context 'without % placeholder' do
-      it { is_expected.to run.with_params('', "#{touch} /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \/no\/such\/file \S+' returned 1:.*(cannot touch|o such file or)/) }
-      it { is_expected.to run.with_params('', "#{touch} /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
+      it {
+        is_expected.to run
+          .with_params('', "#{touch} /no/such/file").and_raise_error(Puppet::ParseError, %r{Execution of '#{touch} \/no\/such\/file \S+' returned 1:.*(cannot touch|o such file or)})
+      }
+      it { is_expected.to run.with_params('', "#{touch} /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) }
     end
   end
 end
index 69fcae4..0ac1a3d 100644 (file)
@@ -3,7 +3,7 @@ require 'spec_helper'
 describe 'validate_domain_name' do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
   describe 'valid inputs' do
@@ -16,20 +16,20 @@ describe 'validate_domain_name' do
   end
 
   describe 'invalid inputs' do
-    it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
 
-    it { is_expected.to run.with_params('foo.example.com', []).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('foo.example.com', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('foo.example.com', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('foo.example.com', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('foo.example.com', []).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('foo.example.com', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('foo.example.com', 1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('foo.example.com', true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
 
-    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) }
-    it { is_expected.to run.with_params('invalid domain').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) }
-    it { is_expected.to run.with_params('-foo.example.com').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) }
-    it { is_expected.to run.with_params('www.example.2com').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) }
-    it { is_expected.to run.with_params('192.168.1.1').and_raise_error(Puppet::ParseError, /is not a syntactically correct domain name/) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) }
+    it { is_expected.to run.with_params('invalid domain').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) }
+    it { is_expected.to run.with_params('-foo.example.com').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) }
+    it { is_expected.to run.with_params('www.example.2com').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) }
+    it { is_expected.to run.with_params('192.168.1.1').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) }
   end
 end
index 7628383..520c7a4 100644 (file)
@@ -3,7 +3,7 @@ require 'spec_helper'
 describe 'validate_email_address' do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
   describe 'valid inputs' do
@@ -12,12 +12,12 @@ describe 'validate_email_address' do
   end
 
   describe 'invalid inputs' do
-    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid email/) }
-    it { is_expected.to run.with_params('bob@gmail.com', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('bob@gmail.com', true).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('bob@gmail.com', 'one').and_raise_error(Puppet::ParseError, /is not a valid email/) }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a valid email}) }
+    it { is_expected.to run.with_params('bob@gmail.com', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('bob@gmail.com', true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('bob@gmail.com', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid email}) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 7533abe..f71d0c3
@@ -3,36 +3,36 @@ require 'spec_helper'
 describe 'validate_hash' do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
     describe 'check for deprecation warning' do
-      after(:all) do
+      after(:each) do
         ENV.delete('STDLIB_LOG_DEPRECATIONS')
       end
       # Checking for deprecation warning
-      it 'should display a single deprecation' do
-        ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-        scope.expects(:warning).with(includes('This method is deprecated'))
-        is_expected.to run.with_params({'key' => 'value'})
+      it 'displays a single deprecation' do
+        ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+        expect(scope).to receive(:warning).with(include('This method is deprecated'))
+        is_expected.to run.with_params('key' => 'value')
       end
     end
 
     describe 'valid inputs' do
       it { is_expected.to run.with_params({}) }
-      it { is_expected.to run.with_params({'key' => 'value'}) }
-      it { is_expected.to run.with_params({}, {'key' => 'value'}) }
-      it { is_expected.to run.with_params({'key1' => 'value1'}, {'key2' => 'value2'}) }
+      it { is_expected.to run.with_params('key' => 'value') }
+      it { is_expected.to run.with_params({}, 'key' => 'value') }
+      it { is_expected.to run.with_params({ 'key1' => 'value1' }, 'key2' => 'value2') }
     end
 
     describe 'invalid inputs' do
-      it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a Hash/) }
-      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a Hash/) }
-      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a Hash/) }
-      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a Hash/) }
-      it { is_expected.to run.with_params({}, []).and_raise_error(Puppet::ParseError, /is not a Hash/) }
-      it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /is not a Hash/) }
-      it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, /is not a Hash/) }
-      it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
+      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
+      it { is_expected.to run.with_params({}, []).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
+      it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
+      it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
+      it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 6558d00..cf29cf8
@@ -1,41 +1,41 @@
 require 'spec_helper'
 
 describe 'validate_integer' do
-  after(:all) do
+  after(:each) do
     ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
   # Checking for deprecation warning
-  it 'should display a single deprecation' do
-    ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-    scope.expects(:warning).with(includes('This method is deprecated'))
+  it 'displays a single deprecation' do
+    ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+    expect(scope).to receive(:warning).with(include('This method is deprecated'))
     is_expected.to run.with_params(3)
   end
 
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
-    [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', 7.0, -7.0, {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x'].each do |invalid|
-      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /to be an Integer/) }
-      it { is_expected.to run.with_params(invalid, 10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
-      it { is_expected.to run.with_params(invalid, 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
-      it { is_expected.to run.with_params([0, 1, 2, invalid, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
+    [true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', 7.0, -7.0, {}, { 'key' => 'value' }, { 1 => 2 }, '', :undef, 'x'].each do |invalid|
+      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, %r{to be an Integer}) }
+      it { is_expected.to run.with_params(invalid, 10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) }
+      it { is_expected.to run.with_params(invalid, 10, -10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) }
+      it { is_expected.to run.with_params([0, 1, 2, invalid, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) }
     end
 
     context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do
-      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
+      it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) }
     end
 
     context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do
-      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
-      it { is_expected.to run.with_params([0, 1, 2, {0=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+      it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+      it { is_expected.to run.with_params([0, 1, 2, { 0 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
     end
 
-    it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, /to be unset or an Integer/) }
-    it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, /to be unset or an Integer/) }
-    it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, /second argument to be larger than third argument/) }
+    it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, %r{to be unset or an Integer}) }
+    it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, %r{to be unset or an Integer}) }
+    it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, %r{second argument to be larger than third argument}) }
   end
 
   context 'with no range constraints' do
@@ -47,12 +47,12 @@ describe 'validate_integer' do
     it { is_expected.to run.with_params([1, '2', '3', 4]) }
   end
 
-  context "with a maximum limit of 10" do
+  context 'with a maximum limit of 10' do
     describe 'rejects numbers greater than the limit' do
-      it { is_expected.to run.with_params(11, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      it { is_expected.to run.with_params(100, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      it { is_expected.to run.with_params(2**65, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      it { is_expected.to run.with_params([1,2,10,100], 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params(11, 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(100, 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(2**65, 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params([1, 2, 10, 100], 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
     end
 
     describe 'accepts numbers less or equal to the limit' do
@@ -64,32 +64,32 @@ describe 'validate_integer' do
       it { is_expected.to run.with_params([1, 2, 3, 4], 10) }
       it { is_expected.to run.with_params([1, '2', '3', 4], 10) }
     end
+  end
 
-    context "with a minimum limit of -10" do
-      describe 'rejects numbers greater than the upper limit' do
-        it { is_expected.to run.with_params(11, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-        it { is_expected.to run.with_params(100, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-        it { is_expected.to run.with_params(2**65, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-        it { is_expected.to run.with_params([1,2,10,100], 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      end
+  context 'with a minimum limit of -10' do
+    describe 'rejects numbers greater than the upper limit' do
+      it { is_expected.to run.with_params(11, 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(100, 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(2**65, 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params([1, 2, 10, 100], 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+    end
 
-      describe 'rejects numbers smaller than the lower limit' do
-        it { is_expected.to run.with_params(-11, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-        it { is_expected.to run.with_params(-100, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-        it { is_expected.to run.with_params(-2**65, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-        it { is_expected.to run.with_params([-10, 1,2,10,-100], 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-      end
+    describe 'rejects numbers smaller than the lower limit' do
+      it { is_expected.to run.with_params(-11, 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+      it { is_expected.to run.with_params(-100, 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+      it { is_expected.to run.with_params(-2**65, 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+      it { is_expected.to run.with_params([-10, 1, 2, 10, -100], 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+    end
 
-      describe 'accepts numbers between and including the limits' do
-        it { is_expected.to run.with_params(10, 10, -10) }
-        it { is_expected.to run.with_params(-10, 10, -10) }
-        it { is_expected.to run.with_params(1, 10, -10) }
-        it { is_expected.to run.with_params(-1, 10, -10) }
-        it { is_expected.to run.with_params('1', 10, -10) }
-        it { is_expected.to run.with_params('-1', 10, -10) }
-        it { is_expected.to run.with_params([1, 2, 3, 4], 10, -10) }
-        it { is_expected.to run.with_params([1, '2', '3', 4], 10, -10) }
-      end
+    describe 'accepts numbers between and including the limits' do
+      it { is_expected.to run.with_params(10, 10, -10) }
+      it { is_expected.to run.with_params(-10, 10, -10) }
+      it { is_expected.to run.with_params(1, 10, -10) }
+      it { is_expected.to run.with_params(-1, 10, -10) }
+      it { is_expected.to run.with_params('1', 10, -10) }
+      it { is_expected.to run.with_params('-1', 10, -10) }
+      it { is_expected.to run.with_params([1, 2, 3, 4], 10, -10) }
+      it { is_expected.to run.with_params([1, '2', '3', 4], 10, -10) }
     end
   end
 
index 0414f5e..8fd145e 100644 (file)
@@ -1,10 +1,9 @@
 require 'spec_helper'
 
 describe 'validate_ip_address' do
-
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
   describe 'valid inputs' do
@@ -21,23 +20,23 @@ describe 'validate_ip_address' do
     it { is_expected.to run.with_params('::1/64') }
     it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') }
 
-    context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
-      after(:all) do
+    context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do
+      after(:each) do
         ENV.delete('STDLIB_LOG_DEPRECATIONS')
       end
       # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-      it 'should display a single deprecation' do
-        ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-        scope.expects(:warning).with(includes('This method is deprecated'))
+      it 'displays a single deprecation' do
+        ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+        expect(scope).to receive(:warning).with(include('This method is deprecated'))
         is_expected.to run.with_params('1.2.3.4')
       end
-      it 'should display no warning for deprecation' do
-        ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-        scope.expects(:warning).with(includes('This method is deprecated')).never
+      it 'displays no warning for deprecation' do
+        ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+        expect(scope).to receive(:warning).with(include('This method is deprecated')).never
         is_expected.to run.with_params('1.2.3.4')
       end
     end
-    
+
     context 'with netmasks' do
       it { is_expected.to run.with_params('8.8.8.8/0') }
       it { is_expected.to run.with_params('8.8.8.8/16') }
@@ -47,19 +46,19 @@ describe 'validate_ip_address' do
   end
 
   describe 'invalid inputs' do
-    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
-    it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
-    it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
-    it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
-    it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
-    it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) }
+    it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) }
+    it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) }
+    it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) }
+    it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) }
+    it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 6e4ca05..0a1a433
@@ -1,25 +1,24 @@
 require 'spec_helper'
 
 describe 'validate_ipv4_address' do
-
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
-  context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
-    after(:all) do
+  context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
     end
   end
@@ -29,13 +28,13 @@ describe 'validate_ipv4_address' do
   end
 
   SharedData::IPV4_NEGATIVE_PATTERNS.each do |value|
-    it { is_expected.to run.with_params(value).and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+    it { is_expected.to run.with_params(value).and_raise_error(Puppet::ParseError, %r{is not a valid IPv4}) }
   end
 
   describe 'invalid inputs' do
-    [ {}, [], 1, true ].each do |invalid|
-      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first, invalid).and_raise_error(Puppet::ParseError, /is not a string/) }
+    [{}, [], 1, true].each do |invalid|
+      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first, invalid).and_raise_error(Puppet::ParseError, %r{is not a string}) }
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 137db36..0834307
@@ -1,28 +1,27 @@
 require 'spec_helper'
 
 describe 'validate_ipv6_address' do
-  
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
-  context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
-    after(:all) do
+  context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do
+    after(:each) do
       ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
-    it 'should display a single deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-      scope.expects(:warning).with(includes('This method is deprecated'))
+    it 'displays a single deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+      expect(scope).to receive(:warning).with(include('This method is deprecated'))
       is_expected.to run.with_params('3ffe:0505:0002::')
     end
-    it 'should display no warning for deprecation' do
-      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
-      scope.expects(:warning).with(includes('This method is deprecated')).never
+    it 'displays no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
+      expect(scope).to receive(:warning).with(include('This method is deprecated')).never
       is_expected.to run.with_params('3ffe:0505:0002::')
     end
-  end 
+  end
 
   describe 'valid inputs' do
     it { is_expected.to run.with_params('3ffe:0505:0002::') }
@@ -39,22 +38,22 @@ describe 'validate_ipv6_address' do
   end
 
   describe 'invalid inputs' do
-    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('::ffff:2.3.4').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('::ffff:257.1.2.3').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('::ffff:12345678901234567890.1.26').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
-    it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) }
-    it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('::ffff:2.3.4').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('::ffff:257.1.2.3').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('::ffff:12345678901234567890.1.26').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
+    it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+    it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) }
     context 'unless running on ruby 1.8.7', :if => RUBY_VERSION != '1.8.7' do
-      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params('::1', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params('::1', 1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
     end
   end
 end
index 7b48f12..6c65d5e 100644 (file)
@@ -6,61 +6,49 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.4.0') >= 0
     it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
 
     describe 'when passing the type assertion and passing the previous validation' do
-      before do
-        scope.expects(:function_validate_foo).with([5]).once
-        Puppet.expects(:notice).never
-      end
       it 'passes without notice' do
+        expect(scope).to receive(:function_validate_foo).with([5]).once
+        expect(Puppet).to receive(:notice).never
         is_expected.to run.with_params('Integer', 'validate_foo', 5)
       end
     end
 
     describe 'when passing the type assertion and failing the previous validation' do
-      before do
-        scope.expects(:function_validate_foo).with([5]).raises(Puppet::ParseError, 'foo').once
-        Puppet.expects(:notice).with(includes('Accepting previously invalid value for target type'))
-      end
       it 'passes with a notice about newly accepted value' do
+        expect(scope).to receive(:function_validate_foo).with([5]).and_raise(Puppet::ParseError, 'foo').once
+        expect(Puppet).to receive(:notice).with(include('Accepting previously invalid value for target type'))
         is_expected.to run.with_params('Integer', 'validate_foo', 5)
       end
     end
 
     describe 'when failing the type assertion and passing the previous validation' do
-      before do
-        scope.expects(:function_validate_foo).with(['5']).once
-        subject.func.expects(:call_function).with('deprecation', 'validate_legacy', includes('Integer')).once
-      end
       it 'passes with a deprecation message' do
+        expect(scope).to receive(:function_validate_foo).with(['5']).once
+        expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('Integer')).once
         is_expected.to run.with_params('Integer', 'validate_foo', '5')
       end
     end
 
     describe 'when failing the type assertion and failing the previous validation' do
-      before do
-        scope.expects(:function_validate_foo).with(['5']).raises(Puppet::ParseError, 'foo').once
-        subject.func.expects(:call_function).with('fail', includes('Integer')).once
-      end
       it 'fails with a helpful message' do
+        expect(scope).to receive(:function_validate_foo).with(['5']).and_raise(Puppet::ParseError, 'foo').once
+        expect(subject.func).to receive(:call_function).with('fail', include('Integer')).once
         is_expected.to run.with_params('Integer', 'validate_foo', '5')
       end
     end
 
     describe 'when passing in undef' do
-      before do
-        scope.expects(:function_validate_foo).with([:undef]).once
-        Puppet.expects(:notice).never
-      end
       it 'works' do
+        expect(scope).to receive(:function_validate_foo).with([:undef]).once
+        expect(Puppet).to receive(:notice).never
         is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef)
       end
     end
 
     describe 'when passing in multiple arguments' do
-      before do
-        scope.expects(:function_validate_foo).with([:undef, 1, 'foo']).once
-        Puppet.expects(:notice).never
-      end
       it 'passes with a deprecation message' do
+        expect(scope).to receive(:function_validate_foo).with([:undef, 1, 'foo']).once
+        expect(Puppet).to receive(:notice).never
         is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef, 1, 'foo')
       end
     end
old mode 100755 (executable)
new mode 100644 (file)
index 4c0e24d..80b3e37
@@ -1,40 +1,40 @@
 require 'spec_helper'
 
 describe 'validate_numeric' do
-  after(:all) do
+  after(:each) do
     ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
-  
+
   # Checking for deprecation warning
-  it 'should display a single deprecation' do
-    ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-    scope.expects(:warning).with(includes('This method is deprecated'))
+  it 'displays a single deprecation' do
+    ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+    expect(scope).to receive(:warning).with(include('This method is deprecated'))
     is_expected.to run.with_params(3)
   end
 
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
-    [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x'].each do |invalid|
-      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
-      it { is_expected.to run.with_params(invalid, 10.0).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
-      it { is_expected.to run.with_params(invalid, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
+    [true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1 => 2 }, '', :undef, 'x'].each do |invalid|
+      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) }
+      it { is_expected.to run.with_params(invalid, 10.0).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) }
+      it { is_expected.to run.with_params(invalid, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) }
     end
 
     context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do
-      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
+      it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) }
     end
 
     context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do
-      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
-      it { is_expected.to run.with_params([0, 1, 2, {0=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+      it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+      it { is_expected.to run.with_params([0, 1, 2, { 0 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
     end
 
-    it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, /to be unset or a Numeric/) }
-    it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, /to be unset or a Numeric/) }
-    it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, /second argument to be larger than third argument/) }
+    it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, %r{to be unset or a Numeric}) }
+    it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, %r{to be unset or a Numeric}) }
+    it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, %r{second argument to be larger than third argument}) }
   end
 
   context 'with no range constraints' do
@@ -46,12 +46,12 @@ describe 'validate_numeric' do
     it { is_expected.to run.with_params([1, '2', '3', 4]) }
   end
 
-  context "with a maximum limit of 10.0" do
+  context 'with a maximum limit of 10.0' do
     describe 'rejects numbers greater than the limit' do
-      it { is_expected.to run.with_params(11, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      it { is_expected.to run.with_params(100, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      it { is_expected.to run.with_params(2**65, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      it { is_expected.to run.with_params([1,2,10.0,100], 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params(11, 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(100, 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(2**65, 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params([1, 2, 10.0, 100], 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
     end
 
     describe 'accepts numbers less or equal to the limit' do
@@ -63,32 +63,32 @@ describe 'validate_numeric' do
       it { is_expected.to run.with_params([1, 2, 3, 4], 10.0) }
       it { is_expected.to run.with_params([1, '2', '3', 4], 10.0) }
     end
+  end
 
-    context "with a minimum limit of -10.0" do
-      describe 'rejects numbers greater than the upper limit' do
-        it { is_expected.to run.with_params(11, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-        it { is_expected.to run.with_params(100, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-        it { is_expected.to run.with_params(2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-        it { is_expected.to run.with_params([1,2,10.0,100], 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
-      end
+  context 'with a minimum limit of -10.0' do
+    describe 'rejects numbers greater than the upper limit' do
+      it { is_expected.to run.with_params(11, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(100, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params(2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+      it { is_expected.to run.with_params([1, 2, 10.0, 100], 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) }
+    end
 
-      describe 'rejects numbers smaller than the lower limit' do
-        it { is_expected.to run.with_params(-11, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-        it { is_expected.to run.with_params(-100, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-        it { is_expected.to run.with_params(-2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-        it { is_expected.to run.with_params([-10.0, 1,2,10.0,-100], 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
-      end
+    describe 'rejects numbers smaller than the lower limit' do
+      it { is_expected.to run.with_params(-11, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+      it { is_expected.to run.with_params(-100, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+      it { is_expected.to run.with_params(-2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+      it { is_expected.to run.with_params([-10.0, 1, 2, 10.0, -100], 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) }
+    end
 
-      describe 'accepts numbers between and including the limits' do
-        it { is_expected.to run.with_params(10.0, 10.0, -10.0) }
-        it { is_expected.to run.with_params(-10.0, 10.0, -10.0) }
-        it { is_expected.to run.with_params(1, 10.0, -10.0) }
-        it { is_expected.to run.with_params(-1, 10.0, -10.0) }
-        it { is_expected.to run.with_params('1', 10.0, -10.0) }
-        it { is_expected.to run.with_params('-1', 10.0, -10.0) }
-        it { is_expected.to run.with_params([1, 2, 3, 4], 10.0, -10.0) }
-        it { is_expected.to run.with_params([1, '2', '3', 4], 10.0, -10.0) }
-      end
+    describe 'accepts numbers between and including the limits' do
+      it { is_expected.to run.with_params(10.0, 10.0, -10.0) }
+      it { is_expected.to run.with_params(-10.0, 10.0, -10.0) }
+      it { is_expected.to run.with_params(1, 10.0, -10.0) }
+      it { is_expected.to run.with_params(-1, 10.0, -10.0) }
+      it { is_expected.to run.with_params('1', 10.0, -10.0) }
+      it { is_expected.to run.with_params('-1', 10.0, -10.0) }
+      it { is_expected.to run.with_params([1, 2, 3, 4], 10.0, -10.0) }
+      it { is_expected.to run.with_params([1, '2', '3', 4], 10.0, -10.0) }
     end
   end
 
old mode 100755 (executable)
new mode 100644 (file)
index 3531182..270e2b1
@@ -1,55 +1,55 @@
 require 'spec_helper'
 
 describe 'validate_re' do
-  after(:all) do
+  after(:each) do
     ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
   # Checking for deprecation warning
-  it 'should display a single deprecation' do
-    ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-    scope.expects(:warning).with(includes('This method is deprecated'))
+  it 'displays a single deprecation' do
+    ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+    expect(scope).to receive(:warning).with(include('This method is deprecated'))
     is_expected.to run.with_params('', '')
   end
 
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
     describe 'valid inputs' do
       it { is_expected.to run.with_params('', '') }
       it { is_expected.to run.with_params('', ['']) }
       it { is_expected.to run.with_params('', [''], 'custom error') }
       it { is_expected.to run.with_params('one', '^one') }
-      it { is_expected.to run.with_params('one', [ '^one', '^two' ]) }
-      it { is_expected.to run.with_params('one', [ '^one', '^two' ], 'custom error') }
+      it { is_expected.to run.with_params('one', ['^one', '^two']) }
+      it { is_expected.to run.with_params('one', ['^one', '^two'], 'custom error') }
     end
 
     describe 'invalid inputs' do
-      it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, /does not match/) }
-      it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
-      it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
-      it { is_expected.to run.with_params('', ['two']).and_raise_error(Puppet::ParseError, /does not match/) }
-      it { is_expected.to run.with_params('', ['two'], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
-      it { is_expected.to run.with_params('notone', '^one').and_raise_error(Puppet::ParseError, /does not match/) }
-      it { is_expected.to run.with_params('notone', [ '^one', '^two' ]).and_raise_error(Puppet::ParseError, /does not match/) }
-      it { is_expected.to run.with_params('notone', [ '^one', '^two' ], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
+      it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, %r{does not match}) }
+      it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{does not match}) }
+      it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, %r{does not match}) }
+      it { is_expected.to run.with_params('', ['two']).and_raise_error(Puppet::ParseError, %r{does not match}) }
+      it { is_expected.to run.with_params('', ['two'], 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) }
+      it { is_expected.to run.with_params('notone', '^one').and_raise_error(Puppet::ParseError, %r{does not match}) }
+      it { is_expected.to run.with_params('notone', ['^one', '^two']).and_raise_error(Puppet::ParseError, %r{does not match}) }
+      it { is_expected.to run.with_params('notone', ['^one', '^two'], 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) }
+    end
 
-      describe 'non-string inputs' do
-        [
-          1,             # Fixnum
-          3.14,          # Float
-          nil,           # NilClass
-          true,          # TrueClass
-          false,         # FalseClass
-          ["10"],        # Array
-          :key,          # Symbol
-          {:key=>"val"}, # Hash
-        ].each do |input|
-          it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, /needs to be a String/) }
-        end
+    describe 'non-string inputs' do
+      [
+        1,             # Fixnum
+        3.14,          # Float
+        nil,           # NilClass
+        true,          # TrueClass
+        false,         # FalseClass
+        ['10'],        # Array
+        :key,          # Symbol
+        { :key => 'val' }, # Hash
+      ].each do |input|
+        it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, %r{needs to be a String}) }
       end
     end
   end
old mode 100755 (executable)
new mode 100644 (file)
index e4162de..b11444d
@@ -1,72 +1,81 @@
 require 'spec_helper'
 
 describe 'validate_slength' do
-  after(:all) do
+  after(:each) do
     ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
   # Checking for deprecation warning
-  it 'should display a single deprecation' do
-    ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-    scope.expects(:warning).with(includes('This method is deprecated'))
+  it 'displays a single deprecation' do
+    ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+    expect(scope).to receive(:warning).with(include('This method is deprecated'))
     is_expected.to run.with_params('1234567890', 10)
   end
-  
+
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('', 2, 3, 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /second argument to be a positive Numeric/) }
-    it { is_expected.to run.with_params('', -1).and_raise_error(Puppet::ParseError, /second argument to be a positive Numeric/) }
-    it { is_expected.to run.with_params('', 1, '').and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) }
-    it { is_expected.to run.with_params('', 1, -1).and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) }
-    it { is_expected.to run.with_params('', 1, 2).and_raise_error(Puppet::ParseError, /argument to be equal to or larger than third argument/) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('', 2, 3, 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{second argument to be a positive Numeric}) }
+    it { is_expected.to run.with_params('', -1).and_raise_error(Puppet::ParseError, %r{second argument to be a positive Numeric}) }
+    it { is_expected.to run.with_params('', 1, '').and_raise_error(Puppet::ParseError, %r{third argument to be unset or a positive Numeric}) }
+    it { is_expected.to run.with_params('', 1, -1).and_raise_error(Puppet::ParseError, %r{third argument to be unset or a positive Numeric}) }
+    it { is_expected.to run.with_params('', 1, 2).and_raise_error(Puppet::ParseError, %r{argument to be equal to or larger than third argument}) }
   end
 
-  context "with a maximum length of 10" do
+  context 'with a maximum length of 10' do
     describe 'rejects strings longer than the limit' do
-      it { is_expected.to run.with_params('1234567890a', 10).and_raise_error(Puppet::ParseError, /Expected length/) }
-      it { is_expected.to run.with_params('1234567890abcdef', 10).and_raise_error(Puppet::ParseError, /Expected length/) }
-      it { is_expected.to run.with_params([ 'one', '1234567890abcdef' ], 10).and_raise_error(Puppet::ParseError, /Expected length/) }
+      it { is_expected.to run.with_params('1234567890a', 10).and_raise_error(Puppet::ParseError, %r{Expected length}) }
+      it { is_expected.to run.with_params('1234567890abcdef', 10).and_raise_error(Puppet::ParseError, %r{Expected length}) }
+      it { is_expected.to run.with_params(['one', '1234567890abcdef'], 10).and_raise_error(Puppet::ParseError, %r{Expected length}) }
     end
 
     describe 'accepts strings shorter or equal to the limit' do
       it { is_expected.to run.with_params('1234567890', 10) }
       it { is_expected.to run.with_params('12345', 10) }
-      it { is_expected.to run.with_params([ 'one', 'two' ], 10) }
+      it { is_expected.to run.with_params(['one', 'two'], 10) }
     end
+  end
 
-    context "with a minimum length of 5" do
-      describe 'rejects strings longer than the upper limit' do
-        it { is_expected.to run.with_params('1234567890a', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
-        it { is_expected.to run.with_params('1234567890abcdef', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
-      end
+  context 'with a minimum length of 5' do
+    describe 'rejects strings longer than the upper limit' do
+      it { is_expected.to run.with_params('1234567890a', 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) }
+      it { is_expected.to run.with_params('1234567890abcdef', 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) }
+    end
 
-      describe 'rejects numbers shorter than the lower limit' do
-        it { is_expected.to run.with_params('one', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
-        it { is_expected.to run.with_params(['12345678', 'two'], 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
-      end
+    describe 'rejects numbers shorter than the lower limit' do
+      it { is_expected.to run.with_params('one', 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) }
+      it { is_expected.to run.with_params(['12345678', 'two'], 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) }
+    end
 
-      describe 'accepts strings of length between and including the limits' do
-        it { is_expected.to run.with_params('12345', 10, 5) }
-        it { is_expected.to run.with_params('123456', 10, 5) }
-        it { is_expected.to run.with_params('1234567', 10, 5) }
-        it { is_expected.to run.with_params('12345678', 10, 5) }
-        it { is_expected.to run.with_params('123456789', 10, 5) }
-        it { is_expected.to run.with_params('1234567890', 10, 5) }
-        it { is_expected.to run.with_params(['1233456', '12345678'], 10, 5) }
-      end
+    describe 'accepts strings of length between and including the limits' do
+      it { is_expected.to run.with_params('12345', 10, 5) }
+      it { is_expected.to run.with_params('123456', 10, 5) }
+      it { is_expected.to run.with_params('1234567', 10, 5) }
+      it { is_expected.to run.with_params('12345678', 10, 5) }
+      it { is_expected.to run.with_params('123456789', 10, 5) }
+      it { is_expected.to run.with_params('1234567890', 10, 5) }
+      it { is_expected.to run.with_params(['1233456', '12345678'], 10, 5) }
     end
   end
 
   describe 'corner cases' do
-    it { pending('this should work'); is_expected.to run.with_params('', 0, 0) }
+    it {
+      pending('this should work')
+      is_expected.to run.with_params('', 0, 0)
+    }
     it { is_expected.to run.with_params('1234567890', 10, 10) }
   end
 
   describe 'empty upper limit is interpreted as infinity' do
-    it { pending('not implemented'); is_expected.to run.with_params('1234567890ab', '', 10) }
-    it { pending('not implemented'); is_expected.to run.with_params('12345678', '', 10).and_raise_error(Puppet::ParseError, /Expected length/) }
+    it {
+      pending('not implemented')
+      is_expected.to run.with_params('1234567890ab', '', 10)
+    }
+    it {
+      pending('not implemented')
+      is_expected.to run.with_params('12345678', '', 10).and_raise_error(Puppet::ParseError, %r{Expected length})
+    }
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 0907ede..27570d4
@@ -1,20 +1,20 @@
 require 'spec_helper'
 
 describe 'validate_string' do
-  after(:all) do
+  after(:each) do
     ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
-  
+
   # Checking for deprecation warning
-  it 'should display a single deprecation' do
-    ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
-    scope.expects(:warning).with(includes('This method is deprecated'))
+  it 'displays a single deprecation' do
+    ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
+    expect(scope).to receive(:warning).with(include('This method is deprecated'))
     is_expected.to run.with_params('', '')
   end
 
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
 
     describe 'valid inputs' do
       it { is_expected.to run.with_params('') }
@@ -24,10 +24,10 @@ describe 'validate_string' do
     end
 
     describe 'invalid inputs' do
-      it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
     end
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index eb63310..937c189
@@ -1,9 +1,8 @@
 require 'spec_helper'
 
 describe 'validate_x509_rsa_key_pair' do
-
   let(:valid_cert) do
-  <<EOS
+    <<DOC
 -----BEGIN CERTIFICATE-----
 MIIC9jCCAeCgAwIBAgIRAK11n3X7aypJ7FPM8UFyAeowCwYJKoZIhvcNAQELMBIx
 EDAOBgNVBAoTB0FjbWUgQ28wHhcNMTUxMTIzMjIzOTU4WhcNMTYxMTIyMjIzOTU4
@@ -22,11 +21,11 @@ IeAvBZHr4/kVXWnfo6kzCLcku1f8yE/yDEFClZe9XV1Lk/s+3YfXVtNnMJJ1giZI
 QVOe6CkmuQq+4AtIeW8aLkvlfp632jag1F77a1y+L268koKkj0hBMrtcErVQaxmq
 xym0+soR4Tk4pTIGckeFglrLxkP2JpM/yTwSEAVlmG9vgTliYKyR0uMl
 -----END CERTIFICATE-----
-EOS
+DOC
   end
 
   let(:valid_key) do
-  <<EOS
+    <<DOC
 -----BEGIN RSA PRIVATE KEY-----
 MIIEogIBAAKCAQEAz9bY/piKahD10AiJSfbI2A8NG5UwRz0r9T/WfvNVdhgrsGFg
 NQjvpUoZnNJpQIHBbgMOiXqfATFjJl5FjEkSf7GUHohlGVls9MX2JmVvknzsiitd
@@ -54,11 +53,11 @@ c7pZAoGATd9NckT0XtXLEsF3IraDivq8dP6bccX2DNfS8UeEvRRrRwpFpSRrmuGb
 jbG4yzoIX4RjQfj/z48hwhJB+cKiN9WwcPsFXtHe7v3F6BRwK0JUfrCiXad8/SGZ
 KAf7Dfqi608zBdnPWHacre2Y35gPHB00nFQOLS6u46aBNSq07YA=
 -----END RSA PRIVATE KEY-----
-EOS
+DOC
   end
 
   let(:another_valid_key) do
-  <<EOS
+    <<DOC
 -----BEGIN RSA PRIVATE KEY-----
 MIIEpAIBAAKCAQEAoISxYJBTPAeAzFnm+lE/ljLlmGal2Xr3vwZKkvJiuKA/m4QJ
 0ZNdtkBSDOVuG2dXVv6W4sChRtsCdvuVe7bjTYvlU8TWM3VEJDL9l9cRXScxxlKQ
@@ -86,15 +85,16 @@ B2ZXgoUCgYAGa13P0ggUf5BMJpBd8S08jKRyvZb1CDXcUCuGtk2yEx45ern9U5WY
 zJ13E5z9MKKO8nkGBqrRfjJa8Xhxk4HKNFuzHEet5lvNE7IKCF4YQRb0ZBhnb/78
 +4ZKjFki1RrWRNSw9TdvrK6qaDKgTtCTtfRVXAYQXUgq7lSFOTtL3A==
 -----END RSA PRIVATE KEY-----
-EOS
+DOC
   end
+  # rubocop:enable Layout/IndentHeredoc
 
   let(:valid_cert_but_indented) do
-    valid_cert.gsub(/^/, '  ')
+    valid_cert.gsub(%r{^}, '  ')
   end
 
   let(:valid_key_but_indented) do
-    valid_key.gsub(/^/, '  ')
+    valid_key.gsub(%r{^}, '  ')
   end
 
   let(:malformed_cert) do
@@ -113,58 +113,58 @@ EOS
     'bar'
   end
 
-  context 'function signature validation' do
+  context 'with function signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params(0, 1, 2, 3).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params(0, 1, 2, 3).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   end
 
-  context 'valid input' do
+  context 'with valid input' do
     describe 'valid certificate and key' do
       it { is_expected.to run.with_params(valid_cert, valid_key) }
     end
   end
 
-  context 'bad input' do
+  context 'with bad input' do
     describe 'valid certificate, valid but indented key' do
-      it { is_expected.to run.with_params(valid_cert, valid_key_but_indented).and_raise_error(Puppet::ParseError, /Not a valid RSA key/) }
+      it { is_expected.to run.with_params(valid_cert, valid_key_but_indented).and_raise_error(Puppet::ParseError, %r{Not a valid RSA key}) }
     end
 
     describe 'valid certificate, malformed key' do
-      it { is_expected.to run.with_params(valid_cert, malformed_key).and_raise_error(Puppet::ParseError, /Not a valid RSA key/) }
+      it { is_expected.to run.with_params(valid_cert, malformed_key).and_raise_error(Puppet::ParseError, %r{Not a valid RSA key}) }
     end
 
     describe 'valid certificate, bad key' do
-      it { is_expected.to run.with_params(valid_cert, bad_key).and_raise_error(Puppet::ParseError, /Not a valid RSA key/) }
+      it { is_expected.to run.with_params(valid_cert, bad_key).and_raise_error(Puppet::ParseError, %r{Not a valid RSA key}) }
     end
 
     describe 'valid but indented certificate, valid key' do
-      it { is_expected.to run.with_params(valid_cert_but_indented, valid_key).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+      it { is_expected.to run.with_params(valid_cert_but_indented, valid_key).and_raise_error(Puppet::ParseError, %r{Not a valid x509 certificate}) }
     end
 
     describe 'malformed certificate, valid key' do
-      it { is_expected.to run.with_params(malformed_cert, valid_key).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+      it { is_expected.to run.with_params(malformed_cert, valid_key).and_raise_error(Puppet::ParseError, %r{Not a valid x509 certificate}) }
     end
 
     describe 'bad certificate, valid key' do
-      it { is_expected.to run.with_params(bad_cert, valid_key).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+      it { is_expected.to run.with_params(bad_cert, valid_key).and_raise_error(Puppet::ParseError, %r{Not a valid x509 certificate}) }
     end
 
     describe 'validate certificate and key; certficate not signed by key' do
-      it { is_expected.to run.with_params(valid_cert, another_valid_key).and_raise_error(Puppet::ParseError, /Certificate signature does not match supplied key/) }
+      it { is_expected.to run.with_params(valid_cert, another_valid_key).and_raise_error(Puppet::ParseError, %r{Certificate signature does not match supplied key}) }
     end
 
     describe 'valid cert and key but arguments in wrong order' do
-      it { is_expected.to run.with_params(valid_key, valid_cert).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+      it { is_expected.to run.with_params(valid_key, valid_cert).and_raise_error(Puppet::ParseError, %r{Not a valid x509 certificate}) }
     end
 
     describe 'non-string arguments' do
-      it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params(true, true).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params("foo", {}).and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params(1, "bar").and_raise_error(Puppet::ParseError, /is not a string/) }
-      it { is_expected.to run.with_params("baz", true).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params(true, true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params('foo', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params(1, 'bar').and_raise_error(Puppet::ParseError, %r{is not a string}) }
+      it { is_expected.to run.with_params('baz', true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
     end
   end
 
@@ -175,6 +175,6 @@ EOS
     end_pos = middle + (chars_to_truncate / 2)
 
     string[start_pos...end_pos] = ''
-    return string
+    string
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 681c101..048f270
@@ -3,31 +3,31 @@ require 'spec_helper'
 describe 'values_at' do
   describe 'signature validation' do
     it { is_expected.not_to eq(nil) }
-    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-    it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+    it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
     it {
-      pending("Current implementation ignores parameters after the first two.")
-      is_expected.to run.with_params([], 0, 1).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+      pending('Current implementation ignores parameters after the first two.')
+      is_expected.to run.with_params([], 0, 1).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
     }
-    it { is_expected.to run.with_params('', 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
-    it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
-    it { is_expected.to run.with_params(true, 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
-    it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
-    it { is_expected.to run.with_params([0,1,2], 'two').and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
-    it { is_expected.to run.with_params([0,1,2], []).and_raise_error(Puppet::ParseError, /provide at least one positive index/) }
-    it { is_expected.to run.with_params([0,1,2], '-1-1').and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
-    it { is_expected.to run.with_params([0,1,2], '2-1').and_raise_error(Puppet::ParseError, /Stop index in given indices range is smaller than the start index/) }
+    it { is_expected.to run.with_params('', 1).and_raise_error(Puppet::ParseError, %r{Requires array}i) }
+    it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{Requires array}i) }
+    it { is_expected.to run.with_params(true, 1).and_raise_error(Puppet::ParseError, %r{Requires array}i) }
+    it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, %r{Requires array}i) }
+    it { is_expected.to run.with_params([0, 1, 2], 'two').and_raise_error(Puppet::ParseError, %r{Unknown format of given index}) }
+    it { is_expected.to run.with_params([0, 1, 2], []).and_raise_error(Puppet::ParseError, %r{provide at least one positive index}) }
+    it { is_expected.to run.with_params([0, 1, 2], '-1-1').and_raise_error(Puppet::ParseError, %r{Unknown format of given index}) }
+    it { is_expected.to run.with_params([0, 1, 2], '2-1').and_raise_error(Puppet::ParseError, %r{Stop index in given indices range is smaller than the start index}) }
   end
 
   context 'when requesting a single item' do
-    it { is_expected.to run.with_params([0, 1, 2], -1).and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
+    it { is_expected.to run.with_params([0, 1, 2], -1).and_raise_error(Puppet::ParseError, %r{Unknown format of given index}) }
     it { is_expected.to run.with_params([0, 1, 2], 0).and_return([0]) }
     it { is_expected.to run.with_params([0, 1, 2], 1).and_return([1]) }
     it { is_expected.to run.with_params([0, 1, 2], [1]).and_return([1]) }
     it { is_expected.to run.with_params([0, 1, 2], '1').and_return([1]) }
     it { is_expected.to run.with_params([0, 1, 2], '1-1').and_return([1]) }
     it { is_expected.to run.with_params([0, 1, 2], 2).and_return([2]) }
-    it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, /index exceeds array size/) }
+    it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, %r{index exceeds array size}) }
   end
 
   context 'when requesting a single item using UTF8 and double byte characters' do
@@ -36,10 +36,10 @@ describe 'values_at' do
   end
 
   context 'when requesting multiple items' do
-    it { is_expected.to run.with_params([0, 1, 2], [1, -1]).and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
+    it { is_expected.to run.with_params([0, 1, 2], [1, -1]).and_raise_error(Puppet::ParseError, %r{Unknown format of given index}) }
     it { is_expected.to run.with_params([0, 1, 2], [0, 2]).and_return([0, 2]) }
     it { is_expected.to run.with_params([0, 1, 2], ['0-2', 1, 2]).and_return([0, 1, 2, 1, 2]) }
-    it { is_expected.to run.with_params([0, 1, 2], [3, 2]).and_raise_error(Puppet::ParseError, /index exceeds array size/) }
+    it { is_expected.to run.with_params([0, 1, 2], [3, 2]).and_raise_error(Puppet::ParseError, %r{index exceeds array size}) }
 
     describe 'different range syntaxes' do
       it { is_expected.to run.with_params([0, 1, 2], '0-2').and_return([0, 1, 2]) }
old mode 100755 (executable)
new mode 100644 (file)
index 26c6dfb..850d314
@@ -1,23 +1,23 @@
 require 'spec_helper'
 
-describe 'values' do
+describe 'values', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the first.")
-    is_expected.to run.with_params({}, 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the first.')
+    is_expected.to run.with_params({}, 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
-  it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
-  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
-  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
   it { is_expected.to run.with_params({}).and_return([]) }
-  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['value']) }
-  it 'should return the array of values' do
+  it { is_expected.to run.with_params('key' => 'value').and_return(['value']) }
+  it 'returns the array of values' do
     result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2', 'duplicate_value_key' => 'value2' }])
     expect(result).to match_array(['value1', 'value2', 'value2'])
   end
 
-  it 'should run with UTF8 and double byte characters' do
+  it 'runs with UTF8 and double byte characters' do
     result = subject.call([{ 'かぎ' => '使用', 'ҝĕұ' => '√ẩŀứệ', 'ҝĕұďŭрļǐçằťè' => '√ẩŀứệ' }])
     expect(result).to match_array(['使用', '√ẩŀứệ', '√ẩŀứệ'])
   end
old mode 100755 (executable)
new mode 100644 (file)
index e1ae8ee..433e448
@@ -2,20 +2,19 @@ require 'spec_helper'
 
 describe 'zip' do
   it { is_expected.not_to eq(nil) }
-  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
-  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
   it {
-    pending("Current implementation ignores parameters after the third.")
-    is_expected.to run.with_params([], [], true, []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    pending('Current implementation ignores parameters after the third.')
+    is_expected.to run.with_params([], [], true, []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
   }
   it { is_expected.to run.with_params([], []).and_return([]) }
-  it { is_expected.to run.with_params([1,2,3], [4,5,6]).and_return([[1,4], [2,5], [3,6]]) }
-  it { is_expected.to run.with_params([1,2,3], [4,5,6], false).and_return([[1,4], [2,5], [3,6]]) }
-  it { is_expected.to run.with_params([1,2,3], [4,5,6], true).and_return([1, 4, 2, 5, 3, 6]) }
+  it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6]).and_return([[1, 4], [2, 5], [3, 6]]) }
+  it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6], false).and_return([[1, 4], [2, 5], [3, 6]]) }
+  it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6], true).and_return([1, 4, 2, 5, 3, 6]) }
 
-  context 'should run with UTF8 and double byte characters' do
-   it { is_expected.to run.with_params(['ầ', 'ь', 'ć'], ['đ', 'ề', 'ƒ']).and_return([['ầ','đ'], ['ь','ề'], ['ć', 'ƒ']]) }
-   it { is_expected.to run.with_params(['ペ', '含', '値'], ['ッ', '文', 'イ']).and_return([['ペ','ッ'], ['含','文'], ['値', 'イ']]) }
+  context 'with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params(['ầ', 'ь', 'ć'], ['đ', 'ề', 'ƒ']).and_return([['ầ', 'đ'], ['ь', 'ề'], ['ć', 'ƒ']]) }
+    it { is_expected.to run.with_params(['ペ', '含', '値'], ['ッ', '文', 'イ']).and_return([['ペ', 'ッ'], ['含', '文'], ['値', 'イ']]) }
   end
 end
-
old mode 100755 (executable)
new mode 100644 (file)
index 505e240..51a7b9d
@@ -1,9 +1,8 @@
-#! /usr/bin/env ruby -S rspec
 require 'rspec'
-
+# class Object
 class Object
   # This is necessary because the RAL has a 'should'
   # method.
-  alias :must :should
-  alias :must_not :should_not
+  alias must should
+  alias must_not should_not
 end
old mode 100755 (executable)
new mode 100644 (file)
index 3ae59f9..70cf4f0
@@ -1,11 +1,10 @@
-#! /usr/bin/env ruby -S rspec
 # Some monkey-patching to allow us to test private methods.
 class Class
-    def publicize_methods(*methods)
-        saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
+  def publicize_methods(*methods)
+    saved_private_instance_methods = methods.empty? ? private_instance_methods : methods
 
-        self.class_eval { public(*saved_private_instance_methods) }
-        yield
-        self.class_eval { private(*saved_private_instance_methods) }
-    end
+    class_eval { public(*saved_private_instance_methods) }
+    yield
+    class_eval { private(*saved_private_instance_methods) }
+  end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 22d5d68..0a030e6
@@ -1,8 +1,48 @@
-#This file is generated by ModuleSync, do not edit.
+RSpec.configure do |c|
+  c.mock_with :rspec
+end
+
 require 'puppetlabs_spec_helper/module_spec_helper'
+require 'rspec-puppet-facts'
+
+require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
+
+include RspecPuppetFacts
+
+default_facts = {
+  puppetversion: Puppet.version,
+  facterversion: Facter.version,
+}
+
+default_fact_files = [
+  File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
+  File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
+]
 
-# put local configuration and setup into spec_helper_local
-begin
-  require 'spec_helper_local'
-rescue LoadError
+default_fact_files.each do |f|
+  next unless File.exist?(f) && File.readable?(f) && File.size?(f)
+
+  begin
+    default_facts.merge!(YAML.safe_load(File.read(f)))
+  rescue => e
+    RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
+  end
+end
+
+RSpec.configure do |c|
+  c.default_facts = default_facts
+  c.before :each do
+    # set to strictest setting for testing
+    # by default Puppet runs at warning level
+    Puppet.settings[:strict] = :warning
+  end
 end
+
+def ensure_module_defined(module_name)
+  module_name.split('::').reduce(Object) do |last_module, next_module|
+    last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
+    last_module.const_get(next_module, false)
+  end
+end
+
+# 'spec_overrides' from sync.yml will appear below this line
old mode 100755 (executable)
new mode 100644 (file)
index 4d85e7d..d658703
@@ -1,11 +1,13 @@
-#! /usr/bin/env ruby -S rspec
+require 'beaker-pe'
+require 'beaker-puppet'
 require 'puppet'
 require 'beaker-rspec'
 require 'beaker/puppet_install_helper'
 require 'beaker/module_install_helper'
 
 run_puppet_install_helper
-install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i
+configure_type_defaults_on(hosts)
+install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i
 install_module_on(hosts)
 install_module_dependencies_on(hosts)
 
@@ -18,20 +20,20 @@ RSpec.configure do |c|
   end
 end
 
-def get_puppet_version
+def return_puppet_version
   (on default, puppet('--version')).output.chomp
 end
 
-RSpec.shared_context "with faked facts" do
+RSpec.shared_context 'with faked facts' do
   let(:facts_d) do
-    puppet_version = get_puppet_version
-    if fact('osfamily') =~ /windows/i
+    puppet_version = return_puppet_version
+    if fact('osfamily') =~ %r{windows}i
       if fact('kernelmajversion').to_f < 6.0
         'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
       else
         'C:/ProgramData/PuppetLabs/facter/facts.d'
       end
-    elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true"
+    elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 && fact('is_pe', '--puppet') == 'true'
       '/etc/puppetlabs/facter/facts.d'
     else
       '/etc/facter/facts.d'
@@ -39,14 +41,14 @@ RSpec.shared_context "with faked facts" do
   end
 
   before :each do
-    #No need to create on windows, PE creates by default
-    if fact('osfamily') !~ /windows/i
+    # No need to create on windows, PE creates by default
+    if fact('osfamily') !~ %r{windows}i
       shell("mkdir -p '#{facts_d}'")
     end
   end
 
   after :each do
-    shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0,1])
+    shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0, 1])
   end
 
   def fake_fact(name, value)
index 616490c..5fea4da 100644 (file)
@@ -1,7 +1,7 @@
 # automatically load any shared examples or contexts
-Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
+Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
 
-# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
+# HACK: to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
 RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
 
 RSpec.configure do |config|
@@ -16,7 +16,7 @@ RSpec.configure do |config|
     # Facter.collection.loader.load(:ipaddress)
     Facter.clear
     Facter.clear_messages
-    
+
     RSpec::Mocks.setup
   end
 
index ea9b7a0..013ec10 100644 (file)
@@ -14,7 +14,7 @@ module SharedData
     '8.8.8.8/16',
     '8.8.8.8/255.255.0.0',
     '8.8.8.8/32',
-  ]
+  ].freeze
   IPV4_NEGATIVE_PATTERNS = [
     '',
     '0000',
@@ -34,5 +34,5 @@ module SharedData
     '9999.9999.9999.9999',
     'affe::beef',
     'nope',
-  ]
+  ].freeze
 end
old mode 100755 (executable)
new mode 100644 (file)
index 0afadb2..9dad049
@@ -1,31 +1,29 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 require 'facter/facter_dot_d'
 
-describe Facter::Util::DotD do
-
-  context 'returns a simple fact' do
+describe Facter::Util::DotD do # rubocop:disable RSpec/FilePath : Spec path is as it should be
+  context 'with a simple fact' do
     before :each do
-      Facter.stubs(:version).returns('1.6.1')
-      subject.stubs(:entries).returns(['/etc/facter/facts.d/fake_fact.txt'])
-      File.stubs(:readlines).with('/etc/facter/facts.d/fake_fact.txt').returns(['fake_fact=fake fact'])
+      allow(Facter).to receive(:version).and_return('1.6.1')
+      allow(subject).to receive(:entries).and_return(['/etc/facter/facts.d/fake_fact.txt'])
+      allow(File).to receive(:readlines).with('/etc/facter/facts.d/fake_fact.txt').and_return(['fake_fact=fake fact'])
       subject.create
     end
 
-    it 'should return successfully' do
+    it 'returns successfully' do
       expect(Facter.fact(:fake_fact).value).to eq('fake fact')
     end
   end
 
-  context 'returns a fact with equals signs' do
+  context 'with a fact with equals signs' do
     before :each do
-      Facter.stubs(:version).returns('1.6.1')
-      subject.stubs(:entries).returns(['/etc/facter/facts.d/foo.txt'])
-      File.stubs(:readlines).with('/etc/facter/facts.d/foo.txt').returns(['foo=1+1=2'])
+      allow(Facter).to receive(:version).and_return('1.6.1')
+      allow(subject).to receive(:entries).and_return(['/etc/facter/facts.d/foo.txt'])
+      allow(File).to receive(:readlines).with('/etc/facter/facts.d/foo.txt').and_return(['foo=1+1=2'])
       subject.create
     end
 
-    it 'should return successfully' do
+    it 'returns successfully' do
       expect(Facter.fact(:foo).value).to eq('1+1=2')
     end
   end
index 3954faf..011d3ed 100644 (file)
@@ -1,40 +1,39 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 require 'puppet/type'
 require 'puppet/type/package'
 
 describe 'package_provider', :type => :fact do
-  before { Facter.clear }
-  after { Facter.clear }
+  before(:each) { Facter.clear }
+  after(:each) { Facter.clear }
 
   ['4.2.2', '3.7.1 (Puppet Enterprise 3.2.1)'].each do |puppetversion|
     describe "on puppet ''#{puppetversion}''" do
       before :each do
-        Facter.stubs(:value).returns puppetversion
+        allow(Facter).to receive(:value).and_return(puppetversion)
       end
 
-      context "darwin" do
-        it "should return pkgdmg" do
+      context 'when darwin' do
+        it 'returns pkgdmg' do
           provider = Puppet::Type.type(:package).provider(:pkgdmg)
-          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+          allow(Puppet::Type.type(:package)).to receive(:defaultprovider).and_return(provider)
 
           expect(Facter.fact(:package_provider).value).to eq('pkgdmg')
         end
       end
 
-      context "centos 7" do
-        it "should return yum" do
+      context 'when centos 7' do
+        it 'returns yum' do
           provider = Puppet::Type.type(:package).provider(:yum)
-          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+          allow(Puppet::Type.type(:package)).to receive(:defaultprovider).and_return(provider)
 
           expect(Facter.fact(:package_provider).value).to eq('yum')
         end
       end
 
-      context "ubuntu" do
-        it "should return apt" do
+      context 'when ubuntu' do
+        it 'returns apt' do
           provider = Puppet::Type.type(:package).provider(:apt)
-          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+          allow(Puppet::Type.type(:package)).to receive(:defaultprovider).and_return(provider)
 
           expect(Facter.fact(:package_provider).value).to eq('apt')
         end
old mode 100755 (executable)
new mode 100644 (file)
index c11a1cd..d74a5c3
@@ -1,8 +1,6 @@
-#!/usr/bin/env rspec
-
 require 'spec_helper'
 
-describe "PE Version specs" do
+describe 'PE Version specs' do
   before :each do
     # Explicitly load the pe_version.rb file which contains generated facts
     # that cannot be automatically loaded.  Puppet 2.x implements
@@ -14,29 +12,32 @@ describe "PE Version specs" do
       Facter.collection.loader.load(:pe_version)
     end
   end
-  
-  context "When puppetversion is nil" do
+
+  context 'when puppetversion is nil' do
     before :each do
-      Facter.fact(:puppetversion).stubs(:value).returns(nil)
+      allow(Facter.fact(:puppetversion)).to receive(:value).and_return(nil)
     end
-    
-    it "pe_version is nil" do
+
+    it 'puppetversion is nil' do
       expect(Facter.fact(:puppetversion).value).to be_nil
+    end
+
+    it 'pe_version is nil' do
       expect(Facter.fact(:pe_version).value).to be_nil
     end
   end
 
-  context "If PE is installed" do
-    %w{ 2.6.1 2.10.300 }.each do |version|
+  context 'when PE is installed' do
+    ['2.6.1', '2.10.300'].each do |version|
       puppetversion = "2.7.19 (Puppet Enterprise #{version})"
       context "puppetversion => #{puppetversion}" do
         before :each do
-          Facter.fact(:puppetversion).stubs(:value).returns(puppetversion)
+          allow(Facter.fact(:puppetversion)).to receive(:value).and_return(puppetversion)
         end
 
-        (major,minor,patch) = version.split(".")
+        (major, minor, patch) = version.split('.')
 
-        it "Should return true" do
+        it 'returns true' do
           expect(Facter.fact(:is_pe).value).to eq(true)
         end
 
@@ -59,30 +60,29 @@ describe "PE Version specs" do
     end
   end
 
-  context "When PE is not installed" do
+  context 'when PE is not installed' do
     before :each do
-      Facter.fact(:puppetversion).stubs(:value).returns("2.7.19")
+      allow(Facter.fact(:puppetversion)).to receive(:value).and_return('2.7.19')
     end
 
-    it "is_pe is false" do
+    it 'is_pe is false' do
       expect(Facter.fact(:is_pe).value).to eq(false)
     end
 
-    it "pe_version is nil" do
+    it 'pe_version is nil' do
       expect(Facter.fact(:pe_version).value).to be_nil
     end
 
-    it "pe_major_version is nil" do
+    it 'pe_major_version is nil' do
       expect(Facter.fact(:pe_major_version).value).to be_nil
     end
 
-    it "pe_minor_version is nil" do
+    it 'pe_minor_version is nil' do
       expect(Facter.fact(:pe_minor_version).value).to be_nil
     end
 
-    it "Should have a patch version" do
+    it 'has a patch version' do
       expect(Facter.fact(:pe_patch_version).value).to be_nil
     end
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index a5c2846..5e5b0bf
@@ -1,65 +1,65 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 require 'facter/root_home'
+describe 'Root Home Specs' do
+  describe Facter::Util::RootHome do
+    context 'when solaris' do
+      let(:root_ent) { 'root:x:0:0:Super-User:/:/sbin/sh' }
+      let(:expected_root_home) { '/' }
 
-describe Facter::Util::RootHome do
-  context "solaris" do
-    let(:root_ent) { "root:x:0:0:Super-User:/:/sbin/sh" }
-    let(:expected_root_home) { "/" }
-
-    it "should return /" do
-      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
-      expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home)
+      it 'returns /' do
+        expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent)
+        expect(described_class.returnt_root_home).to eq(expected_root_home)
+      end
     end
-  end
-  context "linux" do
-    let(:root_ent) { "root:x:0:0:root:/root:/bin/bash" }
-    let(:expected_root_home) { "/root" }
+    context 'when linux' do
+      let(:root_ent) { 'root:x:0:0:root:/root:/bin/bash' }
+      let(:expected_root_home) { '/root' }
 
-    it "should return /root" do
-      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
-      expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home)
+      it 'returns /root' do
+        expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent)
+        expect(described_class.returnt_root_home).to eq(expected_root_home)
+      end
     end
-  end
-  context "windows" do
-    before :each do
-      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil)
-    end
-    it "should be nil on windows" do
-      expect(Facter::Util::RootHome.get_root_home).to be_nil
+    context 'when windows' do
+      it 'is nil on windows' do
+        expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(nil)
+        expect(described_class.returnt_root_home).to be_nil
+      end
     end
   end
-end
 
-describe 'root_home', :type => :fact do
-  before { Facter.clear }
-  after { Facter.clear }
+  describe 'root_home', :type => :fact do
+    before(:each) { Facter.clear }
+    after(:each) { Facter.clear }
 
-  context "macosx" do
-    before do
-      Facter.fact(:kernel).stubs(:value).returns("Darwin")
-      Facter.fact(:osfamily).stubs(:value).returns("Darwin")
-    end
-    let(:expected_root_home) { "/var/root" }
-    sample_dscacheutil = File.read(fixtures('dscacheutil','root'))
+    context 'when macosx' do
+      before(:each) do
+        allow(Facter.fact(:kernel)).to receive(:value).and_return('Darwin')
+        allow(Facter.fact(:osfamily)).to receive(:value).and_return('Darwin')
+      end
+      let(:expected_root_home) { '/var/root' }
 
-    it "should return /var/root" do
-      Facter::Util::Resolution.stubs(:exec).with("dscacheutil -q user -a name root").returns(sample_dscacheutil)
-      expect(Facter.fact(:root_home).value).to eq(expected_root_home)
-    end
-  end
+      sample_dscacheutil = File.read(fixtures('dscacheutil', 'root'))
 
-  context "aix" do
-    before do
-      Facter.fact(:kernel).stubs(:value).returns("AIX")
-      Facter.fact(:osfamily).stubs(:value).returns("AIX")
+      it 'returns /var/root' do
+        allow(Facter::Util::Resolution).to receive(:exec).with('dscacheutil -q user -a name root').and_return(sample_dscacheutil)
+        expect(Facter.fact(:root_home).value).to eq(expected_root_home)
+      end
     end
-    let(:expected_root_home) { "/root" }
-    sample_lsuser = File.read(fixtures('lsuser','root'))
 
-    it "should return /root" do
-      Facter::Util::Resolution.stubs(:exec).with("lsuser -c -a home root").returns(sample_lsuser)
-      expect(Facter.fact(:root_home).value).to eq(expected_root_home)
+    context 'when aix' do
+      before(:each) do
+        allow(Facter.fact(:kernel)).to receive(:value).and_return('AIX')
+        allow(Facter.fact(:osfamily)).to receive(:value).and_return('AIX')
+      end
+      let(:expected_root_home) { '/root' }
+
+      sample_lsuser = File.read(fixtures('lsuser', 'root'))
+
+      it 'returns /root' do
+        allow(Facter::Util::Resolution).to receive(:exec).with('lsuser -c -a home root').and_return(sample_lsuser)
+        expect(Facter.fact(:root_home).value).to eq(expected_root_home)
+      end
     end
   end
 end
index ad8a5fc..b3d4aec 100644 (file)
@@ -1,37 +1,35 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 require 'puppet/type'
 require 'puppet/type/service'
 
 describe 'service_provider', :type => :fact do
-  before { Facter.clear }
-  after { Facter.clear }
+  before(:each) { Facter.clear }
+  after(:each) { Facter.clear }
 
-  context "macosx" do
-    it "should return launchd" do
+  context 'when macosx' do
+    it 'returns launchd' do
       provider = Puppet::Type.type(:service).provider(:launchd)
-      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+      allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider)
 
       expect(Facter.fact(:service_provider).value).to eq('launchd')
     end
   end
 
-  context "systemd" do
-    it "should return systemd" do
+  context 'when systemd' do
+    it 'returns systemd' do
       provider = Puppet::Type.type(:service).provider(:systemd)
-      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+      allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider)
 
       expect(Facter.fact(:service_provider).value).to eq('systemd')
     end
   end
 
-  context "redhat" do
-    it "should return redhat" do
+  context 'when redhat' do
+    it 'returns redhat' do
       provider = Puppet::Type.type(:service).provider(:redhat)
-      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+      allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider)
 
       expect(Facter.fact(:service_provider).value).to eq('redhat')
     end
   end
-
 end
old mode 100755 (executable)
new mode 100644 (file)
index c278b79..05dff89
@@ -1,35 +1,34 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 require 'facter/util/puppet_settings'
 
 describe Facter::Util::PuppetSettings do
-
-  describe "#with_puppet" do
-    context "Without Puppet loaded" do
+  describe '#with_puppet' do
+    context 'without Puppet loaded' do
       before(:each) do
-        Module.expects(:const_get).with("Puppet").raises(NameError)
+        allow(Module).to receive(:const_get).with('Puppet').and_raise(NameError)
       end
 
-      it 'should be nil' do
+      it 'is nil' do
         expect(subject.with_puppet { Puppet[:vardir] }).to be_nil
       end
-      it 'should not yield to the block' do
-        Puppet.expects(:[]).never
+      it 'does not yield to the block' do
+        expect(Puppet).to receive(:[]).never
         expect(subject.with_puppet { Puppet[:vardir] }).to be_nil
       end
     end
-    context "With Puppet loaded" do
+    context 'with Puppet loaded' do
+      # module Puppet
       module Puppet; end
-      let(:vardir) { "/var/lib/puppet" }
+      let(:vardir) { '/var/lib/puppet' }
 
       before :each do
-        Puppet.expects(:[]).with(:vardir).returns vardir
+        allow(Puppet).to receive(:[]).with(:vardir).and_return(vardir)
       end
 
-      it 'should yield to the block' do
+      it 'yields to the block' do
         subject.with_puppet { Puppet[:vardir] }
       end
-      it 'should return the nodes vardir' do
+      it 'returns the nodes vardir' do
         expect(subject.with_puppet { Puppet[:vardir] }).to eq vardir
       end
     end
index b162127..39d3b7a 100644 (file)
@@ -1,68 +1,67 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the enclose_ipv6 function" do
+describe 'the enclose_ipv6 function' do
   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("enclose_ipv6")).to eq("function_enclose_ipv6")
+  it 'exists' do
+    expect(Puppet::Parser::Functions.function('enclose_ipv6')).to eq('function_enclose_ipv6')
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_enclose_ipv6([]) }.to( raise_error(Puppet::ParseError) )
+  it 'raises a ParseError if there is less than 1 arguments' do
+    expect { scope.function_enclose_ipv6([]) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should raise a ParseError if there is more than 1 arguments" do
-    expect { scope.function_enclose_ipv6(['argument1','argument2']) }.to( raise_error(Puppet::ParseError) )
+  it 'raises a ParseError if there is more than 1 arguments' do
+    expect { scope.function_enclose_ipv6(['argument1', 'argument2']) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should raise a ParseError when given garbage" do
-    expect { scope.function_enclose_ipv6(['garbage']) }.to( raise_error(Puppet::ParseError) )
+  it 'raises a ParseError when given garbage' do
+    expect { scope.function_enclose_ipv6(['garbage']) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should raise a ParseError when given something else than a string or an array" do
-    expect { scope.function_enclose_ipv6([['1' => '127.0.0.1']]) }.to( raise_error(Puppet::ParseError) )
+  it 'raises a ParseError when given something else than a string or an array' do
+    expect { scope.function_enclose_ipv6([['1' => '127.0.0.1']]) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should not raise a ParseError when given a single ip string" do
-    expect { scope.function_enclose_ipv6(['127.0.0.1']) }.to_not raise_error
+  it 'does not raise a ParseError when given a single ip string' do
+    expect { scope.function_enclose_ipv6(['127.0.0.1']) }.not_to raise_error
   end
 
-  it "should not raise a ParseError when given * as ip string" do
-    expect { scope.function_enclose_ipv6(['*']) }.to_not raise_error
+  it 'does not raise a ParseError when given * as ip string' do
+    expect { scope.function_enclose_ipv6(['*']) }.not_to raise_error
   end
 
-  it "should not raise a ParseError when given an array of ip strings" do
-    expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1']]) }.to_not raise_error
+  it 'does not raise a ParseError when given an array of ip strings' do
+    expect { scope.function_enclose_ipv6([['127.0.0.1', 'fe80::1']]) }.not_to raise_error
   end
 
-  it "should not raise a ParseError when given differently notations of ip addresses" do
-    expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::1]']]) }.to_not raise_error
+  it 'does not raise a ParseError when given differently notations of ip addresses' do
+    expect { scope.function_enclose_ipv6([['127.0.0.1', 'fe80::1', '[fe80::1]']]) }.not_to raise_error
   end
 
-  it "should raise a ParseError when given a wrong ipv4 address" do
-    expect { scope.function_enclose_ipv6(['127..0.0.1']) }.to( raise_error(Puppet::ParseError) )
+  it 'raises a ParseError when given a wrong ipv4 address' do
+    expect { scope.function_enclose_ipv6(['127..0.0.1']) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should raise a ParseError when given a ipv4 address with square brackets" do
-    expect { scope.function_enclose_ipv6(['[127.0.0.1]']) }.to( raise_error(Puppet::ParseError) )
+  it 'raises a ParseError when given a ipv4 address with square brackets' do
+    expect { scope.function_enclose_ipv6(['[127.0.0.1]']) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should raise a ParseError when given a wrong ipv6 address" do
-    expect { scope.function_enclose_ipv6(['fe80:::1']) }.to( raise_error(Puppet::ParseError) )
+  it 'raises a ParseError when given a wrong ipv6 address' do
+    expect { scope.function_enclose_ipv6(['fe80:::1']) }.to(raise_error(Puppet::ParseError))
   end
 
-  it "should embrace ipv6 adresses within an array of ip addresses" do
-    result = scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::2]']])
-    expect(result).to(eq(['127.0.0.1','[fe80::1]','[fe80::2]']))
+  it 'embraces ipv6 adresses within an array of ip addresses' do
+    result = scope.function_enclose_ipv6([['127.0.0.1', 'fe80::1', '[fe80::2]']])
+    expect(result).to(eq(['127.0.0.1', '[fe80::1]', '[fe80::2]']))
   end
 
-  it "should embrace a single ipv6 adresse" do
+  it 'embraces a single ipv6 adresse' do
     result = scope.function_enclose_ipv6(['fe80::1'])
     expect(result).to(eq(['[fe80::1]']))
   end
 
-  it "should not embrace a single ipv4 adresse" do
+  it 'does not embrace a single ipv4 adresse' do
     result = scope.function_enclose_ipv6(['127.0.0.1'])
     expect(result).to(eq(['127.0.0.1']))
   end
index 8931208..589ad82 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper'
 
-describe :is_absolute_path do
+describe 'is_absolute_path' do
   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
 
   let(:function_args) do
@@ -11,31 +11,28 @@ describe :is_absolute_path do
     scope.function_is_absolute_path(function_args)
   end
 
-
   describe 'validate arity' do
     let(:function_args) do
-       [1,2]
-    end
-    it "should raise a ParseError if there is more than 1 arguments" do
-      lambda { function }.should( raise_error(ArgumentError))
+      [1, 2]
     end
 
+    it 'raises a ParseError if there is more than 1 arguments' do
+      -> { function }.should(raise_error(ArgumentError))
+    end
   end
-  
-  it "should exist" do
+
+  it 'exists' do
     Puppet::Parser::Functions.function(subject).should == "function_#{subject}"
   end
 
   # help enforce good function defination
-  it 'should contain arity' do
-
+  it 'contains arity' do
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    lambda { function }.should( raise_error(ArgumentError))
+  it 'raises a ParseError if there is less than 1 arguments' do
+    -> { function }.should(raise_error(ArgumentError))
   end
 
-
   describe 'should retrun true' do
     let(:return_value) do
       true
@@ -45,7 +42,8 @@ describe :is_absolute_path do
       let(:function_args) do
         ['c:\temp\test.txt']
       end
-      it 'should return data' do
+
+      it 'returns data' do
         function.should eq(return_value)
       end
     end
@@ -55,7 +53,7 @@ describe :is_absolute_path do
         ['/temp/test.txt']
       end
 
-      it 'should return data' do
+      it 'returns data' do
         function.should eq(return_value)
       end
     end
@@ -65,11 +63,13 @@ describe :is_absolute_path do
     let(:return_value) do
       false
     end
+
     describe 'windows' do
       let(:function_args) do
         ['..\temp\test.txt']
       end
-      it 'should return data' do
+
+      it 'returns data' do
         function.should eq(return_value)
       end
     end
@@ -78,9 +78,10 @@ describe :is_absolute_path do
       let(:function_args) do
         ['../var/lib/puppet']
       end
-      it 'should return data' do
+
+      it 'returns data' do
         function.should eq(return_value)
       end
     end
   end
-end
\ No newline at end of file
+end
old mode 100755 (executable)
new mode 100644 (file)
index dcca4a4..d0f653a
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
-require 'tempfile'
+
 provider_class = Puppet::Type.type(:file_line).provider(:ruby)
-# These tests fail on windows when run as part of the rake task. Individually they pass
+#  These tests fail on windows when run as part of the rake task. Individually they pass
 describe provider_class, :unless => Puppet::Util::Platform.windows? do
-  context "when adding" do
-    let :tmpfile do
-      tmp = Tempfile.new('tmp')
-      path = tmp.path
-      tmp.close!
-      path
-    end
-    let :resource do
-      Puppet::Type::File_line.new(
-        {:name => 'foo', :path => tmpfile, :line => 'foo'}
-      )
-    end
-    let :provider do
-      provider_class.new(resource)
-    end
+  include PuppetlabsSpec::Files
 
-    it 'should detect if the line exists in the file' do
-      File.open(tmpfile, 'w') do |fh|
-        fh.write('foo')
-      end
-      expect(provider.exists?).to be_truthy
-    end
-    it 'should detect if the line does not exist in the file' do
-      File.open(tmpfile, 'w') do |fh|
-        fh.write('foo1')
-      end
-      expect(provider.exists?).to eql (false)
-    end
-    it 'should append to an existing file when creating' do
-      provider.create
-      expect(File.read(tmpfile).chomp).to eq('foo')
-    end
+  let :tmpfile do
+    tmpfilename('file_line_test')
+  end
+  let :content do
+    ''
+  end
+  let :params do
+    {}
+  end
+  let :resource do
+    Puppet::Type::File_line.new({
+      :name => 'foo',
+      :path => tmpfile,
+      :line => 'foo',
+    }.merge(params))
+  end
+  let :provider do
+    provider_class.new(resource)
   end
-  context 'when using replace' do
-    before :each do
-      # TODO: these should be ported over to use the PuppetLabs spec_helper
-      #  file fixtures once the following pull request has been merged:
-      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
-      tmp = Tempfile.new('tmp')
-      @tmpfile = tmp.path
-      tmp.close!
-      @resource = Puppet::Type::File_line.new(
-        {
-          :name    => 'foo',
-          :path    => @tmpfile,
-          :line    => 'foo = bar',
-          :match   => '^foo\s*=.*$',
-          :replace => false,
-        }
-      )
-      @provider = provider_class.new(@resource)
-    end
 
-    it 'should not replace the matching line' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo=blah\nfoo2\nfoo3")
-      end
-      expect(@provider.exists?).to be_truthy
-      @provider.create
-      expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo=blah\nfoo2\nfoo3")
+  before :each do
+    File.open(tmpfile, 'w') do |fh|
+      fh.write(content)
     end
+  end
+
+  describe 'line parameter' do
+    context 'when line exists' do
+      let(:content) { 'foo' }
 
-    it 'should append the line if no matches are found' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo2")
+      it 'detects the line' do
+        expect(provider).to be_exists
       end
-      expect(@provider.exists?).to eql (false)
-      @provider.create
-      expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo2\nfoo = bar")
     end
+    context 'when line does not exist' do
+      let(:content) { 'foo bar' }
 
-    it 'should raise an error with invalid values' do
-      expect {
-        @resource = Puppet::Type::File_line.new(
-          {
-            :name     => 'foo',
-            :path     => @tmpfile,
-            :line     => 'foo = bar',
-            :match    => '^foo\s*=.*$',
-            :replace  => 'asgadga',
-          }
-        )
-      }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./)
+      it 'requests changes' do
+        expect(provider).not_to be_exists
+      end
+      it 'appends the line' do
+        provider.create
+        expect(File.read(tmpfile).chomp).to eq("foo bar\nfoo")
+      end
     end
   end
-  context "when matching" do
-    before :each do
-      # TODO: these should be ported over to use the PuppetLabs spec_helper
-      #  file fixtures once the following pull request has been merged:
-      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
-      tmp = Tempfile.new('tmp')
-      @tmpfile = tmp.path
-      tmp.close!
-      @resource = Puppet::Type::File_line.new(
-        {
-          :name  => 'foo',
-          :path  => @tmpfile,
-          :line  => 'foo = bar',
-          :match => '^foo\s*=.*$',
-        }
-      )
-      @provider = provider_class.new(@resource)
-    end
 
-    describe 'using match' do
-      it 'should raise an error if more than one line matches, and should not have modified the file' do
-        File.open(@tmpfile, 'w') do |fh|
-          fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
-        end
-        expect(@provider.exists?).to eql(false)
-        expect { @provider.create }.to raise_error(Puppet::Error, /More than one line.*matches/)
-        expect(File.read(@tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz")
-      end
+  describe 'match parameter' do
+    let(:params) { { :match => '^bar' } }
 
-      it 'should replace all lines that matches' do
-        @resource = Puppet::Type::File_line.new(
-          {
-            :name     => 'foo',
-            :path     => @tmpfile,
-            :line     => 'foo = bar',
-            :match    => '^foo\s*=.*$',
-            :multiple => true,
-          }
-        )
-        @provider = provider_class.new(@resource)
-        File.open(@tmpfile, 'w') do |fh|
-          fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
-        end
-        expect(@provider.exists?).to eql(false)
-        @provider.create
-        expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar")
-      end
+    describe 'does not match line - line does not exist - replacing' do
+      let(:content) { "foo bar\nbar" }
 
-      it 'should replace all lines that match, even when some lines are correct' do
-        @resource = Puppet::Type::File_line.new(
-          {
-            :name     => 'neil',
-            :path     => @tmpfile,
-            :line     => "\thard\tcore\t0\n",
-            :match    => '^[ \t]hard[ \t]+core[ \t]+.*',
-            :multiple => true,
-          }
-        )
-        @provider = provider_class.new(@resource)
-        File.open(@tmpfile, 'w') do |fh|
-          fh.write("\thard\tcore\t90\n\thard\tcore\t0\n")
-        end
-        expect(@provider.exists?).to eql(false)
-        @provider.create
-        expect(File.read(@tmpfile).chomp).to eql("\thard\tcore\t0\n\thard\tcore\t0")
+      it 'requests changes' do
+        expect(provider).not_to be_exists
       end
-
-      it 'should raise an error with invalid values' do
-        expect {
-          @resource = Puppet::Type::File_line.new(
-            {
-              :name     => 'foo',
-              :path     => @tmpfile,
-              :line     => 'foo = bar',
-              :match    => '^foo\s*=.*$',
-              :multiple => 'asgadga',
-            }
-          )
-        }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./)
+      it 'replaces the match' do
+        provider.create
+        expect(File.read(tmpfile).chomp).to eq("foo bar\nfoo")
       end
+    end
 
-      it 'should replace a line that matches' do
-        File.open(@tmpfile, 'w') do |fh|
-          fh.write("foo1\nfoo=blah\nfoo2")
-        end
-        expect(@provider.exists?).to eql(false)
-        @provider.create
-        expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
-      end
-      it 'should add a new line if no lines match' do
-        File.open(@tmpfile, 'w') do |fh|
-          fh.write("foo1\nfoo2")
-        end
-        expect(@provider.exists?).to eql(false)
-        @provider.create
-        expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n")
-      end
-      it 'should do nothing if the exact line already exists' do
-        File.open(@tmpfile, 'w') do |fh|
-          fh.write("foo1\nfoo = bar\nfoo2")
-        end
-        expect(@provider.exists?).to eql(true)
-        @provider.create
-        expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
-      end
+    describe 'does not match line - line does not exist - appending' do
+      let(:params) { super().merge(:replace => false) }
+      let(:content) { "foo bar\nbar" }
 
-      it 'should not add line after no matches found' do
-        @resource = Puppet::Type::File_line.new(
-          {
-            :name               => 'foo',
-            :path               => @tmpfile,
-            :line               => 'inserted = line',
-            :match              => '^foo3$',
-            :append_on_no_match => false,
-          }
-        )
-        @provider = provider_class.new(@resource)
-        File.open(@tmpfile, 'w') do |fh|
-          fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz")
-        end
-        expect(@provider.exists?).to be true
-        expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = blah\nfoo2\nfoo = baz")
+      it 'does not request changes' do
+        expect(provider).to be_exists
       end
     end
 
-    describe 'using after' do
-      let :resource do
-        Puppet::Type::File_line.new(
-          {
-            :name  => 'foo',
-            :path  => @tmpfile,
-            :line  => 'inserted = line',
-            :after => '^foo1',
-          }
-        )
-      end
+    context 'when does not match line - line exists' do
+      let(:content) { "foo\nbar" }
 
-      let :provider do
-        provider_class.new(resource)
-      end
-      context 'match and after set' do
-        shared_context 'resource_create' do
-          let(:match) { '^foo2$' }
-          let(:after) { '^foo1$' }
-          let(:resource) {
-            Puppet::Type::File_line.new(
-              {
-                :name  => 'foo',
-                :path  => @tmpfile,
-                :line  => 'inserted = line',
-                :after => after,
-                :match => match,
-              }
-            )
-          }
-        end
-        before :each do
-          File.open(@tmpfile, 'w') do |fh|
-            fh.write("foo1\nfoo2\nfoo = baz")
-          end
-        end
-        describe 'inserts at match' do
-          include_context 'resource_create'
-          it {
-            provider.create
-            expect(File.read(@tmpfile).chomp).to eq("foo1\ninserted = line\nfoo = baz")
-          }
-        end
-        describe 'inserts a new line after when no match' do
-          include_context 'resource_create' do
-            let(:match) { '^nevergoingtomatch$' }
-          end
-          it {
-            provider.create
-            expect(File.read(@tmpfile).chomp).to eq("foo1\ninserted = line\nfoo2\nfoo = baz")
-          }
-        end
-        describe 'append to end of file if no match for both after and match' do
-          include_context 'resource_create' do
-            let(:match) { '^nevergoingtomatch$' }
-            let(:after) { '^stillneverafter' }
-          end
-          it {
-            provider.create
-            expect(File.read(@tmpfile).chomp).to eq("foo1\nfoo2\nfoo = baz\ninserted = line")
-          }
-        end
-      end
-      context 'with one line matching the after expression' do
-        before :each do
-          File.open(@tmpfile, 'w') do |fh|
-            fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz")
-          end
-        end
-
-        it 'inserts the specified line after the line matching the "after" expression' do
-          provider.create
-          expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz")
-        end
+      it 'detects the line' do
+        expect(provider).to be_exists
       end
+    end
+
+    context 'when matches line - line exists' do
+      let(:params) { { :match => '^foo' } }
+      let(:content) { "foo\nbar" }
 
-      context 'with multiple lines matching the after expression' do
-        before :each do
-          File.open(@tmpfile, 'w') do |fh|
-            fh.write("foo1\nfoo = blah\nfoo2\nfoo1\nfoo = baz")
-          end
-        end
-
-        it 'errors out stating "One or no line must match the pattern"' do
-          expect { provider.create }.to raise_error(Puppet::Error, /One or no line must match the pattern/)
-        end
-
-        it 'adds the line after all lines matching the after expression' do
-          @resource = Puppet::Type::File_line.new(
-            {
-              :name     => 'foo',
-              :path     => @tmpfile,
-              :line     => 'inserted = line',
-              :after    => '^foo1$',
-              :multiple => true,
-            }
-          )
-          @provider = provider_class.new(@resource)
-          expect(@provider.exists?).to eql (false) 
-          @provider.create
-          expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo1\ninserted = line\nfoo = baz")
-        end
+      it 'detects the line' do
+        expect(provider).to be_exists
       end
+    end
 
-      context 'with no lines matching the after expression' do
-        let :content do
-          "foo3\nfoo = blah\nfoo2\nfoo = baz\n"
-        end
-
-        before :each do
-          File.open(@tmpfile, 'w') do |fh|
-            fh.write(content)
-          end
-        end
-
-        it 'appends the specified line to the file' do
-          provider.create
-          expect(File.read(@tmpfile)).to eq(content << resource[:line] << "\n")
-        end
+    context 'when matches line - line does not exist' do
+      let(:params) { { :match => '^foo' } }
+      let(:content) { "foo bar\nbar" }
+
+      it 'requests changes' do
+        expect(provider).not_to be_exists
+      end
+      it 'replaces the match' do
+        provider.create
+        expect(File.read(tmpfile).chomp).to eq("foo\nbar")
       end
     end
   end
 
-  context "when removing" do
-    before :each do
-      # TODO: these should be ported over to use the PuppetLabs spec_helper
-      #  file fixtures once the following pull request has been merged:
-      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
-      tmp = Tempfile.new('tmp')
-      @tmpfile = tmp.path
-      tmp.close!
-      @resource = Puppet::Type::File_line.new(
-        {
-          :name   => 'foo',
-          :path   => @tmpfile,
-          :line   => 'foo',
-          :ensure => 'absent',
-        }
-      )
-      @provider = provider_class.new(@resource)
-    end
-    it 'should remove the line if it exists' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2")
-      end
-      @provider.destroy
-      expect(File.read(@tmpfile)).to eql("foo1\nfoo2")
+  describe 'append_on_no_match' do
+    let(:params) do
+      {
+        :append_on_no_match => false,
+        :match => '^foo1$',
+      }
     end
 
-    it 'should remove the line without touching the last new line' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2\n")
+    context 'when matching' do
+      let(:content) { "foo1\nbar" }
+
+      it 'requests changes' do
+        expect(provider).not_to be_exists
+      end
+      it 'replaces the match' do
+        provider.create
+        expect(File.read(tmpfile).chomp).to eql("foo\nbar")
       end
-      @provider.destroy
-      expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
     end
+    context 'when not matching' do
+      let(:content) { "foo3\nbar" }
 
-    it 'should remove any occurence of the line' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2\nfoo\nfoo")
+      it 'does not affect the file' do
+        expect(provider).to be_exists
       end
-      @provider.destroy
-      expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
     end
   end
 
-  context "when removing with a match" do
-    before :each do
-      # TODO: these should be ported over to use the PuppetLabs spec_helper
-      #  file fixtures once the following pull request has been merged:
-      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
-      tmp = Tempfile.new('tmp')
-      @tmpfile = tmp.path
-      tmp.close!
-      @resource = Puppet::Type::File_line.new(
+  describe 'replace_all_matches_not_matching_line' do
+    context 'when replace is false' do
+      let(:params) do
         {
-          :name              => 'foo',
-          :path              => @tmpfile,
-          :line              => 'foo2',
-          :ensure            => 'absent',
-          :match             => 'o$',
-          :match_for_absence => true,
+          :replace_all_matches_not_matching_line => true,
+          :replace => false,
         }
-      )
-      @provider = provider_class.new(@resource)
-    end
+      end
 
-    it 'should find a line to match' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2")
+      it 'raises an error' do
+        expect { provider.exists? }.to raise_error(Puppet::Error, %r{replace must be true})
       end
-      expect(@provider.exists?).to eql (true)
     end
 
-    it 'should remove one line if it matches' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2")
+    context 'when match matches line - when there are more matches than lines' do
+      let(:params) do
+        {
+          :replace_all_matches_not_matching_line => true,
+          :match => '^foo',
+          :multiple => true,
+        }
       end
-      @provider.destroy
-      expect(File.read(@tmpfile)).to eql("foo1\nfoo2")
-    end
+      let(:content) { "foo\nfoo bar\nbar\nfoo baz" }
 
-    it 'should raise an error if more than one line matches' do
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2\nfoo\nfoo")
+      it 'requests changes' do
+        expect(provider).not_to be_exists
+      end
+      it 'replaces the matches' do
+        provider.create
+        expect(File.read(tmpfile).chomp).to eql("foo\nfoo\nbar\nfoo")
       end
-      expect { @provider.destroy }.to raise_error(Puppet::Error, /More than one line/)
     end
 
-    it 'should remove multiple lines if :multiple is true' do
-      @resource = Puppet::Type::File_line.new(
+    context 'when match matches line - when there are the same matches and lines' do
+      let(:params) do
         {
-          :name              => 'foo',
-          :path              => @tmpfile,
-          :line              => 'foo2',
-          :ensure            => 'absent',
-          :match             => 'o$',
-          :multiple          => true,
-          :match_for_absence => true,
+          :replace_all_matches_not_matching_line => true,
+          :match => '^foo',
+          :multiple => true,
         }
-      )
-      @provider = provider_class.new(@resource)
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2\nfoo\nfoo")
       end
-      @provider.destroy
-      expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
+      let(:content) { "foo\nfoo\nbar" }
+
+      it 'does not request changes' do
+        expect(provider).to be_exists
+      end
     end
 
-    it 'should ignore the match if match_for_absence is not specified' do
-      @resource = Puppet::Type::File_line.new(
+    context 'when match does not match line - when there are more matches than lines' do
+      let(:params) do
         {
-          :name     => 'foo',
-          :path     => @tmpfile,
-          :line     => 'foo2',
-          :ensure   => 'absent',
-          :match    => 'o$',
+          :replace_all_matches_not_matching_line => true,
+          :match => '^bar',
+          :multiple => true,
         }
-      )
-      @provider = provider_class.new(@resource)
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2")
       end
-      @provider.destroy
-      expect(File.read(@tmpfile)).to eql("foo1\nfoo\n")
+      let(:content) { "foo\nfoo bar\nbar\nbar baz" }
+
+      it 'requests changes' do
+        expect(provider).not_to be_exists
+      end
+      it 'replaces the matches' do
+        provider.create
+        expect(File.read(tmpfile).chomp).to eql("foo\nfoo bar\nfoo\nfoo")
+      end
     end
 
-    it 'should ignore the match if match_for_absence is false' do
-      @resource = Puppet::Type::File_line.new(
+    context 'when match does not match line - when there are the same matches and lines' do
+      let(:params) do
         {
-          :name              => 'foo',
-          :path              => @tmpfile,
-          :line              => 'foo2',
-          :ensure            => 'absent',
-          :match             => 'o$',
-          :match_for_absence => false,
+          :replace_all_matches_not_matching_line => true,
+          :match => '^bar',
+          :multiple => true,
         }
-      )
-      @provider = provider_class.new(@resource)
-      File.open(@tmpfile, 'w') do |fh|
-        fh.write("foo1\nfoo\nfoo2")
       end
-      @provider.destroy
-      expect(File.read(@tmpfile)).to eql("foo1\nfoo\n")
+      let(:content) { "foo\nfoo\nbar\nbar baz" }
+
+      it 'requests changes' do
+        expect(provider).not_to be_exists
+      end
+      it 'replaces the matches' do
+        provider.create
+        expect(File.read(tmpfile).chomp).to eql("foo\nfoo\nfoo\nfoo")
+      end
+    end
+  end
+
+  context 'when match does not match line - when there are no matches' do
+    let(:params) do
+      {
+        :replace_all_matches_not_matching_line => true,
+        :match => '^bar',
+        :multiple => true,
+      }
     end
+    let(:content) { "foo\nfoo bar" }
 
+    it 'does not request changes' do
+      expect(provider).to be_exists
+    end
   end
 
+  context 'when match does not match line - when there are no matches or lines' do
+    let(:params) do
+      {
+        :replace_all_matches_not_matching_line => true,
+        :match => '^bar',
+        :multiple => true,
+      }
+    end
+    let(:content) { 'foo bar' }
+
+    it 'requests changes' do
+      expect(provider).not_to be_exists
+    end
+    it 'appends the line' do
+      provider.create
+      expect(File.read(tmpfile).chomp).to eql("foo bar\nfoo")
+    end
+  end
 end
old mode 100755 (executable)
new mode 100644 (file)
index c738a27..c2d9779
@@ -1,11 +1,9 @@
-#!/usr/bin/env ruby
-
 require 'spec_helper'
 
-anchor = Puppet::Type.type(:anchor).new(:name => "ntp::begin")
+anchor = Puppet::Type.type(:anchor).new(:name => 'ntp::begin')
 
 describe anchor do
-  it "should stringify normally" do
-    expect(anchor.to_s).to eq("Anchor[ntp::begin]")
+  it 'stringifies normally' do
+    expect(anchor.to_s).to eq('Anchor[ntp::begin]')
   end
 end
old mode 100755 (executable)
new mode 100644 (file)
index 150149b..627bdf0
@@ -1,4 +1,3 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 require 'tempfile'
 describe Puppet::Type.type(:file_line) do
@@ -19,93 +18,92 @@ describe Puppet::Type.type(:file_line) do
   let :file_line do
     Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => tmp_path)
   end
-  it 'should accept a line and path' do
+
+  it 'accepts a line' do
     file_line[:line] = 'my_line'
     expect(file_line[:line]).to eq('my_line')
+  end
+  it 'accepts a path' do
     file_line[:path] = my_path
     expect(file_line[:path]).to eq(my_path)
   end
-  it 'should accept a match regex' do
+  it 'accepts a match regex' do
     file_line[:match] = '^foo.*$'
     expect(file_line[:match]).to eq('^foo.*$')
   end
-  it 'should accept a match regex that does not match the specified line' do
+
+  it 'accepts a match regex that does not match the specified line' do
     expect {
       Puppet::Type.type(:file_line).new(
-          :name   => 'foo',
-          :path   => my_path,
-          :line   => 'foo=bar',
-          :match  => '^bar=blah$'
-    )}.not_to raise_error
+        :name => 'foo', :path => my_path, :line => 'foo=bar', :match => '^bar=blah$',
+      )
+    }.not_to raise_error
   end
-  it 'should accept a match regex that does match the specified line' do
+  it 'accepts a match regex that does match the specified line' do
     expect {
       Puppet::Type.type(:file_line).new(
-          :name   => 'foo',
-          :path   => my_path,
-          :line   => 'foo=bar',
-          :match  => '^\s*foo=.*$'
-      )}.not_to raise_error
+        :name => 'foo', :path => my_path, :line => 'foo=bar', :match => '^\s*foo=.*$',
+      )
+    }.not_to raise_error
   end
-  it 'should accept utf8 characters' do
+  it 'accepts utf8 characters' do
     expect {
       Puppet::Type.type(:file_line).new(
-          :name   => 'ƒồỗ',
-          :path   => my_path,
-          :line   => 'ƒồỗ=ьåя',
-          :match  => '^ьåя=βļάħ$'
-      )}.not_to raise_error
+        :name => 'ƒồỗ', :path => my_path, :line => 'ƒồỗ=ьåя', :match => '^ьåя=βļάħ$',
+      )
+    }.not_to raise_error
   end
-  it 'should accept double byte characters' do
+  it 'accepts double byte characters' do
     expect {
       Puppet::Type.type(:file_line).new(
-          :name   => 'フーバー',
-          :path   => my_path,
-          :line   => 'この=それ',
-          :match  => '^この=ああ$'
-      )}.not_to raise_error
+        :name => 'フーバー', :path => my_path, :line => 'この=それ', :match => '^この=ああ$',
+      )
+    }.not_to raise_error
   end
-  it 'should accept posix filenames' do
+  it 'accepts posix filenames' do
     file_line[:path] = tmp_path
     expect(file_line[:path]).to eq(tmp_path)
   end
-  it 'should not accept unqualified path' do
-    expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, /File paths must be fully qualified/)
+  it 'does not accept unqualified path' do
+    expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, %r{File paths must be fully qualified})
   end
-  it 'should require that a line is specified' do
-    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, /line is a required attribute/)
+  it 'requires that a line is specified' do
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, %r{line is a required attribute})
   end
-  it 'should not require that a line is specified when matching for absence' do
-    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error
+  it 'does not require that a line is specified when matching for absence' do
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Metrics/LineLength
   end
-  it 'should require that a file is specified' do
-    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/)
+  it 'although if a line is specified anyway when matching for absence it still works and the line is silently ignored' do
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Metrics/LineLength
   end
-  it 'should default to ensure => present' do
+  it 'requires that a file is specified' do
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, %r{path is a required attribute})
+  end
+  it 'defaults to ensure => present' do
     expect(file_line[:ensure]).to eq :present
   end
-  it 'should default to replace => true' do
+  it 'defaults to replace => true' do
     expect(file_line[:replace]).to eq :true
   end
-  it 'should default to encoding => UTF-8' do
+  it 'defaults to encoding => UTF-8' do
     expect(file_line[:encoding]).to eq 'UTF-8'
   end
-  it 'should accept encoding => iso-8859-1' do
+  it 'accepts encoding => iso-8859-1' do
     expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :present, :encoding => 'iso-8859-1', :line => 'bar') }.not_to raise_error
   end
-  it "should autorequire the file it manages" do
+
+  it 'autorequires the file it manages' do
     catalog = Puppet::Resource::Catalog.new
     file = Puppet::Type.type(:file).new(:name => tmp_path)
     catalog.add_resource file
     catalog.add_resource file_line
-
     relationship = file_line.autorequire.find do |rel|
-      (rel.source.to_s == "File[#{tmp_path}]") and (rel.target.to_s == file_line.to_s)
+      (rel.source.to_s == "File[#{tmp_path}]") && (rel.target.to_s == file_line.to_s)
     end
     expect(relationship).to be_a Puppet::Relationship
   end
 
-  it "should not autorequire the file it manages if it is not managed" do
+  it 'does not autorequire the file it manages if it is not managed' do
     catalog = Puppet::Resource::Catalog.new
     catalog.add_resource file_line
     expect(file_line.autorequire).to be_empty
index d11784e..60f9c86 100644 (file)
@@ -4,4 +4,4 @@
 # slash = '[\\\\/]'
 # name = '[^\\\\/]+'
 # %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
-type Stdlib::Compat::Absolute_path = Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]]
+type Stdlib::Compat::Absolute_path = Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]] # lint:ignore:140chars
index e5cadb6..047344d 100644 (file)
@@ -20,4 +20,4 @@
 # > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers.
 #
 # This allows you to find all places where a consumers of your code call it with unexpected values.
-type Stdlib::Compat::Integer = Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]]
+type Stdlib::Compat::Integer = Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]] # lint:ignore:140chars
index a0ba0d6..87a4dc9 100644 (file)
@@ -1,2 +1,2 @@
 # Emulate the validate_ipv4_address and is_ipv4_address functions
-type Stdlib::Compat::Ipv4 = Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/]
+type Stdlib::Compat::Ipv4 = Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/] # lint:ignore:140chars
index 8b82f1a..0a9677e 100644 (file)
@@ -1 +1 @@
-type Stdlib::Compat::Ipv6 = Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/]
+type Stdlib::Compat::Ipv6 = Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/] # lint:ignore:140chars
index 5bfc3d3..3cf9c0d 100644 (file)
@@ -20,4 +20,4 @@
 # > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers.
 #
 # This allows you to find all places where a consumers of your code call it with unexpected values.
-type Stdlib::Compat::Numeric = Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]]
+type Stdlib::Compat::Numeric = Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]] # lint:ignore:140chars
index 36fd30f..e7ec43a 100644 (file)
@@ -1 +1 @@
-type Stdlib::HTTPSUrl = Pattern[/^https:\/\//]
+type Stdlib::HTTPSUrl = Pattern[/(?i:^https:\/\/)/]
index 0d93a95..5b3a1da 100644 (file)
@@ -1 +1 @@
-type Stdlib::HTTPUrl = Pattern[/^https?:\/\//]
+type Stdlib::HTTPUrl = Pattern[/(?i:^https?:\/\/)/]
index 4103574..6445957 100644 (file)
@@ -1,2 +1,5 @@
 # A type for a MAC address
-type Stdlib::MAC = Pattern[/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/]
+type Stdlib::MAC = Pattern[
+  /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
+  /^([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})$/
+]
index ec3bf7d..0736852 100644 (file)
@@ -1,2 +1,2 @@
-# this regex rejects any path component that is a / or a NUL
-type Stdlib::Unixpath = Pattern[/^\/([^\/\0]+\/*)+$/]
+# this regex rejects any path component that does not start with "/" or is NUL
+type Stdlib::Unixpath = Pattern[/^\/([^\/\0]+\/*)*$/]