Update stdlib
authorPeter Palfrader <peter@palfrader.org>
Thu, 31 Aug 2017 21:13:32 +0000 (23:13 +0200)
committerPeter Palfrader <peter@palfrader.org>
Thu, 31 Aug 2017 21:13:32 +0000 (23:13 +0200)
539 files changed:
3rdparty/Puppetfile
3rdparty/modules/stdlib/CHANGELOG.md
3rdparty/modules/stdlib/CONTRIBUTING.md
3rdparty/modules/stdlib/Gemfile
3rdparty/modules/stdlib/LICENSE
3rdparty/modules/stdlib/MAINTAINERS.md [new file with mode: 0644]
3rdparty/modules/stdlib/NOTICE [new file with mode: 0644]
3rdparty/modules/stdlib/README.markdown [deleted file]
3rdparty/modules/stdlib/README.md [new file with mode: 0644]
3rdparty/modules/stdlib/Rakefile
3rdparty/modules/stdlib/appveyor.yml [new file with mode: 0644]
3rdparty/modules/stdlib/checksums.json
3rdparty/modules/stdlib/examples/file_line.pp [new file with mode: 0644]
3rdparty/modules/stdlib/examples/has_interface_with.pp [new file with mode: 0644]
3rdparty/modules/stdlib/examples/has_ip_address.pp [new file with mode: 0644]
3rdparty/modules/stdlib/examples/has_ip_network.pp [new file with mode: 0644]
3rdparty/modules/stdlib/examples/init.pp [new file with mode: 0644]
3rdparty/modules/stdlib/lib/facter/facter_dot_d.rb
3rdparty/modules/stdlib/lib/facter/package_provider.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/facter/pe_version.rb
3rdparty/modules/stdlib/lib/facter/puppet_settings.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/facter/puppet_vardir.rb [deleted file]
3rdparty/modules/stdlib/lib/facter/root_home.rb
3rdparty/modules/stdlib/lib/facter/service_provider.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/fact.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/length.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/type_of.rb
3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/abs.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb [new file with mode: 0644]
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/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 [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/concat.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/count.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 [new file with mode: 0644]
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 [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/difference.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb [new file with mode: 0644]
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 [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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/hash.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/intersection.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb [new file with mode: 0644]
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 [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb [new file with mode: 0644]
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/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/prefix.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb [new file with mode: 0644]
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 [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/reverse.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/rstrip.rb
3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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/file_line.rb
3rdparty/modules/stdlib/locales/config.yaml [new file with mode: 0644]
3rdparty/modules/stdlib/locales/ja/puppetlabs-stdlib.po [new file with mode: 0644]
3rdparty/modules/stdlib/locales/puppetlabs-stdlib.pot [new file with mode: 0644]
3rdparty/modules/stdlib/manifests/init.pp
3rdparty/modules/stdlib/manifests/stages.pp
3rdparty/modules/stdlib/metadata.json
3rdparty/modules/stdlib/readmes/README_ja_JP.md [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/abs_spec.rb
3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/acceptance/any2array_spec.rb
3rdparty/modules/stdlib/spec/acceptance/base64_spec.rb
3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb
3rdparty/modules/stdlib/spec/acceptance/capitalize_spec.rb
3rdparty/modules/stdlib/spec/acceptance/ceiling_spec.rb
3rdparty/modules/stdlib/spec/acceptance/chomp_spec.rb
3rdparty/modules/stdlib/spec/acceptance/chop_spec.rb
3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/acceptance/concat_spec.rb
3rdparty/modules/stdlib/spec/acceptance/count_spec.rb
3rdparty/modules/stdlib/spec/acceptance/deep_merge_spec.rb
3rdparty/modules/stdlib/spec/acceptance/defined_with_params_spec.rb
3rdparty/modules/stdlib/spec/acceptance/delete_at_spec.rb
3rdparty/modules/stdlib/spec/acceptance/delete_spec.rb
3rdparty/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb
3rdparty/modules/stdlib/spec/acceptance/delete_values_spec.rb
3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/difference_spec.rb
3rdparty/modules/stdlib/spec/acceptance/dirname_spec.rb
3rdparty/modules/stdlib/spec/acceptance/downcase_spec.rb
3rdparty/modules/stdlib/spec/acceptance/empty_spec.rb
3rdparty/modules/stdlib/spec/acceptance/ensure_packages_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/acceptance/ensure_resource_spec.rb
3rdparty/modules/stdlib/spec/acceptance/flatten_spec.rb
3rdparty/modules/stdlib/spec/acceptance/floor_spec.rb
3rdparty/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb
3rdparty/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb
3rdparty/modules/stdlib/spec/acceptance/get_module_path_spec.rb
3rdparty/modules/stdlib/spec/acceptance/getparam_spec.rb
3rdparty/modules/stdlib/spec/acceptance/getvar_spec.rb
3rdparty/modules/stdlib/spec/acceptance/grep_spec.rb
3rdparty/modules/stdlib/spec/acceptance/has_interface_with_spec.rb
3rdparty/modules/stdlib/spec/acceptance/has_ip_address_spec.rb
3rdparty/modules/stdlib/spec/acceptance/has_ip_network_spec.rb
3rdparty/modules/stdlib/spec/acceptance/has_key_spec.rb
3rdparty/modules/stdlib/spec/acceptance/hash_spec.rb
3rdparty/modules/stdlib/spec/acceptance/intersection_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/is_array_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_bool_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_domain_name_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_float_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_function_available_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_hash_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_integer_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_ip_address_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/acceptance/is_mac_address_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_numeric_spec.rb
3rdparty/modules/stdlib/spec/acceptance/is_string_spec.rb
3rdparty/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb
3rdparty/modules/stdlib/spec/acceptance/join_spec.rb
3rdparty/modules/stdlib/spec/acceptance/keys_spec.rb
3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/loadyaml_spec.rb
3rdparty/modules/stdlib/spec/acceptance/lstrip_spec.rb
3rdparty/modules/stdlib/spec/acceptance/max_spec.rb
3rdparty/modules/stdlib/spec/acceptance/member_spec.rb
3rdparty/modules/stdlib/spec/acceptance/merge_spec.rb
3rdparty/modules/stdlib/spec/acceptance/min_spec.rb
3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-7-x64.yml [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/nodesets/debian-8-x64.yml [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/nodesets/default.yml
3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/centos-7.yml [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/debian-8.yml [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/ubuntu-14.04.yml [new file with mode: 0644]
3rdparty/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml [deleted file]
3rdparty/modules/stdlib/spec/acceptance/num2bool_spec.rb
3rdparty/modules/stdlib/spec/acceptance/parsejson_spec.rb
3rdparty/modules/stdlib/spec/acceptance/parseyaml_spec.rb
3rdparty/modules/stdlib/spec/acceptance/pick_default_spec.rb
3rdparty/modules/stdlib/spec/acceptance/pick_spec.rb
3rdparty/modules/stdlib/spec/acceptance/prefix_spec.rb
3rdparty/modules/stdlib/spec/acceptance/pw_hash_spec.rb
3rdparty/modules/stdlib/spec/acceptance/range_spec.rb
3rdparty/modules/stdlib/spec/acceptance/reject_spec.rb
3rdparty/modules/stdlib/spec/acceptance/reverse_spec.rb
3rdparty/modules/stdlib/spec/acceptance/rstrip_spec.rb
3rdparty/modules/stdlib/spec/acceptance/shuffle_spec.rb
3rdparty/modules/stdlib/spec/acceptance/size_spec.rb
3rdparty/modules/stdlib/spec/acceptance/sort_spec.rb
3rdparty/modules/stdlib/spec/acceptance/squeeze_spec.rb
3rdparty/modules/stdlib/spec/acceptance/str2bool_spec.rb
3rdparty/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb
3rdparty/modules/stdlib/spec/acceptance/strftime_spec.rb
3rdparty/modules/stdlib/spec/acceptance/strip_spec.rb
3rdparty/modules/stdlib/spec/acceptance/suffix_spec.rb
3rdparty/modules/stdlib/spec/acceptance/swapcase_spec.rb
3rdparty/modules/stdlib/spec/acceptance/time_spec.rb
3rdparty/modules/stdlib/spec/acceptance/to_bytes_spec.rb
3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/acceptance/type_spec.rb
3rdparty/modules/stdlib/spec/acceptance/union_spec.rb
3rdparty/modules/stdlib/spec/acceptance/unique_spec.rb
3rdparty/modules/stdlib/spec/acceptance/unsupported_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/acceptance/upcase_spec.rb
3rdparty/modules/stdlib/spec/acceptance/uriescape_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_array_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_augeas_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_bool_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_cmd_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_hash_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_re_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_slength_spec.rb
3rdparty/modules/stdlib/spec/acceptance/validate_string_spec.rb
3rdparty/modules/stdlib/spec/acceptance/values_at_spec.rb
3rdparty/modules/stdlib/spec/acceptance/values_spec.rb
3rdparty/modules/stdlib/spec/acceptance/zip_spec.rb
3rdparty/modules/stdlib/spec/aliases/absolute_path_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/absolutepath_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/array_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/bool_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/float_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/hash_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/httpsurl_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/httpurl_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/integer_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/ip_address.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/ipv4_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/ipv6_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/numeric_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/string_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/unixpath_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/aliases/windowspath_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/classes/anchor_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/fixtures/dscacheutil/root [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/lsuser/root [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolute_path.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolutepath.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/array.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/bool.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/deftype.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ensure_resources.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/float.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/hash.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpsurl.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/httpurl.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/integer.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ip_address.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv4.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/ipv6.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/numeric.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/string.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/unixpath.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/fixtures/test/manifests/windowspath.pp [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/abs_spec.rb
3rdparty/modules/stdlib/spec/functions/any2array_spec.rb
3rdparty/modules/stdlib/spec/functions/any2bool_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/assert_private_spec.rb
3rdparty/modules/stdlib/spec/functions/base64_spec.rb
3rdparty/modules/stdlib/spec/functions/basename_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb
3rdparty/modules/stdlib/spec/functions/bool2str_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/camelcase_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/capitalize_spec.rb
3rdparty/modules/stdlib/spec/functions/ceiling_spec.rb
3rdparty/modules/stdlib/spec/functions/chomp_spec.rb
3rdparty/modules/stdlib/spec/functions/chop_spec.rb
3rdparty/modules/stdlib/spec/functions/clamp_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/concat_spec.rb
3rdparty/modules/stdlib/spec/functions/convert_base_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/count_spec.rb
3rdparty/modules/stdlib/spec/functions/deep_merge_spec.rb
3rdparty/modules/stdlib/spec/functions/defined_with_params_spec.rb
3rdparty/modules/stdlib/spec/functions/delete_at_spec.rb
3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/delete_spec.rb
3rdparty/modules/stdlib/spec/functions/delete_undef_values_spec.rb
3rdparty/modules/stdlib/spec/functions/delete_values_spec.rb
3rdparty/modules/stdlib/spec/functions/deprecation_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/difference_spec.rb
3rdparty/modules/stdlib/spec/functions/dig44_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/dig_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/dirname_spec.rb
3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/downcase_spec.rb
3rdparty/modules/stdlib/spec/functions/empty_spec.rb
3rdparty/modules/stdlib/spec/functions/ensure_packages_spec.rb
3rdparty/modules/stdlib/spec/functions/ensure_resource_spec.rb
3rdparty/modules/stdlib/spec/functions/ensure_resources_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/flatten_spec.rb
3rdparty/modules/stdlib/spec/functions/floor_spec.rb
3rdparty/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb
3rdparty/modules/stdlib/spec/functions/fqdn_rotate_spec.rb
3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/get_module_path_spec.rb
3rdparty/modules/stdlib/spec/functions/getparam_spec.rb
3rdparty/modules/stdlib/spec/functions/getvar_spec.rb
3rdparty/modules/stdlib/spec/functions/glob_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/grep_spec.rb
3rdparty/modules/stdlib/spec/functions/has_interface_with_spec.rb
3rdparty/modules/stdlib/spec/functions/has_ip_address_spec.rb
3rdparty/modules/stdlib/spec/functions/has_ip_network_spec.rb
3rdparty/modules/stdlib/spec/functions/has_key_spec.rb
3rdparty/modules/stdlib/spec/functions/hash_spec.rb
3rdparty/modules/stdlib/spec/functions/intersection_spec.rb
3rdparty/modules/stdlib/spec/functions/is_a_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/is_array_spec.rb
3rdparty/modules/stdlib/spec/functions/is_bool_spec.rb
3rdparty/modules/stdlib/spec/functions/is_domain_name_spec.rb
3rdparty/modules/stdlib/spec/functions/is_email_address_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/is_float_spec.rb
3rdparty/modules/stdlib/spec/functions/is_function_available.rb
3rdparty/modules/stdlib/spec/functions/is_hash_spec.rb
3rdparty/modules/stdlib/spec/functions/is_integer_spec.rb
3rdparty/modules/stdlib/spec/functions/is_ip_address_spec.rb
3rdparty/modules/stdlib/spec/functions/is_ipv4_address_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/is_mac_address_spec.rb
3rdparty/modules/stdlib/spec/functions/is_numeric_spec.rb
3rdparty/modules/stdlib/spec/functions/is_string_spec.rb
3rdparty/modules/stdlib/spec/functions/join_keys_to_values_spec.rb
3rdparty/modules/stdlib/spec/functions/join_spec.rb
3rdparty/modules/stdlib/spec/functions/keys_spec.rb
3rdparty/modules/stdlib/spec/functions/length.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/loadyaml_spec.rb
3rdparty/modules/stdlib/spec/functions/lstrip_spec.rb
3rdparty/modules/stdlib/spec/functions/max_spec.rb
3rdparty/modules/stdlib/spec/functions/member_spec.rb
3rdparty/modules/stdlib/spec/functions/merge_spec.rb
3rdparty/modules/stdlib/spec/functions/min_spec.rb
3rdparty/modules/stdlib/spec/functions/num2bool_spec.rb
3rdparty/modules/stdlib/spec/functions/parsejson_spec.rb
3rdparty/modules/stdlib/spec/functions/parseyaml_spec.rb
3rdparty/modules/stdlib/spec/functions/pick_default_spec.rb
3rdparty/modules/stdlib/spec/functions/pick_spec.rb
3rdparty/modules/stdlib/spec/functions/prefix_spec.rb
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
3rdparty/modules/stdlib/spec/functions/regexpescape_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/reject_spec.rb
3rdparty/modules/stdlib/spec/functions/reverse_spec.rb
3rdparty/modules/stdlib/spec/functions/round_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/rstrip_spec.rb
3rdparty/modules/stdlib/spec/functions/seeded_rand_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/shell_escape_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/shell_join_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/shell_split_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/shuffle_spec.rb
3rdparty/modules/stdlib/spec/functions/size_spec.rb
3rdparty/modules/stdlib/spec/functions/sort_spec.rb
3rdparty/modules/stdlib/spec/functions/squeeze_spec.rb
3rdparty/modules/stdlib/spec/functions/str2bool_spec.rb
3rdparty/modules/stdlib/spec/functions/str2saltedsha512_spec.rb
3rdparty/modules/stdlib/spec/functions/strftime_spec.rb
3rdparty/modules/stdlib/spec/functions/strip_spec.rb
3rdparty/modules/stdlib/spec/functions/suffix_spec.rb
3rdparty/modules/stdlib/spec/functions/swapcase_spec.rb
3rdparty/modules/stdlib/spec/functions/time_spec.rb
3rdparty/modules/stdlib/spec/functions/to_bytes_spec.rb
3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/type3x_spec.rb
3rdparty/modules/stdlib/spec/functions/type_of_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/type_spec.rb
3rdparty/modules/stdlib/spec/functions/union_spec.rb
3rdparty/modules/stdlib/spec/functions/unique_spec.rb
3rdparty/modules/stdlib/spec/functions/unix2dos_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/upcase_spec.rb
3rdparty/modules/stdlib/spec/functions/uriescape_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_absolute_path_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_array_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_augeas_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_bool_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_cmd_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_domain_name_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/validate_email_address_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/validate_hash_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_integer_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_ip_address_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_legacy_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/functions/validate_numeric_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_re_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_slength_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_string_spec.rb
3rdparty/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb [new file with mode: 0755]
3rdparty/modules/stdlib/spec/functions/values_at_spec.rb
3rdparty/modules/stdlib/spec/functions/values_spec.rb
3rdparty/modules/stdlib/spec/functions/zip_spec.rb
3rdparty/modules/stdlib/spec/lib/puppet_spec/compiler.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/database.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/files.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/fixtures.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/matchers.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/modules.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/pops.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/scope.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/settings.rb [deleted file]
3rdparty/modules/stdlib/spec/lib/puppet_spec/verbose.rb [deleted file]
3rdparty/modules/stdlib/spec/spec.opts [deleted file]
3rdparty/modules/stdlib/spec/spec_helper.rb
3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb
3rdparty/modules/stdlib/spec/spec_helper_local.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/support/shared_data.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/unit/facter/package_provider_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/unit/facter/pe_version_spec.rb
3rdparty/modules/stdlib/spec/unit/facter/root_home_spec.rb
3rdparty/modules/stdlib/spec/unit/facter/service_provider_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb
3rdparty/modules/stdlib/spec/unit/puppet/functions/type_of_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/basename_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/bool2str_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/camelcase_spec.rb [deleted file]
3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb [new file with mode: 0644]
3rdparty/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb
3rdparty/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb
3rdparty/modules/stdlib/tests/file_line.pp [deleted file]
3rdparty/modules/stdlib/tests/has_interface_with.pp [deleted file]
3rdparty/modules/stdlib/tests/has_ip_address.pp [deleted file]
3rdparty/modules/stdlib/tests/has_ip_network.pp [deleted file]
3rdparty/modules/stdlib/tests/init.pp [deleted file]
3rdparty/modules/stdlib/types/absolutepath.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/absolute_path.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/array.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/bool.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/float.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/hash.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/integer.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/ip_address.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/ipv4.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/ipv6.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/numeric.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/re.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/compat/string.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/httpsurl.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/httpurl.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/mac.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/unixpath.pp [new file with mode: 0644]
3rdparty/modules/stdlib/types/windowspath.pp [new file with mode: 0644]

index 22f360c..c60bf5d 100644 (file)
@@ -1,6 +1,6 @@
 forge "http://forge.puppetlabs.com"
 
-mod 'puppetlabs/stdlib', '4.6.0'
+mod 'puppetlabs/stdlib', '4.19.0'
 mod 'puppetlabs/concat', '1.2.2'
 mod 'puppetlabs/rabbitmq', '5.2.1'
 mod 'puppetlabs-postgresql', '5.1.0'
index c17e750..f021e64 100644 (file)
@@ -1,9 +1,328 @@
-##2015-04-14 - Supported Release 4.6.0
-###Summary
+# Change log
+
+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 4.19.0
+### Summary
+
+This release adds new functions and better documentation/fixes for existing functions with a noteworthy fix for file_line.
+
+#### Added
+- Add validate_domain_name function
+- Add the round function
+- Add type for MAC address
+- Add support for sensitive data type to pw_hash ([MODULES-4908](https://tickets.puppet.com/browse/MODULES-4908))
+- 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) 
+- Fix headers in CHANGELOG.md so that headers render correctly
+- ensure_packages, converge ensure values 'present' and 'installed'
+
+#### Changed
+- Removes listed support for EOL Ubuntu versions
+
+## Supported Release 4.18.0
+### Summary
+
+Small release that reverts the Puppet version requirement lower bound to again include Puppet 2.7+ and bumps the upper bound to now include Puppet 5.
+
+#### Fixed
+- Reverts lower bound of Puppet requirement to 2.7.20
+
+## Supported Release 4.17.1
+### Summary
+
+Small release to address a bug (PUP-7650). Also pushes the Puppet version compatibility to 4.7.0.
+
+#### Bugfixes
+- (MODULES-5095) Workaround for PUP-7650
+- (FM-6197) Formatting fixes for file_line resource
+
+
+## Supported Release 4.17.0
+### Summary
+This release adds support for internationalization. It also contains Japanese translations for the README, summary and description of the metadata.json and major cleanups in the README. Additional folders have been introduced called locales and readmes where translation files can be found. A number of features and bug fixes are also included in this release. It also adds a new function `glob()` for expanding file lists. Also works around an issue that appeared in puppet 4.6.0 involving types being declared multiple times.
+
+#### Features
+- Addition of POT file / folder structure for i18n.
+- Addition of Internationalized READMEs.
+- `glob()` function
+
+### Fixed
+- Occasional duplicate type definitions when using `defined_with_params()`
+- `file_line` encoding issue on ruby 1.8 (unsupported)
+- Huge readme refresh
+
+## Supported Release 4.16.0
+### Summary
+
+This release sees a massive update to all unit tests to test UTF8 characters. There are also multiple cleanups in preparation for internationalization. Alongside this, improvements to ipv6 support, a new length function compatible with Puppet 4, and an update to path types. Also contains multiple bug fixes around functionality and tests.
+
+#### Features
+- Addition of coverage in all unit tests for functions, data and resource types for UTF8 for i18n.
+- All strings within the readme and functions that are split over two lines have been combined in preparation for i18n parser/decorator.
+- Improvement on the ipv6 support for type - Improves regex to catch some valid (but lesser known) ipv6 strings, mostly those which are a mix of ipv6 strings and embedded ipv6 numbers.
+- Adds a new parameter `encoding` to allow non UTF-8 files to specify a file encoding. This prevents receiving the error message "invalid byte sequence in UTF-8" when special characters that are not UTF-8 encoded appear in the input stream, such as the copyright symbol.
+- Addition of the new length function. Returns the length of a given string, array or hash. To eventually replace the deprecated size() function as can handle the new type functionality introduced in Puppet 4.
+- Permit double slash in absolute/Unix path types.
+
+#### Bugfixes
+- Fix unsupported data type error with rspec-puppet master.
+- Now allows test module metadata.json to be read by Puppet.
+- Fix acceptance test failure "Hiera is not a class".
+- Removal of unsupported platforms and future parser setting in acceptance tests.
+- Regex for tuple checking has been loosened.
+- Ensure_packages function - Now only tries to apply the resource if not defined.
+- (MODULES-4528) Use versioncmp to check Puppet version for 4.10.x compat.
+- Adds comments to warn for UTF8 incompatibility of the functions that may not be compatible with UTF8 with Ruby < 2.4.0.
+
+## Supported Release 4.15.0
+### Summary
+
+This release introduces multiple new functions, a new fact and the addition of Ubuntu Xenial support. Also includes a bugfix and documentation update.
+
+#### Features
+- Addition of puppet_server fact to return agents server.
+- Addition of a pry function.
+- Addition of tests for ensure_resources.
+- Addition of FQDN UUID generation function.
+- Addition of Ubuntu Xenial to OS Support.
+
+#### Bugfixes
+- Ensure_packages now works with Ruby < 2.0.
+- Updated the documentation of str2bool function.
+
+## Supported Release 4.14.0
+### Summary
+
+Adds several new features and updates, especially around refining the deprecation and validate_legacy functions. Also includes a Gemfile update around an issue with parallel_tests dependancy for different versions of Ruby.
+
+#### Features
+- Deprecation function now uses puppet stacktrace if available.
+- join_key_to_values function now handles array values. If values are arrays, multiple keys are added for each element.
+- Updated Gemfile to deal with parallel_tests Ruby dependancy (MODULES-3983).
+- Updated/Fixed ipv4 regex validator (MODULES-3980).
+- Deprecation clarification added to README.
+
+#### Bugfixes
+- README typo fixes.
+- Use .dup to duplicate classes for modification (MODULES-3829).
+- Fixes spec failures that were caused by a change in the tested error message in validate_legacy_spec.
+- Broken link to validate_legacy docs fixed.
+- Updates deprecation tests to include future parser.
+
+## Supported Release 4.13.1
+### Summary
+
+This bugfix release addresses the `undefined method 'optional_repeated_param'` error messages seen by users of puppet 3.7.
+
+It also improves the user experience around function deprecations by emitting one warning per function(-name) instead of only one deprecation overall. This allows users to identify all deprecated functions used in one agent run, with less back-and-forth.
+
+#### Bugfixes
+
+* Emit deprecations warnings for each function, instead of once per process. (MODULES-3961)
+* Use a universally available API for the v4 deprecation stubs of `is_*` and `validate_*`. (MODULES-3962)
+* Make `getvar()` compatible to ruby 1.8.7. (MODULES-3969)
+* Add v4 deprecation stubs for the `is_` counterparts of the deprecated functions to emit the deprecations warnings in all cases.
+
+
+## Supported Release 4.13.0
+### Summary
+
+This version of stdlib deprecates a whole host of functions, and provides stepping stones to move to Puppet 4 type validations. Be sure to check out the new `deprecation()` and `validate_legacy()` functions to migrate off the deprecated v3-style data validations.
+
+Many thanks to all community contributors: bob, Dmitry Ilyin, Dominic Cleal, Joris, Joseph Yaworski, Loic Antoine-Gombeaud, Maksym Melnychok, Michiel Brandenburg, Nate Potter, Romain Tartière, Stephen Benjamin, and Steve Moore, as well as anyone contributing in the code review process and by submitting issues.
+
+Special thanks to [Voxpupuli's](https://voxpupuli.org/) Igor Galić for donating the puppet-tea types to kickstart this part of stdlib.
+
+
+#### Deprecations
+* `validate_absolute_path`, `validate_array`, `validate_bool`, `validate_hash`, `validate_integer`, `validate_ip_address`, `validate_ipv4_address`, `validate_ipv6_address`, `validate_numeric`, `validate_re`, `validate_slength`, `validate_string`, and their `is_` counter parts are now deprecated on Puppet 4. See the `validate_legacy()` description in the README for help on migrating away from those functions.
+* The `dig` function is provided by core puppet since 4.5.0 with slightly different calling convention. The stdlib version can still be accessed as `dig44` for now.
+
+
+#### Features
+* Add Puppet 4 data types for Unix, and Windows paths, and URLs.
+* Add `deprecation` function to warn users of functionality that will be removed soon.
+* Add `validate_legacy` function to help with migrating to Puppet 4 data types.
+
+* Add `any2bool` function, a combination of of `string2bool` and `num2bool`.
+* Add `delete_regex` function to delete array elements matching a regular expression.
+* Add `puppet_environmentpath` fact to expose the `environmentpath` setting.
+* Add `regexpescape` function to safely insert arbitrary strings into regular expressions.
+* Add `shell_escape`, `shell_join`, and `shell_split` functions for safer working with shell scripts..
+
+* The `delete` function now also accepts regular expressions as search term.
+* The `loadyaml` function now accepts a default value, which is returned when there is an error loading the file.
+
+#### Bugfixes
+* Fix `file_line.match_for_absence` implementation and description to actually work. (MODULES-3590)
+* Fix `getparam` so that it can now also return `false`. (MODULES-3933)
+* Fix the fixture setup for testing and adjust `load_module_metadata` and `loadjson` tests.
+* Fix `defined_with_params` to handle `undef` correctly on all puppet versions. (PUP-6422, MODULES-3543)
+* Fix `file_line.path` validation to use puppet's built in `absolute_path?` matcher.
+
+#### Minor Improvements
+* README changes: improved descriptions of `deep_merge`, `delete`, `ensure_packages`, `file_line.after`, `range`, and `validate_numeric`.
+* The `getvar` function now returns nil in all situations where the variable is not found.
+* Update the `dig44` function with better `undef`, `nil`, and `false` handling.
+* Better wording on `str2bool` argument validation error message.
+
+
+### Known issues
+* The `validate_legacy` function relies on internal APIs from Puppet 4.4.0 (PE 2016.1) onwards, and doesn't work on earlier versions.
+* Puppet 4.5.0 (PE 2016.2) has a number of improvements around data types - especially error handling - that make working with them much nicer.
+
+## Supported Release 4.12.0
+### Summary
+
+This release provides several new functions, bugfixes, modulesync changes, and some documentation updates.
+
+#### Features
+- Adds `clamp`. This function keeps values within a specified range.
+- Adds `validate_x509_rsa_key_pair`. This function validates an x509 RSA certificate and key pair.
+- Adds `dig`. This function performs a deep lookup in nested hashes or arrays.
+- Extends the `base64` support to fit `rfc2045` and `rfc4648`.
+- Adds `is_ipv6_address` and `is_ipv4_address`. These functions validate the specified ipv4 or ipv6 addresses.
+- Adds `enclose_ipv6`. This function encloses IPv6 addresses in square brackets.
+- Adds `ensure_resources`. This function takes a list of resources and creates them if they do not exist.
+- Extends `suffix` to support applying a suffix to keys in a hash.
+- Apply modulesync changes.
+- Add validate_email_address function.
+
+#### Bugfixes
+- Fixes `fqdn_rand_string` tests, since Puppet 4.4.0 and later have a higher `fqdn_rand` ceiling.
+- (MODULES-3152) Adds a check to `package_provider` to prevent failures if Gem is not installed.
+- Fixes to README.md.
+- Fixes catch StandardError rather than the gratuitous Exception
+- Fixes file_line attribute validation.
+- Fixes concat with Hash arguments.
+
+## Supported Release 4.11.0
+### Summary
+
+Provides a validate_absolute_paths and Debian 8 support. There is a fix to the is_package_provider fact and a test improvement.
+
+#### Features
+-  Adds new parser called is_absolute_path
+-  Supports Debian 8
+
+#### Bugfixes
+-  Allow package_provider fact to resolve on PE 3.x
+
+#### Improvements
+- ensures that the test passes independently of changes to rubygems for ensure_resource
+
+## 2015-12-15 - Supported Release 4.10.0
+### Summary
+
+Includes the addition of several new functions and considerable improvements to the existing functions, tests and documentation. Includes some bug fixes which includes compatibility, test and fact issues.
+
+#### Features
+- Adds service_provider fact
+- Adds is_a() function
+- Adds package_provider fact
+- Adds validate_ip_address function
+- Adds seeded_rand function
+
+#### Bugfixes
+- Fix backwards compatibility from an improvement to the parseyaml function
+- Renaming of load_module_metadata test to include _spec.rb
+- Fix root_home fact on AIX 5.x, now '-c' rather than '-C'
+- Fixed Gemfile to work with ruby 1.8.7
+
+#### Improvements
+- (MODULES-2462) Improvement of parseyaml function
+- Improvement of str2bool function
+- Improvement to readme
+- Improvement of intersection function
+- Improvement of validate_re function
+- Improved speed on Facter resolution of service_provider
+- empty function now handles numeric values
+- Package_provider now prevents deprecation warning about the allow_virtual parameter
+- load_module_metadata now succeeds on empty file
+- Check added to ensure puppetversion value is not nil
+- Improvement to bool2str to return a string of choice using boolean
+- Improvement to naming convention in validate_ipv4_address function
+
+## Supported Release 4.9.1
+### Summary
+
+Small release for support of newer PE versions. This increments the version of PE in the metadata.json file.
+
+## 2015-09-08 - Supported Release 4.9.0
+### Summary
+
+This release adds new features including the new functions dos2unix, unix2dos, try_get_value, convert_base as well as other features and improvements.
+
+#### Features
+- (MODULES-2370) allow `match` parameter to influence `ensure => absent` behavior
+- (MODULES-2410) Add new functions dos2unix and unix2dos
+- (MODULE-2456) Modify union to accept more than two arrays
+- Adds a convert_base function, which can convert numbers between bases
+- Add a new function "try_get_value"
+
+#### Bugfixes
+- n/a
+
+#### Improvements
+- (MODULES-2478) Support root_home fact on AIX through "lsuser" command
+- Acceptance test improvements
+- Unit test improvements
+- Readme improvements
+
+## 2015-08-10 - Supported Release 4.8.0
+### Summary
+This release adds a function for reading metadata.json from any module, and expands file\_line's abilities.
+
+#### Features
+- New parameter `replace` on `file_line`
+- New function `load_module_metadata()` to load metadata.json and return the content as a hash.
+- Added hash support to `size()`
+
+#### Bugfixes
+- Fix various docs typos
+- Fix `file_line` resource on puppet < 3.3
+
+## 2015-06-22 - Supported Release 4.7.0
+### Summary
+
+Adds Solaris 12 support along with improved Puppet 4 support. There are significant test improvements, and some minor fixes.
+
+#### Features
+- Add support for Solaris 12
+
+#### Bugfixes
+- Fix for AIO Puppet 4
+- Fix time for ruby 1.8.7
+- Specify rspec-puppet version
+- range() fix for typeerror and missing functionality
+- Fix pw_hash() on JRuby < 1.7.17
+- fqdn_rand_string: fix argument error message
+- catch and rescue from looking up non-existent facts
+- Use puppet_install_helper, for Puppet 4
+
+#### Improvements
+- Enforce support for Puppet 4 testing
+- fqdn_rotate/fqdn_rand_string acceptance tests and implementation
+- Simplify mac address regex
+- validate_integer, validate_numeric: explicitely reject hashes in arrays
+- Readme edits
+- Remove all the pops stuff for rspec-puppet
+- Sync via modulesync
+- Add validate_slength optional 3rd arg
+- Move tests directory to examples directory
+
+## 2015-04-14 - Supported Release 4.6.0
+### Summary
 
 Adds functions and function argument abilities, and improves compatibility with the new puppet parser
 
-####Features
+#### Features
 - MODULES-444: `concat()` can now take more than two arrays
 - `basename()` added to have Ruby File.basename functionality
 - `delete()` can now take an array of items to remove
@@ -12,7 +331,7 @@ Adds functions and function argument abilities, and improves compatibility with
 - `validate_absolute_path()` can now take an array
 - `validate_cmd()` can now use % in the command to embed the validation file argument in the string
 - MODULES-1473: deprecate `type()` function in favor of `type3x()`
-- MODULES-1473: Add `type_of()` to give better time information on future parser
+- MODULES-1473: Add `type_of()` to give better type information on future parser
 - Deprecate `private()` for `assert_private()` due to future parser
 - Adds `ceiling()` to take the ceiling of a number
 - Adds `fqdn_rand_string()` to generate random string based on fqdn
@@ -20,7 +339,7 @@ Adds functions and function argument abilities, and improves compatibility with
 - Adds `validate_integer()`
 - Adds `validate_numeric()` (like `validate_integer()` but also accepts floats)
 
-####Bugfixes
+#### Bugfixes
 - Fix seeding of `fqdn_rotate()`
 - `ensure_resource()` is more verbose on debug mode
 - Stricter argument checking for `dirname()`
@@ -28,37 +347,37 @@ Adds functions and function argument abilities, and improves compatibility with
 - Fix `uriescape()` when called with array
 - Fix `file_line` resource when using the `after` attribute with `match`
 
-##2015-01-14 - Supported Release 4.5.1
-###Summary
+## 2015-01-14 - Supported Release 4.5.1
+### Summary
 
 This release changes the temporary facter_dot_d cache locations outside of the /tmp directory due to a possible security vunerability. CVE-2015-1029
 
-####Bugfixes
+#### Bugfixes
 - Facter_dot_d cache will now be stored in puppet libdir instead of tmp
 
-##2014-12-15 - Supported Release 4.5.0
-###Summary
+## 2014-12-15 - Supported Release 4.5.0
+### Summary
 
 This release improves functionality of the member function and adds improved future parser support.
 
-####Features
+#### Features
 - MODULES-1329: Update member() to allow the variable to be an array.
 - Sync .travis.yml, Gemfile, Rakefile, and CONTRIBUTING.md via modulesync
 
-####Bugfixes
+#### Bugfixes
 - Fix range() to work with numeric ranges with the future parser
 - Accurately express SLES support in metadata.json (was missing 10SP4 and 12)
 - Don't require `line` to match the `match` parameter
 
-##2014-11-10 - Supported Release 4.4.0
-###Summary
+## 2014-11-10 - Supported Release 4.4.0
+### Summary
 This release has an overhauled readme, new private manifest function, and fixes many future parser bugs.
 
-####Features
+#### Features
 - All new shiny README
 - New `private()` function for making private manifests (yay!)
 
-####Bugfixes
+#### Bugfixes
 - Code reuse in `bool2num()` and `zip()`
 - Fix many functions to handle `generate()` no longer returning a string on new puppets
 - `concat()` no longer modifies the first argument (whoops)
@@ -70,32 +389,32 @@ This release has an overhauled readme, new private manifest function, and fixes
 - Fix `file_line` matching on older rubies
 
 
-##2014-07-15 - Supported Release 4.3.2
-###Summary
+## 2014-07-15 - Supported Release 4.3.2
+### Summary
 
 This release merely updates metadata.json so the module can be uninstalled and
 upgraded via the puppet module command.
 
-##2014-07-14 - Supported Release 4.3.1
+## 2014-07-14 - Supported Release 4.3.1
 ### Summary
 This supported release updates the metadata.json to work around upgrade behavior of the PMT.
 
 #### Bugfixes
 - Synchronize metadata.json with PMT-generated metadata to pass checksums
 
-##2014-06-27 - Supported Release 4.3.0
+## 2014-06-27 - Supported Release 4.3.0
 ### Summary
 This release is the first supported release of the stdlib 4 series. It remains
 backwards-compatible with the stdlib 3 series. It adds two new functions, one bugfix, and many testing updates.
 
 #### Features
 - New `bool2str()` function
-- New `camalcase()` function
+- New `camelcase()` function
 
 #### Bugfixes
 - Fix `has_interface_with()` when interfaces fact is nil
 
-##2014-06-04 - Release 4.2.2
+## 2014-06-04 - Release 4.2.2
 ### Summary
 
 This release adds PE3.3 support in the metadata and fixes a few tests.
@@ -139,14 +458,14 @@ This release adds many new functions and fixes, and continues to be backwards co
 - Add/update unit & acceptance tests.
 
 
-##2014-03-04 - Supported Release - 3.2.1
-###Summary
+## 2014-03-04 - Supported Release - 3.2.1
+### Summary
 This is a supported release
 
-####Bugfixes
+#### Bugfixes
 - Fixed `is_integer`/`is_float`/`is_numeric` for checking the value of arithmatic expressions.
 
-####Known bugs
+#### Known bugs
 * No known bugs
 
 ---
@@ -293,7 +612,7 @@ This is a supported release
 
  * Add an ensure\_packages function. (8a8c09e)
 
-##### 2012-11-23 - Erik DalÃ\83Æ\92Ã\82©n <dalen@spotify.com> - 3.2.0
+##### 2012-11-23 - Erik Dalén <dalen@spotify.com> - 3.2.0
 
  * (#17797) min() and max() functions (9954133)
 
@@ -390,7 +709,7 @@ This is a supported release
 
  * Add support for a 'match' parameter to file\_line (a06c0d8)
 
-##### 2012-08-07 - Erik DalÃ\83Æ\92Ã\82©n <dalen@spotify.com> - 2.4.0
+##### 2012-08-07 - Erik Dalén <dalen@spotify.com> - 2.4.0
 
  * (#15872) Add to\_bytes function (247b69c)
 
index f1cbde4..990edba 100644 (file)
@@ -43,7 +43,7 @@ Checklist (and a short version for the impatient)
 
       - Make sure you have a [GitHub account](https://github.com/join)
 
-      - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for.
+      - [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
 
     * Preferred method:
 
@@ -159,7 +159,7 @@ If you already have those gems installed, make sure they are up-to-date:
 With all dependencies in place and up-to-date we can now run the tests:
 
 ```shell
-% rake spec
+% bundle exec rake spec
 ```
 
 This will execute all the [rspec tests](http://rspec-puppet.com/) tests
@@ -178,8 +178,8 @@ installed on your system.
 You can run them by issuing the following command
 
 ```shell
-% rake spec_clean
-% rspec spec/acceptance
+% bundle exec rake spec_clean
+% bundle exec rspec spec/acceptance
 ```
 
 This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
@@ -208,13 +208,10 @@ review.
 Additional Resources
 ====================
 
-* [Getting additional help](http://puppetlabs.com/community/get-help)
+* [Getting additional help](http://puppet.com/community/get-help)
 
-* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests)
-
-* [Patchwork](https://patchwork.puppetlabs.com)
+* [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/)
-
index 2d19594..a9f0161 100644 (file)
@@ -1,51 +1,76 @@
-source ENV['GEM_SOURCE'] || 'https://rubygems.org'
+#This file is generated by ModuleSync, do not edit.
 
-def location_for(place, fake_version = nil)
-  if place =~ /^(git[:@][^#]*)#(.*)/
+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 =~ /^file:\/\/(.*)/
+  elsif place_or_version =~ /^file:\/\/(.*)/
     ['>= 0', { :path => File.expand_path($1), :require => false }]
   else
-    [place, { :require => false }]
+    [place_or_version, { :require => false }]
   end
 end
 
-group :development, :unit_tests do
-  gem 'rake', '~> 10.1.0',       :require => false
-  gem 'rspec', '~> 3.1.0',       :require => false
-  gem 'rspec-puppet',            :require => false
-  gem 'puppetlabs_spec_helper',  :require => false
-  gem 'puppet-lint',             :require => false
-  gem 'pry',                     :require => false
-  gem 'simplecov',               :require => false
+# 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]}"
+
+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')
 end
 
-beaker_version = ENV['BEAKER_VERSION']
-beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
 group :system_tests do
-  if beaker_version
-    gem 'beaker', *location_for(beaker_version)
-  end
-  if beaker_rspec_version
-    gem 'beaker-rspec', *location_for(beaker_rspec_version)
-  else
-    gem 'beaker-rspec',  :require => false
-  end
-  gem 'serverspec',    :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"]
+  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
 end
 
-facterversion = ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION']
-if facterversion
-  gem 'facter', *location_for(facterversion)
-else
-  gem 'facter', :require => false
+gem 'puppet', *location_for(ENV['PUPPET_GEM_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']
+
+
+# Evaluate Gemfile.local if it exists
+if File.exists? "#{__FILE__}.local"
+  eval(File.read("#{__FILE__}.local"), binding)
 end
 
-puppetversion = ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION']
-if puppetversion
-  gem 'puppet', *location_for(puppetversion)
-else
-  gem 'puppet', :require => false
+# Evaluate ~/.gemfile if it exists
+if File.exists?(File.join(Dir.home, '.gemfile'))
+  eval(File.read(File.join(Dir.home, '.gemfile')), binding)
 end
 
 # vim:ft=ruby
index ec0587c..d645695 100644 (file)
-Copyright (C) 2011 Puppet Labs Inc
 
-and some parts:
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
 
-Copyright (C) 2011 Krzysztof Wilczynski
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 
-Puppet Labs can be contacted at: info@puppetlabs.com
+   1. Definitions.
 
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
 
-    http://www.apache.org/licenses/LICENSE-2.0
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
 
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/3rdparty/modules/stdlib/MAINTAINERS.md b/3rdparty/modules/stdlib/MAINTAINERS.md
new file mode 100644 (file)
index 0000000..e8004a5
--- /dev/null
@@ -0,0 +1,6 @@
+## Maintenance
+
+Maintainers:
+  - Puppet Forge Modules Team `forge-modules |at| puppet |dot| com`
+
+Tickets: https://tickets.puppet.com/browse/MODULES. Make sure to set component to `stdlib`.
diff --git a/3rdparty/modules/stdlib/NOTICE b/3rdparty/modules/stdlib/NOTICE
new file mode 100644 (file)
index 0000000..3c8c03a
--- /dev/null
@@ -0,0 +1,23 @@
+stdlib puppet module
+
+Copyright (C) 2011-2016 Puppet Labs, Inc.
+
+and some parts:
+
+Copyright (C) 2011 Krzysztof Wilczynski
+
+
+Puppet Labs can be contacted at: info@puppetlabs.com
+
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/3rdparty/modules/stdlib/README.markdown b/3rdparty/modules/stdlib/README.markdown
deleted file mode 100644 (file)
index 3889088..0000000
+++ /dev/null
@@ -1,1042 +0,0 @@
-#stdlib
-
-####Table of Contents
-
-1. [Overview](#overview)
-2. [Module Description - What the module does and why it is useful](#module-description)
-3. [Setup - The basics of getting started with stdlib](#setup)
-4. [Usage - Configuration options and additional functionality](#usage)
-5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
-5. [Limitations - OS compatibility, etc.](#limitations)
-6. [Development - Guide for contributing to the module](#development)
-
-##Overview
-
-Adds a standard library of resources for Puppet modules.
-
-##Module Description
-
-This module provides a standard library of resources for the development of Puppet
-modules. Puppet modules make heavy use of this standard library. The stdlib module adds the following resources to Puppet:
-
- * Stages
- * Facts
- * Functions
- * Defined resource types
- * Types
- * Providers
-
-> *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.
-
-##Setup
-
-Installing the stdlib module adds the functions, facts, and resources of this standard library to Puppet.
-
-##Usage
-
-After you've installed stdlib, all of its functions, facts, and resources are available for module use or development.
-
-If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest.
-
-## Reference
-
-### Classes
-
-#### Public Classes
-
-* `stdlib`: 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`.
-
-  When declared, stdlib declares all other classes in the module. The only other class currently included in the module is `stdlib::stages`.
-
-  The stdlib class has no parameters.
-
-#### Private Classes
-
-* `stdlib::stages`: This class manages a standard set of run stages for Puppet. It is managed by the stdlib class and should not be declared independently.
-
-  The `stdlib::stages` class declares various run stages for deploying infrastructure, language runtimes, and application layers. The high level stages are (in order):
-
-  * setup
-  * main
-  * runtime
-  * setup_infra
-  * deploy_infra
-  * setup_app
-  * deploy_app
-  * deploy
-
-  Sample usage:
-
-  ```
-  node default {
-    include stdlib
-    class { java: stage => 'runtime' }
-  }
-  ```
-
-### Resources
-
-* `file_line`: This resource ensures that a given line, including whitespace at the beginning and end, is contained within a file. If the line is not contained in the given file, Puppet will add the line. Multiple resources can be declared to manage multiple lines in the same file. You can also use match to replace existing lines.
-
-  ```
-  file_line { 'sudo_rule':
-    path => '/etc/sudoers',
-    line => '%sudo ALL=(ALL) ALL',
-  }
-  file_line { 'sudo_rule_nopw':
-    path => '/etc/sudoers',
-    line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
-  }
-  ```
-
-  * `after`: Specify the line after which Puppet will add any new lines. (Existing lines are added in place.) Optional.
-  * `ensure`: Ensures whether the resource is present. Valid values are 'present', 'absent'.
- * `line`: The line to be added to the file located by the `path` parameter.
- * `match`: A 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. Optional.
- * `multiple`: Determine if match can change multiple lines. Valid values are 'true', 'false'. Optional.
- * `name`: An arbitrary name used as the identity of the resource.
- * `path`: The file in which Puppet will ensure the line specified by the line parameter.
-
-### Functions
-
-#### `abs`
-
-Returns the absolute value of a number; for example, '-34.56' becomes '34.56'. Takes a single integer and float value as an argument. *Type*: rvalue
-
-#### `any2array`
-
-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. *Type*: rvalue
-
-#### `base64`
-
-Converts a string to and from base64 encoding.
-Requires an action ('encode', 'decode') and either a plain or base64-encoded
-string. *Type*: rvalue
-
-#### `basename`
-
-Returns the `basename` of a path (optionally stripping an 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'
-
-  *Type*: rvalue
-
-#### `bool2num`
-
-Converts a boolean to a number. Converts 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. *Type*: rvalue
-
-#### `capitalize`
-
-Capitalizes the first letter of a string or array of strings.
-Requires either a single string or an array as an input. *Type*: rvalue
-
-#### `ceiling`
-
-Returns the smallest integer greater than or equal to the argument.
-Takes a single numeric value as an argument. *Type*: rvalue
-
-#### `chomp`
-
-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. *Type*: rvalue
-
-#### `chop`
-
-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 want to merely remove record separators, then you should use the `chomp` function. Requires a string or an array of strings as input. *Type*: rvalue
-
-#### `concat`
-
-Appends the contents of multiple arrays onto array 1. For example:
-  * `concat(['1','2','3'],'4')` results in: ['1','2','3','4'].
-  * `concat(['1','2','3'],'4',['5','6','7'])` results in: ['1','2','3','4','5','6','7'].
-
-#### `count`
-
-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. *Type*: rvalue
-
-#### `defined_with_params`
-
-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. Returns 'false' otherwise.
-
-  ```
-  user { 'dan':
-    ensure => present,
-  }
-
-  if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
-    user { 'dan': ensure => present, }
-  }
-  ```
-
-  *Type*: rvalue
-
-#### `delete`
-
-Deletes all instances of a given element from an array, substring from a
-string, or key from a hash. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1} *Type*: rvalue
-
-#### `delete_at`
-
-Deletes a determined indexed value from an array. For example, `delete_at(['a','b','c'], 1)` returns ['a','c']. *Type*: rvalue
-
-#### `delete_values`
-
-Deletes all instances of a given value from a hash. For example, `delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')` returns {'a'=>'A','c'=>'C','B'=>'D'} *Type*: rvalue
-
-#### `delete_undef_values`
-
-Deletes all instances of the undef value from an array or hash. For example, `$hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})` returns {a => 'A', b => '', d => false}. *Type*: rvalue
-
-#### `difference`
-
-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. For example, `difference(["a","b","c"],["b","c","d"])` returns ["a"].
-
-#### `dirname`
-
-Returns the `dirname` of a path. For example, `dirname('/path/to/a/file.ext')` returns '/path/to/a'.
-
-#### `downcase`
-
-Converts the case of a string or of all strings in an array to lowercase. *Type*: rvalue
-
-#### `empty`
-
-Returns 'true' if the variable is empty. *Type*: rvalue
-
-#### `ensure_packages`
-
-Takes a list of packages and only installs them if they don't already exist. It optionally takes a hash as a second parameter to be passed as the third argument to the `ensure_resource()` function. *Type*: statement
-
-#### `ensure_resource`
-
-Takes a resource type, title, and a list of attributes that describe a resource.
-
-  ```
-  user { 'dan':
-    ensure => present,
-  }
-  ```
-
-  This example only creates the resource if it does not already exist:
-
-    `ensure_resource('user', 'dan', {'ensure' => 'present' })`
-
-  If the resource already exists, but does not match the specified parameters, this function attempts 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.
-
-  `ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})`
-
-  *Type*: statement
-
-#### `flatten`
-
-This function flattens any deeply nested arrays and returns a single flat array as a result. For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c']. *Type*: rvalue
-
-#### `floor`
-
-Returns the largest integer less than or equal to the argument.
-Takes a single numeric value as an argument. *Type*: rvalue
-
-#### `fqdn_rand_string`
-
-Generates a random alphanumeric string using an optionally-specified character set (default is alphanumeric), combining the `$fqdn` fact and an optional seed for repeatable randomness.
-
-*Usage:*
-```
-fqdn_rand_string(LENGTH, [CHARSET], [SEED])
-```
-*Examples:*
-```
-fqdn_rand_string(10)
-fqdn_rand_string(10, 'ABCDEF!@#$%^')
-fqdn_rand_string(10, '', 'custom seed')
-```
-
-*Type*: rvalue
-
-#### `fqdn_rotate`
-
-Rotates an array a random number of times based on a node's fqdn. *Type*: rvalue
-
-#### `get_module_path`
-
-Returns the absolute path of the specified module for the current environment.
-
-  `$module_path = get_module_path('stdlib')`
-
-  *Type*: rvalue
-
-#### `getparam`
-
-Takes a resource reference and the name of the parameter and
-returns the value of the resource's parameter. For example, the following code returns 'param_value'.
-
-  *Example:*
-
-  ```
-  define example_resource($param) {
-  }
-
-  example_resource { "example_resource_instance":
-    param => "param_value"
-  }
-
-  getparam(Example_resource["example_resource_instance"], "param")
-  ```
-
-  *Type*: rvalue
-
-#### `getvar`
-
-Lookup a variable in a remote namespace.
-
-  For example:
-
-  ```
-  $foo = getvar('site::data::foo')
-  # Equivalent to $foo = $site::data::foo
-  ```
-
-  This is useful if the namespace itself is stored in a string:
-
-  ```
-  $datalocation = 'site::data'
-  $bar = getvar("${datalocation}::bar")
-  # Equivalent to $bar = $site::data::bar
-  ```
-
-  *Type*: rvalue
-
-#### `grep`
-
-This function searches through an array and returns any elements that match the provided regular expression. For example, `grep(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['aaa','aaaddd']. *Type*: rvalue
-
-#### `has_interface_with`
-
-Returns boolean based on kind and value:
-  * macaddress
-  * netmask
-  * ipaddress
-  * network
-
-  *Examples:*
-
-  ```
-  has_interface_with("macaddress", "x:x:x:x:x:x")
-  has_interface_with("ipaddress", "127.0.0.1")    => true
-  ```
-
-  If no kind is given, then the presence of the interface is checked:
-
-  ```
-  has_interface_with("lo")                        => true
-  ```
-
-  *Type*: rvalue
-
-#### `has_ip_address`
-
-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. *Type*: rvalue
-
-#### `has_ip_network`
-
-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. *Type*: rvalue
-
-#### `has_key`
-
-Determine if a hash has a certain key value.
-
-  *Example*:
-
-  ```
-  $my_hash = {'key_one' => 'value_one'}
-  if has_key($my_hash, 'key_two') {
-    notice('we will not reach here')
-  }
-  if has_key($my_hash, 'key_one') {
-    notice('this will be printed')
-  }
-  ```
-
-  *Type*: rvalue
-
-#### `hash`
-
-This function converts an array into a hash. For example, `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}. *Type*: rvalue
-
-#### `intersection`
-
-This function returns an array an intersection of two. For example, `intersection(["a","b","c"],["b","c","d"])` returns ["b","c"].
-
-#### `is_array`
-
-Returns 'true' if the variable passed to this function is an array. *Type*: rvalue
-
-#### `is_bool`
-
-Returns 'true' if the variable passed to this function is a boolean. *Type*: rvalue
-
-#### `is_domain_name`
-
-Returns 'true' if the string passed to this function is a syntactically correct domain name. *Type*: rvalue
-
-#### `is_float`
-
-Returns 'true' if the variable passed to this function is a float. *Type*: rvalue
-
-#### `is_function_available`
-
-This function 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. *Type*: rvalue
-
-#### `is_hash`
-
-Returns 'true' if the variable passed to this function is a hash. *Type*: rvalue
-
-#### `is_integer`
-
-Returns 'true' if the variable returned to this string is an integer. *Type*: rvalue
-
-#### `is_ip_address`
-
-Returns 'true' if the string passed to this function is a valid IP address. *Type*: rvalue
-
-#### `is_mac_address`
-
-Returns 'true' if the string passed to this function is a valid MAC address. *Type*: rvalue
-
-#### `is_numeric`
-
-Returns 'true' if the variable passed to this function is a number. *Type*: rvalue
-
-#### `is_string`
-
-Returns 'true' if the variable passed to this function is a string. *Type*: rvalue
-
-#### `join`
-
-This function joins an array into a string using a separator. For example, `join(['a','b','c'], ",")` results in: "a,b,c". *Type*: rvalue
-
-#### `join_keys_to_values`
-
-This function joins each key of a hash to that key's corresponding value with a separator. Keys and values are cast to strings. The return value is an array in which each element is one joined key/value pair. For example, `join_keys_to_values({'a'=>1,'b'=>2}, " is ")` results in ["a is 1","b is 2"]. *Type*: rvalue
-
-#### `keys`
-
-Returns the keys of a hash as an array. *Type*: rvalue
-
-#### `loadyaml`
-
-Load a YAML file containing an array, string, or hash, and return the data in the corresponding native data type. For example:
-
-  ```
-  $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
-  ```
-
-  *Type*: rvalue
-
-#### `lstrip`
-
-Strips leading spaces to the left of a string. *Type*: rvalue
-
-#### `max`
-
-Returns the highest value of all arguments. Requires at least one argument. *Type*: rvalue
-
-#### `member`
-
-This function determines if a variable is a member of an array. The variable can be either a string, array, or fixnum. For example, `member(['a','b'], 'b')` and `member(['a','b','c'], ['b','c'])` return 'true', while `member(['a','b'], 'c')`  and `member(['a','b','c'], ['c','d'])` return 'false'. *Type*: rvalue
-
-#### `merge`
-
-Merges two or more hashes together and returns the resulting hash.
-
-  *Example*:
-
-  ```
-  $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'}
-  ```
-
-  When there is a duplicate key, the key in the rightmost hash "wins." *Type*: rvalue
-
-#### `min`
-
-Returns the lowest value of all arguments. Requires at least one argument. *Type*: rvalue
-
-#### `num2bool`
-
-This function 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'. *Type*: rvalue
-
-#### `parsejson`
-
-This function accepts JSON as a string and converts into the correct Puppet structure. *Type*: rvalue
-
-#### `parseyaml`
-
-This function accepts YAML as a string and converts it into the correct Puppet structure. *Type*: rvalue
-
-#### `pick`
-
-From a list of values, returns the first value that is not undefined or an empty string. Takes any number of arguments, and raises an error if all values are undefined or empty.
-
-  ```
-  $real_jenkins_version = pick($::jenkins_version, '1.449')
-  ```
-
- *Type*: rvalue
-
-#### `prefix`
-
-This function applies a prefix to all elements in an array or to the keys in a hash. For example, `prefix(['a','b','c'], 'p')` returns ['pa','pb','pc'], and `prefix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')` returns {'pa'=>'b','pb'=>'c','pc'=>'d'}. *Type*: rvalue
-
-
-#### `assert_private`
-
-This function sets the current class or definition as private.
-Calling the class or definition from outside the current module will fail. For example, `assert_private()` called in class `foo::bar` outputs the following message if class is called from outside module `foo`:
-
-  ```
-  Class foo::bar is private
-  ```
-
-  You can specify the error message you want to use:
-
-  ```
-  assert_private("You're not supposed to do that!")
-  ```
-
-  *Type*: statement
-
-#### `pw_hash`
-
-Hashes a password using the crypt function. Provides a hash usable on most POSIX systems.
-
-The first argument to this function is the password to hash. If it is undef or an empty string, this function returns undef.
-
-The second argument to this function is which type of hash to use. It will be converted into the appropriate crypt(3) hash specifier. Valid hash types are:
-
-|Hash type            |Specifier|
-|---------------------|---------|
-|MD5                  |1        |
-|SHA-256              |5        |
-|SHA-512 (recommended)|6        |
-
-The third argument to this function is the salt to use.
-
-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.
-
-#### `range`
-
-When given range in the form of '(start, stop)', `range` extrapolates a range as an array. For example, `range("0", "9")` returns [0,1,2,3,4,5,6,7,8,9]. Zero-padded strings are converted to integers automatically, so `range("00", "09")` returns [0,1,2,3,4,5,6,7,8,9].
-
-  Non-integer strings are accepted; `range("a", "c")` returns ["a","b","c"], and `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"].
-
-  Passing a third argument will cause the generated range to step by that interval, e.g. `range("0", "9", "2")` returns ["0","2","4","6","8"]
-
-  *Type*: rvalue
-
-#### `reject`
-
-This function searches through an array and rejects all elements that match the provided regular expression. For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc']. *Type*: rvalue
-
-#### `reverse`
-
-Reverses the order of a string or array. *Type*: rvalue
-
-#### `rstrip`
-
-Strips leading spaces to the right of the string.*Type*: rvalue
-
-#### `shuffle`
-
-Randomizes the order of a string or array elements. *Type*: rvalue
-
-#### `size`
-
-Returns the number of elements in a string or array. *Type*: rvalue
-
-#### `sort`
-
-Sorts strings and arrays lexically. *Type*: rvalue
-
-#### `squeeze`
-
-Returns a new string where runs of the same character that occur in this set are replaced by a single character. *Type*: rvalue
-
-#### `str2bool`
-
-This converts a string to a boolean. This attempts to convert strings that contain values such as '1', 't', 'y', and 'yes' to 'true' and strings that contain values such as '0', 'f', 'n', and 'no' to 'false'. *Type*: rvalue
-
-#### `str2saltedsha512`
-
-This converts a string to a salted-SHA512 password hash, used for OS X versions >= 10.7. Given any string, this function returns a hex version of a salted-SHA512 password hash, which can be inserted into your Puppet
-manifests as a valid password attribute. *Type*: rvalue
-
-#### `strftime`
-
-This function returns formatted time. For example,  `strftime("%s")` returns the time since epoch, and `strftime("%Y=%m-%d")` returns the date. *Type*: rvalue
-
-  *Format:*
-
-    * `%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`: 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
-
-#### `strip`
-
-This function removes leading and trailing whitespace from a string or from every string inside an array. For example, `strip("    aaa   ")` results in "aaa". *Type*: rvalue
-
-#### `suffix`
-
-This function applies a suffix to all elements in an array. For example, `suffix(['a','b','c'], 'p')` returns ['ap','bp','cp']. *Type*: rvalue
-
-#### `swapcase`
-
-This function swaps the existing case of a string. For example, `swapcase("aBcD")` results in "AbCd". *Type*: rvalue
-
-#### `time`
-
-This function returns the current time since epoch as an integer. For example, `time()` returns something like '1311972653'. *Type*: rvalue
-
-#### `to_bytes`
-
-Converts the argument into bytes, for example 4 kB becomes 4096.
-Takes a single string value as an argument. *Type*: rvalue
-
-#### `type3x`
-
-Returns a string description of the type when passed a value. Type can be a string, array, hash, float, integer, or boolean. This function will be removed when puppet 3 support is dropped and the new type system may be used. *Type*: rvalue
-
-#### `type_of`
-
-Returns the literal type when passed a value. Requires the new
-  parser. 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] { ... }`) *Type*: rvalue
-
-#### `union`
-
-This function returns a union of two arrays. For example, `union(["a","b","c"],["b","c","d"])` returns ["a","b","c","d"].
-
-#### `unique`
-
-This function removes duplicates from strings and arrays. For example, `unique("aabbcc")` returns 'abc'.
-
-You can also use this with arrays. For example, `unique(["a","a","b","b","c","c"])` returns ["a","b","c"]. *Type*: rvalue
-
-#### `upcase`
-
-Converts an object, array or hash of objects that respond to upcase to uppercase. For example, `upcase("abcd")` returns 'ABCD'.  *Type*: rvalue
-
-#### `uriescape`
-
-Urlencodes a string or array of strings. Requires either a single string or an array as an input. *Type*: rvalue
-
-#### `validate_absolute_path`
-
-Validate the string represents an absolute path in the filesystem.  This function works for Windows and Unix style paths.
-
-    The following values will pass:
-
-    ```
-    $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
-    validate_absolute_path($my_path)
-    $my_path2 = '/var/lib/puppet'
-    validate_absolute_path($my_path2)
-    $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet']
-    validate_absolute_path($my_path3)
-    $my_path4 = ['/var/lib/puppet','/usr/share/puppet']
-    validate_absolute_path($my_path4)
-    ```
-
-    The following values will fail, causing compilation to abort:
-
-    ```
-    validate_absolute_path(true)
-    validate_absolute_path('../var/lib/puppet')
-    validate_absolute_path('var/lib/puppet')
-    validate_absolute_path([ 'var/lib/puppet', '/var/foo' ])
-    validate_absolute_path([ '/var/lib/puppet', 'var/foo' ])
-    $undefined = undef
-    validate_absolute_path($undefined)
-    ```
-
-    *Type*: statement
-
-#### `validate_array`
-
-Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check.
-
-  The following values will pass:
-
-  ```
-  $my_array = [ 'one', 'two' ]
-  validate_array($my_array)
-  ```
-
-  The following values will fail, causing compilation to abort:
-
-  ```
-  validate_array(true)
-  validate_array('some_string')
-  $undefined = undef
-  validate_array($undefined)
-  ```
-
-  *Type*: statement
-
-#### `validate_augeas`
-
-Performs validation of a string using an Augeas lens.
-The first argument of this function should be the string to test, and the second argument should be the name of the Augeas lens to use. If Augeas fails to parse the string with the lens, the compilation aborts with a parse error.
-
-  A third optional argument lists paths which should **not** be found in the file. The `$file` variable points to the location of the temporary file being tested in the Augeas tree.
-
-  For example, to make sure your passwd content never contains user `foo`:
-
-  ```
-  validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
-  ```
-
-  To ensure that no users use the '/bin/barsh' shell:
-
-  ```
-  validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
-  ```
-
-  You can pass a fourth argument as the error message raised and shown to the user:
-
-  ```
-  validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
-  ```
-
-  *Type*: statement
-
-#### `validate_bool`
-
-Validate that all passed values are either true or false. Abort catalog compilation if any value fails this check.
-
-  The following values will pass:
-
-  ```
-  $iamtrue = true
-  validate_bool(true)
-  validate_bool(true, true, false, $iamtrue)
-  ```
-
-  The following values will fail, causing compilation to abort:
-
-  ```
-  $some_array = [ true ]
-  validate_bool("false")
-  validate_bool("true")
-  validate_bool($some_array)
-  ```
-
-  *Type*: statement
-
-#### `validate_cmd`
-
-Performs 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 taking a % as a placeholder for the file path (will default to the end of the command if no % placeholder given). If the command, launched against a tempfile containing the passed string, returns a non-null value, compilation will abort with a parse error.
-
-If a third argument is specified, this will be the error message raised and seen by the user.
-
-  ```
-  # Defaults to end of path
-  validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
-  ```
-  ```
-  # % as file location
-  validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
-  ```
-
-  *Type*: statement
-
-#### `validate_hash`
-
-Validates that all passed values are hash data structures. Abort catalog compilation if any value fails this check.
-
-  The following values will pass:
-
-  ```
-  $my_hash = { 'one' => 'two' }
-  validate_hash($my_hash)
-  ```
-
-  The following values will fail, causing compilation to abort:
-
-  ```
-  validate_hash(true)
-  validate_hash('some_string')
-  $undefined = undef
-  validate_hash($undefined)
-  ```
-
-  *Type*: statement
-
-#### `validate_integer`
-
-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.
-
-  The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
-  If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check
-  if (all elements of) the first argument are greater or equal to the given minimum.
-
-  It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer.
-
-  The following values will pass:
-
-  ```
-  validate_integer(1)
-  validate_integer(1, 2)
-  validate_integer(1, 1)
-  validate_integer(1, 2, 0)
-  validate_integer(2, 2, 2)
-  validate_integer(2, '', 0)
-  validate_integer(2, undef, 0)
-  $foo = undef
-  validate_integer(2, $foo, 0)
-  validate_integer([1,2,3,4,5], 6)
-  validate_integer([1,2,3,4,5], 6, 0)
-  ```
-
-  * Plus all of the above, but any combination of values passed as strings ('1' or "1").
-  * Plus all of the above, but with (correct) combinations of negative integer values.
-
-  The following values will fail, causing compilation to abort:
-
-  ```
-  validate_integer(true)
-  validate_integer(false)
-  validate_integer(7.0)
-  validate_integer({ 1 => 2 })
-  $foo = undef
-  validate_integer($foo)
-  validate_integer($foobaridontexist)
-
-  validate_integer(1, 0)
-  validate_integer(1, true)
-  validate_integer(1, '')
-  validate_integer(1, undef)
-  validate_integer(1, , 0)
-  validate_integer(1, 2, 3)
-  validate_integer(1, 3, 2)
-  validate_integer(1, 3, true)
-  ```
-
-  * Plus all of the above, but any combination of values passed as strings ('false' or "false").
-  * Plus all of the above, but with incorrect combinations of negative integer values.
-  * Plus all of the above, but with non-integer crap in arrays or maximum / minimum argument.
-
-  *Type*: statement
-
-#### `validate_numeric`
-
-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.
-
-  The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
-  If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check
-  if (all elements of) the first argument are greater or equal to the given minimum.
-
-  It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric.
-
-  For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too.
-
-  *Type*: statement
-
-#### `validate_re`
-
-Performs simple validation of a string against one or more regular expressions. The first argument of this function should be the string to
-test, and the second argument should be a stringified regular expression
-(without the // delimiters) or an array of regular expressions. If none
-of the regular expressions match the string passed in, compilation aborts with a parse error.
-
-  You can pass a third argument as the error message raised and shown to the user.
-
-  The following strings validate against the regular expressions:
-
-  ```
-  validate_re('one', '^one$')
-  validate_re('one', [ '^one', '^two' ])
-  ```
-
-  The following string fails to validate, causing compilation to abort:
-
-  ```
-  validate_re('one', [ '^two', '^three' ])
-  ```
-
-  To set the error message:
-
-  ```
-  validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
-  ```
-
-  *Type*: statement
-
-#### `validate_slength`
-
-Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if arg 2 is not convertable to a number.
-
-  The following values pass:
-
-  ```
-  validate_slength("discombobulate",17)
-  validate_slength(["discombobulate","moo"],17)
-  ```
-
-  The following values fail:
-
-  ```
-  validate_slength("discombobulate",1)
-  validate_slength(["discombobulate","thermometer"],5)
-  ```
-
-  *Type*: statement
-
-#### `validate_string`
-
-Validates that all passed values are string data structures. Aborts catalog compilation if any value fails this check.
-
-  The following values pass:
-
-  ```
-  $my_string = "one two"
-  validate_string($my_string, 'three')
-  ```
-
-  The following values fail, causing compilation to abort:
-
-  ```
-  validate_string(true)
-  validate_string([ 'some', 'array' ])
-  $undefined = undef
-  validate_string($undefined)
-  ```
-
-  *Type*: statement
-
-#### `values`
-
-When given a hash, this function returns the values of that hash.
-
-  *Examples:*
-
-  ```
-  $hash = {
-    'a' => 1,
-    'b' => 2,
-    'c' => 3,
-  }
-  values($hash)
-  ```
-
-  The example above returns [1,2,3].
-
-  *Type*: rvalue
-
-#### `values_at`
-
-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
-
-  For example, `values_at(['a','b','c'], 2)` returns ['c']; `values_at(['a','b','c'], ["0-1"])` returns ['a','b']; and `values_at(['a','b','c','d','e'], [0, "2-3"])` returns ['a','c','d'].
-
-  *Type*: rvalue
-
-#### `zip`
-
-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. For example, `zip(['1','2','3'],['4','5','6'])` results in ["1", "4"], ["2", "5"], ["3", "6"]. *Type*: rvalue
-
-##Limitations
-
-As of Puppet Enterprise version 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 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).
-
-##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 of 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.
-
-You can read the complete module contribution guide on the [Puppet Labs wiki](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing).
-
-To report or research a bug with any part of this module, please go to
-[http://tickets.puppetlabs.com/browse/PUP](http://tickets.puppetlabs.com/browse/PUP).
-
-##Contributors
-
-The list of contributors can be found at: https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors
-
-
-
-
diff --git a/3rdparty/modules/stdlib/README.md b/3rdparty/modules/stdlib/README.md
new file mode 100644 (file)
index 0000000..7813f19
--- /dev/null
@@ -0,0 +1,2456 @@
+# stdlib
+
+#### Table of Contents
+
+1. [Module Description - What the module does and why it is useful](#module-description)
+1. [Setup - The basics of getting started with stdlib](#setup)
+1. [Usage - Configuration options and additional functionality](#usage)
+1. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
+    1. [Classes](#classes)
+    1. [Defined Types](#defined-types)
+    1. [Data Types](#data-types)
+    1. [Facts](#facts)
+    1. [Functions](#functions)
+1. [Limitations - OS compatibility, etc.](#limitations)
+1. [Development - Guide for contributing to the module](#development)
+1. [Contributors](#contributors)
+
+
+## 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:
+
+ * Stages
+ * Facts
+ * Functions
+ * Defined types
+ * Data types
+ * Providers
+
+> *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.
+
+## 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.
+
+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.
+
+## 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`.
+
+When declared, stdlib declares all other classes in the module. The only other class currently included in the module is `stdlib::stages`.
+
+The `stdlib::stages` class declares various run stages for deploying infrastructure, language runtimes, and application layers. The high level stages are (in order):
+
+  * setup
+  * main
+  * runtime
+  * setup_infra
+  * deploy_infra
+  * setup_app
+  * deploy_app
+  * deploy
+
+Sample usage:
+
+```puppet
+node default {
+  include stdlib
+  class { java: stage => 'runtime' }
+}
+```
+
+## Reference
+
+* [Public classes](#public-classes)
+* [Private classes](#private-classes)
+* [Defined types](#defined-types)
+* [Data types](#data-types)
+* [Facts](#facts)
+* [Functions](#functions)
+
+### Classes
+
+#### Public classes
+
+The `stdlib` class has no parameters.
+
+#### Private classes
+
+* `stdlib::stages`: Manages a standard set of run stages for Puppet.
+
+### Defined types
+
+#### `file_line`
+
+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 appends the line to the end of the file to ensure the desired state. Multiple resources can be declared to manage multiple lines in the same file.
+
+Example:
+
+```puppet
+file_line { 'sudo_rule':
+  path => '/etc/sudoers',
+  line => '%sudo ALL=(ALL) ALL',
+}
+
+file_line { 'sudo_rule_nopw':
+  path => '/etc/sudoers',
+  line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
+}
+```
+
+In the example above, Puppet ensures that both of the specified lines are contained in the file `/etc/sudoers`.
+
+Match Example:
+
+```puppet
+file_line { 'bashrc_proxy':
+  ensure => present,
+  path   => '/etc/bashrc',
+  line   => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+  match  => '^export\ HTTP_PROXY\=',
+}
+```
+
+In the example above, `match` looks for a line beginning with 'export' followed by 'HTTP_PROXY' and replaces it with the value in line.
+
+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,
+    }
+
+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`:
+
+```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.
+
+Encoding example:
+
+```puppet
+file_line { "XScreenSaver":
+  ensure   => present,
+  path     => '/root/XScreenSaver'
+  line     => "*lock: 10:00:00",
+  match    => '^*lock:',
+  encoding => "iso-8859-1",
+}
+```
+
+Files with special characters that are not valid UTF-8 give the error message "Invalid byte sequence in UTF-8". In this case, determine the correct file encoding and specify it with the `encoding` attribute.
+
+**Autorequires:** If Puppet is managing the file that contains the line being managed, the `file_line` resource autorequires that file.
+
+**Parameters**
+
+All parameters are optional, unless otherwise noted.
+
+##### `after`
+
+Specifies the line after which Puppet adds any new lines using a regular expression. (Existing lines are added in place.)
+
+Values: String containing a regex.
+
+Default value: `undef`.
+
+##### `encoding`
+
+Specifies the correct file encoding.
+
+Values: String specifying a valid Ruby character encoding.
+
+Default: 'UTF-8'.
+
+##### `ensure`: Specifies whether the resource is present.
+
+Values: 'present', 'absent'.
+
+Default value: 'present'.
+
+##### `line`
+
+**Required.**
+
+Sets the line to be added to the file located by the `path` parameter.
+
+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.
+
+Values: String containing a regex.
+
+Default value: `undef`.
+
+
+##### `match_for_absence`
+
+Specifies whether a match should be applied when `ensure => absent`. If set to `true` and match is set, the line that matches is deleted. If set to `false` (the default), match is ignored when `ensure => absent` and the value of `line` is used instead. Ignored when `ensure => present`.
+
+Boolean.
+
+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.
+
+Values: `true`, `false`.
+
+Default value: `false`.
+
+
+##### `name`
+
+Specifies the name to use as the identity of the resource. If you want the resource namevar to differ from the supplied `title` of the resource, specify it with `name`.
+
+Values: String.
+
+Default value: The value of the title.
+
+##### `path`
+
+**Required.**
+
+Specifies the file in which Puppet ensures the line specified by `line`.
+
+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.
+
+Boolean.
+
+Default value: `true`.
+
+### Data types
+
+#### `Stdlib::Absolutepath`
+
+A strict absolute path type. Uses a variant of Unixpath and Windowspath types.
+
+Acceptable input examples:
+
+```shell
+/var/log
+```
+
+```shell
+/usr2/username/bin:/usr/local/bin:/usr/bin:.
+```
+
+```shell
+C:\\WINDOWS\\System32
+```
+
+Unacceptable input example:
+
+```shell
+../relative_path
+```
+
+#### `Stdlib::Httpsurl`
+
+Matches HTTPS URLs.
+
+Acceptable input example:
+
+```shell
+https://hello.com
+```
+
+Unacceptable input example:
+
+```shell
+httds://notquiteright.org`
+```
+
+#### `Stdlib::Httpurl`
+
+Matches both HTTPS and HTTP URLs.
+
+Acceptable input example:
+
+```shell
+https://hello.com
+
+http://hello.com
+```
+
+Unacceptable input example:
+
+```shell
+httds://notquiteright.org
+```
+
+#### `Stdlib::MAC`
+
+Matches MAC addresses defined in [RFC5342](https://tools.ietf.org/html/rfc5342).
+
+#### `Stdlib::Unixpath`
+
+Matches paths on Unix operating systems.
+
+Acceptable input example:
+
+```shell
+/usr2/username/bin:/usr/local/bin:/usr/bin:
+
+/var/tmp
+```
+
+Unacceptable input example:
+
+```shell
+C:/whatever
+```
+
+#### `Stdlib::Windowspath`
+
+Matches paths on Windows operating systems.
+
+Acceptable input example:
+
+```shell
+C:\\WINDOWS\\System32
+
+C:\\
+
+\\\\host\\windows
+```
+
+Unacceptable input example:
+
+```shell
+/usr2/username/bin:/usr/local/bin:/usr/bin:.
+```
+
+### Facts
+
+#### `package_provider`
+
+Returns the default provider Puppet uses to manage packages on this system.
+
+#### `is_pe`
+
+Returns whether Puppet Enterprise is installed. Does not report anything on platforms newer than PE 3.x.
+
+#### `pe_version`
+
+Returns the version of Puppet Enterprise installed. Does not report anything on platforms newer than PE 3.x.
+
+#### `pe_major_version`
+
+Returns the major version Puppet Enterprise that is installed. Does not report anything on platforms newer than PE 3.x.
+
+#### `pe_minor_version`
+
+Returns the minor version of Puppet Enterprise that is installed. Does not report anything on platforms newer than PE 3.x.
+
+#### `pe_patch_version`
+
+Returns the patch version of Puppet Enterprise that is installed.
+
+#### `puppet_vardir`
+
+Returns the value of the Puppet vardir setting for the node running Puppet or Puppet agent.
+
+#### `puppet_environmentpath`
+
+Returns the value of the Puppet environment path settings for the node running Puppet or Puppet agent.
+
+#### `puppet_server`
+
+Returns the Puppet agent's `server` value, which is the hostname of the Puppet master with which the agent should communicate.
+
+#### `root_home`
+
+Determines the root home directory.
+
+Determines the root home directory, which depends on your operating system. Generally this is '/root'.
+
+#### `service_provider`
+
+Returns the default provider Puppet uses to manage services on this system
+
+### Functions
+
+#### `abs`
+
+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.
+
+*Type*: rvalue.
+
+#### `any2array`
+
+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.
+
+*Type*: rvalue.
+
+#### `any2bool`
+
+Converts any object to a Boolean:
+
+* Strings such as 'Y', 'y', '1', 'T', 't', 'TRUE', 'yes', 'true' return `true`.
+* Strings such as '0', 'F', 'f', 'N', 'n', 'FALSE', 'no', 'false' return `false`.
+* Booleans return their original value.
+* A number (or a string representation of a number) greater than 0 returns `true`, otherwise `false`.
+* An undef value returns `false`.
+* Anything else returns `true`.
+
+*Type*: rvalue.
+
+#### `assert_private`
+
+Sets the current class or definition as private. Calling the class or defined type from outside the current module fails.
+
+For example, `assert_private()` called in class `foo::bar` outputs the following message if class is called from outside module `foo`: `Class foo::bar is private.`
+
+To specify the error message you want to use:
+
+```puppet
+assert_private("You're not supposed to do that!")
+```
+
+*Type*: statement.
+
+#### `base64`
+
+Converts a string to and from base64 encoding. Requires an `action` ('encode', 'decode') and either a plain or base64-encoded `string`, and an optional `method` ('default', 'strict', 'urlsafe').
+
+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.
+
+**Examples:**
+
+```puppet
+base64('encode', 'hello')
+base64('encode', 'hello', 'default')
+# return: "aGVsbG8=\n"
+
+base64('encode', 'hello', 'strict')
+# return: "aGVsbG8="
+
+base64('decode', 'aGVsbG8=')
+base64('decode', 'aGVsbG8=\n')
+base64('decode', 'aGVsbG8=', 'default')
+base64('decode', 'aGVsbG8=\n', 'default')
+base64('decode', 'aGVsbG8=', 'strict')
+# return: "hello"
+
+base64('encode', 'https://puppetlabs.com', 'urlsafe')
+# return: "aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ=="
+
+base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe')
+# return: "https://puppetlabs.com"
+```
+
+*Type*: rvalue.
+
+#### `basename`
+
+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'
+
+*Type*: rvalue.
+
+#### `bool2num`
+
+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.
+
+  *Type*: rvalue.
+
+#### `bool2str`
+
+Converts a Boolean to a string using optionally supplied arguments. The optional second and third arguments represent what true and false are converted to respectively. If only one argument is given, it is converted from a Boolean to a string containing `true` or `false`.
+
+*Examples:*
+
+```puppet
+bool2str(true)                    => `true`
+bool2str(true, 'yes', 'no')       => 'yes'
+bool2str(false, 't', 'f')         => 'f'
+```
+
+Arguments: Boolean.
+
+*Type*: rvalue.
+
+#### `camelcase`
+
+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.
+
+*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.
+
+ *Type*: rvalue.
+
+#### `capitalize`
+
+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.
+
+*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.
+
+#### `ceiling`
+
+Returns the smallest integer greater than or equal to the argument.
+
+Arguments: A single numeric value.
+
+*Type*: rvalue.
+
+#### `chomp`
+
+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.
+
+*Type*: rvalue.
+
+#### `chop`
+
+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.
+
+*Type*: rvalue.
+
+#### `clamp`
+
+Keeps value within the range [Min, X, Max] by sort based on integer value (parameter order doesn't matter). Strings are converted and compared numerically. Arrays of values are flattened into a list for further handling. For example:
+
+  * `clamp('24', [575, 187])` returns 187.
+  * `clamp(16, 88, 661)` returns 88.
+  * `clamp([4, 3, '99'])` returns 4.
+
+Arguments: strings, arrays, or numerics.
+
+*Type*: rvalue.
+
+#### `concat`
+
+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'].
+
+*Type*: rvalue.
+
+#### `convert_base`
+
+Converts a given integer or base 10 string representing an integer to a specified base, as a string. For example:
+
+  * `convert_base(5, 2)` results in: '101'
+  * `convert_base('254', '16')` results in: 'fe'
+
+#### `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.
+
+*Type*: rvalue.
+
+#### `deep_merge`
+
+Recursively merges two or more hashes together and returns the resulting hash.
+
+```puppet
+$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
+$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
+$merged_hash = deep_merge($hash1, $hash2)
+```
+
+The resulting hash is equivalent to:
+
+```puppet
+$merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
+```
+
+If there is a duplicate key that is a hash, they are recursively merged. If there is a duplicate key that is not a hash, the key in the rightmost hash takes precedence.
+
+*Type*: rvalue.
+
+#### `defined_with_params`
+
+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. Returns `false` otherwise.
+
+```puppet
+user { 'dan':
+  ensure => present,
+}
+
+if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
+  user { 'dan': ensure => present, }
+}
+```
+
+*Type*: rvalue.
+
+#### `delete`
+
+Deletes all instances of a given element from an array, substring from a string, or key from a hash.
+
+For example:
+
+* `delete(['a','b','c','b'], 'b')` returns ['a','c'].
+* `delete('abracadabra', 'bra')` returns 'acada'.
+* `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}.
+* `delete(['ab', 'b'], 'b')` returns ['ab'].
+
+*Type*: rvalue.
+
+#### `delete_at`
+
+Deletes a determined indexed value from an array.
+
+For example: `delete_at(['a','b','c'], 1)` returns ['a','c'].
+
+*Type*: rvalue.
+
+#### `delete_regex`
+
+Deletes all instances of a given element from an array or hash that match a provided regular expression. A string is treated as a one-item array.
+
+*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
+
+* `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'].
+
+*Type*: rvalue.
+
+#### `delete_values`
+
+Deletes all instances of a given value from a hash.
+
+For example:
+
+* `delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')` returns {'a'=>'A','c'=>'C','B'=>'D'}
+
+*Type*: rvalue.
+
+#### `delete_undef_values`
+
+Deletes all instances of the `undef` value from an array or hash.
+
+For example:
+
+* `$hash = delete_undef_values({a=>'A', b=>'', c=>`undef`, d => false})` returns {a => 'A', b => '', d => false}.
+
+*Type*: rvalue.
+
+#### `deprecation`
+
+Prints deprecation warnings and logs a warning once for a given key:
+
+```puppet
+deprecation(key, message)
+```
+
+Arguments:
+
+* A string specifying the key: To keep the number of messages low during the lifetime of a Puppet process, only one message per key is logged.
+* A string specifying the message: the text to be logged.
+
+*Type*: Statement.
+
+**Settings that affect `deprecation`**
+
+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):
+
+    * `error`: Fails immediately with the deprecation message
+    * `off`: Output emits no messages.
+    * `warning`: Logs all warnings. This is the default setting.
+
+* The environment variable `STDLIB_LOG_DEPRECATIONS`
+
+  Specifies whether or not to log deprecation warnings. This is especially useful for automated tests to avoid flooding your logs before you are ready to migrate.
+
+  This variable is Boolean, with the following effects:
+
+  * `true`: Functions log a warning.
+  * `false`: No warnings are logged.
+  * No value set: Puppet 4 emits warnings, but Puppet 3 does not.
+
+#### `difference`
+
+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.
+
+For example:
+
+* `difference(["a","b","c"],["b","c","d"])` returns ["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.
+
+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.
+
+In addition to the required path argument, the function accepts the default argument. It is returned if the path is not correct, if no value was found, or if any other error has occurred.
+
+```ruby
+$data = {
+  'a' => {
+    'b' => [
+      'b1',
+      'b2',
+      'b3',
+    ]
+  }
+}
+
+$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'
+```
+
+1. **$data** The data structure we are working with.
+2. **['a', 'b', 2]** The path array.
+3. **'not_found'** The default value. It is returned if nothing is found.
+
+Default value: `undef`.
+
+*Type*: rvalue.
+
+#### `dig44`
+
+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.
+
+In addition to the required path argument, the function accepts the default argument. It is returned if the path is incorrect, if no value was found, or if any other error has occurred.
+
+```ruby
+$data = {
+  'a' => {
+    'b' => [
+      'b1',
+      'b2',
+      'b3',
+    ]
+  }
+}
+
+$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'
+```
+
+*Type*: rvalue.
+
+1. **$data** The data structure we are working with.
+2. **['a', 'b', 2]** The path array.
+3. **'not_found'** The default value. It will be returned if nothing is found.
+   (optional, defaults to `undef`)
+
+#### `dirname`
+
+Returns the `dirname` of a path. For example, `dirname('/path/to/a/file.ext')` returns '/path/to/a'.
+
+*Type*: rvalue.
+
+#### `dos2unix`
+
+Returns the Unix version of the given string. Very useful when using a File resource with a cross-platform template.
+
+```puppet
+file { $config_file:
+  ensure  => file,
+  content => dos2unix(template('my_module/settings.conf.erb')),
+}
+```
+
+See also [unix2dos](#unix2dos).
+
+*Type*: rvalue.
+
+#### `downcase`
+
+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.
+
+*Type*: rvalue.
+
+#### `empty`
+
+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.
+
+#### `enclose_ipv6`
+
+Takes an array of IP addresses and encloses the ipv6 addresses with square brackets.
+
+*Type*: rvalue.
+
+#### `ensure_packages`
+
+Takes a list of packages in an array or hash and installs them only if they don't already exist. Optionally takes a hash as a second parameter to be passed as the third argument to the `ensure_resource()` or `ensure_resources()` function.
+
+*Type*: statement.
+
+For an array:
+
+```puppet
+ensure_packages(['ksh','openssl'], {'ensure' => 'present'})
+```
+
+For a hash:
+
+```puppet
+ensure_packages({'ksh' => { ensure => '20120801-1' } ,  'mypackage' => { source => '/tmp/myrpm-1.0.0.x86_64.rpm', provider => "rpm" }}, {'ensure' => 'present'})
+```
+
+#### `ensure_resource`
+
+Takes a resource type, title, and a hash of attributes that describe the resource(s).
+
+```
+user { 'dan':
+  ensure => present,
+}
+```
+
+This example only creates the resource if it does not already exist:
+
+  `ensure_resource('user', 'dan', {'ensure' => 'present' })`
+
+If the resource already exists, but does not match the specified parameters, this function attempts 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.
+
+`ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})`
+
+*Type*: statement.
+
+#### `ensure_resources`
+
+Creates resource declarations from a hash, but doesn't conflict with resources that are already declared.
+
+Specify a resource type and title and a hash of attributes that describe the resource(s).
+
+```puppet
+user { 'dan':
+  gid => 'mygroup',
+  ensure => present,
+}
+
+ensure_resources($user)
+```
+
+Pass in a hash of resources. Any listed resources that don't already exist will be created with the type and parameters specified:
+
+    ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } ,  'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
+
+From Hiera backend:
+
+```yaml
+userlist:
+  dan:
+    gid: 'mygroup'
+    uid: '600'
+  alex:
+    gid: 'mygroup'
+```
+
+```puppet
+ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
+```
+
+#### `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.
+
+Example usage:
+
+```puppet
+fact('kernel')
+fact('osfamily')
+fact('os.architecture')
+```
+
+Array indexing:
+
+```puppet
+$first_processor  = fact('processors.models.0')
+$second_processor = fact('processors.models.1')
+```
+
+Fact containing a "." in the fact name:
+
+```puppet
+fact('vmware."VRA.version"')
+```
+
+#### `flatten`
+
+Flattens deeply nested arrays and returns a single flat array as a result.
+
+For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c'].
+
+*Type*: rvalue.
+
+#### `floor`
+
+Returns the largest integer less than or equal to the argument.
+
+Arguments: A single numeric value.
+
+*Type*: rvalue.
+
+#### `fqdn_rand_string`
+
+Generates a random alphanumeric string, combining the `$fqdn` fact and an optional seed for repeatable randomness. Optionally, you can specify a character set for the function (defaults to alphanumeric).
+
+*Usage:*
+
+```puppet
+fqdn_rand_string(LENGTH, [CHARSET], [SEED])
+```
+
+*Examples:*
+
+```puppet
+fqdn_rand_string(10)
+fqdn_rand_string(10, 'ABCDEF!@#$%^')
+fqdn_rand_string(10, '', 'custom seed')
+```
+
+Arguments:
+
+* An integer, specifying the length of the resulting string.
+* Optionally, a string specifying the character set.
+* Optionally, a string specifying the seed for repeatable randomness.
+
+*Type*: rvalue.
+
+#### `fqdn_rotate`
+
+Rotates an array or string a random number of times, combining the `$fqdn` fact and an optional seed for repeatable randomness.
+
+*Usage:*
+
+```puppet
+fqdn_rotate(VALUE, [SEED])
+```
+
+*Examples:*
+
+```puppet
+fqdn_rotate(['a', 'b', 'c', 'd'])
+fqdn_rotate('abcd')
+fqdn_rotate([1, 2, 3], 'custom seed')
+```
+
+*Type*: rvalue.
+
+#### `fqdn_uuid`
+
+Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID based on an FQDN string under the DNS namespace:
+
+  * fqdn_uuid('puppetlabs.com') returns '9c70320f-6815-5fc5-ab0f-debe68bf764c'
+  * fqdn_uuid('google.com') returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09c8'
+
+*Type*: rvalue.
+
+#### `get_module_path`
+
+Returns the absolute path of the specified module for the current environment.
+
+```puppet
+$module_path = get_module_path('stdlib')
+```
+
+*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':
+
+```puppet
+define example_resource($param) {
+}
+
+example_resource { "example_resource_instance":
+  param => "param_value"
+}
+
+getparam(Example_resource["example_resource_instance"], "param")
+```
+
+*Type*: rvalue.
+
+#### `getvar`
+
+Looks up a variable in a remote namespace.
+
+For example:
+
+```puppet
+$foo = getvar('site::data::foo')
+# Equivalent to $foo = $site::data::foo
+```
+
+This is useful if the namespace itself is stored in a string:
+
+```puppet
+$datalocation = 'site::data'
+$bar = getvar("${datalocation}::bar")
+# Equivalent to $bar = $site::data::bar
+```
+
+*Type*: rvalue.
+
+#### `glob`
+
+Returns an array of strings of paths matching path patterns.
+
+Arguments: A string or an array of strings specifying path patterns.
+
+```puppet
+$confs = glob(['/etc/**/*.conf', '/opt/**/*.conf'])
+```
+
+*Type*: rvalue.
+
+#### `grep`
+
+Searches through an array and returns any elements that match the provided regular expression.
+
+For example, `grep(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['aaa','aaaddd'].
+
+*Type*: rvalue.
+
+#### `has_interface_with`
+
+Returns a Boolean based on kind and value:
+
+  * macaddress
+  * netmask
+  * ipaddress
+  * network
+
+*Examples:*
+
+```puppet
+has_interface_with("macaddress", "x:x:x:x:x:x")
+has_interface_with("ipaddress", "127.0.0.1")    => true
+```
+
+If no kind is given, then the presence of the interface is checked:
+
+```puppet
+has_interface_with("lo")                        => true
+```
+
+*Type*: rvalue.
+
+#### `has_ip_address`
+
+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.
+
+Arguments: A string specifying an IP address.
+
+*Type*: rvalue.
+
+#### `has_ip_network`
+
+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.
+
+Arguments: A string specifying an IP address.
+
+*Type*: rvalue.
+
+#### `has_key`
+
+Determines if a hash has a certain key value.
+
+*Example*:
+
+```
+$my_hash = {'key_one' => 'value_one'}
+if has_key($my_hash, 'key_two') {
+  notice('we will not reach here')
+}
+if has_key($my_hash, 'key_one') {
+  notice('this will be printed')
+}
+```
+
+*Type*: rvalue.
+
+#### `hash`
+
+Converts an array into a hash.
+
+For example, `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}.
+
+*Type*: rvalue.
+
+#### `intersection`
+
+Returns an array an intersection of two.
+
+For example, `intersection(["a","b","c"],["b","c","d"])` returns ["b","c"].
+
+*Type*: rvalue.
+
+#### `is_a`
+
+Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. This function is available only in Puppet 4, or in Puppet 3 with the "future" parser.
+
+```
+foo = 3
+$bar = [1,2,3]
+$baz = 'A string!'
+
+if $foo.is_a(Integer) {
+  notify  { 'foo!': }
+}
+if $bar.is_a(Array) {
+  notify { 'bar!': }
+}
+if $baz.is_a(String) {
+  notify { 'baz!': }
+}
+```
+
+* 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.
+
+#### `is_absolute_path`
+
+**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).**
+
+Returns `true` if the given path is absolute.
+
+*Type*: rvalue.
+
+#### `is_array`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_bool`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_domain_name`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_email_address`
+
+Returns true if the string passed to this function is a valid email address.
+
+*Type*: rvalue.
+
+
+#### `is_float`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_function_available`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_hash`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_integer`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_ip_address`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_ipv6_address`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_ipv4_address`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_mac_address`
+
+Returns `true` if the string passed to this function is a valid MAC address.
+
+*Type*: rvalue.
+
+#### `is_numeric`
+
+**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.
+
+*Type*: rvalue.
+
+#### `is_string`
+
+**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.
+
+*Type*: rvalue.
+
+#### `join`
+
+Joins an array into a string using a separator. For example, `join(['a','b','c'], ",")` results in: "a,b,c".
+
+*Type*: rvalue.
+
+#### `join_keys_to_values`
+
+Joins each key of a hash to that key's corresponding value with a separator, returning the result as strings.
+
+If a value is an array, the key is prefixed to each element. The return value is a flattened array.
+
+For example, `join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")` results in ["a is 1","b is 2","b is 3"].
+
+*Type*: rvalue.
+
+#### `keys`
+
+Returns the keys of a hash as an array.
+
+*Type*: rvalue.
+
+#### `length`
+
+Returns the length of a given string, array or hash. Replaces the deprecated `size()` function.
+
+*Type*: rvalue.
+
+#### `loadyaml`
+
+Loads a YAML file containing an array, string, or hash, and returns the data in the corresponding native data type.
+
+For example:
+
+```puppet
+$myhash = loadyaml('/etc/puppet/data/myhash.yaml')
+```
+
+The second parameter is returned if the file was not found or could not be parsed.
+
+For example:
+
+```puppet
+$myhash = loadyaml('no-file.yaml', {'default'=>'value'})
+```
+
+*Type*: rvalue.
+
+#### `loadjson`
+
+Loads a JSON file containing an array, string, or hash, and returns the data in the corresponding native data type.
+
+For example:
+
+```puppet
+$myhash = loadjson('/etc/puppet/data/myhash.json')
+```
+
+The second parameter is returned if the file was not found or could not be parsed.
+
+For example:
+
+```puppet
+  $myhash = loadjson('no-file.json', {'default'=>'value'})
+  ```
+
+*Type*: rvalue.
+
+#### `load_module_metadata`
+
+Loads the metadata.json of a target module. Can be used to determine module version and authorship for dynamic support of modules.
+
+```puppet
+$metadata = load_module_metadata('archive')
+notify { $metadata['author']: }
+```
+
+When a module's metadata file is absent, the catalog compilation fails. To avoid this failure:
+
+```
+$metadata = load_module_metadata('mysql', true)
+if empty($metadata) {
+  notify { "This module does not have a metadata.json file.": }
+}
+```
+
+*Type*: rvalue.
+
+#### `lstrip`
+
+Strips spaces to the left of a string.
+
+*Type*: rvalue.
+
+#### `max`
+
+Returns the highest value of all arguments. Requires at least one argument.
+
+Arguments: A numeric or a string representing a number.
+
+*Type*: rvalue.
+
+#### `member`
+
+This function determines if a variable is a member of an array. The variable can be a string, an array, or a fixnum.
+
+For example, `member(['a','b'], 'b')` and `member(['a','b','c'], ['b','c'])` return `true`, while `member(['a','b'], 'c')` and `member(['a','b','c'], ['c','d'])` return `false`.
+
+*Note*: This function does not support nested arrays. If the first argument contains nested arrays, it will not recurse through them.
+
+*Type*: rvalue.
+
+#### `merge`
+
+Merges two or more hashes together and returns the resulting hash.
+
+*Example*:
+
+```puppet
+$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'}
+```
+
+When there is a duplicate key, the key in the rightmost hash takes precedence.
+
+*Type*: rvalue.
+
+#### `min`
+
+Returns the lowest value of all arguments. Requires at least one argument.
+
+Arguments: A numeric or a string representing a number.
+
+*Type*: rvalue.
+
+#### `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`.
+
+*Type*: rvalue.
+
+#### `parsejson`
+
+Converts a string of JSON into the correct Puppet structure (as a hash, array, string, integer, or a combination of such).
+
+Arguments:
+* The JSON string to convert, as a first argument.
+* Optionally, the result to return if conversion fails, as a second error.
+
+*Type*: rvalue.
+
+#### `parseyaml`
+
+Converts a string of YAML into the correct Puppet structure.
+
+Arguments:
+* The YAML string to convert, as a first argument.
+* Optionally, the result to return if conversion fails, as a second error.
+
+*Type*: rvalue.
+
+#### `pick`
+
+From a list of values, returns the first value that is not undefined or an empty string. Takes any number of arguments, and raises an error if all values are undefined or empty.
+
+```puppet
+$real_jenkins_version = pick($::jenkins_version, '1.449')
+```
+
+*Type*: rvalue.
+
+#### `pick_default`
+
+Returns the first value in a list of values. Unlike the `pick()` function, `pick_default()` does not fail if all arguments are empty. This allows it to use an empty value as default.
+
+*Type*: rvalue.
+
+#### `prefix`
+
+Applies a prefix to all elements in an array, or to the keys in a hash.
+
+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'}.
+
+*Type*: rvalue.
+
+#### `pry`
+
+Invokes a pry debugging session in the current scope object. Useful for debugging manifest code at specific points during a compilation. Should be used only when running `puppet apply` or running a Puppet master in the foreground. Requires the `pry` gem to be installed in Puppet's rubygems.
+
+*Examples:*
+
+```puppet
+pry()
+```
+
+In a pry session, useful commands include:
+
+* Run `catalog` to see the contents currently compiling catalog.
+* Run `cd catalog` and `ls` to see catalog methods and instance variables.
+* Run `@resource_table` to see the current catalog resource table.
+
+#### `pw_hash`
+
+Hashes a password using the crypt function. Provides a hash usable on most POSIX systems.
+
+The first argument to this function is the password to hash. If it is `undef` or an empty string, this function returns `undef`.
+
+The second argument to this function is which type of hash to use. It will be converted into the appropriate crypt(3) hash specifier. Valid hash types are:
+
+|Hash type            |Specifier|
+|---------------------|---------|
+|MD5                  |1        |
+|SHA-256              |5        |
+|SHA-512 (recommended)|6        |
+
+The third argument to this function is the salt to use.
+
+This function 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.
+
+*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.
+
+#### `range`
+
+Extrapolates a range as an array when given in the form of '(start, stop)'. For example, `range("0", "9")` returns [0,1,2,3,4,5,6,7,8,9]. Zero-padded strings are converted to integers automatically, so `range("00", "09")` returns [0,1,2,3,4,5,6,7,8,9].
+
+Non-integer strings are accepted:
+
+* `range("a", "c")` returns ["a","b","c"].
+* `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"].
+
+You must explicitly include trailing zeros, or the underlying Ruby function fails.
+
+Passing a third argument causes the generated range to step by that interval. For example:
+
+* `range("0", "9", "2")` returns ["0","2","4","6","8"].
+
+*Type*: rvalue.
+
+#### `regexpescape`
+
+Regexp escape a string or array of strings. Requires either a single string or an array as an input.
+
+*Type*: rvalue.
+
+#### `reject`
+
+Searches through an array and rejects all elements that match the provided regular expression.
+
+For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc'].
+
+*Type*: rvalue.
+
+#### `reverse`
+
+Reverses the order of a string or array.
+
+#### `round`
+
+ Rounds a number to the nearest integer
+
+*Type*: rvalue.
+
+#### `rstrip`
+
+Strips spaces to the right of the string.
+
+*Type*: rvalue.
+
+#### `seeded_rand`
+
+Takes an integer max value and a string seed value and returns a repeatable random integer smaller than max. Similar to `fqdn_rand`, but does not add node specific data to the seed.
+
+*Type*: rvalue.
+
+#### `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).
+
+For example:
+
+```puppet
+shell_escape('foo b"ar') => 'foo\ b\"ar'
+```
+
+*Type*: rvalue.
+
+#### `shell_join`
+
+Builds a command line string from a 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; see the [Ruby documentation](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shelljoin).
+
+For example:
+
+```puppet
+shell_join(['foo bar', 'ba"z']) => 'foo\ bar ba\"z'
+```
+
+*Type*: rvalue.
+
+#### `shell_split`
+
+Splits a string into an array of tokens. This function behaves the same as Ruby's `Shellwords.shellsplit()` function; see the [ruby documentation](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellsplit).
+
+*Example:*
+
+```puppet
+shell_split('foo\ bar ba\"z') => ['foo bar', 'ba"z']
+```
+
+*Type*: rvalue.
+
+#### `shuffle`
+
+Randomizes the order of a string or array elements.
+
+*Type*: rvalue.
+
+#### `size`
+
+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.
+
+#### `sort`
+
+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.
+
+#### `squeeze`
+
+Replaces consecutive repeats (such as 'aaaa') in a string with a single character. Returns a new string.
+
+*Type*: rvalue.
+
+#### `str2bool`
+
+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.
+
+*Type*: rvalue.
+
+#### `str2saltedsha512`
+
+Converts a string to a salted-SHA512 password hash, used for OS X versions 10.7 or greater. Returns a hex version of a salted-SHA512 password hash, which can be inserted into Puppet manifests as a valid password attribute.
+
+*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.
+
+#### `strftime`
+
+Returns formatted time.
+
+For example, `strftime("%s")` returns the time since Unix epoch, and `strftime("%Y-%m-%d")` returns the date.
+
+Arguments: A string specifying the time in `strftime` format. See the Ruby [strftime](https://ruby-doc.org/core-2.1.9/Time.html#method-i-strftime) documentation for details.
+
+*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.
+
+*Format:*
+
+* `%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 the Unix epoch, 1970-01-01 00:00:00 UTC.
+* `%S`: Second of the minute (00..60)
+* `%t`: Tab character (        )
+* `%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
+
+#### `strip`
+
+Removes leading and trailing whitespace from a string or from every string inside an array. For example, `strip("    aaa   ")` results in "aaa".
+
+*Type*: rvalue.
+
+#### `suffix`
+
+Applies a suffix to all elements in an array or to all keys in a hash.
+
+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'}.
+
+*Type*: rvalue.
+
+#### `swapcase`
+
+Swaps the existing case of a string. For example, `swapcase("aBcD")` results in "AbCd".
+
+*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.
+
+#### `time`
+
+Returns the current Unix epoch time as an integer.
+
+For example, `time()` returns something like '1311972653'.
+
+*Type*: rvalue.
+
+#### `to_bytes`
+
+Converts the argument into bytes.
+
+For example, "4 kB" becomes "4096".
+
+Arguments: A single string.
+
+*Type*: rvalue.
+
+#### `try_get_value`
+
+**DEPRECATED:** replaced by `dig()`.
+
+Retrieves a value within multiple layers of hashes and arrays.
+
+Arguments:
+
+* A string containing a path, as the first argument. Provide this argument as a string of hash keys or array indexes starting with zero and separated by the path separator character (default "/"). This function goes through the structure by each path component and tries to return the value at the end of the path.
+
+* A default argument as a second argument. This argument is returned if the path is not correct, if no value was found, or if any other error has occurred.
+* The path separator character as a last argument.
+
+```ruby
+$data = {
+  'a' => {
+    'b' => [
+      'b1',
+      'b2',
+      'b3',
+    ]
+  }
+}
+
+$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']
+```
+
+1. **$data** The data structure we are working with.
+2. **'a/b/2'** The path string.
+3. **'not_found'** The default value. It will be returned if nothing is found.
+   (optional, defaults to *`undef`*)
+4. **'/'** The path separator character.
+   (optional, defaults to *'/'*)
+
+*Type*: rvalue.
+
+#### `type3x`
+
+**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.
+
+Arguments:
+
+* string
+* array
+* hash
+* float
+* integer
+* Boolean
+
+*Type*: rvalue.
+
+#### `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.
+
+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] { ... }`).
+
+*Type*: rvalue.
+
+#### `union`
+
+Returns a union of two or more arrays, without duplicates.
+
+For example, `union(["a","b","c"],["b","c","d"])` returns ["a","b","c","d"].
+
+*Type*: rvalue.
+
+#### `unique`
+
+Removes duplicates from strings and arrays.
+
+For example, `unique("aabbcc")` returns 'abc', and `unique(["a","a","b","b","c","c"])` returns ["a","b","c"].
+
+*Type*: rvalue.
+
+#### `unix2dos`
+
+Returns the DOS version of a given string. Useful when using a File resource with a cross-platform template.
+
+*Type*: rvalue.
+
+```puppet
+file { $config_file:
+  ensure  => file,
+  content => unix2dos(template('my_module/settings.conf.erb')),
+}
+```
+
+See also [dos2unix](#dos2unix).
+
+#### `upcase`
+
+Converts an object, array, or hash of objects to uppercase. Objects to be converted must respond to upcase.
+
+For example, `upcase('abcd')` returns 'ABCD'.
+
+*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.
+
+#### `uriescape`
+
+URLEncodes a string or array of strings.
+
+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.
+
+#### `validate_absolute_path`
+
+Validates that a given string represents an absolute path in the filesystem. Works for Windows and Unix style paths.
+
+The following values pass:
+
+```puppet
+$my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
+validate_absolute_path($my_path)
+$my_path2 = '/var/lib/puppet'
+validate_absolute_path($my_path2)
+$my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet']
+validate_absolute_path($my_path3)
+$my_path4 = ['/var/lib/puppet','/usr/share/puppet']
+validate_absolute_path($my_path4)
+```
+
+The following values fail, causing compilation to terminate:
+
+```puppet
+validate_absolute_path(true)
+validate_absolute_path('../var/lib/puppet')
+validate_absolute_path('var/lib/puppet')
+validate_absolute_path([ 'var/lib/puppet', '/var/foo' ])
+validate_absolute_path([ '/var/lib/puppet', 'var/foo' ])
+$undefined = `undef`
+validate_absolute_path($undefined)
+```
+
+*Type*: statement.
+
+#### `validate_array`
+
+**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.
+
+The following values pass:
+
+```puppet
+$my_array = [ 'one', 'two' ]
+validate_array($my_array)
+```
+
+The following values fail, causing compilation to terminate:
+
+```puppet
+validate_array(true)
+validate_array('some_string')
+$undefined = `undef`
+validate_array($undefined)
+```
+
+*Type*: statement.
+
+#### `validate_augeas`
+
+Validates a string using an Augeas lens.
+
+Arguments:
+
+* The string to test, as the first argument.
+* The name of the Augeas lens to use, as the second argument.
+* Optionally, a list of paths which should **not** be found in the file, as a third argument.
+* Optionally, an error message to raise and show to the user, as a fourth argument.
+
+If Augeas fails to parse the string with the lens, the compilation terminates with a parse error.
+
+The `$file` variable points to the location of the temporary file being tested in the Augeas tree.
+
+For example, to make sure your $passwdcontent never contains user `foo`, include the third argument:
+
+```puppet
+validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
+```
+
+To raise and display an error message, include the fourth argument:
+
+```puppet
+validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
+```
+
+*Type*: statement.
+
+#### `validate_bool`
+
+**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.
+
+The following values pass:
+
+```puppet
+$iamtrue = true
+validate_bool(true)
+validate_bool(true, true, false, $iamtrue)
+```
+
+The following values fail, causing compilation to terminate:
+
+```puppet
+$some_array = [ true ]
+validate_bool("false")
+validate_bool("true")
+validate_bool($some_array)
+```
+
+*Type*: statement.
+
+#### `validate_cmd`
+
+Validates a string with an external command.
+
+Arguments:
+* The string to test, as the first argument.
+* The path to a test command, as the second argument. This argument takes a % as a placeholder for the file path (if no % placeholder is given, defaults to the end of the command). If the command is launched against a tempfile containing the passed string, or returns a non-null value, compilation will terminate with a parse error.
+* Optionally, an error message to raise and show to the user, as a third argument.
+
+```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')
+```
+
+*Type*: statement.
+
+#### `validate_domain_name`
+
+**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.
+
+The following values pass:
+
+~~~
+$my_domain_name = 'server.domain.tld'
+validate_domain_name($my_domain_name)
+validate_domain_name('domain.tld', 'puppet.com', $my_domain_name)
+~~~
+
+The following values fail, causing compilation to abort:
+
+~~~
+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')
+~~~
+
+*Type*: statement.
+
+#### `validate_email_address`
+
+Validate that all values passed are valid email addresses. Fail compilation if any value fails this check.
+
+The following values will pass:
+
+~~~
+$my_email = "waldo@gmail.com"
+validate_email_address($my_email)
+validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email)
+~~~
+
+The following values will fail, causing compilation to abort:
+
+~~~
+$some_array = [ 'bad_email@/d/efdf.com' ]
+validate_email_address($some_array)
+~~~
+
+*Type*: statement.
+
+#### `validate_hash`
+
+**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.
+
+The following values will pass:
+
+```puppet
+$my_hash = { 'one' => 'two' }
+validate_hash($my_hash)
+```
+
+The following values will fail, causing compilation to terminate:
+
+```puppet
+validate_hash(true)
+validate_hash('some_string')
+$undefined = `undef`
+validate_hash($undefined)
+```
+
+*Type*: statement.
+
+#### `validate_integer`
+
+**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.
+
+Arguments:
+
+* An integer or an array of integers, as the first argument.
+* Optionally, a maximum, as the second argument. (All elements of) the first argument must be equal to or less than this maximum.
+* Optionally, a minimum, as the third argument. (All elements of) the first argument must be equal to or greater than than this maximum.
+
+This function fails if the first argument is not an integer or array of integers, or if the second or third arguments are not convertable to an integer. However, if (and only if) a minimum is given, the second argument may be an empty string or `undef`, which serves as a placeholder to ensure the minimum check.
+
+The following values pass:
+
+```puppet
+validate_integer(1)
+validate_integer(1, 2)
+validate_integer(1, 1)
+validate_integer(1, 2, 0)
+validate_integer(2, 2, 2)
+validate_integer(2, '', 0)
+validate_integer(2, `undef`, 0)
+$foo = `undef`
+validate_integer(2, $foo, 0)
+validate_integer([1,2,3,4,5], 6)
+validate_integer([1,2,3,4,5], 6, 0)
+```
+
+* Plus all of the above, but any combination of values passed as strings ('1' or "1").
+* Plus all of the above, but with (correct) combinations of negative integer values.
+
+The following values fail, causing compilation to terminate:
+
+```puppet
+validate_integer(true)
+validate_integer(false)
+validate_integer(7.0)
+validate_integer({ 1 => 2 })
+$foo = `undef`
+validate_integer($foo)
+validate_integer($foobaridontexist)
+
+validate_integer(1, 0)
+validate_integer(1, true)
+validate_integer(1, '')
+validate_integer(1, `undef`)
+validate_integer(1, , 0)
+validate_integer(1, 2, 3)
+validate_integer(1, 3, 2)
+validate_integer(1, 3, true)
+```
+
+* Plus all of the above, but any combination of values passed as strings (`false` or "false").
+* 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.
+
+*Type*: statement.
+
+#### `validate_ip_address`
+
+**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.
+
+Arguments: A string specifying an IP address.
+
+The following values will pass:
+
+```puppet
+validate_ip_address('0.0.0.0')
+validate_ip_address('8.8.8.8')
+validate_ip_address('127.0.0.1')
+validate_ip_address('194.232.104.150')
+validate_ip_address('3ffe:0505:0002::')
+validate_ip_address('::1/64')
+validate_ip_address('fe80::a00:27ff:fe94:44d6/64')
+validate_ip_address('8.8.8.8/32')
+```
+
+The following values will fail, causing compilation to terminate:
+
+```puppet
+validate_ip_address(1)
+validate_ip_address(true)
+validate_ip_address(0.0.0.256)
+validate_ip_address('::1', {})
+validate_ip_address('0.0.0.0.0')
+validate_ip_address('3.3.3')
+validate_ip_address('23.43.9.22/64')
+validate_ip_address('260.2.32.43')
+```
+
+
+#### `validate_legacy`
+
+Validates a value against both a specified type and a deprecated validation function. Silently passes if both pass, errors if only one validation passes, and fails if both validations return false.
+
+Arguments:
+
+* The type to check the value against,
+* The full name of the previous validation function,
+* The value to be checked,
+* An unspecified number of arguments needed for the previous validation function.
+
+Example:
+
+```puppet
+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.
+
+> Note: This function is compatible only with Puppet 4.4.0 (PE 2016.1) and later.
+
+##### For module users
+
+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.
+
+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.
+
+The deprecation messages you get can vary, depending on the modules and data that you use. These deprecation messages appear by default only in Puppet 4:
+
+* `Notice: Accepting previously invalid value for target type '<type>'`: This message is informational only. You're using values that are allowed by the new type, but would have been invalid by the old validation function.
+* `Warning: This method is deprecated, please use the stdlib validate_legacy function`: The module has not yet upgraded to `validate_legacy`. Use the [deprecation](#deprecation) options to silence warnings for now, or submit a fix with the module's developer. See the information [for module developers](#for-module-developers) below for how to fix the issue.
+* `Warning: validate_legacy(<function>) expected <type> value, got <actual type>_`: Your code passes a value that was accepted by the Puppet 3-style validation, but will not be accepted by the next version of the module. Most often, you can fix this by removing quotes from numbers or booleans.
+* `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>`: Your code passes a value that is not acceptable to either the new or the old style validation.
+
+##### For module developers
+
+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.
+
+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:
+
+|              | `validate_` pass | `validate_` fail |
+| ------------ | ---------------- | ---------------- |
+| matches type | pass             | pass, notice     |
+| fails type   | pass, deprecated | fail             |
+
+The code after the validation still has to handle all possible values for now, but users of your code can change their manifests to pass only values that match the new type.
+
+For each `validate_*` function in stdlib, there is a matching `Stdlib::Compat::*` type that allows the appropriate set of values. See the documentation in the `types/` directory in the stdlib source code for caveats.
+
+For example, given a class that should accept only numbers, like this:
+
+```puppet
+class example($value) {
+  validate_numeric($value)
+```
+
+the resulting validation code looks like this:
+
+```puppet
+class example(
+  Variant[Stdlib::Compat::Numeric, Numeric] $value
+) {
+  validate_legacy(Numeric, 'validate_numeric', $value)
+```
+
+Here, the type of `$value` is defined as `Variant[Stdlib::Compat::Numeric, Numeric]`, which allows any `Numeric` (the new type), as well as all values previously accepted by `validate_numeric` (through `Stdlib::Compat::Numeric`).
+
+The call to `validate_legacy` takes care of triggering the correct log or fail message for you. It requires the new type, the previous validation function name, and all arguments to that function.
+
+If your module still supported Puppet 3, this is a breaking change. Update your `metadata.json` requirements section to indicate that your module no longer supports Puppet 3, and bump the major version of your module. With this change, all existing tests for your module should still pass. Create additional tests for the new possible values.
+
+As a breaking change, this is also a good time to call [`deprecation`](#deprecation) for any parameters you want to get rid of, or to add additional constraints on your parameters.
+
+After releasing this version, you can release another breaking change release where you remove all compat types and all calls to `validate_legacy`. At that time, you can also go through your code and remove any leftovers dealing with the previously possible values.
+
+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).**
+
+Validates a numeric value, or an array or string of numeric values. Terminates catalog compilation if any of the checks fail.
+
+Arguments:
+
+* A numeric value, or an array or string of numeric values.
+* Optionally, a maximum value. (All elements of) the first argument has to be less or equal to this max.
+* Optionally, a minimum value. (All elements of) the first argument has to be greater or equal to this min.
+
+This function fails if the first argument is not a numeric (Integer or Float) or an array or string of numerics, or if the second and third arguments are not convertable to a numeric. If, and only if, a minimum is given, the second argument can be an empty string or `undef`, which serves as a placeholder to ensure the minimum check.
+
+For passing and failing usage, see [`validate_integer`](#validate-integer). The same values pass and fail, except that `validate_numeric` also allows floating point values.
+
+*Type*: statement.
+
+#### `validate_re`
+
+**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.
+
+Arguments:
+
+* The string to test, as the first argument. If this argument is not a string, compilation terminates. Use quotes to force stringification.
+* A stringified regular expression (without the // delimiters) or an array of regular expressions, as the second argument.
+* Optionally, the error message raised and shown to the user, as a third argument.
+
+If none of the regular expressions in the second argument match the string passed in the first argument, compilation terminates with a parse error.
+
+The following strings validate against the regular expressions:
+
+```puppet
+validate_re('one', '^one$')
+validate_re('one', [ '^one', '^two' ])
+```
+
+The following string fails to validate, causing compilation to terminate:
+
+```puppet
+validate_re('one', [ '^two', '^three' ])
+```
+
+To set the error message:
+
+```puppet
+validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
+```
+
+To force stringification, use quotes:
+
+  ```
+  validate_re("${::operatingsystemmajrelease}", '^[57]$')
+  ```
+
+*Type*: statement.
+
+#### `validate_slength`
+
+**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
+
+Arguments:
+
+* A string or an array of strings, as a first argument.
+* A numeric value for maximum length, as a second argument.
+* Optionally, a numeric value for minimum length, as a third argument.
+
+  The following values pass:
+
+```puppet
+validate_slength("discombobulate",17)
+validate_slength(["discombobulate","moo"],17)
+validate_slength(["discombobulate","moo"],17,3)
+```
+
+The following values fail:
+
+```puppet
+validate_slength("discombobulate",1)
+validate_slength(["discombobulate","thermometer"],5)
+validate_slength(["discombobulate","moo"],17,10)
+```
+
+*Type*: statement.
+
+#### `validate_string`
+
+**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.
+
+The following values pass:
+
+```puppet
+$my_string = "one two"
+validate_string($my_string, 'three')
+```
+
+The following values fail, causing compilation to terminate:
+
+```puppet
+validate_string(true)
+validate_string([ 'some', 'array' ])
+```
+
+*Note:* validate_string(`undef`) will not fail in this version of the functions API.
+
+Instead, use:
+
+  ```
+  if $var == `undef` {
+    fail('...')
+  }
+  ```
+
+*Type*: statement.
+
+#### `validate_x509_rsa_key_pair`
+
+Validates a PEM-formatted X.509 certificate and private key using OpenSSL.
+Verifies that the certificate's signature was created from the supplied key.
+
+Fails catalog compilation if any value fails this check.
+
+Arguments:
+
+* An X.509 certificate as the first argument.
+* An RSA private key, as the second argument.
+
+```puppet
+validate_x509_rsa_key_pair($cert, $key)
+```
+
+*Type*: statement.
+
+#### `values`
+
+Returns the values of a given hash.
+
+For example, given `$hash = {'a'=1, 'b'=2, 'c'=3} values($hash)` returns [1,2,3].
+
+*Type*: rvalue.
+
+#### `values_at`
+
+Finds values inside an array based on location.
+
+Arguments:
+
+* The array you want to analyze, as the first argument.
+* Any combination of the following values, as the second argument:
+  * A single numeric index
+  * A range in the form of 'start-stop' (eg. 4-9)
+  * An array combining the above
+
+For example:
+
+* `values_at(['a','b','c'], 2)` returns ['c'].
+* `values_at(['a','b','c'], ["0-1"])` returns ['a','b'].
+* `values_at(['a','b','c','d','e'], [0, "2-3"])` returns ['a','c','d'].
+
+*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.
+
+## 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).
+
+## 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).
+
+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).
+
+## 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 4ed1327..d12d854 100644 (file)
@@ -1,18 +1,37 @@
-require 'rubygems'
 require 'puppetlabs_spec_helper/rake_tasks'
 require 'puppet-lint/tasks/puppet-lint'
-PuppetLint.configuration.send('disable_80chars')
-PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
+require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
 
-desc "Validate manifests, templates, and ruby files in lib."
-task :validate do
-  Dir['manifests/**/*.pp'].each do |manifest|
-    sh "puppet parser validate --noop #{manifest}"
+PuppetLint.configuration.fail_on_warnings = true
+PuppetLint.configuration.send('relative')
+
+desc 'Generate pooler nodesets'
+task :gen_nodeset do
+  require 'beaker-hostgenerator'
+  require 'securerandom'
+  require 'fileutils'
+
+  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
-  Dir['lib/**/*.rb'].each do |lib_file|
-    sh "ruby -c #{lib_file}"
+
+  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
-  Dir['templates/**/*.erb'].each do |template|
-    sh "erb -P -x -T '-' #{template} | ruby -c"
+
+  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)
   end
+  puts nodeset
 end
diff --git a/3rdparty/modules/stdlib/appveyor.yml b/3rdparty/modules/stdlib/appveyor.yml
new file mode 100644 (file)
index 0000000..7e05880
--- /dev/null
@@ -0,0 +1,52 @@
+version: 1.1.x.{build}
+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'
+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
+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
+build: off
+test_script:
+- bundle exec puppet -V
+- ruby -v
+- bundle exec rake spec SPEC_OPTS='--format documentation'
+notifications:
+- provider: Email
+  to:
+  - nobody@nowhere.com
+  on_build_success: false
+  on_build_failure: false
+  on_build_status_changed: false
index 07ce765..6fd8771 100644 (file)
 {
-  "CHANGELOG.md": "0df10b918eaaa55394d222a36089aedc",
-  "CONTRIBUTING.md": "e2b8e8e433fc76b3798b7fe435f49375",
-  "Gemfile": "f5c444df2b7f648ce49b6a24bb1c338d",
-  "LICENSE": "38a048b9d82e713d4e1b2573e370a756",
-  "README.markdown": "e09856fda53506497ddde02ce6f1e2cb",
+  "CHANGELOG.md": "fac876d70b44f0d961af9d90a7a59216",
+  "CONTRIBUTING.md": "77d0440d7cd4206497f99065c60bed46",
+  "Gemfile": "99e30e5e231f5f2b460b812c37d084f7",
+  "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57",
+  "MAINTAINERS.md": "b40ec4f2c16145af6f723c2c34bb2ff9",
+  "NOTICE": "b2e552587e5969886fdd60481e8b0351",
+  "README.md": "cee15bd22180e5b74fac7864c45d6d1e",
   "README_DEVELOPER.markdown": "220a8b28521b5c5d2ea87c4ddb511165",
   "README_SPECS.markdown": "82bb4c6abbb711f40778b162ec0070c1",
   "RELEASE_PROCESS.markdown": "94b92bc99ac4106ba1a74d5c04e520f9",
-  "Rakefile": "dfa334598bfd087adf11533a72d71106",
-  "lib/facter/facter_dot_d.rb": "15c1ec06d198c8e7cf2339ca34211b7a",
-  "lib/facter/pe_version.rb": "4a9353952963b011759f3e6652a10da5",
-  "lib/facter/puppet_vardir.rb": "c7ddc97e8a84ded3dd93baa5b9b3283d",
-  "lib/facter/root_home.rb": "d9c8276acdceb7340d95f60c36dcdcc5",
+  "Rakefile": "3851f083966b9bbd6d46e50dba5aa52a",
+  "appveyor.yml": "5bad9cb8e861bca53eeea6247eec5c60",
+  "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/service_provider.rb": "66cc42526eae631e306b397391f1f01c",
   "lib/facter/util/puppet_settings.rb": "9f1d2593d0ae56bfca89d4b9266aeee1",
-  "lib/puppet/functions/type_of.rb": "71e19f89e167c45ec691ea6c7d319625",
-  "lib/puppet/parser/functions/abs.rb": "32161bd0435fdfc2aec2fc559d2b454b",
+  "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/assert_private.rb": "1365284f9e474ecec24cfe43ee8e7cf4",
-  "lib/puppet/parser/functions/base64.rb": "ae25adf92295df67ebd9edfabc9ecdd6",
+  "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": "f953f5fc094c2ae3908a72d8840ba291",
-  "lib/puppet/parser/functions/bool2str.rb": "34497af8db94754542b9d4cfacc8a27f",
-  "lib/puppet/parser/functions/camelcase.rb": "71c67b71eac4b7f46a0dd22cb915d2e6",
-  "lib/puppet/parser/functions/capitalize.rb": "da131748a9d32da9eb0b6438e39377eb",
-  "lib/puppet/parser/functions/ceiling.rb": "dfa9b1c75ce89344026b3b5aed2d190f",
-  "lib/puppet/parser/functions/chomp.rb": "2b7dc42f9967edd34cfa0ba9a97229ca",
-  "lib/puppet/parser/functions/chop.rb": "0ec76f54afd94201f35785dfeb2092b5",
-  "lib/puppet/parser/functions/concat.rb": "2a12f95e94669129827ee2f2a26349c3",
-  "lib/puppet/parser/functions/count.rb": "9eb74eccd93e2b3c87fd5ea14e329eba",
+  "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": "ffab4433d03f32b551f2ea024a2948fc",
-  "lib/puppet/parser/functions/delete.rb": "cec92c5de6d748c8dc93ca7d25ac1c68",
-  "lib/puppet/parser/functions/delete_at.rb": "6bc24b79390d463d8be95396c963381a",
-  "lib/puppet/parser/functions/delete_undef_values.rb": "b32d4a3925753b2eb2c318cbd7f14404",
-  "lib/puppet/parser/functions/delete_values.rb": "39b147f7d369bb5f809044b6341954a2",
-  "lib/puppet/parser/functions/difference.rb": "e31b95fbaf974cf853a510177368bfb9",
+  "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/downcase.rb": "73121616d73339cf8dd10e0de61a6c50",
-  "lib/puppet/parser/functions/empty.rb": "0b6ca9d0550a39c1ca50fc3d1ecbc98c",
-  "lib/puppet/parser/functions/ensure_packages.rb": "fbed5c0c9bf82b7746e01f15f89d184f",
+  "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/flatten.rb": "25777b76f9719162a8bab640e5595b7a",
-  "lib/puppet/parser/functions/floor.rb": "42cad4c689231a51526c55a6f0985d1f",
-  "lib/puppet/parser/functions/fqdn_rand_string.rb": "375a7436960805b13ae34e2f970da443",
-  "lib/puppet/parser/functions/fqdn_rotate.rb": "2485c2eab774a8b1f52de9c17d4b0833",
+  "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": "4dd7a0e35f4a3780dcfc9b19b4e0006e",
-  "lib/puppet/parser/functions/getvar.rb": "ab01ce68140bbdd84162a519a14ece3b",
-  "lib/puppet/parser/functions/grep.rb": "5682995af458b05f3b53dd794c4bf896",
-  "lib/puppet/parser/functions/has_interface_with.rb": "ee3a1d6193951939b492a69ef170faac",
-  "lib/puppet/parser/functions/has_ip_address.rb": "ee207f47906455a5aa49c4fb219dd325",
-  "lib/puppet/parser/functions/has_ip_network.rb": "b4d726c8b2a0afac81ced8a3a28aa731",
+  "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": "9d072527dfc7354b69292e9302906530",
-  "lib/puppet/parser/functions/intersection.rb": "924ac4aceec7b896952166a7ec08fdb1",
-  "lib/puppet/parser/functions/is_array.rb": "875ca4356cb0d7a10606fb146b4a3d11",
-  "lib/puppet/parser/functions/is_bool.rb": "e693b7c4b5366cff1380b6e0c7dd7b11",
-  "lib/puppet/parser/functions/is_domain_name.rb": "6ca1f2708add756a6803b29d593d5830",
-  "lib/puppet/parser/functions/is_float.rb": "10e0d3ecf75fac15e415aee79acf70dc",
-  "lib/puppet/parser/functions/is_function_available.rb": "628428bbcd9313ce09783d9484330e09",
-  "lib/puppet/parser/functions/is_hash.rb": "8c7d9a05084dab0389d1b779c8a05b1a",
-  "lib/puppet/parser/functions/is_integer.rb": "c665be82686aa4729959bb42c66a7510",
-  "lib/puppet/parser/functions/is_ip_address.rb": "a714a736c1560e8739aaacd9030cca00",
-  "lib/puppet/parser/functions/is_mac_address.rb": "288bd4b38d4df42a83681f13e7eaaee0",
-  "lib/puppet/parser/functions/is_numeric.rb": "93ddc9d4c0834a5e5e0562d7b3cdce91",
-  "lib/puppet/parser/functions/is_string.rb": "2bd9a652bbb2668323eee6c57729ff64",
-  "lib/puppet/parser/functions/join.rb": "a285a05c015ae278608f6454aef211ea",
-  "lib/puppet/parser/functions/join_keys_to_values.rb": "f29da49531228f6ca5b3aa0df00a14c2",
-  "lib/puppet/parser/functions/keys.rb": "eb6ac815ea14fbf423580ed903ef7bad",
-  "lib/puppet/parser/functions/loadyaml.rb": "2b912f257aa078e376d3b3f6a86c2a00",
-  "lib/puppet/parser/functions/lstrip.rb": "20a9b1fa077c16f34e0ef5448b895698",
-  "lib/puppet/parser/functions/max.rb": "f652fd0b46ef7d2fbdb42b141f8fdd1d",
-  "lib/puppet/parser/functions/member.rb": "3c5375ebf3e2dafa84903009f0f1f47c",
+  "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": "0d2a1b7e735ab251c5469e735fa3f4c6",
-  "lib/puppet/parser/functions/num2bool.rb": "605c12fa518c87ed2c66ae153e0686ce",
-  "lib/puppet/parser/functions/parsejson.rb": "e7f968c34928107b84cd0860daf50ab1",
-  "lib/puppet/parser/functions/parseyaml.rb": "00f10ec1e2b050e23d80c256061ebdd7",
+  "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": "e377fd64bd63dde6c9660aa75aca4942",
+  "lib/puppet/parser/functions/prefix.rb": "ece9341c5b232a25c58545718a54e92f",
   "lib/puppet/parser/functions/private.rb": "1500a21d5cf19961c5b1d476df892d92",
-  "lib/puppet/parser/functions/pw_hash.rb": "02ed57b9b2b1e6266aa52d9680eed412",
-  "lib/puppet/parser/functions/range.rb": "b8bbbc3179ea8e1c84952137cfc97cd0",
+  "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": "b234b54b8cd62b2d67ccd70489ffdccf",
-  "lib/puppet/parser/functions/rstrip.rb": "b4e4ada41f7c1d2fcad073ce6344980f",
-  "lib/puppet/parser/functions/shuffle.rb": "d50f72b0aeb921e64d2482f62488e2f3",
-  "lib/puppet/parser/functions/size.rb": "8972d48c0f9e487d659bd7326b40b642",
-  "lib/puppet/parser/functions/sort.rb": "504b033b438461ca4f9764feeb017833",
-  "lib/puppet/parser/functions/squeeze.rb": "541f85b4203b55c9931d3d6ecd5c75f8",
-  "lib/puppet/parser/functions/str2bool.rb": "6320f1a50fd28ec027981cd1fb8ffdd0",
-  "lib/puppet/parser/functions/str2saltedsha512.rb": "49afad7b386be38ce53deaefef326e85",
-  "lib/puppet/parser/functions/strftime.rb": "e02e01a598ca5d7d6eee0ba22440304a",
-  "lib/puppet/parser/functions/strip.rb": "85d70ab95492e3e4ca5f0b5ec3f284a9",
-  "lib/puppet/parser/functions/suffix.rb": "109279db4180441e75545dbd5f273298",
-  "lib/puppet/parser/functions/swapcase.rb": "b17a9f3cb0271451d309e4b4f52dd651",
-  "lib/puppet/parser/functions/time.rb": "08d88d52abd1e230e3a2f82107545d48",
-  "lib/puppet/parser/functions/to_bytes.rb": "65437027687b6172173b3a211a799e37",
+  "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": "f9bf4de8341afb0c677c26b40ec8a2b2",
-  "lib/puppet/parser/functions/union.rb": "137998fe47decf25aede20f0c0155a4c",
-  "lib/puppet/parser/functions/unique.rb": "c1bb4a8aeebd09ba3e4c8bc3702cfd60",
-  "lib/puppet/parser/functions/upcase.rb": "c475c4d9d0ed46bcf0adf5de63ba1e82",
-  "lib/puppet/parser/functions/uriescape.rb": "d912ba09ba3f58c70988e662e05ffbe8",
-  "lib/puppet/parser/functions/validate_absolute_path.rb": "d229bb0ff30405f9c6f505dadfebdc34",
-  "lib/puppet/parser/functions/validate_array.rb": "72b29289b8af1cfc3662ef9be78911b8",
-  "lib/puppet/parser/functions/validate_augeas.rb": "b57e68fca390759782885474dc3ab2d0",
-  "lib/puppet/parser/functions/validate_bool.rb": "a712634a000024398b3c6cd4ecc46463",
-  "lib/puppet/parser/functions/validate_cmd.rb": "57b3b128c035802fb67754eed3a88475",
-  "lib/puppet/parser/functions/validate_hash.rb": "e9cfaca68751524efe16ecf2f958a9a0",
-  "lib/puppet/parser/functions/validate_integer.rb": "53d5a7effe41cdebc5acde2ea718ad31",
-  "lib/puppet/parser/functions/validate_ipv4_address.rb": "a8fb6f0ca36aa460d462c07c2af5d5a2",
-  "lib/puppet/parser/functions/validate_ipv6_address.rb": "4699238e4cad60e7e1428905523eaeb7",
-  "lib/puppet/parser/functions/validate_numeric.rb": "bab908e866b78a51412f827ad9f5cf20",
-  "lib/puppet/parser/functions/validate_re.rb": "c6664b3943bc820415a43f16372dc2a9",
-  "lib/puppet/parser/functions/validate_slength.rb": "7e67c213509b9383707819cc612b2a29",
-  "lib/puppet/parser/functions/validate_string.rb": "cf6a20877a27b1073d63fdd522af50bb",
-  "lib/puppet/parser/functions/values.rb": "066a6e4170e5034edb9a80463dff2bb5",
-  "lib/puppet/parser/functions/values_at.rb": "325a899e0201e8df5bd483fec6f12d76",
-  "lib/puppet/parser/functions/zip.rb": "a89d5e802bc1e63e52020c2ddbaaca2c",
-  "lib/puppet/provider/file_line/ruby.rb": "21807f8ce44552e6ca69d322909189ab",
+  "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": "56734a41d7d7e3bcb90b78cdb1cfac22",
-  "manifests/init.pp": "f2ba5f36e7227ed87bbb69034fc0de8b",
-  "manifests/stages.pp": "cc6ed1751d334b0ea278c0335c7f0b5a",
-  "metadata.json": "751bc3ba13674db184b13aded4793357",
-  "spec/acceptance/abs_spec.rb": "538db8d037db814b455a6d741e91bb8d",
-  "spec/acceptance/any2array_spec.rb": "de86ead0205acbb3eca3a8a4792bdac8",
-  "spec/acceptance/base64_spec.rb": "1684d5dd176dd5bbd4c3c6b1e64fbcea",
-  "spec/acceptance/bool2num_spec.rb": "bf53ceac40d0a67551c618b11809f3f8",
+  "lib/puppet/type/file_line.rb": "7486754fca55fe98d40f268b032b7e6a",
+  "locales/config.yaml": "574ee65e2a2a9d2f67edbc58735f50d4",
+  "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": "e77ea2c37144a75a67969c0d0839adfd",
-  "spec/acceptance/ceiling_spec.rb": "b2718dc74a39399e342ef96fe0d00fdc",
-  "spec/acceptance/chomp_spec.rb": "fb0862a6b7eeb3c290e280788e705061",
-  "spec/acceptance/chop_spec.rb": "4e7ab2d3a441b88b667a0d8ea5b174c1",
-  "spec/acceptance/concat_spec.rb": "6d88764fde8859e2db6b604f69fe2e17",
-  "spec/acceptance/count_spec.rb": "d82cfcad2461b16872455d6347a8b114",
-  "spec/acceptance/deep_merge_spec.rb": "c335a947f1666e185e0210e661f1c78a",
-  "spec/acceptance/defined_with_params_spec.rb": "f27c54ade9872c63c69316f62b03c119",
-  "spec/acceptance/delete_at_spec.rb": "9c028b703ee0286565c9877757678f3f",
-  "spec/acceptance/delete_spec.rb": "31e6dfcb9cc7c16b20d47c00e6a85a1d",
-  "spec/acceptance/delete_undef_values_spec.rb": "6e6a66aee0c383c843b5f92ef8c8410c",
-  "spec/acceptance/delete_values_spec.rb": "22c9b4914d4cbc0153aa3862cb4fb50e",
-  "spec/acceptance/difference_spec.rb": "289f4f1788feaacb304ffd54971c7e7e",
-  "spec/acceptance/dirname_spec.rb": "84db53878c4400a6c684c924cff05cfc",
-  "spec/acceptance/downcase_spec.rb": "0f094849b94a94df491ee01186473104",
-  "spec/acceptance/empty_spec.rb": "35c1f43e8a3e1fe7dd4335ef86e7efcc",
-  "spec/acceptance/ensure_packages_spec.rb": "de93ff46bcdff523f5636d05b449f6be",
-  "spec/acceptance/ensure_resource_spec.rb": "3e3e9b26ec6cd770469998e3eff49e00",
-  "spec/acceptance/flatten_spec.rb": "83fb08cc168a105c1d5d0df66b1d9e84",
-  "spec/acceptance/floor_spec.rb": "d7267b2914b1da6406224abb7489ca86",
-  "spec/acceptance/fqdn_rand_string_spec.rb": "52fbcdc2b6db4ddf8a63ca759b1a604e",
-  "spec/acceptance/fqdn_rotate_spec.rb": "43ef31f9f2c2616572753cb2b872984e",
-  "spec/acceptance/get_module_path_spec.rb": "2658cdcd1abd4b7d20f53c4aced3c72a",
-  "spec/acceptance/getparam_spec.rb": "4d32dc5a0ee34d045242c36d77a3b482",
-  "spec/acceptance/getvar_spec.rb": "ba2f081a88be97c0e7004a6296294f23",
-  "spec/acceptance/grep_spec.rb": "98818b8b0557b80d6ff519f70ea7617c",
-  "spec/acceptance/has_interface_with_spec.rb": "30e27096050c43b7efdb5e6c0d54f53b",
-  "spec/acceptance/has_ip_address_spec.rb": "2812117ec4b88556039e8488d53c0cb0",
-  "spec/acceptance/has_ip_network_spec.rb": "ca75b43ff1256ead9052f2db7620db99",
-  "spec/acceptance/has_key_spec.rb": "6509a26a0886f7d591eaa926b2f92407",
-  "spec/acceptance/hash_spec.rb": "1c626457ba056bdd3936e28aa5bf503e",
-  "spec/acceptance/intersection_spec.rb": "40f586af7f95408a5d4a2882a4aa98f1",
-  "spec/acceptance/is_array_spec.rb": "c2ff70ce59b90b50a5aed67abaa5399d",
-  "spec/acceptance/is_bool_spec.rb": "c001fdecff6b0a3c9dc78774987a0b15",
-  "spec/acceptance/is_domain_name_spec.rb": "63e84285c26d8717fd5d4dda01e3f432",
-  "spec/acceptance/is_float_spec.rb": "2f0164b4d732166aa46055a2cf7b4ea9",
-  "spec/acceptance/is_function_available_spec.rb": "7745eba89f8719c9ca7ebf04d5b005f7",
-  "spec/acceptance/is_hash_spec.rb": "cff723cd8fddac45033af5dc8406d4e4",
-  "spec/acceptance/is_integer_spec.rb": "c09201d17d3914bba197872897fa3413",
-  "spec/acceptance/is_ip_address_spec.rb": "aa14cf9abf404c3fe1e761ea957871fe",
-  "spec/acceptance/is_mac_address_spec.rb": "30ff4c6a63be58daa3568305617ca2a7",
-  "spec/acceptance/is_numeric_spec.rb": "fb9829c7a1a8d4a58836df6ff4c3386d",
-  "spec/acceptance/is_string_spec.rb": "df3022de123b72f0022728eb2d8ce857",
-  "spec/acceptance/join_keys_to_values_spec.rb": "8aa128bbaeea65aab8d92badee3ca2b5",
-  "spec/acceptance/join_spec.rb": "c6378ed481265152bba9871fc5501ee6",
-  "spec/acceptance/keys_spec.rb": "20486e3ebee53e50dc9de3b78b9d6ae6",
-  "spec/acceptance/loadyaml_spec.rb": "bd440cb6779026bd07d83f1aceb2781b",
-  "spec/acceptance/lstrip_spec.rb": "e29ab4039b65660ec2bd76a298adcae0",
-  "spec/acceptance/max_spec.rb": "209cda4b83d677743afb1a8870330618",
-  "spec/acceptance/member_spec.rb": "d6088a4fa6321791a3067d9b9cf8914a",
-  "spec/acceptance/merge_spec.rb": "5f168188fa0d6b31ba5b3dac49fb609c",
-  "spec/acceptance/min_spec.rb": "152a7db28434a0d0378561d4f64cddcc",
-  "spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151",
-  "spec/acceptance/nodesets/centos-6-vcloud.yml": "bdf9ce9d3b0f0b4995666ae9d64d878d",
-  "spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b",
-  "spec/acceptance/nodesets/centos-64-x64.yml": "092dd2c588a9f87fa1fb12997c0723ef",
-  "spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af",
-  "spec/acceptance/nodesets/default.yml": "3e5c36e6aa5a690229e720f4048bb8af",
-  "spec/acceptance/nodesets/fedora-18-x64.yml": "80e41b1ee16ea489f53164bfdae58855",
-  "spec/acceptance/nodesets/sles-11-x64.yml": "44e4c6c15c018333bfa9840a5e702f66",
-  "spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297",
-  "spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269",
-  "spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "5f0aed10098ac5b78e4217bb27c7aaf0",
-  "spec/acceptance/nodesets/windows-2003-i386.yml": "b518fc01fab99ee6a9afccec5bc0c1c4",
-  "spec/acceptance/nodesets/windows-2003-x86_64.yml": "5c783eaa8ea4734edc836e89e923dfa1",
-  "spec/acceptance/nodesets/windows-2008-x86_64.yml": "3082234eafcfaf7a9579d9ebdb8bc409",
-  "spec/acceptance/nodesets/windows-2008r2-x86_64.yml": "dfeff32a4cc3fffa872c8281d990a840",
-  "spec/acceptance/nodesets/windows-2012-x86_64.yml": "8bed73362ee1f43d21ea1903a729f955",
-  "spec/acceptance/nodesets/windows-2012r2-x86_64.yml": "3f4f6112d24db02989b8ab79d3a1256f",
-  "spec/acceptance/num2bool_spec.rb": "e4a00b913b08c68a689837e9f9336cb2",
-  "spec/acceptance/parsejson_spec.rb": "ea3973d412ad6f72425fdfac6fbb2bb4",
-  "spec/acceptance/parseyaml_spec.rb": "7bbfeed73d0626f69daedfc151957967",
-  "spec/acceptance/pick_default_spec.rb": "1bc2562380ef6f6cded5ec90a03922be",
-  "spec/acceptance/pick_spec.rb": "272c54c8f9398f499768331bdb4276ee",
-  "spec/acceptance/prefix_spec.rb": "da620568c6771e7d492ec1ff697c531c",
-  "spec/acceptance/pw_hash_spec.rb": "50d2f3a3ba9a4a7d2fe42f941f9ecd54",
-  "spec/acceptance/range_spec.rb": "65e5b98ceca257658604d988fbec7d03",
-  "spec/acceptance/reject_spec.rb": "b5185f1a6071c9bdc7aca92e6f899c3e",
-  "spec/acceptance/reverse_spec.rb": "7bdee543e82532e97bbf7a067140031c",
-  "spec/acceptance/rstrip_spec.rb": "28a64ceb7cb5ae8a93d31f49816190ab",
-  "spec/acceptance/shuffle_spec.rb": "8a8652e57d56f2b4946cdf4d20052b7a",
-  "spec/acceptance/size_spec.rb": "ae17d8a55921a0570972200c7c9327e1",
-  "spec/acceptance/sort_spec.rb": "d44b1b8c090f0f00a2f38515fda431ea",
-  "spec/acceptance/squeeze_spec.rb": "adcd65fa4e72203b97f1f14c8835c2cd",
-  "spec/acceptance/str2bool_spec.rb": "55ad165ceef6b9ba32bf20ca3b53b44c",
-  "spec/acceptance/str2saltedsha512_spec.rb": "b684c4214d06ae3d5bae055262a5ccaa",
-  "spec/acceptance/strftime_spec.rb": "0f4eadbd74445b35de4a42c9790fbcc1",
-  "spec/acceptance/strip_spec.rb": "6767da5bc735beb5362aeee6ff692c9e",
-  "spec/acceptance/suffix_spec.rb": "07dfc7eed48b75fcc1b93d0308243eda",
-  "spec/acceptance/swapcase_spec.rb": "5c3c1bc19a09fed6e01881f79b0b4ea5",
-  "spec/acceptance/time_spec.rb": "044b2f634a1fa6ecc735998d68a93b73",
-  "spec/acceptance/to_bytes_spec.rb": "f9df1f234b9409f5eaf56ef24e651c36",
-  "spec/acceptance/type_spec.rb": "4297e038a8ff7e6ecb859b8b68c7b3a6",
-  "spec/acceptance/union_spec.rb": "b6092941e0574f3c60910bebf84d2844",
-  "spec/acceptance/unique_spec.rb": "9b00b21cefde3b5391f50eeb9cd2493b",
-  "spec/acceptance/unsupported_spec.rb": "09b9265ecb05252cd5e5a18327c7ae97",
-  "spec/acceptance/upcase_spec.rb": "ffd1d6f9e6ec24131fb78983c53a75f9",
-  "spec/acceptance/uriescape_spec.rb": "13daa387714cbfc63b587aaa8dbf7fcd",
-  "spec/acceptance/validate_absolute_path_spec.rb": "8b9ebfae80329231d84fcab606a3eeaf",
-  "spec/acceptance/validate_array_spec.rb": "382641719e754622ffae562d10e38bf7",
-  "spec/acceptance/validate_augeas_spec.rb": "c26b8ca2184a9dd87033a0c6f0553093",
-  "spec/acceptance/validate_bool_spec.rb": "08bc139459204cf0a35098a5bc30ab95",
-  "spec/acceptance/validate_cmd_spec.rb": "e9260c49d880e4de54f77bf4fd70cff4",
-  "spec/acceptance/validate_hash_spec.rb": "70ceacc18a0dee97b26ab2e50f925706",
-  "spec/acceptance/validate_ipv4_address_spec.rb": "dc901bbd05c3764a93cb49154cea6e4b",
-  "spec/acceptance/validate_ipv6_address_spec.rb": "c0872c56230ac2800cd5723eaa5bc53a",
-  "spec/acceptance/validate_re_spec.rb": "b289909078d6ae0d015419f518566698",
-  "spec/acceptance/validate_slength_spec.rb": "f0a05c1c2b895b096cb7326df4821594",
-  "spec/acceptance/validate_string_spec.rb": "6c9ced99fb1e263e66e25427d24f8f7b",
-  "spec/acceptance/values_at_spec.rb": "669b26c4d47742051472003518c3aa61",
-  "spec/acceptance/values_spec.rb": "9681223bb1bd755c28946ef0bcd6ece9",
-  "spec/acceptance/zip_spec.rb": "86d1b555745ee873da68c71f1e46ed21",
-  "spec/classes/anchor_spec.rb": "40600ba2845f9bd360a9504a347f12ba",
-  "spec/functions/abs_spec.rb": "6c3a4f6072cf28132c29ff42791c0d11",
-  "spec/functions/any2array_spec.rb": "2feb23a3615dc55d5e99ae8617f4aca3",
-  "spec/functions/assert_private_spec.rb": "192cf2b9763ab7b741f19a146c069601",
-  "spec/functions/base64_spec.rb": "c93bdf30f5894728fe6558eb24955e26",
-  "spec/functions/bool2num_spec.rb": "12d7f3074beaf3a8b5c06da39b8f5a88",
-  "spec/functions/capitalize_spec.rb": "da52f8dd560b2a2ed57f13019b0b8302",
-  "spec/functions/ceiling_spec.rb": "aa2e9b34a10f7fbda4b33bfc8f5dadcd",
-  "spec/functions/chomp_spec.rb": "dea81927a4c134e2a47500969324c70e",
-  "spec/functions/chop_spec.rb": "3b0d0335f5e3347b7a9815e58b923657",
-  "spec/functions/concat_spec.rb": "e8377bd292819360ffc5359c86adbff2",
-  "spec/functions/count_spec.rb": "25e6e666561ced6d644d62bd71a648c6",
-  "spec/functions/deep_merge_spec.rb": "84f4f2cc194de907143ea17a3d40687e",
-  "spec/functions/defined_with_params_spec.rb": "498e064c37bb330dc80420e877e4e57d",
-  "spec/functions/delete_at_spec.rb": "012b3399d4a7101fc4cd4938e9bd2d50",
-  "spec/functions/delete_spec.rb": "889f0a0d5a8eb12ad6ee93e98601600d",
-  "spec/functions/delete_undef_values_spec.rb": "d61453c547c8816128e0a5e358821248",
-  "spec/functions/delete_values_spec.rb": "737cf476b579fb7b549280eb20d13ae7",
-  "spec/functions/difference_spec.rb": "2d7c07bc8bcb82831fcfe2f2a9958605",
-  "spec/functions/dirname_spec.rb": "b35d4806c8167478a6c45e0b63623513",
-  "spec/functions/downcase_spec.rb": "0864d43eb33e5d46a5943c2d117bfa40",
-  "spec/functions/empty_spec.rb": "046c8206121e364eb9b11bfb378e591b",
-  "spec/functions/ensure_packages_spec.rb": "f1b60599078cdcb3cff1368346108264",
-  "spec/functions/ensure_resource_spec.rb": "7765dde3b9fc54b7dddb6597e0f7b523",
-  "spec/functions/flatten_spec.rb": "a830987eb5b26a1b4325a7737fb9a7e2",
-  "spec/functions/floor_spec.rb": "d53e184f732c7b0fa49664645d6fb63d",
-  "spec/functions/fqdn_rand_string_spec.rb": "4d01df1bb76c413692ff5c035c4ac9df",
-  "spec/functions/fqdn_rotate_spec.rb": "0fecb71063ed7e8cf3b1e4b67699bb4a",
-  "spec/functions/get_module_path_spec.rb": "632de3cddb0980998b1f7f819feda3b4",
-  "spec/functions/getparam_spec.rb": "292346901bc0083a983fc166fee44675",
-  "spec/functions/getvar_spec.rb": "e0fa7cde8c415d099cd31888670ca2fc",
-  "spec/functions/grep_spec.rb": "aa5ab60a3899a4286152fbd5d3218bd3",
-  "spec/functions/has_interface_with_spec.rb": "2abef34f38bf2369434f27ab5ab02e0f",
-  "spec/functions/has_ip_address_spec.rb": "89d2a1e161ba9efdec36f90e1b7737bf",
-  "spec/functions/has_ip_network_spec.rb": "b0c080fa6fa27f03a0999a07b4cfbd08",
-  "spec/functions/has_key_spec.rb": "63f35c643a8a0ac1f3281b2981b4ab26",
-  "spec/functions/hash_spec.rb": "f85918bdeb33c2b0dc276fda46528d56",
-  "spec/functions/intersection_spec.rb": "fa5e91bec7bcf48c5d4b66e2824ba629",
-  "spec/functions/is_array_spec.rb": "82266ebdbc4002dc4471eb19095a617d",
-  "spec/functions/is_bool_spec.rb": "f8075f0d7b79b5568a646d97fb4e8115",
-  "spec/functions/is_domain_name_spec.rb": "35c18882c7a3bc361e72c3ca09e73c74",
-  "spec/functions/is_float_spec.rb": "adf03894b9e78f1e66831ba52ac20f49",
-  "spec/functions/is_function_available.rb": "193666f87f9a739a77335d9171411f5f",
-  "spec/functions/is_hash_spec.rb": "f1906d7cacf56f0ed26f703a3c4e19c4",
-  "spec/functions/is_integer_spec.rb": "5ed8c0620c64a4e8a6a07105816ae1f4",
-  "spec/functions/is_ip_address_spec.rb": "1c3ce0f2f9b6354d6ea7ffa36731d94c",
-  "spec/functions/is_mac_address_spec.rb": "60b1ea6464e10f3c8a095af0b69a1f4a",
-  "spec/functions/is_numeric_spec.rb": "6ceee608830d8d3c37a0d52d253e5ed1",
-  "spec/functions/is_string_spec.rb": "b67b213edc19f0bd97b2e4e561b4688b",
-  "spec/functions/join_keys_to_values_spec.rb": "444289422833c4d932432cba336d79ff",
-  "spec/functions/join_spec.rb": "35fe86a4a49befe39452eb861f3c66ff",
-  "spec/functions/keys_spec.rb": "6ada6f2263dda5a22b0505bab90c1543",
-  "spec/functions/loadyaml_spec.rb": "7d688e8382dd47db93dc4c710f8d6010",
-  "spec/functions/lstrip_spec.rb": "3161f3673f327aed9488958bbb91d720",
-  "spec/functions/max_spec.rb": "0ced8af1760cb387e7b8f4bc014fc94b",
-  "spec/functions/member_spec.rb": "8ac9f5d1aee5b3f503532fd54d9f609d",
-  "spec/functions/merge_spec.rb": "791ea69c46145b9c39f65f8d241a1205",
-  "spec/functions/min_spec.rb": "b13e21751bfacc850019fa4c7c177536",
-  "spec/functions/num2bool_spec.rb": "837bc45de67428a3c1faf8e22bb7dcf1",
-  "spec/functions/parsejson_spec.rb": "76e923a21cc6ddd38edf9a18e52991ae",
-  "spec/functions/parseyaml_spec.rb": "ebc620457c14d268a3f313277ab5ff46",
-  "spec/functions/pick_default_spec.rb": "dbfcee6a55488e8cb0af0866e1297f8c",
-  "spec/functions/pick_spec.rb": "c7ae8b1aa7eb615c9164d3cccfc891fb",
-  "spec/functions/prefix_spec.rb": "79de342f14f025114c0cd36ab23a7bf9",
-  "spec/functions/private_spec.rb": "367348d2d5a089fd5a77f1852fc56168",
-  "spec/functions/pw_hash_spec.rb": "f138aa3182e98b9eb06d5ed99579444c",
-  "spec/functions/range_spec.rb": "17ff3b8d7ead0939519c38d993fe2347",
-  "spec/functions/reject_spec.rb": "12cd8e9b98234dbfca06b33af4152bf3",
-  "spec/functions/reverse_spec.rb": "4dc357880ba5d3716c53d73e2045466a",
-  "spec/functions/rstrip_spec.rb": "af0d0c8b18c772f10e8227b3e9d8a54a",
-  "spec/functions/shuffle_spec.rb": "de716009e14609112b0209570dc69b06",
-  "spec/functions/size_spec.rb": "7551af6a9055650c863431ee6f9c82f5",
-  "spec/functions/sort_spec.rb": "c548fee79b5e86e5371371dbb36982db",
-  "spec/functions/squeeze_spec.rb": "aa7d260c8840e0eb4b72def5e0f63d96",
-  "spec/functions/str2bool_spec.rb": "1b854776e182f528d72f624a581e1a19",
-  "spec/functions/str2saltedsha512_spec.rb": "284430b18af76f42d60ad2db4c5e265a",
-  "spec/functions/strftime_spec.rb": "55b2abeecb65d147136d6af49ce61924",
-  "spec/functions/strip_spec.rb": "ac5316d9357fecba9ac55bdb0eb0ac29",
-  "spec/functions/suffix_spec.rb": "217ff8dc2f509b860af7c7c9ff73134b",
-  "spec/functions/swapcase_spec.rb": "686d6ff7c7a1fd473d2a74a1c3bbe8ca",
-  "spec/functions/time_spec.rb": "1a2db01a57ed1437b19cdeaaabc2c77e",
-  "spec/functions/to_bytes_spec.rb": "f0b0fbb9919bbe3882ca0d8f8db2c3b8",
-  "spec/functions/type3x_spec.rb": "dcbb17597f5040b4f02f7d035fa24eb7",
-  "spec/functions/type_spec.rb": "4a09d1fd50a3c787aba1bc82dbe9ae3b",
-  "spec/functions/union_spec.rb": "db5d5a0aa8c29725936e2488ccbcfd0a",
-  "spec/functions/unique_spec.rb": "42f9b82d1df269a1b34f4562369b8b84",
-  "spec/functions/upcase_spec.rb": "a4797eddc5cbddf006a1255d95f429ad",
-  "spec/functions/uriescape_spec.rb": "021fe7a48be167eab45318ca5890dcfd",
-  "spec/functions/validate_absolute_path_spec.rb": "6d8fa2007ba1490ef0a4082fad569d5b",
-  "spec/functions/validate_array_spec.rb": "bcd231229554785c4270ca92ef99cb60",
-  "spec/functions/validate_augeas_spec.rb": "57214b36976344d5fdec1171cb31485e",
-  "spec/functions/validate_bool_spec.rb": "7aeb6085fc9601c6bbe6c49e56d209a4",
-  "spec/functions/validate_cmd_spec.rb": "0fbecaf7616ba5a8ae6447082c9804bc",
-  "spec/functions/validate_hash_spec.rb": "8529c74051ceb71e6b1b97c9cecdf625",
-  "spec/functions/validate_integer_spec.rb": "860949498dfa7dc29cfc4d0cfb319619",
-  "spec/functions/validate_ipv4_address_spec.rb": "19f2f44fbbdf7a2e69aeaa2f0f402695",
-  "spec/functions/validate_ipv6_address_spec.rb": "2d8617be4405bdbd84d140ba8be6c184",
-  "spec/functions/validate_numeric_spec.rb": "c2ce1a20ec9d45f69852c8d973f52fd9",
-  "spec/functions/validate_re_spec.rb": "d8ab477f9afcb748f144588ebb3a28a3",
-  "spec/functions/validate_slength_spec.rb": "438738f1ac9363d5a7cd8c3ee09fe14c",
-  "spec/functions/validate_string_spec.rb": "64a4f681084cba55775a070f7fab5e0c",
-  "spec/functions/values_at_spec.rb": "cdfc313cc283400f1aed75f4cbd0ab4f",
-  "spec/functions/values_spec.rb": "2ea5dd37e6ac9c89f4b434c7ed7cc45e",
-  "spec/functions/zip_spec.rb": "d67e3424e60de00ff26e73516f4bf6da",
-  "spec/lib/puppet_spec/compiler.rb": "3c1f03dd8ac2f6f90d7e8f879a3ce4c0",
-  "spec/lib/puppet_spec/database.rb": "c74c0cf62980beea88c7749f876ccfa7",
-  "spec/lib/puppet_spec/files.rb": "906da85e399302cee403e10e357d3f4c",
-  "spec/lib/puppet_spec/fixtures.rb": "0722c5ccbfcba1fc27da1900e54b4463",
-  "spec/lib/puppet_spec/matchers.rb": "dd30ba6b936e8c267511d67acb087c35",
-  "spec/lib/puppet_spec/modules.rb": "445d2739aa8754568a14816280727d70",
-  "spec/lib/puppet_spec/pops.rb": "adf661defa460b7189e3750535533d34",
-  "spec/lib/puppet_spec/scope.rb": "01aeb89bdc2d29a2528ced26ec6402ec",
-  "spec/lib/puppet_spec/settings.rb": "5da4e0dad8bf6b21cc4437c73753a56d",
-  "spec/lib/puppet_spec/verbose.rb": "71dbccd9a45ed89d12fd1c44456a6820",
+  "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",
+  "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/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.opts": "a600ded995d948e393fbe2320ba8e51c",
-  "spec/spec_helper.rb": "b7a797512ad4ae4395fa5d1ff524e1f0",
-  "spec/spec_helper_acceptance.rb": "ffb989c77153f8206c9be08f32278147",
+  "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/pe_version_spec.rb": "af4d4428a7625a19de1751ce1bb09d5c",
-  "spec/unit/facter/root_home_spec.rb": "2dabfc67279e85714e0d4479bd149e78",
-  "spec/unit/facter/util/puppet_settings_spec.rb": "7b4afdfe4b80ee6463564bda2c4af344",
-  "spec/unit/puppet/functions/type_of_spec.rb": "3fe581c5de01b6f6338370e475b6b1b2",
-  "spec/unit/puppet/parser/functions/basename_spec.rb": "e7ac349b8336c6a2bb99f27443a9d077",
-  "spec/unit/puppet/parser/functions/bool2str_spec.rb": "c0a7f753889d0e65c25db5b0eebad7ac",
-  "spec/unit/puppet/parser/functions/camelcase_spec.rb": "332621f98485c651b281aa4b5ac82b5d",
-  "spec/unit/puppet/provider/file_line/ruby_spec.rb": "e8dcf08c5cd346a6408d8da4fa0bbf7e",
+  "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": "5800799a8d3aed42c6fb6cf3ea574e07",
-  "tests/file_line.pp": "67727539aa7b7dd76f06626fe734f7f7",
-  "tests/has_interface_with.pp": "59c98b4af0d39fc11d1ef4c7a6dc8f7a",
-  "tests/has_ip_address.pp": "93ce02915f67ddfb43a049b2b84ef391",
-  "tests/has_ip_network.pp": "abc05686797a776ea8c054657e6f7456",
-  "tests/init.pp": "1d98070412c76824e66db4b7eb74d433"
+  "spec/unit/puppet/type/file_line_spec.rb": "83e11166de4abe69cdf0dc7450e79778",
+  "types/absolutepath.pp": "3ae6f48dd95835df87c5dacea13c88d2",
+  "types/compat/absolute_path.pp": "6d0e102d1098d85d97c8f13051cb2c10",
+  "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/ip_address.pp": "d42c7435de30a469a71b69c45d642da7",
+  "types/compat/ipv4.pp": "c84eb3764f45b256a09be68afe61b749",
+  "types/compat/ipv6.pp": "d3c0fada5425d576aeca14ddbee78653",
+  "types/compat/numeric.pp": "f864539d78e95dabf0bab361b4ccc042",
+  "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/windowspath.pp": "4c1eda331ecb43de98c29ed22d0ad448"
 }
\ No newline at end of file
diff --git a/3rdparty/modules/stdlib/examples/file_line.pp b/3rdparty/modules/stdlib/examples/file_line.pp
new file mode 100644 (file)
index 0000000..e628bea
--- /dev/null
@@ -0,0 +1,9 @@
+# This is a simple smoke test
+# of the file_line resource type.
+file { '/tmp/dansfile':
+  ensure => file,
+}
+-> file_line { 'dans_line':
+  line => 'dan is awesome',
+  path => '/tmp/dansfile',
+}
diff --git a/3rdparty/modules/stdlib/examples/has_interface_with.pp b/3rdparty/modules/stdlib/examples/has_interface_with.pp
new file mode 100644 (file)
index 0000000..a578dd2
--- /dev/null
@@ -0,0 +1,9 @@
+include ::stdlib
+info('has_interface_with(\'lo\'):', has_interface_with('lo'))
+info('has_interface_with(\'loX\'):', has_interface_with('loX'))
+info('has_interface_with(\'ipaddress\', \'127.0.0.1\'):', has_interface_with('ipaddress', '127.0.0.1'))
+info('has_interface_with(\'ipaddress\', \'127.0.0.100\'):', has_interface_with('ipaddress', '127.0.0.100'))
+info('has_interface_with(\'network\', \'127.0.0.0\'):', has_interface_with('network', '127.0.0.0'))
+info('has_interface_with(\'network\', \'128.0.0.0\'):', has_interface_with('network', '128.0.0.0'))
+info('has_interface_with(\'netmask\', \'255.0.0.0\'):', has_interface_with('netmask', '255.0.0.0'))
+info('has_interface_with(\'netmask\', \'256.0.0.0\'):', has_interface_with('netmask', '256.0.0.0'))
diff --git a/3rdparty/modules/stdlib/examples/has_ip_address.pp b/3rdparty/modules/stdlib/examples/has_ip_address.pp
new file mode 100644 (file)
index 0000000..594143d
--- /dev/null
@@ -0,0 +1,3 @@
+include ::stdlib
+info('has_ip_address(\'192.168.1.256\'):', has_ip_address('192.168.1.256'))
+info('has_ip_address(\'127.0.0.1\'):', has_ip_address('127.0.0.1'))
diff --git a/3rdparty/modules/stdlib/examples/has_ip_network.pp b/3rdparty/modules/stdlib/examples/has_ip_network.pp
new file mode 100644 (file)
index 0000000..1f1130d
--- /dev/null
@@ -0,0 +1,3 @@
+include ::stdlib
+info('has_ip_network(\'127.0.0.0\'):', has_ip_network('127.0.0.0'))
+info('has_ip_network(\'128.0.0.0\'):', has_ip_network('128.0.0.0'))
diff --git a/3rdparty/modules/stdlib/examples/init.pp b/3rdparty/modules/stdlib/examples/init.pp
new file mode 100644 (file)
index 0000000..ad27972
--- /dev/null
@@ -0,0 +1 @@
+include ::stdlib
index b058437..5c5fb1f 100644 (file)
@@ -8,7 +8,7 @@
 # contains a cache TTL.  For foo.sh store the ttl as just
 # a number in foo.sh.ttl
 #
-# The cache is stored in /tmp/facts_cache.yaml as a mode
+# 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
 
@@ -48,7 +48,7 @@ class Facter::Util::DotD
         end
       end
     end
-  rescue Exception => e
+  rescue StandardError => e
     Facter.warn("Failed to handle #{file} as text facts: #{e.class}: #{e}")
   end
 
@@ -65,7 +65,7 @@ class Facter::Util::DotD
         setcode { v }
       end
     end
-  rescue Exception => e
+  rescue StandardError => e
     Facter.warn("Failed to handle #{file} as json facts: #{e.class}: #{e}")
   end
 
@@ -77,7 +77,7 @@ class Facter::Util::DotD
         setcode { v }
       end
     end
-  rescue Exception => e
+  rescue StandardError => e
     Facter.warn("Failed to handle #{file} as yaml facts: #{e.class}: #{e}")
   end
 
@@ -106,7 +106,7 @@ class Facter::Util::DotD
         end
       end
     end
-  rescue Exception => e
+  rescue StandardError => e
     Facter.warn("Failed to handle #{file} as script facts: #{e.class}: #{e}")
     Facter.debug(e.backtrace.join("\n\t"))
   end
diff --git a/3rdparty/modules/stdlib/lib/facter/package_provider.rb b/3rdparty/modules/stdlib/lib/facter/package_provider.rb
new file mode 100644 (file)
index 0000000..3a9117f
--- /dev/null
@@ -0,0 +1,21 @@
+# Fact: package_provider
+#
+# Purpose: Returns the default provider Puppet will choose to manage packages
+#   on this system
+#
+# Resolution: Instantiates a dummy package resource and return the provider
+#
+# Caveats:
+#
+require 'puppet/type'
+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')
+      Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s
+    else
+      Puppet::Type.type(:package).newpackage(:name => 'dummy')[:provider].to_s
+    end
+  end
+end
index 0cc0f64..c9f2181 100644 (file)
 #
 Facter.add("pe_version") do
   setcode do
-    pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
-    pe_ver[1] if pe_ver
+    puppet_ver = Facter.value("puppetversion")
+    if puppet_ver != nil
+      pe_ver = puppet_ver.match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
+      pe_ver[1] if pe_ver
+    else
+      nil
+    end
   end
 end
 
diff --git a/3rdparty/modules/stdlib/lib/facter/puppet_settings.rb b/3rdparty/modules/stdlib/lib/facter/puppet_settings.rb
new file mode 100644 (file)
index 0000000..eac9e97
--- /dev/null
@@ -0,0 +1,43 @@
+# These facter facts return the value of the Puppet vardir and environment path
+# settings for the node running puppet or puppet agent.  The intent is to
+# enable Puppet modules to automatically have insight into a place where they
+# can place variable data, or for modules running on the puppet master to know
+# where environments are stored.
+#
+# The values should be directly usable in a File resource path attribute.
+#
+begin
+  require 'facter/util/puppet_settings'
+rescue LoadError => e
+  # puppet apply does not add module lib directories to the $LOAD_PATH (See
+  # #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
+end
+
+
+# These will be nil if Puppet is not available.
+Facter.add(:puppet_vardir) do
+  setcode do
+    Facter::Util::PuppetSettings.with_puppet do
+      Puppet[:vardir]
+    end
+  end
+end
+
+Facter.add(:puppet_environmentpath) do
+  setcode do
+    Facter::Util::PuppetSettings.with_puppet do
+      Puppet[:environmentpath]
+    end
+  end
+end
+
+Facter.add(:puppet_server) do
+  setcode do
+    Facter::Util::PuppetSettings.with_puppet do
+      Puppet[:server]
+    end
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/facter/puppet_vardir.rb b/3rdparty/modules/stdlib/lib/facter/puppet_vardir.rb
deleted file mode 100644 (file)
index 0e6af40..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# This facter fact returns the value of the Puppet vardir setting for the node
-# running puppet or puppet agent.  The intent is to enable Puppet modules to
-# automatically have insight into a place where they can place variable data,
-# regardless of the node's platform.
-#
-# The value should be directly usable in a File resource path attribute.
-
-
-begin
-  require 'facter/util/puppet_settings'
-rescue LoadError => e
-  # puppet apply does not add module lib directories to the $LOAD_PATH (See
-  # #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
-end
-
-Facter.add(:puppet_vardir) do
-  setcode do
-    # This will be nil if Puppet is not available.
-    Facter::Util::PuppetSettings.with_puppet do
-      Puppet[:vardir]
-    end
-  end
-end
index b4f87ff..87c7657 100644 (file)
@@ -30,3 +30,16 @@ Facter.add(:root_home) do
     hash['dir'].strip
   end
 end
+
+Facter.add(:root_home) do
+  confine :kernel => :aix
+  root_home = nil
+  setcode do
+    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]
+    end
+    root_home
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/facter/service_provider.rb b/3rdparty/modules/stdlib/lib/facter/service_provider.rb
new file mode 100644 (file)
index 0000000..a117921
--- /dev/null
@@ -0,0 +1,17 @@
+# Fact: service_provider
+#
+# Purpose: Returns the default provider Puppet will choose to manage services
+#   on this system
+#
+# Resolution: Instantiates a dummy service resource and return the provider
+#
+# Caveats:
+#
+require 'puppet/type'
+require 'puppet/type/service'
+
+Facter.add(:service_provider) do
+  setcode do
+    Puppet::Type.type(:service).newservice(:name => 'dummy')[:provider].to_s
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb b/3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb
new file mode 100644 (file)
index 0000000..39d9bc7
--- /dev/null
@@ -0,0 +1,29 @@
+# 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
+  dispatch :deprecation do
+    param 'String', :key
+    param 'String', :message
+  end
+
+  def deprecation(key, message)
+    if defined? Puppet::Pops::PuppetStack.stacktrace()
+      stacktrace = Puppet::Pops::PuppetStack.stacktrace()
+      file = stacktrace[0]
+      line = stacktrace[1]
+      message = "#{message} at #{file}:#{line}"
+    end
+    # depending on configuration setting of strict
+    case Puppet.settings[:strict]
+    when :off
+      # do nothing
+    when :error
+      fail("deprecation. #{key}. #{message}")
+    else
+      unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false'
+        Puppet.deprecation_warning(message, key)
+      end
+    end
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/fact.rb b/3rdparty/modules/stdlib/lib/puppet/functions/fact.rb
new file mode 100644 (file)
index 0000000..dfb048b
--- /dev/null
@@ -0,0 +1,58 @@
+# Digs into the facts hash using dot-notation
+#
+# Example usage:
+#
+#     fact('osfamily')
+#     fact('os.architecture')
+#
+# Array indexing:
+#
+#     fact('mountpoints."/dev".options.1')
+#
+# Fact containing a "." in the name:
+#
+#     fact('vmware."VRA.version"')
+#
+Puppet::Functions.create_function(:fact) do
+  dispatch :fact do
+    param 'String', :fact_name
+  end
+
+  def to_dot_syntax(array_path)
+    array_path.map do |string|
+      string.include?('.') ? %Q{"#{string}"} : string
+    end.join('.')
+  end
+
+  def fact(fact_name)
+    facts = closure_scope['facts']
+
+    # 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 }
+
+    walked_path = []
+    path.reduce(facts) do |d, k|
+      return nil if d.nil? || k.nil?
+
+      case
+      when d.is_a?(Array)
+        begin
+          result = d[Integer(k)]
+        rescue ArgumentError => e
+          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)
+        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}'")
+        result = nil
+      end
+
+      walked_path << k
+      result
+    end
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb
new file mode 100644 (file)
index 0000000..da98b03
--- /dev/null
@@ -0,0 +1,32 @@
+# Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks.
+#
+# @example how to check a data type
+#   # check a data type
+#       foo = 3
+#       $bar = [1,2,3]
+#       $baz = 'A string!'
+#
+#       if $foo.is_a(Integer) {
+#         notify  { 'foo!': }
+#       }
+#       if $bar.is_a(Array) {
+#         notify { 'bar!': }
+#       }
+#       if $baz.is_a(String) {
+#         notify { 'baz!': }
+#       }
+#
+# 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.
+#
+Puppet::Functions.create_function(:is_a) do
+  dispatch :is_a do
+    param 'Any', :value
+    param 'Type', :type
+  end
+
+  def is_a(value, type)
+    # See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression
+    Puppet::Pops::Types::TypeCalculator.instance?(type, value)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb
new file mode 100644 (file)
index 0000000..b61064a
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_absolute_path) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb
new file mode 100644 (file)
index 0000000..a29fe8a
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_array) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb
new file mode 100644 (file)
index 0000000..6e2c22b
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_bool) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb
new file mode 100644 (file)
index 0000000..c91aa5d
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_float) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb
new file mode 100644 (file)
index 0000000..4c72037
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_ip_address) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb
new file mode 100644 (file)
index 0000000..97b01ae
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_ipv4_address) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb
new file mode 100644 (file)
index 0000000..be0c98a
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_ipv6_address) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb
new file mode 100644 (file)
index 0000000..f5e9d41
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_numeric) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb
new file mode 100644 (file)
index 0000000..a05a796
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:is_string) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/length.rb b/3rdparty/modules/stdlib/lib/puppet/functions/length.rb
new file mode 100644 (file)
index 0000000..86e735c
--- /dev/null
@@ -0,0 +1,14 @@
+#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. 
+Puppet::Functions.create_function(:length) do
+  dispatch :length do
+    param 'Variant[String,Array,Hash]', :value
+  end
+  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
+  end
+end
index 02cdd4d..01f1f49 100644 (file)
@@ -10,6 +10,8 @@
 # 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 
+# this function is provided for backwards compatibility.
 Puppet::Functions.create_function(:type_of) do
   def type_of(value)
     Puppet::Pops::Types::TypeCalculator.infer_set(value)
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb
new file mode 100644 (file)
index 0000000..a3c696d
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_absolute_path) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb
new file mode 100644 (file)
index 0000000..f59c6b4
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_array) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb
new file mode 100644 (file)
index 0000000..5cfb2ac
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_bool) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb
new file mode 100644 (file)
index 0000000..89ad9ab
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_hash) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb
new file mode 100644 (file)
index 0000000..475ea0f
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_integer) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb
new file mode 100644 (file)
index 0000000..1521c08
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_ip_address) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb
new file mode 100644 (file)
index 0000000..fe66ab3
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_ipv4_address) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb
new file mode 100644 (file)
index 0000000..7cc3cbd
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_ipv6_address) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb
new file mode 100644 (file)
index 0000000..c9d1f56
--- /dev/null
@@ -0,0 +1,62 @@
+Puppet::Functions.create_function(:validate_legacy) do
+  # The function checks a value against both the target_type (new) and the previous_validation function (old).
+
+  dispatch :validate_legacy do
+    param 'Any', :scope
+    param 'Type', :target_type
+    param 'String', :function_name
+    param 'Any', :value
+    repeated_param 'Any', :args
+  end
+
+  dispatch :validate_legacy_s do
+    param 'Any', :scope
+    param 'String', :type_string
+    param 'String', :function_name
+    param 'Any', :value
+    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.
+  def call(scope, *args)
+    manipulated_args = [scope] + args
+    self.class.dispatcher.dispatch(self, scope, manipulated_args)
+  end
+
+  def validate_legacy_s(scope, type_string, *args)
+    t = Puppet::Pops::Types::TypeParser.new.parse(type_string, scope)
+    validate_legacy(scope, t, *args)
+  end
+
+  def validate_legacy(scope, target_type, function_name, value, *prev_args)
+    if assert_type(target_type, value)
+      if previous_validation(scope, function_name, value, *prev_args)
+        # Silently passes
+      else
+        Puppet.notice("Accepting previously invalid value for target type '#{target_type}'")
+      end
+    else
+      inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value)
+      error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch("validate_legacy(#{function_name})", target_type, inferred_type)
+      if previous_validation(scope, function_name, value, *prev_args)
+        call_function('deprecation', 'validate_legacy', error_msg)
+      else
+        call_function('fail', error_msg)
+      end
+    end
+  end
+
+  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
+  end
+
+  def assert_type(type, value)
+    Puppet::Pops::Types::TypeCalculator.instance?(type, value)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb
new file mode 100644 (file)
index 0000000..3052d35
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_numeric) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb
new file mode 100644 (file)
index 0000000..19443a8
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_re) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb
new file mode 100644 (file)
index 0000000..584232a
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_slength) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb
new file mode 100644 (file)
index 0000000..91ff004
--- /dev/null
@@ -0,0 +1,15 @@
+Puppet::Functions.create_function(:validate_string) do
+  dispatch :deprecation_gen 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.
+  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)
+  end
+end
index 11d2d7f..222a902 100644 (file)
@@ -9,8 +9,7 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "abs(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "abs(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
 
     value = arguments[0]
 
@@ -21,8 +20,7 @@ module Puppet::Parser::Functions
       elsif value.match(/^-?\d+$/)
         value = value.to_i
       else
-        raise(Puppet::ParseError, 'abs(): Requires float or ' +
-          'integer to work with')
+        raise(Puppet::ParseError, 'abs(): Requires float or integer to work with')
       end
     end
 
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb
new file mode 100644 (file)
index 0000000..17612bf
--- /dev/null
@@ -0,0 +1,54 @@
+#
+# any2bool.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:any2bool, :type => :rvalue, :doc => <<-EOS
+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
+    EOS
+  ) do |arguments|
+
+    raise(Puppet::ParseError, "any2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+
+    # If argument is already Boolean, return it
+    if !!arguments[0] == arguments[0]
+      return arguments[0]
+    end
+
+    arg = arguments[0]
+
+    if arg == nil
+      return false
+    end
+
+    if arg == :undef
+      return false
+    end
+
+    valid_float = !!Float(arg) rescue false
+
+    if arg.is_a?(Numeric)
+      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
+    end
+
+    return true
+
+  end
+end
+
+# vim: set ts=2 sw=2 et :
index 66c79cc..62e2c6b 100644 (file)
@@ -9,8 +9,7 @@ module Puppet::Parser::Functions
     EOS
   ) do |args|
 
-    raise(Puppet::ParseError, "assert_private(): Wrong number of arguments "+
-      "given (#{args.size}}) for 0 or 1)") if args.size > 1
+    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')
index 617ba31..d610146 100644 (file)
@@ -1,3 +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|
@@ -6,14 +9,19 @@ module Puppet::Parser::Functions
 
     Usage:
 
-      $encodestring = base64('encode','thestring')
-      $decodestring = base64('decode','dGhlc3RyaW5n')
+      $encodestring = base64('encode', 'thestring')
+      $decodestring = base64('decode', 'dGhlc3RyaW5n')
+
+      # explicitly define encode/decode method: default, strict, urlsafe
+      $method = 'default'
+      $encodestring = base64('encode', 'thestring', $method)
+      $decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
 
     ENDHEREDOC
 
     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']
 
@@ -25,11 +33,37 @@ module Puppet::Parser::Functions
       raise Puppet::ParseError, ("base64(): the second argument must be a string to base64")
     end
 
+    method = ['default','strict','urlsafe']
+
+    if args.length <= 2
+      chosenMethod = 'default'
+    else
+      chosenMethod = args[2]
+    end
+
+    unless method.include?(chosenMethod)
+      raise Puppet::ParseError, ("base64(): the third argument must be one of 'default', 'strict', or 'urlsafe'")
+    end
+
     case args[0]
       when 'encode'
-        result = Base64.encode64(args[1])
+        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'
-        result = Base64.decode64(args[1])
+        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
     end
 
     return result
index 6ad6cf4..92e4dde 100644 (file)
@@ -11,8 +11,7 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "bool2num(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
 
     value = function_str2bool([arguments[0]])
 
index fcd3791..37d4a4e 100644 (file)
@@ -4,15 +4,28 @@
 
 module Puppet::Parser::Functions
   newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS
-    Converts a boolean to a string.
+    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
+    converted from a boolean to a string containing 'true' or 'false'.
+
+    *Examples:*
+
+    bool2str(true)                    => 'true'
+    bool2str(true, 'yes', 'no')       => 'yes'
+    bool2str(false, 't', 'f')         => 'f'
+
     Requires a single boolean as an input.
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "bool2str(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    unless arguments.size == 1 or arguments.size == 3
+      raise(Puppet::ParseError, "bool2str(): Wrong number of arguments given (#{arguments.size} for 3)")
+    end
 
     value = arguments[0]
+    true_string = arguments[1] || 'true'
+    false_string = arguments[2] || 'false'
     klass = value.class
 
     # We can have either true or false, and nothing else
@@ -20,7 +33,11 @@ module Puppet::Parser::Functions
       raise(Puppet::ParseError, 'bool2str(): Requires a boolean to work with')
     end
 
-    return value.to_s
+    unless [true_string, false_string].all?{|x| x.kind_of?(String)}
+      raise(Puppet::ParseError, "bool2str(): Requires strings to convert to" )
+    end
+
+    return value ? true_string : false_string
   end
 end
 
index d7f43f7..085b3c6 100644 (file)
@@ -1,5 +1,6 @@
 #
 #  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
@@ -8,15 +9,13 @@ Converts the case of a string or all strings in an array to camel case.
     EOS
   ) 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.size < 1
 
     value = arguments[0]
     klass = value.class
 
     unless [Array, String].include?(klass)
-      raise(Puppet::ParseError, 'camelcase(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'camelcase(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
index 98b2d16..096bc5d 100644 (file)
@@ -1,5 +1,6 @@
 #
 #  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
@@ -9,14 +10,12 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "capitalize(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'capitalize(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'capitalize(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
@@ -29,5 +28,3 @@ module Puppet::Parser::Functions
     return result
   end
 end
-
-# vim: set ts=2 sw=2 et :
index 5f3b10b..bec4266 100644 (file)
@@ -5,18 +5,15 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "ceiling(): Wrong number of arguments " +
-          "given (#{arguments.size} for 1)") if arguments.size != 1
+    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
-      raise(Puppet::ParseError, "ceiling(): Wrong argument type " +
-            "given (#{arguments[0]} for Numeric)")
+      raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arguments[0]} for Numeric)")
     end
 
-    raise(Puppet::ParseError, "ceiling(): Wrong argument type " +
-          "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
+    raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
 
     arg.ceil
   end
index c55841e..f9da50f 100644 (file)
@@ -10,14 +10,12 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "chomp(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "chomp(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'chomp(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'chomp(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
index b24ab78..809349d 100644 (file)
@@ -12,14 +12,12 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "chop(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "chop(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'chop(): Requires either an ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'chop(): Requires either an array or string to work with')
     end
 
     if value.is_a?(Array)
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/clamp.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/clamp.rb
new file mode 100644 (file)
index 0000000..c4503fe
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# clamp.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS
+    Clamps value to a range.
+    EOS
+  ) do |args|
+
+    args.flatten!
+
+    raise(Puppet::ParseError, 'clamp(): Wrong number of arguments, need three to clamp') if args.size != 3
+
+    # 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})")
+      end
+    end
+
+    # convert to numeric each element
+    # then sort them and get a middle value
+    args.map{ |n| n.to_i }.sort[1]
+  end
+end
index 618e62d..0a49cfe 100644 (file)
@@ -17,8 +17,7 @@ Would result in:
   ) 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
+    raise(Puppet::ParseError, "concat(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2
 
     a = arguments[0]
 
@@ -31,7 +30,7 @@ Would result in:
     arguments.shift
 
     arguments.each do |x|
-      result = result + Array(x)
+      result = result + (x.is_a?(Array) ? x : [x])
     end
 
     return result
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb
new file mode 100644 (file)
index 0000000..0fcbafe
--- /dev/null
@@ -0,0 +1,35 @@
+module Puppet::Parser::Functions
+
+  newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args|
+
+    Converts a given integer or base 10 string representing an integer to a specified base, as a string.
+
+    Usage:
+
+      $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
+
+    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))
+
+    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]+$/
+    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]+$/
+    end
+
+    number_to_convert = args[0]
+    new_base = args[1]
+
+    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
+
+    return number_to_convert.to_s(new_base)
+  end
+end
index 52de1b8..cef2637 100644 (file)
@@ -7,8 +7,7 @@ If called with only an array it counts the number of elements that are not nil/u
   ) do |args|
 
     if (args.size > 2) then
-      raise(ArgumentError, "count(): Wrong number of arguments "+
-        "given #{args.size} for 1 or 2.")
+      raise(ArgumentError, "count(): Wrong number of arguments given #{args.size} for 1 or 2.")
     end
 
     collection, item = args
index d7df306..c45a9df 100644 (file)
@@ -24,9 +24,30 @@ ENDOFDOC
     params = {}
   end
   ret = false
-  if resource = findresource(reference.to_s)
+
+  if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0
+    # Workaround for PE-20308
+    if reference.is_a?(String)
+      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
+      title = reference.title
+    else
+      raise(ArgumentError, "Reference is not understood: '#{reference.class}'")
+    end
+    #end workaround
+  else
+    type = reference.to_s
+    title = nil
+  end
+
+  if resource = findresource(type, title)
     matches = params.collect do |key, value|
-      resource[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?
+      (resource_is_undef && value_is_undef) || (resource[key] == value)
     end
     ret = params.empty? || !matches.include?(false)
   end
index f548b44..9dd5164 100644 (file)
@@ -2,8 +2,6 @@
 # delete.rb
 #
 
-# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
-
 module Puppet::Parser::Functions
   newfunction(:delete, :type => :rvalue, :doc => <<-EOS
 Deletes all instances of a given element from an array, substring from a
@@ -25,10 +23,7 @@ string, or key from a hash.
   EOS
   ) do |arguments|
 
-    if (arguments.size != 2) then
-      raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
-                                  "given #{arguments.size} for 2.")
-    end
+    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|
@@ -38,8 +33,7 @@ string, or key from a hash.
         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}.")
+          raise(TypeError, "delete(): First argument must be an Array, String, or Hash. Given an argument of class #{collection.class}.")
       end
     end
     collection
index 3eb4b53..daf3721 100644 (file)
@@ -14,8 +14,7 @@ Would return: ['a','c']
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " +
-      "given (#{arguments.size} for 2)") if arguments.size < 2
+    raise(Puppet::ParseError, "delete_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
 
     array = arguments[0]
 
@@ -26,8 +25,7 @@ Would return: ['a','c']
     index = arguments[1]
 
     if index.is_a?(String) and not index.match(/^\d+$/)
-      raise(Puppet::ParseError, 'delete_at(): You must provide ' +
-        'non-negative numeric index')
+      raise(Puppet::ParseError, 'delete_at(): You must provide non-negative numeric index')
     end
 
     result = array.clone
@@ -36,8 +34,7 @@ Would return: ['a','c']
     index = index.to_i
 
     if index > result.size - 1 # First element is at index 0 is it not?
-      raise(Puppet::ParseError, 'delete_at(): Given index ' +
-        'exceeds size of array given')
+      raise(Puppet::ParseError, 'delete_at(): Given index exceeds size of array given')
     end
 
     result.delete_at(index) # We ignore the element that got deleted ...
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_regex.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_regex.rb
new file mode 100644 (file)
index 0000000..e5dc1fd
--- /dev/null
@@ -0,0 +1,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.
+
+*Examples:*
+
+    delete_regex(['a','b','c','b'], 'b')
+    Would return: ['a','c']
+
+    delete_regex(['a','b','c','b'], ['b', 'c'])
+    Would return: ['a']
+
+    delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
+    Would return: {'a'=>1,'c'=>3}
+
+    delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
+    Would return: {'b'=>2,'c'=>3}
+
+  EOS
+  ) 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}.")
+      end
+    end
+    collection
+  end
+end
+
+# vim: set ts=2 sw=2 et :
index f94d4da..00bd252 100644 (file)
@@ -15,13 +15,10 @@ Would return: ['A','',false]
       EOS
     ) do |args|
 
-    raise(Puppet::ParseError,
-          "delete_undef_values(): Wrong number of arguments given " +
-          "(#{args.size})") if args.size < 1
+    raise(Puppet::ParseError, "delete_undef_values(): Wrong number of arguments given (#{args.size})") if args.size < 1
 
     unless args[0].is_a? Array or args[0].is_a? Hash
-      raise(Puppet::ParseError,
-            "delete_undef_values(): expected an array or hash, got #{args[0]} type  #{args[0].class} ")
+      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)
index f6c8c0e..e799aef 100644 (file)
@@ -11,15 +11,12 @@ Would return: {'a'=>'A','c'=>'C','B'=>'D'}
       EOS
     ) do |arguments|
 
-    raise(Puppet::ParseError,
-          "delete_values(): Wrong number of arguments given " +
-          "(#{arguments.size} of 2)") if arguments.size != 2
+    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)
-      raise(TypeError, "delete_values(): First argument must be a Hash. " + \
-                       "Given an argument of class #{hash.class}.")
+      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 }
   end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/deprecation.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/deprecation.rb
new file mode 100644 (file)
index 0000000..39d306a
--- /dev/null
@@ -0,0 +1,16 @@
+module Puppet::Parser::Functions
+  newfunction(:deprecation, :doc => <<-EOS
+  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|
+
+    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"
+      warning("deprecation. #{key}. #{message}")
+    end
+  end
+end
index cd258f7..c9ac478 100644 (file)
@@ -17,8 +17,7 @@ Would return: ["a"]
   ) do |arguments|
 
     # Two arguments are required
-    raise(Puppet::ParseError, "difference(): Wrong number of arguments " +
-      "given (#{arguments.size} for 2)") if arguments.size != 2
+    raise(Puppet::ParseError, "difference(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2
 
     first = arguments[0]
     second = arguments[1]
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb
new file mode 100644 (file)
index 0000000..34fa701
--- /dev/null
@@ -0,0 +1,16 @@
+#
+# dig.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:dig, :type => :rvalue, :doc => <<-EOS
+    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)
+      Puppet::Parser::Functions.autoloader.load(:dig44)
+    end
+    function_dig44(arguments)
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb
new file mode 100644 (file)
index 0000000..21c0a8c
--- /dev/null
@@ -0,0 +1,70 @@
+#
+# 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.
+
+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 = dig44($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.
+
+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
+  ) 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
+
+    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
+        end
+        break if structure[key].nil? or structure[key] == :undef
+        structure[key]
+      else
+        break
+      end
+    end
+    value.nil? ? default : value
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb
new file mode 100644 (file)
index 0000000..ccac899
--- /dev/null
@@ -0,0 +1,15 @@
+# Custom Puppet function to convert dos to unix format
+module Puppet::Parser::Functions
+  newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-EOS
+    Returns the Unix version of the given string.
+    Takes a single string argument.
+    EOS
+  ) do |arguments|
+
+    unless arguments[0].is_a?(String)
+      raise(Puppet::ParseError, 'dos2unix(): Requires string as argument')
+    end
+
+    arguments[0].gsub(/\r\n/, "\n")
+  end
+end
index 040b84f..ab04f8a 100644 (file)
@@ -1,5 +1,6 @@
 #
 #  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
@@ -8,14 +9,12 @@ Converts the case of a string or all strings in an array to lower case.
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'downcase(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'downcase(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
index cca620f..4f77ad3 100644 (file)
@@ -8,19 +8,21 @@ Returns true if the variable is empty.
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "empty(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
 
     value = arguments[0]
 
-    unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String)
-      raise(Puppet::ParseError, 'empty(): Requires either ' +
-        'array, hash or string to work with')
+    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
 
-    result = value.empty?
+    if value.is_a?(Numeric)
+      return false
+    else
+      result = value.empty?
 
-    return result
+      return result
+    end
   end
 end
 
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb
new file mode 100644 (file)
index 0000000..1f8a454
--- /dev/null
@@ -0,0 +1,42 @@
+#
+# 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|
+
+    require 'ipaddr'
+
+    rescuable_exceptions = [ ArgumentError ]
+    if defined?(IPAddr::InvalidAddressError)
+           rescuable_exceptions << IPAddr::InvalidAddressError
+    end
+
+    if (arguments.size != 1) then
+      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
+      raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type given #{arguments[0].class} expected String or Array")
+    end
+
+    input = [arguments[0]].flatten.compact
+    result = []
+
+    input.each do |val|
+      unless val == '*'
+        begin
+          ip = IPAddr.new(val)
+        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?
+      end
+      result << val
+    end
+
+    return result.uniq
+  end
+end
index f1da4aa..1bf8bf1 100644 (file)
@@ -11,24 +11,43 @@ third argument to the ensure_resource() function.
   ) 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(): 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
 
-    packages = Array(arguments[0])
+    if arguments[0].is_a?(Hash)
+      if arguments[1]
+        defaults = { 'ensure' => 'present' }.merge(arguments[1])
+        if defaults['ensure'] == 'installed'
+          defaults['ensure'] = 'present'
+        end
+      else
+        defaults = { 'ensure' => 'present' }
+      end
 
-    if arguments[1]
-      defaults = { 'ensure' => 'present' }.merge(arguments[1])
+      Puppet::Parser::Functions.function(:ensure_resources)
+      function_ensure_resources(['package', arguments[0].dup, defaults ])
     else
-      defaults = { 'ensure' => 'present' }
-    end
+      packages = Array(arguments[0])
+
+      if arguments[1]
+        defaults = { 'ensure' => 'present' }.merge(arguments[1])
+        if defaults['ensure'] == 'installed'
+          defaults['ensure'] = 'present'
+        end
+      else
+        defaults = { 'ensure' => 'present' }
+      end
 
-    Puppet::Parser::Functions.function(:ensure_resource)
-    packages.each { |package_name|
-      function_ensure_resource(['package', package_name, defaults ])
+      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 ])
+      end
     }
+    end
   end
 end
 
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb
new file mode 100644 (file)
index 0000000..b3c51e6
--- /dev/null
@@ -0,0 +1,54 @@
+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.
+
+    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.
+
+    ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } ,  'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
+
+From Hiera Backend:
+
+userlist:
+  dan:
+    gid: 'mygroup'
+ uid: '600'
+  alex:
+ gid: 'mygroup'
+
+Call:
+ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
+
+ENDOFDOC
+) 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')
+  end
+end
index a1ed183..4401bdb 100644 (file)
@@ -15,8 +15,7 @@ Would return: ['a','b','c']
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "flatten(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size != 1
+    raise(Puppet::ParseError, "flatten(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     array = arguments[0]
 
index 9a6f014..9e4b504 100644 (file)
@@ -5,18 +5,15 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "floor(): Wrong number of arguments " +
-          "given (#{arguments.size} for 1)") if arguments.size != 1
+    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
-      raise(Puppet::ParseError, "floor(): Wrong argument type " +
-            "given (#{arguments[0]} for Numeric)")
+      raise(Puppet::ParseError, "floor(): Wrong argument type given (#{arguments[0]} for Numeric)")
     end
 
-    raise(Puppet::ParseError, "floor(): Wrong argument type " +
-          "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
+    raise(Puppet::ParseError, "floor(): Wrong argument type given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
 
     arg.floor
   end
index 785c9fd..2bb1287 100644 (file)
@@ -15,8 +15,8 @@ Puppet::Parser::Functions::newfunction(
   `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_base64(): first argument must be a positive integer") unless function_is_integer([args[0]]) and args[0].to_i > 0
-    raise(ArgumentError, "fqdn_rand_base64(): second argument must be undef or a string") unless args[1].nil? or args[1].is_a? String
+    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
 
     Puppet::Parser::Functions.function('fqdn_rand')
 
index cf22d36..05bdcc7 100644 (file)
@@ -2,21 +2,26 @@
 # fqdn_rotate.rb
 #
 
-module Puppet::Parser::Functions
-  newfunction(:fqdn_rotate, :type => :rvalue, :doc => <<-EOS
-Rotates an array a random number of times based on a nodes fqdn.
-    EOS
-  ) do |arguments|
-
-    raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
-
-    value = arguments[0]
+Puppet::Parser::Functions.newfunction(
+  :fqdn_rotate,
+  :type => :rvalue,
+  :doc => "Usage: `fqdn_rotate(VALUE, [SEED])`. VALUE is required and
+  must be an array or a string. SEED is optional and may be any number
+  or string.
+
+  Rotates VALUE a random number of times, combining the `$fqdn` fact and
+  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|
+
+    raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments given (#{args.size} for 1)") if args.size < 1
+
+    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')
+      raise(Puppet::ParseError, 'fqdn_rotate(): Requires either array or string to work with')
     end
 
     result = value.clone
@@ -31,7 +36,7 @@ Rotates an array a random number of times based on a nodes fqdn.
 
     elements = result.size
 
-    seed = Digest::MD5.hexdigest([lookupvar('::fqdn'),arguments].join(':')).hex
+    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
@@ -39,9 +44,9 @@ Rotates an array a random number of times based on a nodes fqdn.
       if defined?(Random) == 'constant' && Random.class == Class
         offset = Random.new(seed).rand(elements)
       else
-        srand(seed)
+        old_seed = srand(seed)
         offset = rand(elements)
-        srand()
+        srand(old_seed)
       end
     end
     offset.times {
@@ -51,7 +56,6 @@ Rotates an array a random number of times based on a nodes fqdn.
     result = string ? result.join : result
 
     return result
-  end
 end
 
 # vim: set ts=2 sw=2 et :
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_uuid.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_uuid.rb
new file mode 100644 (file)
index 0000000..30205d0
--- /dev/null
@@ -0,0 +1,92 @@
+require 'digest/sha1'
+
+module Puppet::Parser::Functions
+  newfunction(:fqdn_uuid, :type => :rvalue, :doc => <<-END) 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:
+
+    Usage:
+
+      $uuid = fqdn_uuid($::fqdn)
+
+    The generated UUID will be the same for the given hostname
+
+    The resulting UUID is returned on the form:
+
+      1d839dea-5e10-5243-88eb-e66815bd7d5c
+
+    (u.e. without any curly braces.)
+
+    The generated UUID is a version 5 UUID with the V5 DNS namespace:
+
+      6ba7b810-9dad-11d1-80b4-00c04fd430c8
+
+    This only supports a the V5 SHA-1 hash, using the DNS namespace.
+
+    Please consult http://www.ietf.org/rfc/rfc4122.txt for the details on
+    UUID generation and example implementation.
+
+    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
+
+    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
+
+    # Code lovingly taken from
+    # https://github.com/puppetlabs/marionette-collective/blob/master/lib/mcollective/ssl.rb
+
+    # This is the UUID version 5 type DNS name space which is as follows:
+    #
+    #  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
+
+    sha1 = Digest::SHA1.new
+    sha1.update(uuid_name_space_dns)
+    sha1.update(fqdn)
+
+    # first 16 bytes..
+    bytes = sha1.digest[0, 16].bytes.to_a
+
+    # version 5 adjustments
+    bytes[6] &= 0x0f
+    bytes[6] |= 0x50
+
+    # variant is DCE 1.1
+    bytes[8] &= 0x3f
+    bytes[8] |= 0x80
+
+    bytes = [4, 2, 2, 2, 6].collect do |i|
+      bytes.slice!(0, i).pack('C*').unpack('H*')
+    end
+
+    bytes.join('-')
+  end
+end
index 6d51006..0a5cbe0 100644 (file)
@@ -28,7 +28,7 @@ ENDOFDOC
   return '' if param.empty?
 
   if resource = findresource(reference.to_s)
-    return resource[param] if resource[param]
+    return resource[param] unless resource[param].nil?
   end
 
   return ''
index fb336b6..3af8d48 100644 (file)
@@ -20,7 +20,13 @@ module Puppet::Parser::Functions
     end
 
     begin
-      self.lookupvar("#{args[0]}")
+      result = nil
+      catch(:undefined_variable) do
+        result = self.lookupvar("#{args[0]}")
+      end
+
+      # avoid relying on incosistent behaviour around ruby return values from catch
+      result
     rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
     end
 
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb
new file mode 100644 (file)
index 0000000..54cdda6
--- /dev/null
@@ -0,0 +1,22 @@
+#
+#  glob.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:glob, :type => :rvalue, :doc => <<-'EOS'
+    Returns an Array of file entries of a directory or an Array of directories.
+    Uses same patterns as Dir#glob
+    EOS
+  ) do |arguments|
+
+    raise(Puppet::ParseError, "glob(): Wrong number of arguments given " +
+      "(#{arguments.size} for 1)") unless arguments.size == 1
+
+    pattern = arguments[0]
+
+    raise(Puppet::ParseError, 'glob(): Requires either array or string ' +
+      'to work') unless pattern.is_a?(String) || pattern.is_a?(Array)
+
+    Dir.glob(pattern)
+  end
+end
index ceba9ec..c611a7e 100644 (file)
@@ -18,8 +18,7 @@ Would return:
   ) do |arguments|
 
     if (arguments.size != 2) then
-      raise(Puppet::ParseError, "grep(): Wrong number of arguments "+
-        "given #{arguments.size} for 2")
+      raise(Puppet::ParseError, "grep(): Wrong number of arguments given #{arguments.size} for 2")
     end
 
     a = arguments[0]
index 3691524..f6cb74b 100644 (file)
@@ -19,8 +19,7 @@ has_interface_with("lo")                        => true
     EOS
   ) 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.size < 1 or args.size > 2
 
     interfaces = lookupvar('interfaces')
 
@@ -38,8 +37,11 @@ has_interface_with("lo")                        => true
     # Bug with 3.7.1 - 3.7.3  when using future parser throws :undefined_variable
     # https://tickets.puppetlabs.com/browse/PUP-3597
     factval = nil
-    catch :undefined_variable do
-      factval = lookupvar(kind)
+    begin
+      catch :undefined_variable do
+        factval = lookupvar(kind)
+      end
+    rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
     end
     if factval == value
       return true
index 842c8ec..a0071c8 100644 (file)
@@ -11,8 +11,7 @@ This function iterates through the 'interfaces' fact and checks the
     EOS
   ) do |args|
 
-    raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments " +
-          "given (#{args.size} for 1)") if args.size != 1
+    raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1
 
     Puppet::Parser::Functions.autoloader.load(:has_interface_with) \
       unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with)
index 9ccf902..b02c0c0 100644 (file)
@@ -11,8 +11,7 @@ This function iterates through the 'interfaces' fact and checks the
     EOS
   ) do |args|
 
-    raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments " +
-          "given (#{args.size} for 1)") if args.size != 1
+    raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1
 
     Puppet::Parser::Functions.autoloader.load(:has_interface_with) \
       unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with)
index 8cc4823..22763f3 100644 (file)
@@ -14,8 +14,7 @@ Would return: {'a'=>1,'b'=>2,'c'=>3}
     EOS
   ) 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.size < 1
 
     array = arguments[0]
 
@@ -29,9 +28,8 @@ Would return: {'a'=>1,'b'=>2,'c'=>3}
       # This is to make it compatible with older version of Ruby ...
       array  = array.flatten
       result = Hash[*array]
-    rescue Exception
-      raise(Puppet::ParseError, 'hash(): Unable to compute ' +
-        'hash from array given')
+    rescue StandardError
+      raise(Puppet::ParseError, 'hash(): Unable to compute hash from array given')
     end
 
     return result
index 48f02e9..8a438f4 100644 (file)
@@ -4,19 +4,18 @@
 
 module Puppet::Parser::Functions
   newfunction(:intersection, :type => :rvalue, :doc => <<-EOS
-This function returns an array an intersection of two.
+This function returns an array of the intersection of two.
 
 *Examples:*
 
-    intersection(["a","b","c"],["b","c","d"])
+    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)
 
-Would return: ["b","c"]
     EOS
   ) do |arguments|
 
     # Two arguments are required
-    raise(Puppet::ParseError, "intersection(): Wrong number of arguments " +
-      "given (#{arguments.size} for 2)") if arguments.size != 2
+    raise(Puppet::ParseError, "intersection(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2
 
     first = arguments[0]
     second = arguments[1]
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb
new file mode 100644 (file)
index 0000000..e64777f
--- /dev/null
@@ -0,0 +1,50 @@
+module Puppet::Parser::Functions
+  newfunction(:is_absolute_path, :type => :rvalue, :arity => 1, :doc => <<-'ENDHEREDOC') do |args|
+    Returns boolean true if the string represents an absolute path in the filesystem.  This function works
+    for windows and unix style paths.
+
+    The following values will return true:
+
+        $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
+        is_absolute_path($my_path)
+        $my_path2 = '/var/lib/puppet'
+        is_absolute_path($my_path2)
+        $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet']
+        is_absolute_path($my_path3)
+        $my_path4 = ['/var/lib/puppet']
+        is_absolute_path($my_path4)
+
+    The following values will return false:
+
+        is_absolute_path(true)
+        is_absolute_path('../var/lib/puppet')
+        is_absolute_path('var/lib/puppet')
+        $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.'])
+    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))
+    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
+      # defaults to the local platform if none is specified.
+      # Escape once for the string literal, and once for the regex.
+      slash = '[\\\\/]'
+      name = '[^\\\\/]+'
+      regexes = {
+        :windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
+        :posix => %r!^/!
+      }
+      value = (!!(path =~ regexes[:posix])) || (!!(path =~ regexes[:windows]))
+    end
+    value
+  end
+end
index b39e184..a33afe4 100644 (file)
@@ -8,8 +8,9 @@ Returns true if the variable passed to this function is an array.
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "is_array(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    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
 
     type = arguments[0]
 
@@ -18,5 +19,3 @@ Returns true if the variable passed to this function is an array.
     return result
   end
 end
-
-# vim: set ts=2 sw=2 et :
index 8bbdbc8..2ebe430 100644 (file)
@@ -8,8 +8,9 @@ Returns true if the variable passed to this function is a boolean.
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size != 1
+    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
 
     type = arguments[0]
 
@@ -18,5 +19,3 @@ Returns true if the variable passed to this function is a boolean.
     return result
   end
 end
-
-# vim: set ts=2 sw=2 et :
index 90ede32..247db3b 100644 (file)
@@ -9,8 +9,7 @@ Returns true if the string passed to this function is a syntactically correct do
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     # Only allow string types
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb
new file mode 100644 (file)
index 0000000..bcd7921
--- /dev/null
@@ -0,0 +1,20 @@
+#
+# 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
+             ) do |arguments|
+    if arguments.size != 1
+      raise(Puppet::ParseError, "is_email_address(): Wrong number of arguments given #{arguments.size} for 1")
+    end
+
+    # 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
+  end
+end
+
+# vim: set ts=2 sw=2 et :
index a2da943..aa84a2b 100644 (file)
@@ -8,9 +8,10 @@ Returns true if the variable passed to this function is a float.
     EOS
   ) 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.'])
+
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "is_float(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     value = arguments[0]
index 6da82c8..50cd5e1 100644 (file)
@@ -11,8 +11,7 @@ true if the function exists, false if not.
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     # Only allow String types
index ad907f0..3162f7d 100644 (file)
@@ -8,8 +8,7 @@ Returns true if the variable passed to this function is a hash.
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "is_hash(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size != 1
+    raise(Puppet::ParseError, "is_hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     type = arguments[0]
 
index c03d28d..8965b15 100644 (file)
@@ -13,9 +13,10 @@ If given any other argument `false` is returned.
     EOS
   ) 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.'])
+
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "is_integer(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     value = arguments[0]
index a90adab..79ddb98 100644 (file)
@@ -10,9 +10,10 @@ Returns true if the string passed to this function is a valid IP address.
 
     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.'])
+
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     begin
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb
new file mode 100644 (file)
index 0000000..91869b6
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# 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|
+
+    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.'])
+
+    if (arguments.size != 1) then
+      raise(Puppet::ParseError, "is_ipv4_address(): Wrong number of arguments given #{arguments.size} for 1")
+    end
+
+    begin
+      ip = IPAddr.new(arguments[0])
+    rescue ArgumentError
+      return false
+    end
+
+    return ip.ipv4?
+  end
+end
+
+# vim: set ts=2 sw=2 et :
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb
new file mode 100644 (file)
index 0000000..4d96202
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# 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|
+
+    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
+      raise(Puppet::ParseError, "is_ipv6_address(): Wrong number of arguments given #{arguments.size} for 1")
+    end
+
+    begin
+      ip = IPAddr.new(arguments[0])
+    rescue ArgumentError
+      return false
+    end
+
+    return ip.ipv6?
+  end
+end
+
+# vim: set ts=2 sw=2 et :
index 1b3088a..5993ed2 100644 (file)
@@ -9,13 +9,12 @@ Returns true if the string passed to this function is a valid mac address.
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     mac = arguments[0]
 
-    if /^[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}$/.match(mac) then
+    if /^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$/i.match(mac) then
       return true
     else
       return false
index e7e1d2a..7800edd 100644 (file)
@@ -24,9 +24,10 @@ Valid examples:
     EOS
   ) 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.'])
+
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     value = arguments[0]
@@ -71,5 +72,3 @@ Valid examples:
     end
   end
 end
-
-# vim: set ts=2 sw=2 et :
index f5bef04..0ed6aec 100644 (file)
@@ -8,12 +8,14 @@ Returns true if the variable passed to this function is a string.
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "is_string(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    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
 
     type = arguments[0]
 
-    result = type.is_a?(String)
+    # 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
       return false
index 6c0a6ba..1c17997 100644 (file)
@@ -15,8 +15,7 @@ Would result in: "a,b,c"
   ) 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.size < 1
 
     array = arguments[0]
 
index e9924fe..d8966ba 100644 (file)
@@ -5,7 +5,8 @@
 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 and values are cast to strings. The return value is an array in
+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:*
@@ -13,33 +14,38 @@ which each element is one joined key/value pair.
     join_keys_to_values({'a'=>1,'b'=>2}, " is ")
 
 Would result in: ["a is 1","b is 2"]
+
+    join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")
+
+Would result in: ["a is 1","b is 2","b is 3"]
     EOS
   ) do |arguments|
 
     # Validate the number of arguments.
     if arguments.size != 2
-      raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two " +
-            "arguments, but #{arguments.size} given.")
+      raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two arguments, but #{arguments.size} given.")
     end
 
     # Validate the first argument.
     hash = arguments[0]
     if not hash.is_a?(Hash)
-      raise(TypeError, "join_keys_to_values(): The first argument must be a " +
-            "hash, but a #{hash.class} was given.")
+      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)
-      raise(TypeError, "join_keys_to_values(): The second argument must be a " +
-            "string, but a #{separator.class} was given.")
+      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|
-      String(k) + separator + String(v)
-    end
+      if v.is_a?(Array)
+        v.map { |va| String(k) + separator + String(va) }
+      else
+        String(k) + separator + String(v)
+      end
+    end.flatten
 
   end
 end
index f0d13b6..199e319 100644 (file)
@@ -8,8 +8,7 @@ Returns the keys of a hash as an array.
     EOS
   ) 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.size < 1
 
     hash = arguments[0]
 
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb
new file mode 100644 (file)
index 0000000..c9b8488
--- /dev/null
@@ -0,0 +1,24 @@
+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)
+    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)
+    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
+    end
+
+    return metadata
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb
new file mode 100644 (file)
index 0000000..3a3372b
--- /dev/null
@@ -0,0 +1,34 @@
+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.
+
+For example:
+
+    $myhash = loadjson('/etc/puppet/data/myhash.json')
+    $myhash = loadjson('no-file.json', {'default' => 'value'})
+  ENDHEREDOC
+
+    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]
+        else
+          raise e
+        end
+      end
+    else
+      warning("Can't load '#{args[0]}' File does not exist!")
+      args[1]
+    end
+
+  end
+
+end
index 10c4005..9696362 100644 (file)
@@ -1,20 +1,34 @@
 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, :doc => <<-'ENDHEREDOC') do |args|
-    Load a YAML file containing an array, string, or hash, and return the data
-    in the corresponding native data type.
+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')
-    ENDHEREDOC
+    raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1
+    require 'yaml'
 
-    unless args.length == 1
-      raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)")
+    if File.exists?(args[0])
+      begin
+        YAML::load_file(args[0]) || args[1]
+      rescue Exception => e
+        if args[1]
+          args[1]
+        else
+          raise e
+        end
+      end
+    else
+      warning("Can't load '#{args[0]}' File does not exist!")
+      args[1]
     end
 
-    YAML.load_file(args[0])
-
   end
 
 end
index 624e4c8..9a9ee29 100644 (file)
@@ -8,14 +8,12 @@ Strips leading spaces to the left of a string.
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'lstrip(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'lstrip(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
index 60fb94a..758c42c 100644 (file)
@@ -5,8 +5,7 @@ module Puppet::Parser::Functions
     EOS
   ) do |args|
 
-    raise(Puppet::ParseError, "max(): Wrong number of arguments " +
-          "need at least one") if args.size == 0
+    raise(Puppet::ParseError, "max(): Wrong number of arguments need at least one") if args.size == 0
 
     # Sometimes we get numbers as numerics and sometimes as strings.
     # We try to compare them as numbers when possible
index 88609ce..fb93452 100644 (file)
@@ -30,8 +30,7 @@ would return: false
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "member(): Wrong number of arguments " +
-      "given (#{arguments.size} for 2)") if arguments.size < 2
+    raise(Puppet::ParseError, "member(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
 
     array = arguments[0]
 
@@ -44,14 +43,13 @@ would return: false
     end
 
     if arguments[1].is_a? String or arguments[1].is_a? Fixnum
-      item = Array(arguments[1])
+      item = [arguments[1]]
     else
       item = arguments[1]
     end
 
 
-    raise(Puppet::ParseError, 'member(): You must provide item ' +
-      'to search for within array given') if item.respond_to?('empty?') && item.empty?
+    raise(Puppet::ParseError, 'member(): You must provide item to search for within array given') if item.respond_to?('empty?') && item.empty?
 
     result = (item - array).empty?
 
index 6bd6ebf..f10a2b2 100644 (file)
@@ -5,8 +5,7 @@ module Puppet::Parser::Functions
     EOS
   ) do |args|
 
-    raise(Puppet::ParseError, "min(): Wrong number of arguments " +
-          "need at least one") if args.size == 0
+    raise(Puppet::ParseError, "min(): Wrong number of arguments need at least one") if args.size == 0
 
     # Sometimes we get numbers as numerics and sometimes as strings.
     # We try to compare them as numbers when possible
index af0e6ed..9ad59b2 100644 (file)
@@ -10,8 +10,7 @@ become true.
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size != 1
+    raise(Puppet::ParseError, "num2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     number = arguments[0]
 
index a9a16a4..f7c2896 100644 (file)
@@ -4,20 +4,25 @@
 
 module Puppet::Parser::Functions
   newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS
-This function accepts JSON as a string and converts into the correct Puppet
-structure.
-    EOS
+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|
+    raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1
 
-    if (arguments.size != 1) then
-      raise(Puppet::ParseError, "parsejson(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+    begin
+      PSON::load(arguments[0]) || arguments[1]
+    rescue StandardError => e
+      if arguments[1]
+        arguments[1]
+      else
+        raise e
+      end
     end
 
-    json = arguments[0]
-
-    # PSON is natively available in puppet
-    PSON.load(json)
   end
 end
 
index 53d54fa..ba9d98a 100644 (file)
@@ -6,17 +6,26 @@ 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.
-    EOS
-  ) do |arguments|
-
-    if (arguments.size != 1) then
-      raise(Puppet::ParseError, "parseyaml(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
-    end
 
+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|
+    raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1
     require 'yaml'
 
-    YAML::load(arguments[0])
+    begin
+      YAML::load(arguments[0]) || arguments[1]
+      # 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
+    end
 
   end
 end
index ac1c58a..b1c1e35 100644 (file)
@@ -15,8 +15,7 @@ Will return: ['pa','pb','pc']
   ) 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.size < 1
 
     enumerable = arguments[0]
 
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb
new file mode 100644 (file)
index 0000000..c18ef7e
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# 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.
+
+*Examples:*
+
+    pry()
+    EOS
+  ) do |arguments|
+    begin
+      require 'pry'
+    rescue LoadError
+      raise(Puppet::Error, "pry(): Requires the 'pry' rubygem to use, but it was not found")
+    end
+    #
+    ## Run `catalog` to see the contents currently compiling catalog
+    ## Run `cd catalog` and `ls` to see catalog methods and instance variables
+    ## Run `@resource_table` to see the current catalog resource table
+    #
+    if $stdout.isatty
+      binding.pry # rubocop:disable Lint/Debugger
+    else
+      Puppet.warning 'pry(): cowardly refusing to start the debugger on a daemonized master'
+    end
+  end
+end
index ad3e393..0deeb3a 100644 (file)
@@ -1,3 +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.
+
 Puppet::Parser::Functions::newfunction(
   :pw_hash,
   :type => :rvalue,
@@ -24,6 +27,13 @@ Puppet::Parser::Functions::newfunction(
   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',
@@ -38,19 +48,19 @@ Puppet::Parser::Functions::newfunction(
     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'
-        # override String#crypt for password variable
-        def password.crypt(salt)
-          # puppetserver bundles Apache Commons Codec
-          org.apache.commons.codec.digest.Crypt.crypt(self.to_java_bytes, salt)
-        end
+        # 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
+    else
+      password.crypt(salt)
     end
-    password.crypt("$#{hash_type}$#{args[2]}")
 end
index 49fba21..72c373a 100644 (file)
@@ -25,8 +25,8 @@ integers automatically)
 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.
 
 Passing a third argument will cause the generated range to step by that
 interval, e.g.
@@ -37,18 +37,16 @@ Will return: [0,2,4,6,8]
     EOS
   ) do |arguments|
 
-    # We support more than one argument but at least one is mandatory ...
-    raise(Puppet::ParseError, "range(): Wrong number of " +
-      "arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    raise(Puppet::ParseError, 'range(): Wrong number of arguments given (0 for 1)') if arguments.size == 0
 
     if arguments.size > 1
       start = arguments[0]
       stop  = arguments[1]
       step  = arguments[2].nil? ? 1 : arguments[2].to_i.abs
 
-      type = '..' # We select simplest type for Range available in Ruby ...
+      type = '..' # Use the simplest type of Range available in Ruby
 
-    elsif arguments.size > 0
+    else # arguments.size == 1
       value = arguments[0]
 
       if m = value.match(/^(\w+)(\.\.\.?|\-)(\w+)$/)
@@ -56,16 +54,15 @@ Will return: [0,2,4,6,8]
         stop  = m[3]
 
         type = m[2]
-
+        step = 1
       elsif value.match(/^.+$/)
-        raise(Puppet::ParseError, 'range(): Unable to compute range ' +
-          'from the value given')
+        raise(Puppet::ParseError, "range(): Unable to compute range from the value: #{value}")
       else
-        raise(Puppet::ParseError, 'range(): Unknown format of range given')
+        raise(Puppet::ParseError, "range(): Unknown range format: #{value}")
       end
     end
 
-    # Check whether we have integer value if so then make it so ...
+    # If we were given an integer, ensure we work with one
     if start.to_s.match(/^\d+$/)
       start = start.to_i
       stop  = stop.to_i
@@ -76,10 +73,10 @@ Will return: [0,2,4,6,8]
 
     range = case type
       when /^(\.\.|\-)$/ then (start .. stop)
-      when /^(\.\.\.)$/  then (start ... stop) # Exclusive of last element ...
+      when '...'         then (start ... stop) # Exclusive of last element
     end
 
-    result = range.step(step).collect { |i| i } # Get them all ... Pokemon ...
+    result = range.step(step).to_a
 
     return result
   end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/regexpescape.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/regexpescape.rb
new file mode 100644 (file)
index 0000000..2cfa3bb
--- /dev/null
@@ -0,0 +1,29 @@
+#
+#  regexpescape.rb
+#
+module Puppet::Parser::Functions
+  newfunction(:regexpescape, :type => :rvalue, :doc => <<-EOS
+    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
+    raise(Puppet::ParseError, "regexpescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
+
+    value = arguments[0]
+
+    unless value.is_a?(Array) || value.is_a?(String)
+      raise(Puppet::ParseError, 'regexpescape(): Requires either array or string to work with')
+    end
+
+    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 }
+             else
+               Regexp.escape(value)
+             end
+
+    return result
+  end
+end
+
+# vim: set ts=2 sw=2 et :
index 7f1018f..aca98ce 100644 (file)
@@ -8,14 +8,12 @@ Reverses the order of a string or array.
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'reverse(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'reverse(): Requires either array or string to work with')
     end
 
     result = value.reverse
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb
new file mode 100644 (file)
index 0000000..489c301
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# round.rb
+#
+
+module Puppet::Parser::Functions
+  newfunction(:round, :type => :rvalue, :doc => <<-EOS
+  Rounds a number to the nearest integer
+
+  *Examples:*
+
+  round(2.9)
+
+  returns: 3
+
+  round(2.4)
+
+  returns: 2
+
+  EOS
+  ) 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
+
+    value = args[0]
+
+    if value >= 0
+      Integer(value + 0.5)
+    else
+      Integer(value - 0.5)
+    end
+  end
+end
index 0cf8d22..e24abd5 100644 (file)
@@ -8,14 +8,12 @@ Strips leading spaces to the right of the string.
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'rstrip(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'rstrip(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb
new file mode 100644 (file)
index 0000000..44e27b8
--- /dev/null
@@ -0,0 +1,22 @@
+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.
+
+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
+) 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
+
+  max = args[0].to_i
+  seed = Digest::MD5.hexdigest(args[1]).hex
+  Puppet::Util.deterministic_rand(seed,max)
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb
new file mode 100644 (file)
index 0000000..7306b7c
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# 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.
+
+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|
+
+    raise(Puppet::ParseError, "shell_escape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
+
+    # explicit conversion to string is required for ruby 1.9
+    string = arguments[0].to_s
+
+    result = Shellwords.shellescape(string)
+
+    return result
+  end
+end
+
+# vim: set ts=2 sw=2 et :
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb
new file mode 100644 (file)
index 0000000..682ed8d
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# 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.
+
+This function behaves the same as ruby's Shellwords.shelljoin() function
+  EOS
+  ) 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)
+
+    # explicit conversion to string is required for ruby 1.9
+    array = array.map { |item| item.to_s }
+    result = Shellwords.shelljoin(array)
+
+    return result
+  end
+end
+
+# vim: set ts=2 sw=2 et :
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb
new file mode 100644 (file)
index 0000000..09e6e78
--- /dev/null
@@ -0,0 +1,25 @@
+#
+# 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.
+
+This function behaves the same as ruby's Shellwords.shellsplit() function
+  EOS
+  ) do |arguments|
+
+    raise(Puppet::ParseError, "shell_split(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
+
+    string = arguments[0].to_s
+
+    result = Shellwords.shellsplit(string)
+
+    return result
+  end
+end
+
+# vim: set ts=2 sw=2 et :
index 30c663d..942cbce 100644 (file)
@@ -8,14 +8,12 @@ Randomizes the order of a string or array elements.
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'shuffle(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'shuffle(): Requires either array or string to work with')
     end
 
     result = value.clone
index cc207e3..b503aa0 100644 (file)
@@ -2,19 +2,18 @@
 # size.rb
 #
 
-# TODO(Krzysztof Wilczynski): Support for hashes would be nice too ...
-
 module Puppet::Parser::Functions
   newfunction(:size, :type => :rvalue, :doc => <<-EOS
-Returns the number of elements in a string or array.
+Returns the number of elements in a string, an array or a hash
     EOS
   ) 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.size < 1
 
     item = arguments[0]
 
+    function_deprecation([:size, 'This method is going to be deprecated, please use the stdlib length function.'])
+
     if item.is_a?(String)
 
       begin
@@ -28,14 +27,13 @@ Returns the number of elements in a string or array.
         #
         Float(item)
 
-        raise(Puppet::ParseError, 'size(): Requires either ' +
-          'string or array to work with')
+        raise(Puppet::ParseError, 'size(): Requires either string, array or hash to work with')
 
       rescue ArgumentError
         result = item.size
       end
 
-    elsif item.is_a?(Array)
+    elsif item.is_a?(Array) || item.is_a?(Hash)
       result = item.size
     else
       raise(Puppet::ParseError, 'size(): Unknown type given')
index cefbe54..d7792f5 100644 (file)
@@ -1,5 +1,6 @@
 #
-# sort.rb
+#  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
@@ -9,8 +10,7 @@ Sorts strings and arrays lexically.
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "sort(): Wrong number of arguments "+
-        "given #{arguments.size} for 1")
+      raise(Puppet::ParseError, "sort(): Wrong number of arguments given #{arguments.size} for 1")
     end
 
     value = arguments[0]
index 81fadfd..f5757d1 100644 (file)
@@ -9,8 +9,7 @@ Returns a new string where runs of the same character that occur in this set are
   ) do |arguments|
 
     if ((arguments.size != 2) and (arguments.size != 1)) then
-      raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+
-        "given #{arguments.size} for 2 or 1")
+      raise(Puppet::ParseError, "squeeze(): Wrong number of arguments given #{arguments.size} for 2 or 1")
     end
 
     item = arguments[0]
index 446732e..38ad1ce 100644 (file)
@@ -5,13 +5,12 @@
 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, 1, t, true to 'true' and strings that contain things
-like: 0, f, n, false, no to 'false'.
+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|
 
-    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.size < 1
 
     string = arguments[0]
 
@@ -21,8 +20,7 @@ like: 0, f, n, false, no to 'false'.
     end
 
     unless string.is_a?(String)
-      raise(Puppet::ParseError, 'str2bool(): Requires either ' +
-        'string to work with')
+      raise(Puppet::ParseError, 'str2bool(): Requires string to work with')
     end
 
     # We consider all the yes, no, y, n and so on too ...
@@ -32,8 +30,8 @@ like: 0, f, n, false, no to 'false'.
       # We yield false in this case.
       #
       when /^$/, '' then false # Empty string will be false ...
-      when /^(1|t|y|true|yes)$/  then true
-      when /^(0|f|n|false|no)$/  then 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')
index 7fe7b01..0410c62 100644 (file)
@@ -1,5 +1,6 @@
 #
-# str2saltedsha512.rb
+#  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
@@ -12,14 +13,12 @@ manifests as a valid password attribute.
   ) do |arguments|
     require 'digest/sha2'
 
-    raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments " +
-      "passed (#{arguments.size} but we require 1)") if arguments.size != 1
+    raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments passed (#{arguments.size} but we require 1)") if arguments.size != 1
 
     password = arguments[0]
 
     unless password.is_a?(String)
-      raise(Puppet::ParseError, 'str2saltedsha512(): Requires a ' +
-        "String argument, you passed: #{password.class}")
+      raise(Puppet::ParseError, "str2saltedsha512(): Requires a String argument, you passed: #{password.class}")
     end
 
     seedint    = rand(2**31 - 1)
index 0b52ade..deae329 100644 (file)
@@ -1,5 +1,6 @@
 #
-# strftime.rb
+#  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
@@ -71,13 +72,11 @@ To return the date:
   ) 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.size < 1
 
     format = arguments[0]
 
-    raise(Puppet::ParseError, 'strftime(): You must provide ' +
-      'format for evaluation') if format.empty?
+    raise(Puppet::ParseError, 'strftime(): You must provide format for evaluation') if format.empty?
 
     # The Time Zone argument is optional ...
     time_zone = arguments[1] if arguments[1]
index 3fac47d..9e8366f 100644 (file)
@@ -15,14 +15,12 @@ Would result in: "aaa"
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'strip(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'strip(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
index f7792d6..7c5057d 100644 (file)
@@ -4,7 +4,8 @@
 
 module Puppet::Parser::Functions
   newfunction(:suffix, :type => :rvalue, :doc => <<-EOS
-This function applies a suffix to all elements in an array.
+This function applies a suffix to all elements in an array, or to the keys
+in a hash.
 
 *Examples:*
 
@@ -15,13 +16,12 @@ Will return: ['ap','bp','cp']
   ) 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.size < 1
 
-    array = arguments[0]
+    enumerable = arguments[0]
 
-    unless array.is_a?(Array)
-      raise Puppet::ParseError, "suffix(): expected first argument to be an Array, got #{array.inspect}"
+    unless enumerable.is_a?(Array) or enumerable.is_a?(Hash)
+      raise Puppet::ParseError, "suffix(): expected first argument to be an Array or a Hash, got #{enumerable.inspect}"
     end
 
     suffix = arguments[1] if arguments[1]
@@ -32,10 +32,17 @@ Will return: ['ap','bp','cp']
       end
     end
 
-    # Turn everything into string same as join would do ...
-    result = array.collect do |i|
-      i = i.to_s
-      suffix ? i + suffix : i
+    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
 
     return result
index eb7fe13..f3276fb 100644 (file)
@@ -1,5 +1,6 @@
 #
 #  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
@@ -14,14 +15,12 @@ Would result in: "AbCd"
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'swapcase(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'swapcase(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
index 0cddaf8..d7780c8 100644 (file)
@@ -18,8 +18,7 @@ Will return something like: 1311972653
     time_zone = arguments[0] if arguments[0]
 
     if (arguments.size != 0) and (arguments.size != 1) then
-      raise(Puppet::ParseError, "time(): Wrong number of arguments "+
-        "given #{arguments.size} for 0 or 1")
+      raise(Puppet::ParseError, "time(): Wrong number of arguments given #{arguments.size} for 0 or 1")
     end
 
     time = Time.new
@@ -33,13 +32,14 @@ Will return something like: 1311972653
 
       ENV['TZ'] = time_zone
 
-      time = local_time.localtime
+      result = local_time.localtime.strftime('%s')
 
       ENV['TZ'] = original_zone
+    else
+      result = time.localtime.strftime('%s')
     end
 
     # Calling Time#to_i on a receiver changes it.  Trust me I am the Doctor.
-    result = time.strftime('%s')
     result = result.to_i
 
     return result
index df490ea..bf72503 100644 (file)
@@ -7,8 +7,7 @@ module Puppet::Parser::Functions
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " +
-          "given (#{arguments.size} for 1)") if arguments.size != 1
+    raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     arg = arguments[0]
 
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb
new file mode 100644 (file)
index 0000000..fc19a23
--- /dev/null
@@ -0,0 +1,53 @@
+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
+  ) do |args|
+    warning("try_get_value() DEPRECATED: this function is deprecated, please use dig() instead.")
+    data = args[0]
+    path = args[1] || ''
+    default = args[2]
+
+    if !(data.is_a?(Hash) || data.is_a?(Array)) || path == ''
+      return default || data
+    end
+
+    separator = args[3] || '/'
+    path = path.split(separator).map{ |key| key =~ /^\d+$/ ? key.to_i : key }
+    function_dig([data, path, default])
+  end
+end
index 0800b4a..b17380e 100644 (file)
@@ -16,8 +16,7 @@ Returns the type when passed a value. Type can be one of:
 * boolean
     EOS
   ) do |args|
-    raise(Puppet::ParseError, "type3x(): Wrong number of arguments " +
-      "given (#{args.size} for 1)") if args.size < 1
+    raise(Puppet::ParseError, "type3x(): Wrong number of arguments given (#{args.size} for 1)") if args.size < 1
 
     value = args[0]
 
index c91bb80..abe2dc8 100644 (file)
@@ -4,7 +4,7 @@
 
 module Puppet::Parser::Functions
   newfunction(:union, :type => :rvalue, :doc => <<-EOS
-This function returns a union of two arrays.
+This function returns a union of two or more arrays.
 
 *Examples:*
 
@@ -14,20 +14,14 @@ Would return: ["a","b","c","d"]
     EOS
   ) do |arguments|
 
-    # Two arguments are required
-    raise(Puppet::ParseError, "union(): Wrong number of arguments " +
-      "given (#{arguments.size} for 2)") if arguments.size != 2
+    # 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
 
-    first = arguments[0]
-    second = arguments[1]
-
-    unless first.is_a?(Array) && second.is_a?(Array)
-      raise(Puppet::ParseError, 'union(): Requires 2 arrays')
+    arguments.each do |argument|
+      raise(Puppet::ParseError, 'union(): Every parameter must be an array') unless argument.is_a?(Array)
     end
 
-    result = first | second
-
-    return result
+    arguments.reduce(:|)
   end
 end
 
index cf770f3..1e2a895 100644 (file)
@@ -24,14 +24,16 @@ This returns:
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "unique(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
+    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
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'unique(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'unique(): Requires either array or string to work with')
     end
 
     result = value.clone
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb
new file mode 100644 (file)
index 0000000..0bd9cd1
--- /dev/null
@@ -0,0 +1,15 @@
+# Custom Puppet function to convert unix to dos format
+module Puppet::Parser::Functions
+  newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-EOS
+    Returns the DOS version of the given string.
+    Takes a single string argument.
+    EOS
+  ) do |arguments|
+
+    unless arguments[0].is_a?(String)
+      raise(Puppet::ParseError, 'unix2dos(): Requires string as argument')
+    end
+
+    arguments[0].gsub(/\r*\n/, "\r\n")
+  end
+end
index 0226a88..e847e51 100644 (file)
@@ -1,5 +1,6 @@
 #
-# upcase.rb
+#  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
@@ -12,18 +13,16 @@ Converts a string or an array of strings to uppercase.
 
 Will return:
 
-    ASDF
+    ABCD
   EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "upcase(): Wrong number of arguments " +
-                                "given (#{arguments.size} for 1)") if arguments.size != 1
+    raise(Puppet::ParseError, "upcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(Hash) || value.respond_to?(:upcase)
-      raise(Puppet::ParseError, 'upcase(): Requires an ' +
-                                  'array, hash or object that responds to upcase in order to work')
+      raise(Puppet::ParseError, 'upcase(): Requires an array, hash or object that responds to upcase in order to work')
     end
 
     if value.is_a?(Array)
index 45bbed2..4c5c400 100644 (file)
@@ -1,5 +1,6 @@
 #
 #  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'
 
@@ -10,14 +11,12 @@ module Puppet::Parser::Functions
     EOS
   ) 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.size < 1
 
     value = arguments[0]
 
     unless value.is_a?(Array) || value.is_a?(String)
-      raise(Puppet::ParseError, 'uriescape(): Requires either ' +
-        'array or string to work with')
+      raise(Puppet::ParseError, 'uriescape(): Requires either array or string to work with')
     end
 
     if value.is_a?(Array)
index b696680..c73f3df 100644 (file)
@@ -26,6 +26,9 @@ module Puppet::Parser::Functions
 
     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.'])
+
     require 'puppet/util'
 
     unless args.length > 0 then
@@ -40,28 +43,10 @@ module Puppet::Parser::Functions
       unless arg.is_a?(Array) then
         candidates = Array.new(1,arg)
       end
-      # iterate over all pathes within the candidates array
+      # iterate over all paths within the candidates array
       candidates.each do |path|
-        # 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
-          unless Puppet::Util.absolute_path?(path, :posix) or Puppet::Util.absolute_path?(path, :windows)
-            raise Puppet::ParseError, ("#{path.inspect} is not an absolute path.")
-          end
-        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
-          # defaults to the local platform if none is specified.
-          # Escape once for the string literal, and once for the regex.
-          slash = '[\\\\/]'
-          name = '[^\\\\/]+'
-          regexes = {
-            :windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
-            :posix => %r!^/!,
-          }
-          rval = (!!(path =~ regexes[:posix])) || (!!(path =~ regexes[:windows]))
-          rval or raise Puppet::ParseError, ("#{path.inspect} is not an absolute path.")
+        unless function_is_absolute_path([path])
+          raise Puppet::ParseError, ("#{path.inspect} is not an absolute path.")
         end
       end
     end
index 34b5118..3bf3983 100644 (file)
@@ -18,6 +18,8 @@ module Puppet::Parser::Functions
 
     ENDHEREDOC
 
+    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)")
     end
index 4ea4fe0..2196c3e 100644 (file)
@@ -31,7 +31,7 @@ module Puppet::Parser::Functions
 
     ENDHEREDOC
     unless Puppet.features.augeas?
-      raise Puppet::ParseError, ("validate_augeas(): this function requires the augeas feature. See http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas#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
index 59a0805..49075b8 100644 (file)
@@ -19,6 +19,9 @@ module Puppet::Parser::Functions
 
     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.'])
+
     unless args.length > 0 then
       raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)")
     end
index 5df3c60..685162b 100644 (file)
@@ -53,7 +53,7 @@ module Puppet::Parser::Functions
     rescue Puppet::ExecutionFailure => detail
       msg += "\n#{detail}"
       raise Puppet::ParseError, msg
-    rescue Exception => detail
+    rescue StandardError => detail
       msg += "\n#{detail.class.name} #{detail}"
       raise Puppet::ParseError, msg
     ensure
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_domain_name.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_domain_name.rb
new file mode 100644 (file)
index 0000000..c3fad78
--- /dev/null
@@ -0,0 +1,39 @@
+module Puppet::Parser::Functions
+  newfunction(:validate_domain_name, :doc => <<-ENDHEREDOC
+    Validate that all values passed are syntactically correct domain names.
+    Fail compilation if any value fails this check.
+
+    The following values will pass:
+
+        $my_domain_name = 'server.domain.tld'
+        validate_domain_name($my_domain_name)
+        validate_domain_name('domain.tld', 'puppet.com', $my_domain_name)
+
+    The following values will fail, causing compilation to abort:
+
+        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')
+
+    ENDHEREDOC
+  ) do |args|
+
+    rescuable_exceptions = [ArgumentError]
+
+    if args.empty?
+      raise Puppet::ParseError, "validate_domain_name(): wrong number of arguments (#{args.length}; must be > 0)"
+    end
+
+    args.each do |arg|
+      raise Puppet::ParseError, "#{arg.inspect} is not a string." unless arg.is_a?(String)
+
+      begin
+        raise Puppet::ParseError, "#{arg.inspect} is not a syntactically correct domain name" unless function_is_domain_name([arg])
+      rescue *rescuable_exceptions
+        raise Puppet::ParseError, "#{arg.inspect} is not a syntactically correct domain name"
+      end
+    end
+  end
+end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb
new file mode 100644 (file)
index 0000000..ddd0d25
--- /dev/null
@@ -0,0 +1,31 @@
+module Puppet::Parser::Functions
+  newfunction(:validate_email_address, :doc => <<-ENDHEREDOC
+    Validate that all values passed are valid email addresses.
+    Fail compilation if any value fails this check.
+    The following values will pass:
+    $my_email = "waldo@gmail.com"
+    validate_email_address($my_email)
+    validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email)
+
+    The following values will fail, causing compilation to abort:
+    $some_array = [ 'bad_email@/d/efdf.com' ]
+    validate_email_address($some_array)
+    ENDHEREDOC
+             ) do |args|
+    rescuable_exceptions = [ArgumentError]
+
+    if args.empty?
+      raise Puppet::ParseError, "validate_email_address(): wrong number of arguments (#{args.length}; must be > 0)"
+    end
+
+    args.each do |arg|
+      raise Puppet::ParseError, "#{arg.inspect} is not a string." unless arg.is_a?(String)
+
+      begin
+        raise Puppet::ParseError, "#{arg.inspect} is not a valid email address" unless function_is_email_address([arg])
+      rescue *rescuable_exceptions
+        raise Puppet::ParseError, "#{arg.inspect} is not a valid email address"
+      end
+    end
+  end
+end
index 9bdd543..fcdc7e1 100644 (file)
@@ -18,6 +18,8 @@ module Puppet::Parser::Functions
 
     ENDHEREDOC
 
+    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)")
     end
index 995f8db..2ae0293 100644 (file)
@@ -2,7 +2,7 @@ module Puppet::Parser::Functions
 
   newfunction(:validate_integer, :doc => <<-'ENDHEREDOC') 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.
 
     The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
@@ -49,10 +49,12 @@ module Puppet::Parser::Functions
 
     Plus all of the above, but any combination of values passed as strings ('false' or "false").
     Plus all of the above, but with incorrect combinations of negative integer values.
-    Plus all of the above, but with non-integer crap in arrays or maximum / minimum argument.
+    Plus all of the above, but with non-integer items in arrays or maximum / minimum argument.
 
     ENDHEREDOC
 
+    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
 
@@ -109,6 +111,7 @@ module Puppet::Parser::Functions
       # check every element of the array
       input.each_with_index do |arg, pos|
         begin
+          raise TypeError if arg.is_a?(Hash)
           arg = Integer(arg.to_s)
           validator.call(arg)
         rescue TypeError, ArgumentError
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb
new file mode 100644 (file)
index 0000000..5d80cfb
--- /dev/null
@@ -0,0 +1,52 @@
+module Puppet::Parser::Functions
+
+  newfunction(:validate_ip_address, :doc => <<-ENDHEREDOC
+    Validate that all values passed are valid IP addresses,
+    regardless they are IPv4 or IPv6
+    Fail compilation if any value fails this check.
+    The following values will pass:
+    $my_ip = "1.2.3.4"
+    validate_ip_address($my_ip)
+    validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip)
+
+    $my_ip = "3ffe:505:2"
+    validate_ip_address(1)
+    validate_ip_address($my_ip)
+    validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip)
+
+    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|
+
+    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.'])
+
+    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)")
+    end
+
+    args.each do |arg|
+      unless arg.is_a?(String)
+        raise Puppet::ParseError, "#{arg.inspect} is not a string."
+      end
+
+      begin
+        unless IPAddr.new(arg).ipv4? or 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 fc02748..0660abd 100644 (file)
@@ -8,7 +8,7 @@ module Puppet::Parser::Functions
 
     $my_ip = "1.2.3.4"
     validate_ipv4_address($my_ip)
-    validate_bool("8.8.8.8", "172.16.0.1", $my_ip)
+    validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip)
 
     The following values will fail, causing compilation to abort:
 
@@ -18,6 +18,8 @@ module Puppet::Parser::Functions
     ENDHEREDOC
   ) 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.'])
+
     require "ipaddr"
     rescuable_exceptions = [ ArgumentError ]
 
index b0f2558..f5dd9e5 100644 (file)
@@ -19,6 +19,8 @@ module Puppet::Parser::Functions
     ENDHEREDOC
   ) 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.'])
+
     require "ipaddr"
     rescuable_exceptions = [ ArgumentError ]
 
index d2e4d16..4205b30 100644 (file)
@@ -2,7 +2,7 @@ module Puppet::Parser::Functions
 
   newfunction(:validate_numeric, :doc => <<-'ENDHEREDOC') 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.
 
     The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
@@ -15,6 +15,8 @@ module Puppet::Parser::Functions
 
     ENDHEREDOC
 
+    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
 
@@ -71,6 +73,7 @@ module Puppet::Parser::Functions
       # check every element of the array
       input.each_with_index do |arg, pos|
         begin
+          raise TypeError if arg.is_a?(Hash)
           arg = Float(arg.to_s)
           validator.call(arg)
         rescue TypeError, ArgumentError
index ca25a70..0ac83dd 100644 (file)
@@ -23,16 +23,26 @@ module Puppet::Parser::Functions
 
         validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
 
+    Note: Compilation will also abort, if the first argument is not a String. Always use
+    quotes to force stringification:
+
+        validate_re("${::operatingsystemmajrelease}", '^[57]$')
+
     ENDHEREDOC
+
+    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
-      raise Puppet::ParseError, ("validate_re(): wrong number of arguments (#{args.length}; must be 2 or 3)")
+      raise Puppet::ParseError, "validate_re(): wrong number of arguments (#{args.length}; must be 2 or 3)"
     end
 
+    raise Puppet::ParseError, "validate_re(): input needs to be a String, not a #{args[0].class}" unless args[0].is_a? String
+
     msg = args[2] || "validate_re(): #{args[0].inspect} does not match #{args[1].inspect}"
 
     # We're using a flattened array here because we can't call String#any? in
     # Ruby 1.9 like we can in Ruby 1.8
-    raise Puppet::ParseError, (msg) unless [args[1]].flatten.any? do |re_str|
+    raise Puppet::ParseError, msg unless [args[1]].flatten.any? do |re_str|
       args[0] =~ Regexp.compile(re_str)
     end
 
index 7d534f3..383855c 100644 (file)
@@ -3,7 +3,7 @@ module Puppet::Parser::Functions
   newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') 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
+    parameter can be given the minimum length. It fails if the first
     argument is not a string or array of strings, and if arg 2 and arg 3 are
     not convertable to a number.
 
@@ -21,6 +21,8 @@ module Puppet::Parser::Functions
 
     ENDHEREDOC
 
+    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
 
     input, max_length, min_length = *args
@@ -43,9 +45,7 @@ module Puppet::Parser::Functions
       min_length = 0
     end
 
-    if min_length > max_length
-      raise Puppet::ParseError, "validate_slength(): Expected second argument to be larger than third argument"
-    end
+    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
index c841f6a..6675d86 100644 (file)
@@ -13,22 +13,25 @@ module Puppet::Parser::Functions
 
         validate_string(true)
         validate_string([ 'some', 'array' ])
-        
+
     Note: validate_string(undef) will not fail in this version of the
     functions API (incl. current and future parser). Instead, use:
-    
+
         if $var == undef {
           fail('...')
         }
-    
+
     ENDHEREDOC
 
+    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)")
     end
 
     args.each do |arg|
-      unless arg.is_a?(String)
+      # 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}")
       end
     end
diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb
new file mode 100644 (file)
index 0000000..fc9f23f
--- /dev/null
@@ -0,0 +1,47 @@
+module Puppet::Parser::Functions
+
+  newfunction(:validate_x509_rsa_key_pair, :doc => <<-ENDHEREDOC
+    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.
+
+    Fail compilation if any value fails this check.
+
+    validate_x509_rsa_key_pair($cert, $key)
+
+    ENDHEREDOC
+  ) do |args|
+
+    require 'openssl'
+
+    NUM_ARGS = 2 unless defined? NUM_ARGS
+
+    unless args.length == NUM_ARGS then
+      raise Puppet::ParseError,
+        ("validate_x509_rsa_key_pair(): wrong number of arguments (#{args.length}; must be #{NUM_ARGS})")
+    end
+
+    args.each do |arg|
+      unless arg.is_a?(String)
+        raise Puppet::ParseError, "#{arg.inspect} is not a string."
+      end
+    end
+
+    begin
+      cert = OpenSSL::X509::Certificate.new(args[0])
+    rescue OpenSSL::X509::CertificateError => e
+      raise Puppet::ParseError, "Not a valid x509 certificate: #{e}"
+    end
+
+    begin
+      key = OpenSSL::PKey::RSA.new(args[1])
+    rescue OpenSSL::PKey::RSAError => e
+      raise Puppet::ParseError, "Not a valid RSA key: #{e}"
+    end
+
+    unless cert.verify(key)
+      raise Puppet::ParseError, "Certificate signature does not match supplied key"
+    end
+  end
+
+end
index 1606756..0ca236c 100644 (file)
@@ -21,8 +21,7 @@ This example would return:
     EOS
   ) 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.size < 1
 
     hash = arguments[0]
 
index f350f53..04a3d1a 100644 (file)
@@ -29,8 +29,7 @@ Would return ['a','c','d'].
     EOS
   ) do |arguments|
 
-    raise(Puppet::ParseError, "values_at(): Wrong number of " +
-      "arguments given (#{arguments.size} for 2)") if arguments.size < 2
+    raise(Puppet::ParseError, "values_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
 
     array = arguments.shift
 
@@ -41,8 +40,7 @@ Would return ['a','c','d'].
     indices = [arguments.shift].flatten() # Get them all ... Pokemon ...
 
     if not indices or indices.empty?
-      raise(Puppet::ParseError, 'values_at(): You must provide ' +
-        'at least one positive index to collect')
+      raise(Puppet::ParseError, 'values_at(): You must provide at least one positive index to collect')
     end
 
     result       = []
@@ -57,11 +55,9 @@ Would return ['a','c','d'].
         type = m[2]
 
         if start > stop
-          raise(Puppet::ParseError, 'values_at(): Stop index in ' +
-            'given indices range is smaller than the start index')
+          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')
+          raise(Puppet::ParseError, 'values_at(): Stop index in given indices range exceeds array size')
         end
 
         range = case type
@@ -73,16 +69,14 @@ Would return ['a','c','d'].
       else
         # Only positive numbers allowed in this case ...
         if not i.match(/^\d+$/)
-          raise(Puppet::ParseError, 'values_at(): Unknown format ' +
-            'of given index')
+          raise(Puppet::ParseError, 'values_at(): Unknown format of given index')
         end
 
         # In Puppet numbers are often string-encoded ...
         i = i.to_i
 
         if i > array.size - 1 # Same story.  First element is at index 0 ...
-          raise(Puppet::ParseError, 'values_at(): Given index ' +
-            'exceeds array size')
+          raise(Puppet::ParseError, 'values_at(): Given index exceeds array size')
         end
 
         indices_list << i
index 3074f28..13e24b6 100644 (file)
@@ -17,8 +17,7 @@ Would result in:
   ) 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
+    raise(Puppet::ParseError, "zip(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
 
     a = arguments[0]
     b = arguments[1]
index e7854f0..16f2709 100644 (file)
@@ -1,53 +1,92 @@
 Puppet::Type.type(:file_line).provide(:ruby) do
   def exists?
-    lines.find do |line|
-      line.chomp == resource[:line].chomp
+    found = false
+    lines_count = 0
+    lines.each do |line|
+      found = line.chomp == resource[:line]
+      if found
+        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
   end
 
   def create
-    if resource[:match]
-      handle_create_with_match
-    elsif resource[:after]
-      handle_create_with_after
-    else
-      append_line
+    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
     end
   end
 
   def destroy
-    local_lines = lines
-    File.open(resource[:path],'w') do |fh|
-      fh.write(local_lines.reject{|l| l.chomp == resource[:line] }.join(''))
+    if resource[:match_for_absence].to_s == 'true' && resource[:match]
+      handle_destroy_with_match
+    else
+      handle_destroy_line
     end
   end
 
   private
+
   def lines
     # If this type is ever used with very large files, we should
     #  write this in a different way, using a temp
     #  file; for now assuming that this type is only used on
     #  small-ish config files that can fit into memory without
     #  too much trouble.
-    @lines ||= File.readlines(resource[:path])
+    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
+  end
+
+  def new_after_regex
+    resource[:after] ? Regexp.new(resource[:after]) : nil
+  end
+
+  def new_match_regex
+    resource[:match] ? Regexp.new(resource[:match]) : nil
+  end
+
+  def count_matches(regex)
+    lines.select{ |line| line.match(regex) }.size
   end
 
   def handle_create_with_match()
-    regex = resource[:match] ? Regexp.new(resource[:match]) : nil
-    regex_after = resource[:after] ? Regexp.new(resource[:after]) : nil
-    match_count = count_matches(regex)
+    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]}'"
     end
 
     File.open(resource[:path], 'w') do |fh|
-      lines.each do |l|
-        fh.puts(regex.match(l) ? resource[:line] : l)
-        if (match_count == 0 and regex_after)
-          if regex_after.match(l)
+      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.
+            match_count += 1 # Increment match_count to indicate that the new line has been inserted.
           end
         end
       end
@@ -59,39 +98,53 @@ Puppet::Type.type(:file_line).provide(:ruby) do
   end
 
   def handle_create_with_after
-    regex = Regexp.new(resource[:after])
-    count = count_matches(regex)
-    case count
-    when 1 # find the line to put our line after
-      File.open(resource[:path], 'w') do |fh|
-        lines.each do |l|
-          fh.puts(l)
-          if regex.match(l) then
-            fh.puts(resource[:line])
-          end
+    after_regex = new_after_regex
+    after_count = count_matches(after_regex)
+
+    if after_count > 1 && resource[:multiple].to_s != 'true'
+      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|
+      lines.each do |line|
+        fh.puts(line)
+        if after_regex.match(line)
+          fh.puts(resource[:line])
         end
       end
-    when 0 # append the line to the end of the file
-      append_line
-    else
-      raise Puppet::Error, "#{count} lines match pattern '#{resource[:after]}' in file '#{resource[:path]}'.  One or no line must match the pattern."
+
+      if (after_count == 0)
+        fh.puts(resource[:line])
+      end
     end
   end
 
-  def count_matches(regex)
-    lines.select{|l| l.match(regex)}.size
+  def handle_destroy_with_match
+    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]}'"
+    end
+
+    local_lines = lines
+    File.open(resource[:path],'w') do |fh|
+      fh.write(local_lines.reject{ |line| match_regex.match(line) }.join(''))
+    end
   end
 
-  ##
-  # append the line to the file.
-  #
-  # @api private
-  def append_line
-    File.open(resource[:path], 'w') do |fh|
-      lines.each do |l|
-        fh.puts(l)
+  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(''))
+    end
+  end
+
+  def handle_append_line
+    File.open(resource[:path],'w') do |fh|
+      lines.each do |line|
+        fh.puts(line)
       end
-      fh.puts resource[:line]
+      fh.puts(resource[:line])
     end
   end
 end
index 29f9538..b2357b8 100644 (file)
@@ -4,7 +4,7 @@ Puppet::Type.newtype(:file_line) do
     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
-    the end of the file to ensure the desired state.  Multiple resources may 
+    the end of the file to ensure the desired state.  Multiple resources may
     be declared to manage multiple lines in the same file.
 
     Example:
@@ -31,12 +31,41 @@ Puppet::Type.newtype(:file_line) do
           match  => '^export\ HTTP_PROXY\=',
         }
 
-    In this code example match will look for a line beginning with export 
+    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`:
+
+        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 this code example match will look for a line beginning with export
+    followed by HTTP_PROXY and delete it.  If multiple lines match, an
+    error will be raised unless the `multiple => true` parameter is set.
+
+    Encoding example:
+
+        file_line { "XScreenSaver":
+          ensure   => present,
+          path     => '/root/XScreenSaver'
+          line     => "*lock: 10:00:00",
+          match    => '^*lock:',
+          encoding => "iso-8859-1",
+        }
+
+    Files with special characters that are not valid UTF-8 will give the
+    error message "invalid byte sequence in UTF-8".  In this case, determine
+    the correct file encoding and specify the correct encoding using the
+    encoding attribute, the value of which needs to be a valid Ruby character
+    encoding.
+
     **Autorequires:** If Puppet is managing the file that will contain the line
     being managed, the file_line resource will autorequire that file.
-
   EOT
 
   ensurable do
@@ -49,10 +78,19 @@ Puppet::Type.newtype(:file_line) do
   end
 
   newparam(:match) do
-    desc 'An optional ruby regular expression to run against existing lines in the file.' + 
+    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 comparisson is performed against the line value and if it does not' +
-         ' match an exception will be raised. '
+         ' 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.' +
+         ' When `ensure => present`, match_for_absence is ignored.'
+    newvalues(true, false)
+    defaultto false
   end
 
   newparam(:multiple) do
@@ -62,30 +100,61 @@ Puppet::Type.newtype(:file_line) do
   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
 
-  newparam(:line) do
+  # The line property never changes; the type only ever performs a create() or
+  # destroy(). line is a property in order to allow it to correctly handle
+  # Sensitive type values. Because it is a property which will never change,
+  # it should never be considered out of sync.
+  newproperty(:line) do
     desc 'The line to be appended to the file or used to replace matches found by the match attribute.'
+
+    def retrieve
+      @resource[:line]
+    end
   end
 
   newparam(:path) do
     desc 'The file Puppet will ensure contains the line specified by the line parameter.'
     validate do |value|
-      unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
-        raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'")
+      unless Puppet::Util.absolute_path?(value)
+        raise Puppet::Error, "File paths must be fully qualified, not '#{value}'"
       end
     end
   end
 
+  newparam(:replace) do
+    desc 'If true, replace line that matches. If false, do not write line if a match is found'
+    newvalues(true, false)
+    defaultto true
+  end
+
+  newparam(:encoding) do
+    desc 'For files that are not UTF-8 encoded, specify encoding such as iso-8859-1'
+    defaultto 'UTF-8'
+  end
+
+  newparam(:append_on_no_match) do
+    desc 'If true, append line if match is not found. If false, do not append line if a match is not found'
+    newvalues(true, false)
+    defaultto true
+  end
+
   # Autorequire the file resource if it's being managed
   autorequire(:file) do
     self[:path]
   end
 
   validate do
-    unless self[:line] and self[:path]
-      raise(Puppet::Error, "Both line and path are required attributes")
+    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")
+      end
+    end
+    unless self[:path]
+      raise(Puppet::Error, "path is a required attribute")
     end
   end
 end
diff --git a/3rdparty/modules/stdlib/locales/config.yaml b/3rdparty/modules/stdlib/locales/config.yaml
new file mode 100644 (file)
index 0000000..1ee70ab
--- /dev/null
@@ -0,0 +1,25 @@
+---
+# This is the project-specific configuration file for setting up
+# fast_gettext for your project.
+gettext:
+  # This is used for the name of the .pot and .po files; they will be
+  # called <project_name>.pot?
+  project_name: puppetlabs-stdlib
+  # This is used in comments in the .pot and .po files to indicate what
+  # project the files belong to and should bea little more desctiptive than
+  # <project_name>
+  package_name: puppetlabs-stdlib
+  # The locale that the default messages in the .pot file are in
+  default_locale: en
+  # The email used for sending bug reports.
+  bugs_address: docs@puppet.com
+  # The holder of the copyright.
+  copyright_holder: Puppet, Inc.
+  # This determines which comments in code should be eligible for translation.
+  # Any comments that start with this string will be externalized. (Leave
+  # empty to include all.)
+  comments_tag: TRANSLATOR
+  # Patterns for +Dir.glob+ used to find all files that might contain
+  # translatable content, relative to the project root directory
+  source_files:
+  
diff --git a/3rdparty/modules/stdlib/locales/ja/puppetlabs-stdlib.po b/3rdparty/modules/stdlib/locales/ja/puppetlabs-stdlib.po
new file mode 100644 (file)
index 0000000..c154c2f
--- /dev/null
@@ -0,0 +1,26 @@
+# 
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-03-21 14:19+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: 梅田智世 <c-umeda@nifty.com>, 2017\n"
+"Language-Team: Japanese (Japan) (https://www.transifex.com/puppet/teams/29089/ja_JP/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: ja_JP\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Generator: Translate Toolkit 2.0.0\n"
+
+#. metadata.json
+#: .summary
+msgid "Standard library of resources for Puppet modules."
+msgstr "Puppet モジュールのリソースの標準ライブラリ"
+
+#. metadata.json
+#: .description
+msgid "Standard Library for Puppet Modules"
+msgstr "Puppet モジュールの標準ライブラリ"
diff --git a/3rdparty/modules/stdlib/locales/puppetlabs-stdlib.pot b/3rdparty/modules/stdlib/locales/puppetlabs-stdlib.pot
new file mode 100644 (file)
index 0000000..2608675
--- /dev/null
@@ -0,0 +1,23 @@
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-03-21 14:19+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Translate Toolkit 2.0.0\n"
+
+#. metadata.json
+#: .summary
+msgid "Standard library of resources for Puppet modules."
+msgstr ""
+
+#. metadata.json
+#: .description
+msgid "Standard Library for Puppet Modules"
+msgstr ""
index 500ad77..9ea22a7 100644 (file)
@@ -14,7 +14,5 @@
 # Requires: nothing
 #
 class stdlib {
-
-  class { 'stdlib::stages': }
-
+  include ::stdlib::stages
 }
index eb15fd6..7de254c 100644 (file)
@@ -26,7 +26,7 @@
 # Sample Usage:
 #
 #  node default {
-#    include stdlib
+#    include ::stdlib
 #    class { java: stage => 'runtime' }
 #  }
 #
index 51b73f7..0526272 100644 (file)
@@ -1,12 +1,16 @@
 {
   "name": "puppetlabs-stdlib",
-  "version": "4.6.0",
+  "version": "4.19.0",
   "author": "puppetlabs",
   "summary": "Standard library of resources for Puppet modules.",
   "license": "Apache-2.0",
   "source": "https://github.com/puppetlabs/puppetlabs-stdlib",
   "project_page": "https://github.com/puppetlabs/puppetlabs-stdlib",
   "issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
+  "dependencies": [
+  
+  ],
+  "data_provider": null,
   "operatingsystem_support": [
     {
       "operatingsystem": "RedHat",
       "operatingsystem": "Debian",
       "operatingsystemrelease": [
         "6",
-        "7"
+        "7",
+        "8"
       ]
     },
     {
       "operatingsystem": "Ubuntu",
       "operatingsystemrelease": [
-        "10.04",
-        "12.04",
-        "14.04"
+        "14.04",
+        "16.04"
       ]
     },
     {
     }
   ],
   "requirements": [
-    {
-      "name": "pe",
-      "version_requirement": "3.x"
-    },
     {
       "name": "puppet",
-      "version_requirement": ">=2.7.20 <4.0.0"
+      "version_requirement": ">=2.7.20 < 6.0.0"
     }
   ],
-  "description": "Standard Library for Puppet Modules",
-  "dependencies": [
-  
-  ]
+  "description": "Standard Library for Puppet Modules"
 }
diff --git a/3rdparty/modules/stdlib/readmes/README_ja_JP.md b/3rdparty/modules/stdlib/readmes/README_ja_JP.md
new file mode 100644 (file)
index 0000000..ae74d25
--- /dev/null
@@ -0,0 +1,2357 @@
+# stdlib
+
+#### 目次
+
+1. [モジュールの説明 - モジュールの機能とその有益性](#モジュールの説明)
+1. [セットアップ - stdlib導入の基本](#セットアップ)
+1. [使用 - 設定オプションと追加機能](#使用)
+1. [リファレンス - モジュールの機能と動作について](#リファレンス)
+    1. [クラス](#クラス)
+    1. [定義タイプ](#定義タイプ)
+    1. [データタイプ](#データタイプ)
+    1. [Facts](#facts)
+    1. [関数](#関数)
+1. [制約 - OS互換性など](#制約)
+1. [開発 - モジュール貢献についてのガイド](#開発)
+1. [コントリビュータ](#コントリビュータ)
+
+
+## モジュールの説明
+
+このモジュールでは、Puppetモジュールのリソースの 標準ライブラリを提供しています。Puppetモジュールでは、この標準ライブラリを広く使用しています。stdlibモジュールは、以下のリソースをPuppetに追加します。
+
+ * ステージ
+ * Facts
+ * 関数
+ * 定義タイプ
+ * データタイプ
+ * プロバイダ
+
+> *注:* バージョン3.7のPuppet Enterpriseには、stdlibモジュールが含まれていません。Puppet Enterpriseを使用している場合は、Puppetと互換性のあるstdlibの最新リリースをインストールする必要があります。
+
+## セットアップ
+
+stdlibモジュールを[インストール](https://docs.puppet.com/puppet/latest/modules_installing.html)し、この標準ライブラリの関数、Facts、リソースをPuppetに追加します。
+
+stdlibに依存するモジュールを記述する場合は、必ずmetadata.jsonで[依存関係を特定](https://docs.puppet.com/puppet/latest/modules_metadata.html#specifying-dependencies)してください。
+
+## 使用
+
+stdlibのほとんどの機能は、Puppetに自動的にロードされます。Puppetで標準化されたランステージを使用するには、`include stdlib`を用いてマニフェスト内でこのクラスを宣言してください。
+
+宣言すると、stdlibがモジュール内の他のすべてのクラスを宣言します。現在モジュールに含まれている他のクラスは、`stdlib::stages`のみです。
+
+`stdlib::stages`クラスは、インフラストラクチャ、言語ランタイム、アプリケーションレイヤの配備に関する各種のランステージを宣言します。ハイレベルステージは、以下のとおりです(順番どおり)。
+
+  * setup
+  * main
+  * runtime
+  * setup_infra
+  * deploy_infra
+  * setup_app
+  * deploy_app
+  * deploy
+
+使用例:
+
+```puppet
+node default {
+  include stdlib
+  class { java: stage => 'runtime' }
+}
+```
+
+## リファレンス
+
+* [パブリッククラス][]
+* [プライベートクラス][]
+* [定義タイプ][]
+* [データタイプ][]
+* [Facts][]
+* [関数][]
+
+### クラス
+
+#### パブリッククラス
+
+`stdlib`クラスにはパラメータはありません。
+
+#### プライベートクラス
+
+* `stdlib::stages`: Puppetのランステージの標準セットを管理します。
+
+### 定義タイプ
+
+#### `file_line`
+
+任意の行がファイル内に確実に含まれるようにします。最初と最後の空白を含め、行全体をマッチさせます。その行が与えられたファイルに含まれない場合は、Puppetがファイルの最後にその行を追加し、望ましい状態を確保します。1つのファイル内で複数のリソースを宣言し、複数の行を管理することが可能です。
+
+例:
+
+```puppet
+file_line { 'sudo_rule':
+  path => '/etc/sudoers',
+  line => '%sudo ALL=(ALL) ALL',
+}
+
+file_line { 'sudo_rule_nopw':
+  path => '/etc/sudoers',
+  line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
+}
+```
+
+上の例では、指定された両方の行が、ファイル `/etc/sudoers`に確実に含まれます。
+
+マッチ例:
+
+```puppet
+file_line { 'bashrc_proxy':
+  ensure => present,
+  path   => '/etc/bashrc',
+  line   => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+  match  => '^export\ HTTP_PROXY\=',
+}
+```
+
+上の例では、`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が行内の値に置き換えられます。
+
+ `ensure => absent`を用いたマッチ例:
+
+```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`パラメータが設定されていない場合は、エラーが生じます。
+
+エンコード例:
+
+```puppet
+file_line { "XScreenSaver":
+  ensure   => present,
+  path     => '/root/XScreenSaver'
+  line     => "*lock: 10:00:00",
+  match    => '^*lock:',
+  encoding => "iso-8859-1",
+}
+```
+
+ファイルにUTF-8に対応しない特殊文字が用いられていると、「Invalid byte sequence in UTF-8」(UTF-8で無効なバイト列)というエラーメッセージが表示されます。この場合は、ファイルエンコーディングを決定し、`encoding`属性で指定してください。
+
+**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`
+
+### データタイプ
+
+#### `Stdlib::Absolutepath`
+
+厳密な絶対パスタイプ。UnixpathタイプおよびWindowspathタイプの異形を使用します。
+
+使用可能なインプット例:
+
+```shell
+/var/log
+```
+
+```shell
+/usr2/username/bin:/usr/local/bin:/usr/bin:.
+```
+
+```shell
+C:\\WINDOWS\\System32
+```
+
+使用不可能なインプット例:
+
+```shell
+../relative_path
+```
+
+#### `Stdlib::Httpsurl`
+
+HTTPS URLに一致します。
+
+使用可能なインプット例:
+
+```shell
+https://hello.com
+```
+
+使用不可能なインプット例:
+
+```shell
+httds://notquiteright.org`
+```
+
+#### `Stdlib::Httpurl`
+
+HTTPSおよびHTTP URLの両方に一致します。
+
+使用可能なインプット例:
+
+```shell
+https://hello.com
+
+http://hello.com
+```
+
+使用不可能なインプット例:
+
+```shell
+httds://notquiteright.org
+```
+
+#### `Stdlib::Unixpath`
+
+Unixオペレーティングシステムのパスに一致します。
+
+使用可能なインプット例:
+
+```shell
+/usr2/username/bin:/usr/local/bin:/usr/bin:
+
+/var/tmp
+```
+
+使用不可能なインプット例:
+
+```shell
+C:/whatever
+```
+
+#### `Stdlib::Windowspath`
+
+Windowsオペレーティングシステムのパスに一致します。
+
+使用可能なインプット例: 
+
+```shell
+C:\\WINDOWS\\System32
+
+C:\\
+
+\\\\host\\windows
+```
+
+使用不可能なインプット例:
+
+```shell
+/usr2/username/bin:/usr/local/bin:/usr/bin:.
+```
+
+### Facts
+
+#### `package_provider`
+
+Puppetがこのシステムのパッケージ管理に使用するデフォルトのプロバイダを返します。
+
+#### `is_pe`
+
+Puppet Enterpriseがインストールされているかどうかを返します。PE 3.x以降のプラットフォームでは何も報告されません。
+
+#### `pe_version`
+
+インストールされているPuppet Enterpriseのバージョンを返します。PE 3.x以降のプラットフォームでは何も報告されません。
+
+#### `pe_major_version`
+
+インストールされているPuppet Enterpriseのメジャーバージョンを返します。PE 3.x以降のプラットフォームでは何も報告されません。
+
+#### `pe_minor_version`
+
+インストールされているPuppet Enterpriseのマイナーバージョンを返します。PE 3.x以降のプラットフォームでは何も報告されません。
+
+#### `pe_patch_version`
+
+インストールされているPuppet Enterpriseのパッチバージョンを返します。
+
+#### `puppet_vardir`
+
+PuppetまたはPuppet agentが稼働しているノードについて設定されたPuppet vardirの値を返します。
+
+#### `puppet_environmentpath`
+
+PuppetまたはPuppet agentが稼働しているノードについて設定されたPuppet環境の値を返します。
+
+#### `puppet_server`
+
+Puppet agentの`server`値を返します。この値は、agentが通信するPuppet masterのホストネームです。
+
+#### `root_home`
+
+ルートのホームディレクトリを決定します。
+
+ルートのホームディレクトリを決定します。これは、オペレーティングシステムによって異なります。通常は'/root'です。
+
+#### `service_provider`
+
+Puppetがこのシステムのサービス管理に使用するデフォルトのプロバイダを返します。
+
+### 関数
+
+#### `abs`
+
+数字の絶対値を返します。たとえば、'-34.56'は'34.56'になります。
+
+引数: 整数値または浮動小数点値のいずれかの単一の引数。
+
+*タイプ*: 右辺値
+
+#### `any2array`
+
+任意のオブジェクトを、そのオブジェクトを含む配列に変換します。空の引数リストは空の配列に変換されます。ハッシュは、キーと値が交互になった配列に変換されます。配列は変換されません。
+
+*タイプ*: 右辺値
+
+#### `any2bool`
+
+任意のオブジェクトをブーリアンに変換します。
+
+* 'Y'、'y'、'1'、'T'、't'、'TRUE'、'yes'、'true'といった文字列は`true`を返します。
+* '0'、'F'、'f'、'N'、'n'、'FALSE'、'no'、'false'といった文字列は`false`を返します。
+* ブーリアンは元の値を返します。
+* 0よりも大きい数字(または数字の文字列表現)は`true`を返します。それ以外は`false`を返します。
+* undef値は`false`を返します。
+* それ以外はすべて`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `assert_private`
+
+現在のクラスまたは定義をプライベートとして設定します。現在のモジュール外のクラスまたは定義タイプを呼び出すことはできません。
+
+たとえば、クラス`foo::bar`で`assert_private()`がコールされると、クラスがモジュール`foo`の外から呼び出された場合、次のメッセージがアウトプットされます:`Class foo::bar is private`。
+
+使用したいエラーメッセージを指定する方法:
+
+```puppet
+assert_private("You're not supposed to do that!")
+```
+
+*タイプ*: ステートメント
+
+#### `base64`
+
+文字列とbase64エンコードを相互に変換します。`action` ('encode'、'decode')とプレーンまたは base64でエンコードした`string`、およびオプションで`method` ('default'、'strict'、'urlsafe')が必要です。
+
+下位互換性を得るには、`method`を`default`に設定します(指定されていない場合)。
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+**例:**
+
+```puppet
+base64('encode', 'hello')
+base64('encode', 'hello', 'default')
+# リターン: "aGVsbG8=\n"
+
+base64('encode', 'hello', 'strict')
+# リターン: "aGVsbG8="
+
+base64('decode', 'aGVsbG8=')
+base64('decode', 'aGVsbG8=\n')
+base64('decode', 'aGVsbG8=', 'default')
+base64('decode', 'aGVsbG8=\n', 'default')
+base64('decode', 'aGVsbG8=', 'strict')
+# リターン: "hello"
+
+base64('encode', 'https://puppetlabs.com', 'urlsafe')
+# リターン: "aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ=="
+
+base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe')
+# リターン: "https://puppetlabs.com"
+```
+
+*タイプ*: 右辺値
+
+#### `basename`
+
+パスの`basename`を返します。オプションの引数で拡張子が外れます。例:
+
+  * ('/path/to/a/file.ext')は'file.ext'を返します。
+  * ('relative/path/file.ext')は'file.ext'を返します。
+  * ('/path/to/a/file.ext', '.ext')は'file'を返します。
+
+*タイプ*: 右辺値
+
+#### `bool2num`
+
+ブーリアンを数字に変換します。以下の値を変換します。
+
+* `false`、'f'、'0'、'n'、'no'を0に変換します。
+* `true`、't'、'1'、'y'、'yes'を1に変換します。
+  
+  引数: インプットとして、単一のブーリアンまたは文字列。
+  
+  *タイプ*: 右辺値
+
+#### `bool2str`
+
+オプションで提供される引数を用いて、ブーリアンを文字列に変換します。オプションの第2および第3の引数は、trueおよびfalseがそれぞれ何に変換されるかを表しています。与えられた引数が1つだけの場合は、ブーリアンから`true`または`false`を含む文字列に変換されます。
+
+*例:*
+
+```puppet
+bool2str(true)                    => `true`
+bool2str(true, 'yes', 'no')       => 'yes'
+bool2str(false, 't', 'f')         => 'f'
+```
+
+引数: ブーリアン。
+
+*タイプ*: 右辺値
+
+#### `camelcase`
+
+配列内の1つの文字列またはすべての文字列の大文字と小文字の別をCamelCase(大小文字混在)に変換します。
+
+引数: 配列または文字列のいずれか。受け取ったものと同じタイプの引数を返しますが、CamelCaseの形式で返します。
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+ *タイプ*: 右辺値
+
+#### `capitalize`
+
+文字列または複数文字列の配列の最初の文字を大文字にし、各文字列の残りの文字を小文字にします。
+
+引数: インプットとして、単一文字列または配列。*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+#### `ceiling`
+
+引数以上の最小整数を返します。
+
+引数: 単一の数値。
+
+*タイプ*: 右辺値
+
+#### `chomp`
+
+文字列または複数文字列の配列の最後から、レコード分離文字を削除します。たとえば、'hello\n'は'hello'になります。
+
+引数: 単一の文字または配列。
+
+*タイプ*: 右辺値
+
+#### `chop`
+
+最後の文字を削除した新しい文字列を返します。文字列が'\r\n'で終わる場合は、両方の文字が削除されます。`chop`を空文字列に適用すると、空文字列が返されます。レコード分離文字のみを削除する場合は、`chomp`関数を使用してください。
+
+引数: インプットとして、文字列または複数文字列の配列。
+
+*タイプ*: 右辺値
+
+#### `clamp`
+
+整数値に基づく分類により、当該領域[Min、X、Max]内で値を維持します(パラメータの順序は関係ありません)。文字列が変換され、数字として比較されます。値の配列は、さらなる処理が可能なリストに平坦化されます。例:
+
+  * `clamp('24', [575, 187])`は187を返します。
+  * `clamp(16, 88, 661)`は88を返します。
+  * `clamp([4, 3, '99'])`は4を返します。
+  
+引数: 文字列、配列、数字。 
+
+*タイプ*: 右辺値
+
+#### `concat`
+
+複数配列のコンテンツを、与えられた最初の配列に追加します。例:
+
+  * `concat(['1','2','3'],'4')`は['1','2','3','4']を返します。
+  * `concat(['1','2','3'],'4',['5','6','7'])`は['1','2','3','4','5','6','7']を返します。
+
+*タイプ*: 右辺値
+
+#### `convert_base`
+
+与えられた整数または整数を表す10進数文字列を、指定した基数の文字列に変換します。例:
+
+  * `convert_base(5, 2)`は'101'になります。
+  * `convert_base('254', '16')`は'fe'になります。
+
+#### `count`
+
+配列のみで呼び出した場合は、空または`undef`**ではない**要素の数をカウントします。第2の引数を用いて呼び出した場合は、第2の引数にマッチする配列内の要素の数をカウントします。
+
+*タイプ*: 右辺値
+
+#### `deep_merge`
+
+2つ以上のハッシュを再帰的に統合し、その結果得られたハッシュを返します。
+
+```puppet
+$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
+$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
+$merged_hash = deep_merge($hash1, $hash2)
+```
+
+得られるハッシュは、以下に相当します。
+
+```puppet
+$merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
+```
+
+ハッシュである重複キーが存在する場合は、そうした重複キーが再帰的に統合されます。ハッシュではない重複キーが存在する場合は、最右のハッシュのキーが上位になります。
+
+*タイプ*: 右辺値
+
+#### `defined_with_params`
+
+属性のリソースリファレンスとオプションでハッシュを取得します。特定の属性を持つリソースがすでにカタログに追加されている場合は`true`を返します。そうでない場合は`false`を返します。
+
+```puppet
+user { 'dan':
+  ensure => present,
+}
+
+if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
+  user { 'dan': ensure => present, }
+}
+```
+
+*タイプ*: 右辺値
+
+#### `delete`
+
+配列から任意の要素のインスタンスを、文字列からサブストリングを、またはハッシュからキーをすべて削除します。
+
+例:
+
+* `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']を返します。
+
+*タイプ*: 右辺値
+
+#### `delete_at`
+
+決められたインデックス付き値を配列から削除します。
+
+例: `delete_at(['a','b','c'], 1)`は['a','c']を返します。
+
+*タイプ*: 右辺値
+
+#### `delete_regex`
+
+提示された正規表現にマッチする任意の要素のインスタンスを、配列またはハッシュからすべて削除します。文字列は1アイテム配列として処理されます。
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+
+例
+
+* `delete_regex(['a','b','c','b'], 'b')`は['a','c']を返します。
+* `delete_regex({'a' => 1,'b' => 2,'c' => 3},['b','c'])`は{'a'=> 1}を返します。
+* `delete_regex(['abf', 'ab', 'ac'], '^ab.*')`は['ac']を返します。
+* `delete_regex(['ab', 'b'], 'b')`は['ab']を返します。
+
+*タイプ*: 右辺値
+
+#### `delete_values`
+
+任意の値のインスタンスをハッシュからすべて削除します。
+
+例:
+
+* `delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')`は{'a'=>'A','c'=>'C','B'=>'D'}を返します。
+
+*タイプ*: 右辺値
+
+#### `delete_undef_values`
+
+`undef`値のインスタンスをアレイまたはハッシュからすべて削除します。
+
+例:
+
+* `$hash = delete_undef_values({a=>'A', b=>'', c=>`undef`, d => false})`は{a => 'A', b => '', d => false}を返します。
+
+*タイプ*: 右辺値
+
+#### `deprecation`
+
+非推奨警告をプリントし、任意のキーについて警告を一度記録します:
+
+```puppet
+deprecation(key, message)
+```
+
+引数:
+
+* キーを指定する文字列: Puppetプロセスの継続期間中にメッセージの数を少なく抑えるために、1つのキーにつき1つのメッセージのみを記録します。
+* メッセージを指定する文字列: 記録されるテキスト。
+
+*タイプ*: ステートメント
+
+**`deprecation`に影響を与える設定**
+
+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):
+
+    * `error`: 非推奨メッセージにより、ただちに機能しなくなります。
+    * `off`: メッセージがアウトプットされません。
+    * `warning`: すべての警告を記録します。これがデフォルト設定です。
+
+* 環境変数`STDLIB_LOG_DEPRECATIONS`
+
+  非推奨警告を記録するかどうかを指定します。これは特に、自動テストの際、移行の準備ができる前にログに情報が氾濫するのを避けるうえで役立ちます。
+
+  この変数はブーリアンで、以下の効果があります:
+  
+  * `true`: 警告を記録します。
+  * `false`: 警告は記録されません。
+  * 値を設定しない場合: Puppet 4は警告を出しますが、Puppet 3は出しません。
+
+#### `difference`
+
+2つの配列の間の差異を返します。返される配列はオリジナル配列のコピーで、第2の配列にも見られるアイテムがあれば、それが取り除かれます。
+
+例:
+
+* `difference(["a","b","c"],["b","c","d"])`は["a"]を返します。
+
+*タイプ*: 右辺値
+
+#### `dig`
+
+> 非推奨: この関数は、Puppet 4.5.0で、内蔵の[`dig`](https://docs.puppet.com/puppet/latest/function.html#dig)関数に置き換えられました。下位互換性を得るには、[`dig44()`](#dig44)を使用するか、新しいバージョンを使用してください。
+
+パスを含むキー配列を通じて、複数レイヤーのハッシュおよびアレイ内の値を探します。この関数は各パスコンポーネントにより構造内を移動し、パスの最後で値を返すよう試みます。
+
+この関数では、必要とされるパス引数に加え、デフォルトの引数を使用できます。パスが正しくない場合や、値が見つからない場合、その他のエラーが生じた場合は、デフォルトの引数を返します。
+
+```ruby
+$data = {
+  'a' => {
+    'b' => [
+      'b1',
+      'b2',
+      'b3',
+    ]
+  }
+}
+
+$value = dig($data, ['a', 'b', 2])
+# $value = 'b3'
+
+# 可能なすべてのオプションを使用
+$value = dig($data, ['a', 'b', 2], 'not_found')
+# $value = 'b3'
+
+# デフォルト値を使用
+$value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
+# $value = 'not_found'
+```
+
+1. **$data** 取り扱うデータ構造。
+2. **['a', 'b', 2]** パス配列。
+3. **'not_found'** デフォルト値。何も見つからない場合に返されます。
+
+デフォルト値: `undef`
+
+*タイプ*: 右辺値
+
+#### `dig44`
+
+パスを含むキー配列を通じて、複数レイヤーのハッシュおよびアレイ内の値を探します。この関数は各パスコンポーネントにより構造内を移動し、パスの最後で値を返すよう試みます。
+
+この関数では、必要とされるパス引数に加え、デフォルトの引数を使用できます。パスが正しくない場合や、値が見つからない場合、その他のエラーが生じた場合は、デフォルトの引数を返します。
+
+```ruby
+$data = {
+  'a' => {
+    'b' => [
+      'b1',
+      'b2',
+      'b3',
+    ]
+  }
+}
+
+$value = dig44($data, ['a', 'b', 2])
+# $value = 'b3'
+
+# 可能なすべてのオプションを使用
+$value = dig44($data, ['a', 'b', 2], 'not_found')
+# $value = 'b3'
+
+# デフォルト値を使用
+$value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
+# $value = 'not_found'
+```
+
+*タイプ*: 右辺値
+
+1. **$data** 取り扱うデータ構造。
+2. **['a', 'b', 2]** パス配列。
+3. **'not_found'** デフォルト値。何も見つからない場合に返されます。
+   (オプション、デフォルトは`undef`)
+
+#### `dirname`
+
+パスの`dirname`を返します。たとえば、`dirname('/path/to/a/file.ext')`は'/path/to/a'を返します。
+
+*タイプ*: 右辺値
+
+#### `dos2unix`
+
+与えられた文字列のUnixバージョンを返します。クロスプラットフォームテンプレートでファイルリソースを使用する場合に非常に役立ちます。
+
+```puppet
+file{$config_file:
+  ensure  => file,
+  content => dos2unix(template('my_module/settings.conf.erb')),
+}
+```
+
+[unix2dos](#unix2dos)も参照してください。
+
+*タイプ*: 右辺値
+
+#### `downcase`
+
+配列内の1つの文字列またはすべての文字列の大文字と小文字の別を、小文字に変換します。
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+*タイプ*: 右辺値
+
+#### `empty`
+
+引数が要素を含まない配列かハッシュ、または空文字列である場合に、`true`を返します。引数が数値の場合に`false`を返します。
+
+*タイプ*: 右辺値
+
+#### `enclose_ipv6`
+
+IPアドレスの配列を取得し、ipv6アドレスを大括弧でくくります。
+
+*タイプ*: 右辺値
+
+#### `ensure_packages`
+
+配列またはハッシュ内のパッケージのリストを取得し、すでに存在しない場合にのみ、それらをインストールします。オプションで、ハッシュを第2のパラメータとして取得し、第3の引数として`ensure_resource()`または `ensure_resources()`関数に渡します。
+
+*タイプ*: ステートメント
+
+配列の場合:
+
+```puppet
+ensure_packages(['ksh','openssl'], {'ensure' => 'present'})
+```
+
+ハッシュの場合:
+
+```puppet
+ensure_packages({'ksh' => { ensure => '20120801-1' } ,  'mypackage' => { source => '/tmp/myrpm-1.0.0.x86_64.rpm', provider => "rpm" }}, {'ensure' => 'present'})
+```
+
+#### `ensure_resource`
+
+リソースタイプ、タイトル、リソースを記述する属性のハッシュを取得します。
+
+```
+user { 'dan':
+  ensure => present,
+}
+```
+
+この例では、すでに存在しない場合にのみリソースが作成されます:
+
+  `ensure_resource('user', 'dan', {'ensure' => 'present' })`
+
+リソースがすでに存在しているものの、指定されたパラメータとマッチしない場合は、リソースの再作成が試みられ、重複リソース定義エラーにつながります。
+
+リソースの配列を提示することも可能です。それぞれのリソースは、すでに存在しない場合に、指定のタイプおよびパラメータにより作成されます。
+
+`ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})`
+
+*タイプ*: ステートメント
+
+#### `ensure_resources`
+
+ハッシュからリソース宣言を作成しますが、すでに宣言されているリソースとは対立しません。
+
+リソースタイプ、タイトル、リソースを記述する属性のハッシュを指定します。
+
+```puppet
+user { 'dan':
+  gid => 'mygroup',
+  ensure => present,
+}
+
+ensure_resources($user)
+```
+
+リソースのハッシュを提示します。リストにあるリソースは、すでに存在しない場合に、指定のタイプおよびパラメータにより作成されます。
+
+    ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } ,  'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
+
+Hieraバックエンドから:
+
+```yaml
+userlist:
+  dan:
+    gid: 'mygroup'
+    uid: '600'
+  alex:
+    gid: 'mygroup'
+```
+
+```puppet
+ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
+```
+
+### `flatten`
+
+ネストの深いアレイを平坦化し、結果として単一のフラット配列を返します。
+
+たとえば、`flatten(['a', ['b', ['c']]])`は['a','b','c']を返します。
+
+*タイプ*: 右辺値
+
+#### `floor`
+
+引数以下の最大整数を返します。
+
+引数: 単一の数値。
+
+*タイプ*: 右辺値
+
+#### `fqdn_rand_string`
+
+ランダムな英数字文字列を生成します。`$fqdn` factとオプションのシードを組み合わせると、反復的な無作為抽出が可能です。オプションで、この関数に使用する文字セットを指定することもできます(デフォルトは英数字)。
+
+*使用例:*
+
+```puppet
+fqdn_rand_string(LENGTH, [CHARSET], [SEED])
+```
+
+*例:*
+
+```puppet
+fqdn_rand_string(10)
+fqdn_rand_string(10, 'ABCDEF!@#$%^')
+fqdn_rand_string(10, '', 'custom seed')
+```
+
+引数:
+
+* 整数、得られる文字列の長さを指定。
+* オプションで、文字セットを指定する文字列。
+* オプションで、反復的な無作為抽出を可能にするシードを指定する文字列。
+
+*タイプ*: 右辺値
+
+#### `fqdn_rotate`
+
+配列と文字列をランダムな回数で回転させます。`$fqdn` factとオプションのシードを組み合わせると、反復的な無作為抽出が可能です。
+
+*使用例:*
+
+```puppet
+fqdn_rotate(VALUE, [SEED])
+```
+
+*例:*
+
+```puppet
+fqdn_rotate(['a', 'b', 'c', 'd'])
+fqdn_rotate('abcd')
+fqdn_rotate([1, 2, 3], 'custom seed')
+```
+
+*タイプ*: 右辺値
+
+#### `fqdn_uuid`
+
+DNSネームスペースのFQDN文字列をもとに、[RFC 4122](https://tools.ietf.org/html/rfc4122)有効バージョン5 UUIDを返します:
+
+  * fqdn_uuid('puppetlabs.com')は'9c70320f-6815-5fc5-ab0f-debe68bf764c'を返します。
+  * fqdn_uuid('google.com')は'64ee70a4-8cc1-5d25-abf2-dea6c79a09c8'を返します。
+
+*タイプ*: 右辺値
+
+#### `get_module_path`
+
+現在の環境について、指定されたモジュールの絶対パスを返します。
+
+```puppet
+$module_path = get_module_path('stdlib')
+```
+
+*タイプ*: 右辺値
+
+#### `getparam`
+
+リソースのパラメータの値を返します。
+
+引数: リソースリファレンスおよびパラメータの名前。
+
+たとえば、以下の場合は'param_value'を返します:
+
+```puppet
+define example_resource($param) {
+}
+
+example_resource { "example_resource_instance":
+  param => "param_value"
+}
+
+getparam(Example_resource["example_resource_instance"], "param")
+```
+
+*タイプ*: 右辺値
+
+#### `getvar`
+
+リモートネームスペースの変数を調べます。
+
+例:
+
+```puppet
+$foo = getvar('site::data::foo')
+# $foo = $site::data::fooに相当
+```
+
+この関数は、ネームスペースそのものが文字列に保存されている場合に役立ちます:
+
+```puppet
+$datalocation = 'site::data'
+$bar = getvar("${datalocation}::bar")
+# $bar = $site::data::barに相当
+```
+
+*タイプ*: 右辺値
+
+#### `glob`
+
+パスパターンに一致するパスの文字列配列を返します。
+
+引数: パスパターンを指定する文字列または文字列配列。
+
+```puppet
+$confs = glob(['/etc/**/*.conf', '/opt/**/*.conf'])
+```
+
+*タイプ*: 右辺値
+
+#### `grep`
+
+配列内を検索し、提示された正規表現に一致する要素を返します。
+
+たとえば、`grep(['aaa','bbb','ccc','aaaddd'], 'aaa')`は['aaa','aaaddd']を返します。
+
+*タイプ*: 右辺値
+
+#### `has_interface_with`
+
+種類および値に基づきブーリアンを返します:
+
+  * macaddress
+  * netmask
+  * ipaddress
+  * network
+
+*例:*
+
+```puppet
+has_interface_with("macaddress", "x:x:x:x:x:x")
+has_interface_with("ipaddress", "127.0.0.1")    => true
+```
+
+種類が提示されていない場合は、インターフェースの有無が確認されます:
+
+```puppet
+has_interface_with("lo")                        => true
+```
+
+*タイプ*: 右辺値
+
+#### `has_ip_address`
+
+一部のインターフェース上で、リクエストされたIPアドレスがクライアントに存在する場合は`true`を返します。この関数は`interfaces` factで反復され、`ipaddress_IFACE` factsをチェックし、簡単な文字列比較を実行します。
+
+引数: IPアドレスを指定する文字列。
+
+*タイプ*: 右辺値
+
+#### `has_ip_network`
+
+リクエストされたネットワーク内でIPアドレスがクライアントに存在する場合は`true`を返します。この関数は`interfaces` factで反復され、 `network_IFACE` factsをチェックし、簡単な文字列比較を実行します。
+
+引数: IPアドレスを指定する文字列。
+
+*タイプ*: 右辺値
+
+#### `has_key`
+
+ハッシュに特定のキー値があるかどうかを判定します。
+
+*例*:
+
+```
+$my_hash = {'key_one' => 'value_one'}
+if has_key($my_hash, 'key_two') {
+  notice('we will not reach here')
+}
+if has_key($my_hash, 'key_one') {
+  notice('this will be printed')
+}
+```
+
+*タイプ*: 右辺値
+
+#### `hash`
+
+配列をハッシュに変換します。
+
+たとえば、`hash(['a',1,'b',2,'c',3])`は{'a'=>1,'b'=>2,'c'=>3}を返します。
+
+*タイプ*: 右辺値
+
+#### `intersection`
+
+2つの共通部分の配列を返します。
+
+たとえば、`intersection(["a","b","c"],["b","c","d"])`は["b","c"]を返します。
+
+*タイプ*: 右辺値
+
+#### `is_a`
+
+ブーリアンチェックにより、変数が任意のデータタイプのものかどうかを判定します。これは`=~`タイプチェックに相当します。この関数はPuppet 4と、"future"パーサーを備えたPuppet 3でのみ使用できます。
+
+```
+foo = 3
+$bar = [1,2,3]
+$baz = 'A string!'
+
+if $foo.is_a(Integer) {
+  notify  { 'foo!': }
+}
+if $bar.is_a(Array) {
+  notify { 'bar!': }
+}
+if $baz.is_a(String) {
+  notify { 'baz!': }
+}
+```
+
+* タイプに関する詳細は、[Puppetタイプシステム](https://docs.puppetlabs.com/latest/type.html#about-resource-types)を参照してください。
+* 値のタイプを特定する各種の方法については、[`assert_type()`](https://docs.puppetlabs.com/latest/function.html#asserttype)関数を参照してください。
+
+#### `is_absolute_path`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+与えられたパスが絶対パスである場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_array`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された変数が配列である場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_bool`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された変数がブーリアンである場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_domain_name`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された文字列が構文的に正しいドメイン名である場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_float`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された変数がフロート型である場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_function_available`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+文字列を引数として受け入れ、Puppetランタイムがその名前を用いて関数にアクセスできるかどうかを判定します。関数が存在する場合は`true`、存在しない場合は`false`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_hash`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された変数がハッシュである場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_integer`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この文字列に返された変数が整数である場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_ip_address`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された文字列が有効なIPアドレスである場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_ipv6_address`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された文字列が有効なIPv6アドレスである場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_ipv4_address`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された文字列が有効なIPv4アドレスである場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_mac_address`
+
+この関数に渡された文字列が有効なMACアドレスである場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_numeric`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された変数が数字である場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `is_string`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+この関数に渡された変数が文字列である場合に`true`を返します。
+
+*タイプ*: 右辺値
+
+#### `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"]になります。
+
+*タイプ*: 右辺値
+
+#### `keys`
+
+ハッシュのキーを配列として返します。
+
+*タイプ*: 右辺値
+
+#### `length`
+
+与えられた文字列、配列、ハッシュの長さを返します。廃止された`size()`関数に代わるものです。
+
+*タイプ*: 右辺値
+
+#### `loadyaml`
+
+配列、文字列、ハッシュを含むYAMLファイルをロードし、対応するネイティブデータタイプでデータを返します。
+
+例:
+
+```puppet
+$myhash = loadyaml('/etc/puppet/data/myhash.yaml')
+```
+
+第2のパラメータは、ファイルが見つからなかった場合、または構文解析できなかった場合に返されます。
+
+例:
+
+```puppet
+$myhash = loadyaml('no-file.yaml', {'default'=>'value'})
+```
+
+*タイプ*: 右辺値
+
+#### `loadjson`
+
+配列、文字列、ハッシュを含むJSONファイルをロードし、対応するネイティブデータタイプでデータを返します。
+
+例:
+
+```puppet
+$myhash = loadjson('/etc/puppet/data/myhash.json')
+```
+
+第2のパラメータは、ファイルが見つからなかった場合、または構文解析できなかった場合に返されます。
+
+例:
+
+```puppet
+  $myhash = loadjson('no-file.json', {'default'=>'value'})
+  ```
+
+*タイプ*: 右辺値
+
+#### `load_module_metadata`
+
+ターゲットモジュールのmetadata.jsonをロードします。モジュールのバージョンや、モジュールの動的サポートに関するオーサーシップの判定に使用できます。
+
+```puppet
+$metadata = load_module_metadata('archive')
+notify { $metadata['author']: }
+```
+
+モジュールのメタデータファイルが存在しない場合、カタログコンパイルに失敗します。これを避ける方法は、以下のとおりです:
+
+```
+$metadata = load_module_metadata('mysql', true)
+if empty($metadata) {
+  notify { "This module does not have a metadata.json file.": }
+}
+```
+
+*タイプ*: 右辺値
+
+#### `lstrip`
+
+文字列の左側のスペースを取り除きます。
+
+*タイプ*: 右辺値
+
+#### `max`
+
+すべての引数の最大値を返します。少なくとも1つの引数が必要です。
+
+引数: 数字または数字を表す文字列。
+
+*タイプ*: 右辺値
+
+#### `member`
+
+変数が配列の構成要素かどうかを判定します。変数には文字列、配列、fixnumが使用できます。
+
+たとえば、`member(['a','b'], 'b')`および`member(['a','b','c'], ['b','c'])`は`true`を返し、`member(['a','b'], 'c')`および`member(['a','b','c'], ['c','d'])`は`false`を返します。
+
+*注*: この関数は、ネスト化した配列には対応していません。最初の引数にネスト化した配列が含まれている場合は、再帰的処理は行われません。
+
+*タイプ*: 右辺値
+
+#### `merge`
+
+2つ以上のハッシュを統合し、その結果得られたハッシュを返します。
+
+*例*:
+
+```puppet
+$hash1 = {'one' => 1, 'two' => 2}
+$hash2 = {'two' => 'dos', 'three' => 'tres'}
+$merged_hash = merge($hash1, $hash2)
+# 得られるハッシュは、以下に相当します:
+# $merged_hash =  {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
+```
+
+重複キーが存在する場合は、最右のハッシュのキーが上位になります。
+
+*タイプ*: 右辺値
+
+#### `min`
+
+すべての引数の最小値を返します。少なくとも1つの引数が必要です。
+
+引数: 数字または数字を表す文字列。
+
+*タイプ*: 右辺値
+
+#### `num2bool`
+
+数字または数字の文字列表現を正当なブーリアンに変換します。0または非数字は`false`になります。0より大きい数字は`true`になります。
+
+*タイプ*: 右辺値
+
+#### `parsejson`
+
+JSONの文字列を正確なPuppet構造に変換します(ハッシュ、配列、文字列、整数、またはそれらの組み合わせとして)。
+
+引数:
+* 第1の引数として、変換されるJSON文字列。
+* オプションで、第2のエラーとして、変換に失敗した場合に返される結果。
+
+*タイプ*: 右辺値
+
+#### `parseyaml`
+
+YAMLの文字列を正確なPuppet構造に変換します。
+
+引数:
+* 第1の引数として、変換されるYAML文字列。
+* オプションで、第2のエラーとして、変換に失敗した場合に返される結果。
+
+*タイプ*: 右辺値 
+
+#### `pick`
+
+値のリストから、未定義または空文字列ではない最初の値を返します。引数から任意の数字をとり、すべての値が未定義または空の場合はエラーが生じます。
+
+```puppet
+$real_jenkins_version = pick($::jenkins_version, '1.449')
+```
+
+*タイプ*: 右辺値
+
+#### `pick_default`
+
+値のリストにある最初の値を返します。`pick()`関数とは異なり、`pick_default()`は、すべての引数が空の場合も失敗にはなりません。そのため、デフォルトとして空の値を使用できます。
+
+*タイプ*: 右辺値
+
+#### `prefix`
+
+配列のすべての要素、またはハッシュのキーに接頭辞を適用します。
+
+例:
+
+* `prefix(['a','b','c'], 'p')`は['pa','pb','pc']を返します。
+* `prefix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')`は{'pa'=>'b','pb'=>'c','pc'=>'d'}を返します。
+
+*タイプ*: 右辺値
+
+#### `pry`
+
+現在のスコープオブジェクトでpryデバッグセッションを起動します。コンパイル中の特定ポイントにおけるマニフェストコードのデバッグに役立ちます。`puppet apply`の実行中またはフォアグラウンドでPuppet masterを実行しているときにのみ使用する必要があります。PuppetのRubyGemsに`pry` gemがインストールされている必要があります。
+
+*例:*
+
+```puppet
+pry()
+```
+
+pryセッションで役立つコマンドは以下のとおりです:
+
+* `catalog`を実行すると、現在カタログをコンパイルしているコンテンツを見られます。
+* `cd catalog`および`ls`を実行すると、カタログメソッドおよびインスタンス変数を見られます。
+* `@resource_table`を実行すると、現在のカタログリソーステーブルを見られます。
+
+#### `pw_hash`
+
+crypt関数を用いてパスワードをハッシュします。ほとんどのPOSIXシステムで使えるハッシュを提供します。
+
+この関数の最初の引数は、ハッシュするパスワードです。`undef`または空文字列の場合は、この関数により`undef`が返されます。
+
+この関数の第2の引数は、使用するハッシュのタイプです。適切なcrypt(3)ハッシュ指定子に変換されます。有効なハッシュタイプは以下のとおりです:
+
+|ハッシュタイプ            |指定子|
+|---------------------|---------|
+|MD5                  |1        |
+|SHA-256              |5        |
+|SHA-512 (推奨)|6        |
+
+この関数の第3の引数は、使用するソルトです。
+
+この関数は、Puppet masterのcrypt(3)実装を使用しています。お使いの環境に複数の異なるオペレーティングシステムが含まれている場合は、この関数を使用する前に、互換性があることを確認してください。
+
+*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+#### `range`
+
+'(start, stop)'の形式で与えられた場合に、領域を配列として外挿します。たとえば、`range("0", "9")`は[0,1,2,3,4,5,6,7,8,9]を返します。ゼロパディングされた文字列は、自動的に整数に変換されます。したがって、`range("00", "09")`は[0,1,2,3,4,5,6,7,8,9]を返します。
+
+非整数文字列を使用できます:
+
+* `range("a", "c")`は["a","b","c"]を返します。
+* `range("host01", "host10")`は["host01", "host02", ..., "host09", "host10"]を返します。
+
+末尾のゼロを明示的に含める必要があります。そうでないと、下層のRuby関数が適切に機能しません。
+
+第3の引数を渡すと、生成された領域がその間隔で刻まれます。例:
+
+* `range("0", "9", "2")`は["0","2","4","6","8"]を返します。
+
+*タイプ*: 右辺値
+
+#### `regexpescape`
+
+文字列または文字列の配列を正規表現エスケープします。インプットとして、単一の文字列または配列のいずれかが必要です。
+
+*タイプ*: 右辺値
+
+#### `reject`
+
+配列を検索し、提示された正規表現に一致する要素をすべてリジェクトします。
+
+たとえば、`reject(['aaa','bbb','ccc','aaaddd'], 'aaa')`は['bbb','ccc']を返します。
+
+*タイプ*: 右辺値
+
+#### `reverse`
+
+文字列または配列の順序を逆転します。
+
+*タイプ*: 右辺値
+
+#### `rstrip`
+
+文字列の右側のスペースを取り除きます。
+
+*タイプ*: 右辺値
+
+#### `seeded_rand`
+
+整数の最大値と文字列のシード値を取り、最大値よりも小さい反復可能かつランダムな整数を返します。`fqdn_rand`と同様ですが、シードにノード固有のデータが追加されません。
+
+*タイプ*: 右辺値
+
+#### `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'
+```
+
+*タイプ*: 右辺値
+
+#### `shell_join`
+
+与えられた文字列の配列からコマンドライン文字列を構築します。各配列アイテムが、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'
+```
+
+*タイプ*: 右辺値
+
+#### `shell_split`
+
+文字列をトークンの配列に分割します。この関数は、Rubyの`Shellwords.shellsplit()`関数と同様に挙動します。[Rubyドキュメント](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellsplit)を参照してください。
+
+*例:*
+
+```puppet
+shell_split('foo\ bar ba\"z') => ['foo bar', 'ba"z']
+```
+
+*タイプ*: 右辺値
+
+#### `shuffle`
+
+文字列または配列の順序をランダム化します。
+
+*タイプ*: 右辺値
+
+#### `size`
+
+文字列、配列、ハッシュの要素数を返します。この関数は、今後のリリースでは廃止されます。Puppet 4では、`length`関数を使用してください。
+
+*タイプ*: 右辺値
+
+#### `sort`
+
+文字列と配列を語彙的に分類します。
+
+*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+#### `squeeze`
+
+文字列内の連続した繰り返し('aaaa'など)を単一文字に置き換え、新たな文字列を返します。
+
+*タイプ*: 右辺値
+
+#### `str2bool`
+
+特定の文字列をブーリアンに変換します。値'1'、'true'、't'、'y'、'yes'を含む文字列は`true`に変換されます。値'0'、'false'、'f'、'n'、'no'を含む文字列、および空文字列または未定義文字列は`false`に変換されます。その他の値の場合、エラーが生じます。このチェックでは、大文字と小文字は区別されません。
+
+*タイプ*: 右辺値
+
+#### `str2saltedsha512`
+
+OS Xバージョン10.7以上で使用されるソルト付きSHA512パスワードハッシュに文字列を変換します。hexバージョンのソルト付きSHA512パスワードハッシュを返します。これは、有効なパスワード属性としてPuppetマニフェストに挿入することができます。
+
+*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+#### `strftime`
+
+フォーマットされた時刻を返します。
+
+たとえば、`strftime("%s")`はUnixエポックからの経過時間を返し、`strftime("%Y-%m-%d")`は日付を返します。
+
+引数: `strftime`フォーマットで時間を指定する文字列。詳細については、Ruby [strftime](https://ruby-doc.org/core-2.1.9/Time.html#method-i-strftime)ドキュメントを参照してください。
+
+*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+*フォーマット:*
+
+* `%a`: 曜日の名称の短縮形('Sun')
+* `%A`: 曜日の完全な名称('Sunday')
+* `%b`: 月の名称の短縮形('Jan')
+* `%B`: 月の完全な名称('January')
+* `%c`: 推奨される地域の日付および時刻の表現
+* `%C`: 世紀(2009年であれば20)
+* `%d`: その月の日(01..31)
+* `%D`: 日付(%m/%d/%y)
+* `%e`: その月の日、1桁の場合は半角空白で埋める( 1..31)
+* `%F`: %Y-%m-%d(ISO 8601の日付フォーマット)と同等
+* `%h`: %bと同等
+* `%H`: 24時間制の時(00..23)
+* `%I`: 12時間制の時(01..12)
+* `%j`: 年中の通算日(001..366)
+* `%k`: 24時間制の時、1桁の場合は半角空白で埋める( 0..23)
+* `%l`: 12時間制の時、1桁の場合は半角空白で埋める( 0..12)
+* `%L`: ミリ秒(000..999)
+* `%m`: その年の月(01..12)
+* `%M`: 分(00..59)
+* `%n`: 改行(\n)
+* `%N`: 秒の小数点以下の桁、デフォルトは9桁(ナノ秒)
+  * `%3N`: ミリ秒(3桁)
+  * `%6N`: マイクロ秒(6桁)
+  * `%9N`: ナノ秒(9桁)
+* `%p`: 午前または午後('AM'または'PM')
+* `%P`: 午前または午後('am'または'pm')
+* `%r`: 12時間制の時刻(%I:%M:%S %pと同等)
+* `%R`: 24時間制の時刻(%H:%M)
+* `%s`: Unixエポック、1970-01-01 00:00:00 UTCからの経過秒
+* `%S`: 秒(00..60)
+* `%t`: タブ文字(  )
+* `%T`: 24時間制の時刻(%H:%M:%S)
+* `%u`: 月曜日を1とした、曜日の数値表現(1..7)
+* `%U`: 最初の日曜日を第1週の始まりとした、現在の週を表す数(00..53)
+* `%v`: VMS形式の日付(%e-%b-%Y)
+* `%V`: ISO 8601形式の暦週(01..53)
+* `%W`: 最初の月曜日を第1週の始まりとした、現在の週を表す数(00..53)
+* `%w`: 曜日(日曜が0、0..6)
+* `%x`: 推奨される日付のみの表現、時刻はなし
+* `%X`: 推奨される時刻のみの表現、日付はなし
+* `%y`: 世紀なしの年(00..99)
+* `%Y`: 世紀ありの年
+* `%z`: タイムゾーン、UTCからのオフセット(+0900など)
+* `%Z`: タイムゾーンの名称
+* `%%`: '%'文字
+
+#### `strip`
+
+1つの文字列、または配列内のすべての文字列から、冒頭および末尾の空白を削除します。たとえば、`strip("    aaa   ")`は"aaa"になります。
+
+*タイプ*: 右辺値
+
+#### `suffix`
+
+配列のすべての要素、またはハッシュのすべてのキーに接尾辞を適用します。
+
+例:
+
+* `suffix(['a','b','c'], 'p')`は['ap','bp','cp']を返します。
+* `suffix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')`は{'ap'=>'b','bp'=>'c','cp'=>'d'}を返します。
+
+*タイプ*: 右辺値
+
+#### `swapcase`
+
+文字列の現在の大文字と小文字を入れ替えます。たとえば、`swapcase("aBcD")`は"AbCd"になります。
+
+*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+#### `time`
+
+現在のUnixエポック時刻を整数として返します。
+
+たとえば、`time()`は'1311972653'などを返します。
+
+*タイプ*: 右辺値
+
+#### `to_bytes`
+
+引数をバイトに変換します。
+
+たとえば、"4 kB"は"4096"になります。 
+
+引数: 単一の文字列。
+
+*タイプ*: 右辺値
+
+#### `try_get_value`
+
+**非推奨:** `dig()`に置き換えられました。
+
+ハッシュおよび配列の複数レイヤー内の値を取得します。
+
+引数: 
+
+* 第1の引数として、パスを含む文字列。この引数は、ゼロではじまり、パス区切り文字(デフォルトは"/")で区切ったハッシュキーまたは配列インデックスの文字列として提示してください。この関数は各パスコンポーネントにより構造内を移動し、パスの最後で値を返すよう試みます。
+
+*デフォルトの第2の引数。パスが正しくない場合や、値が見つからない場合、その他のエラーが生じた場合は、この引数が返されます。
+* 最後の引数として、パス区切り文字。
+
+```ruby
+$data = {
+  'a' => {
+    'b' => [
+      'b1',
+      'b2',
+      'b3',
+    ]
+  }
+}
+
+$value = try_get_value($data, 'a/b/2')
+# $value = 'b3'
+
+# 可能なすべてのオプションを使用
+$value = try_get_value($data, 'a/b/2', 'not_found', '/')
+# $value = 'b3'
+
+# デフォルト値を使用
+$value = try_get_value($data, 'a/b/c/d', 'not_found')
+# $value = 'not_found'
+
+# カスタム区切りを使用
+$value = try_get_value($data, 'a|b', [], '|')
+# $value = ['b1','b2','b3']
+```
+
+1. **$data** 取り扱うデータ構造。
+2. **'a/b/2'** パス文字列。
+3. **'not_found'** デフォルト値。何も見つからない場合に返されます。
+   (オプション、デフォルトは`undef`)
+4. **'/'** パス区切り文字。
+   (オプション、デフォルトは*'/'*)
+
+*タイプ*: 右辺値
+
+#### `type3x`
+
+**非推奨**。この関数は、今後のリリースで廃止されます。 
+
+与えられた値のタイプを説明する文字列を返します。タイプとしては、文字列、配列、ハッシュ、フロート、整数、ブーリアンが可能です。Puppet 4では、この代わりに新しいタイプシステムを使用してください。
+
+引数:
+
+* 文字列
+* 配列
+* ハッシュ
+* フロート
+* 整数
+* ブーリアン
+
+*タイプ*: 右辺値
+
+#### `type_of`
+
+この関数は下位互換性を得るために提供されていますが、Puppetで提供されている内蔵の[type()関数](https://docs.puppet.com/puppet/latest/reference/function.html#type)の使用を推奨します。
+
+与えられた値のリテラル型を返します。Puppet 4が必要です。`if type_of($some_value) <= Array[String] { ... }`のように(これは`if $some_value =~ Array[String] { ... }`に相当します)、`<=`を用いたタイプの比較に役立ちます。
+
+*タイプ*: 右辺値
+
+#### `union`
+
+2つ以上の配列を重複なしで結合したものを返します。
+
+たとえば、`union(["a","b","c"],["b","c","d"])`は["a","b","c","d"]を返します。
+
+*タイプ*: 右辺値
+
+#### `unique`
+
+文字列および配列から重複を削除します。
+
+たとえば、`unique("aabbcc")`は'abc'を、`unique(["a","a","b","b","c","c"])`は["a","b","c"]を返します。
+
+*タイプ*: 右辺値
+
+#### `unix2dos`
+
+与えられた文字列のDOSバージョンを返します。クロスプラットフォームテンプレートでファイルリソースを使用する場合に役立ちます。
+
+*タイプ*: 右辺値
+
+```puppet
+file{$config_file:
+  ensure  => file,
+  content => unix2dos(template('my_module/settings.conf.erb')),
+}
+```
+
+[dos2unix](#dos2unix)も参照してください。
+
+#### `upcase`
+
+オブジェクト、配列、オブジェクトのハッシュを大文字に変換します。変換されるオブジェクトは、大文字化に対応するものでなければなりません。
+
+たとえば、`upcase('abcd')`は'ABCD'を返します。
+
+*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+#### `uriescape`
+
+文字列または文字列の配列をURLエンコードします。 
+
+引数: 単一の文字列または文字列の配列。
+
+*タイプ*: 右辺値
+
+*注:* この関数はRubyクラスの実装にあたり、UTF8との互換性がない可能性があります。互換性を確保するには、Ruby 2.4.0以降でこの関数を使用してください。
+
+#### `validate_absolute_path`
+
+ファイルシステムの絶対パスを表す任意の文字列の有効性を確認します。WindowsおよびUnix形式のパスで機能します。
+
+以下の値が渡されます:
+
+```puppet
+$my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
+validate_absolute_path($my_path)
+$my_path2 = '/var/lib/puppet'
+validate_absolute_path($my_path2)
+$my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet']
+validate_absolute_path($my_path3)
+$my_path4 = ['/var/lib/puppet','/usr/share/puppet']
+validate_absolute_path($my_path4)
+```
+
+以下の値は失敗になり、コンパイルが中止されます:
+
+```puppet
+validate_absolute_path(true)
+validate_absolute_path('../var/lib/puppet')
+validate_absolute_path('var/lib/puppet')
+validate_absolute_path([ 'var/lib/puppet', '/var/foo' ])
+validate_absolute_path([ '/var/lib/puppet', 'var/foo' ])
+$undefined = `undef`
+validate_absolute_path($undefined)
+```
+
+*タイプ*: ステートメント
+
+#### `validate_array`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+渡されたすべての値が配列データ構造であることを確認します。このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
+
+以下の値が渡されます:
+
+```puppet
+$my_array = [ 'one', 'two' ]
+validate_array($my_array)
+```
+
+以下の値は失敗になり、コンパイルが中止されます:
+
+```puppet
+validate_array(true)
+validate_array('some_string')
+$undefined = `undef`
+validate_array($undefined)
+```
+
+*タイプ*: ステートメント
+
+#### `validate_augeas`
+
+Augeasレンズを用いて文字列を確認します。
+
+引数:
+
+* 第1の引数として、テストする文字列。
+* 第2の引数として、使用するAugeasレンズの名前。
+* オプションの第3の文字列として、ファイル内で見つかるべき**ではない**パスのリスト。
+* オプションの第4の引数として、ユーザに表示するエラーメッセージ。
+
+Augeasがレンズによる文字列の構文解析に失敗した場合は、構文エラーによりコンパイルが中止されます。 
+
+`$file`変数は、Augeasツリーでテストされる一時ファイルのロケーションを示します。
+
+たとえば、$passwdcontentにユーザの`foo`が含まれないようにするには、第3の引数を以下のようにします:
+
+```puppet
+validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
+```
+
+エラーメッセージを生成して表示するには、第4の引数を以下のようにします:
+
+```puppet
+validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
+```
+
+*タイプ*: ステートメント
+
+#### `validate_bool`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+渡されたすべての値が`true`または`false`のいずれかであることを確認します。 
+このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
+
+以下の値が渡されます:
+
+```puppet
+$iamtrue = true
+validate_bool(true)
+validate_bool(true, true, false, $iamtrue)
+```
+
+以下の値は失敗になり、コンパイルが中止されます:
+
+```puppet
+$some_array = [ true ]
+validate_bool("false")
+validate_bool("true")
+validate_bool($some_array)
+```
+
+*タイプ*: ステートメント
+
+#### `validate_cmd`
+
+外部コマンドにより文字列を確認します。
+
+引数:
+* 第1の引数として、テストする文字列。
+* 第2の引数として、テストコマンドのパス。この引数は、ファイルパスのプレースホルダ―として%をとります(%プレースホルダーが与えられていない場合、デフォルトはコマンド末尾)。パスした文字列を含む一時ファイルに対してコマンドが起動した場合や、ゼロではない値が返された場合は、構文エラーによりコンパイルが中止されます。
+* オプションの第3の引数として、ユーザに表示するエラーメッセージ。
+
+```puppet
+# デフォルトのパス末尾
+validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
+```
+
+```puppet
+# ファイルロケーションとして%を使用
+validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
+```
+
+*タイプ*: ステートメント
+
+#### `validate_hash`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+渡されたすべての値がハッシュデータ構造であることを確認します。このチェックで不合格となった値がある場合は、カタログコンパイルが中止されます。
+
+以下の値が渡されます:
+
+```puppet
+$my_hash = { 'one' => 'two' }
+validate_hash($my_hash)
+```
+
+以下の値は失敗になり、コンパイルが中止されます:
+
+```puppet
+validate_hash(true)
+validate_hash('some_string')
+$undefined = `undef`
+validate_hash($undefined)
+```
+
+*タイプ*: ステートメント
+
+#### `validate_integer`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+整数または整数の配列を確認します。いずれかがチェックで不合格になった場合には、カタログコンパイルが中止されます。
+
+引数:
+
+* 第1の引数として、整数または整数の配列。
+* オプションの第2の引数として、最大値。第1の引数(のすべての要素)は、この最大値以下でなければなりません。
+* オプションの第3の引数として、最小値。第1の引数(のすべての要素)は、この最小値以上でなければなりません。 
+
+第1の引数が整数または整数の配列でない場合や、第2または第3の引数が整数に変換できない場合は、この関数は失敗になります。ただし、最小値が与えられている場合は(この場合に限られます)、第2の引数を空文字列または`undef`にすることが可能です。これは、最小チェックを確実に行うためのプレースホルダーとして機能します。
+
+以下の値が渡されます:
+
+```puppet
+validate_integer(1)
+validate_integer(1, 2)
+validate_integer(1, 1)
+validate_integer(1, 2, 0)
+validate_integer(2, 2, 2)
+validate_integer(2, '', 0)
+validate_integer(2, `undef`, 0)
+$foo = `undef`
+validate_integer(2, $foo, 0)
+validate_integer([1,2,3,4,5], 6)
+validate_integer([1,2,3,4,5], 6, 0)
+```
+
+* 加えて、上述のすべて。ただし、文字列として渡された値を任意に組み合わせたもの('1'または"1")。
+* 加えて、上述のすべて。ただし、負の整数値を(適切に)組み合わせたもの。
+
+以下の値は失敗になり、コンパイルが中止されます:
+
+```puppet
+validate_integer(true)
+validate_integer(false)
+validate_integer(7.0)
+validate_integer({ 1 => 2 })
+$foo = `undef`
+validate_integer($foo)
+validate_integer($foobaridontexist)
+
+validate_integer(1, 0)
+validate_integer(1, true)
+validate_integer(1, '')
+validate_integer(1, `undef`)
+validate_integer(1, , 0)
+validate_integer(1, 2, 3)
+validate_integer(1, 3, 2)
+validate_integer(1, 3, true)
+```
+
+* 加えて、上述のすべて。ただし、文字列として渡された値を任意に組み合わせたもの (`false`、または"false")。
+* 加えて、上述のすべて。ただし、負の整数値を不適切に組み合わせたもの。
+* 加えて、上述のすべて。ただし、配列内の非整数アイテムまたは最大/最小引数を用いたもの。
+
+*タイプ*: ステートメント
+
+#### `validate_ip_address`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+IPv4アドレスかIPv6アドレスかにかかわらず、引数がIPアドレスであることを確認します。また、ネットマスクによりIPアドレスを確認します。 
+
+引数: IPアドレスを指定する文字列。
+
+以下の値が渡されます:
+
+```puppet
+validate_ip_address('0.0.0.0')
+validate_ip_address('8.8.8.8')
+validate_ip_address('127.0.0.1')
+validate_ip_address('194.232.104.150')
+validate_ip_address('3ffe:0505:0002::')
+validate_ip_address('::1/64')
+validate_ip_address('fe80::a00:27ff:fe94:44d6/64')
+validate_ip_address('8.8.8.8/32')
+```
+
+以下の値は失敗になり、コンパイルが中止されます:
+
+```puppet
+validate_ip_address(1)
+validate_ip_address(true)
+validate_ip_address(0.0.0.256)
+validate_ip_address('::1', {})
+validate_ip_address('0.0.0.0.0')
+validate_ip_address('3.3.3')
+validate_ip_address('23.43.9.22/64')
+validate_ip_address('260.2.32.43')
+```
+
+
+#### `validate_legacy`
+
+指定したタイプおよび非推奨の確認関数の両方に照らして値を確認します。両方にパスした場合はそのままパスし、片方の確認のみにパスした場合はエラーが生じ、両方の確認でfalseが返された場合は失敗になります。
+
+引数:
+
+* 値のチェックに用いるタイプ。
+* 過去の確認関数のフルネーム。
+* チェックする値。
+* 過去の確認関数に必要な引数の不特定数。
+
+例:
+
+```puppet
+validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."])
+```
+
+この関数は、Puppet 3形式の引数確認(stdlibの`validate_*`関数を使用)からPuppet 4データタイプへのモジュールのアップデートに対応しており、Puppet 3形式の確認に頼っている場合も機能性が中断することはありません。
+
+> 注: この関数は、Puppet 4.4.0 (PE 2016.1)以降にのみ対応しています。
+
+##### モジュールユーザへ
+
+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とともに、非推奨の `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: 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>`: コードの渡す値は、新形式の確認でも旧形式の確認でも認められません。
+
+##### モジュール開発者へ
+
+`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データタイプを選択してください。たいていの場合、新しいデータタイプにより、元の`validate_*`関数とは異なる値のセットを使用できるようになります。以下のような状況になります:
+
+|              | `validate_` pass | `validate_` fail |
+| ------------ | ---------------- | ---------------- |
+| マッチタイプ | パス             | パス、通告     |
+| 失敗タイプ   | パス、非推奨 | 失敗             |
+
+現在のところ、確認後のコードでも、すべての可能な値に対処する必要がありますが、新形式にマッチする値のみを渡すように、コードのユーザがマニフェストを変更することができます。
+
+stdlibの`validate_*`関数それぞれについて、マッチする`Stdlib::Compat::*`タイプがあり、適切な値のセットが許可されます。注意事項については、stdlibソースコードの `types/`ディレクトリにあるドキュメントを参照してください。
+
+たとえば、数字のみが許可されるクラスを与えると、以下のようになります:
+
+```puppet
+class example($value) {
+  validate_numeric($value)
+```
+
+得られる確認コードは、以下のようになります:
+
+```puppet
+class example(
+  Variant[Stdlib::Compat::Numeric, Numeric] $value
+) {
+  validate_legacy(Numeric, 'validate_numeric', $value)
+```
+
+ここでは、`$value`のタイプが`Variant[Stdlib::Compat::Numeric, Numeric]`と定義されています。これにより、任意の`Numeric` (新形式)のほか、`validate_numeric`で(`Stdlib::Compat::Numeric`を通じて)これまで許可されていたすべての値を使用できます。
+
+`validate_legacy`を呼び出すと、適切なログまたは失敗メッセージのトリガーが処理されます。これには、新形式、以前の確認関数の名称、およびその関数のすべての引数が必要です。
+
+お使いのモジュールがまだPuppet 3をサポートしている場合は、これは互換性を破る変更になります。`metadata.json`要件セクションをアップデートしてモジュールがもうPuppet 3をサポートしていないことを示し、モジュールのメジャーバージョンを放棄してください。この変更を加えても、モジュールに関する既存のすべてのテストにパスするはずです。新たに可能になった値について、追加のテストを作成してください。
+
+これは互換性を破る変更であることから、取り除きたいすべてのパラメータについて [`deprecation`](#deprecation)をコールしたり、パラメータにさらなる制約を追加したりする良い機会でもあります。
+
+このバージョンのリリース後、互換性を破る変更を加えた別のリリースを公開し、すべての互換性タイプおよび `validate_legacy`のコールを削除することができます。その時点で、コードを実行し、過去に可能だった値に関する残余要素を取り除くこともできます。
+
+そうした変更については、必ずCHANGELOGおよびREADMEで通告してください。
+
+#### `validate_numeric`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+数値または数値の配列や文字列を確認します。いずれかがチェックに失敗した場合には、カタログコンパイルが中止されます。
+
+引数:
+
+* 数値、または数値の配列か文字列。
+* オプションで、最大値。第1の引数(のすべての要素) は、この最大値以下でなければなりません。
+* オプションで、最小値。第1の引数(のすべての要素)は、この最小値以上でなければなりません。
+
+第1の引数が数値(整数またはフロート)または数値の配列が文字列でない場合や、第2および第3の引数が数値に変換できない場合は、この関数は失敗になります。最小値が与えられている場合は(この場合に限られます)、第2の引数を空文字列または`undef`にすることが可能です。これは、最小チェックを確実に行うためのプレースホルダーとして機能します。
+
+パスおよび失敗の使用については、[`validate_integer`](#validate-integer)を参照してください。同じ値がパスおよび失敗します。ただし、`validate_numeric`では、浮動小数点値も許可されます。
+
+*タイプ*: ステートメント
+
+#### `validate_re`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+1つまたは複数の正規表現に照らして、文字列の簡単な確認を行います。
+
+引数:
+
+* 第1の引数として、テストする文字列。この引数が文字列でない場合、コンパイルが中止されます。クォートを用いて強制的に文字列化してください。
+* 第2の引数として、文字列化した正規表現(区切り文字//なし)または正規表現の配列。
+* オプションの第3の引数として、ユーザに表示するエラーメッセージ。
+
+第2の引数の正規表現が第1の引数で渡した文字列にマッチしない場合は、構文エラーによりコンパイルが中止されます。
+
+以下の文字列により、正規表現に照らして確認が行われます:
+
+```puppet
+validate_re('one', '^one$')
+validate_re('one', [ '^one', '^two' ])
+```
+
+以下の文字列では、確認に失敗し、コンパイルが中止されます:
+
+```puppet
+validate_re('one', [ '^two', '^three' ])
+```
+
+エラーメッセージの設定方法:
+
+```puppet
+validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
+```
+
+強制的に文字列化するには、クォートを使用してください:
+
+  ```
+  validate_re("${::operatingsystemmajrelease}", '^[57]$')
+  ```
+
+*タイプ*: ステートメント
+
+#### `validate_slength`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+文字列(または文字列の配列)が指定した長さ以下であることを確認します。
+
+引数:
+
+* 第1の引数として、文字列または文字列の配列。
+* 第2の引数として、長さの最大値を示す数値。
+* オプションの第3の引数として、長さの最小値を示す数値。
+
+  以下の値が渡されます:
+
+```puppet
+validate_slength("discombobulate",17)
+validate_slength(["discombobulate","moo"],17)
+validate_slength(["discombobulate","moo"],17,3)
+```
+
+以下の値は失敗になります:
+
+```puppet
+validate_slength("discombobulate",1)
+validate_slength(["discombobulate","thermometer"],5)
+validate_slength(["discombobulate","moo"],17,10)
+```
+
+*タイプ*: ステートメント
+
+#### `validate_string`
+
+**非推奨。今後のバージョンのstdlibでは削除されます。[`validate_legacy`](#validate_legacy)を参照してください。**
+
+渡したすべての値が文字列データ構造であることを確認します。このチェックに失敗した値がある場合は、カタログコンパイルが中止されます。
+
+以下の値が渡されます:
+
+```puppet
+$my_string = "one two"
+validate_string($my_string, 'three')
+```
+
+以下の値は失敗になり、コンパイルが中止されます:
+
+```puppet
+validate_string(true)
+validate_string([ 'some', 'array' ])
+```
+
+*注:* validate_string(`undef`)は、このバージョンの関数APIでは失敗しません。
+
+代わりに、以下を使用してください:
+
+  ```
+  if $var == `undef` {
+    fail('...')
+  }
+  ```
+
+*タイプ*: ステートメント
+
+#### `validate_x509_rsa_key_pair`
+
+OpenSSLにより、PEMフォーマットされたX.509認証およびプライベートキーを確認します。
+認証の署名が提供されたキーから作成されたものであることを確認します。
+
+このチェックに失敗した値がある場合は、カタログコンパイルが中止されます。
+
+引数:
+
+* 第1の引数として、X.509認証。
+* 第2の引数として、RSAプライベートキー。
+
+```puppet
+validate_x509_rsa_key_pair($cert, $key)
+```
+
+*タイプ*: ステートメント
+
+#### `values`
+
+与えられたハッシュの値を返します。
+
+たとえば、`$hash = {'a'=1, 'b'=2, 'c'=3} values($hash)`を与えると、[1,2,3]を返します。
+
+*タイプ*: 右辺値
+
+#### `values_at`
+
+ロケーションをもとに、配列内の値を探します。
+
+引数:
+
+* 第1の引数として、解析したい配列。
+* 第2の引数として、以下の値の任意の組み合わせ:
+  * 単一の数値インデックス。
+  * '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']を返します。
+
+*タイプ*: 右辺値
+
+#### `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の最新リリースをインストールする必要があります。
+
+### バージョン互換性
+
+バージョン | Puppet 2.6 | Puppet 2.7 | Puppet 3.x | Puppet 4.x |
+:---------------|:-----:|:---:|:---:|:----:
+**stdlib 2.x**  | **あり** | **あり** | なし | なし
+**stdlib 3.x**  | なし    | **あり**  | **あり** | なし
+**stdlib 4.x**  | なし    | **あり**  | **あり** | なし
+**stdlib 4.6+**  | なし    | **あり**  | **あり** | **あり**
+**stdlib 5.x**  | なし    | なし  | **あり**  | **あり**
+
+**stdlib 5.x**:  stdlib 5.xのリリース時には、Puppet 2.7.xのサポートが廃止されます。[この説明](https://github.com/puppetlabs/puppetlabs-stdlib/pull/176#issuecomment-30251414)を参照してください。
+
+## 開発
+
+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
index 6e41e2f..5af436f 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'abs function' do
   describe 'success' do
     it 'should accept a string' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb
new file mode 100755 (executable)
index 0000000..24a9064
--- /dev/null
@@ -0,0 +1,26 @@
+require 'spec_helper_acceptance'
+
+describe 'anchor type' do
+  describe 'success' do
+    it 'should effect proper chaining of resources' do
+      pp = <<-EOS
+      class anchored {
+        anchor { 'anchored::begin': }
+        ~> anchor { 'anchored::end': }
+      }
+
+      class anchorrefresh {
+        notify { 'first': }
+        ~> class { 'anchored': }
+        ~> anchor { 'final': }
+      }
+
+      include anchorrefresh
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Anchor\[final\]: Triggered 'refresh'/)
+      end
+    end
+  end
+end
index 18ea4cd..8a13911 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'any2array function' do
   describe 'success' do
     it 'should create an empty array' do
       pp = <<-EOS
index 97e1738..e9096a7 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'base64 function' do
   describe 'success' do
     it 'should encode then decode a string' do
       pp = <<-EOS
index 52ff75b..c69acc6 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+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
index e5e7b7b..03d01a8 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'capitalize function' do
   describe 'success' do
     it 'should capitalize the first letter of a string' do
       pp = <<-EOS
index 557986e..895e4a0 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'ceiling function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'ceiling function' do
   describe 'success' do
     it 'ceilings floats' do
       pp = <<-EOS
index f6c1595..56e0876 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'chomp function' do
   describe 'success' do
     it 'should eat the newline' do
       pp = <<-EOS
index a16a710..0993806 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'chop function' do
   describe 'success' do
     it 'should eat the last character' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb
new file mode 100755 (executable)
index 0000000..e8ccb96
--- /dev/null
@@ -0,0 +1,40 @@
+#! /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
+      $x = 17
+      $y = 225
+      $z = 155
+      $o = clamp($x, $y, $z)
+      if $o == $z {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'clamps array of values' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles no arguments'
+  end
+end
index 06b649f..8d184d1 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'concat function' do
   describe 'success' do
     it 'should concat one array to another' do
       pp = <<-EOS
@@ -34,6 +34,20 @@ describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper
       }
       EOS
 
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'should concat hash arguments' do
+      pp = <<-EOS
+      $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
+      validate_array($output)
+      if size($output) != 2 {
+        fail("${output} should have 2 elements.")
+      }
+      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)
     end
   end
index fe7ca9d..18c039d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'count function' do
   describe 'success' do
     it 'should count elements in an array' do
       pp = <<-EOS
index c0f9b12..8222f24 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'deep_merge function' do
   describe 'success' do
     it 'should deep merge two hashes' do
       pp = <<-EOS
index fc54450..a332bd6 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'defined_with_params function' do
   describe 'success' do
     it 'should successfully notify' do
       pp = <<-EOS
index db0c01f..d4f852a 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'delete_at function' do
   describe 'success' do
     it 'should delete elements of the array' do
       pp = <<-EOS
index a28604c..f85b093 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'delete function' do
   describe 'success' do
     it 'should delete elements of the array' do
       pp = <<-EOS
index b7eda19..af45a92 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'delete_undef_values function' do
   describe 'success' do
     it 'should delete elements of the array' do
       pp = <<-EOS
index 6d2369c..04b6920 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'delete_values function' do
   describe 'success' do
     it 'should delete elements of the hash' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb
new file mode 100644 (file)
index 0000000..7a0b34c
--- /dev/null
@@ -0,0 +1,102 @@
+#! /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
+
+  # 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', }\""
+  remove_file_manifest = "file { '#{test_file}': ensure => absent }"
+
+  before :all 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
+
+    after :all do
+      apply_manifest(remove_file_manifest)
+    end
+
+    it "should return 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/)
+    end
+
+    describe file("#{test_file}") 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
+
+    after :all do
+      apply_manifest(remove_file_manifest)
+    end
+
+    it "should 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/)
+    end
+
+    describe file("#{test_file}") 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
+
+    after :all do
+      apply_manifest(remove_file_manifest)
+    end
+
+    it "should 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/)
+    end
+
+    describe file("#{test_file}") 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
+    after :all do
+      apply_manifest(remove_file_manifest)
+    end
+
+    it "should return a deprecation error" do
+      expect(@result.stderr).to match(/Warning: message/)
+    end
+    it "should pass without error" do
+      expect(@result.exit_code).to eq(0)
+    end
+  end
+
+end
index 2fae5c4..68f6bbe 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'difference function' do
   describe 'success' do
     it 'returns non-duplicates in the first array' do
       pp = <<-EOS
index 97913dd..db83f0f 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'dirname function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'dirname function' do
   describe 'success' do
     context 'absolute path' do
       it 'returns the dirname' do
index bc4e706..300bcfa 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'downcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'downcase function' do
   describe 'success' do
     it 'returns the downcase' do
       pp = <<-EOS
index 8b46aac..97b7333 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'empty function' do
   describe 'success' do
     it 'recognizes empty strings' do
       pp = <<-EOS
@@ -27,6 +27,20 @@ describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera
       }
       EOS
 
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'handles numerical values' do
+      pp = <<-EOS
+      $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/)
       end
diff --git a/3rdparty/modules/stdlib/spec/acceptance/ensure_packages_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/ensure_packages_spec.rb
deleted file mode 100755 (executable)
index aedcfb5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'spec_helper_acceptance'
-
-describe 'ensure_packages function', :unless => fact('osfamily') =~ /windows/i do
-  describe 'success' do
-    it 'ensure_packages a package' do
-      apply_manifest('package { "rake": ensure => absent, provider => "gem", }')
-      pp = <<-EOS
-      $a = "rake"
-      ensure_packages($a,{'provider' => 'gem'})
-      EOS
-
-      apply_manifest(pp, :expect_changes => true)
-    end
-    it 'ensures a package already declared'
-    it 'takes defaults arguments'
-  end
-  describe 'failure' do
-    it 'handles no arguments'
-    it 'handles non strings'
-  end
-end
index 1cee53d..93f25dd 100755 (executable)
@@ -1,18 +1,26 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'ensure_resource function', :unless => fact('osfamily') =~ /windows/i do
+describe 'ensure_resource function' do
   describe 'success' do
-    it 'ensure_resource a package' do
-      apply_manifest('package { "rake": ensure => absent, provider => "gem", }')
+    it 'ensures a resource already declared' do
+      apply_manifest('')
       pp = <<-EOS
-      $a = "rake"
-      ensure_resource('package', $a, {'provider' => 'gem'})
+      notify { "test": loglevel => 'err' }
+      ensure_resource('notify', 'test', { 'loglevel' => 'err' })
+      EOS
+
+      apply_manifest(pp, :expect_changes => true)
+    end
+
+    it 'ensures a undeclared resource' do
+      apply_manifest('')
+      pp = <<-EOS
+      ensure_resource('notify', 'test', { 'loglevel' => 'err' })
       EOS
 
       apply_manifest(pp, :expect_changes => true)
     end
-    it 'ensures a resource already declared'
     it 'takes defaults arguments'
   end
   describe 'failure' do
index c4d66e0..289eec9 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'flatten function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'flatten function' do
   describe 'success' do
     it 'flattens arrays' do
       pp = <<-EOS
index 0dcdad9..8259d2a 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'floor function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'floor function' do
   describe 'success' do
     it 'floors floats' do
       pp = <<-EOS
index 8fe1a69..af1b2a9 100644 (file)
@@ -1,55 +1,61 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'fqdn_rand_string function' do
   describe 'success' do
-    let(:facts_d) do
-      if fact('is_pe', '--puppet') == "true"
-        if fact('osfamily') =~ /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
-        else
-          '/etc/puppetlabs/facter/facts.d'
+    include_context "with faked facts"
+    context "when the FQDN is 'fakehost.localdomain'" do
+      before :each do
+        fake_fact("fqdn", "fakehost.localdomain")
+      end
+
+      it 'generates random alphanumeric strings' do
+        pp = <<-eos
+        $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)"/)
         end
-      else
-        '/etc/facter/facts.d'
       end
-    end
-    after :each do
-      shell("if [ -f '#{facts_d}/fqdn.txt' ] ; then rm '#{facts_d}/fqdn.txt' ; fi")
-    end
-    before :each do
-      #no need to create on windows, pe creates by default
-      if fact('osfamily') !~ /windows/i
-        shell("mkdir -p '#{facts_d}'")
+      it 'generates random alphanumeric strings with custom charsets' do
+        pp = <<-eos
+        $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)"/)
+        end
       end
-    end
-    it 'generates random alphanumeric strings' do
-      shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
-      pp = <<-eos
-      $l = 10
-      $o = fqdn_rand_string($l)
-      notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
-      eos
+      it 'generates random alphanumeric strings with custom seeds' do
+        pp = <<-eos
+        $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 "7oDp0KOr1b"/)
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"/)
+        end
       end
-    end
-    it 'generates random alphanumeric strings with custom seeds' do
-      shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
-      pp = <<-eos
-      $l = 10
-      $s = 'seed'
-      $o = fqdn_rand_string($l, undef, $s)
-      notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
-      eos
+      it 'generates random alphanumeric strings with custom charsets and seeds' do
+        pp = <<-eos
+        $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 "3HS4mbuI3E"/)
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rand_string is "(3104058232|7100592312)"/)
+        end
       end
     end
   end
index 753068b..66e94a9 100755 (executable)
@@ -1,47 +1,64 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'fqdn_rotate function' do
   describe 'success' do
-    let(:facts_d) do
-      if fact('is_pe', '--puppet') == "true"
-        if fact('osfamily') =~ /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
-        else
-          '/etc/puppetlabs/facter/facts.d'
+    include_context "with faked facts"
+    context "when the FQDN is 'fakehost.localdomain'" do
+      before :each do
+        fake_fact("fqdn", "fakehost.localdomain")
+      end
+
+      it 'rotates arrays' do
+        pp = <<-EOS
+        $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"\]/)
         end
-      else
-        '/etc/facter/facts.d'
       end
-    end
-    after :each do
-      shell("if [ -f '#{facts_d}/fqdn.txt' ] ; then rm '#{facts_d}/fqdn.txt' ; fi")
-    end
-    before :each do
-      #No need to create on windows, PE creates by default
-      if fact('osfamily') !~ /windows/i
-        shell("mkdir -p '#{facts_d}'")
+      it 'rotates arrays with custom seeds' do
+        pp = <<-EOS
+        $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"\]/)
+        end
       end
-    end
-    it 'fqdn_rotates floats' do
-      shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
-      pp = <<-EOS
-      $a = ['a','b','c','d']
-      $o = fqdn_rotate($a)
-      notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
-      EOS
+      it 'rotates strings' do
+        pp = <<-EOS
+        $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"/)
+        end
+      end
+      it 'rotates strings with custom seeds' do
+        pp = <<-EOS
+        $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 \["c", "d", "a", "b"\]/)
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rotate is "cdab"/)
+        end
       end
     end
   end
   describe 'failure' do
     it 'handles improper argument counts'
-    it 'handles non-numbers'
+    it 'handles invalid arguments'
   end
 end
index 6ac690c..3d10251 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'get_module_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'get_module_path function' do
   describe 'success' do
     it 'get_module_paths dne' do
       pp = <<-EOS
index b1a677e..bd12154 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'getparam function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'getparam function' do
   describe 'success' do
     it 'getparam a notify' do
       pp = <<-EOS
index 333c467..605cdce 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'getvar function' do
   describe 'success' do
     it 'getvars from classes' do
       pp = <<-EOS
index b39d48e..7c35ee4 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'grep function' do
   describe 'success' do
     it 'greps arrays' do
       pp = <<-EOS
index 9590193..fd33af5 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'has_interface_with function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
   describe 'success' do
     it 'has_interface_with existing ipaddress' do
       pp = <<-EOS
index 149a10d..878d921 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'has_ip_address function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
   describe 'success' do
     it 'has_ip_address existing ipaddress' do
       pp = <<-EOS
index 7d2f34e..f7a7d35 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'has_ip_network function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
   describe 'success' do
     it 'has_ip_network existing ipaddress' do
       pp = <<-EOS
index c8557cb..661c122 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'has_key function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'has_key function' do
   describe 'success' do
     it 'has_keys in hashes' do
       pp = <<-EOS
index ed53834..85da50b 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'hash function' do
   describe 'success' do
     it 'hashs arrays' do
       pp = <<-EOS
index 66b8652..02d4e7d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'intersection function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'intersection function' do
   describe 'success' do
     it 'intersections arrays' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb
new file mode 100644 (file)
index 0000000..fb0019a
--- /dev/null
@@ -0,0 +1,30 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+if get_puppet_version =~ /^4/
+  describe 'is_a function' do
+    it 'should match a string' do
+      pp = <<-EOS
+      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/)
+      end
+    end
+
+    it 'should not match a integer as string' do
+      pp = <<-EOS
+      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/)
+      end
+    end
+  end
+end
index 9c6bad7..1a83417 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_array function' do
   describe 'success' do
     it 'is_arrays arrays' do
       pp = <<-EOS
index 60079f9..823cb46 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_bool function' do
   describe 'success' do
     it 'is_bools arrays' do
       pp = <<-EOS
index e0f03fa..884b0bc 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_domain_name function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_domain_name function' do
   describe 'success' do
     it 'is_domain_names arrays' do
       pp = <<-EOS
index 338ba58..0b38d94 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_float function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_float function' do
   describe 'success' do
     it 'is_floats arrays' do
       pp = <<-EOS
index 2b5dd6d..f8191ee 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_function_available function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_function_available function' do
   describe 'success' do
     it 'is_function_availables arrays' do
       pp = <<-EOS
index 2ef310a..64f016c 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_hash function' do
   describe 'success' do
     it 'is_hashs arrays' do
       pp = <<-EOS
index bf6902b..7333687 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_integer function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_integer function' do
   describe 'success' do
     it 'is_integers arrays' do
       pp = <<-EOS
index ed7a854..2c62c77 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_ip_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_ip_address function' do
   describe 'success' do
     it 'is_ip_addresss ipv4' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb
new file mode 100755 (executable)
index 0000000..abe26d8
--- /dev/null
@@ -0,0 +1,52 @@
+#! /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
+      $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/)
+      end
+    end
+    it 'is_ipv4_addresss strings' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+    it 'is_ipv4_addresss ipv4 out of range' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb
new file mode 100755 (executable)
index 0000000..73a3fa4
--- /dev/null
@@ -0,0 +1,66 @@
+#! /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
+      $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/)
+      end
+    end
+    it 'is_ipv6_addresss ipv6 compressed' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+    it 'is_ipv6_addresss strings' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+    it 'is_ipv6_addresss ip out of range' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
index a2c892f..617bef6 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_mac_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_mac_address function' do
   describe 'success' do
     it 'is_mac_addresss a mac' do
       pp = <<-EOS
index 21c8988..7e65384 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_numeric function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_numeric function' do
   describe 'success' do
     it 'is_numerics arrays' do
       pp = <<-EOS
index 94d8e96..bee5e01 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'is_string function' do
   describe 'success' do
     it 'is_strings arrays' do
       pp = <<-EOS
@@ -95,6 +95,17 @@ describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
         expect(r.stdout).to match(/Notice: output correct/)
       end
     end
+    it 'is_strings undef' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
   end
   describe 'failure' do
     it 'handles improper argument counts'
index 70493fd..ae6947e 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'join_keys_to_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'join_keys_to_values function' do
   describe 'success' do
     it 'join_keys_to_valuess hashes' do
       pp = <<-EOS
index 5397ce2..75b88d8 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'join function' do
   describe 'success' do
     it 'joins arrays' do
       pp = <<-EOS
index 176918e..65bfe28 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'keys function' do
   describe 'success' do
     it 'keyss hashes' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb
new file mode 100644 (file)
index 0000000..ebd5307
--- /dev/null
@@ -0,0 +1,52 @@
+#! /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')
+      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/)
+      end
+    end
+
+    it 'returns the default value if there is no file to load' do
+      pp = <<-EOS
+      $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"/)
+      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'})
+      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"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'fails with no arguments'
+  end
+end
index 1e910a9..57fb8cb 100644 (file)
@@ -3,7 +3,7 @@ require 'spec_helper_acceptance'
 
 tmpdir = default.tmpdir('stdlib')
 
-describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'loadyaml function' do
   describe 'success' do
     it 'loadyamls array of values' do
       shell("echo '---
@@ -26,6 +26,29 @@ describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('op
         expect(r.stdout).to match(/loadyaml\[ddd\] is 4/)
       end
     end
+
+    it 'returns the default value if there is no file to load' do
+      pp = <<-EOS
+      $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"/)
+      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'})
+      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"/)
+      end
+    end
   end
   describe 'failure' do
     it 'fails with no arguments'
index 3dc952f..eba5d0d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'lstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'lstrip function' do
   describe 'success' do
     it 'lstrips arrays' do
       pp = <<-EOS
index f04e3d2..3caa813 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'max function' do
   describe 'success' do
     it 'maxs arrays' do
       pp = <<-EOS
index fe75a07..2bcadd3 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'member function' do
   shared_examples 'item found' do
     it 'should output correctly' do
       apply_manifest(pp, :catch_failures => true) do |r|
index 227b994..814db4e 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'merge function' do
   describe 'success' do
     it 'should merge two hashes' do
       pp = <<-EOS
index 509092d..7b18fac 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'min function' do
   describe 'success' do
     it 'mins arrays' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml
deleted file mode 100644 (file)
index 2ad90b8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
-  centos-59-x64:
-    roles:
-      - master
-    platform: el-5-x86_64
-    box : centos-59-x64-vbox4210-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box
-    hypervisor : vagrant
-CONFIG:
-  type: git
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml
deleted file mode 100644 (file)
index ca9c1d3..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-HOSTS:
-  'centos-6-vcloud':
-    roles:
-      - master
-    platform: el-6-x86_64
-    hypervisor: vcloud
-    template: centos-6-x86_64
-CONFIG:
-  type: foss
-  ssh:
-    keys: "~/.ssh/id_rsa-acceptance"
-  datastore: instance0
-  folder: Delivery/Quality Assurance/Enterprise/Dynamic
-  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
-  pooling_api: http://vcloud.delivery.puppetlabs.net/
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml
deleted file mode 100644 (file)
index 7d9242f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-HOSTS:
-  centos-64-x64:
-    roles:
-      - master
-      - database
-      - dashboard
-    platform: el-6-x86_64
-    box : centos-64-x64-vbox4210-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
-    hypervisor : vagrant
-CONFIG:
-  type: pe
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml
deleted file mode 100644 (file)
index 05540ed..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
-  centos-64-x64:
-    roles:
-      - master
-    platform: el-6-x86_64
-    box : centos-64-x64-vbox4210-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
-    hypervisor : vagrant
-CONFIG:
-  type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml
deleted file mode 100644 (file)
index 4e2cb80..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
-  centos-65-x64:
-    roles:
-      - master
-    platform: el-6-x86_64
-    box : centos-65-x64-vbox436-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
-    hypervisor : vagrant
-CONFIG:
-  type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-7-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/centos-7-x64.yml
new file mode 100644 (file)
index 0000000..5eebdef
--- /dev/null
@@ -0,0 +1,10 @@
+HOSTS:
+  centos-7-x64:
+    roles:
+      - agent
+      - default
+    platform: el-7-x86_64
+    hypervisor: vagrant
+    box: puppetlabs/centos-7.2-64-nocm
+CONFIG:
+  type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/debian-8-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/debian-8-x64.yml
new file mode 100644 (file)
index 0000000..fef6e63
--- /dev/null
@@ -0,0 +1,10 @@
+HOSTS:
+  debian-8-x64:
+    roles:
+      - agent
+      - default
+    platform: debian-8-amd64
+    hypervisor: vagrant
+    box: puppetlabs/debian-8.2-64-nocm
+CONFIG:
+  type: foss
index 4e2cb80..dba339c 100644 (file)
@@ -1,10 +1,10 @@
 HOSTS:
-  centos-65-x64:
+  ubuntu-1404-x64:
     roles:
-      - master
-    platform: el-6-x86_64
-    box : centos-65-x64-vbox436-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
-    hypervisor : vagrant
+      - agent
+      - default
+    platform: ubuntu-14.04-amd64
+    hypervisor: vagrant
+    box: puppetlabs/ubuntu-14.04-64-nocm
 CONFIG:
   type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/centos-7.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/centos-7.yml
new file mode 100644 (file)
index 0000000..a3333aa
--- /dev/null
@@ -0,0 +1,12 @@
+HOSTS:
+  centos-7-x64:
+    platform: el-7-x86_64
+    hypervisor: docker
+    image: centos:7
+    docker_preserve_image: true
+    docker_cmd: '["/usr/sbin/init"]'
+    # install various tools required to get the image up to usable levels
+    docker_image_commands:
+      - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts'
+CONFIG:
+  trace_limit: 200
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/debian-8.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/debian-8.yml
new file mode 100644 (file)
index 0000000..df5c319
--- /dev/null
@@ -0,0 +1,11 @@
+HOSTS:
+  debian-8-x64:
+    platform: debian-8-amd64
+    hypervisor: docker
+    image: debian:8
+    docker_preserve_image: true
+    docker_cmd: '["/sbin/init"]'
+    docker_image_commands:
+      - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen'
+CONFIG:
+  trace_limit: 200
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/docker/ubuntu-14.04.yml
new file mode 100644 (file)
index 0000000..b1efa58
--- /dev/null
@@ -0,0 +1,12 @@
+HOSTS:
+  ubuntu-1404-x64:
+    platform: ubuntu-14.04-amd64
+    hypervisor: docker
+    image: ubuntu:14.04
+    docker_preserve_image: true
+    docker_cmd: '["/sbin/init"]'
+    docker_image_commands:
+      # ensure that upstart is booting correctly in the container
+      - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8'
+CONFIG:
+  trace_limit: 200
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml
deleted file mode 100644 (file)
index 1361649..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
-  fedora-18-x64:
-    roles:
-      - master
-    platform: fedora-18-x86_64
-    box : fedora-18-x64-vbox4210-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box
-    hypervisor : vagrant
-CONFIG:
-  type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml
deleted file mode 100644 (file)
index 41abe21..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
-  sles-11-x64.local:
-    roles:
-      - master
-    platform: sles-11-x64
-    box : sles-11sp1-x64-vbox4210-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box
-    hypervisor : vagrant
-CONFIG:
-    type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml
deleted file mode 100644 (file)
index 5ca1514..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
-  ubuntu-server-10044-x64:
-    roles:
-      - master
-    platform: ubuntu-10.04-amd64
-    box : ubuntu-server-10044-x64-vbox4210-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
-    hypervisor : vagrant
-CONFIG:
-  type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
deleted file mode 100644 (file)
index d065b30..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
-  ubuntu-server-12042-x64:
-    roles:
-      - master
-    platform: ubuntu-12.04-amd64
-    box : ubuntu-server-12042-x64-vbox4210-nocm
-    box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
-    hypervisor : vagrant
-CONFIG:
-  type: foss
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
deleted file mode 100644 (file)
index cba1cd0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-HOSTS:
-  ubuntu-server-1404-x64:
-    roles:
-      - master
-    platform: ubuntu-14.04-amd64
-    box : puppetlabs/ubuntu-14.04-64-nocm
-    box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
-    hypervisor : vagrant
-CONFIG:
-  log_level   : debug
-  type: git
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml
deleted file mode 100644 (file)
index 47dadbd..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
-  ubuntu1204:
-    roles:
-      - master
-      - database
-      - dashboard
-    platform: ubuntu-12.04-amd64
-    template: ubuntu-1204-x86_64
-    hypervisor: vcloud
-  win2003_i386:
-    roles:
-      - agent
-      - default
-    platform: windows-2003-i386
-    template: win-2003-i386
-    hypervisor: vcloud
-CONFIG:
-  nfs_server: none
-  ssh:
-    keys: "~/.ssh/id_rsa-acceptance"
-  consoleport: 443
-  datastore: instance0
-  folder: Delivery/Quality Assurance/Enterprise/Dynamic
-  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
-  pooling_api: http://vcloud.delivery.puppetlabs.net/
-  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml
deleted file mode 100644 (file)
index 6a884bc..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
-  ubuntu1204:
-    roles:
-      - master
-      - database
-      - dashboard
-    platform: ubuntu-12.04-amd64
-    template: ubuntu-1204-x86_64
-    hypervisor: vcloud
-  win2003_x86_64:
-    roles:
-      - agent
-      - default
-    platform: windows-2003-x86_64
-    template: win-2003-x86_64
-    hypervisor: vcloud
-CONFIG:
-  nfs_server: none
-  ssh:
-    keys: "~/.ssh/id_rsa-acceptance"
-  consoleport: 443
-  datastore: instance0
-  folder: Delivery/Quality Assurance/Enterprise/Dynamic
-  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
-  pooling_api: http://vcloud.delivery.puppetlabs.net/
-  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml
deleted file mode 100644 (file)
index ae3c11d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
-  ubuntu1204:
-    roles:
-      - master
-      - database
-      - dashboard
-    platform: ubuntu-12.04-amd64
-    template: ubuntu-1204-x86_64
-    hypervisor: vcloud
-  win2008_x86_64:
-    roles:
-      - agent
-      - default
-    platform: windows-2008-x86_64
-    template: win-2008-x86_64
-    hypervisor: vcloud
-CONFIG:
-  nfs_server: none
-  ssh:
-    keys: "~/.ssh/id_rsa-acceptance"
-  consoleport: 443
-  datastore: instance0
-  folder: Delivery/Quality Assurance/Enterprise/Dynamic
-  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
-  pooling_api: http://vcloud.delivery.puppetlabs.net/
-  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml
deleted file mode 100644 (file)
index 63923ac..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
-  ubuntu1204:
-    roles:
-      - master
-      - database
-      - dashboard
-    platform: ubuntu-12.04-amd64
-    template: ubuntu-1204-x86_64
-    hypervisor: vcloud
-  win2008r2:
-    roles:
-      - agent
-      - default
-    platform: windows-2008r2-x86_64
-    template: win-2008r2-x86_64
-    hypervisor: vcloud
-CONFIG:
-  nfs_server: none
-  ssh:
-    keys: "~/.ssh/id_rsa-acceptance"
-  consoleport: 443
-  datastore: instance0
-  folder: Delivery/Quality Assurance/Enterprise/Dynamic
-  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
-  pooling_api: http://vcloud.delivery.puppetlabs.net/
-  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml
deleted file mode 100644 (file)
index eaa4eca..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
-  ubuntu1204:
-    roles:
-      - master
-      - database
-      - dashboard
-    platform: ubuntu-12.04-amd64
-    template: ubuntu-1204-x86_64
-    hypervisor: vcloud
-  win2012:
-    roles:
-      - agent
-      - default
-    platform: windows-2012-x86_64
-    template: win-2012-x86_64
-    hypervisor: vcloud
-CONFIG:
-  nfs_server: none
-  ssh:
-    keys: "~/.ssh/id_rsa-acceptance"
-  consoleport: 443
-  datastore: instance0
-  folder: Delivery/Quality Assurance/Enterprise/Dynamic
-  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
-  pooling_api: http://vcloud.delivery.puppetlabs.net/
-  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml b/3rdparty/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml
deleted file mode 100644 (file)
index 1f0ea97..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
-  ubuntu1204:
-    roles:
-      - master
-      - database
-      - dashboard
-    platform: ubuntu-12.04-amd64
-    template: ubuntu-1204-x86_64
-    hypervisor: vcloud
-  win2012r2:
-    roles:
-      - agent
-      - default
-    platform: windows-2012r2-x86_64
-    template: win-2012r2-x86_64
-    hypervisor: vcloud
-CONFIG:
-  nfs_server: none
-  ssh:
-    keys: "~/.ssh/id_rsa-acceptance"
-  consoleport: 443
-  datastore: instance0
-  folder: Delivery/Quality Assurance/Enterprise/Dynamic
-  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
-  pooling_api: http://vcloud.delivery.puppetlabs.net/
-  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
index 1d99ba0..00d0ddc 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'num2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'num2bool function' do
   describe 'success' do
     it 'bools positive numbers and numeric strings as true' do
       pp = <<-EOS
index 5097810..52133e4 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'parsejson function' do
   describe 'success' do
     it 'parses valid json' do
       pp = <<-EOS
@@ -16,7 +16,20 @@ describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
       end
     end
   end
+
   describe 'failure' do
+    it 'raises error on incorrect json' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+
     it 'raises error on incorrect json' do
       pp = <<-EOS
       $a = '{"hunter": "washere", "tests": "passing",}'
@@ -29,6 +42,14 @@ describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
       end
     end
 
-    it 'raises error on incorrect number of arguments'
+    it 'raises error on incorrect number of arguments' do
+      pp = <<-EOS
+      $o = parsejson()
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/wrong number of arguments/i)
+      end
+    end
   end
 end
index 5819837..acbda46 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'parseyaml function' do
   describe 'success' do
     it 'parses valid yaml' do
       pp = <<-EOS
@@ -16,7 +16,21 @@ describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
       end
     end
   end
+
   describe 'failure' do
+    it 'returns the default value on incorrect yaml' do
+      pp = <<-EOS
+      $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"/)
+      end
+    end
+
     it 'raises error on incorrect yaml' do
       pp = <<-EOS
       $a = "---\nhunter: washere\ntests: passing\n:"
@@ -30,6 +44,15 @@ describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
       end
     end
 
-    it 'raises error on incorrect number of arguments'
+
+    it 'raises error on incorrect number of arguments' do
+      pp = <<-EOS
+      $o = parseyaml()
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/wrong number of arguments/i)
+      end
+    end
   end
 end
index a663f54..e7e25ab 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'pick_default function' do
   describe 'success' do
     it 'pick_defaults a default value' do
       pp = <<-EOS
index 46cf63f..c70b2d9 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'pick function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'pick function' do
   describe 'success' do
     it 'picks a default value' do
       pp = <<-EOS
index de55530..58c691d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'prefix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'prefix function' do
   describe 'success' do
     it 'prefixes array of values' do
       pp = <<-EOS
index eddb782..829d087 100644 (file)
@@ -2,7 +2,7 @@
 require 'spec_helper_acceptance'
 
 # Windows and OS X do not have useful implementations of crypt(3)
-describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin']).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
index a3ccd33..f57f884 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'range function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'range function' do
   describe 'success' do
     it 'ranges letters' do
       pp = <<-EOS
index 7f16a00..ce4342d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'reject function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'reject function' do
   describe 'success' do
     it 'rejects array of values' do
       pp = <<-EOS
index c3f0156..3b5dfad 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'reverse function' do
   describe 'success' do
     it 'reverses strings' do
       pp = <<-EOS
index b57a8b0..150dac1 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'rstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'rstrip function' do
   describe 'success' do
     it 'rstrips arrays' do
       pp = <<-EOS
index b840d1f..0738383 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'shuffle function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'shuffle function' do
   describe 'success' do
     it 'shuffles arrays' do
       pp = <<-EOS
index a52b778..6390c20 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'size function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'size function' do
   describe 'success' do
     it 'single string size' do
       pp = <<-EOS
index c85bfab..e7ff7f7 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'sort function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'sort function' do
   describe 'success' do
     it 'sorts arrays' do
       pp = <<-EOS
index 400a458..3324691 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'squeeze function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'squeeze function' do
   describe 'success' do
     it 'squeezes arrays' do
       pp = <<-EOS
index cf549da..9a8c06c 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'str2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'str2bool function' do
   describe 'success' do
     it 'works with "y"' do
       pp = <<-EOS
index 993e63b..5f03924 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'str2saltedsha512 function' do
   describe 'success' do
     it 'works with "y"' do
       pp = <<-EOS
index 53b7f90..38521b0 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'strftime function' do
   describe 'success' do
     it 'gives the Century' do
       pp = <<-EOS
index 906fd7a..05cd395 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'strip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'strip function' do
   describe 'success' do
     it 'strips arrays' do
       pp = <<-EOS
index 630f866..60a6264 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'suffix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'suffix function' do
   describe 'success' do
     it 'suffixes array of values' do
       pp = <<-EOS
index b7894fb..9f94c0d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'swapcase function' do
   describe 'success' do
     it 'works with strings' do
       pp = <<-EOS
index cdb2960..dae1166 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'time function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'time function' do
   describe 'success' do
     it 'gives the time' do
       pp = <<-EOS
index 2b4c61f..b1015a3 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'to_bytes function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'to_bytes function' do
   describe 'success' do
     it 'converts kB to B' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb
new file mode 100755 (executable)
index 0000000..716241c
--- /dev/null
@@ -0,0 +1,47 @@
+#! /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
+      $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"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'uses a default value' do
+      pp = <<-EOS
+      $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/)
+      end
+    end
+
+    it 'raises error on incorrect number of arguments' do
+      pp = <<-EOS
+      $o = try_get_value()
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/wrong number of arguments/i)
+      end
+    end
+  end
+end
index 67e3248..5cc9470 100755 (executable)
@@ -1,29 +1,29 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || is_future_parser_enabled?) do
+describe 'type function' do
   describe 'success' do
     it 'types arrays' do
       pp = <<-EOS
       $a = ["the","public","art","galleries"]
       # Anagram: Large picture halls, I bet
       $o = type($a)
-      notice(inline_template('type is <%= @o.inspect %>'))
+      notice(inline_template('type is <%= @o.to_s %>'))
       EOS
 
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/type is "array"/)
+        expect(r.stdout).to match(/type is Tuple\[String.*, String.*, String.*, String.*\]/)
       end
     end
     it 'types strings' do
       pp = <<-EOS
       $a = "blowzy night-frumps vex'd jack q"
       $o = type($a)
-      notice(inline_template('type is <%= @o.inspect %>'))
+      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"/)
+        expect(r.stdout).to match(/type is String/)
       end
     end
     it 'types hashes'
index 6db8d0c..7229bf5 100755 (executable)
@@ -1,14 +1,15 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'union function' do
   describe 'success' do
     it 'unions arrays' do
       pp = <<-EOS
       $a = ["the","public"]
-      $b = ["art","galleries"]
+      $b = ["art"]
+      $c = ["galleries"]
       # Anagram: Large picture halls, I bet
-      $o = union($a,$b)
+      $o = union($a,$b,$c)
       notice(inline_template('union is <%= @o.inspect %>'))
       EOS
 
index bfadad1..7fb5eca 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'unique function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'unique function' do
   describe 'success' do
     it 'uniques arrays' do
       pp = <<-EOS
diff --git a/3rdparty/modules/stdlib/spec/acceptance/unsupported_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/unsupported_spec.rb
deleted file mode 100755 (executable)
index 1c559f6..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'spec_helper_acceptance'
-
-describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
-  it 'should fail' do
-    pp = <<-EOS
-    class { 'mysql::server': }
-    EOS
-    expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i)
-  end
-end
index 3d2906d..1782309 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'upcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'upcase function' do
   describe 'success' do
     it 'upcases arrays' do
       pp = <<-EOS
index 7e30205..e123425 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'uriescape function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'uriescape function' do
   describe 'success' do
     it 'uriescape strings' do
       pp = <<-EOS
index 7082e84..880850d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_absolute_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_absolute_path function' do
   describe 'success' do
     %w{
       C:/
index b53e98c..a76321d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_array function' do
   describe 'success' do
     it 'validates a single argument' do
       pp = <<-EOS
@@ -20,14 +20,14 @@ describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fa
 
       apply_manifest(pp, :catch_failures => true)
     end
-    it 'validates a non-array' do
-      {
-        %{validate_array({'a' => 'hash' })} => "Hash",
-        %{validate_array('string')}         => "String",
-        %{validate_array(false)}            => "FalseClass",
-        %{validate_array(undef)}            => "String"
-      }.each do |pp,type|
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+    [
+      %{validate_array({'a' => 'hash' })},
+      %{validate_array('string')},
+      %{validate_array(false)},
+      %{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/)
       end
     end
   end
index 71a4c84..be213d3 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_augeas function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows')) do
+describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do
   describe 'prep' do
     it 'installs augeas for tests'
   end
index c837f08..993f9ef 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_bool function' do
   describe 'success' do
     it 'validates a single argument' do
       pp = <<-EOS
@@ -20,14 +20,14 @@ describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fac
 
       apply_manifest(pp, :catch_failures => true)
     end
-    it 'validates a non-bool' do
-      {
-        %{validate_bool('true')}  => "String",
-        %{validate_bool('false')} => "String",
-        %{validate_bool([true])}  => "Array",
-        %{validate_bool(undef)}   => "String",
-      }.each do |pp,type|
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+    [
+      %{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/)
       end
     end
   end
index 5ac66fd..5fc7b94 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_cmd function' do
   describe 'success' do
     it 'validates a true command' do
       pp = <<-EOS
index 52fb615..fc0f079 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_hash function' do
   describe 'success' do
     it 'validates a single argument' do
       pp = <<-EOS
@@ -20,14 +20,14 @@ describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fac
 
       apply_manifest(pp, :catch_failures => true)
     end
-    it 'validates a non-hash' do
-      {
-        %{validate_hash('{ "not" => "hash" }')} => "String",
-        %{validate_hash('string')}              => "String",
-        %{validate_hash(["array"])}             => "Array",
-        %{validate_hash(undef)}                 => "String",
-      }.each do |pp,type|
-        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+    [
+      %{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(//)
       end
     end
   end
index 64841c3..67d3139 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_ipv4_address function' do
   describe 'success' do
     it 'validates a single argument' do
       pp = <<-EOS
index 6426d1a..eaa845d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_ipv6_address function' do
   describe 'success' do
     it 'validates a single argument' do
       pp = <<-EOS
index 22f6d47..eefb286 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_re function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_re function' do
   describe 'success' do
     it 'validates a string' do
       pp = <<-EOS
index 1ab2bb9..c29fd23 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_slength function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_slength function' do
   describe 'success' do
     it 'validates a single string max' do
       pp = <<-EOS
index 8956f48..f04608d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'validate_string function' do
   describe 'success' do
     it 'validates a single argument' do
       pp = <<-EOS
@@ -20,6 +20,13 @@ describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(f
 
       apply_manifest(pp, :catch_failures => true)
     end
+    it 'validates undef' do
+      pp = <<-EOS
+      validate_string(undef)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
     it 'validates a non-string' do
       {
         %{validate_string({ 'a' => 'hash' })} => "Hash",
index da63cf3..eb0bf4f 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'values_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'values_at function' do
   describe 'success' do
     it 'returns a specific value' do
       pp = <<-EOS
index a2eff32..cef1c9d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'values function' do
   describe 'success' do
     it 'returns an array of values' do
       pp = <<-EOS
@@ -13,12 +13,7 @@ describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper
       $output = values($arg)
       notice(inline_template('<%= @output.sort.inspect %>'))
       EOS
-      if is_future_parser_enabled?
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
-      else
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
-      end
-
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
     end
   end
   describe 'failure' do
index 139079e..ae22896 100755 (executable)
@@ -1,8 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
-require 'puppet'
 
-describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'zip function' do
   describe 'success' do
     it 'zips two arrays of numbers together' do
       pp = <<-EOS
@@ -11,11 +10,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
       EOS
-      if is_future_parser_enabled?
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/)
-      else
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/)
-      end
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/)
     end
     it 'zips two arrays of numbers & bools together' do
       pp = <<-EOS
@@ -24,11 +19,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
       EOS
-      if is_future_parser_enabled?
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/)
-      else
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/)
-      end
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[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:
@@ -41,11 +32,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
       $output = zip($one,$two,true)
       notice(inline_template('<%= @output.inspect %>'))
       EOS
-      if is_future_parser_enabled?
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/)
-      else
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/)
-      end
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/)
     end
     it 'handles unmatched length' do
       # XXX Is this expected behavior?
@@ -55,11 +42,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
       EOS
-      if is_future_parser_enabled?
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/)
-      else
-        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/)
-      end
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/)
     end
   end
   describe 'failure' do
@@ -69,7 +52,6 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
       $output = zip($one)
       notice(inline_template('<%= @output.inspect %>'))
       EOS
-
       expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/)
     end
     it 'handles improper argument types' do
@@ -79,7 +61,6 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
       $output = zip($one,$two)
       notice(inline_template('<%= @output.inspect %>'))
       EOS
-
       expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires array/)
     end
   end
diff --git a/3rdparty/modules/stdlib/spec/aliases/absolute_path_spec.rb b/3rdparty/modules/stdlib/spec/aliases/absolute_path_spec.rb
new file mode 100644 (file)
index 0000000..308a3aa
--- /dev/null
@@ -0,0 +1,67 @@
+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
new file mode 100644 (file)
index 0000000..ff23dc0
--- /dev/null
@@ -0,0 +1,50 @@
+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
new file mode 100644 (file)
index 0000000..89cc2af
--- /dev/null
@@ -0,0 +1,34 @@
+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
new file mode 100644 (file)
index 0000000..b84ab51
--- /dev/null
@@ -0,0 +1,32 @@
+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
new file mode 100644 (file)
index 0000000..84e1934
--- /dev/null
@@ -0,0 +1,28 @@
+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
new file mode 100644 (file)
index 0000000..6e5060d
--- /dev/null
@@ -0,0 +1,32 @@
+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
new file mode 100644 (file)
index 0000000..3e51118
--- /dev/null
@@ -0,0 +1,44 @@
+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
new file mode 100644 (file)
index 0000000..fd49a47
--- /dev/null
@@ -0,0 +1,47 @@
+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
new file mode 100644 (file)
index 0000000..9cf0357
--- /dev/null
@@ -0,0 +1,34 @@
+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
new file mode 100644 (file)
index 0000000..67a555c
--- /dev/null
@@ -0,0 +1,34 @@
+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
new file mode 100644 (file)
index 0000000..6a503ad
--- /dev/null
@@ -0,0 +1,22 @@
+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
new file mode 100644 (file)
index 0000000..ae90f42
--- /dev/null
@@ -0,0 +1,40 @@
+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
new file mode 100644 (file)
index 0000000..09c28ec
--- /dev/null
@@ -0,0 +1,32 @@
+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
new file mode 100644 (file)
index 0000000..4fc8ce6
--- /dev/null
@@ -0,0 +1,32 @@
+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
new file mode 100644 (file)
index 0000000..6aecfe7
--- /dev/null
@@ -0,0 +1,47 @@
+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
new file mode 100644 (file)
index 0000000..c20e373
--- /dev/null
@@ -0,0 +1,47 @@
+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/classes/anchor_spec.rb b/3rdparty/modules/stdlib/spec/classes/anchor_spec.rb
deleted file mode 100755 (executable)
index 2d4455e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'spec_helper'
-require 'puppet_spec/compiler'
-
-describe "anchorrefresh" do
-  include PuppetSpec::Compiler
-
-  let :transaction do
-    apply_compiled_manifest(<<-ANCHORCLASS)
-      class anchored {
-        anchor { 'anchored::begin': }
-        ~> anchor { 'anchored::end': }
-      }
-
-      class anchorrefresh {
-        notify { 'first': }
-        ~> class { 'anchored': }
-        ~> anchor { 'final': }
-      }
-
-      include anchorrefresh
-    ANCHORCLASS
-  end
-
-  it 'propagates events through the anchored class' do
-    resource = transaction.resource_status('Anchor[final]')
-
-    expect(resource.restarted).to eq(true)
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/fixtures/dscacheutil/root b/3rdparty/modules/stdlib/spec/fixtures/dscacheutil/root
new file mode 100644 (file)
index 0000000..1e34519
--- /dev/null
@@ -0,0 +1,8 @@
+name: root
+password: *
+uid: 0
+gid: 0
+dir: /var/root
+shell: /bin/bash
+gecos: rawr Root
+
diff --git a/3rdparty/modules/stdlib/spec/fixtures/lsuser/root b/3rdparty/modules/stdlib/spec/fixtures/lsuser/root
new file mode 100644 (file)
index 0000000..afd59ca
--- /dev/null
@@ -0,0 +1,2 @@
+#name:home
+root:/root
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolute_path.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/absolute_path.pp
new file mode 100644 (file)
index 0000000..d77f6bd
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..8321471
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..84b6a5b
--- /dev/null
@@ -0,0 +1,8 @@
+# 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
new file mode 100644 (file)
index 0000000..ab5b5ea
--- /dev/null
@@ -0,0 +1,8 @@
+# Class to test the Stdlib::Compat::Bool type alias
+class test::bool(
+  Stdlib::Compat::Bool $value,
+  ) {
+
+    notice("Success")
+
+}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/deftype.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/deftype.pp
new file mode 100644 (file)
index 0000000..825f8fe
--- /dev/null
@@ -0,0 +1,3 @@
+define test::deftype($param = 'foo') {
+  notify { "deftype: $title": }
+}
diff --git a/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ensure_resources.pp b/3rdparty/modules/stdlib/spec/fixtures/test/manifests/ensure_resources.pp
new file mode 100644 (file)
index 0000000..bd26002
--- /dev/null
@@ -0,0 +1,4 @@
+# A helper class to test the ensure_resources function
+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
new file mode 100644 (file)
index 0000000..03a603d
--- /dev/null
@@ -0,0 +1,8 @@
+# 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
new file mode 100644 (file)
index 0000000..c243570
--- /dev/null
@@ -0,0 +1,8 @@
+# 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
new file mode 100644 (file)
index 0000000..9d6b92d
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..abf869e
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..a4f26df
--- /dev/null
@@ -0,0 +1,8 @@
+# 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
new file mode 100644 (file)
index 0000000..bbbd804
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..2e8022d
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..7912fd6
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..2657ebc
--- /dev/null
@@ -0,0 +1,8 @@
+# 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
new file mode 100644 (file)
index 0000000..6508c70
--- /dev/null
@@ -0,0 +1,8 @@
+# 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
new file mode 100644 (file)
index 0000000..9311109
--- /dev/null
@@ -0,0 +1,6 @@
+# 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
new file mode 100644 (file)
index 0000000..af93ed3
--- /dev/null
@@ -0,0 +1,6 @@
+# Class to test the Stdlib::Windowspath type alias
+class test::windowspath(
+    Stdlib::Windowspath $value,
+    ) {
+  notice("Success")
+}
index 3c25ce2..7d2257b 100755 (executable)
@@ -1,25 +1,30 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the abs function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("abs")).to eq("function_abs")
-  end
+describe 'abs' do
+  it { is_expected.not_to eq(nil) }
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_abs([]) }.to( raise_error(Puppet::ParseError))
+  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
 
-  it "should convert a negative number into a positive" do
-    result = scope.function_abs(["-34"])
-    expect(result).to(eq(34))
+  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) }
   end
 
-  it "should do nothing with a positive number" do
-    result = scope.function_abs(["5678"])
-    expect(result).to(eq(5678))
-  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
index 87cd04b..631657f 100755 (executable)
@@ -1,55 +1,21 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the any2array function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("any2array")).to eq("function_any2array")
-  end
-
-  it "should return an empty array if there is less than 1 argument" do
-    result = scope.function_any2array([])
-    expect(result).to(eq([]))
-  end
-
-  it "should convert boolean true to [ true ] " do
-    result = scope.function_any2array([true])
-    expect(result).to(eq([true]))
-  end
-
-  it "should convert one object to [object]" do
-    result = scope.function_any2array(['one'])
-    expect(result).to(eq(['one']))
-  end
-
-  it "should convert multiple objects to [objects]" do
-    result = scope.function_any2array(['one', 'two'])
-    expect(result).to(eq(['one', 'two']))
-  end
-
-  it "should return empty array it was called with" do
-    result = scope.function_any2array([[]])
-    expect(result).to(eq([]))
-  end
-
-  it "should return one-member array it was called with" do
-    result = scope.function_any2array([['string']])
-    expect(result).to(eq(['string']))
-  end
-
-  it "should return multi-member array it was called with" do
-    result = scope.function_any2array([['one', 'two']])
-    expect(result).to(eq(['one', 'two']))
-  end
-
-  it "should return members of a hash it was called with" do
-    result = scope.function_any2array([{ 'key' => 'value' }])
-    expect(result).to(eq(['key', 'value']))
-  end
-
-  it "should return an empty array if it was called with an empty hash" do
-    result = scope.function_any2array([{ }])
-    expect(result).to(eq([]))
-  end
+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(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']) }
+  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', '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('‰').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('€', '万', 'Ö', '♥', '割').and_return(['€', '万', 'Ö', '♥', '割']) }
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/any2bool_spec.rb b/3rdparty/modules/stdlib/spec/functions/any2bool_spec.rb
new file mode 100755 (executable)
index 0000000..9d351ce
--- /dev/null
@@ -0,0 +1,42 @@
+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(true).and_return(true) }
+  it { is_expected.to run.with_params(false).and_return(false) }
+
+  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|
+      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|
+      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|
+      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|
+      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|
+      it { is_expected.to run.with_params(value).and_return(true) }
+    end
+  end
+
+end
index a009d28..355e0dd 100755 (executable)
@@ -1,43 +1,30 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:assert_private) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  subject do
-    function_name = Puppet::Parser::Functions.function(:assert_private)
-    scope.method(function_name)
-  end
-
-  context "when called from inside module" do
+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')
-      expect {
-        subject.call []
-      }.not_to raise_error
+
+      is_expected.to run.with_params()
     end
   end
 
-  context "with an explicit failure message" do
-    it "prints the failure message on error" do
+  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')
-      expect {
-        subject.call ['failure message!']
-      }.to raise_error Puppet::ParseError, /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/
+
+      is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /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!/) }
     end
   end
 
@@ -47,9 +34,8 @@ describe Puppet::Parser::Functions.function(:assert_private) do
       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/
+
+      is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Definition foo::baz is private/)
     end
   end
 end
index e93fafc..842a37a 100755 (executable)
@@ -1,34 +1,37 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the base64 function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("base64")).to eq("function_base64")
-  end
-
-  it "should raise a ParseError if there are other than 2 arguments" do
-    expect { scope.function_base64([]) }.to(raise_error(Puppet::ParseError))
-    expect { scope.function_base64(["asdf"]) }.to(raise_error(Puppet::ParseError))
-    expect { scope.function_base64(["asdf","moo","cow"]) }.to(raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if argument 1 isn't 'encode' or 'decode'" do
-    expect { scope.function_base64(["bees","astring"]) }.to(raise_error(Puppet::ParseError, /first argument must be one of/))
-  end
-
-  it "should raise a ParseError if argument 2 isn't a string" do
-    expect { scope.function_base64(["encode",["2"]]) }.to(raise_error(Puppet::ParseError, /second argument must be a string/))
-  end
-
-  it "should encode a encoded string" do
-    result = scope.function_base64(["encode",'thestring'])
-    expect(result).to match(/\AdGhlc3RyaW5n\n\Z/)
-  end
-  it "should decode a base64 encoded string" do
-    result = scope.function_base64(["decode",'dGhlc3RyaW5n'])
-    expect(result).to eq('thestring')
-  end
+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") }
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/basename_spec.rb b/3rdparty/modules/stdlib/spec/functions/basename_spec.rb
new file mode 100755 (executable)
index 0000000..3e02b01
--- /dev/null
@@ -0,0 +1,19 @@
+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('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) }
+  it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('file.ext') }
+  it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('file.ext') }
+  it { is_expected.to run.with_params('/path/to/a/file.ext', '.ext').and_return('file') }
+  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
+    it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('竹.ext') }
+    it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ', '.ㄘ').and_return('竹') }
+  end
+end
index 3904d7e..e506859 100755 (executable)
@@ -1,38 +1,14 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the bool2num function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'bool2num' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("bool2num")).to eq("function_bool2num")
+  [ true, 'true', AlsoString.new('true') ].each do |truthy|
+    it { is_expected.to run.with_params(truthy).and_return(1) }
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_bool2num([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should convert true to 1" do
-    result = scope.function_bool2num([true])
-    expect(result).to(eq(1))
-  end
-
-  it "should convert 'true' to 1" do
-    result = scope.function_bool2num(['true'])
-    result.should(eq(1))
-  end
-
-  it "should convert 'false' to 0" do
-    result = scope.function_bool2num(['false'])
-    expect(result).to(eq(0))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new('true')
-    result = scope.function_bool2num([value])
-    result.should(eq(1))
+  [ false, 'false', AlsoString.new('false') ].each do |falsey|
+    it { is_expected.to run.with_params(falsey).and_return(0) }
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/bool2str_spec.rb b/3rdparty/modules/stdlib/spec/functions/bool2str_spec.rb
new file mode 100755 (executable)
index 0000000..23a754b
--- /dev/null
@@ -0,0 +1,17 @@
+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(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") }
+
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/camelcase_spec.rb b/3rdparty/modules/stdlib/spec/functions/camelcase_spec.rb
new file mode 100755 (executable)
index 0000000..c78aa62
--- /dev/null
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe 'camelcase' 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(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([]).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"]) }
+end
index fd0e92b..7ce2e16 100755 (executable)
@@ -1,28 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the capitalize function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("capitalize")).to eq("function_capitalize")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_capitalize([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should capitalize the beginning of a string" do
-    result = scope.function_capitalize(["abc"])
-    expect(result).to(eq("Abc"))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new('abc')
-    result = scope.function_capitalize([value])
-    result.should(eq('Abc'))
-  end
+describe 'capitalize' 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(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(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"]) }
 end
index 814aa7c..567426f 100755 (executable)
@@ -1,39 +1,13 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the ceiling function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("ceiling")).to eq("function_ceiling")
-  end
-
-  it "should raise a ParseError if there is less than 1 argument" do
-    expect { scope.function_ceiling([]) }.to( raise_error(Puppet::ParseError, /Wrong number of arguments/))
-  end
-
-  it "should should raise a ParseError if input isn't numeric (eg. String)" do
-    expect { scope.function_ceiling(["foo"]) }.to( raise_error(Puppet::ParseError, /Wrong argument type/))
-  end
-
-  it "should should raise a ParseError if input isn't numeric (eg. Boolean)" do
-    expect { scope.function_ceiling([true]) }.to( raise_error(Puppet::ParseError, /Wrong argument type/))
-  end
-
-  it "should return an integer when a numeric type is passed" do
-    result = scope.function_ceiling([12.4])
-    expect(result.is_a?(Integer)).to(eq(true))
-  end
-
-  it "should return the input when an integer is passed" do
-    result = scope.function_ceiling([7])
-    expect(result).to(eq(7))
-  end
-
-  it "should return the smallest integer greater than or equal to the input" do
-    result = scope.function_ceiling([3.8])
-    expect(result).to(eq(4))
-  end
+describe 'ceiling' 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(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
 
index b1e1e60..56bd9b1 100755 (executable)
@@ -1,28 +1,25 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the chomp function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'chomp' 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(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)
+  }
+  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 "should exist" do
-    expect(Puppet::Parser::Functions.function("chomp")).to eq("function_chomp")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_chomp([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should chomp the end of a string" do
-    result = scope.function_chomp(["abc\n"])
-    expect(result).to(eq("abc"))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
+  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"]) }
 
-    value = AlsoString.new("abc\n")
-    result = scope.function_chomp([value])
-    result.should(eq("abc"))
+  context 'should run 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
 end
index c8a1951..b70fc37 100755 (executable)
@@ -1,28 +1,25 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the chop function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'chop' 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(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)
+  }
+  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 "should exist" do
-    expect(Puppet::Parser::Functions.function("chop")).to eq("function_chop")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_chop([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should chop the end of a string" do
-    result = scope.function_chop(["asdf\n"])
-    expect(result).to(eq("asdf"))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
+  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"]) }
 
-    value = AlsoString.new("abc\n")
-    result = scope.function_chop([value])
-    result.should(eq('abc'))
+  context 'should run 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
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/clamp_spec.rb b/3rdparty/modules/stdlib/spec/functions/clamp_spec.rb
new file mode 100644 (file)
index 0000000..3e2fe7a
--- /dev/null
@@ -0,0 +1,16 @@
+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(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('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) }
+  it { is_expected.to run.with_params([3, 873], 73).and_return(73) }
+  it { is_expected.to run.with_params([4], 8, 75).and_return(8) }
+  it { is_expected.to run.with_params([6], [31], 9911).and_return(31) }
+end
index 49fa6bb..6ab1b6e 100755 (executable)
@@ -1,50 +1,29 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the concat function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should raise a ParseError if the client does not provide at least two arguments" do
-    expect { scope.function_concat([]) }.to(raise_error(Puppet::ParseError))
-    expect { scope.function_concat([[1]]) }.to(raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if the first parameter is not an array" do
-    expect { scope.function_concat([1, []])}.to(raise_error(Puppet::ParseError))
-  end
-
-  it "should not raise a ParseError if the client provides more than two arguments" do
-    expect { scope.function_concat([[1],[2],[3]]) }.not_to raise_error
-  end
-
-  it "should be able to concat an array" do
-    result = scope.function_concat([['1','2','3'],['4','5','6']])
-    expect(result).to(eq(['1','2','3','4','5','6']))
-  end
-
-  it "should be able to concat a primitive to an array" do
-    result = scope.function_concat([['1','2','3'],'4'])
-    expect(result).to(eq(['1','2','3','4']))
-  end
-
-  it "should not accidentally flatten nested arrays" do
-    result = scope.function_concat([['1','2','3'],[['4','5'],'6']])
-    expect(result).to(eq(['1','2','3',['4','5'],'6']))
-  end
+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([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']) }
+
+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
 
   it "should leave the original array intact" do
-    array_original = ['1','2','3']
-    result = scope.function_concat([array_original,['4','5','6']])
-    array_original.should(eq(['1','2','3']))
-  end
-
-  it "should be able to concat multiple arrays" do
-    result = scope.function_concat([['1','2','3'],['4','5','6'],['7','8','9']])
-    expect(result).to(eq(['1','2','3','4','5','6','7','8','9']))
-  end
-
-  it "should be able to concat mix of primitives and arrays to a final array" do
-    result = scope.function_concat([['1','2','3'],'4',['5','6','7']])
-    expect(result).to(eq(['1','2','3','4','5','6','7']))
+    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)
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/convert_base_spec.rb b/3rdparty/modules/stdlib/spec/functions/convert_base_spec.rb
new file mode 100644 (file)
index 0000000..8ab2284
--- /dev/null
@@ -0,0 +1,24 @@
+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 "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/)
+  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/)
+  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(5, 2).and_return('101') }
+end
index f8f1d48..3854cb8 100755 (executable)
@@ -1,31 +1,23 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the count function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("count")).to eq("function_count")
-  end
-
-  it "should raise a ArgumentError if there is more than 2 arguments" do
-    expect { scope.function_count(['foo', 'bar', 'baz']) }.to( raise_error(ArgumentError))
-  end
-
-  it "should be able to count arrays" do
-    expect(scope.function_count([["1","2","3"]])).to(eq(3))
-  end
-
-  it "should be able to count matching elements in arrays" do
-    expect(scope.function_count([["1", "2", "2"], "2"])).to(eq(2))
-  end
-
-  it "should not count nil or empty strings" do
-    expect(scope.function_count([["foo","bar",nil,""]])).to(eq(2))
-  end
-
-  it 'does not count an undefined hash key or an out of bound array index (which are both :undef)' do
-    expect(scope.function_count([["foo",:undef,:undef]])).to eq(1)
-  end
+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 {
+    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(["ổņ℮", "ŧщộ", "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
index 7087904..819e025 100755 (executable)
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:deep_merge) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe 'when calling deep_merge from puppet' do
-    it "should not compile when no arguments are passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = '$x = deep_merge()'
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
-
-    it "should not compile when 1 argument is passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = "$my_hash={'one' => 1}\n$x = deep_merge($my_hash)"
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
+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_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'}) }
+
+  describe 'when arguments have key collisions' do
+    it 'should prefer 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'})
+    end
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1'}, {'key1' => 'value2'}, {'key1' => 'value3'}) \
+      .and_return({'key1' => 'value3' })
+    }
   end
 
-  describe 'when calling deep_merge on the scope instance' do
-    it 'should require all parameters are hashes' do
-      expect { new_hash = scope.function_deep_merge([{}, '2'])}.to raise_error(Puppet::ParseError, /unexpected argument type String/)
-      expect { new_hash = scope.function_deep_merge([{}, 2])}.to raise_error(Puppet::ParseError, /unexpected argument type Fixnum/)
-    end
-
-    it 'should accept empty strings as puppet undef' do
-      expect { new_hash = scope.function_deep_merge([{}, ''])}.not_to raise_error
-    end
-
-    it 'should be able to deep_merge two hashes' do
-      new_hash = scope.function_deep_merge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}])
-      expect(new_hash['one']).to   eq('1')
-      expect(new_hash['two']).to   eq('2')
-      expect(new_hash['three']).to eq('2')
-    end
-
-    it 'should deep_merge multiple hashes' do
-      hash = scope.function_deep_merge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}])
-      expect(hash['one']).to eq('3')
-    end
-
-    it 'should accept empty hashes' do
-      expect(scope.function_deep_merge([{},{},{}])).to eq({})
-    end
-
-    it 'should deep_merge subhashes' do
-      hash = scope.function_deep_merge([{'one' => 1}, {'two' => 2, 'three' => { 'four' => 4 } }])
-      expect(hash['one']).to eq(1)
-      expect(hash['two']).to eq(2)
-      expect(hash['three']).to eq({ 'four' => 4 })
-    end
-
-    it 'should append to subhashes' do
-      hash = scope.function_deep_merge([{'one' => { 'two' => 2 } }, { 'one' => { 'three' => 3 } }])
-      expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 })
-    end
-
-    it 'should append to subhashes 2' do
-      hash = scope.function_deep_merge([{'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, {'two' => 'dos', 'three' => { 'five' => 5 } }])
-      expect(hash['one']).to eq(1)
-      expect(hash['two']).to eq('dos')
-      expect(hash['three']).to eq({ 'four' => 4, 'five' => 5 })
-    end
-
-    it 'should append to subhashes 3' do
-      hash = scope.function_deep_merge([{ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, { 'key1' => { 'b' => 99 } }])
-      expect(hash['key1']).to eq({ 'a' => 1, 'b' => 99 })
-      expect(hash['key2']).to eq({ 'c' => 3 })
-    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' => {'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'}}})
+    }
+  end
 
-    it 'should not change the original hashes' do
-      hash1 = {'one' => { 'two' => 2 } }
-      hash2 = { 'one' => { 'three' => 3 } }
-      hash = scope.function_deep_merge([hash1, hash2])
-      expect(hash1).to eq({'one' => { 'two' => 2 } })
-      expect(hash2).to eq({ 'one' => { 'three' => 3 } })
-      expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 })
-    end
+  it 'should not change the original hashes' do
+    argument1 = { 'key1' => 'value1' }
+    original1 = argument1.dup
+    argument2 = { 'key2' => 'value2' }
+    original2 = argument2.dup
 
-    it 'should not change the original hashes 2' do
-      hash1 = {'one' => { 'two' => [1,2] } }
-      hash2 = { 'one' => { 'three' => 3 } }
-      hash = scope.function_deep_merge([hash1, hash2])
-      expect(hash1).to eq({'one' => { 'two' => [1,2] } })
-      expect(hash2).to eq({ 'one' => { 'three' => 3 } })
-      expect(hash['one']).to eq({ 'two' => [1,2], 'three' => 3 })
-    end
+    subject.call([argument1, argument2])
+    expect(argument1).to eq(original1)
+    expect(argument2).to eq(original2)
+  end
 
-    it 'should not change the original hashes 3' do
-      hash1 = {'one' => { 'two' => [1,2, {'two' => 2} ] } }
-      hash2 = { 'one' => { 'three' => 3 } }
-      hash = scope.function_deep_merge([hash1, hash2])
-      expect(hash1).to eq({'one' => { 'two' => [1,2, {'two' => 2}] } })
-      expect(hash2).to eq({ 'one' => { 'three' => 3 } })
-      expect(hash['one']).to eq({ 'two' => [1,2, {'two' => 2} ], 'three' => 3 })
-      expect(hash['one']['two']).to eq([1,2, {'two' => 2}])
-    end
+  context 'should run with UTF8 and double byte characters' do
+    it { is_expected.to run.with_params({'ĸέỹ1' => 'ϋǻļủë1'}, {'この文字列' => '万' }).and_return({'ĸέỹ1' => 'ϋǻļủë1', 'この文字列' => '万'}) }
   end
 end
index 3590304..491a03b 100755 (executable)
@@ -1,19 +1,20 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-require 'rspec-puppet'
 describe 'defined_with_params' do
-  describe 'when a resource is not specified' do
+  describe 'when no resource is specified' do
     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 do
-      is_expected.to run.with_params('User[dan]', {}).and_return(true)
-      is_expected.to run.with_params('User[bob]', {}).and_return(false)
-      is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false)
+    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) }
+
+    context 'should run 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
   end
 
@@ -21,17 +22,47 @@ describe 'defined_with_params' do
     let :pre_condition do
       'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
     end
-    it do
-      is_expected.to run.with_params('User[dan]', {}).and_return(true)
-      is_expected.to run.with_params('User[dan]', '').and_return(true)
-      is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}
-                            ).and_return(true)
-      is_expected.to run.with_params('User[dan]',
-                             {'ensure' => 'present', 'managehome' => false}
-                            ).and_return(true)
-      is_expected.to run.with_params('User[dan]',
-                             {'ensure' => 'absent', 'managehome' => false}
-                            ).and_return(false)
+    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) }
+  end
+
+  describe 'when passing undef values' do
+    let :pre_condition do
+      'file { "/tmp/a": ensure => present }'
+    end
+
+    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) }
+  end
+
+  describe 'when the reference is a' do
+    let :pre_condition do
+      'user { "dan": }'
+    end
+    context '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
+        it 'fails' do
+          expect {
+            subject.call([['User[dan]'], {}])
+          }.to raise_error ArgumentError, /not understood: 'Array'/
+        end
+      end
+    end
+  end
+
+  describe 'when passed a defined type' do
+    let :pre_condition do
+      '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
 end
index 7c20aec..0471039 100755 (executable)
@@ -1,25 +1,30 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the delete_at function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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('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.")
+    is_expected.to run.with_params(['one'], 0, 1).and_raise_error(Puppet::ParseError)
+  }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("delete_at")).to eq("function_delete_at")
+  describe 'argument validation' do
+    it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError) }
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_delete_at([]) }.to( raise_error(Puppet::ParseError))
-  end
+  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 "should delete an item at specified location from an array" do
-    result = scope.function_delete_at([['a','b','c'],1])
-    expect(result).to(eq(['a','c']))
-  end
 
-  it "should not change origin array passed as argument" do
-    origin_array = ['a','b','c','d']
-    result = scope.function_delete_at([origin_array, 1])
-    expect(origin_array).to(eq(['a','b','c','d']))
+  it "should leave the original array intact" do
+    argument = [1, 2, 3]
+    original = argument.dup
+    result = subject.call([argument,2])
+    expect(argument).to eq(original)
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb b/3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb
new file mode 100755 (executable)
index 0000000..f27a946
--- /dev/null
@@ -0,0 +1,54 @@
+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([], 'two') }
+  it { is_expected.to run.with_params({}, 'two') }
+  it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], 'two', 'three', 'four').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
+
+  describe 'deleting from an array' do
+    it { is_expected.to run.with_params([], '').and_return([]) }
+    it { is_expected.to run.with_params([], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['two'], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], '^t.*').and_return(['one']) }
+    it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) }
+    it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) }
+    it { is_expected.to run.with_params(['abracadabra'], 'abr').and_return(['abracadabra']) }
+    it { is_expected.to run.with_params(['abracadabra'], '^.*jimbob.*$').and_return(['abracadabra']) }
+  end
+
+  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({'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']
+    original1 = argument1.dup
+    subject.call([argument1,'two'])
+    expect(argument1).to eq(original1)
+  end
+  it "should leave the original hash intact" do
+    argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}
+    original1 = argument1.dup
+    subject.call([argument1,'key2'])
+    expect(argument1).to eq(original1)
+  end
+end
index c8edd78..4e37865 100755 (executable)
@@ -1,61 +1,76 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the delete function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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([], 'two') }
+  it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("delete")).to eq("function_delete")
+  describe 'deleting from an array' do
+    it { is_expected.to run.with_params([], '').and_return([]) }
+    it { is_expected.to run.with_params([], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['two'], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) }
+    it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three', 'two'], ['one', 'two']).and_return(['three']) }
+    it { is_expected.to run.with_params(['ồאּẻ', 'ŧẅơ', 'ŧңŗё℮', 'ŧẅơ'], ['ồאּẻ', 'ŧẅơ']).and_return(['ŧңŗё℮']) }
   end
 
-  it "should raise a ParseError if there are fewer than 2 arguments" do
-    expect { scope.function_delete([]) }.to(raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if there are greater than 2 arguments" do
-    expect { scope.function_delete([[], 'foo', 'bar']) }.to(raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a TypeError if a number is passed as the first argument" do
-    expect { scope.function_delete([1, 'bar']) }.to(raise_error(TypeError))
-  end
-
-  it "should delete all instances of an element from an array" do
-    result = scope.function_delete([['a', 'b', 'c', 'b'], 'b'])
-    expect(result).to(eq(['a', 'c']))
-  end
-
-  it "should delete all instances of a substring from a string" do
-    result = scope.function_delete(['foobarbabarz', 'bar'])
-    expect(result).to(eq('foobaz'))
-  end
+  describe 'deleting from a string' do
+    it { is_expected.to run.with_params('', '').and_return('') }
+    it { is_expected.to run.with_params('bar', '').and_return('bar') }
+    it { is_expected.to run.with_params('', 'bar').and_return('') }
+    it { is_expected.to run.with_params('bar', 'bar').and_return('') }
+    it { is_expected.to run.with_params('barbar', 'bar').and_return('') }
+    it { is_expected.to run.with_params('barfoobar', 'bar').and_return('foo') }
+    it { is_expected.to run.with_params('foobarbabarz', 'bar').and_return('foobaz') }
+    it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') }
+    it { is_expected.to run.with_params('ƒōōβậяβậβậяź', ['ƒōō', 'βậя']).and_return('βậź') }
 
-  it "should delete a key from a hash" do
-    result = scope.function_delete([{'a' => 1, 'b' => 2, 'c' => 3}, 'b'])
-    expect(result).to(eq({'a' => 1, 'c' => 3}))
+    it { is_expected.to run.with_params('barfoobar', ['barbar', 'foo']).and_return('barbar') }
+    it { is_expected.to run.with_params('barfoobar', ['foo', 'barbar']).and_return('') }
   end
 
-  it 'should accept an array of items to delete' do
-    result = scope.function_delete([{'a' => 1, 'b' => 2, 'c' => 3}, ['b', 'c']])
-    expect(result).to(eq({'a' => 1}))
+  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({'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'})
+    }
   end
 
-  it "should not change origin array passed as argument" do
-    origin_array = ['a', 'b', 'c', 'd']
-    result = scope.function_delete([origin_array, 'b'])
-    expect(origin_array).to(eq(['a', 'b', 'c', 'd']))
+  it "should leave the original array intact" do
+    argument1 = ['one','two','three']
+    original1 = argument1.dup
+    result = subject.call([argument1,'two'])
+    expect(argument1).to eq(original1)
   end
-
-  it "should not change the origin string passed as argument" do
-    origin_string = 'foobarbabarz'
-    result = scope.function_delete([origin_string, 'bar'])
-    expect(origin_string).to(eq('foobarbabarz'))
+  it "should leave the original string intact" do
+    argument1 = 'onetwothree'
+    original1 = argument1.dup
+    result = subject.call([argument1,'two'])
+    expect(argument1).to eq(original1)
   end
-
-  it "should not change origin hash passed as argument" do
-    origin_hash = {'a' => 1, 'b' => 2, 'c' => 3}
-    result = scope.function_delete([origin_hash, 'b'])
-    expect(origin_hash).to(eq({'a' => 1, 'b' => 2, 'c' => 3}))
+  it "should leave the original hash intact" do
+    argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}
+    original1 = argument1.dup
+    result = subject.call([argument1,'key2'])
+    expect(argument1).to eq(original1)
   end
-
 end
index dc67953..c20cee2 100755 (executable)
@@ -1,41 +1,57 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the delete_undef_values function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("delete_undef_values")).to eq("function_delete_undef_values")
-  end
-
-  it "should raise a ParseError if there is less than 1 argument" do
-    expect { scope.function_delete_undef_values([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if the argument is not Array nor Hash" do
-    expect { scope.function_delete_undef_values(['']) }.to( raise_error(Puppet::ParseError))
-    expect { scope.function_delete_undef_values([nil]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should delete all undef items from Array and only these" do
-    result = scope.function_delete_undef_values([['a',:undef,'c','undef']])
-    expect(result).to(eq(['a','c','undef']))
-  end
-
-  it "should delete all undef items from Hash and only these" do
-    result = scope.function_delete_undef_values([{'a'=>'A','b'=>:undef,'c'=>'C','d'=>'undef'}])
-    expect(result).to(eq({'a'=>'A','c'=>'C','d'=>'undef'}))
-  end
-
-  it "should not change origin array passed as argument" do
-    origin_array = ['a',:undef,'c','undef']
-    result = scope.function_delete_undef_values([origin_array])
-    expect(origin_array).to(eq(['a',:undef,'c','undef']))
+describe 'delete_undef_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(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|
+      describe "when undef is represented by #{undef_value.inspect}" do
+        before 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
+        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(['ớņέ','ŧשּׁō','ŧħґëə']) }
+      end
+
+      it "should leave the original argument intact" do
+        argument = ['one',undef_value,'two']
+        original = argument.dup
+        result = subject.call([argument,2])
+        expect(argument).to eq(original)
+      end
+    end
+
+    it { is_expected.to run.with_params(['undef']).and_return(['undef']) }
   end
 
-  it "should not change origin hash passed as argument" do
-    origin_hash = { 'a' => 1, 'b' => :undef, 'c' => 'undef' }
-    result = scope.function_delete_undef_values([origin_hash])
-    expect(origin_hash).to(eq({ 'a' => 1, 'b' => :undef, 'c' => 'undef' }))
+  describe 'when deleting from a hash' do
+    [ :undef, '', nil ].each do |undef_value|
+      describe "when undef is represented by #{undef_value.inspect}" do
+        before 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
+        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'})
+        }
+      end
+
+      it "should leave the original argument intact" do
+        argument = { 'key1' => 'value1', 'key2' => undef_value }
+        original = argument.dup
+        result = subject.call([argument,2])
+        expect(argument).to eq(original)
+      end
+    end
+
+    it { is_expected.to run.with_params({'key' => 'undef'}).and_return({'key' => 'undef'}) }
   end
 end
index 4f4d411..329fa0b 100755 (executable)
@@ -1,36 +1,41 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the delete_values function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("delete_values")).to eq("function_delete_values")
-  end
-
-  it "should raise a ParseError if there are fewer than 2 arguments" do
-    expect { scope.function_delete_values([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if there are greater than 2 arguments" do
-    expect { scope.function_delete_values([[], 'foo', 'bar']) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a TypeError if the argument is not a hash" do
-    expect { scope.function_delete_values([1,'bar']) }.to( raise_error(TypeError))
-    expect { scope.function_delete_values(['foo','bar']) }.to( raise_error(TypeError))
-    expect { scope.function_delete_values([[],'bar']) }.to( raise_error(TypeError))
+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(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) }
+  describe 'when the first argument is not a hash' do
+    it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
+    it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError) }
+    it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError) }
   end
 
-  it "should delete all instances of a value from a hash" do
-    result = scope.function_delete_values([{ 'a'=>'A', 'b'=>'B', 'B'=>'C', 'd'=>'B' },'B'])
-    expect(result).to(eq({ 'a'=>'A', 'B'=>'C' }))
+  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({'ҝếỵ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' => 'value to delete', 'key3' => 'value to delete'}, 'value to delete') \
+      .and_return({'key1' => 'value1'})
+    }
   end
 
-  it "should not change origin hash passed as argument" do
-    origin_hash = { 'a' => 1, 'b' => 2, 'c' => 3 }
-    result = scope.function_delete_values([origin_hash, 2])
-    expect(origin_hash).to(eq({ 'a' => 1, 'b' => 2, 'c' => 3 }))
+  it "should leave the original argument intact" do
+    argument = { 'key1' => 'value1', 'key2' => 'value2' }
+    original = argument.dup
+    result = subject.call([argument, 'value2'])
+    expect(argument).to eq(original)
   end
-
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/deprecation_spec.rb b/3rdparty/modules/stdlib/spec/functions/deprecation_spec.rb
new file mode 100644 (file)
index 0000000..bde4e89
--- /dev/null
@@ -0,0 +1,60 @@
+require 'spec_helper'
+
+if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
+  describe 'deprecation' do
+    before(:each) {
+      # this is to reset the strict variable to default
+      Puppet.settings[:strict] = :warning
+    }
+
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+
+    it 'should display a single warning' do
+      Puppet.expects(:warning).with(includes('heelo'))
+      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')
+    end
+
+    it 'should fail 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/)
+    end
+
+    it 'should display 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')
+    end
+
+    after(:all) {
+      # this is to reset the strict variable to default
+      Puppet.settings[:strict] = :warning
+    }
+  end
+elsif Puppet.version.to_f < 4.0
+  # Puppet version < 4 will use these tests.
+  describe 'deprecation' do
+    after(:all) do
+      ENV.delete('STDLIB_LOG_DEPRECATIONS')
+    end
+    before(:all) 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 'should display a single warning' do
+      scope.expects(:warning).with(includes('heelo'))
+      is_expected.to run.with_params('key', 'heelo')
+    end
+  end
+end
index 24b2b1b..0ae3689 100755 (executable)
@@ -1,19 +1,23 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the difference function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("difference")).to eq("function_difference")
-  end
-
-  it "should raise a ParseError if there are fewer than 2 arguments" do
-    expect { scope.function_difference([]) }.to( raise_error(Puppet::ParseError) )
-  end
-
-  it "should return the difference between two arrays" do
-    result = scope.function_difference([["a","b","c"],["b","c","d"]])
-    expect(result).to(eq(["a"]))
-  end
+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('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) }
+  it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], '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_return([]) }
+  it { is_expected.to run.with_params([], ['one']).and_return([]) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return([]) }
+  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', 'two', 'three'], ['two', 'three']).and_return(['one']) }
+  it { is_expected.to run.with_params(['ớņέ', 'ŧשּׁō', 'ŧħґëə', 2], ['ŧשּׁō', 'ŧħґëə']).and_return(['ớņέ', 2]) }
+  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
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/dig44_spec.rb b/3rdparty/modules/stdlib/spec/functions/dig44_spec.rb
new file mode 100644 (file)
index 0000000..a7b8a3d
--- /dev/null
@@ -0,0 +1,131 @@
+require 'spec_helper'
+
+describe 'dig44' do
+
+  let(:data) do
+    {
+        'a' => {
+            'g' => '2',
+            'e' => [
+                'f0',
+                'f1',
+                {
+                    'x' => {
+                        'y' => 'z'
+                    }
+                },
+                'f3',
+            ]
+        },
+        'b' => true,
+        'c' => false,
+        'd' => '1',
+        'e' => :undef,
+        'f' => nil,
+    }
+  end
+
+  let(:utf8_data) do
+    {
+        'ẵ' => {
+            'в' => [
+                '©',
+                'ĝ',
+                'に',
+            ]
+        }
+    }
+  end
+
+  context 'single values' do
+    it 'should exist' do
+      is_expected.not_to be_nil
+    end
+
+    it 'should require 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
+      is_expected.to run.with_params('test', []).and_raise_error(Puppet::Error)
+    end
+
+    it 'should fail 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
+      is_expected.to run.with_params(data, ['d'], 'default').and_return('1')
+    end
+
+    it 'should return 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
+      is_expected.to run.with_params(data, ['c'], 'default').and_return(false)
+    end
+
+    it 'should return 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
+      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
+      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')
+    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')
+    end
+
+    it 'should support 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')
+    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')
+    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')
+    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')
+    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)
+    end
+  end
+
+  context 'Internationalization (i18N) values' do
+
+    it 'should be 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
+      is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 1]).and_return('ĝ')
+    end
+
+    it 'should be able to return a double byte character' do
+      is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 2]).and_return('に')
+    end
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/dig_spec.rb b/3rdparty/modules/stdlib/spec/functions/dig_spec.rb
new file mode 100644 (file)
index 0000000..ad16fdd
--- /dev/null
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe 'dig' do
+
+  it "should exist" 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.")
+    scope.function_dig([{}, []])
+  end
+end
index 4261144..c494915 100755 (executable)
@@ -1,38 +1,18 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the dirname function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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('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('/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') }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("dirname")).to eq("function_dirname")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_dirname([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if there is more than 1 argument" do
-    expect { scope.function_dirname(['a', 'b']) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return dirname for an absolute path" do
-    result = scope.function_dirname(['/path/to/a/file.ext'])
-    expect(result).to(eq('/path/to/a'))
-  end
-
-  it "should return dirname for a relative path" do
-    result = scope.function_dirname(['path/to/a/file.ext'])
-    expect(result).to(eq('path/to/a'))
-  end
-
-  it "should complain about hash argument" do
-    expect { scope.function_dirname([{}]) }.to( raise_error(Puppet::ParseError))
-  end
-  it "should complain about list argument" do
-    expect { scope.function_dirname([[]]) }.to( raise_error(Puppet::ParseError))
-  end
-  it "should complain about numeric argument" do
-    expect { scope.function_dirname([2112]) }.to( raise_error(Puppet::ParseError))
+  context 'should run 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
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb b/3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb
new file mode 100644 (file)
index 0000000..97abae7
--- /dev/null
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe 'dos2unix' do
+  context '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/)
+    end
+    it do
+      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/)
+    end
+    it do
+      is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError)
+    end
+  end
+
+  context '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)
+    end
+  end
+
+  context '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)
+    end
+
+    it 'should output double byte string' do
+      should run.with_params(sample_text_doublebyte).and_return(desired_output_doublebyte)
+    end
+  end
+end
index edebc44..c594560 100755 (executable)
@@ -1,33 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the downcase function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("downcase")).to eq("function_downcase")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_downcase([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should downcase a string" do
-    result = scope.function_downcase(["ASFD"])
-    expect(result).to(eq("asfd"))
-  end
-
-  it "should do nothing to a string that is already downcase" do
-    result = scope.function_downcase(["asdf asdf"])
-    expect(result).to(eq("asdf asdf"))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new("ASFD")
-    result = scope.function_downcase([value])
-    result.should(eq('asfd'))
-  end
+describe 'downcase' 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(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(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"]) }
 end
index 6a97c4c..a3a25d6 100755 (executable)
@@ -1,32 +1,22 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the empty function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("empty")).to eq("function_empty")
-  end
+describe 'empty' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it {
+    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) }
+  it { is_expected.to run.with_params('').and_return(true) }
+  it { is_expected.to run.with_params('one').and_return(false) }
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_empty([]) }.to( raise_error(Puppet::ParseError))
-  end
+  it { is_expected.to run.with_params(AlsoString.new('')).and_return(true) }
+  it { is_expected.to run.with_params(AlsoString.new('one')).and_return(false) }
 
-  it "should return a true for an empty string" do
-    result = scope.function_empty([''])
-    expect(result).to(eq(true))
-  end
+  it { is_expected.to run.with_params([]).and_return(true) }
+  it { is_expected.to run.with_params(['one']).and_return(false) }
 
-  it "should return a false for a non-empty string" do
-    result = scope.function_empty(['asdf'])
-    expect(result).to(eq(false))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new()
-    result = scope.function_empty([value])
-    result.should(eq(true))
-  end
+  it { is_expected.to run.with_params({}).and_return(true) }
+  it { is_expected.to run.with_params({'key' => 'value'}).and_return(false) }
 end
index 436be10..190e580 100755 (executable)
@@ -1,81 +1,71 @@
-#! /usr/bin/env ruby
-
 require 'spec_helper'
-require 'rspec-puppet'
-require 'puppet_spec/compiler'
 
 describe 'ensure_packages' do
-  include PuppetSpec::Compiler
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it {
+    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)
+  }
+  it { is_expected.to run.with_params("packagename") }
+  it { is_expected.to run.with_params(["packagename1", "packagename2"]) }
 
-  before :each do
-    Puppet::Parser::Functions.autoloader.loadall
-    Puppet::Parser::Functions.function(:ensure_packages)
-    Puppet::Parser::Functions.function(:ensure_resource)
-    Puppet::Parser::Functions.function(:defined_with_params)
-    Puppet::Parser::Functions.function(:create_resources)
-  end
+  context 'given a catalog with "package { puppet: ensure => absent }"' do
+    let(:pre_condition) { 'package { puppet: ensure => absent }' }
 
-  let :node     do Puppet::Node.new('localhost') end
-  let :compiler do Puppet::Parser::Compiler.new(node) end
-  let :scope    do
-    if Puppet.version.to_f >= 3.0
-      Puppet::Parser::Scope.new(compiler)
-    else
-      newscope = Puppet::Parser::Scope.new
-      newscope.compiler = compiler
-      newscope.source   = Puppet::Resource::Type.new(:node, :localhost)
-      newscope
-    end
-  end
+    describe 'after running ensure_package("facter")' do
+      before { subject.call(['facter']) }
 
-  describe 'argument handling' do
-    it 'fails with no arguments' do
-      expect {
-        scope.function_ensure_packages([])
-      }.to raise_error(Puppet::ParseError, /0 for 1 or 2/)
+      # 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') }
     end
 
-    it 'accepts an array of values' do
-      scope.function_ensure_packages([['foo']])
-    end
+    describe 'after running ensure_package("facter", { "provider" => "gem" })' do
+      before { subject.call(['facter', { "provider" => "gem" }]) }
 
-    it 'accepts a single package name as a string' do
-      scope.function_ensure_packages(['foo'])
+      # 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") }
     end
   end
 
-  context 'given a catalog with puppet package => absent' do
-    let :catalog do
-      compile_to_catalog(<<-EOS
-        ensure_packages(['facter'])
-        package { puppet: ensure => absent }
-      EOS
-      )
-    end
+  context 'given an empty packages array' do
+    let(:pre_condition) { 'notify { "hi": } -> Package <| |>; $somearray = ["vim",""]; ensure_packages($somearray)' }
 
-    it 'has no effect on Package[puppet]' do
-      expect(catalog.resource(:package, 'puppet')['ensure']).to eq('absent')
+    describe 'after running ensure_package(["vim", ""])' do
+      it { expect { catalogue }.to raise_error(Puppet::ParseError, /Empty String provided/) }
     end
   end
 
-  context 'given a clean catalog' do
-    let :catalog do
-      compile_to_catalog('ensure_packages(["facter"])')
-    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"}}]) }
+
+    # 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 'declares package resources with ensure => present' do
-      expect(catalog.resource(:package, 'facter')['ensure']).to eq('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'}) }
     end
   end
 
-  context 'given a clean catalog and specified defaults' do
-    let :catalog do
-      compile_to_catalog('ensure_packages(["facter"], {"provider" => "gem"})')
-    end
+  context 'given a catalog with "package { puppet: ensure => present }"' do
+    let(:pre_condition) { 'package { puppet: ensure => present }' }
 
-    it 'declares package resources with ensure => present' do
-      expect(catalog.resource(:package, 'facter')['ensure']).to eq('present')
-      expect(catalog.resource(:package, 'facter')['provider']).to eq('gem')
+    describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do
+      before { subject.call(['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') }
     end
   end
+
 end
index 33bcac0..c847bf7 100755 (executable)
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
-require 'rspec-puppet'
-require 'puppet_spec/compiler'
 
 describe 'ensure_resource' do
-  include PuppetSpec::Compiler
-
-  before :all do
-    Puppet::Parser::Functions.autoloader.loadall
-    Puppet::Parser::Functions.function(:ensure_packages)
+  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/) }
+  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
+    it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) }
   end
 
-  let :node     do Puppet::Node.new('localhost') end
-  let :compiler do Puppet::Parser::Compiler.new(node) end
-  let :scope    do Puppet::Parser::Scope.new(compiler) end
+  it {
+    pending("should not accept numbers as arguments")
+    is_expected.to run.with_params(1,2,3).and_raise_error(Puppet::ParseError)
+  }
 
-  describe 'when a type or title is not specified' do
-    it { expect { scope.function_ensure_resource([]) }.to raise_error }
-    it { expect { scope.function_ensure_resource(['type']) }.to raise_error }
-  end
+  context 'given an empty catalog' do
+    describe 'after running ensure_resource("user", "username1", {})' do
+      before { subject.call(['User', 'username1', {}]) }
 
-  describe 'when compared against a resource with no attributes' do
-    let :catalog do
-      compile_to_catalog(<<-EOS
-        user { "dan": }
-        ensure_resource('user', 'dan', {})
-      EOS
-      )
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('username1').without_ensure }
     end
 
-    it 'should contain the the ensured resources' do
-      expect(catalog.resource(:user, 'dan').to_s).to eq('User[dan]')
+    describe 'after running ensure_resource("user", "username1", { gid => undef })' do
+      before { subject.call(['User', 'username1', { 'gid' => :undef }]) }
+
+      # 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 }
     end
-  end
 
-  describe 'works when compared against a resource with non-conflicting attributes' do
-    [
-      "ensure_resource('User', 'dan', {})",
-      "ensure_resource('User', 'dan', '')",
-      "ensure_resource('User', 'dan', {'ensure' => 'present'})",
-      "ensure_resource('User', 'dan', {'ensure' => 'present', 'managehome' => false})"
-    ].each do |ensure_resource|
-      pp = <<-EOS
-        user { "dan": ensure => present, shell => "/bin/csh", managehome => false}
-        #{ensure_resource}
-      EOS
-
-      it { expect { compile_to_catalog(pp) }.to_not raise_error }
+    describe 'after running ensure_resource("user", "username1", { ensure => present, gid => undef })' do
+      before { subject.call(['User', 'username1', { 'ensure' => 'present', 'gid' => :undef }]) }
+
+      # 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 }
     end
-  end
 
-  describe 'fails when compared against a resource with conflicting attributes' do
-    pp = <<-EOS
-      user { "dan": ensure => present, shell => "/bin/csh", managehome => false}
-      ensure_resource('User', 'dan', {'ensure' => 'absent', 'managehome' => false})
-    EOS
+    describe 'after running ensure_resource("test::deftype", "foo", {})' do
+      before { subject.call(['test::deftype', 'foo', {}]) }
 
-    it { expect { compile_to_catalog(pp) }.to raise_error }
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure }
+    end
   end
 
-  describe 'when an array of new resources are passed in' do
-    let :catalog do
-      compile_to_catalog("ensure_resource('User', ['dan', 'alex'], {})")
+  context 'given a catalog with UTF8 chars' do
+    describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", {})' do
+      before { subject.call(['User', 'Şắოрŀễ Ţëם', {}]) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure }
     end
 
-    it 'should contain the ensured resources' do
-      expect(catalog.resource('User[dan]').to_s).to eq('User[dan]')
-      expect(catalog.resource('User[alex]').to_s).to eq('User[alex]')
+    describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { gid => undef })' do
+      before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'gid' => :undef }]) }
+
+      # 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 }
+    end
+
+    describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { ensure => present, gid => undef })' do
+      before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'ensure' => 'present', 'gid' => :undef }]) }
+
+      # 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 }
     end
   end
 
-  describe 'when an array of existing resources is compared against existing resources' do
-    pp = <<-EOS
-      user { 'dan': ensure => present; 'alex': ensure => present }
-      ensure_resource('User', ['dan', 'alex'], {})
-    EOS
+  context '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', {}]) }
 
-    let :catalog do
-      compile_to_catalog(pp)
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
     end
 
-    it 'should return the existing resources' do
-      expect(catalog.resource('User[dan]').to_s).to eq('User[dan]')
-      expect(catalog.resource('User[alex]').to_s).to eq('User[alex]')
+    describe 'after running ensure_resource("user", "username2", {})' do
+      before { subject.call(['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 }
     end
-  end
 
-  describe 'works when compared against existing resources with attributes' do
-    [
-      "ensure_resource('User', ['dan', 'alex'], {})",
-      "ensure_resource('User', ['dan', 'alex'], '')",
-      "ensure_resource('User', ['dan', 'alex'], {'ensure' => 'present'})",
-    ].each do |ensure_resource|
-      pp = <<-EOS
-        user { 'dan': ensure => present; 'alex': ensure => present }
-        #{ensure_resource}
-      EOS
-
-      it { expect { compile_to_catalog(pp) }.to_not raise_error }
+    describe 'after running ensure_resource("user", "username1", { gid => undef })' do
+      before { subject.call(['User', 'username1', { 'gid' => :undef }]) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
     end
-  end
 
-  describe 'fails when compared against existing resources with conflicting attributes' do
-    pp = <<-EOS
-      user { 'dan': ensure => present; 'alex': ensure => present }
-      ensure_resource('User', ['dan', 'alex'], {'ensure' => 'absent'})
-    EOS
+    describe 'after running ensure_resource("user", ["username1", "username2"], {})' do
+      before { subject.call(['User', ['username1', 'username2'], {}]) }
 
-    it { expect { compile_to_catalog(pp) }.to raise_error }
+      # 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 }
+    end
+
+    describe 'when providing already set params' do
+      let(:params) { { 'ensure' => 'present' } }
+      before { subject.call(['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) }
+    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/)
+      }
+    end
   end
 
+  context 'given a catalog with "test::deftype { foo: }"' do
+    let(:pre_condition) { 'test::deftype { "foo": }' }
+
+    describe 'after running ensure_resource("test::deftype", "foo", {})' do
+      before { subject.call(['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 }
+    end
+  end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/ensure_resources_spec.rb b/3rdparty/modules/stdlib/spec/functions/ensure_resources_spec.rb
new file mode 100644 (file)
index 0000000..7cca671
--- /dev/null
@@ -0,0 +1,25 @@
+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/) }
+
+  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'}]) }
+
+    # 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'}) }
+  end
+
+  describe 'given a title hash of a single resource' do
+    before { subject.call(['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'}) }
+  end
+end
index de8c66d..b80f3c5 100755 (executable)
@@ -1,27 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the flatten function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("flatten")).to eq("function_flatten")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_flatten([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if there is more than 1 argument" do
-    expect { scope.function_flatten([[], []]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should flatten a complex data structure" do
-    result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]])
-    expect(result).to(eq(["a","b","c","d","e","f","g"]))
-  end
-
-  it "should do nothing to a structure that is already flat" do
-    result = scope.function_flatten([["a","b","c","d"]])
-    expect(result).to(eq(["a","b","c","d"]))
-  end
+describe 'flatten' 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([]).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(["ã","β","ĉ","đ","ẽ","ƒ","ġ"]) }
 end
index 12a6917..608c602 100755 (executable)
@@ -1,39 +1,12 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the floor function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("floor")).to eq("function_floor")
-  end
-
-  it "should raise a ParseError if there is less than 1 argument" do
-    expect { scope.function_floor([]) }.to( raise_error(Puppet::ParseError, /Wrong number of arguments/))
-  end
-
-  it "should should raise a ParseError if input isn't numeric (eg. String)" do
-    expect { scope.function_floor(["foo"]) }.to( raise_error(Puppet::ParseError, /Wrong argument type/))
-  end
-
-  it "should should raise a ParseError if input isn't numeric (eg. Boolean)" do
-    expect { scope.function_floor([true]) }.to( raise_error(Puppet::ParseError, /Wrong argument type/))
-  end
-
-  it "should return an integer when a numeric type is passed" do
-    result = scope.function_floor([12.4])
-    expect(result.is_a?(Integer)).to(eq(true))
-  end
-
-  it "should return the input when an integer is passed" do
-    result = scope.function_floor([7])
-    expect(result).to(eq(7))
-  end
-
-  it "should return the largest integer less than or equal to the input" do
-    result = scope.function_floor([3.8])
-    expect(result).to(eq(3))
-  end
+describe 'floor' 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(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(33) }
+  it { is_expected.to run.with_params(-33.1).and_return(-34) }
 end
-
index 949d930..861a59e 100644 (file)
@@ -1,51 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the fqdn_rand_string function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("fqdn_rand_string")).to eq("function_fqdn_rand_string")
-  end
-
-  it "should raise an ArgumentError if there is less than 1 argument" do
-    expect { fqdn_rand_string() }.to( raise_error(ArgumentError, /wrong number of arguments/))
-  end
-
-  it "should raise an ArgumentError if argument 1 isn't a positive integer" do
-    expect { fqdn_rand_string(0) }.to( raise_error(ArgumentError, /first argument must be a positive integer/))
-    expect { fqdn_rand_string(-1) }.to( raise_error(ArgumentError, /first argument must be a positive integer/))
-    expect { fqdn_rand_string(0.5) }.to( raise_error(ArgumentError, /first argument must be a positive integer/))
-  end
-
-  it "provides a valid alphanumeric string when no character set is provided" do
-    length = 100
-    string = %r{\A[a-zA-Z0-9]{#{length}}\z}
-    expect(fqdn_rand_string(length).match(string)).not_to eq(nil)
-  end
-
-  it "provides a valid alphanumeric string when an undef character set is provided" do
-    length = 100
-    string = %r{\A[a-zA-Z0-9]{#{length}}\z}
-    expect(fqdn_rand_string(length, :charset => nil).match(string)).not_to eq(nil)
-  end
-
-  it "provides a valid alphanumeric string when an empty character set is provided" do
-    length = 100
-    string = %r{\A[a-zA-Z0-9]{#{length}}\z}
-    expect(fqdn_rand_string(length, :charset => '').match(string)).not_to eq(nil)
-  end
-
-  it "uses a provided character set" do
-    length = 100
-    charset = '!@#$%^&*()-_=+'
-    string = %r{\A[#{charset}]{#{length}}\z}
-    expect(fqdn_rand_string(length, :charset => charset).match(string)).not_to eq(nil)
-  end
-
-  it "provides a random string exactly as long as the given length" do
-    expect(fqdn_rand_string(10).size).to eql(10)
-  end
+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(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 "provides the same 'random' value on subsequent calls for the same host" do
     expect(fqdn_rand_string(10)).to eql(fqdn_rand_string(10))
@@ -77,9 +52,9 @@ describe "the fqdn_rand_string function" do
     charset = args[:charset]
     extra = args[:extra_identifier] || []
 
-    scope = PuppetlabsSpec::PuppetInternals.scope
-    scope.stubs(:[]).with("::fqdn").returns(host)
-    scope.stubs(:lookupvar).with("::fqdn").returns(host)
+    # 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)
 
     function_args = [max]
     if args.has_key?(:charset) or !extra.empty?
index 673a8a3..7c1038a 100755 (executable)
@@ -1,60 +1,76 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the fqdn_rotate function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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_return('') }
+  it { is_expected.to run.with_params('a').and_return('a') }
+  it { is_expected.to run.with_params('ã').and_return('ã') }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("fqdn_rotate")).to eq("function_fqdn_rotate")
+  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)
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_fqdn_rotate([]) }.to( raise_error(Puppet::ParseError))
+  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')
+    expect(val1).to eq(val2)
   end
 
-  it "should rotate a string and the result should be the same size" do
-    scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
-    result = scope.function_fqdn_rotate(["asdf"])
-    expect(result.size).to(eq(4))
+  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 "should rotate a string to give the same results for one host" do
-    scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
-    expect(scope.function_fqdn_rotate(["abcdefg"])).to eql(scope.function_fqdn_rotate(["abcdefg"]))
+  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
-     scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
-     val1 = scope.function_fqdn_rotate(["abcdefghijklmnopqrstuvwxyz01234567890987654321"])
-     scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.2")
-     val2 = scope.function_fqdn_rotate(["abcdefghijklmnopqrstuvwxyz01234567890987654321"])
-     expect(val1).not_to eql(val2)
+    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
-    class AlsoString < String
-    end
-
-    scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
-    value = AlsoString.new("asdf")
-    result = scope.function_fqdn_rotate([value])
-    result.size.should(eq(4))
+    result = fqdn_rotate(AlsoString.new('asdf'))
+    expect(result).to eq('dfas')
   end
 
-  it "should use the Puppet::Util.deterministic_rand function if available" do
-    scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
+  it "should use the Puppet::Util.deterministic_rand function" do
     if Puppet::Util.respond_to?(:deterministic_rand)
-      Puppet::Util.expects(:deterministic_rand).with(113646079810780526294648115052177588845,4)
+      Puppet::Util.expects(:deterministic_rand).with(44489829212339698569024999901561968770,4)
+      fqdn_rotate("asdf")
+    else
+      skip 'Puppet::Util#deterministic_rand not available'
     end
-    scope.function_fqdn_rotate(["asdf"])
   end
 
   it "should not leave the global seed in a deterministic state" do
-    scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
-    scope.function_fqdn_rotate(["asdf"])
+    fqdn_rotate("asdf")
     rand1 = rand()
-    scope.function_fqdn_rotate(["asdf"])
+    fqdn_rotate("asdf")
     rand2 = rand()
     expect(rand1).not_to eql(rand2)
   end
+
+  def fqdn_rotate(value, args = {})
+    host = args[:host] || '127.0.0.1'
+    extra = args[:extra_identifier] || []
+
+    # 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)
+
+    function_args = [value] + extra
+    scope.function_fqdn_rotate(function_args)
+  end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb b/3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb
new file mode 100644 (file)
index 0000000..d0c30d6
--- /dev/null
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe 'fqdn_uuid' do
+
+  context "Invalid parameters" do
+    it { should run.with_params().and_raise_error(ArgumentError, /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') }
+  end
+end
index 38ce645..a39e413 100755 (executable)
@@ -1,8 +1,12 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:get_module_path) do
-  Internals = PuppetlabsSpec::PuppetInternals
+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/) }
+
   class StubModule
     attr_reader :path
     def initialize(path)
@@ -10,37 +14,35 @@ describe Puppet::Parser::Functions.function(:get_module_path) do
     end
   end
 
-  def scope(environment = "production")
-    Internals.scope(:compiler => Internals.compiler(:node => Internals.node(:environment => environment)))
-  end
-
-  it 'should only allow one argument' do
-    expect { scope.function_get_module_path([]) }.to raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/)
-    expect { scope.function_get_module_path(['1','2','3']) }.to raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/)
-  end
-  it 'should raise an exception when the module cannot be found' do
-    expect { scope.function_get_module_path(['foo']) }.to raise_error(Puppet::ParseError, /Could not find module/)
-  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") }
 
     before(:each) { Puppet[:modulepath] = modulepath }
 
-    it 'should be able to find module paths from the modulepath setting' do
-      Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo)
-      expect(scope.function_get_module_path(['foo'])).to eq(path_of_module_foo.path)
-    end
-    it 'should be able to find module paths when the modulepath is a list' do
-      Puppet[:modulepath] = modulepath + ":/tmp"
-      Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo)
-      expect(scope.function_get_module_path(['foo'])).to eq(path_of_module_foo.path)
+    context 'in the default environment' do
+      before(:each) { Puppet::Module.expects(:find).with('foo', 'rp_env').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' }
+
+        it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+      end
     end
-    it 'should respect the environment' do
-      skip("Disabled on Puppet 2.6.x") if Puppet.version =~ /^2\.6\b/
-      Puppet.settings[:environment] = 'danstestenv'
-      Puppet::Module.expects(:find).with('foo', 'danstestenv').returns(path_of_module_foo)
-      expect(scope('danstestenv').function_get_module_path(['foo'])).to eq(path_of_module_foo.path)
+
+    context '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' }
+
+        it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+      end
     end
   end
 end
index 833c4d4..522ed3b 100755 (executable)
@@ -1,76 +1,35 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
-require 'rspec-puppet'
-require 'puppet_spec/compiler'
 
 describe 'getparam' do
-  include PuppetSpec::Compiler
-
-  before :each do
-    Puppet::Parser::Functions.autoloader.loadall
-    Puppet::Parser::Functions.function(:getparam)
-  end
-
-  let :node     do Puppet::Node.new('localhost') end
-  let :compiler do Puppet::Parser::Compiler.new(node) end
-  if Puppet.version.to_f >= 3.0
-    let :scope    do Puppet::Parser::Scope.new(compiler) end
-  else
-    let :scope    do
-      newscope = Puppet::Parser::Scope.new
-      newscope.compiler = compiler
-      newscope.source   = Puppet::Resource::Type.new(:node, :localhost)
-      newscope
-    end
-  end
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("getparam")).to eq("function_getparam")
-  end
-
-  describe 'when a resource is not specified' do
-    it { expect { scope.function_getparam([]) }.to raise_error }
-    it { expect { scope.function_getparam(['User[dan]']) }.to raise_error }
-    it { expect { scope.function_getparam(['User[dan]']) }.to raise_error }
-    it { expect { scope.function_getparam(['User[dan]', {}]) }.to raise_error }
-    # This seems to be OK because we just check for a string.
-    it { expect { scope.function_getparam(['User[dan]', '']) }.to_not raise_error }
+  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/) }
+
+  describe 'when compared against a user resource with no params' do
+    let(:pre_condition) { 'user { "one": }' }
+
+    it { is_expected.to run.with_params('User[one]', 'ensure').and_return('') }
+    it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
+    it { is_expected.to run.with_params('User[one]', 'shell').and_return('') }
   end
 
-  describe 'when compared against a resource with no params' do
-    let :catalog do
-      compile_to_catalog(<<-EOS
-        user { "dan": }
-      EOS
-      )
-    end
+  describe 'when compared against a user resource with params' do
+    let(:pre_condition) { 'user { "one": ensure => present, shell => "/bin/sh", managehome => false, }' }
 
-    it do
-      expect(scope.function_getparam(['User[dan]', 'shell'])).to eq('')
-    end
+    it { is_expected.to run.with_params('User[one]', 'ensure').and_return('present') }
+    it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
+    it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') }
+    it { is_expected.to run.with_params('User[one]', 'managehome').and_return(false) }
   end
 
-  describe 'when compared against a resource with params' do
-    let :catalog do
-      compile_to_catalog(<<-EOS
-        user { 'dan': ensure => present, shell => '/bin/sh', managehome => false}
-        $test = getparam(User[dan], 'shell')
-      EOS
-      )
-    end
+  describe 'when compared against a user resource with UTF8 and double byte params' do
+    let(:pre_condition) { 'user { ["三", "ƒốưř"]: ensure => present }' }
 
-    it do
-      resource = Puppet::Parser::Resource.new(:user, 'dan', {:scope => scope})
-      resource.set_parameter('ensure', 'present')
-      resource.set_parameter('shell', '/bin/sh')
-      resource.set_parameter('managehome', false)
-      compiler.add_resource(scope, resource)
+    it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') }
+    it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') }
 
-      expect(scope.function_getparam(['User[dan]', 'shell'])).to eq('/bin/sh')
-      expect(scope.function_getparam(['User[dan]', ''])).to eq('')
-      expect(scope.function_getparam(['User[dan]', 'ensure'])).to eq('present')
-      # TODO: Expected this to be false, figure out why we're getting '' back.
-      expect(scope.function_getparam(['User[dan]', 'managehome'])).to eq('')
-    end
   end
 end
index 87ab9b5..55789d8 100755 (executable)
@@ -1,37 +1,38 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:getvar) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-  describe 'when calling getvar from puppet' do
+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 "should not compile when no arguments are passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = '$foo = getvar()'
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
+  it { is_expected.to run.with_params('$::foo').and_return(nil) }
 
-    it "should not compile when too many arguments are passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = '$foo = getvar("foo::bar", "baz")'
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
+  context 'given variables in namespaces' do
+    let(:pre_condition) {
+      <<-'ENDofPUPPETcode'
+      class site::data { $foo = 'baz' }
+      include site::data
+      ENDofPUPPETcode
+    }
+
+    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
 
-    it "should lookup variables in other namespaces" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        class site::data { $foo = 'baz' }
-        include site::data
-        $foo = getvar("site::data::foo")
-        if $foo != 'baz' {
-          fail('getvar did not return what we expect')
-        }
+  context 'given variables in namespaces' do
+    let(:pre_condition) {
+      <<-'ENDofPUPPETcode'
+      class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' }
+      class site::new { $item = '万Ü€‰' }
+      include site::info
+      include site::new
       ENDofPUPPETcode
-      scope.compiler.compile
-    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
+
diff --git a/3rdparty/modules/stdlib/spec/functions/glob_spec.rb b/3rdparty/modules/stdlib/spec/functions/glob_spec.rb
new file mode 100755 (executable)
index 0000000..06439da
--- /dev/null
@@ -0,0 +1,11 @@
+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(1).and_raise_error(Puppet::ParseError) }
+  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(['/etc/xyzxyzxyz', '/etcxyzxyzxyz']).and_return([]) }
+end
index 9c671dd..d2152b1 100755 (executable)
@@ -1,19 +1,20 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the grep function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("grep")).to eq("function_grep")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_grep([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should grep contents from an array" do
-    result = scope.function_grep([["aaabbb","bbbccc","dddeee"], "bbb"])
-    expect(result).to(eq(["aaabbb","bbbccc"]))
-  end
+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 {
+    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/)
+  }
+  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/)
+  }
+  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([], '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']) }
+  it { is_expected.to run.with_params(['ờאּê', 'ţשּׂỡ', 'ţһŗəè'], 'ţ(שּׂỡ|һŗəè)').and_return(['ţשּׂỡ', 'ţһŗəè']) }
 end
index 23e09a9..7334d38 100755 (executable)
@@ -1,64 +1,38 @@
-#!/usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:has_interface_with) do
-
-  let(:scope) do
-    PuppetlabsSpec::PuppetInternals.scope
-  end
-
-  # The subject of these examples is the method itself.
-  subject do
-    function_name = Puppet::Parser::Functions.function(:has_interface_with)
-    scope.method(function_name)
-  end
+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) }
 
   # 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
-    before :each do
-      scope.stubs(:lookupvar).with("interfaces").returns('lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0')
-    end
-    it 'should have loopback (lo0)' do
-      expect(subject.call(['lo0'])).to be_truthy
-    end
-    it 'should not have loopback (lo)' do
-      expect(subject.call(['lo'])).to be_falsey
-    end
+    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
-    before :each do
-      scope.stubs(:lookupvar).with("interfaces").returns('eth0,lo')
-      scope.stubs(:lookupvar).with("ipaddress").returns('10.0.0.1')
-      scope.stubs(:lookupvar).with("ipaddress_lo").returns('127.0.0.1')
-      scope.stubs(:lookupvar).with("ipaddress_eth0").returns('10.0.0.1')
-      scope.stubs(:lookupvar).with('muppet').returns('kermit')
-      scope.stubs(:lookupvar).with('muppet_lo').returns('mspiggy')
-      scope.stubs(:lookupvar).with('muppet_eth0').returns('kermit')
-    end
-    it 'should have loopback (lo)' do
-      expect(subject.call(['lo'])).to be_truthy
-    end
-    it 'should not have loopback (lo0)' do
-      expect(subject.call(['lo0'])).to be_falsey
-    end
-    it 'should have ipaddress with 127.0.0.1' do
-      expect(subject.call(['ipaddress', '127.0.0.1'])).to be_truthy
-    end
-    it 'should have ipaddress with 10.0.0.1' do
-      expect(subject.call(['ipaddress', '10.0.0.1'])).to be_truthy
-    end
-    it 'should not have ipaddress with 10.0.0.2' do
-      expect(subject.call(['ipaddress', '10.0.0.2'])).to be_falsey
-    end
-    it 'should have muppet named kermit' do
-      expect(subject.call(['muppet', 'kermit'])).to be_truthy
-    end
-    it 'should have muppet named mspiggy' do
-      expect(subject.call(['muppet', 'mspiggy'])).to be_truthy
-    end
-    it 'should not have muppet named bigbird' do
-      expect(subject.call(['muppet', 'bigbird'])).to be_falsey
+    let(:facts) do
+      {
+        :interfaces => 'eth0,lo',
+        :ipaddress => '10.0.0.1',
+        :ipaddress_lo => '127.0.0.1',
+        :ipaddress_eth0 => '10.0.0.1',
+        :muppet => 'kermit',
+        :muppet_lo => 'mspiggy',
+        :muppet_eth0 => 'kermit',
+      }
     end
+
+    it { is_expected.to run.with_params('lo').and_return(true) }
+    it { is_expected.to run.with_params('lo0').and_return(false) }
+    it { is_expected.to run.with_params('ipaddress', '127.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('ipaddress', '10.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('ipaddress', '8.8.8.8').and_return(false) }
+    it { is_expected.to run.with_params('muppet', 'kermit').and_return(true) }
+    it { is_expected.to run.with_params('muppet', 'mspiggy').and_return(true) }
+    it { is_expected.to run.with_params('muppet', 'bigbird').and_return(false) }
   end
 end
index 0df12a7..42a5a79 100755 (executable)
@@ -1,39 +1,22 @@
-#!/usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:has_ip_address) do
-
-  let(:scope) do
-    PuppetlabsSpec::PuppetInternals.scope
-  end
-
-  subject do
-    function_name = Puppet::Parser::Functions.function(:has_ip_address)
-    scope.method(function_name)
-  end
+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) }
 
   context "On Linux Systems" do
-    before :each do
-      scope.stubs(:lookupvar).with('interfaces').returns('eth0,lo')
-      scope.stubs(:lookupvar).with('ipaddress').returns('10.0.2.15')
-      scope.stubs(:lookupvar).with('ipaddress_eth0').returns('10.0.2.15')
-      scope.stubs(:lookupvar).with('ipaddress_lo').returns('127.0.0.1')
-    end
-
-    it 'should have primary address (10.0.2.15)' do
-      expect(subject.call(['10.0.2.15'])).to be_truthy
+    let(:facts) do
+      {
+        :interfaces => 'eth0,lo',
+        :ipaddress => '10.0.0.1',
+        :ipaddress_lo => '127.0.0.1',
+        :ipaddress_eth0 => '10.0.0.1',
+      }
     end
 
-    it 'should have lookupback address (127.0.0.1)' do
-      expect(subject.call(['127.0.0.1'])).to be_truthy
-    end
-
-    it 'should not have other address' do
-      expect(subject.call(['192.1681.1.1'])).to be_falsey
-    end
-
-    it 'should not have "mspiggy" on an interface' do
-      expect(subject.call(['mspiggy'])).to be_falsey
-    end
+    it { is_expected.to run.with_params('127.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('10.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('8.8.8.8').and_return(false) }
   end
 end
index 2a2578e..57cf613 100755 (executable)
@@ -1,36 +1,21 @@
-#!/usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:has_ip_network) do
-
-  let(:scope) do
-    PuppetlabsSpec::PuppetInternals.scope
-  end
-
-  subject do
-    function_name = Puppet::Parser::Functions.function(:has_ip_network)
-    scope.method(function_name)
-  end
+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) }
 
   context "On Linux Systems" do
-    before :each do
-      scope.stubs(:lookupvar).with('interfaces').returns('eth0,lo')
-      scope.stubs(:lookupvar).with('network').returns(:undefined)
-      scope.stubs(:lookupvar).with('network_eth0').returns('10.0.2.0')
-      scope.stubs(:lookupvar).with('network_lo').returns('127.0.0.1')
-    end
-
-    it 'should have primary network (10.0.2.0)' do
-      expect(subject.call(['10.0.2.0'])).to be_truthy
-    end
-
-    it 'should have loopback network (127.0.0.0)' do
-      expect(subject.call(['127.0.0.1'])).to be_truthy
+    let(:facts) do
+      {
+        :interfaces => 'eth0,lo',
+        :network_lo => '127.0.0.0',
+        :network_eth0 => '10.0.0.0',
+      }
     end
 
-    it 'should not have other network' do
-      expect(subject.call(['192.168.1.0'])).to be_falsey
-    end
+    it { is_expected.to run.with_params('127.0.0.0').and_return(true) }
+    it { is_expected.to run.with_params('10.0.0.0').and_return(true) }
+    it { is_expected.to run.with_params('8.8.8.0').and_return(false) }
   end
 end
-
index 6b71800..0e0e1cc 100755 (executable)
@@ -1,42 +1,20 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:has_key) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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/) }
 
-  describe 'when calling has_key from puppet' do
-    it "should not compile when no arguments are passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = '$x = has_key()'
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
+  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 "should not compile when 1 argument is passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = "$x = has_key('foo')"
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
-
-    it "should require the first value to be a Hash" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = "$x = has_key('foo', 'bar')"
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /expects the first argument to be a hash/)
-    end
-  end
-
-  describe 'when calling the function has_key from a scope instance' do
-    it 'should detect existing keys' do
-      expect(scope.function_has_key([{'one' => 1}, 'one'])).to be_truthy
-    end
-
-    it 'should detect existing keys' do
-      expect(scope.function_has_key([{'one' => 1}, 'two'])).to be_falsey
-    end
+  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) }
   end
 end
index ec2988b..092474b 100755 (executable)
@@ -1,19 +1,15 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the hash function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("hash")).to eq("function_hash")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_hash([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should convert an array to a hash" do
-    result = scope.function_hash([['a',1,'b',2,'c',3]])
-    expect(result).to(eq({'a'=>1,'b'=>2,'c'=>3}))
-  end
+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 {
+    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)
+  }
+  it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, /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' }) }
 end
index 6361304..ec368a5 100755 (executable)
@@ -1,19 +1,22 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the intersection function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("intersection")).to eq("function_intersection")
-  end
-
-  it "should raise a ParseError if there are fewer than 2 arguments" do
-    expect { scope.function_intersection([]) }.to( raise_error(Puppet::ParseError) )
-  end
-
-  it "should return the intersection of two arrays" do
-    result = scope.function_intersection([["a","b","c"],["b","c","d"]])
-    expect(result).to(eq(["b","c"]))
-  end
+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('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) }
+  it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], '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_return([]) }
+  it { is_expected.to run.with_params([], ['one']).and_return([]) }
+  it { is_expected.to run.with_params(['one'], []).and_return([]) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) }
+  it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ['ŧשợ', 'ţђŕẽё']).and_return(['ŧשợ', 'ţђŕẽё']) }
+  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
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/is_a_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_a_spec.rb
new file mode 100644 (file)
index 0000000..2d6cb46
--- /dev/null
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+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) }
+    end
+  end
+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 'succeeds when comparing a string and a string' do
+      is_expected.to run.with_params('hello world', String).and_return(true)
+    end
+
+    it 'fails when comparing an integer and a string' do
+      is_expected.to run.with_params(5, String).and_return(false)
+    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)
+    end
+  end
+end
index 94920a4..e89f54b 100755 (executable)
@@ -1,29 +1,36 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_array function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_array")).to eq("function_is_array")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_array([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if passed an array" do
-    result = scope.function_is_array([[1,2,3]])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if passed a hash" do
-    result = scope.function_is_array([{'a'=>1}])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if passed a string" do
-    result = scope.function_is_array(["asdf"])
-    expect(result).to(eq(false))
+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 {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /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) }
+  it { is_expected.to run.with_params([1]).and_return(true) }
+  it { is_expected.to run.with_params([{}]).and_return(true) }
+  it { is_expected.to run.with_params([[]]).and_return(true) }
+  it { is_expected.to run.with_params('').and_return(false) }
+  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
+      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'))
+      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
+      is_expected.to run.with_params(['1.2.3.4']).and_return(true)
+    end
   end
 end
index 4a342ba..d21345c 100755 (executable)
@@ -1,44 +1,33 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_bool function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_bool")).to eq("function_is_bool")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_bool([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if passed a TrueClass" do
-    result = scope.function_is_bool([true])
-    expect(result).to(eq(true))
-  end
-
-  it "should return true if passed a FalseClass" do
-    result = scope.function_is_bool([false])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if passed the string 'true'" do
-    result = scope.function_is_bool(['true'])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if passed the string 'false'" do
-    result = scope.function_is_bool(['false'])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if passed an array" do
-    result = scope.function_is_bool([["a","b"]])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if passed a hash" do
-    result = scope.function_is_bool([{"a" => "b"}])
-    expect(result).to(eq(false))
-  end
+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(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) }
+  it { is_expected.to run.with_params([{}]).and_return(false) }
+  it { is_expected.to run.with_params([[]]).and_return(false) }
+  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
+      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'))
+      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
+      is_expected.to run.with_params(false).and_return(true)
+    end
+  end 
 end
+
index ef88061..c1bf0e3 100755 (executable)
@@ -1,81 +1,43 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_domain_name function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_domain_name")).to eq("function_is_domain_name")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_domain_name([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if a valid short domain name" do
-    result = scope.function_is_domain_name(["x.com"])
-    expect(result).to(be_truthy)
-  end
-
-  it "should return true if the domain is ." do
-    result = scope.function_is_domain_name(["."])
-    expect(result).to(be_truthy)
+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(1).and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  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('com').and_return(true) }
+  it { is_expected.to run.with_params('com.').and_return(true) }
+  it { is_expected.to run.with_params('x.com').and_return(true) }
+  it { is_expected.to run.with_params('x.com.').and_return(true) }
+  it { is_expected.to run.with_params('foo.example.com').and_return(true) }
+  it { is_expected.to run.with_params('foo.example.com.').and_return(true) }
+  it { is_expected.to run.with_params('2foo.example.com').and_return(true) }
+  it { is_expected.to run.with_params('2foo.example.com.').and_return(true) }
+  it { is_expected.to run.with_params('www.2foo.example.com').and_return(true) }
+  it { is_expected.to run.with_params('www.2foo.example.com.').and_return(true) }
+  describe 'inputs with spaces' do
+    it { is_expected.to run.with_params('invalid domain').and_return(false) }
+  end
+  describe 'inputs with hyphens' do
+    it { is_expected.to run.with_params('foo-bar.example.com').and_return(true) }
+    it { is_expected.to run.with_params('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('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) }
   end
-
-  it "should return true if the domain is x.com." do
-    result = scope.function_is_domain_name(["x.com."])
-    expect(result).to(be_truthy)
-  end
-
-  it "should return true if a valid domain name" do
-    result = scope.function_is_domain_name(["foo.bar.com"])
-    expect(result).to(be_truthy)
-  end
-
-  it "should allow domain parts to start with numbers" do
-    result = scope.function_is_domain_name(["3foo.2bar.com"])
-    expect(result).to(be_truthy)
-  end
-
-  it "should allow domain to end with a dot" do
-    result = scope.function_is_domain_name(["3foo.2bar.com."])
-    expect(result).to(be_truthy)
-  end
-
-  it "should allow a single part domain" do
-    result = scope.function_is_domain_name(["orange"])
-    expect(result).to(be_truthy)
-  end
-
-  it "should return false if domain parts start with hyphens" do
-    result = scope.function_is_domain_name(["-3foo.2bar.com"])
-    expect(result).to(be_falsey)
-  end
-
-  it "should return true if domain contains hyphens" do
-    result = scope.function_is_domain_name(["3foo-bar.2bar-fuzz.com"])
-    expect(result).to(be_truthy)
-  end
-
-  it "should return false if domain name contains spaces" do
-    result = scope.function_is_domain_name(["not valid"])
-    expect(result).to(be_falsey)
-  end
-
   # Values obtained from Facter values will be frozen strings
   # in newer versions of Facter:
-  it "should not throw an exception if passed a frozen string" do
-    result = scope.function_is_domain_name(["my.domain.name".freeze])
-    expect(result).to(be_truthy)
+  it { is_expected.to run.with_params('www.example.com'.freeze).and_return(true) }
+  describe 'top level domain must be alphabetic if there are multiple labels' do
+    it { is_expected.to run.with_params('2com').and_return(true) }
+    it { is_expected.to run.with_params('www.example.2com').and_return(false) }
   end
-
-  it "should return false if top-level domain is not entirely alphabetic" do
-    result = scope.function_is_domain_name(["kiwi.2bar"])
-    expect(result).to(be_falsey)
-  end
-
-  it "should return false if domain name has the dotted-decimal form, e.g. an IPv4 address" do
-    result = scope.function_is_domain_name(["192.168.1.1"])
-    expect(result).to(be_falsey)
+  describe 'IP addresses are not domain names' do
+    it { is_expected.to run.with_params('192.168.1.1').and_return(false) }
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/is_email_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_email_address_spec.rb
new file mode 100755 (executable)
index 0000000..8b7b358
--- /dev/null
@@ -0,0 +1,14 @@
+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('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) }
+  it { is_expected.to run.with_params('1.2.3@domain').and_return(false) }
+  it { is_expected.to run.with_params('1.2.3.4.5@').and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+end
index d926634..af3322e 100755 (executable)
@@ -1,33 +1,42 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_float function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'is_float' do
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_float")).to eq("function_is_float")
-  end
+  it { is_expected.not_to eq(nil) }
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_float([]) }.to( raise_error(Puppet::ParseError))
-  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(0.1, 0.2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
 
-  it "should return true if a float" do
-    result = scope.function_is_float(["0.12"])
-    expect(result).to(eq(true))
+  describe 'passing a string' do
+    it { is_expected.to run.with_params('0.1').and_return(true) }
+    it { is_expected.to run.with_params('1.0').and_return(true) }
+    it { is_expected.to run.with_params('1').and_return(false) }
+    it { is_expected.to run.with_params('one').and_return(false) }
+    it { is_expected.to run.with_params('one 1.0').and_return(false) }
+    it { is_expected.to run.with_params('1.0 one').and_return(false) }
   end
 
-  it "should return false if a string" do
-    result = scope.function_is_float(["asdf"])
-    expect(result).to(eq(false))
+  describe 'passing numbers' do
+    it { is_expected.to run.with_params(0.1).and_return(true) }
+    it { is_expected.to run.with_params(1.0).and_return(true) }
+    it { is_expected.to run.with_params(1).and_return(false) }
   end
 
-  it "should return false if an integer" do
-    result = scope.function_is_float(["3"])
-    expect(result).to(eq(false))
-  end
-  it "should return true if a float is created from an arithmetical operation" do
-    result = scope.function_is_float([3.2*2])
-    expect(result).to(eq(true))
+  context 'Checking for deprecation warning' do
+    after(:all) 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'))
+      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
+      is_expected.to run.with_params(1.0).and_return(true)
+    end
   end
+
 end
index 3a9aa1b..44f08c0 100755 (executable)
@@ -1,31 +1,9 @@
-#!/usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_function_available function" do
-  before :all do
-    Puppet::Parser::Functions.autoloader.loadall
-  end
-
-  before :each do
-    @scope = Puppet::Parser::Scope.new
-  end
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_function_available")).to eq("function_is_function_available")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { @scope.function_is_function_available([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return false if a nonexistent function is passed" do
-    result = @scope.function_is_function_available(['jeff_mccunes_left_sock'])
-    expect(result).to(eq(false))
-  end
-
-  it "should return true if an available function is passed" do
-    result = @scope.function_is_function_available(['require'])
-    expect(result).to(eq(true))
-  end
-
+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
index a849411..c2599a0 100755 (executable)
@@ -1,29 +1,11 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_hash function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_hash")).to eq("function_is_hash")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_hash([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if passed a hash" do
-    result = scope.function_is_hash([{"a"=>1,"b"=>2}])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if passed an array" do
-    result = scope.function_is_hash([["a","b"]])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if passed a string" do
-    result = scope.function_is_hash(["asdf"])
-    expect(result).to(eq(false))
-  end
+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_return(false) }
+  it { is_expected.to run.with_params({}).and_return(true) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params(1).and_return(false) }
 end
index f0cbca8..8118ef4 100755 (executable)
@@ -1,69 +1,48 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_integer function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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(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("123\nfoo").and_return(true) }
+  it { is_expected.to run.with_params("foo\n123").and_return(true) }
+
+  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) }
+  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(true).and_return(false) }
+  it { is_expected.to run.with_params(false).and_return(false) }
+  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
+      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'))
+      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
+      is_expected.to run.with_params(50).and_return(true)
+    end
+  end 
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_integer")).to eq("function_is_integer")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_integer([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if an integer" do
-    result = scope.function_is_integer(["3"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return true if a negative integer" do
-    result = scope.function_is_integer(["-7"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if a float" do
-    result = scope.function_is_integer(["3.2"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if a string" do
-    result = scope.function_is_integer(["asdf"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return true if an integer is created from an arithmetical operation" do
-    result = scope.function_is_integer([3*2])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if an array" do
-    result = scope.function_is_numeric([["asdf"]])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if a hash" do
-    result = scope.function_is_numeric([{"asdf" => false}])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if a boolean" do
-    result = scope.function_is_numeric([true])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if a whitespace is in the string" do
-    result = scope.function_is_numeric([" -1324"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if it is zero prefixed" do
-    result = scope.function_is_numeric(["0001234"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if it is wrapped inside an array" do
-    result = scope.function_is_numeric([[1234]])
-    expect(result).to(eq(false))
-  end
 end
index c16d12b..39525d7 100755 (executable)
@@ -1,39 +1,40 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_ip_address function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_ip_address")).to eq("function_is_ip_address")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_ip_address([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if an IPv4 address" do
-    result = scope.function_is_ip_address(["1.2.3.4"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return true if a full IPv6 address" do
-    result = scope.function_is_ip_address(["fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return true if a compressed IPv6 address" do
-    result = scope.function_is_ip_address(["fe00::1"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if not valid" do
-    result = scope.function_is_ip_address(["asdf"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if IP octets out of range" do
-    result = scope.function_is_ip_address(["1.1.1.300"])
-    expect(result).to(eq(false))
+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('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) }
+  it { is_expected.to run.with_params('1.2.3').and_return(false) }
+  it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) }
+  it { is_expected.to run.with_params('fe00::1').and_return(true) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74').and_return(true) }
+  it { is_expected.to run.with_params('FE80:0000:CD12:D123:E2F8:47FF:FE09:DD74').and_return(true) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:zzzz').and_return(false) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09').and_return(false) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74:dd74').and_return(false) }
+  it { is_expected.to run.with_params('').and_return(false) }
+  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) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+
+  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'))
+      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
+      is_expected.to run.with_params('1.2.3.4').and_return(true)
+    end
+    after(:all) do 
+      ENV.delete('STDLIB_LOG_DEPRECATIONS')
+    end
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/is_ipv4_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_ipv4_address_spec.rb
new file mode 100644 (file)
index 0000000..985260c
--- /dev/null
@@ -0,0 +1,32 @@
+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) }
+
+  SharedData::IPV4_PATTERNS.each do |value|
+    it { is_expected.to run.with_params(value).and_return(true) }
+  end
+
+  SharedData::IPV4_NEGATIVE_PATTERNS.each do |value|
+    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
+      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'))
+      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
+      is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first).and_return(true)
+    end
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb
new file mode 100644 (file)
index 0000000..acd6a87
--- /dev/null
@@ -0,0 +1,30 @@
+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('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) }
+  it { is_expected.to run.with_params('1.2.3.4.5').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 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+    after(:all) 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'))
+      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
+      is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true)
+    end
+  end
+end
index 66edd19..c1e33b8 100755 (executable)
@@ -1,29 +1,30 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_mac_address function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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('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('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) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_mac_address")).to eq("function_is_mac_address")
+  context 'function can handle 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 "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_mac_address([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if a valid mac address" do
-    result = scope.function_is_mac_address(["00:a0:1f:12:7f:a0"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if octets are out of range" do
-    result = scope.function_is_mac_address(["00:a0:1f:12:7f:g0"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if not valid" do
-    result = scope.function_is_mac_address(["not valid"])
-    expect(result).to(eq(false))
-  end
+  it {
+    pending "should properly typecheck its arguments"
+    is_expected.to run.with_params(1).and_return(false)
+  }
+  it {
+    pending "should properly typecheck its arguments"
+    is_expected.to run.with_params({}).and_return(false)
+  }
+  it {
+    pending "should properly typecheck its arguments"
+    is_expected.to run.with_params([]).and_return(false)
+  }
 end
index 4176961..5962d8a 100755 (executable)
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_numeric function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_numeric")).to eq("function_is_numeric")
-  end
-
-  it "should raise a ParseError if there is less than 1 argument" do
-    expect { scope.function_is_numeric([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if an integer" do
-    result = scope.function_is_numeric(["3"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return true if a float" do
-    result = scope.function_is_numeric(["3.2"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return true if an integer is created from an arithmetical operation" do
-    result = scope.function_is_numeric([3*2])
-    expect(result).to(eq(true))
-  end
-
-  it "should return true if a float is created from an arithmetical operation" do
-    result = scope.function_is_numeric([3.2*2])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if a string" do
-    result = scope.function_is_numeric(["asdf"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if an array" do
-    result = scope.function_is_numeric([["asdf"]])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if an array of integers" do
-    result = scope.function_is_numeric([[1,2,3,4]])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if a hash" do
-    result = scope.function_is_numeric([{"asdf" => false}])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if a hash with numbers in it" do
-    result = scope.function_is_numeric([{1 => 2}])
-    expect(result).to(eq(false))
-  end
-
-  it "should return false if a boolean" do
-    result = scope.function_is_numeric([true])
-    expect(result).to(eq(false))
-  end
-
-  it "should return true if a negative float with exponent" do
-    result = scope.function_is_numeric(["-342.2315e-12"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if a negative integer with whitespaces before/after the dash" do
-    result = scope.function_is_numeric([" -  751"])
-    expect(result).to(eq(false))
+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(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('-342.2315e-12').and_return(true) }
+
+  it { is_expected.to run.with_params('one').and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  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(true).and_return(false) }
+  it { is_expected.to run.with_params(false).and_return(false) }
+  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
+      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'))
+      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
+      is_expected.to run.with_params(7).and_return(true)
+    end
   end
 
-#  it "should return true if a hexadecimal" do
-#    result = scope.function_is_numeric(["0x52F8c"])
-#    result.should(eq(true))
-#  end
-#
-#  it "should return true if a hexadecimal with uppercase 0X prefix" do
-#    result = scope.function_is_numeric(["0X52F8c"])
-#    result.should(eq(true))
-#  end
-#
-#  it "should return false if a hexadecimal without a prefix" do
-#    result = scope.function_is_numeric(["52F8c"])
-#    result.should(eq(false))
-#  end
-#
-#  it "should return true if a octal" do
-#    result = scope.function_is_numeric(["0751"])
-#    result.should(eq(true))
-#  end
-#
-#  it "should return true if a negative hexadecimal" do
-#    result = scope.function_is_numeric(["-0x52F8c"])
-#    result.should(eq(true))
-#  end
-#
-#  it "should return true if a negative octal" do
-#    result = scope.function_is_numeric(["-0751"])
-#    result.should(eq(true))
-#  end
-#
-#  it "should return false if a negative octal with whitespaces before/after the dash" do
-#    result = scope.function_is_numeric([" -  0751"])
-#    result.should(eq(false))
-#  end
-#
-#  it "should return false if a bad hexadecimal" do
-#    result = scope.function_is_numeric(["0x23d7g"])
-#    result.should(eq(false))
-#  end
-#
-#  it "should return false if a bad octal" do
-#    result = scope.function_is_numeric(["0287"])
-#    result.should(eq(false))
-#  end
 end
index 6a0801a..e92f85c 100755 (executable)
@@ -1,34 +1,47 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the is_string function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'is_string' do
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("is_string")).to eq("function_is_string")
-  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 {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_is_string([]) }.to( raise_error(Puppet::ParseError))
-  end
+  it { is_expected.to run.with_params(3).and_return(false) }
+  it { is_expected.to run.with_params('3').and_return(false) }
+  it { is_expected.to run.with_params(-3).and_return(false) }
+  it { is_expected.to run.with_params('-3').and_return(false) }
 
-  it "should return true if a string" do
-    result = scope.function_is_string(["asdf"])
-    expect(result).to(eq(true))
-  end
+  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 "should return false if an integer" do
-    result = scope.function_is_string(["3"])
-    expect(result).to(eq(false))
-  end
+  it { is_expected.to run.with_params([]).and_return(false) }
+  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(true).and_return(false) }
+  it { is_expected.to run.with_params(false).and_return(false) }
+  it { is_expected.to run.with_params('one').and_return(true) }
+  it { is_expected.to run.with_params('0001234').and_return(true) }
 
-  it "should return false if a float" do
-    result = scope.function_is_string(["3.23"])
-    expect(result).to(eq(false))
-  end
+  context 'Checking for deprecation warning' do
+    after(:all) 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'))
+      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
+      is_expected.to run.with_params('bob').and_return(true)
+    end
+  end 
 
-  it "should return false if an array" do
-    result = scope.function_is_string([["a","b","c"]])
-    expect(result).to(eq(false))
-  end
 end
index 4a9ae87..0a2a50c 100755 (executable)
@@ -1,40 +1,30 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the join_keys_to_values function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 "should exist" do
-    expect(Puppet::Parser::Functions.function("join_keys_to_values")).to eq("function_join_keys_to_values")
-  end
-
-  it "should raise a ParseError if there are fewer than two arguments" do
-    expect { scope.function_join_keys_to_values([{}]) }.to raise_error Puppet::ParseError
-  end
+  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']) }
 
-  it "should raise a ParseError if there are greater than two arguments" do
-    expect { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.to raise_error Puppet::ParseError
+  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(['ҝẽγ万√ạĺűē']) }
   end
 
-  it "should raise a TypeError if the first argument is an array" do
-    expect { scope.function_join_keys_to_values([[1,2], ',']) }.to raise_error TypeError
+  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)
   end
-
-  it "should raise a TypeError if the second argument is an array" do
-    expect { scope.function_join_keys_to_values([{}, [1,2]]) }.to raise_error TypeError
-  end
-
-  it "should raise a TypeError if the second argument is a number" do
-    expect { scope.function_join_keys_to_values([{}, 1]) }.to raise_error TypeError
-  end
-
-  it "should return an empty array given an empty hash" do
-    result = scope.function_join_keys_to_values([{}, ":"])
-    expect(result).to eq([])
-  end
-
-  it "should join hash's keys to its values" do
-    result = scope.function_join_keys_to_values([{'a'=>1,2=>'foo',:b=>nil}, ":"])
-    expect(result).to match_array(['a:1','2:foo','b:'])
+  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)
   end
 end
+
index 793c36f..98852d5 100755 (executable)
@@ -1,19 +1,20 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the join function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'join' 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 {
+    pending("Current implementation ignores parameters after the second.")
+    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, /Requires array to work with/) }
+  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /Requires string to work with/) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("join")).to eq("function_join")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_join([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should join an array into a string" do
-    result = scope.function_join([["a","b","c"], ":"])
-    expect(result).to(eq("a:b:c"))
-  end
+  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(['one']).and_return('one') }
+  it { is_expected.to run.with_params(['one'], ':').and_return('one') }
+  it { is_expected.to run.with_params(['one', 'two', 'three']).and_return('onetwothree') }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ':').and_return('one:two:three') }
+  it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ':').and_return('ōŋể:ŧשợ:ţђŕẽё') }
 end
index f2e7d42..fc7d6d8 100755 (executable)
@@ -1,21 +1,24 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the keys function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("keys")).to eq("function_keys")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_keys([]) }.to( raise_error(Puppet::ParseError))
+describe 'keys' 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 {
+    pending("Current implementation ignores parameters after the first.")
+    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, /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_return([]) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key']) }
+  it 'should return the array of keys' do
+    result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }])
+    expect(result).to match_array(['key1', 'key2'])
   end
 
-  it "should return an array of keys when given a hash" do
-    result = scope.function_keys([{'a'=>1, 'b'=>2}])
-    # =~ performs 'array with same elements' (set) matching
-    # For more info see RSpec::Matchers::MatchArray
-    expect(result).to match_array(['a','b'])
+  it 'should run with UTF8 and double byte characters' do
+    result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }])
+    expect(result).to match_array(['ҝểү', 'キー'])
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/length.rb b/3rdparty/modules/stdlib/spec/functions/length.rb
new file mode 100755 (executable)
index 0000000..d1ab003
--- /dev/null
@@ -0,0 +1,35 @@
+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
diff --git a/3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb b/3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb
new file mode 100755 (executable)
index 0000000..9496fcb
--- /dev/null
@@ -0,0 +1,61 @@
+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) }
+
+  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"}')
+    end
+
+    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(/\/(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
+
+      result = subject.call(['science'])
+      expect(result['name']).to eq('spencer-science')
+    end
+
+    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)
+      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)
+      end
+      result = subject.call(['science', true])
+      expect(result).to eq({})
+    end
+    end
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb b/3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb
new file mode 100644 (file)
index 0000000..dbef805
--- /dev/null
@@ -0,0 +1,66 @@
+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) }
+
+  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"}')
+    end
+
+    context 'when a non-existing file is specified' do
+      let(:filename) {
+        if Puppet::Util::Platform.windows?
+          'C:/tmp/doesnotexist'
+        else
+          '/tmp/doesnotexist'
+        end
+      }
+      before {
+        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
+
+    context 'when an existing file is specified' do
+      let(:filename) {
+        if Puppet::Util::Platform.windows?
+          'C:/tmp/doesexist'
+        else
+          '/tmp/doesexist'
+        end
+      }
+      let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} }
+      let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
+      before {
+        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
+      }
+      it { is_expected.to run.with_params(filename).and_return(data) }
+    end
+
+    context 'when the file could not be parsed' do
+      let(:filename) {
+        if Puppet::Util::Platform.windows?
+          'C:/tmp/doesexist'
+        else
+          '/tmp/doesexist'
+        end
+      }
+      let(:json) { '{"key":"value"}' }
+      before {
+        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!'
+      }
+      it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
+    end
+  end
+end
index cdc3d6f..e9428e3 100755 (executable)
@@ -1,25 +1,36 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the loadyaml function" do
-  include PuppetlabsSpec::Files
+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) }
 
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("loadyaml")).to eq("function_loadyaml")
+  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({'デフォルト' => '値'}) }
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_loadyaml([]) }.to raise_error(Puppet::ParseError)
+  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) }
   end
 
-  it "should convert YAML file to a data structure" do
-    yaml_file = tmpfilename ('yamlfile')
-    File.open(yaml_file, 'w') do |fh|
-      fh.write("---\n aaa: 1\n bbb: 2\n ccc: 3\n ddd: 4\n")
-    end
-    result = scope.function_loadyaml([yaml_file])
-    expect(result).to eq({"aaa" => 1, "bbb" => 2, "ccc" => 3, "ddd" => 4 })
+  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 { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) }
   end
 end
index 68cca1c..a5a09ed 100755 (executable)
@@ -1,28 +1,35 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the lstrip function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("lstrip")).to eq("function_lstrip")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_lstrip([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should lstrip a string" do
-    result = scope.function_lstrip(["  asdf"])
-    expect(result).to(eq('asdf'))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new("  asdf")
-    result = scope.function_lstrip([value])
-    result.should(eq("asdf"))
-  end
+describe 'lstrip' 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 {
+    pending("Current implementation ignores parameters after the first.")
+    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, /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_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("\t").and_return('') }
+  it { is_expected.to run.with_params("\t ").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('     one').and_return('one') }
+  it { is_expected.to run.with_params("\tone").and_return('one') }
+  it { is_expected.to run.with_params("\t one").and_return('one') }
+  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('     one ').and_return('one ') }
+  it { is_expected.to run.with_params('     ǿňè ').and_return('ǿňè ') }
+  it { is_expected.to run.with_params("\tone ").and_return('one ') }
+  it { is_expected.to run.with_params("\t one ").and_return('one ') }
+  it { is_expected.to run.with_params("one \t").and_return("one \t") }
+  it { is_expected.to run.with_params(" one \t").and_return("one \t") }
+  it { is_expected.to run.with_params("     one \t").and_return("one \t") }
+  it { is_expected.to run.with_params("\tone \t").and_return("one \t") }
+  it { is_expected.to run.with_params("\t one \t").and_return("one \t") }
+  it { is_expected.to run.with_params(' o n e ').and_return('o n e ') }
+  it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one ') }
 end
index c3d8a13..66fb0c8 100755 (executable)
@@ -1,27 +1,21 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the max function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("max")).to eq("function_max")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_max([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should be able to compare strings" do
-    expect(scope.function_max(["albatross","dog","horse"])).to(eq("horse"))
-  end
-
-  it "should be able to compare numbers" do
-    expect(scope.function_max([6,8,4])).to(eq(8))
-  end
+describe 'max' 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).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) }
+  it { is_expected.to run.with_params(3, 2, 1).and_return(3) }
+  it { is_expected.to run.with_params('one').and_return('one') }
+  it { is_expected.to run.with_params('one', 'two').and_return('two') }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_return('two') }
+  it { is_expected.to run.with_params('three', 'two', 'one').and_return('two') }
 
-  it "should be able to compare a number with a stringified number" do
-    expect(scope.function_max([1,"2"])).to(eq("2"))
+  describe 'implementation artifacts' do
+    it { is_expected.to run.with_params(1, 'one').and_return('one') }
+    it { is_expected.to run.with_params('1', 'one').and_return('one') }
+    it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.4e0') }
+    it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.3e1) }
   end
 end
index 1a1d7c6..8988632 100755 (executable)
@@ -1,34 +1,23 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the member function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("member")).to eq("function_member")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_member([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if a member is in an array" do
-    result = scope.function_member([["a","b","c"], "a"])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if a member is not in an array" do
-    result = scope.function_member([["a","b","c"], "d"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return true if a member array is in an array" do
-    result = scope.function_member([["a","b","c"], ["a", "b"]])
-    expect(result).to(eq(true))
-  end
-
-  it "should return false if a member array is not in an array" do
-    result = scope.function_member([["a","b","c"], ["d", "e"]])
-    expect(result).to(eq(false))
-  end
+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 {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, /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) }
+  it { is_expected.to run.with_params([''], '').and_return(true) }
+  it { is_expected.to run.with_params([''], ['']).and_return(true) }
+  it { is_expected.to run.with_params([], 'one').and_return(false) }
+  it { is_expected.to run.with_params([], ['one']).and_return(false) }
+  it { is_expected.to run.with_params(['one'], 'one').and_return(true) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return(true) }
+  it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) }
+  it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ŧẅồ']).and_return(true) }
+  it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) }
+  it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ƒί√ə']).and_return(false) }
 end
index 2abf976..3b2e3ef 100755 (executable)
@@ -1,52 +1,25 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:merge) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe 'when calling merge from puppet' do
-    it "should not compile when no arguments are passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = '$x = merge()'
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
-
-    it "should not compile when 1 argument is passed" do
-      skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
-      Puppet[:code] = "$my_hash={'one' => 1}\n$x = merge($my_hash)"
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    end
-  end
-
-  describe 'when calling merge on the scope instance' do
-    it 'should require all parameters are hashes' do
-      expect { new_hash = scope.function_merge([{}, '2'])}.to raise_error(Puppet::ParseError, /unexpected argument type String/)
-      expect { new_hash = scope.function_merge([{}, 2])}.to raise_error(Puppet::ParseError, /unexpected argument type Fixnum/)
-    end
-
-    it 'should accept empty strings as puppet undef' do
-      expect { new_hash = scope.function_merge([{}, ''])}.not_to raise_error
-    end
-
-    it 'should be able to merge two hashes' do
-      new_hash = scope.function_merge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}])
-      expect(new_hash['one']).to   eq('1')
-      expect(new_hash['two']).to   eq('2')
-      expect(new_hash['three']).to eq('2')
-    end
-
-    it 'should merge multiple hashes' do
-      hash = scope.function_merge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}])
-      expect(hash['one']).to eq('3')
-    end
-
-    it 'should accept empty hashes' do
-      expect(scope.function_merge([{},{},{}])).to eq({})
-    end
+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 {
+    pending 'should not special case this'
+    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({}) }
+  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({ 'key1' => 'value1' }, { 'key2' => 'value2' }, { 'key3' => 'value3' }) \
+      .and_return({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' })
+  }
 end
index 35a0890..c840a72 100755 (executable)
@@ -1,27 +1,21 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the min function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("min")).to eq("function_min")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_min([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should be able to compare strings" do
-    expect(scope.function_min(["albatross","dog","horse"])).to(eq("albatross"))
-  end
-
-  it "should be able to compare numbers" do
-    expect(scope.function_min([6,8,4])).to(eq(4))
-  end
+describe 'min' 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).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('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') }
+  it { is_expected.to run.with_params('three', 'two', 'one').and_return('one') }
 
-  it "should be able to compare a number with a stringified number" do
-    expect(scope.function_min([1,"2"])).to(eq(1))
+  describe 'implementation artifacts' do
+    it { is_expected.to run.with_params(1, 'one').and_return(1) }
+    it { is_expected.to run.with_params('1', 'one').and_return('1') }
+    it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.3e1') }
+    it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.4e0) }
   end
 end
index d0ba935..494afff 100755 (executable)
@@ -1,67 +1,22 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the num2bool function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("num2bool")).to eq("function_num2bool")
-  end
-
-  it "should raise a ParseError if there are no arguments" do
-    expect { scope.function_num2bool([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if there are more than 1 arguments" do
-    expect { scope.function_num2bool(["foo","bar"]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if passed something non-numeric" do
-    expect { scope.function_num2bool(["xyzzy"]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return true if passed string 1" do
-    result = scope.function_num2bool(["1"])
-    expect(result).to(be_truthy)
-  end
-
-  it "should return true if passed string 1.5" do
-    result = scope.function_num2bool(["1.5"])
-    expect(result).to(be_truthy)
-  end
-
-  it "should return true if passed number 1" do
-    result = scope.function_num2bool([1])
-    expect(result).to(be_truthy)
-  end
-
-  it "should return false if passed string 0" do
-    result = scope.function_num2bool(["0"])
-    expect(result).to(be_falsey)
-  end
-
-  it "should return false if passed number 0" do
-    result = scope.function_num2bool([0])
-    expect(result).to(be_falsey)
-  end
-
-  it "should return false if passed string -1" do
-    result = scope.function_num2bool(["-1"])
-    expect(result).to(be_falsey)
-  end
-
-  it "should return false if passed string -1.5" do
-    result = scope.function_num2bool(["-1.5"])
-    expect(result).to(be_falsey)
-  end
-
-  it "should return false if passed number -1" do
-    result = scope.function_num2bool([-1])
-    expect(result).to(be_falsey)
-  end
-
-  it "should return false if passed float -1.5" do
-    result = scope.function_num2bool([-1.5])
-    expect(result).to(be_falsey)
-  end
+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(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) }
+  it { is_expected.to run.with_params('1.5').and_return(true) }
+  it { is_expected.to run.with_params(-1).and_return(false) }
+  it { is_expected.to run.with_params('-1').and_return(false) }
+  it { is_expected.to run.with_params(-1.5).and_return(false) }
+  it { is_expected.to run.with_params('-1.5').and_return(false) }
+  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_return(false) }
+  it { is_expected.to run.with_params('{}').and_raise_error(Puppet::ParseError, /does not look like a number/) }
 end
index 1dd41b9..7b07e49 100755 (executable)
@@ -1,22 +1,69 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the parsejson function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'parsejson' do
+  it 'should exist' do
+    is_expected.not_to eq(nil)
+  end
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("parsejson")).to eq("function_parsejson")
+  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)
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_parsejson([]) }.to( raise_error(Puppet::ParseError))
+  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'})
+    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'])
+    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({})
+    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] } })
+    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({'×' =>'これ', 'ý' => '記号', 'です' => { '©' => ['Á', 'ß'] } })
+    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'})
+    end
+
   end
 
-  it "should convert JSON to a data structure" do
-    json = <<-EOS
-["aaa","bbb","ccc"]
-EOS
-    result = scope.function_parsejson([json])
-    expect(result).to(eq(['aaa','bbb','ccc']))
+  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)
+    end
+
+    it 'should support 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')
+      end
+    end
+
   end
+
 end
index e5f145b..c2a138c 100755 (executable)
@@ -1,24 +1,86 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the parseyaml function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'parseyaml' do
+  it 'should exist' 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)
+  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')
+    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'})
+    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'])
+    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]}})
+    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"=>"×", "これ"=>"記号", "です"=>{"©"=>["Á", "ß"]} })
+    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'})
+    end
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("parseyaml")).to eq("function_parseyaml")
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_parseyaml([]) }.to( raise_error(Puppet::ParseError))
+  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)
+    end
   end
 
-  it "should convert YAML to a data structure" do
-    yaml = <<-EOS
-- aaa
-- bbb
-- ccc
-EOS
-    result = scope.function_parseyaml([yaml])
-    expect(result).to(eq(['aaa','bbb','ccc']))
+    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
+    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'})
+    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')
+      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')
+        end
+      end
+    end
+
   end
+
 end
index db10cc3..a7ffc86 100755 (executable)
@@ -1,58 +1,26 @@
-#!/usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the pick_default function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("pick_default")).to eq("function_pick_default")
-  end
-
-  it 'should return the correct value' do
-    expect(scope.function_pick_default(['first', 'second'])).to eq('first')
-  end
-
-  it 'should return the correct value if the first value is empty' do
-    expect(scope.function_pick_default(['', 'second'])).to eq('second')
-  end
-
-  it 'should skip empty string values' do
-    expect(scope.function_pick_default(['', 'first'])).to eq('first')
-  end
-
-  it 'should skip :undef values' do
-    expect(scope.function_pick_default([:undef, 'first'])).to eq('first')
-  end
-
-  it 'should skip :undefined values' do
-    expect(scope.function_pick_default([:undefined, 'first'])).to eq('first')
-  end
-
-  it 'should return the empty string if it is the last possibility' do
-    expect(scope.function_pick_default([:undef, :undefined, ''])).to eq('')
-  end
-
-  it 'should return :undef if it is the last possibility' do
-    expect(scope.function_pick_default(['', :undefined, :undef])).to eq(:undef)
-  end
-
-  it 'should return :undefined if it is the last possibility' do
-    expect(scope.function_pick_default([:undef, '', :undefined])).to eq(:undefined)
-  end
-
-  it 'should return the empty string if it is the only possibility' do
-    expect(scope.function_pick_default([''])).to eq('')
-  end
-
-  it 'should return :undef if it is the only possibility' do
-    expect(scope.function_pick_default([:undef])).to eq(:undef)
-  end
-
-  it 'should return :undefined if it is the only possibility' do
-    expect(scope.function_pick_default([:undefined])).to eq(:undefined)
-  end
-
-  it 'should error if no values are passed' do
-    expect { scope.function_pick_default([]) }.to raise_error(Puppet::Error, /Must receive at least one argument./)
+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('one', 'two').and_return('one') }
+  it { is_expected.to run.with_params('ớņệ', 'ťωơ').and_return('ớņệ') }
+  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') }
+
+  [ '', :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) }
+    end
   end
 end
index 8be8f58..438553b 100755 (executable)
@@ -1,34 +1,17 @@
-#!/usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the pick function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("pick")).to eq("function_pick")
-  end
-
-  it 'should return the correct value' do
-    expect(scope.function_pick(['first', 'second'])).to eq('first')
-  end
-
-  it 'should return the correct value if the first value is empty' do
-    expect(scope.function_pick(['', 'second'])).to eq('second')
-  end
-
-  it 'should remove empty string values' do
-    expect(scope.function_pick(['', 'first'])).to eq('first')
-  end
-
-  it 'should remove :undef values' do
-    expect(scope.function_pick([:undef, 'first'])).to eq('first')
-  end
-
-  it 'should remove :undefined values' do
-    expect(scope.function_pick([:undefined, 'first'])).to eq('first')
-  end
-
-  it 'should error if no values are passed' do
-    expect { scope.function_pick([]) }.to( raise_error(Puppet::ParseError, "pick(): must receive at least one non empty value"))
+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('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 ţẽם') }
   end
 end
index aec8a7d..5510c58 100755 (executable)
@@ -1,33 +1,29 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the prefix function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "raises a ParseError if there is less than 1 arguments" do
-    expect { scope.function_prefix([]) }.to raise_error(Puppet::ParseError, /number of arguments/)
-  end
-
-  it "raises an error if the first argument is not an array" do
-    expect {
-      scope.function_prefix([Object.new])
-    }.to raise_error(Puppet::ParseError, /expected first argument to be an Array/)
-  end
-
-
-  it "raises an error if the second argument is not a string" do
-    expect {
-      scope.function_prefix([['first', 'second'], 42])
-    }.to raise_error(Puppet::ParseError, /expected second argument to be a String/)
-  end
-
-  it "returns a prefixed array" do
-    result = scope.function_prefix([['a','b','c'], 'p'])
-    expect(result).to(eq(['pa','pb','pc']))
-  end
-
-  it "returns a prefixed hash" do
-    result = scope.function_prefix([{'a' => 'b','b' => 'c','c' => 'd'}, 'p'])
-    expect(result).to(eq({'pa'=>'b','pb'=>'c','pc'=>'d'}))
-  end
+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 {
+    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)
+  }
+  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_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']) }
+  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(['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({}, '').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({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'pre') \
+      .and_return({ 'prekey1' => 'value1', 'prekey2' => 'value2', 'prekey3' => 'value3' })
+  }
 end
index c90282e..a13be64 100644 (file)
@@ -1,17 +1,13 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:private) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  subject do
-    function_name = Puppet::Parser::Functions.function(:private)
-    scope.method(function_name)
-  end
-
+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.")
-    subject.call []
+    begin
+      subject.call []
+    rescue
+      # ignore this
+    end
   end
 
   context "when called from inside module" do
index 3378090..9e03464 100644 (file)
@@ -1,95 +1,76 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the pw_hash function" do
+describe 'pw_hash' do
 
-  before :all do
-    @enhanced_salts_supported = RUBY_PLATFORM == 'java'
-  end
-
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+  it { is_expected.not_to eq(nil) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("pw_hash")).to eq("function_pw_hash")
+  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) }
   end
 
-  it "should raise an ArgumentError if there are less than 3 arguments" do
-    expect { scope.function_pw_hash([]) }.to( raise_error(ArgumentError, /[Ww]rong number of arguments/) )
-    expect { scope.function_pw_hash(['password']) }.to( raise_error(ArgumentError, /[Ww]rong number of arguments/) )
-    expect { scope.function_pw_hash(['password', 'sha-512']) }.to( raise_error(ArgumentError, /[Ww]rong number of arguments/) )
+  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) }
   end
 
-  it "should raise an ArgumentError if there are more than 3 arguments" do
-    expect { scope.function_pw_hash(['password', 'sha-512', 'salt', 5]) }.to( raise_error(ArgumentError, /[Ww]rong number of arguments/) )
+  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/) }
   end
 
-  it "should raise an ArgumentError if the first argument is not a string" do
-    expect { scope.function_pw_hash([['password'], 'sha-512', 'salt']) }.to( raise_error(ArgumentError, /first argument must be a string/) )
-    # in Puppet 3, numbers are passed as strings, so we can't test that
+  context 'when the first argument is undefined' do
+    it { is_expected.to run.with_params('', 'sha-256', 'salt').and_return(nil) }
+    it { is_expected.to run.with_params(nil, 'sha-256', 'salt').and_return(nil) }
   end
 
-  it "should return nil if the first argument is empty" do
-    expect(scope.function_pw_hash(['', 'sha-512', 'salt'])).to eq(nil)
+  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/) }
   end
 
-  it "should return nil if the first argument is undef" do
-    expect(scope.function_pw_hash([nil, 'sha-512', 'salt'])).to eq(nil)
+  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/) }
   end
 
-  it "should raise an ArgumentError if the second argument is an invalid hash type" do
-    expect { scope.function_pw_hash(['', 'invalid', 'salt']) }.to( raise_error(ArgumentError, /not a valid hash type/) )
+  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/) }
   end
 
-  it "should raise an ArgumentError if the second argument is not a string" do
-    expect { scope.function_pw_hash(['', [], 'salt']) }.to( raise_error(ArgumentError, /second argument must be a string/) )
+  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/) }
   end
 
-  it "should raise an ArgumentError if the third argument is not a string" do
-    expect { scope.function_pw_hash(['password', 'sha-512', ['salt']]) }.to( raise_error(ArgumentError, /third argument must be a string/) )
-    # in Puppet 3, numbers are passed as strings, so we can't test that
+  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/) }
   end
 
-  it "should raise an ArgumentError if the third argument is empty" do
-    expect { scope.function_pw_hash(['password', 'sha-512', '']) }.to( raise_error(ArgumentError, /third argument must not be empty/) )
-  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') }
 
-  it "should raise an ArgumentError if the third argument has invalid characters" do
-    expect { scope.function_pw_hash(['password', 'sha-512', '%']) }.to( raise_error(ArgumentError, /characters in salt must be in the set/) )
+    it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_raise_error(Puppet::ParseError, /system does not support enhanced salts/) }
   end
 
-  it "should fail on platforms with weak implementations of String#crypt" do
-    String.any_instance.expects(:crypt).with('$1$1').returns('$1SoNol0Ye6Xk')
-    expect { scope.function_pw_hash(['password', 'sha-512', 'salt']) }.to( raise_error(Puppet::ParseError, /system does not support enhanced salts/) )
-  end
-
-  if @enhanced_salts_supported
+  if RUBY_PLATFORM == 'java' or 'test'.crypt('$1$1') == '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
     describe "on systems with enhanced salts support" do
-      it "should return a hashed password" do
-        result = scope.function_pw_hash(['password', 'sha-512', 'salt'])
-        expect(result).to eql('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.')
-      end
-
-      it "should use the specified salt" do
-        result = scope.function_pw_hash(['password', 'sha-512', 'salt'])
-        expect(result).to match('salt')
-      end
-
-      it "should use the specified hash type" do
-        resultmd5 = scope.function_pw_hash(['password', 'md5', 'salt'])
-        resultsha256 = scope.function_pw_hash(['password', 'sha-256', 'salt'])
-        resultsha512 = scope.function_pw_hash(['password', 'sha-512', 'salt'])
-
-        expect(resultmd5).to eql('$1$salt$qJH7.N4xYta3aEG/dfqo/0')
-        expect(resultsha256).to eql('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1')
-        expect(resultsha512).to eql('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.')
-      end
-
-      it "should generate a valid hash" do
-        password_hash = scope.function_pw_hash(['password', 'sha-512', 'salt'])
-
-        hash_parts = password_hash.match(%r{\A\$(.*)\$([a-zA-Z0-9./]+)\$([a-zA-Z0-9./]+)\z})
+      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.') }
+    end
 
-        expect(hash_parts).not_to eql(nil)
+    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('password', 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt')).and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') }
       end
     end
   end
index ef86f97..ca569d5 100755 (executable)
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the range function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'range' do
+  it { is_expected.not_to eq(nil) }
 
-  it "exists" do
-    expect(Puppet::Parser::Functions.function("range")).to eq("function_range")
+  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 third.")
+      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('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) }
   end
 
-  it "raises a ParseError if there is less than 1 arguments" do
-    expect { scope.function_range([]) }.to raise_error Puppet::ParseError, /Wrong number of arguments.*0 for 1/
+  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) }
   end
 
-  describe 'with a letter range' do
-    it "returns a letter range" do
-      result = scope.function_range(["a","d"])
-      expect(result).to eq ['a','b','c','d']
-    end
+  context 'with characters as bounds' do
+    it { is_expected.to run.with_params('d', 'a').and_return([]) }
+    it { is_expected.to run.with_params('a', 'a').and_return(['a']) }
+    it { is_expected.to run.with_params('a', 'b').and_return(['a', 'b']) }
+    it { is_expected.to run.with_params('a', 'd').and_return(['a', 'b', 'c', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', 1).and_return(['a', 'b', 'c', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', '1').and_return(['a', 'b', 'c', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', 2).and_return(['a', 'c']) }
+    it { is_expected.to run.with_params('a', 'd', -2).and_return(['a', 'c']) }
+    it { is_expected.to run.with_params('a', 'd', 3).and_return(['a', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', 4).and_return(['a']) }
+  end
 
-    it "returns a letter range given a step of 1" do
-      result = scope.function_range(["a","d","1"])
-      expect(result).to eq ['a','b','c','d']
-    end
+  context 'with strings as bounds' do
+    it { is_expected.to run.with_params('onea', 'oned').and_return(['onea', 'oneb', 'onec', 'oned']) }
+    it { is_expected.to run.with_params('two', 'one').and_return([]) }
+    it { is_expected.to run.with_params('true', 'false').and_return([]) }
+    it { is_expected.to run.with_params('false', 'true').and_return(['false']) }
+  end
 
-    it "returns a stepped letter range" do
-      result = scope.function_range(["a","d","2"])
-      expect(result).to eq ['a','c']
-    end
+  context 'with integers as bounds' do
+    it { is_expected.to run.with_params(4, 1).and_return([]) }
+    it { is_expected.to run.with_params(1, 1).and_return([1]) }
+    it { is_expected.to run.with_params(1, 2).and_return([1, 2]) }
+    it { is_expected.to run.with_params(1, 4).and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params(1, 4, 1).and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params(1, 4, '1').and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params(1, 4, 2).and_return([1, 3]) }
+    it { is_expected.to run.with_params(1, 4, -2).and_return([1, 3]) }
+    it { is_expected.to run.with_params(1, 4, 3).and_return([1, 4]) }
+    it { is_expected.to run.with_params(1, 4, 4).and_return([1]) }
+  end
 
-    it "returns a stepped letter range given a negative step" do
-      result = scope.function_range(["a","d","-2"])
-      expect(result).to eq ['a','c']
-    end
+  context 'with integers as strings as bounds' do
+    it { is_expected.to run.with_params('4', '1').and_return([]) }
+    it { is_expected.to run.with_params('1', '1').and_return([1]) }
+    it { is_expected.to run.with_params('1', '2').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1', '4').and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params('1', '4', 1).and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params('1', '4', '1').and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params('1', '4', 2).and_return([1, 3]) }
+    it { is_expected.to run.with_params('1', '4', -2).and_return([1, 3]) }
+    it { is_expected.to run.with_params('1', '4', 3).and_return([1, 4]) }
+    it { is_expected.to run.with_params('1', '4', 4).and_return([1]) }
   end
 
-  describe 'with a number range' do
-    it "returns a number range" do
-      result = scope.function_range(["1","4"])
-      expect(result).to eq [1,2,3,4]
-    end
+  context 'with prefixed numbers as strings as bounds' do
+    it { is_expected.to run.with_params('host01', 'host04').and_return(['host01', 'host02', 'host03', 'host04']) }
+    it { is_expected.to run.with_params('01', '04').and_return([1, 2, 3, 4]) }
+  end
 
-    it "returns a number range given a step of 1" do
-      result = scope.function_range(["1","4","1"])
-      expect(result).to eq [1,2,3,4]
-    end
+  context 'with prefixed numbers as utf8 strings as bounds' do
+    it { is_expected.to run.with_params('ħөŝŧ01', 'ħөŝŧ04').and_return(['ħөŝŧ01', 'ħөŝŧ02', 'ħөŝŧ03', 'ħөŝŧ04']) }
+  end
 
-    it "returns a stepped number range" do
-      result = scope.function_range(["1","4","2"])
-      expect(result).to eq [1,3]
-    end
+  context 'with prefixed numbers as double byte character strings as bounds' do
+    it { is_expected.to run.with_params('ホスト01', 'ホスト04').and_return(['ホスト01', 'ホスト02', 'ホスト03', 'ホスト04']) }
+  end
 
-    it "returns a stepped number range given a negative step" do
-      result = scope.function_range(["1","4","-2"])
-      expect(result).to eq [1,3]
-    end
+  context 'with dash-range syntax' do
+    it { is_expected.to run.with_params('4-1').and_return([]) }
+    it { is_expected.to run.with_params('1-1').and_return([1]) }
+    it { is_expected.to run.with_params('1-2').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1-4').and_return([1, 2, 3, 4]) }
   end
 
-  describe 'with a numeric-like string range' do
-    it "works with padded hostname like strings" do
-      expected = ("host01".."host10").to_a
-      expect(scope.function_range(["host01","host10"])).to eq expected
-    end
+  context 'with two-dot-range syntax' do
+    it { is_expected.to run.with_params('4..1').and_return([]) }
+    it { is_expected.to run.with_params('1..1').and_return([1]) }
+    it { is_expected.to run.with_params('1..2').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1..4').and_return([1, 2, 3, 4]) }
+  end
 
-    it "coerces zero padded digits to integers" do
-      expected = (0..10).to_a
-      expect(scope.function_range(["00", "10"])).to eq expected
-    end
+  context 'with three-dot-range syntax' do
+    it { is_expected.to run.with_params('4...1').and_return([]) }
+    it { is_expected.to run.with_params('1...1').and_return([]) }
+    it { is_expected.to run.with_params('1...2').and_return([1]) }
+    it { is_expected.to run.with_params('1...3').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1...5').and_return([1, 2, 3, 4]) }
   end
 
-  describe 'with a numeric range' do
-    it "returns a range of numbers" do
-      expected = (1..10).to_a
-      expect(scope.function_range([1,10])).to eq expected
-    end
-    it "returns a range of numbers with step parameter" do
-      expected = (1..10).step(2).to_a
-      expect(scope.function_range([1,10,2])).to eq expected
-    end
-    it "works with mixed numeric like strings and numeric arguments" do
-      expected = (1..10).to_a
-      expect(scope.function_range(['1',10])).to eq expected
-      expect(scope.function_range([1,'10'])).to eq expected
-    end
+  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/)
+    }
+    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/)
+    }
+    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/)
+    }
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/regexpescape_spec.rb b/3rdparty/modules/stdlib/spec/functions/regexpescape_spec.rb
new file mode 100644 (file)
index 0000000..36dbe70
--- /dev/null
@@ -0,0 +1,41 @@
+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 {
+      pending("Current implementation ignores parameters after the first.")
+      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 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/) }
+  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
+      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
+      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")
+    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"]) }
+
+    context 'should run 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
+  end
+end
index 88a992e..86db7c7 100755 (executable)
@@ -1,20 +1,20 @@
-#!/usr/bin/env ruby
-
 require 'spec_helper'
 
-describe "the reject function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("reject")).to eq("function_reject")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_reject([]) }.to( raise_error(Puppet::ParseError))
-  end
+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 "should reject contents from an array" do
-    result = scope.function_reject([["1111", "aaabbb","bbbccc","dddeee"], "bbb"])
-    expect(result).to(eq(["1111", "dddeee"]))
-  end
+  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/)
+  }
+  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/)
+  }
+  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']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['one']) }
+  it { is_expected.to run.with_params(['όʼnệ', 'ţщồ', 'ţңяέέ'], 'ţ(щồ|ңяέέ)').and_return(['όʼnệ']) }
 end
index 1f04794..79bc0ad 100755 (executable)
@@ -1,28 +1,33 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the reverse function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 {
+    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)
+  }
+  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([]).and_return([]) }
+  it { is_expected.to run.with_params(['a']).and_return(['a']) }
+  it { is_expected.to run.with_params(['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['three', 'two', 'one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) }
+  it { is_expected.to run.with_params(['ổňë', 'ťŵọ', 'ŧңяəė', 'ƒŏůŗ']).and_return(['ƒŏůŗ', 'ŧңяəė', 'ťŵọ', 'ổňë']) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("reverse")).to eq("function_reverse")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_reverse([]) }.to( raise_error(Puppet::ParseError))
-  end
+  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('abc').and_return('cba') }
+  it { is_expected.to run.with_params('abcd').and_return('dcba') }
+  it { is_expected.to run.with_params('āβćđ').and_return('đćβā') }
 
-  it "should reverse a string" do
-    result = scope.function_reverse(["asdfghijkl"])
-    expect(result).to(eq('lkjihgfdsa'))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
+  context 'when using a class extending String' do
+    it 'should call its reverse method' do
+      value = AlsoString.new('asdfghjkl')
+      value.expects(:reverse).returns('foo')
+      expect(subject).to run.with_params(value).and_return('foo')
     end
-
-    value = AlsoString.new('asdfghjkl')
-    result = scope.function_reverse([value])
-    result.should(eq('lkjhgfdsa'))
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/round_spec.rb b/3rdparty/modules/stdlib/spec/functions/round_spec.rb
new file mode 100755 (executable)
index 0000000..8b13478
--- /dev/null
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe 'round' 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) }
+  it { is_expected.to run.with_params(34.5).and_return(35) }
+  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(3, 4).and_raise_error Puppet::ParseError }
+end
index f6b4838..a7663e2 100755 (executable)
@@ -1,33 +1,35 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the rstrip function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("rstrip")).to eq("function_rstrip")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_rstrip([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should rstrip a string" do
-    result = scope.function_rstrip(["asdf  "])
-    expect(result).to(eq('asdf'))
-  end
-
-  it "should rstrip each element in an array" do
-    result = scope.function_rstrip([["a ","b ", "c "]])
-    expect(result).to(eq(['a','b','c']))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new('asdf ')
-    result = scope.function_rstrip([value])
-    result.should(eq('asdf'))
-  end
+describe 'rstrip' 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 {
+    pending("Current implementation ignores parameters after the first.")
+    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, /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_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("\t").and_return('') }
+  it { is_expected.to run.with_params("\t ").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('     one').and_return('     one') }
+  it { is_expected.to run.with_params("\tone").and_return("\tone") }
+  it { is_expected.to run.with_params("\t one").and_return("\t one") }
+  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('     one ').and_return('     one') }
+  it { is_expected.to run.with_params(' ǿňè    ').and_return(' ǿňè') }
+  it { is_expected.to run.with_params("\tone ").and_return("\tone") }
+  it { is_expected.to run.with_params("\t one ").and_return("\t one") }
+  it { is_expected.to run.with_params("one\t").and_return('one') }
+  it { is_expected.to run.with_params(" one\t").and_return(' one') }
+  it { is_expected.to run.with_params("     one\t").and_return('     one') }
+  it { is_expected.to run.with_params("\tone\t").and_return("\tone") }
+  it { is_expected.to run.with_params("\t one\t").and_return("\t one") }
+  it { is_expected.to run.with_params(' o n e ').and_return(' o n e') }
+  it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return(' one') }
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/seeded_rand_spec.rb b/3rdparty/modules/stdlib/spec/functions/seeded_rand_spec.rb
new file mode 100644 (file)
index 0000000..ac108f4
--- /dev/null
@@ -0,0 +1,58 @@
+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 }
+  end
+
+  it "provides a random number greater or equal to zero" do
+    expect(seeded_rand(3, 'seed')).to satisfy {|n| n.to_i >= 0 }
+  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
+    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")
+
+    expect(val1).to eql(val2)
+  end
+
+  def seeded_rand(max, seed, args = {})
+    host = args[:host] || '127.0.0.1'
+
+    # 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)
+
+    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, '文字列')}
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/shell_escape_spec.rb b/3rdparty/modules/stdlib/spec/functions/shell_escape_spec.rb
new file mode 100644 (file)
index 0000000..77917dd
--- /dev/null
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+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) }
+  end
+
+  describe 'stringification' do
+    it { is_expected.to run.with_params(10).and_return('10') }
+    it { is_expected.to run.with_params(false).and_return('false') }
+  end
+
+  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('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') }
+  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\\ \\ \\ŧ\\ĕ\\χ\\ť') }
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/shell_join_spec.rb b/3rdparty/modules/stdlib/spec/functions/shell_join_spec.rb
new file mode 100644 (file)
index 0000000..46305bf
--- /dev/null
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+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) }
+  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('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') }
+
+  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('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト') }
+    end
+  end
+
+  describe 'stringification' do
+    it { is_expected.to run.with_params([10, false, 'foo']).and_return('10 false foo') }
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/shell_split_spec.rb b/3rdparty/modules/stdlib/spec/functions/shell_split_spec.rb
new file mode 100644 (file)
index 0000000..f8f9c90
--- /dev/null
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+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) }
+  end
+
+  describe 'stringification' do
+    it { is_expected.to run.with_params(10).and_return(['10']) }
+    it { is_expected.to run.with_params(false).and_return(['false']) }
+  end
+
+  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(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) }
+
+     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(['スペー', 'スを含むテ', ' キスト']) }
+    end
+  end
+end
index a62c1fb..4673daa 100755 (executable)
@@ -1,33 +1,38 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the shuffle function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 {
+    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)
+  }
+  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 "should exist" do
-    expect(Puppet::Parser::Functions.function("shuffle")).to eq("function_shuffle")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_shuffle([]) }.to( raise_error(Puppet::ParseError))
-  end
+  context 'when running with a specific seed' do
+    # make tests deterministic
+    before(:each) { srand(2) }
 
-  it "should shuffle a string and the result should be the same size" do
-    result = scope.function_shuffle(["asdf"])
-    expect(result.size).to(eq(4))
-  end
+    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']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['two', 'one', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) }
 
-  it "should shuffle a string but the sorted contents should still be the same" do
-    result = scope.function_shuffle(["adfs"])
-    expect(result.split("").sort.join("")).to(eq("adfs"))
-  end
+    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('abc').and_return('bac') }
+    it { is_expected.to run.with_params('abcd').and_return('dcba') }
 
-  it "should accept objects which extend String" do
-    class AlsoString < String
+    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('字本日語文列の') }
     end
 
-    value = AlsoString.new('asdf')
-    result = scope.function_shuffle([value])
-    result.size.should(eq(4))
+    context 'when using a class extending String' do
+      it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') }
+    end
   end
 end
index 18eb48f..2047423 100755 (executable)
@@ -1,24 +1,38 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the size function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'size' 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 {
+    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)
+  }
+  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([]).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 "should exist" do
-    expect(Puppet::Parser::Functions.function("size")).to eq("function_size")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_size([]) }.to( raise_error(Puppet::ParseError))
-  end
+  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 "should return the size of a string" do
-    result = scope.function_size(["asdf"])
-    expect(result).to(eq(4))
-  end
+  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) }
 
-  it "should return the size of an array" do
-    result = scope.function_size([["a","b","c"]])
-    expect(result).to(eq(3))
+  context 'when using a class extending String' do
+    it 'should call its size method' do
+      value = AlsoString.new('asdfghjkl')
+      value.expects(:size).returns('foo')
+      expect(subject).to run.with_params(value).and_return('foo')
+    end
   end
 end
index 4c2a66c..9abd039 100755 (executable)
@@ -1,24 +1,24 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the sort function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("sort")).to eq("function_sort")
-  end
-
-  it "should raise a ParseError if there is not 1 arguments" do
-    expect { scope.function_sort(['','']) }.to( raise_error(Puppet::ParseError))
+describe 'sort' 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/) }
   end
 
-  it "should sort an array" do
-    result = scope.function_sort([["a","c","b"]])
-    expect(result).to(eq(['a','b','c']))
+  context 'when called with an array' do
+    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(['c', 'b', 'a']).and_return(['a', 'b', 'c']) }
   end
 
-  it "should sort a string" do
-    result = scope.function_sort(["acb"])
-    expect(result).to(eq('abc'))
+  context 'when called with a string' do
+    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('cbda').and_return('abcd') }
   end
 end
index cd0eb37..b267d9a 100755 (executable)
@@ -1,24 +1,50 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the squeeze function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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(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) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("squeeze")).to eq("function_squeeze")
+  context 'when squeezing a single string' do
+    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('aaaaaaaaa').and_return('a') }
+    it { is_expected.to run.with_params('aaaaaaaaa', 'a').and_return('a') }
+    it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') }
   end
 
-  it "should raise a ParseError if there is less than 2 arguments" do
-    expect { scope.function_squeeze([]) }.to( raise_error(Puppet::ParseError))
+  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('語') }
+    it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậ語語語語©©©©©', '©').and_return('ậậậậậậậậậậậậậậậậậ語語語語©') }
   end
 
-  it "should squeeze a string" do
-    result = scope.function_squeeze(["aaabbbbcccc"])
-    expect(result).to(eq('abc'))
+  context 'when squeezing values in an array' do
+    it {
+      is_expected.to run \
+        .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc']) \
+        .and_return( ['', 'a', 'a',         'abc'])
+    }
+    it {
+      is_expected.to run \
+        .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'a') \
+        .and_return( ['', 'a', 'a',         'abbbbbbbbbbcccccccccc'])
+    }
+    it {
+      is_expected.to run \
+        .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'b-c') \
+        .and_return( ['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc'])
+    }
   end
 
-  it "should squeeze all elements in an array" do
-    result = scope.function_squeeze([["aaabbbbcccc","dddfff"]])
-    expect(result).to(eq(['abc','df']))
+  context 'when using a class extending String' do
+    it 'should call its squeeze method' do
+      value = AlsoString.new('aaaaaaaaa')
+      value.expects(:squeeze).returns('foo')
+      expect(subject).to run.with_params(value).and_return('foo')
+    end
   end
 end
index 1d205d7..7d8c47c 100755 (executable)
@@ -1,31 +1,23 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the str2bool function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 {
+    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)
+  }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Unknown type of boolean given/) }
 
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("str2bool")).to eq("function_str2bool")
+  describe 'when testing values that mean "true"' do
+    [ 'TRUE','1', 't', 'y', 'true', 'yes', true ].each do |value|
+      it { is_expected.to run.with_params(value).and_return(true) }
+    end
   end
 
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_str2bool([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should convert string 'true' to true" do
-    result = scope.function_str2bool(["true"])
-    expect(result).to(eq(true))
-  end
-
-  it "should convert string 'undef' to false" do
-    result = scope.function_str2bool(["undef"])
-    expect(result).to(eq(false))
-  end
-
-  it "should return the boolean it was called with" do
-    result = scope.function_str2bool([true])
-    expect(result).to(eq(true))
-    result = scope.function_str2bool([false])
-    expect(result).to(eq(false))
+  describe 'when testing values that mean "false"' do
+    [ '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
 end
index ab7f57f..2e1e818 100755 (executable)
@@ -1,45 +1,17 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the str2saltedsha512 function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 "should exist" do
-    expect(Puppet::Parser::Functions.function("str2saltedsha512")).to eq("function_str2saltedsha512")
-  end
-
-  it "should raise a ParseError if there is less than 1 argument" do
-    expect { scope.function_str2saltedsha512([]) }.to( raise_error(Puppet::ParseError) )
-  end
-
-  it "should raise a ParseError if there is more than 1 argument" do
-    expect { scope.function_str2saltedsha512(['foo', 'bar', 'baz']) }.to( raise_error(Puppet::ParseError) )
-  end
-
-  it "should return a salted-sha512 password hash 136 characters in length" do
-    result = scope.function_str2saltedsha512(["password"])
-    expect(result.length).to(eq(136))
-  end
-
-  it "should raise an error if you pass a non-string password" do
-    expect { scope.function_str2saltedsha512([1234]) }.to( raise_error(Puppet::ParseError) )
-  end
-
-  it "should generate a valid password" do
-    # Allow the function to generate a password based on the string 'password'
-    password_hash = scope.function_str2saltedsha512(["password"])
-
-    # Separate the Salt and Password from the Password Hash
-    salt     = password_hash[0..7]
-    password = password_hash[8..-1]
-
-    # Convert the Salt and Password from Hex to Binary Data
-    str_salt     = Array(salt.lines).pack('H*')
-    str_password = Array(password.lines).pack('H*')
+  context 'when running with a specific seed' do
+    # make tests deterministic
+    before(:each) { srand(2) }
 
-    # Combine the Binary Salt with 'password' and compare the end result
-    saltedpass    = Digest::SHA512.digest(str_salt + 'password')
-    result        = (str_salt + saltedpass).unpack('H*')[0]
-    expect(result).to eq(password_hash)
+    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
index ebec54b..41cda6a 100755 (executable)
@@ -1,9 +1,6 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the strftime function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
+describe 'strftime' do
   it "should exist" do
     expect(Puppet::Parser::Functions.function("strftime")).to eq("function_strftime")
   end
@@ -17,9 +14,9 @@ describe "the strftime function" do
     expect(result.to_i).to(be > 1311953157)
   end
 
-  it "using %s should be lower then 1.5 trillion" do
+  it "using %s should be greater than 1.5 trillion" do
     result = scope.function_strftime(["%s"])
-    expect(result.to_i).to(be < 1500000000)
+    expect(result.to_i).to(be > 1500000000)
   end
 
   it "should return a date when given %Y-%m-%d" do
index 4ac8daf..18e943d 100755 (executable)
@@ -1,27 +1,35 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the strip function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("strip")).to eq("function_strip")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_strip([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should strip a string" do
-    result = scope.function_strip([" ab cd "])
-    expect(result).to(eq('ab cd'))
-  end
-
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new(' as df ')
-    result = scope.function_strip([value])
-    result.should(eq('as df'))
-  end
+describe 'strip' 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 {
+    pending("Current implementation ignores parameters after the first.")
+    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, /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_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("\t").and_return('') }
+  it { is_expected.to run.with_params("\t ").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('     one').and_return('one') }
+  it { is_expected.to run.with_params("\tone").and_return('one') }
+  it { is_expected.to run.with_params("\t one").and_return('one') }
+  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('     one ').and_return('one') }
+  it { is_expected.to run.with_params("\tone ").and_return('one') }
+  it { is_expected.to run.with_params("\t one ").and_return('one') }
+  it { is_expected.to run.with_params("one \t").and_return('one') }
+  it { is_expected.to run.with_params(" one \t").and_return('one') }
+  it { is_expected.to run.with_params("     one \t").and_return('one') }
+  it { is_expected.to run.with_params("\tone \t").and_return('one') }
+  it { is_expected.to run.with_params("\t one \t").and_return('one') }
+  it { is_expected.to run.with_params(' o n e ').and_return('o n e') }
+  it { is_expected.to run.with_params('      ỏŋέ  ').and_return('ỏŋέ') }
+  it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one') }
 end
index c7783c6..e0eafb1 100755 (executable)
@@ -1,27 +1,40 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the suffix function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 {
+    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)
+  }
+  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_return([]) }
+  it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) }
+  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(['one'], 'post').and_return(['onepost']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 'post').and_return(['onepost', 'twopost', 'threepost']) }
+  it { is_expected.to run.with_params(['ỗńέ', 'ťשׂǿ', 'ŧҺř℮ə'], 'рổŝţ').and_return(['ỗńέрổŝţ', 'ťשׂǿрổŝţ', 'ŧҺř℮əрổŝţ']) }
 
-  it "raises a ParseError if there is less than 1 arguments" do
-    expect { scope.function_suffix([]) }.to raise_error(Puppet::ParseError, /number of arguments/)
-  end
-
-  it "raises an error if the first argument is not an array" do
-    expect {
-      scope.function_suffix([Object.new])
-    }.to raise_error(Puppet::ParseError, /expected first argument to be an Array/)
-  end
-
-  it "raises an error if the second argument is not a string" do
-    expect {
-      scope.function_suffix([['first', 'second'], 42])
-    }.to raise_error(Puppet::ParseError, /expected second argument to be a String/)
-  end
-
-  it "returns a suffixed array" do
-    result = scope.function_suffix([['a','b','c'], 'p'])
-    expect(result).to(eq(['ap','bp','cp']))
-  end
+  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({}, '').and_return({})
+  }
+  it {
+    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' })
+  }
+  it {
+    is_expected.to run \
+      .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'post') \
+      .and_return({ 'key1post' => 'value1', 'key2post' => 'value2', 'key3post' => 'value3' })
+  }
 end
index 791d1df..c175a15 100755 (executable)
@@ -1,28 +1,40 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the swapcase function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("swapcase")).to eq("function_swapcase")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_swapcase([]) }.to( raise_error(Puppet::ParseError))
+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 {
+    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)
+  }
+  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/) }
+  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') }
+    it { is_expected.to run.with_params('ONE').and_return('one') }
+    it { is_expected.to run.with_params('oNe').and_return('OnE') }
   end
-
-  it "should swapcase a string" do
-    result = scope.function_swapcase(["aaBBccDD"])
-    expect(result).to(eq('AAbbCCdd'))
+  describe 'with arrays as inputs' do
+    it { is_expected.to run.with_params([]).and_return([]) }
+    describe 'only containing strings' do
+      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(['oNe']).and_return(['OnE']) }
+      it { is_expected.to run.with_params(['one', 'ONE']).and_return(['ONE', 'one']) }
+      it { is_expected.to run.with_params(['ONE', 'OnE']).and_return(['one', 'oNe']) }
+      it { is_expected.to run.with_params(['oNe', 'one']).and_return(['OnE', 'ONE']) }
+    end
+    describe 'containing mixed types' do
+      it { is_expected.to run.with_params(['OnE', {}]).and_return(['oNe', {}]) }
+      it { is_expected.to run.with_params(['OnE', 1]).and_return(['oNe', 1]) }
+      it { is_expected.to run.with_params(['OnE', []]).and_return(['oNe', []]) }
+      it { is_expected.to run.with_params(['OnE', ['two']]).and_return(['oNe', ['two']]) }
+    end
   end
-
   it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new("aaBBccDD")
-    result = scope.function_swapcase([value])
-    result.should(eq("AAbbCCdd"))
+    is_expected.to run.with_params(AlsoString.new("OnE")).and_return('oNe')
   end
 end
index 6e22515..d157939 100755 (executable)
@@ -1,29 +1,21 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the time function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 "should exist" do
-    expect(Puppet::Parser::Functions.function("time")).to eq("function_time")
-  end
-
-  it "should raise a ParseError if there is more than 2 arguments" do
-    expect { scope.function_time(['','']) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return a number" do
-    result = scope.function_time([])
-    expect(result).to be_an(Integer)
-  end
-
-  it "should be higher then when I wrote this test" do
-    result = scope.function_time([])
-    expect(result).to(be > 1311953157)
-  end
-
-  it "should be lower then 1.5 trillion" do
-    result = scope.function_time([])
-    expect(result).to(be < 1500000000)
+  context 'when running at a specific time' do
+    before(:each) {
+      # 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) }
   end
 end
index 0f6ade9..2be23ff 100755 (executable)
@@ -1,83 +1,72 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the to_bytes function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("to_bytes")).to eq("function_to_bytes")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_to_bytes([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should convert kB to B" do
-    result = scope.function_to_bytes(["4 kB"])
-    expect(result).to(eq(4096))
-  end
-
-  it "should convert MB to B" do
-    result = scope.function_to_bytes(["4 MB"])
-    expect(result).to(eq(4194304))
-  end
-
-  it "should convert GB to B" do
-    result = scope.function_to_bytes(["4 GB"])
-    expect(result).to(eq(4294967296))
-  end
-
-  it "should convert TB to B" do
-    result = scope.function_to_bytes(["4 TB"])
-    expect(result).to(eq(4398046511104))
-  end
-
-  it "should convert PB to B" do
-    result = scope.function_to_bytes(["4 PB"])
-    expect(result).to(eq(4503599627370496))
-  end
-
-  it "should convert PB to B" do
-    result = scope.function_to_bytes(["4 EB"])
-    expect(result).to(eq(4611686018427387904))
-  end
-
-  it "should work without B in unit" do
-    result = scope.function_to_bytes(["4 k"])
-    expect(result).to(eq(4096))
-  end
-
-  it "should work without a space before unit" do
-    result = scope.function_to_bytes(["4k"])
-    expect(result).to(eq(4096))
-  end
-
-  it "should work without a unit" do
-    result = scope.function_to_bytes(["5678"])
-    expect(result).to(eq(5678))
-  end
-
-  it "should convert fractions" do
-    result = scope.function_to_bytes(["1.5 kB"])
-    expect(result).to(eq(1536))
-  end
-
-  it "should convert scientific notation" do
-    result = scope.function_to_bytes(["1.5e2 B"])
-    expect(result).to(eq(150))
-  end
-
-  it "should do nothing with a positive number" do
-    result = scope.function_to_bytes([5678])
-    expect(result).to(eq(5678))
-  end
-
-  it "should should raise a ParseError if input isn't a number" do
-    expect { scope.function_to_bytes(["foo"]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should should raise a ParseError if prefix is unknown" do
-    expect { scope.function_to_bytes(["5 uB"]) }.to( raise_error(Puppet::ParseError))
+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/) }
+
+  describe 'when passing numbers' do
+    it { is_expected.to run.with_params(0).and_return(0) }
+    it { is_expected.to run.with_params(1).and_return(1) }
+    it { is_expected.to run.with_params(-1).and_return(-1) }
+    it { is_expected.to run.with_params(1.1).and_return(1.1) }
+    it { is_expected.to run.with_params(-1.1).and_return(-1.1) }
+  end
+
+  describe 'when passing numbers as strings' do
+    describe 'without a unit' do
+      it { is_expected.to run.with_params('1').and_return(1) }
+      it { is_expected.to run.with_params('-1').and_return(-1) }
+      # these are so wrong
+      it { is_expected.to run.with_params('1.1').and_return(1) }
+      it { is_expected.to run.with_params('-1.1').and_return(-1) }
+    end
+
+    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('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) }
+
+      # these are so wrong
+      it { is_expected.to run.with_params('1.0001 k').and_return(1024) }
+      it { is_expected.to run.with_params('-1.0001 kB').and_return(-1024) }
+    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/) }
+    end
+  end
+
+  # these are so wrong
+  describe 'when passing random stuff' do
+    it { is_expected.to run.with_params('-1....1').and_return(-1) }
+    it { is_expected.to run.with_params('-1.e.e.e.1').and_return(-1) }
+    it { is_expected.to run.with_params('-1+1').and_return(-1) }
+    it { is_expected.to run.with_params('1-1').and_return(1) }
+    it { is_expected.to run.with_params('1 kaboom').and_return(1024) }
+    it { is_expected.to run.with_params('kaboom').and_return(0) }
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb b/3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb
new file mode 100644 (file)
index 0000000..38c0efd
--- /dev/null
@@ -0,0 +1,100 @@
+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',
+    }
+  end
+
+  context 'single values' do
+    it 'should exist' do
+      is_expected.not_to eq(nil)
+    end
+
+    it 'should be 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
+      is_expected.to run.with_params('test', 'path', 'default').and_return('default')
+    end
+
+    it 'should return 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
+      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
+      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
+      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
+      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
+      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
+      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, '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, '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, 'a/e/2/x/y', 'default').and_return('z')
+    end
+
+    it 'should be able to return "true" value' do
+      is_expected.to run.with_params(data, 'b', 'default').and_return(true)
+      is_expected.to run.with_params(data, 'm', true).and_return(true)
+    end
+
+    it 'should be able to return "false" value' do
+      is_expected.to run.with_params(data, 'c', 'default').and_return(false)
+      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
+      is_expected.to run.with_params(data, 'a/1').and_return(nil)
+    end
+
+    it 'should be able to use a custom path separator' do
+      is_expected.to run.with_params(data, 'a::g', 'default', '::').and_return('2')
+      is_expected.to run.with_params(data, 'a::c', 'default', '::').and_return('default')
+    end
+  end
+end
index d21236a..c3eb1de 100644 (file)
@@ -1,8 +1,6 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the type3x function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'type3x' do
   it "should exist" do
     expect(Puppet::Parser::Functions.function("type3x")).to eq("function_type3x")
   end
diff --git a/3rdparty/modules/stdlib/spec/functions/type_of_spec.rb b/3rdparty/modules/stdlib/spec/functions/type_of_spec.rb
new file mode 100644 (file)
index 0000000..cc9ef78
--- /dev/null
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+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) }
+    end
+  end
+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 'gives the type of a string' do
+      expect(subject.call({}, 'hello world')).to be_kind_of(Puppet::Pops::Types::PStringType)
+    end
+
+    it 'gives the type of an integer' do
+      expect(subject.call({}, 5)).to be_kind_of(Puppet::Pops::Types::PIntegerType)
+    end
+  end
+end
index b683fcf..4288df0 100755 (executable)
@@ -1,8 +1,6 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the type function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+describe 'type' do
   it "should exist" do
     expect(Puppet::Parser::Functions.function("type")).to eq("function_type")
   end
index 706f4cb..3f36f24 100755 (executable)
@@ -1,19 +1,25 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the union function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("union")).to eq("function_union")
-  end
-
-  it "should raise a ParseError if there are fewer than 2 arguments" do
-    expect { scope.function_union([]) }.to( raise_error(Puppet::ParseError) )
+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/) }
   end
 
-  it "should join two arrays together" do
-    result = scope.function_union([["a","b","c"],["b","c","d"]])
-    expect(result).to(eq(["a","b","c","d"]))
-  end
+  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(['one'], ['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', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one', 'two', 'three']) }
+  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
 end
index 7cd3a56..76932ec 100755 (executable)
@@ -1,33 +1,31 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the unique function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("unique")).to eq("function_unique")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_unique([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should remove duplicate elements in a string" do
-    result = scope.function_unique(["aabbc"])
-    expect(result).to(eq('abc'))
-  end
-
-  it "should remove duplicate elements in an array" do
-    result = scope.function_unique([["a","a","b","b","c"]])
-    expect(result).to(eq(['a','b','c']))
-  end
+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 {
+        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)
+      }
+      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/) }
+    end
 
-  it "should accept objects which extend String" do
-    class AlsoString < String
+    context 'when called with an array' do
+      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(['a', 'b', 'a']).and_return(['a', 'b']) }
+      it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) }
     end
 
-    value = AlsoString.new('aabbc')
-    result = scope.function_unique([value])
-    result.should(eq('abc'))
+    context 'when called with a string' do
+      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('aaba').and_return('ab') }
+      it { is_expected.to run.with_params('ããъã').and_return('ãъ') }
+    end
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/unix2dos_spec.rb b/3rdparty/modules/stdlib/spec/functions/unix2dos_spec.rb
new file mode 100644 (file)
index 0000000..8537a26
--- /dev/null
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe 'unix2dos' do
+  context '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/)
+    end
+    it do
+      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/)
+    end
+    it do
+      is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError)
+    end
+  end
+
+  context '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)
+    end
+  end
+
+  context '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)
+    end
+  end
+end
index 0689099..3b7b02d 100755 (executable)
@@ -1,58 +1,26 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the upcase function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("upcase")).to eq("function_upcase")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_upcase([]) }.to(raise_error(Puppet::ParseError))
+describe 'upcase' 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/) }
   end
 
-  it "should upcase a string" do
-    result = scope.function_upcase(["abc"])
-    expect(result).to(eq('ABC'))
+  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") }
   end
 
-  it "should do nothing if a string is already upcase" do
-    result = scope.function_upcase(["ABC"])
-    expect(result).to(eq('ABC'))
+  describe 'handling classes derived from String' do
+    it { is_expected.to run.with_params(AlsoString.new("ABC")).and_return("ABC") }
   end
 
-  it "should accept objects which extend String" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new('abc')
-    result = scope.function_upcase([value])
-    result.should(eq('ABC'))
-  end
-
-  it 'should accept hashes and return uppercase' do
-    expect(
-        scope.function_upcase([{'test' => %w(this that and other thing)}])
-    ).to eq({'TEST' => %w(THIS THAT AND OTHER THING)})
-  end
-
-  if :test.respond_to?(:upcase)
-    it 'should accept hashes of symbols' do
-      expect(
-          scope.function_upcase([{:test => [:this, :that, :other]}])
-      ).to eq({:TEST => [:THIS, :THAT, :OTHER]})
-    end
-    it 'should return upcase symbol' do
-      expect(
-          scope.function_upcase([:test])
-      ).to eq(:TEST)
-    end
-    it 'should return mixed objects in upcease' do
-      expect(
-          scope.function_upcase([[:test, 'woot']])
-      ).to eq([:TEST, 'WOOT'])
-
-    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"]) }
   end
 end
index d0f37de..f05ec08 100755 (executable)
@@ -1,40 +1,36 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the uriescape function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("uriescape")).to eq("function_uriescape")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_uriescape([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should uriescape a string" do
-    result = scope.function_uriescape([":/?#[]@!$&'()*+,;= \"{}"])
-    expect(result).to(eq(':/?%23[]@!$&\'()*+,;=%20%22%7B%7D'))
+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 {
+      pending("Current implementation ignores parameters after the first.")
+      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 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/) }
   end
 
-  it "should uriescape an array of strings, while not touching up nonstrings" do
-    teststring = ":/?#[]@!$&'()*+,;= \"{}"
-    expectstring = ':/?%23[]@!$&\'()*+,;=%20%22%7B%7D'
-    result = scope.function_uriescape([[teststring, teststring, 1]])
-    expect(result).to(eq([expectstring, expectstring, 1]))
-  end
-
-  it "should do nothing if a string is already safe" do
-    result = scope.function_uriescape(["ABCdef"])
-    expect(result).to(eq('ABCdef'))
+  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') 
+    end
   end
 
-  it "should accept objects which extend String" do
-    class AlsoString < String
+  describe 'handling classes derived from String' do
+    it 'should call 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") 
     end
+  end
 
-    value = AlsoString.new('abc')
-    result = scope.function_uriescape([value])
-    result.should(eq('abc'))
+  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"]) }
   end
 end
index 36c836b..9397da5 100755 (executable)
@@ -1,67 +1,43 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_absolute_path) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  # The subject of these examples is the method itself.
-  subject do
-    # This makes sure the function is loaded within each test
-    function_name = Puppet::Parser::Functions.function(:validate_absolute_path)
-    scope.method(function_name)
+describe 'validate_absolute_path' do
+  after(:all) do
+    ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
-  describe "Valid Paths" do
-    def self.valid_paths
-      %w{
-        C:/
-        C:\\
-        C:\\WINDOWS\\System32
-        C:/windows/system32
-        X:/foo/bar
-        X:\\foo\\bar
-        /var/tmp
-        /var/lib/puppet
-        /var/opt/../lib/puppet
-      }
-    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('c:/')
+  end
 
-    context "Without Puppet::Util.absolute_path? (e.g. Puppet <= 2.6)" do
-      before :each do
-        # The intent here is to mock Puppet to behave like Puppet 2.6 does.
-        # Puppet 2.6 does not have the absolute_path? method.  This is only a
-        # convenience test, stdlib should be run with the Puppet 2.6.x in the
-        # $LOAD_PATH in addition to 2.7.x and master.
-        Puppet::Util.expects(:respond_to?).with(:absolute_path?).returns(false)
-      end
-      valid_paths.each do |path|
-        it "validate_absolute_path(#{path.inspect}) should not fail" do
-          expect { subject.call [path] }.not_to raise_error
-        end
-      end
-      valid_paths do
-        it "validate_absolute_path(#{valid_paths.inspect}) should not fail" do
-          expect { subject.call [valid_paths] }.not_to raise_error
-        end
-      end
-    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) }
+  end
 
-    context "Puppet without mocking" do
-      valid_paths.each do |path|
-        it "validate_absolute_path(#{path.inspect}) should not fail" do
-          expect { subject.call [path] }.not_to raise_error
-        end
-      end
-      valid_paths do
-        it "validate_absolute_path(#{valid_paths.inspect}) should not fail" do
-          expect { subject.call [valid_paths] }.not_to raise_error
-        end
-      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|
+      it { is_expected.to run.with_params(path) }
+      it { is_expected.to run.with_params(['/tmp', path]) }
     end
   end
 
-  describe 'Invalid paths' do
-    context 'Garbage inputs' do
+  describe 'invalid path handling' do
+    context 'garbage inputs' do
       [
         nil,
         [ nil ],
@@ -70,33 +46,26 @@ describe Puppet::Parser::Functions.function(:validate_absolute_path) do
         { },
         '',
       ].each do |path|
-        it "validate_absolute_path(#{path.inspect}) should fail" do
-          expect { subject.call [path] }.to raise_error Puppet::ParseError
-        end
+        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/) }
       end
     end
 
-    context 'Relative paths' do
-      def self.rel_paths 
-        %w{
-          relative1
-          .
-          ..
-          ./foo
-          ../foo
-          etc/puppetlabs/puppet
-          opt/puppet/bin
-        }
-      end
-      rel_paths.each do |path|
-        it "validate_absolute_path(#{path.inspect}) should fail" do
-          expect { subject.call [path] }.to raise_error Puppet::ParseError
-        end
-      end
-      rel_paths do
-        it "validate_absolute_path(#{rel_paths.inspect}) should fail" do
-          expect { subject.call [rel_paths] }.to raise_error Puppet::ParseError
-        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/) }
       end
     end
   end
index 4b31cfd..409b3dc 100755 (executable)
@@ -1,38 +1,37 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_array) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-  describe 'when calling validate_array from puppet' do
-
-    %w{ true false }.each do |the_string|
-      it "should not compile when #{the_string} is a string" do
-        Puppet[:code] = "validate_array('#{the_string}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not an Array/)
-      end
+describe 'validate_array' do
 
-      it "should not compile when #{the_string} is a bare word" do
-        Puppet[:code] = "validate_array(#{the_string})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not an Array/)
-      end
+  describe 'signature validation' do
+    after(:all) 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'))
+      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 "should compile when multiple array arguments are passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = [ ]
-        $bar = [ 'one', 'two' ]
-        validate_array($foo, $bar)
-      ENDofPUPPETcode
-      scope.compiler.compile
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params([]) }
+      it { is_expected.to run.with_params(['one']) }
+      it { is_expected.to run.with_params([], ['two']) }
+      it { is_expected.to run.with_params(['one'], ['two']) }
     end
 
-    it "should not compile when an undef variable is passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = undef
-        validate_array($foo)
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not an Array/)
+    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/) }
     end
   end
 end
+
index 99523ab..4236649 100755 (executable)
@@ -1,49 +1,29 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_augeas), :if => Puppet.features.augeas? do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  # The subject of these examplres is the method itself.
-  subject do
-    # This makes sure the function is loaded within each test
-    function_name = Puppet::Parser::Functions.function(:validate_augeas)
-    scope.method(function_name)
-  end
-
-  context 'Using Puppet::Parser::Scope.new' do
-
-    describe 'Garbage inputs' do
-      inputs = [
-        [ nil ],
-        [ [ nil ] ],
-        [ { 'foo' => 'bar' } ],
-        [ { } ],
-        [ '' ],
-        [ "one", "one", "MSG to User", "4th arg" ],
-      ]
-
-      inputs.each do |input|
-        it "validate_augeas(#{input.inspect}) should fail" do
-          expect { subject.call [input] }.to raise_error Puppet::ParseError
-        end
-      end
+describe 'validate_augeas' do
+  unless Puppet.features.augeas?
+    skip "ruby-augeas not installed"
+  else
+    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('one', 'one', 'MSG to User', '4th arg').and_raise_error(NoMethodError) }
     end
 
-    describe 'Valid inputs' do
+    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'],
       ]
 
       inputs.each do |input|
-        it "validate_augeas(#{input.inspect}) should not fail" do
-          expect { subject.call input }.not_to raise_error
-        end
+        it { is_expected.to run.with_params(*input) }
       end
     end
 
-    describe "Valid inputs which should raise an exception without a message" do
+    describe 'valid inputs which fail augeas validation' do
       # The intent here is to make sure valid inputs raise exceptions when they
       # don't specify an error message to display.  This is the behvior in
       # 2.2.x and prior.
@@ -53,13 +33,11 @@ describe Puppet::Parser::Functions.function(:validate_augeas), :if => Puppet.fea
       ]
 
       inputs.each do |input|
-        it "validate_augeas(#{input.inspect}) should fail" do
-          expect { subject.call input }.to raise_error /validate_augeas.*?matched less than it should/
-        end
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /validate_augeas.*?matched less than it should/) }
       end
     end
 
-    describe "Nicer 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 = [
@@ -68,35 +46,29 @@ describe Puppet::Parser::Functions.function(:validate_augeas), :if => Puppet.fea
       ]
 
       inputs.each do |input|
-        it "validate_augeas(#{input.inspect}) should fail" do
-          expect { subject.call input }.to raise_error /#{input[3]}/
-        end
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /#{input[3]}/) }
       end
     end
 
-    describe "Passing simple unit 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']],
       ]
 
       inputs.each do |input|
-        it "validate_augeas(#{input.inspect}) should fail" do
-          expect { subject.call input }.not_to raise_error
-        end
+        it { is_expected.to run.with_params(*input) }
       end
     end
 
-    describe "Failing simple unit 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']],
       ]
 
       inputs.each do |input|
-        it "validate_augeas(#{input.inspect}) should fail" do
-          expect { subject.call input }.to raise_error /testing path/
-        end
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /testing path/) }
       end
     end
   end
index a352d3b..3074d88 100755 (executable)
@@ -1,51 +1,36 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_bool) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-  describe 'when calling validate_bool from puppet' do
-
-    %w{ true false }.each do |the_string|
-
-      it "should not compile when #{the_string} is a string" do
-        Puppet[:code] = "validate_bool('#{the_string}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a boolean/)
-      end
-
-      it "should compile when #{the_string} is a bare word" do
-        Puppet[:code] = "validate_bool(#{the_string})"
-        scope.compiler.compile
-      end
-
-    end
+describe 'validate_bool' do
+  after(:all) do
+    ENV.delete('STDLIB_LOG_DEPRECATIONS')
+  end
 
-    it "should not compile when an arbitrary string is passed" do
-      Puppet[:code] = 'validate_bool("jeff and dan are awesome")'
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a boolean/)
-    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(true)
+  end
 
-    it "should not compile when no arguments are passed" do
-      Puppet[:code] = 'validate_bool()'
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
-    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) }
+  end
 
-    it "should compile when multiple boolean arguments are passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = true
-        $bar = false
-        validate_bool($foo, $bar, true, false)
-      ENDofPUPPETcode
-      scope.compiler.compile
-    end
+  describe 'acceptable values' do
+    it { is_expected.to run.with_params(true) }
+    it { is_expected.to run.with_params(false) }
+    it { is_expected.to run.with_params(true, false, false, true) }
+  end
 
-    it "should compile when multiple boolean arguments are passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = true
-        $bar = false
-        validate_bool($foo, $bar, true, false, 'jeff')
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a boolean/)
-    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/) }
   end
 end
index 7cb9782..c6559e8 100755 (executable)
@@ -1,85 +1,35 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-TESTEXE = File.exists?('/usr/bin/test') ? '/usr/bin/test' : '/bin/test'
-TOUCHEXE = File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch'
-
-describe Puppet::Parser::Functions.function(:validate_cmd) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  subject do
-    function_name = Puppet::Parser::Functions.function(:validate_cmd)
-    scope.method(function_name)
+describe 'validate_cmd', :unless => Puppet::Util::Platform.windows? do
+  let(:touch) { File.exists?('/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 {
+      pending('should implement stricter type checking')
+      is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /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/)
+    }
+    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/)
+    }
   end
 
-  context 'with no % placeholder' do
-    describe "with an explicit failure message" do
-      it "prints the failure message on error" do
-        expect {
-          subject.call ['', '/bin/false', 'failure message!']
-        }.to raise_error Puppet::ParseError, /failure message!/
-      end
-    end
-
-    describe "on validation failure" do
-      it "includes the command error output" do
-        expect {
-          subject.call ['', "#{TOUCHEXE} /cant/touch/this"]
-        }.to raise_error Puppet::ParseError, /(cannot touch|o such file or)/
-      end
-
-      it "includes the command return value" do
-        expect {
-          subject.call ['', '/cant/run/this']
-        }.to raise_error Puppet::ParseError, /returned 1\b/
-      end
-    end
-
-    describe "when performing actual validation" do
-      it "can positively validate file content" do
-        expect { subject.call ["non-empty", "#{TESTEXE} -s"] }.to_not raise_error
-      end
-
-      it "can negatively validate file content" do
-        expect {
-          subject.call ["", "#{TESTEXE} -s"]
-        }.to raise_error Puppet::ParseError, /failed to validate.*test -s/
-      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/) }
     end
-  end
-
-  context 'with % placeholder' do
-    describe "with an explicit failure message" do
-      it "prints the failure message on error" do
-        expect {
-          subject.call ['', '/bin/false % -f', 'failure message!']
-        }.to raise_error Puppet::ParseError, /failure message!/
-      end
-    end
-    describe "on validation failure" do
-      it "includes the command error output" do
-        expect {
-          subject.call ['', "#{TOUCHEXE} /cant/touch/this"]
-        }.to raise_error Puppet::ParseError, /(cannot touch|o such file or)/
-      end
-
-      it "includes the command return value" do
-        expect {
-          subject.call ['', '/cant/run/this % -z']
-        }.to raise_error Puppet::ParseError, /Execution of '\/cant\/run\/this .+ -z' returned 1/
-      end
-    end
-
-    describe "when performing actual validation" do
-      it "can positively validate file content" do
-        expect { subject.call ["non-empty", "#{TESTEXE} -s %"] }.to_not raise_error
-      end
-
-      it "can negatively validate file content" do
-        expect {
-          subject.call ["", "#{TESTEXE} -s %"]
-        }.to raise_error Puppet::ParseError, /failed to validate.*test -s/
-      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/) }
     end
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/validate_domain_name_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_domain_name_spec.rb
new file mode 100644 (file)
index 0000000..69fcae4
--- /dev/null
@@ -0,0 +1,35 @@
+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) }
+  end
+
+  describe 'valid inputs' do
+    it { is_expected.to run.with_params('com', 'com.') }
+    it { is_expected.to run.with_params('x.com', 'x.com.') }
+    it { is_expected.to run.with_params('foo.example.com', 'foo.example.com.') }
+    it { is_expected.to run.with_params('2foo.example.com', '2foo.example.com.') }
+    it { is_expected.to run.with_params('www.2foo.example.com', 'www.2foo.example.com.') }
+    it { is_expected.to run.with_params('domain.tld', 'puppet.com') }
+  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('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('').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/) }
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/functions/validate_email_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_email_address_spec.rb
new file mode 100644 (file)
index 0000000..7628383
--- /dev/null
@@ -0,0 +1,23 @@
+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) }
+  end
+
+  describe 'valid inputs' do
+    it { is_expected.to run.with_params('bob@gmail.com') }
+    it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com') }
+  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/) }
+  end
+end
index a0c35c2..7533abe 100755 (executable)
@@ -1,43 +1,38 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_hash) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe 'when calling validate_hash from puppet' do
+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) }
 
-    %w{ true false }.each do |the_string|
-
-      it "should not compile when #{the_string} is a string" do
-        Puppet[:code] = "validate_hash('#{the_string}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a Hash/)
+    describe 'check for deprecation warning' do
+      after(:all) do
+        ENV.delete('STDLIB_LOG_DEPRECATIONS')
       end
-
-      it "should not compile when #{the_string} is a bare word" do
-        Puppet[:code] = "validate_hash(#{the_string})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a Hash/)
+      # 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'})
       end
-
     end
 
-    it "should compile when multiple hash arguments are passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = {}
-        $bar = { 'one' => 'two' }
-        validate_hash($foo, $bar)
-      ENDofPUPPETcode
-      scope.compiler.compile
+    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'}) }
     end
 
-    it "should not compile when an undef variable is passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = undef
-        validate_hash($foo)
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a Hash/)
+    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/) }
     end
-
   end
-
 end
index dff3415..6558d00 100755 (executable)
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_integer) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe 'when calling validate_integer from puppet without any argument or to many' do
-    it "should not compile when no argument is passed" do
-      Puppet[:code] = "validate_integer()"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /Wrong number of arguments/)
-    end
-    it "should not compile when more than three arguments are passed" do
-      Puppet[:code] = "validate_integer(1, 1, 1, 1)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /Wrong number of arguments/)
-    end
+describe 'validate_integer' do
+  after(:all) do
+    ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
-  describe 'when calling validate_integer from puppet only with input' do
-    %w{ 1 -1 }.each do |the_number|
-      it "should compile when #{the_number} is an encapsulated integer" do
-        Puppet[:code] = "validate_integer('#{the_number}')"
-        scope.compiler.compile
-      end
-      it "should compile when #{the_number} is an bare integer" do
-        Puppet[:code] = "validate_integer(#{the_number})"
-        scope.compiler.compile
-      end
-    end
-
-    %w{ [1,2,3,4,5] ['1','2','3','4','5'] }.each do |the_number|
-      it "should compile when multiple Integer arguments are passed in an Array" do
-        Puppet[:code] = "validate_integer(#{the_number})"
-        scope.compiler.compile
-      end
-    end
-
-    %w{ true false iAmAString 1test 7.0 -7.0 }.each do |the_number|
-      it "should not compile when #{the_number} is in a string" do
-        Puppet[:code] = "validate_integer('#{the_number}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be an Integer/)
-      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(3)
+  end
 
-      it "should not compile when #{the_number} is a bare word" do
-        Puppet[:code] = "validate_integer(#{the_number})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be an Integer/)
-      end
-    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 "should not compile when an Integer is part of a larger String" do
-      Puppet[:code] = "validate_integer('1 test')"
-      expect { scope.compiler.compile }.to 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, /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/) }
     end
 
-    it "should not compile when an Array with a non-Integer value is passed" do
-      Puppet[:code] = "validate_integer([1, '-7.0'])"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /at array position 1 to be an Integer/)
+    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/) }
     end
 
-    it "should not compile when a Hash is passed" do
-      Puppet[:code] = "validate_integer({ 1 => 2 })"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be an Integer or Array/)
+    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) }
     end
 
-    it "should not compile when an explicitly undef variable is passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = undef
-        validate_integer($foo)
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be an Integer/)
-    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/) }
+  end
 
-    it "should not compile when an undefined variable is passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        validate_integer($foobarbazishouldnotexist)
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be an Integer/)
-    end
+  context 'with no range constraints' do
+    it { is_expected.to run.with_params(1) }
+    it { is_expected.to run.with_params(-1) }
+    it { is_expected.to run.with_params('1') }
+    it { is_expected.to run.with_params('-1') }
+    it { is_expected.to run.with_params([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params([1, '2', '3', 4]) }
   end
 
-  describe 'when calling validate_integer from puppet with input and a maximum' do
-    max = 10
-    %w{ 1 -1 }.each do |the_number|
-      it "should compile when #{the_number} is lower than a maximum of #{max}" do
-        Puppet[:code] = "validate_integer(#{the_number},#{max})"
-        scope.compiler.compile
+  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/) }
+    end
+
+    describe 'accepts numbers less or equal to the limit' do
+      it { is_expected.to run.with_params(10, 10) }
+      it { is_expected.to run.with_params(1, 10) }
+      it { is_expected.to run.with_params(-1, 10) }
+      it { is_expected.to run.with_params('1', 10) }
+      it { is_expected.to run.with_params('-1', 10) }
+      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
+
+    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
-    end
-
-    it "should compile when an Integer is equal the maximum" do
-      Puppet[:code] = "validate_integer(#{max},#{max})"
-      scope.compiler.compile
-    end
 
-    it "should not compile when #{max+1} is greater than a maximum of #{max}" do
-      Puppet[:code] = "validate_integer(#{max+1},#{max})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be smaller or equal to/)
-    end
-
-    %w{ [-10,1,2,3,4,5,10] ['-10','1','2','3','4','5','10'] }.each do |the_number|
-      it "should compile when each element of #{the_number} is lower than a maximum of #{max}" do
-        Puppet[:code] = "validate_integer(#{the_number},#{max})"
-        scope.compiler.compile
+      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
-    end
 
-    it "should not compile when an element of an Array [-10,1,2,3,4,5,#{max+1}] is greater than a maximum of #{max}" do
-      Puppet[:code] = "validate_integer([-10,1,2,3,4,5,#{max+1}],#{max})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be smaller or equal to/)
-    end
-
-    %w{ true false iAmAString 1test 7.0 -7.0 }.each do |the_max|
-      it "should not compile when a non-Integer maximum #{the_max}, encapsulated in a String, is passed" do
-        Puppet[:code] = "validate_integer(1,'#{the_max}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
-      end
-      it "should not compile when a non-Integer maximum #{the_max} bare word is passed" do
-        Puppet[:code] = "validate_integer(1,#{the_max})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
+      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
-
-    it "should not compile when an explicitly undefined variable is passed as maximum and no minimum is passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = undef
-        validate_integer(10, $foo)
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
-    end
-    it "should not compile when an explicitly undef is passed as maximum and no minimum is passed" do
-      Puppet[:code] = "validate_integer(10, undef)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
-    end
-    it "should not compile when an empty string is passed as maximum and no minimum is passed" do
-      Puppet[:code] = "validate_integer(10, '')"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
-    end
-    it "should not compile when an undefined variable for a maximum is passed" do
-      Puppet[:code] = "validate_integer(10, $foobarbazishouldnotexist)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
-    end
   end
 
-  describe 'when calling validate_integer from puppet with input, a maximum and a minimum' do
-    it "should not compile when a minimum larger than maximum is passed" do
-      Puppet[:code] = "validate_integer(1,1,2)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /second argument to be larger than third argument/)
-    end
-
-    max = 10
-    min = -10
-    %w{ 1 -1 }.each do |the_number|
-      it "should compile when each element of #{the_number} is within a range from #{min} to #{max}" do
-        Puppet[:code] = "validate_integer(#{the_number},#{max},#{min})"
-        scope.compiler.compile
-      end
-    end
-
-    it "should compile when an Integer is equal the minimum" do
-      Puppet[:code] = "validate_integer(#{min},#{max},#{min})"
-      scope.compiler.compile
-    end
+  it { is_expected.to run.with_params(10, 10, 10) }
 
-    it "should compile when an Integer is equal the minimum and maximum" do
-      Puppet[:code] = "validate_integer(#{max},#{max},#{max})"
-      scope.compiler.compile
-    end
-
-    it "should compile when an empty maximum is passed and the Integer is greater than the minimum" do
-      Puppet[:code] = "validate_integer(#{max},'',#{min})"
-      scope.compiler.compile
-    end
-    it "should compile when an explicitly undefined maximum is passed and the Integer is greater than the minimum" do
-      Puppet[:code] = "validate_integer(#{max},undef,#{min})"
-      scope.compiler.compile
-    end
-    it "should compile when an explicitly undefined variable is passed for maximum and the Integer is greater than the minimum" do
-      Puppet[:code] = <<-"ENDofPUPPETcode"
-        $foo = undef
-        validate_integer(#{max}, $foo, #{min})
-      ENDofPUPPETcode
-      scope.compiler.compile
-    end
-    it "should not compile when no maximum value is given and the Integer is greater than the minimum" do
-      Puppet[:code] = "validate_integer(#{max},,#{min})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::Error, /Syntax error at ','/)
-    end
-
-    it "should not compile when #{min-1} is lower than a minimum of #{min}" do
-      Puppet[:code] = "validate_integer(#{min-1},#{max},#{min})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be greater or equal to/)
-    end
-
-    %w{ [-10,1,2,3,4,5,10] ['-10','1','2','3','4','5','10'] }.each do |the_number|
-      it "should compile when each element of #{the_number} is within a range from #{min} to #{max}" do
-        Puppet[:code] = "validate_integer(#{the_number},#{max},#{min})"
-        scope.compiler.compile
-      end
-    end
-
-    it "should not compile when an element of an Array [#{min-1},1,2,3,4,5,10] is lower than a minimum of #{min}" do
-      Puppet[:code] = "validate_integer([#{min-1},1,2,3,4,5,10],#{max},#{min})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be greater or equal to/)
-    end
-
-    %w{ true false iAmAString 1test 7.0 -7.0 }.each do |the_min|
-      it "should not compile when a non-Integer minimum #{the_min}, encapsulated in a String, is passed" do
-        Puppet[:code] = "validate_integer(1,#{max},'#{the_min}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
-      end
-      it "should not compile when a non-Integer minimum #{the_min} bare word is passed" do
-        Puppet[:code] = "validate_integer(1,#{max},#{the_min})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or an Integer/)
-      end
-    end
+  describe 'empty upper limit is interpreted as infinity' do
+    it { is_expected.to run.with_params(11, '', 10) }
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/validate_ip_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_ip_address_spec.rb
new file mode 100644 (file)
index 0000000..0414f5e
--- /dev/null
@@ -0,0 +1,65 @@
+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) }
+  end
+
+  describe 'valid inputs' do
+    it { is_expected.to run.with_params('0.0.0.0') }
+    it { is_expected.to run.with_params('8.8.8.8') }
+    it { is_expected.to run.with_params('127.0.0.1') }
+    it { is_expected.to run.with_params('10.10.10.10') }
+    it { is_expected.to run.with_params('194.232.104.150') }
+    it { is_expected.to run.with_params('244.24.24.24') }
+    it { is_expected.to run.with_params('255.255.255.255') }
+    it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') }
+    it { is_expected.to run.with_params('3ffe:0505:0002::') }
+    it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') }
+    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
+        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'))
+        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
+        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') }
+      it { is_expected.to run.with_params('8.8.8.8/32') }
+      it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') }
+    end
+  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/) }
+  end
+end
index 45401a4..6e4ca05 100755 (executable)
@@ -1,64 +1,41 @@
-#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
 
-require "spec_helper"
+describe 'validate_ipv4_address' do
 
-describe Puppet::Parser::Functions.function(:validate_ipv4_address) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe "when calling validate_ipv4_address from puppet" do
-    describe "when given IPv4 address strings" do
-      it "should compile with one argument" do
-        Puppet[:code] = "validate_ipv4_address('1.2.3.4')"
-        scope.compiler.compile
-      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) }
+  end
 
-      it "should compile with multiple arguments" do
-        Puppet[:code] = "validate_ipv4_address('1.2.3.4', '5.6.7.8')"
-        scope.compiler.compile
-      end
+  context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+    after(:all) do
+      ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
-
-    describe "when given an IPv6 address" do
-      it "should not compile" do
-        Puppet[:code] = "validate_ipv4_address('3ffe:505')"
-        expect {
-          scope.compiler.compile
-        }.to raise_error(Puppet::ParseError, /not a valid IPv4 address/)
-      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'))
+      is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
     end
-
-    describe "when given other strings" do
-      it "should not compile" do
-        Puppet[:code] = "validate_ipv4_address('hello', 'world')"
-        expect {
-          scope.compiler.compile
-        }.to raise_error(Puppet::ParseError, /not a valid IPv4 address/)
-      end
+    it 'should display no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+      scope.expects(:warning).with(includes('This method is deprecated')).never
+      is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first)
     end
+  end
 
-    describe "when given numbers" do
-      it "should not compile" do
-        Puppet[:code] = "validate_ipv4_address(1, 2)"
-        expect {
-          scope.compiler.compile
-        }.to raise_error(Puppet::ParseError, /is not a valid IPv4 address/)
-      end
-    end
+  SharedData::IPV4_PATTERNS.each do |value|
+    it { is_expected.to run.with_params(value) }
+  end
 
-    describe "when given booleans" do
-      it "should not compile" do
-        Puppet[:code] = "validate_ipv4_address(true, false)"
-        expect {
-          scope.compiler.compile
-        }.to raise_error(Puppet::ParseError, /is not a string/)
-      end
-    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/) }
+  end
 
-    it "should not compile when no arguments are passed" do
-      Puppet[:code] = "validate_ipv4_address()"
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
+  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/) }
     end
   end
 end
index a839d90..137db36 100755 (executable)
@@ -1,67 +1,60 @@
-#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
 
-require "spec_helper"
-
-describe Puppet::Parser::Functions.function(:validate_ipv6_address) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe "when calling validate_ipv6_address from puppet" do
-    describe "when given IPv6 address strings" do
-      it "should compile with one argument" do
-        Puppet[:code] = "validate_ipv6_address('3ffe:0505:0002::')"
-        scope.compiler.compile
-      end
-
-      it "should compile with multiple arguments" do
-        Puppet[:code] = "validate_ipv6_address('3ffe:0505:0002::', '3ffe:0505:0001::')"
-        scope.compiler.compile
-      end
-    end
-
-    describe "when given an ipv4 address" do
-      it "should not compile" do
-        Puppet[:code] = "validate_ipv6_address('1.2.3.4')"
-        expect {
-          scope.compiler.compile
-        }.to raise_error(Puppet::ParseError, /not a valid IPv6 address/)
-      end
-    end
+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) }
+  end
 
-    describe "when given other strings" do
-      it "should not compile" do
-        Puppet[:code] = "validate_ipv6_address('hello', 'world')"
-        expect {
-          scope.compiler.compile
-        }.to raise_error(Puppet::ParseError, /not a valid IPv6 address/)
-      end
+  context 'Checking for deprecation warning', if: Puppet.version.to_f < 4.0 do
+    after(:all) do
+      ENV.delete('STDLIB_LOG_DEPRECATIONS')
     end
-
-    # 1.8.7 is EOL'd and also absolutely insane about ipv6
-    unless RUBY_VERSION == '1.8.7'
-      describe "when given numbers" do
-        it "should not compile" do
-          Puppet[:code] = "validate_ipv6_address(1, 2)"
-          expect {
-            scope.compiler.compile
-          }.to raise_error(Puppet::ParseError, /not a valid IPv6 address/)
-        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'))
+      is_expected.to run.with_params('3ffe:0505:0002::')
     end
-
-    describe "when given booleans" do
-      it "should not compile" do
-        Puppet[:code] = "validate_ipv6_address(true, false)"
-        expect {
-          scope.compiler.compile
-        }.to raise_error(Puppet::ParseError, /is not a string/)
-      end
+    it 'should display no warning for deprecation' do
+      ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
+      scope.expects(:warning).with(includes('This method is deprecated')).never
+      is_expected.to run.with_params('3ffe:0505:0002::')
     end
+  end 
+
+  describe 'valid inputs' do
+    it { is_expected.to run.with_params('3ffe:0505:0002::') }
+    it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') }
+    it { is_expected.to run.with_params('::1/64') }
+    it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') }
+    it { is_expected.to run.with_params('fe80:0000:0000:0000:0204:61ff:fe9d:f156') }
+    it { is_expected.to run.with_params('fe80:0:0:0:204:61ff:fe9d:f156') }
+    it { is_expected.to run.with_params('fe80::204:61ff:fe9d:f156') }
+    it { is_expected.to run.with_params('fe80:0:0:0:0204:61ff:254.157.241.86') }
+    it { is_expected.to run.with_params('::1') }
+    it { is_expected.to run.with_params('fe80::') }
+    it { is_expected.to run.with_params('2001::') }
+  end
 
-    it "should not compile when no arguments are passed" do
-      Puppet[:code] = "validate_ipv6_address()"
-      expect {
-        scope.compiler.compile
-      }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
+  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/) }
+    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/) }
     end
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/validate_legacy_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_legacy_spec.rb
new file mode 100644 (file)
index 0000000..7b48f12
--- /dev/null
@@ -0,0 +1,68 @@
+require 'spec_helper'
+
+if Puppet::Util::Package.versioncmp(Puppet.version, '4.4.0') >= 0
+  describe 'validate_legacy' do
+    it { is_expected.not_to eq(nil) }
+    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
+        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
+        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
+        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
+        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
+        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
+        is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef, 1, 'foo')
+      end
+    end
+  end
+end
index c8b0e4d..4c0e24d 100755 (executable)
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_numeric) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe 'when calling validate_numeric from puppet without any argument or to many' do
-    it "should not compile when no argument is passed" do
-      Puppet[:code] = "validate_numeric()"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /Wrong number of arguments/)
-    end
-    it "should not compile when more than three arguments are passed" do
-      Puppet[:code] = "validate_numeric(1, 1, 1, 1)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /Wrong number of arguments/)
-    end
+describe 'validate_numeric' do
+  after(:all) 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(3)
   end
 
-  describe 'when calling validate_numeric from puppet only with input' do
-    %w{ 1 -1 1.0 -1.0 }.each do |the_number|
-      it "should compile when #{the_number} is an encapsulated numeric" do
-        Puppet[:code] = "validate_numeric('#{the_number}')"
-        scope.compiler.compile
-      end
-      it "should compile when #{the_number} is a bare numeric" do
-        Puppet[:code] = "validate_numeric(#{the_number})"
-        scope.compiler.compile
-      end
-    end
-
-    %w{ [1,2,3,4,5] ['1','2','3','4','5'] [1.1,2.2,3.3,4.4,5.5] ['1.1','2.2','3.3','4.4','5.5'] }.each do |the_number|
-      it "should compile when multiple Numeric arguments are passed in an Array" do
-        Puppet[:code] = "validate_numeric(#{the_number})"
-        scope.compiler.compile
-      end
-    end
-
-    %w{ true false iAmAString 1test }.each do |the_number|
-      it "should not compile when #{the_number} is in a string" do
-        Puppet[:code] = "validate_numeric('#{the_number}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be a Numeric/)
-      end
-
-      it "should not compile when #{the_number} is a bare word" do
-        Puppet[:code] = "validate_numeric(#{the_number})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be a Numeric/)
-      end
-    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 "should not compile when a Numeric is part of a larger String" do
-      Puppet[:code] = "validate_numeric('1.0 test')"
-      expect { scope.compiler.compile }.to 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, /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/) }
     end
 
-    it "should not compile when an Array with a non-Numeric value is passed" do
-      Puppet[:code] = "validate_numeric([1, 'test'])"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /at array position 1 to be a Numeric/)
+    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/) }
     end
 
-    it "should not compile when a Hash is passed" do
-      Puppet[:code] = "validate_numeric({ 1 => 2 })"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be a Numeric or Array/)
+    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) }
     end
 
-    it "should not compile when an explicitly undef variable is passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = undef
-        validate_numeric($foo)
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be a Numeric/)
-    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/) }
+  end
 
-    it "should not compile when an undefined variable is passed" do
-      Puppet[:code] = 'validate_numeric($foobarbazishouldnotexist)'
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be a Numeric/)
-    end
+  context 'with no range constraints' do
+    it { is_expected.to run.with_params(1) }
+    it { is_expected.to run.with_params(-1) }
+    it { is_expected.to run.with_params('1') }
+    it { is_expected.to run.with_params('-1') }
+    it { is_expected.to run.with_params([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params([1, '2', '3', 4]) }
   end
 
-  describe 'when calling validate_numeric from puppet with input and a maximum' do
-    max = 10
-    %w{ 1 -1 1.0 -1.0 }.each do |the_number|
-      it "should compile when #{the_number} is lower than a maximum of #{max}" do
-        Puppet[:code] = "validate_numeric(#{the_number},#{max})"
-        scope.compiler.compile
+  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/) }
+    end
+
+    describe 'accepts numbers less or equal to the limit' do
+      it { is_expected.to run.with_params(10.0, 10.0) }
+      it { is_expected.to run.with_params(1, 10.0) }
+      it { is_expected.to run.with_params(-1, 10.0) }
+      it { is_expected.to run.with_params('1', 10.0) }
+      it { is_expected.to run.with_params('-1', 10.0) }
+      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
+
+    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
-    end
-
-    it "should compile when a Numeric is equal the maximum" do
-      Puppet[:code] = "validate_numeric(#{max},#{max})"
-      scope.compiler.compile
-    end
-
-    it "should not compile when #{max+1} is greater than a maximum of #{max}" do
-      Puppet[:code] = "validate_numeric(#{max+1},#{max})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be smaller or equal to/)
-    end
 
-    %w{ [-10,1,2,3,4,5,10] ['-10','1','2','3','4','5','10'] }.each do |the_number|
-      it "should compile when each element of #{the_number} is lower than a maximum of #{max}" do
-        Puppet[:code] = "validate_numeric(#{the_number},#{max})"
-        scope.compiler.compile
+      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
-    end
 
-    it "should not compile when an element of an Array [-10,1,2,3,4,5,#{max+1}] is greater than a maximum of #{max}" do
-      Puppet[:code] = "validate_numeric([-10,1,2,3,4,5,#{max+1}],#{max})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be smaller or equal to/)
-    end
-
-    %w{ true false iAmAString 1test }.each do |the_max|
-      it "should not compile when a non-Numeric maximum #{the_max}, encapsulated in a String, is passed" do
-        Puppet[:code] = "validate_numeric(1,'#{the_max}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
-      end
-      it "should not compile when a non-Numeric maximum #{the_max} bare word is passed" do
-        Puppet[:code] = "validate_numeric(1,#{the_max})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
+      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
-
-    it "should not compile when an explicitly undefined variable is passed as maximum and no minimum is passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = undef
-        validate_numeric(10, $foo)
-      ENDofPUPPETcode
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
-    end
-    it "should not compile when an explicitly undef is passed as maximum and no minimum is passed" do
-      Puppet[:code] = "validate_numeric(10, undef)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
-    end
-    it "should not compile when an empty string is passed as maximum and no minimum is passed" do
-      Puppet[:code] = "validate_numeric(10, '')"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
-    end
-    it "should not compile when an undefined variable for a maximum is passed" do
-      Puppet[:code] = "validate_numeric(10, $foobarbazishouldnotexist)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
-    end
   end
 
-  describe 'when calling validate_numeric from puppet with input, a maximum and a minimum' do
-    it "should not compile when a minimum larger than maximum is passed" do
-      Puppet[:code] = "validate_numeric(1,1,2)"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /second argument to be larger than third argument/)
-    end
-
-    max = 10
-    min = -10
-    %w{ 1 -1 }.each do |the_number|
-      it "should compile when each element of #{the_number} is within a range from #{min} to #{max}" do
-        Puppet[:code] = "validate_numeric(#{the_number},#{max},#{min})"
-        scope.compiler.compile
-      end
-    end
-
-    it "should compile when a Numeric is equal the minimum" do
-      Puppet[:code] = "validate_numeric(#{min},#{max},#{min})"
-      scope.compiler.compile
-    end
-
-    it "should compile when a Numeric is equal the minimum and maximum" do
-      Puppet[:code] = "validate_numeric(#{max},#{max},#{max})"
-      scope.compiler.compile
-    end
-
-    it "should compile when an empty maximum is passed and the Numeric is greater than the minimum" do
-      Puppet[:code] = "validate_numeric(#{max}.1,'',#{min})"
-      scope.compiler.compile
-    end
-    it "should compile when an explicitly undefined maximum is passed and the Numeric is greater than the minimum" do
-      Puppet[:code] = "validate_numeric(#{max}.1,undef,#{min})"
-      scope.compiler.compile
-    end
-    it "should compile when an explicitly undefined variable is passed for maximum and the Numeric is greater than the minimum" do
-      Puppet[:code] = <<-"ENDofPUPPETcode"
-        $foo = undef
-        validate_numeric(#{max}.1, $foo, #{min})
-      ENDofPUPPETcode
-      scope.compiler.compile
-    end
-    it "should not compile when no maximum value is given and the Numeric is greater than the minimum" do
-      Puppet[:code] = "validate_numeric(#{max}.1,,#{min})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::Error, /Syntax error at ','/)
-    end
-
-    it "should not compile when #{min-1} is lower than a minimum of #{min}" do
-      Puppet[:code] = "validate_numeric(#{min-1.0},#{max},#{min})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be greater or equal to/)
-    end
-
-    %w{ [-10,1,2,3,4,5,10] ['-10.0','1','2','3','4','5','10.0'] }.each do |the_number|
-      it "should compile when each element of #{the_number} is within a range from #{min} to #{max}" do
-        Puppet[:code] = "validate_numeric(#{the_number},#{max},#{min})"
-        scope.compiler.compile
-      end
-    end
-
-    it "should not compile when an element of an Array [#{min-1.1},1,2,3,4,5,10.0] is lower than a minimum of #{min}" do
-      Puppet[:code] = "validate_numeric([#{min-1},1,2,3,4,5,10],#{max},#{min})"
-      expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be greater or equal to/)
-    end
+  it { is_expected.to run.with_params(10.0, 10.0, 10.0) }
 
-    %w{ true false iAmAString 1test }.each do |the_min|
-      it "should not compile when a non-Numeric minimum #{the_min}, encapsulated in a String, is passed" do
-        Puppet[:code] = "validate_numeric(1,#{max},'#{the_min}')"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
-      end
-      it "should not compile when a non-Numeric minimum #{the_min} bare word is passed" do
-        Puppet[:code] = "validate_numeric(1,#{max},#{the_min})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /to be unset or a Numeric/)
-      end
-    end
+  describe 'empty upper limit is interpreted as infinity' do
+    it { is_expected.to run.with_params(11, '', 10.0) }
   end
 end
index d29988b..3531182 100755 (executable)
@@ -1,75 +1,54 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_re) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  # The subject of these examplres is the method itself.
-  subject do
-    # This makes sure the function is loaded within each test
-    function_name = Puppet::Parser::Functions.function(:validate_re)
-    scope.method(function_name)
+describe 'validate_re' do
+  after(:all) do
+    ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
-  context 'Using Puppet::Parser::Scope.new' do
-
-    describe 'Garbage inputs' do
-      inputs = [
-        [ nil ],
-        [ [ nil ] ],
-        [ { 'foo' => 'bar' } ],
-        [ { } ],
-        [ '' ],
-        [ "one", "one", "MSG to User", "4th arg" ],
-      ]
-
-      inputs.each do |input|
-        it "validate_re(#{input.inspect}) should fail" do
-          expect { subject.call [input] }.to raise_error Puppet::ParseError
-        end
-      end
-    end
-
-    describe 'Valid inputs' do
-      inputs = [
-        [ '/full/path/to/something', '^/full' ],
-        [ '/full/path/to/something', 'full' ],
-        [ '/full/path/to/something', ['full', 'absent'] ],
-        [ '/full/path/to/something', ['full', 'absent'], 'Message to the user' ],
-      ]
-
-      inputs.each do |input|
-        it "validate_re(#{input.inspect}) should not fail" do
-          expect { subject.call input }.not_to raise_error
-        end
-      end
-    end
-    describe "Valid inputs which should raise an exception without a message" do
-      # The intent here is to make sure valid inputs raise exceptions when they
-      # don't specify an error message to display.  This is the behvior in
-      # 2.2.x and prior.
-      inputs = [
-        [ "hello", [ "bye", "later", "adios" ] ],
-        [ "greetings", "salutations" ],
-      ]
+  # 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('', '')
+  end
 
-      inputs.each do |input|
-        it "validate_re(#{input.inspect}) should fail" do
-          expect { subject.call input }.to raise_error /validate_re.*?does not match/
-        end
-      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) }
+
+    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') }
     end
-    describe "Nicer Error Messages" do
-      # The intent here is to make sure the function returns the 3rd argument
-      # in the exception thrown
-      inputs = [
-        [ "hello", [ "bye", "later", "adios" ], "MSG to User" ],
-        [ "greetings", "salutations", "Error, greetings does not match salutations" ],
-      ]
 
-      inputs.each do |input|
-        it "validate_re(#{input.inspect}) should fail" do
-          expect { subject.call input }.to raise_error /#{input[2]}/
+    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/) }
+
+      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
       end
     end
index e23f61a..e4162de 100755 (executable)
@@ -1,67 +1,72 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe "the validate_slength function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("validate_slength")).to eq("function_validate_slength")
+describe 'validate_slength' do
+  after(:all) do
+    ENV.delete('STDLIB_LOG_DEPRECATIONS')
   end
 
-  describe "validating the input argument types" do
-    it "raises an error if there are less than two arguments" do
-      expect { scope.function_validate_slength([]) }.to raise_error Puppet::ParseError, /Wrong number of arguments/
-    end
-
-    it "raises an error if there are more than three arguments" do
-      expect { scope.function_validate_slength(['input', 1, 2, 3]) }.to raise_error Puppet::ParseError, /Wrong number of arguments/
-    end
-
-    it "raises an error if the first argument is not a string" do
-      expect { scope.function_validate_slength([Object.new, 2, 1]) }.to raise_error Puppet::ParseError, /Expected first argument.*got .*Object/
-    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('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/) }
+  end
 
-    it "raises an error if the second argument cannot be cast to an Integer" do
-      expect { scope.function_validate_slength(['input', Object.new]) }.to raise_error Puppet::ParseError, /Expected second argument.*got .*Object/
+  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/) }
     end
 
-    it "raises an error if the third argument cannot be cast to an Integer" do
-      expect { scope.function_validate_slength(['input', 1, Object.new]) }.to raise_error Puppet::ParseError, /Expected third argument.*got .*Object/
+    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) }
     end
 
-    it "raises an error if the second argument is smaller than the third argument" do
-      expect { scope.function_validate_slength(['input', 1, 2]) }.to raise_error Puppet::ParseError, /Expected second argument to be larger than third argument/
-    end
-  end
-
-  describe "validating the input string length" do
-    describe "when the input is a string" do
-      it "fails validation if the string is larger than the max length" do
-        expect { scope.function_validate_slength(['input', 1]) }.to raise_error Puppet::ParseError, /Expected length .* between 0 and 1, was 5/
-      end
-
-      it "fails validation if the string is less than the min length" do
-        expect { scope.function_validate_slength(['input', 10, 6]) }.to raise_error Puppet::ParseError, /Expected length .* between 6 and 10, was 5/
-      end
-
-      it "doesn't raise an error if the string is under the max length" do
-        scope.function_validate_slength(['input', 10])
+    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
 
-      it "doesn't raise an error if the string is equal to the max length" do
-        scope.function_validate_slength(['input', 5])
+      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
 
-      it "doesn't raise an error if the string is equal to the min length" do
-        scope.function_validate_slength(['input', 10, 5])
+      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
+  end
 
-    describe "when the input is an array" do
-      it "fails validation if one of the array elements is not a string" do
-        expect { scope.function_validate_slength([["a", "b", Object.new], 2]) }.to raise_error Puppet::ParseError, /Expected element at array position 2 .*String, got .*Object/
-      end
-    end
+  describe 'corner cases' do
+    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/) }
   end
 end
index 3b4fb3e..0907ede 100755 (executable)
@@ -1,60 +1,33 @@
-#! /usr/bin/env ruby -S rspec
-
 require 'spec_helper'
 
-describe Puppet::Parser::Functions.function(:validate_string) do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  describe 'when calling validate_string from puppet' do
-
-    %w{ foo bar baz }.each do |the_string|
-
-      it "should compile when #{the_string} is a string" do
-        Puppet[:code] = "validate_string('#{the_string}')"
-        scope.compiler.compile
-      end
-
-      it "should compile when #{the_string} is a bare word" do
-        Puppet[:code] = "validate_string(#{the_string})"
-        scope.compiler.compile
-      end
-
-    end
-
-    %w{ true false }.each do |the_string|
-      it "should compile when #{the_string} is a string" do
-        Puppet[:code] = "validate_string('#{the_string}')"
-        scope.compiler.compile
-      end
-
-      it "should not compile when #{the_string} is a bare word" do
-        Puppet[:code] = "validate_string(#{the_string})"
-        expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /is not a string/)
-      end
-    end
+describe 'validate_string' do
+  after(:all) 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('', '')
+  end
 
-    it "should compile when multiple string arguments are passed" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = ''
-        $bar = 'two'
-        validate_string($foo, $bar)
-      ENDofPUPPETcode
-      scope.compiler.compile
-    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 "should compile when an explicitly undef variable is passed (NOTE THIS MAY NOT BE DESIRABLE)" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        $foo = undef
-        validate_string($foo)
-      ENDofPUPPETcode
-      scope.compiler.compile
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params('') }
+      it { is_expected.to run.with_params(nil) }
+      it { is_expected.to run.with_params('one') }
+      it { is_expected.to run.with_params('one', 'two') }
     end
 
-    it "should compile when an undefined variable is passed (NOTE THIS MAY NOT BE DESIRABLE)" do
-      Puppet[:code] = <<-'ENDofPUPPETcode'
-        validate_string($foobarbazishouldnotexist)
-      ENDofPUPPETcode
-      scope.compiler.compile
+    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/) }
     end
   end
 end
diff --git a/3rdparty/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb
new file mode 100755 (executable)
index 0000000..eb63310
--- /dev/null
@@ -0,0 +1,180 @@
+require 'spec_helper'
+
+describe 'validate_x509_rsa_key_pair' do
+
+  let(:valid_cert) do
+  <<EOS
+-----BEGIN CERTIFICATE-----
+MIIC9jCCAeCgAwIBAgIRAK11n3X7aypJ7FPM8UFyAeowCwYJKoZIhvcNAQELMBIx
+EDAOBgNVBAoTB0FjbWUgQ28wHhcNMTUxMTIzMjIzOTU4WhcNMTYxMTIyMjIzOTU4
+WjASMRAwDgYDVQQKEwdBY21lIENvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
+CgKCAQEAz9bY/piKahD10AiJSfbI2A8NG5UwRz0r9T/WfvNVdhgrsGFgNQjvpUoZ
+nNJpQIHBbgMOiXqfATFjJl5FjEkSf7GUHohlGVls9MX2JmVvknzsiitd75H/EJd+
+N+k915lix8Vqmj8d1CTlbF/8tEjzANI67Vqw5QTuqebO7rkIUvRg6yiRfSo75FK1
+RinCJyl++kmleBwQZBInQyg95GvJ5JTqMzBs67DeeyzskDhTeTePRYVF2NwL8QzY
+htvLIBERTNsyU5i7nkxY5ptUwgFUwd93LH4Q19tPqL5C5RZqXxhE51thOOwafm+a
+W/cRkqYqV+tv+j1jJ3WICyF1JNW0BQIDAQABo0swSTAOBgNVHQ8BAf8EBAMCAKAw
+EwYDVR0lBAwwCgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADAUBgNVHREEDTALggls
+b2NhbGhvc3QwCwYJKoZIhvcNAQELA4IBAQAzRo0hpVTrFQZLIXpwvKwZVGvJdCkV
+P95DTsSk/VTGV+/YtxrRqks++hJZnctm2PbnTsCAoIP3AMx+vicCKiKrxvpsLU8/
++6cowUbcuGMdSQktwDqbAgEhQlLsETll06w1D/KC+ejOc4+LRn3GQcEyGDtMk/EX
+IeAvBZHr4/kVXWnfo6kzCLcku1f8yE/yDEFClZe9XV1Lk/s+3YfXVtNnMJJ1giZI
+QVOe6CkmuQq+4AtIeW8aLkvlfp632jag1F77a1y+L268koKkj0hBMrtcErVQaxmq
+xym0+soR4Tk4pTIGckeFglrLxkP2JpM/yTwSEAVlmG9vgTliYKyR0uMl
+-----END CERTIFICATE-----
+EOS
+  end
+
+  let(:valid_key) do
+  <<EOS
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEAz9bY/piKahD10AiJSfbI2A8NG5UwRz0r9T/WfvNVdhgrsGFg
+NQjvpUoZnNJpQIHBbgMOiXqfATFjJl5FjEkSf7GUHohlGVls9MX2JmVvknzsiitd
+75H/EJd+N+k915lix8Vqmj8d1CTlbF/8tEjzANI67Vqw5QTuqebO7rkIUvRg6yiR
+fSo75FK1RinCJyl++kmleBwQZBInQyg95GvJ5JTqMzBs67DeeyzskDhTeTePRYVF
+2NwL8QzYhtvLIBERTNsyU5i7nkxY5ptUwgFUwd93LH4Q19tPqL5C5RZqXxhE51th
+OOwafm+aW/cRkqYqV+tv+j1jJ3WICyF1JNW0BQIDAQABAoIBADAiZ/r+xP+vkd5u
+O61/lCBFzBlZQecdybJw6HJaVK6XBndA9hESUr4LHUdui6W+51ddKd65IV4bXAUk
+zCKjQb+FFvLDT/bA+TTvLATUdTSN7hJJ3OWBAHuNOlQklof6JCB0Hi4+89+P8/pX
+eKUgR/cmuTMDT/iaXdPHeqFbBQyA1ZpQFRjN5LyyJMS/9FkywuNc5wlpsArtc51T
+gIKENUZCuPhosR+kMFc2iuTNvqZWPhvouSrmhi2O6nSqV+oy0+irlqSpCF2GsCI8
+72TtLpq94Grrq0BEH5avouV+Lp4k83vO65OKCQKUFQlxz3Xkxm2U3J7KzxqnRtM3
+/b+cJ/kCgYEA6/yOnaEYhH/7ijhZbPn8RujXZ5VGJXKJqIuaPiHMmHVS5p1j6Bah
+2PcnqJA2IlLs3UloN+ziAxAIH6KCBiwlQ/uPBNMMaJsIjPNBEy8axjndKhKUpidg
+R0OJ7RQqMShOJ8akrSfWdPtXC/GBuwCYE//t77GgZaIMO3FcT9EKA48CgYEA4Xcx
+Fia0Jg9iyAhNmUOXI6hWcGENavMx01+x7XFhbnMjIKTZevFfTnTkrX6HyLXyGtMU
+gHOn+k4PE/purI4ARrKO8m5wYEKqSIt4dBMTkIXXirfQjXgfjR8E4T/aPe5fOFZo
+7OYuxLRtzmG1C2sW4txwKAKX1LaWcVx/RLSttSsCgYBbcj8Brk+F6OJcqYFdzXGJ
+OOlf5mSMVlopyg83THmwCqbZXtw8L6kAHqZrl5airmfDSJLuOQlMDoZXW+3u3mSC
+d5TwVahVUN57YDgzaumBLyMZDqIz0MZqVy23hTzkV64Rk9R0lR9xrYQJyMhw4sYL
+2f0mCTsSpzz+O+t9so+i2QKBgEC38gMlwPhb2kMI/x1LZYr6uzUu5qcYf+jowy4h
+KZKGwkKQj0zXFEB1FV8nvtpCP+irRmtIx6L13SYi8LnfWPzyLE4ynVdES5TfVAgd
+obQOdzx+XwL8xDHCAaiWp5K3ZeXKB/xYZnxYPlzLdyh76Ond1OPnOqX4c16+6llS
+c7pZAoGATd9NckT0XtXLEsF3IraDivq8dP6bccX2DNfS8UeEvRRrRwpFpSRrmuGb
+jbG4yzoIX4RjQfj/z48hwhJB+cKiN9WwcPsFXtHe7v3F6BRwK0JUfrCiXad8/SGZ
+KAf7Dfqi608zBdnPWHacre2Y35gPHB00nFQOLS6u46aBNSq07YA=
+-----END RSA PRIVATE KEY-----
+EOS
+  end
+
+  let(:another_valid_key) do
+  <<EOS
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEAoISxYJBTPAeAzFnm+lE/ljLlmGal2Xr3vwZKkvJiuKA/m4QJ
+0ZNdtkBSDOVuG2dXVv6W4sChRtsCdvuVe7bjTYvlU8TWM3VEJDL9l9cRXScxxlKQ
+Xwb35y1yV35NJfaK/jzm9KcErtQQs1RxvGlWRaohmLM8uQcuhjZfMsSlQoHQD5LX
+sbPtk82RPyxYc1dj2vsaoi1VvuP2+jv4xLQOmNJY1bT5GTurqiltmxEtWhNNmGg0
+2wtK00ifqLVO5HNc3gXQCDM2M99Sbmn1YtbrgsU9xMYfcPmvQvb+YoKskyoqck+c
+HR//hi7vslbxABrny15LBkEfRc4TickphSGYXwIDAQABAoIBAATEzGw8/WwMIQRx
+K06GeWgh7PZBHm4+m/ud2TtSXiJ0CE+7dXs3cJJIiOd/LW08/bhE6gCkjmYHfaRB
+Ryicv1X/cPmzIFX5BuQ4a5ZGOmrVDkKBE27vSxAgJoR46RvWnjx9XLMp/xaekDxz
+psldK8X4DvV1ZbltgDFWji947hvyqUtHdKnkQnc5j7aCIFJf9GMfzaeeDPMaL8WF
+mVL4iy9EAOjNOHBshZj/OHyU5FbJ8ROwZQlCOiLCdFegftSIXt8EYDnjB3BdsALH
+N6hquqrD7xDKyRbTD0K7lqxUubuMwTQpi61jZD8TBTXEPyFVAnoMpXkc0Y+np40A
+YiIsR+kCgYEAyrc4Bh6fb9gt49IXGXOSRZ5i5+TmJho4kzIONrJ7Ndclwx9wzHfh
+eGBodWaw5CxxQGMf4vEiaZrpAiSFeDffBLR+Wa2TFE5aWkdYkR34maDjO00m4PE1
+S+YsZoGw7rGmmj+KS4qv2T26FEHtUI+F31RC1FPohLsQ22Jbn1ORipsCgYEAyrYB
+J2Ncf2DlX1C0GfxyUHQOTNl0V5gpGvpbZ0WmWksumYz2kSGOAJkxuDKd9mKVlAcz
+czmN+OOetuHTNqds2JJKKJy6hJbgCdd9aho3dId5Xs4oh4YwuFQiG8R/bJZfTlXo
+99Qr02L7MmDWYLmrR3BA/93UPeorHPtjqSaYU40CgYEAtmGfWwokIglaSDVVqQVs
+3YwBqmcrla5TpkMLvLRZ2/fktqfL4Xod9iKu+Klajv9ZKTfFkXWno2HHL7FSD/Yc
+hWwqnV5oDIXuDnlQOse/SeERb+IbD5iUfePpoJQgbrCQlwiB0TNGwOojR2SFMczf
+Ai4aLlQLx5dSND9K9Y7HS+8CgYEAixlHQ2r4LuQjoTs0ytwi6TgqE+vn3K+qDTwc
+eoods7oBWRaUn1RCKAD3UClToZ1WfMRQNtIYrOAsqdveXpOWqioAP0wE5TTOuZIo
+GiWxRgIsc7TNtOmNBv+chCdbNP0emxdyjJUIGb7DFnfCw47EjHnn8Guc13uXaATN
+B2ZXgoUCgYAGa13P0ggUf5BMJpBd8S08jKRyvZb1CDXcUCuGtk2yEx45ern9U5WY
+zJ13E5z9MKKO8nkGBqrRfjJa8Xhxk4HKNFuzHEet5lvNE7IKCF4YQRb0ZBhnb/78
++4ZKjFki1RrWRNSw9TdvrK6qaDKgTtCTtfRVXAYQXUgq7lSFOTtL3A==
+-----END RSA PRIVATE KEY-----
+EOS
+  end
+
+  let(:valid_cert_but_indented) do
+    valid_cert.gsub(/^/, '  ')
+  end
+
+  let(:valid_key_but_indented) do
+    valid_key.gsub(/^/, '  ')
+  end
+
+  let(:malformed_cert) do
+    truncate_middle(valid_cert)
+  end
+
+  let(:malformed_key) do
+    truncate_middle(valid_key)
+  end
+
+  let(:bad_cert) do
+    'foo'
+  end
+
+  let(:bad_key) do
+    'bar'
+  end
+
+  context '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) }
+  end
+
+  context '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
+    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/) }
+    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/) }
+    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/) }
+    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/) }
+    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/) }
+    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/) }
+    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/) }
+    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/) }
+    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/) }
+    end
+  end
+
+  def truncate_middle(string)
+    chars_to_truncate = 48
+    middle = (string.length / 2).floor
+    start_pos = middle - (chars_to_truncate / 2)
+    end_pos = middle + (chars_to_truncate / 2)
+
+    string[start_pos...end_pos] = ''
+    return string
+  end
+end
index 86e3c31..681c101 100755 (executable)
@@ -1,38 +1,54 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the values_at function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("values_at")).to eq("function_values_at")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_values_at([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if you try to use a range where stop is greater then start" do
-    expect { scope.function_values_at([['a','b'],["3-1"]]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return a value at from an array" do
-    result = scope.function_values_at([['a','b','c'],"1"])
-    expect(result).to(eq(['b']))
+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 {
+      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)
+    }
+    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/) }
   end
 
-  it "should return a value at from an array when passed a range" do
-    result = scope.function_values_at([['a','b','c'],"0-1"])
-    expect(result).to(eq(['a','b']))
+  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], 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/) }
   end
 
-  it "should return chosen values from an array when passed number of indexes" do
-    result = scope.function_values_at([['a','b','c'],["0","2"]])
-    expect(result).to(eq(['a','c']))
+  context 'when requesting a single item using UTF8 and double byte characters' do
+    it { is_expected.to run.with_params(['ẩ', 'β', 'с', 'ď'], 0).and_return(['ẩ']) }
+    it { is_expected.to run.with_params(['文', '字', 'の', '値'], 2).and_return(['の']) }
   end
 
-  it "should return chosen values from an array when passed ranges and multiple indexes" do
-    result = scope.function_values_at([['a','b','c','d','e','f','g'],["0","2","4-5"]])
-    expect(result).to(eq(['a','c','e','f']))
+  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], [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/) }
+
+    describe 'different range syntaxes' do
+      it { is_expected.to run.with_params([0, 1, 2], '0-2').and_return([0, 1, 2]) }
+      it { is_expected.to run.with_params([0, 1, 2], '0..2').and_return([0, 1, 2]) }
+      it { is_expected.to run.with_params([0, 1, 2], '0...2').and_return([0, 1]) }
+      it {
+        pending('fix this bounds check')
+        is_expected.to run.with_params([0, 1, 2], '0...3').and_return([0, 1, 2])
+      }
+    end
   end
 end
index 08d21b0..26c6dfb 100755 (executable)
@@ -1,31 +1,24 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the values function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("values")).to eq("function_values")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_values([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should return values from a hash" do
-    result = scope.function_values([{'a'=>'1','b'=>'2','c'=>'3'}])
-    # =~ is the RSpec::Matchers::MatchArray matcher.
-    # A.K.A. "array with same elements" (multiset) matching
-    expect(result).to match_array(%w{ 1 2 3 })
-  end
-
-  it "should return a multiset" do
-    result = scope.function_values([{'a'=>'1','b'=>'3','c'=>'3'}])
-    expect(result).to     match_array(%w{ 1 3 3 })
-    expect(result).not_to match_array(%w{ 1 3 })
+describe 'values' 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 {
+    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)
+  }
+  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_return([]) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['value']) }
+  it 'should return 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 raise a ParseError unless a Hash is provided" do
-    expect { scope.function_values([['a','b','c']]) }.to( raise_error(Puppet::ParseError))
+  it 'should run with UTF8 and double byte characters' do
+    result = subject.call([{ 'かぎ' => '使用', 'ҝĕұ' => '√ẩŀứệ', 'ҝĕұďŭрļǐçằťè' => '√ẩŀứệ' }])
+    expect(result).to match_array(['使用', '√ẩŀứệ', '√ẩŀứệ'])
   end
 end
index f265fce..e1ae8ee 100755 (executable)
@@ -1,31 +1,21 @@
-#! /usr/bin/env ruby -S rspec
 require 'spec_helper'
 
-describe "the zip function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+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 {
+    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)
+  }
+  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 "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_zip([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should be able to zip an array" do
-    result = scope.function_zip([['1','2','3'],['4','5','6']])
-    expect(result).to(eq([["1", "4"], ["2", "5"], ["3", "6"]]))
-    result = scope.function_zip([['1','2','3'],['4','5','6'], false])
-    result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]]))
-  end
-
-  it "should be able to zip an array and flatten" do
-    result = scope.function_zip([['1','2','3'],['4','5','6'], true])
-    result.should(eq(["1", "4", "2", "5", "3", "6"]))
-  end
-
-  it "should accept objects which extend String for the second argument" do
-    class AlsoString < String
-    end
-
-    value = AlsoString.new('false')
-    result = scope.function_zip([['1','2','3'],['4','5','6'],value])
-    result.should(eq([["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([['ペ','ッ'], ['含','文'], ['値', 'イ']]) }
   end
 end
+
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/compiler.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/compiler.rb
deleted file mode 100755 (executable)
index 2f0ae4d..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-module PuppetSpec::Compiler
-  def compile_to_catalog(string, node = Puppet::Node.new('foonode'))
-    Puppet[:code] = string
-    Puppet::Parser::Compiler.compile(node)
-  end
-
-  def compile_to_ral(manifest)
-    catalog = compile_to_catalog(manifest)
-    ral = catalog.to_ral
-    ral.finalize
-    ral
-  end
-
-  def compile_to_relationship_graph(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new)
-    ral = compile_to_ral(manifest)
-    graph = Puppet::Graph::RelationshipGraph.new(prioritizer)
-    graph.populate_from(ral)
-    graph
-  end
-
-  if Puppet.version.to_f >= 3.3
-    def apply_compiled_manifest(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new)
-      transaction = Puppet::Transaction.new(compile_to_ral(manifest),
-                                          Puppet::Transaction::Report.new("apply"),
-                                          prioritizer)
-      transaction.evaluate
-      transaction.report.finalize_report
-
-      transaction
-    end
-  else
-    def apply_compiled_manifest(manifest)
-      transaction = Puppet::Transaction.new(compile_to_ral(manifest), Puppet::Transaction::Report.new("apply"))
-      transaction.evaluate
-      transaction.report.finalize_report
-
-      transaction
-    end
-  end
-
-  def order_resources_traversed_in(relationships)
-    order_seen = []
-    relationships.traverse { |resource| order_seen << resource.ref }
-    order_seen
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/database.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/database.rb
deleted file mode 100755 (executable)
index f5c2341..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-# This just makes some nice things available at global scope, and for setup of
-# tests to use a real fake database, rather than a fake stubs-that-don't-work
-# version of the same.  Fun times.
-def sqlite?
-  if $sqlite.nil?
-    begin
-      require 'sqlite3'
-      $sqlite = true
-    rescue LoadError
-      $sqlite = false
-    end
-  end
-  $sqlite
-end
-
-def can_use_scratch_database?
-  sqlite? and Puppet.features.rails?
-end
-
-
-# This is expected to be called in your `before :each` block, and will get you
-# ready to roll with a serious database and all.  Cleanup is handled
-# automatically for you.  Nothing to do there.
-def setup_scratch_database
-  Puppet[:dbadapter] = 'sqlite3'
-  Puppet[:dblocation] = ':memory:'
-  Puppet[:railslog] = PuppetSpec::Files.tmpfile('storeconfigs.log')
-  Puppet::Rails.init
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/files.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/files.rb
deleted file mode 100755 (executable)
index 71b38ff..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'fileutils'
-require 'tempfile'
-require 'tmpdir'
-require 'pathname'
-
-# A support module for testing files.
-module PuppetSpec::Files
-  def self.cleanup
-    $global_tempfiles ||= []
-    while path = $global_tempfiles.pop do
-      begin
-        Dir.unstub(:entries)
-        FileUtils.rm_rf path, :secure => true
-      rescue Errno::ENOENT
-        # nothing to do
-      end
-    end
-  end
-
-  def make_absolute(path) PuppetSpec::Files.make_absolute(path) end
-  def self.make_absolute(path)
-    path = File.expand_path(path)
-    path[0] = 'c' if Puppet.features.microsoft_windows?
-    path
-  end
-
-  def tmpfile(name, dir = nil) PuppetSpec::Files.tmpfile(name, dir) end
-  def self.tmpfile(name, dir = nil)
-    # Generate a temporary file, just for the name...
-    source = dir ? Tempfile.new(name, dir) : Tempfile.new(name)
-    path = source.path
-    source.close!
-
-    record_tmp(File.expand_path(path))
-
-    path
-  end
-
-  def file_containing(name, contents) PuppetSpec::Files.file_containing(name, contents) end
-  def self.file_containing(name, contents)
-    file = tmpfile(name)
-    File.open(file, 'wb') { |f| f.write(contents) }
-    file
-  end
-
-  def tmpdir(name) PuppetSpec::Files.tmpdir(name) end
-  def self.tmpdir(name)
-    dir = Dir.mktmpdir(name)
-
-    record_tmp(dir)
-
-    dir
-  end
-
-  def self.record_tmp(tmp)
-    # ...record it for cleanup,
-    $global_tempfiles ||= []
-    $global_tempfiles << tmp
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/fixtures.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/fixtures.rb
deleted file mode 100755 (executable)
index 81e9775..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-module PuppetSpec::Fixtures
-  def fixtures(*rest)
-    File.join(PuppetSpec::FIXTURE_DIR, *rest)
-  end
-  def my_fixture_dir
-    callers = caller
-    while line = callers.shift do
-      next unless found = line.match(%r{/spec/(.*)_spec\.rb:})
-      return fixtures(found[1])
-    end
-    fail "sorry, I couldn't work out your path from the caller stack!"
-  end
-  def my_fixture(name)
-    file = File.join(my_fixture_dir, name)
-    unless File.readable? file then
-      fail Puppet::DevError, "fixture '#{name}' for #{my_fixture_dir} is not readable"
-    end
-    return file
-  end
-  def my_fixtures(glob = '*', flags = 0)
-    files = Dir.glob(File.join(my_fixture_dir, glob), flags)
-    unless files.length > 0 then
-      fail Puppet::DevError, "fixture '#{glob}' for #{my_fixture_dir} had no files!"
-    end
-    block_given? and files.each do |file| yield file end
-    files
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/matchers.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/matchers.rb
deleted file mode 100755 (executable)
index 093d77c..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'stringio'
-
-########################################################################
-# Backward compatibility for Jenkins outdated environment.
-module RSpec
-  module Matchers
-    module BlockAliases
-      alias_method :to,     :should      unless method_defined? :to
-      alias_method :to_not, :should_not  unless method_defined? :to_not
-      alias_method :not_to, :should_not  unless method_defined? :not_to
-    end
-  end
-end
-
-
-########################################################################
-# Custom matchers...
-RSpec::Matchers.define :have_matching_element do |expected|
-  match do |actual|
-    actual.any? { |item| item =~ expected }
-  end
-end
-
-
-RSpec::Matchers.define :exit_with do |expected|
-  actual = nil
-  match do |block|
-    begin
-      block.call
-    rescue SystemExit => e
-      actual = e.status
-    end
-    actual and actual == expected
-  end
-  failure_message_for_should do |block|
-    "expected exit with code #{expected} but " +
-      (actual.nil? ? " exit was not called" : "we exited with #{actual} instead")
-  end
-  failure_message_for_should_not do |block|
-    "expected that exit would not be called with #{expected}"
-  end
-  description do
-    "expect exit with #{expected}"
-  end
-end
-
-class HavePrintedMatcher
-  attr_accessor :expected, :actual
-
-  def initialize(expected)
-    case expected
-    when String, Regexp
-      @expected = expected
-    else
-      @expected = expected.to_s
-    end
-  end
-
-  def matches?(block)
-    begin
-      $stderr = $stdout = StringIO.new
-      $stdout.set_encoding('UTF-8') if $stdout.respond_to?(:set_encoding)
-      block.call
-      $stdout.rewind
-      @actual = $stdout.read
-    ensure
-      $stdout = STDOUT
-      $stderr = STDERR
-    end
-
-    if @actual then
-      case @expected
-      when String
-        @actual.include? @expected
-      when Regexp
-        @expected.match @actual
-      end
-    else
-      false
-    end
-  end
-
-  def failure_message_for_should
-    if @actual.nil? then
-      "expected #{@expected.inspect}, but nothing was printed"
-    else
-      "expected #{@expected.inspect} to be printed; got:\n#{@actual}"
-    end
-  end
-
-  def failure_message_for_should_not
-    "expected #{@expected.inspect} to not be printed; got:\n#{@actual}"
-  end
-
-  def description
-    "expect #{@expected.inspect} to be printed"
-  end
-end
-
-def have_printed(what)
-  HavePrintedMatcher.new(what)
-end
-
-RSpec::Matchers.define :equal_attributes_of do |expected|
-  match do |actual|
-    actual.instance_variables.all? do |attr|
-      actual.instance_variable_get(attr) == expected.instance_variable_get(attr)
-    end
-  end
-end
-
-RSpec::Matchers.define :be_one_of do |*expected|
-  match do |actual|
-    expected.include? actual
-  end
-
-  failure_message_for_should do |actual|
-    "expected #{actual.inspect} to be one of #{expected.map(&:inspect).join(' or ')}"
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/modules.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/modules.rb
deleted file mode 100755 (executable)
index 910c6d9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-module PuppetSpec::Modules
-  class << self
-    def create(name, dir, options = {})
-      module_dir = File.join(dir, name)
-      FileUtils.mkdir_p(module_dir)
-
-      environment = options[:environment]
-
-      if metadata = options[:metadata]
-        metadata[:source]  ||= 'github'
-        metadata[:author]  ||= 'puppetlabs'
-        metadata[:version] ||= '9.9.9'
-        metadata[:license] ||= 'to kill'
-        metadata[:dependencies] ||= []
-
-        metadata[:name] = "#{metadata[:author]}/#{name}"
-
-        File.open(File.join(module_dir, 'metadata.json'), 'w') do |f|
-          f.write(metadata.to_pson)
-        end
-      end
-
-      Puppet::Module.new(name, module_dir, environment)
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/pops.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/pops.rb
deleted file mode 100755 (executable)
index e056a52..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-module PuppetSpec::Pops
-  extend RSpec::Matchers::DSL
-
-  # Checks if an Acceptor has a specific issue in its list of diagnostics
-  matcher :have_issue do |expected|
-    match do |actual|
-      actual.diagnostics.index { |i| i.issue == expected } != nil
-    end
-    failure_message_for_should do |actual|
-      "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to contain issue #{expected.issue_code}"
-    end
-    failure_message_for_should_not do |actual|
-      "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to not contain issue #{expected.issue_code}"
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/scope.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/scope.rb
deleted file mode 100755 (executable)
index 3847ede..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-
-module PuppetSpec::Scope
-  # Initialize a new scope suitable for testing.
-  #
-  def create_test_scope_for_node(node_name)
-    node = Puppet::Node.new(node_name)
-    compiler = Puppet::Parser::Compiler.new(node)
-    scope = Puppet::Parser::Scope.new(compiler)
-    scope.source = Puppet::Resource::Type.new(:node, node_name)
-    scope.parent = compiler.topscope
-    scope
-  end
-
-end
\ No newline at end of file
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/settings.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/settings.rb
deleted file mode 100755 (executable)
index 8ddcb97..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-module PuppetSpec::Settings
-
-  # It would probably be preferable to refactor defaults.rb such that the real definitions of
-  #  these settings were available as a variable, which was then accessible for use during tests.
-  #  However, I'm not doing that yet because I don't want to introduce any additional moving parts
-  #  to this already very large changeset.
-  #  Would be nice to clean this up later.  --cprice 2012-03-20
-  TEST_APP_DEFAULT_DEFINITIONS = {
-    :name         => { :default => "test", :desc => "name" },
-    :logdir       => { :type => :directory, :default => "test", :desc => "logdir" },
-    :confdir      => { :type => :directory, :default => "test", :desc => "confdir" },
-    :vardir       => { :type => :directory, :default => "test", :desc => "vardir" },
-    :rundir       => { :type => :directory, :default => "test", :desc => "rundir" },
-  }
-end
diff --git a/3rdparty/modules/stdlib/spec/lib/puppet_spec/verbose.rb b/3rdparty/modules/stdlib/spec/lib/puppet_spec/verbose.rb
deleted file mode 100755 (executable)
index b2683df..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-# Support code for running stuff with warnings disabled.
-module Kernel
-  def with_verbose_disabled
-    verbose, $VERBOSE = $VERBOSE, nil
-    result = yield
-    $VERBOSE = verbose
-    return result
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/spec.opts b/3rdparty/modules/stdlib/spec/spec.opts
deleted file mode 100644 (file)
index 91cd642..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
---format
-s
---colour
---loadby
-mtime
---backtrace
index b490ca3..22d5d68 100755 (executable)
@@ -1,34 +1,8 @@
-#! /usr/bin/env ruby -S rspec
-dir = File.expand_path(File.dirname(__FILE__))
-$LOAD_PATH.unshift File.join(dir, 'lib')
-
-# So everyone else doesn't have to include this base constant.
-module PuppetSpec
-  FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
-end
-
-require 'puppet'
-require 'rspec-puppet'
+#This file is generated by ModuleSync, do not edit.
 require 'puppetlabs_spec_helper/module_spec_helper'
-require 'puppet_spec/verbose'
-require 'puppet_spec/files'
-require 'puppet_spec/settings'
-require 'puppet_spec/fixtures'
-require 'puppet_spec/matchers'
-require 'puppet_spec/database'
-require 'monkey_patches/alias_should_to_must'
-require 'mocha/setup'
-
-
 
-RSpec.configure do |config|
-  config.before :each do
-    # Ensure that we don't accidentally cache facts and environment between
-    # test cases.  This requires each example group to explicitly load the
-    # facts being exercised with something like
-    # Facter.collection.loader.load(:ipaddress)
-    Facter::Util::Loader.any_instance.stubs(:load_all)
-    Facter.clear
-    Facter.clear_messages
-  end
+# put local configuration and setup into spec_helper_local
+begin
+  require 'spec_helper_local'
+rescue LoadError
 end
index 3203ce9..4d85e7d 100755 (executable)
@@ -1,50 +1,55 @@
 #! /usr/bin/env ruby -S rspec
+require 'puppet'
 require 'beaker-rspec'
+require 'beaker/puppet_install_helper'
+require 'beaker/module_install_helper'
 
-UNSUPPORTED_PLATFORMS = []
+run_puppet_install_helper
+install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i
+install_module_on(hosts)
+install_module_dependencies_on(hosts)
 
-unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
-  foss_opts = {
-    :default_action => 'gem_install',
-    :version        => (ENV['PUPPET_VERSION'] ? ENV['PUPPET_VERSION'] : '3.7.2'),
-  }
+RSpec.configure do |c|
+  # Readable test descriptions
+  c.formatter = :documentation
+
+  # Configure all nodes in nodeset
+  c.before :suite do
+  end
+end
 
-  if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end
+def get_puppet_version
+  (on default, puppet('--version')).output.chomp
+end
 
-  hosts.each do |host|
-    if host['platform'] !~ /windows/i
-      if host.is_pe?
-        on host, 'mkdir -p /etc/puppetlabs/facter/facts.d'
+RSpec.shared_context "with faked facts" do
+  let(:facts_d) do
+    puppet_version = get_puppet_version
+    if fact('osfamily') =~ /windows/i
+      if fact('kernelmajversion').to_f < 6.0
+        'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
       else
-        on host, "/bin/touch #{host['puppetpath']}/hiera.yaml"
-        on host, "mkdir -p #{host['distmoduledir']}"
-        on host, 'mkdir -p /etc/facter/facts.d'
+        'C:/ProgramData/PuppetLabs/facter/facts.d'
       end
+    elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true"
+      '/etc/puppetlabs/facter/facts.d'
+    else
+      '/etc/facter/facts.d'
     end
   end
-end
 
-RSpec.configure do |c|
-  # Project root
-  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
-
-  # Readable test descriptions
-  c.formatter = :documentation
-
-  # Configure all nodes in nodeset
-  c.before :suite do
-    if ENV['FUTURE_PARSER'] == 'true'
-      default[:default_apply_opts] ||= {}
-      default[:default_apply_opts].merge!({:parser => 'future'})
+  before :each do
+    #No need to create on windows, PE creates by default
+    if fact('osfamily') !~ /windows/i
+      shell("mkdir -p '#{facts_d}'")
     end
+  end
 
-    copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib')
+  after :each do
+    shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0,1])
   end
-end
 
-def is_future_parser_enabled?
-  if default[:default_apply_opts]
-    return default[:default_apply_opts][:parser] == 'future'
+  def fake_fact(name, value)
+    shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'")
   end
-  return false
 end
diff --git a/3rdparty/modules/stdlib/spec/spec_helper_local.rb b/3rdparty/modules/stdlib/spec/spec_helper_local.rb
new file mode 100644 (file)
index 0000000..616490c
--- /dev/null
@@ -0,0 +1,31 @@
+# automatically load any shared examples or contexts
+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
+RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
+
+RSpec.configure do |config|
+  # supply tests with a possibility to test for the future parser
+  config.add_setting :puppet_future
+  config.puppet_future = Puppet.version.to_f >= 4.0
+
+  config.before :each do
+    # Ensure that we don't accidentally cache facts and environment between
+    # test cases.  This requires each example group to explicitly load the
+    # facts being exercised with something like
+    # Facter.collection.loader.load(:ipaddress)
+    Facter.clear
+    Facter.clear_messages
+    
+    RSpec::Mocks.setup
+  end
+
+  config.after :each do
+    RSpec::Mocks.verify
+    RSpec::Mocks.teardown
+  end
+end
+
+# Helper class to test handling of arguments which are derived from string
+class AlsoString < String
+end
diff --git a/3rdparty/modules/stdlib/spec/support/shared_data.rb b/3rdparty/modules/stdlib/spec/support/shared_data.rb
new file mode 100644 (file)
index 0000000..ea9b7a0
--- /dev/null
@@ -0,0 +1,38 @@
+module SharedData
+  IPV4_PATTERNS = [
+    '0.0.0.0',
+    '1.2.3.4',
+    '10.10.10.10',
+    '127.0.0.1',
+    '192.88.99.0',
+    '194.232.104.150',
+    '224.0.0.0',
+    '244.24.24.24',
+    '255.255.255.255',
+    '8.8.8.8',
+    '8.8.8.8/0',
+    '8.8.8.8/16',
+    '8.8.8.8/255.255.0.0',
+    '8.8.8.8/32',
+  ]
+  IPV4_NEGATIVE_PATTERNS = [
+    '',
+    '0000',
+    '0.0.0.0.',
+    '0.0.0.0./0.0.0.0.',
+    '0.0.0.0./1',
+    '0.0.0.0.0',
+    '0.0.0.0/0.0.0.0.',
+    '0.0.0.256',
+    '0.0.0',
+    '1.2.3.4.5',
+    '1.2.3',
+    '10.010.10.10',
+    '2001:0db8:85a3:0000:0000:8a2e:0370:73342001:0db8:85a3:0000:0000:8a2e:0370:7334',
+    '4.4.4',
+    '77',
+    '9999.9999.9999.9999',
+    'affe::beef',
+    'nope',
+  ]
+end
diff --git a/3rdparty/modules/stdlib/spec/unit/facter/package_provider_spec.rb b/3rdparty/modules/stdlib/spec/unit/facter/package_provider_spec.rb
new file mode 100644 (file)
index 0000000..3954faf
--- /dev/null
@@ -0,0 +1,44 @@
+#! /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 }
+
+  ['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
+      end
+
+      context "darwin" do
+        it "should return pkgdmg" do
+          provider = Puppet::Type.type(:package).provider(:pkgdmg)
+          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+
+          expect(Facter.fact(:package_provider).value).to eq('pkgdmg')
+        end
+      end
+
+      context "centos 7" do
+        it "should return yum" do
+          provider = Puppet::Type.type(:package).provider(:yum)
+          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+
+          expect(Facter.fact(:package_provider).value).to eq('yum')
+        end
+      end
+
+      context "ubuntu" do
+        it "should return apt" do
+          provider = Puppet::Type.type(:package).provider(:apt)
+          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+
+          expect(Facter.fact(:package_provider).value).to eq('apt')
+        end
+      end
+    end
+  end
+end
index 4d0349e..c11a1cd 100755 (executable)
@@ -14,6 +14,17 @@ describe "PE Version specs" do
       Facter.collection.loader.load(:pe_version)
     end
   end
+  
+  context "When puppetversion is nil" do
+    before :each do
+      Facter.fact(:puppetversion).stubs(:value).returns(nil)
+    end
+    
+    it "pe_version is nil" do
+      expect(Facter.fact(:puppetversion).value).to be_nil
+      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|
@@ -73,4 +84,5 @@ describe "PE Version specs" do
       expect(Facter.fact(:pe_patch_version).value).to be_nil
     end
   end
+
 end
index 98fe141..a5c2846 100755 (executable)
@@ -49,4 +49,17 @@ describe 'root_home', :type => :fact do
     end
   end
 
+  context "aix" do
+    before do
+      Facter.fact(:kernel).stubs(:value).returns("AIX")
+      Facter.fact(:osfamily).stubs(:value).returns("AIX")
+    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)
+    end
+  end
 end
diff --git a/3rdparty/modules/stdlib/spec/unit/facter/service_provider_spec.rb b/3rdparty/modules/stdlib/spec/unit/facter/service_provider_spec.rb
new file mode 100644 (file)
index 0000000..ad8a5fc
--- /dev/null
@@ -0,0 +1,37 @@
+#! /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 }
+
+  context "macosx" do
+    it "should return launchd" do
+      provider = Puppet::Type.type(:service).provider(:launchd)
+      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+
+      expect(Facter.fact(:service_provider).value).to eq('launchd')
+    end
+  end
+
+  context "systemd" do
+    it "should return systemd" do
+      provider = Puppet::Type.type(:service).provider(:systemd)
+      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+
+      expect(Facter.fact(:service_provider).value).to eq('systemd')
+    end
+  end
+
+  context "redhat" do
+    it "should return redhat" do
+      provider = Puppet::Type.type(:service).provider(:redhat)
+      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+
+      expect(Facter.fact(:service_provider).value).to eq('redhat')
+    end
+  end
+
+end
index c06137d..c278b79 100755 (executable)
@@ -25,6 +25,7 @@ describe Facter::Util::PuppetSettings do
       before :each do
         Puppet.expects(:[]).with(:vardir).returns vardir
       end
+
       it 'should yield to the block' do
         subject.with_puppet { Puppet[:vardir] }
       end
diff --git a/3rdparty/modules/stdlib/spec/unit/puppet/functions/type_of_spec.rb b/3rdparty/modules/stdlib/spec/unit/puppet/functions/type_of_spec.rb
deleted file mode 100644 (file)
index 8afb624..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-
-require 'spec_helper'
-
-if ENV["FUTURE_PARSER"] == 'yes' or Puppet.version >= "4"
-  require 'puppet/pops'
-  require 'puppet/loaders'
-
-  describe 'the type_of function' do
-    before(:all) do
-      loaders = Puppet::Pops::Loaders.new(Puppet::Node::Environment.create(:testing, [File.join(fixtures, "modules")]))
-      Puppet.push_context({:loaders => loaders}, "test-examples")
-    end
-
-    after(:all) do
-      Puppet::Pops::Loaders.clear
-      Puppet::pop_context()
-    end
-
-    let(:func) do
-      # Load the function from the environment modulepath's modules (ie, fixtures)
-      Puppet.lookup(:loaders).private_environment_loader.load(:function, 'type_of')
-    end
-
-    it 'gives the type of a string' do
-      expect(func.call({}, 'hello world')).to be_kind_of(Puppet::Pops::Types::PStringType)
-    end
-
-    it 'gives the type of an integer' do
-      expect(func.call({}, 5)).to be_kind_of(Puppet::Pops::Types::PIntegerType)
-    end
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/basename_spec.rb b/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/basename_spec.rb
deleted file mode 100755 (executable)
index 8a2d0dc..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'spec_helper'
-
-describe "the basename function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    Puppet::Parser::Functions.function("basename").should == "function_basename"
-  end
-
-  it "should raise a ParseError if there is less than 1 argument" do
-    lambda { scope.function_basename([]) }.should( raise_error(Puppet::ParseError))
-  end
-
-  it "should raise a ParseError if there are more than 2 arguments" do
-    lambda { scope.function_basename(['a', 'b', 'c']) }.should( raise_error(Puppet::ParseError))
-  end
-
-  it "should return basename for an absolute path" do
-    result = scope.function_basename(['/path/to/a/file.ext'])
-    result.should(eq('file.ext'))
-  end
-
-  it "should return basename for a relative path" do
-    result = scope.function_basename(['path/to/a/file.ext'])
-    result.should(eq('file.ext'))
-  end
-
-  it "should strip extention when extension specified (absolute path)" do
-    result = scope.function_basename(['/path/to/a/file.ext', '.ext'])
-    result.should(eq('file'))
-  end
-
-  it "should strip extention when extension specified (relative path)" do
-    result = scope.function_basename(['path/to/a/file.ext', '.ext'])
-    result.should(eq('file'))
-  end
-
-  it "should complain about non-string first argument" do
-    lambda { scope.function_basename([[]]) }.should( raise_error(Puppet::ParseError))
-  end
-
-  it "should complain about non-string second argument" do
-    lambda { scope.function_basename(['/path/to/a/file.ext', []]) }.should( raise_error(Puppet::ParseError))
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/bool2str_spec.rb b/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/bool2str_spec.rb
deleted file mode 100755 (executable)
index b878891..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'spec_helper'
-
-describe "the bool2str function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("bool2str")).to eq("function_bool2str")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_bool2str([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should convert true to 'true'" do
-    result = scope.function_bool2str([true])
-    expect(result).to(eq('true'))
-  end
-
-  it "should convert true to a string" do
-    result = scope.function_bool2str([true])
-    expect(result.class).to(eq(String))
-  end
-
-  it "should convert false to 'false'" do
-    result = scope.function_bool2str([false])
-    expect(result).to(eq('false'))
-  end
-
-  it "should convert false to a string" do
-    result = scope.function_bool2str([false])
-    expect(result.class).to(eq(String))
-  end
-
-  it "should not accept a string" do
-    expect { scope.function_bool2str(["false"]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should not accept a nil value" do
-    expect { scope.function_bool2str([nil]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should not accept an undef" do
-    expect { scope.function_bool2str([:undef]) }.to( raise_error(Puppet::ParseError))
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/camelcase_spec.rb b/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/camelcase_spec.rb
deleted file mode 100755 (executable)
index 70382ad..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /usr/bin/env ruby -S rspec
-require 'spec_helper'
-
-describe "the camelcase function" do
-  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
-  it "should exist" do
-    expect(Puppet::Parser::Functions.function("camelcase")).to eq("function_camelcase")
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    expect { scope.function_camelcase([]) }.to( raise_error(Puppet::ParseError))
-  end
-
-  it "should capitalize the beginning of a normal string" do
-    result = scope.function_camelcase(["abc"])
-    expect(result).to(eq("Abc"))
-  end
-
-  it "should camelcase an underscore-delimited string" do
-    result = scope.function_camelcase(["aa_bb_cc"])
-    expect(result).to(eq("AaBbCc"))
-  end
-end
diff --git a/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb b/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb
new file mode 100644 (file)
index 0000000..b162127
--- /dev/null
@@ -0,0 +1,69 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+
+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")
+  end
+
+  it "should raise 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) )
+  end
+
+  it "should raise 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) )
+  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
+  end
+
+  it "should not raise a ParseError when given * as ip string" do
+    expect { scope.function_enclose_ipv6(['*']) }.to_not 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
+  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
+  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) )
+  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) )
+  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) )
+  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]']))
+  end
+
+  it "should embrace 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
+    result = scope.function_enclose_ipv6(['127.0.0.1'])
+    expect(result).to(eq(['127.0.0.1']))
+  end
+end
diff --git a/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb b/3rdparty/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb
new file mode 100644 (file)
index 0000000..8931208
--- /dev/null
@@ -0,0 +1,86 @@
+require 'spec_helper'
+
+describe :is_absolute_path do
+  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+
+  let(:function_args) do
+    []
+  end
+
+  let(:function) 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))
+    end
+
+  end
+  
+  it "should exist" do
+    Puppet::Parser::Functions.function(subject).should == "function_#{subject}"
+  end
+
+  # help enforce good function defination
+  it 'should contain arity' do
+
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { function }.should( raise_error(ArgumentError))
+  end
+
+
+  describe 'should retrun true' do
+    let(:return_value) do
+      true
+    end
+
+    describe 'windows' do
+      let(:function_args) do
+        ['c:\temp\test.txt']
+      end
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+
+    describe 'non-windows' do
+      let(:function_args) do
+        ['/temp/test.txt']
+      end
+
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+  end
+
+  describe 'should return false' do
+    let(:return_value) do
+      false
+    end
+    describe 'windows' do
+      let(:function_args) do
+        ['..\temp\test.txt']
+      end
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+
+    describe 'non-windows' do
+      let(:function_args) do
+        ['../var/lib/puppet']
+      end
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+  end
+end
\ No newline at end of file
index a84fc78..dcca4a4 100755 (executable)
@@ -2,7 +2,8 @@
 require 'spec_helper'
 require 'tempfile'
 provider_class = Puppet::Type.type(:file_line).provider(:ruby)
-describe provider_class do
+# 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')
@@ -29,14 +30,65 @@ describe provider_class do
       File.open(tmpfile, 'w') do |fh|
         fh.write('foo1')
       end
-      expect(provider.exists?).to be_nil
+      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
   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")
+    end
+
+    it 'should append the line if no matches are found' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo2")
+      end
+      expect(@provider.exists?).to eql (false)
+      @provider.create
+      expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo2\nfoo = bar")
+    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*=.*$',
+            :replace  => 'asgadga',
+          }
+        )
+      }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./)
+    end
+  end
   context "when matching" do
     before :each do
       # TODO: these should be ported over to use the PuppetLabs spec_helper
@@ -61,7 +113,7 @@ describe provider_class do
         File.open(@tmpfile, 'w') do |fh|
           fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
         end
-        expect(@provider.exists?).to be_nil
+        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
@@ -80,11 +132,30 @@ describe provider_class do
         File.open(@tmpfile, 'w') do |fh|
           fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
         end
-        expect(@provider.exists?).to be_nil
+        expect(@provider.exists?).to eql(false)
         @provider.create
         expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar")
       end
 
+      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")
+      end
+
       it 'should raise an error with invalid values' do
         expect {
           @resource = Puppet::Type::File_line.new(
@@ -103,7 +174,7 @@ describe provider_class do
         File.open(@tmpfile, 'w') do |fh|
           fh.write("foo1\nfoo=blah\nfoo2")
         end
-        expect(@provider.exists?).to be_nil
+        expect(@provider.exists?).to eql(false)
         @provider.create
         expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
       end
@@ -111,7 +182,7 @@ describe provider_class do
         File.open(@tmpfile, 'w') do |fh|
           fh.write("foo1\nfoo2")
         end
-        expect(@provider.exists?).to be_nil
+        expect(@provider.exists?).to eql(false)
         @provider.create
         expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n")
       end
@@ -119,10 +190,28 @@ describe provider_class do
         File.open(@tmpfile, 'w') do |fh|
           fh.write("foo1\nfoo = bar\nfoo2")
         end
-        expect(@provider.exists?).to be_truthy
+        expect(@provider.exists?).to eql(true)
         @provider.create
         expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
       end
+
+      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")
+      end
     end
 
     describe 'using after' do
@@ -201,7 +290,7 @@ describe provider_class do
         end
       end
 
-      context 'with two lines matching the after expression' do
+      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")
@@ -211,6 +300,22 @@ describe provider_class do
         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
       end
 
       context 'with no lines matching the after expression' do
@@ -274,4 +379,107 @@ describe provider_class do
       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(
+        {
+          :name              => 'foo',
+          :path              => @tmpfile,
+          :line              => 'foo2',
+          :ensure            => 'absent',
+          :match             => 'o$',
+          :match_for_absence => true,
+        }
+      )
+      @provider = provider_class.new(@resource)
+    end
+
+    it 'should find a line to match' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2")
+      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")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo2")
+    end
+
+    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")
+      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(
+        {
+          :name              => 'foo',
+          :path              => @tmpfile,
+          :line              => 'foo2',
+          :ensure            => 'absent',
+          :match             => 'o$',
+          :multiple          => true,
+          :match_for_absence => 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")
+    end
+
+    it 'should ignore the match if match_for_absence is not specified' do
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name     => 'foo',
+          :path     => @tmpfile,
+          :line     => 'foo2',
+          :ensure   => 'absent',
+          :match    => 'o$',
+        }
+      )
+      @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")
+    end
+
+    it 'should ignore the match if match_for_absence is false' do
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name              => 'foo',
+          :path              => @tmpfile,
+          :line              => 'foo2',
+          :ensure            => 'absent',
+          :match             => 'o$',
+          :match_for_absence => false,
+        }
+      )
+      @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")
+    end
+
+  end
+
 end
index 410d0bf..150149b 100755 (executable)
@@ -2,14 +2,28 @@
 require 'spec_helper'
 require 'tempfile'
 describe Puppet::Type.type(:file_line) do
+  let :tmp_path do
+    if Puppet::Util::Platform.windows?
+      'C:\tmp\path'
+    else
+      '/tmp/path'
+    end
+  end
+  let :my_path do
+    if Puppet::Util::Platform.windows?
+      'C:\my\path'
+    else
+      '/my/path'
+    end
+  end
   let :file_line do
-    Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path')
+    Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => tmp_path)
   end
   it 'should accept a line and path' do
     file_line[:line] = 'my_line'
     expect(file_line[:line]).to eq('my_line')
-    file_line[:path] = '/my/path'
-    expect(file_line[:path]).to eq('/my/path')
+    file_line[:path] = my_path
+    expect(file_line[:path]).to eq(my_path)
   end
   it 'should accept a match regex' do
     file_line[:match] = '^foo.*$'
@@ -19,7 +33,7 @@ describe Puppet::Type.type(:file_line) do
     expect {
       Puppet::Type.type(:file_line).new(
           :name   => 'foo',
-          :path   => '/my/path',
+          :path   => my_path,
           :line   => 'foo=bar',
           :match  => '^bar=blah$'
     )}.not_to raise_error
@@ -28,36 +42,65 @@ describe Puppet::Type.type(:file_line) do
     expect {
       Puppet::Type.type(:file_line).new(
           :name   => 'foo',
-          :path   => '/my/path',
+          :path   => my_path,
           :line   => 'foo=bar',
           :match  => '^\s*foo=.*$'
       )}.not_to raise_error
   end
+  it 'should accept utf8 characters' do
+    expect {
+      Puppet::Type.type(:file_line).new(
+          :name   => 'ƒồỗ',
+          :path   => my_path,
+          :line   => 'ƒồỗ=ьåя',
+          :match  => '^ьåя=βļάħ$'
+      )}.not_to raise_error
+  end
+  it 'should accept double byte characters' do
+    expect {
+      Puppet::Type.type(:file_line).new(
+          :name   => 'フーバー',
+          :path   => my_path,
+          :line   => 'この=それ',
+          :match  => '^この=ああ$'
+      )}.not_to raise_error
+  end
   it 'should accept posix filenames' do
-    file_line[:path] = '/tmp/path'
-    expect(file_line[:path]).to eq('/tmp/path')
+    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/)
   end
   it 'should require that a line is specified' do
-    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.to raise_error(Puppet::Error, /Both line and path are required attributes/)
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, /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
   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, /Both line and path are required attributes/)
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/)
   end
   it 'should default to ensure => present' do
     expect(file_line[:ensure]).to eq :present
   end
-
+  it 'should default to replace => true' do
+    expect(file_line[:replace]).to eq :true
+  end
+  it 'should default to encoding => UTF-8' do
+    expect(file_line[:encoding]).to eq 'UTF-8'
+  end
+  it 'should accept 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
     catalog = Puppet::Resource::Catalog.new
-    file = Puppet::Type.type(:file).new(:name => "/tmp/path")
+    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}]") and (rel.target.to_s == file_line.to_s)
     end
     expect(relationship).to be_a Puppet::Relationship
   end
diff --git a/3rdparty/modules/stdlib/tests/file_line.pp b/3rdparty/modules/stdlib/tests/file_line.pp
deleted file mode 100644 (file)
index eea693e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# This is a simple smoke test
-# of the file_line resource type.
-file { '/tmp/dansfile':
-  ensure => present
-}->
-file_line { 'dans_line':
-  line => 'dan is awesome',
-  path => '/tmp/dansfile',
-}
diff --git a/3rdparty/modules/stdlib/tests/has_interface_with.pp b/3rdparty/modules/stdlib/tests/has_interface_with.pp
deleted file mode 100644 (file)
index e1f1353..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-include stdlib
-info('has_interface_with(\'lo\'):', has_interface_with('lo'))
-info('has_interface_with(\'loX\'):', has_interface_with('loX'))
-info('has_interface_with(\'ipaddress\', \'127.0.0.1\'):', has_interface_with('ipaddress', '127.0.0.1'))
-info('has_interface_with(\'ipaddress\', \'127.0.0.100\'):', has_interface_with('ipaddress', '127.0.0.100'))
-info('has_interface_with(\'network\', \'127.0.0.0\'):', has_interface_with('network', '127.0.0.0'))
-info('has_interface_with(\'network\', \'128.0.0.0\'):', has_interface_with('network', '128.0.0.0'))
-info('has_interface_with(\'netmask\', \'255.0.0.0\'):', has_interface_with('netmask', '255.0.0.0'))
-info('has_interface_with(\'netmask\', \'256.0.0.0\'):', has_interface_with('netmask', '256.0.0.0'))
-
diff --git a/3rdparty/modules/stdlib/tests/has_ip_address.pp b/3rdparty/modules/stdlib/tests/has_ip_address.pp
deleted file mode 100644 (file)
index 8429a88..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-include stdlib
-info('has_ip_address(\'192.168.1.256\'):', has_ip_address('192.168.1.256'))
-info('has_ip_address(\'127.0.0.1\'):', has_ip_address('127.0.0.1'))
diff --git a/3rdparty/modules/stdlib/tests/has_ip_network.pp b/3rdparty/modules/stdlib/tests/has_ip_network.pp
deleted file mode 100644 (file)
index a15d8c0..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-include stdlib
-info('has_ip_network(\'127.0.0.0\'):', has_ip_network('127.0.0.0'))
-info('has_ip_network(\'128.0.0.0\'):', has_ip_network('128.0.0.0'))
-
diff --git a/3rdparty/modules/stdlib/tests/init.pp b/3rdparty/modules/stdlib/tests/init.pp
deleted file mode 100644 (file)
index 9675d83..0000000
+++ /dev/null
@@ -1 +0,0 @@
-include stdlib
diff --git a/3rdparty/modules/stdlib/types/absolutepath.pp b/3rdparty/modules/stdlib/types/absolutepath.pp
new file mode 100644 (file)
index 0000000..70ec916
--- /dev/null
@@ -0,0 +1,2 @@
+# A strict absolutepath type
+type Stdlib::Absolutepath = Variant[Stdlib::Windowspath, Stdlib::Unixpath]
diff --git a/3rdparty/modules/stdlib/types/compat/absolute_path.pp b/3rdparty/modules/stdlib/types/compat/absolute_path.pp
new file mode 100644 (file)
index 0000000..d11784e
--- /dev/null
@@ -0,0 +1,7 @@
+# Emulate the is_absolute_path and validate_absolute_path functions
+#
+# The first pattern is originally from is_absolute_path, which had it from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path?
+# 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[/^\//]]
diff --git a/3rdparty/modules/stdlib/types/compat/array.pp b/3rdparty/modules/stdlib/types/compat/array.pp
new file mode 100644 (file)
index 0000000..ba65dc4
--- /dev/null
@@ -0,0 +1,2 @@
+# Emulate the is_array and validate_array functions
+type Stdlib::Compat::Array = Array[Any]
diff --git a/3rdparty/modules/stdlib/types/compat/bool.pp b/3rdparty/modules/stdlib/types/compat/bool.pp
new file mode 100644 (file)
index 0000000..5d8e27e
--- /dev/null
@@ -0,0 +1,2 @@
+# Emulate the is_bool and validate_bool functions
+type Stdlib::Compat::Bool = Boolean
diff --git a/3rdparty/modules/stdlib/types/compat/float.pp b/3rdparty/modules/stdlib/types/compat/float.pp
new file mode 100644 (file)
index 0000000..7f98bd2
--- /dev/null
@@ -0,0 +1,19 @@
+# Emulate the is_float function
+# The regex is what's currently used in is_float
+# To keep your development moving forward, you can also add a deprecation warning using the Integer type:
+#
+# ```class example($value) { validate_float($value,) }```
+#
+# would turn into
+#
+# ```
+# class example(Stdlib::Compat::Float $value) {
+#   validate_float($value, 10, 0)
+#   assert_type(Integer[0, 10], $value) |$expected, $actual| {
+#     warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
+#   }
+# }
+# ```
+#
+# This allows you to find all places where a consumers of your code call it with unexpected values.
+type Stdlib::Compat::Float = Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]]
diff --git a/3rdparty/modules/stdlib/types/compat/hash.pp b/3rdparty/modules/stdlib/types/compat/hash.pp
new file mode 100644 (file)
index 0000000..e84a10b
--- /dev/null
@@ -0,0 +1,2 @@
+# Emulate the is_hash and validate_hash functions
+type Stdlib::Compat::Hash = Hash[Any, Any]
diff --git a/3rdparty/modules/stdlib/types/compat/integer.pp b/3rdparty/modules/stdlib/types/compat/integer.pp
new file mode 100644 (file)
index 0000000..e5cadb6
--- /dev/null
@@ -0,0 +1,23 @@
+# Emulate the is_integer and validate_integer functions
+# The regex is what's currently used in is_integer
+# validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function.
+# For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything.
+# To keep your development moving forward, you can also add a deprecation warning using the Integer type:
+#
+# ```class example($value) { validate_integer($value, 10, 0) }```
+#
+# would turn into
+#
+# ```
+# class example(Stdlib::Compat::Integer $value) {
+#   validate_numeric($value, 10, 0)
+#   assert_type(Integer[0, 10], $value) |$expected, $actual| {
+#     warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
+#   }
+# }
+# ```
+#
+# > 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)$/]]]]
diff --git a/3rdparty/modules/stdlib/types/compat/ip_address.pp b/3rdparty/modules/stdlib/types/compat/ip_address.pp
new file mode 100644 (file)
index 0000000..bf4c4b4
--- /dev/null
@@ -0,0 +1 @@
+type Stdlib::Compat::Ip_address = Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6]
diff --git a/3rdparty/modules/stdlib/types/compat/ipv4.pp b/3rdparty/modules/stdlib/types/compat/ipv4.pp
new file mode 100644 (file)
index 0000000..a0ba0d6
--- /dev/null
@@ -0,0 +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]+))?$/]
diff --git a/3rdparty/modules/stdlib/types/compat/ipv6.pp b/3rdparty/modules/stdlib/types/compat/ipv6.pp
new file mode 100644 (file)
index 0000000..8b82f1a
--- /dev/null
@@ -0,0 +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*$/]
diff --git a/3rdparty/modules/stdlib/types/compat/numeric.pp b/3rdparty/modules/stdlib/types/compat/numeric.pp
new file mode 100644 (file)
index 0000000..5bfc3d3
--- /dev/null
@@ -0,0 +1,23 @@
+# Emulate the is_numeric and validate_numeric functions
+# The regex is what's currently used in is_numeric
+# validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function.
+# For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything.
+# To keep your development moving forward, you can also add a deprecation warning using the Integer type:
+#
+# ```class example($value) { validate_numeric($value, 10, 0) }```
+#
+# would turn into
+#
+# ```
+# class example(Stdlib::Compat::Numeric $value) {
+#   validate_numeric($value, 10, 0)
+#   assert_type(Integer[0, 10], $value) |$expected, $actual| {
+#     warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
+#   }
+# }
+# ```
+#
+# > 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+)?$/]]]]
diff --git a/3rdparty/modules/stdlib/types/compat/re.pp b/3rdparty/modules/stdlib/types/compat/re.pp
new file mode 100644 (file)
index 0000000..e4b5f30
--- /dev/null
@@ -0,0 +1,3 @@
+# Emulate the validate_re function
+# validate_re(value, re) translates to Pattern[re], which is not directly mappable as a type alias, but can be specified as Pattern[re].
+# Therefore this needs to be translated directly.
diff --git a/3rdparty/modules/stdlib/types/compat/string.pp b/3rdparty/modules/stdlib/types/compat/string.pp
new file mode 100644 (file)
index 0000000..b06255d
--- /dev/null
@@ -0,0 +1,2 @@
+# Emulate the is_string and validate_string functions
+type Stdlib::Compat::String = Optional[String]
diff --git a/3rdparty/modules/stdlib/types/httpsurl.pp b/3rdparty/modules/stdlib/types/httpsurl.pp
new file mode 100644 (file)
index 0000000..36fd30f
--- /dev/null
@@ -0,0 +1 @@
+type Stdlib::HTTPSUrl = Pattern[/^https:\/\//]
diff --git a/3rdparty/modules/stdlib/types/httpurl.pp b/3rdparty/modules/stdlib/types/httpurl.pp
new file mode 100644 (file)
index 0000000..0d93a95
--- /dev/null
@@ -0,0 +1 @@
+type Stdlib::HTTPUrl = Pattern[/^https?:\/\//]
diff --git a/3rdparty/modules/stdlib/types/mac.pp b/3rdparty/modules/stdlib/types/mac.pp
new file mode 100644 (file)
index 0000000..4103574
--- /dev/null
@@ -0,0 +1,2 @@
+# A type for a MAC address
+type Stdlib::MAC = Pattern[/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/]
diff --git a/3rdparty/modules/stdlib/types/unixpath.pp b/3rdparty/modules/stdlib/types/unixpath.pp
new file mode 100644 (file)
index 0000000..ec3bf7d
--- /dev/null
@@ -0,0 +1,2 @@
+# this regex rejects any path component that is a / or a NUL
+type Stdlib::Unixpath = Pattern[/^\/([^\/\0]+\/*)+$/]
diff --git a/3rdparty/modules/stdlib/types/windowspath.pp b/3rdparty/modules/stdlib/types/windowspath.pp
new file mode 100644 (file)
index 0000000..bc1ee9c
--- /dev/null
@@ -0,0 +1 @@
+type Stdlib::Windowspath = Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/]