puppet 5.3.7-x64-mingw32 → 5.4.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +42 -29
- data/README.md +8 -6
- data/ext/cert_inspector +2 -2
- data/ext/envpuppet +1 -1
- data/ext/gentoo/init.d/puppetmaster +4 -4
- data/ext/ips/puppet-agent +11 -11
- data/ext/ips/puppet-master +11 -11
- data/ext/puppet-test +1 -2
- data/ext/redhat/client.init +2 -2
- data/ext/redhat/logrotate +1 -1
- data/ext/solaris/smf/puppet +11 -11
- data/ext/solaris/smf/svc-puppetd +5 -5
- data/ext/solaris/smf/svc-puppetmasterd +5 -5
- data/ext/windows/service/daemon.rb +1 -1
- data/install.rb +2 -3
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application/cert.rb +1 -3
- data/lib/puppet/application/describe.rb +0 -1
- data/lib/puppet/application/device.rb +12 -99
- data/lib/puppet/application/filebucket.rb +32 -11
- data/lib/puppet/application/lookup.rb +1 -11
- data/lib/puppet/application/script.rb +261 -0
- data/lib/puppet/configurer.rb +3 -4
- data/lib/puppet/configurer/plugin_handler.rb +26 -9
- data/lib/puppet/context.rb +1 -1
- data/lib/puppet/datatypes.rb +213 -0
- data/lib/puppet/datatypes/error.rb +21 -0
- data/lib/puppet/datatypes/impl/error.rb +40 -0
- data/lib/puppet/defaults.rb +51 -20
- data/lib/puppet/environments.rb +17 -0
- data/lib/puppet/error.rb +17 -0
- data/lib/puppet/etc.rb +2 -2
- data/lib/puppet/external/pson/pure/generator.rb +1 -1
- data/lib/puppet/external/pson/pure/parser.rb +1 -1
- data/lib/puppet/face/config.rb +45 -0
- data/lib/puppet/face/epp.rb +3 -3
- data/lib/puppet/face/help/action.erb +3 -0
- data/lib/puppet/face/module/build.rb +1 -0
- data/lib/puppet/face/module/generate.rb +5 -0
- data/lib/puppet/face/module/install.rb +1 -0
- data/lib/puppet/face/module/search.rb +6 -2
- data/lib/puppet/face/module/uninstall.rb +1 -0
- data/lib/puppet/face/module/upgrade.rb +1 -0
- data/lib/puppet/face/parser.rb +0 -1
- data/lib/puppet/face/plugin.rb +1 -3
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/feature/bolt.rb +3 -0
- data/lib/puppet/file_bucket/dipper.rb +1 -2
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_system/uniquefile.rb +2 -2
- data/lib/puppet/forge.rb +6 -0
- data/lib/puppet/functions.rb +70 -88
- data/lib/puppet/functions/all.rb +6 -2
- data/lib/puppet/functions/annotate.rb +1 -1
- data/lib/puppet/functions/any.rb +7 -3
- data/lib/puppet/functions/contain.rb +6 -0
- data/lib/puppet/functions/convert_to.rb +32 -0
- data/lib/puppet/functions/defined.rb +0 -3
- data/lib/puppet/functions/each.rb +10 -6
- data/lib/puppet/functions/filter.rb +16 -10
- data/lib/puppet/functions/find_file.rb +0 -1
- data/lib/puppet/functions/include.rb +6 -0
- data/lib/puppet/functions/map.rb +12 -9
- data/lib/puppet/functions/module_directory.rb +41 -0
- data/lib/puppet/functions/new.rb +1 -4
- data/lib/puppet/functions/regsubst.rb +1 -1
- data/lib/puppet/functions/require.rb +6 -0
- data/lib/puppet/generate/type.rb +1 -1
- data/lib/puppet/gettext/config.rb +2 -2
- data/lib/puppet/gettext/stubs.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +0 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +6 -2
- data/lib/puppet/indirector/file_server.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +19 -3
- data/lib/puppet/indirector/request.rb +10 -6
- data/lib/puppet/indirector/rest.rb +11 -12
- data/lib/puppet/info_service/class_information_service.rb +1 -1
- data/lib/puppet/interface/action.rb +11 -0
- data/lib/puppet/interface/action_builder.rb +8 -0
- data/lib/puppet/interface/option_manager.rb +1 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/module.rb +6 -2
- data/lib/puppet/module_tool/applications/builder.rb +4 -0
- data/lib/puppet/module_tool/applications/installer.rb +3 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/applications/upgrader.rb +3 -0
- data/lib/puppet/module_tool/installed_modules.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +0 -1
- data/lib/puppet/network/authstore.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
- data/lib/puppet/network/http/connection.rb +1 -9
- data/lib/puppet/network/http/factory.rb +0 -3
- data/lib/puppet/network/http/webrick.rb +1 -0
- data/lib/puppet/network/rights.rb +1 -1
- data/lib/puppet/node.rb +53 -0
- data/lib/puppet/node/environment.rb +1 -1
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parser.rb +1 -0
- data/lib/puppet/parser/abstract_compiler.rb +36 -0
- data/lib/puppet/parser/ast/branch.rb +1 -1
- data/lib/puppet/parser/ast/pops_bridge.rb +8 -52
- data/lib/puppet/parser/compiler.rb +4 -54
- data/lib/puppet/parser/functions.rb +0 -1
- data/lib/puppet/parser/functions/create_resources.rb +6 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
- data/lib/puppet/parser/functions/inline_template.rb +6 -0
- data/lib/puppet/parser/functions/new.rb +47 -32
- data/lib/puppet/parser/functions/realize.rb +6 -0
- data/lib/puppet/parser/functions/return.rb +1 -22
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +1 -1
- data/lib/puppet/parser/functions/sha256.rb +5 -0
- data/lib/puppet/parser/functions/tag.rb +6 -0
- data/lib/puppet/parser/functions/tagged.rb +6 -0
- data/lib/puppet/parser/functions/template.rb +5 -0
- data/lib/puppet/parser/scope.rb +28 -4
- data/lib/puppet/parser/script_compiler.rb +118 -0
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/pops.rb +1 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +38 -4
- data/lib/puppet/pops/evaluator/closure.rb +12 -4
- data/lib/puppet/pops/evaluator/compare_operator.rb +4 -4
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +13 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +38 -10
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +2 -3
- data/lib/puppet/pops/functions/dispatch.rb +6 -5
- data/lib/puppet/pops/functions/function.rb +2 -2
- data/lib/puppet/pops/issues.rb +34 -2
- data/lib/puppet/pops/loader/base_loader.rb +10 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +7 -0
- data/lib/puppet/pops/loader/loader.rb +21 -2
- data/lib/puppet/pops/loader/loader_paths.rb +180 -30
- data/lib/puppet/pops/loader/module_loaders.rb +202 -33
- data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +9 -9
- data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +6 -1
- data/lib/puppet/pops/loader/static_loader.rb +23 -8
- data/lib/puppet/pops/loader/task_instantiator.rb +69 -0
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -0
- data/lib/puppet/pops/loaders.rb +122 -11
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
- data/lib/puppet/pops/lookup/interpolation.rb +1 -1
- data/lib/puppet/pops/lookup/lookup_adapter.rb +0 -1
- data/lib/puppet/pops/model/ast.pp +3 -0
- data/lib/puppet/pops/model/ast.rb +34 -1
- data/lib/puppet/pops/model/factory.rb +30 -3
- data/lib/puppet/pops/model/model_label_provider.rb +1 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -1
- data/lib/puppet/pops/model/tree_dumper.rb +1 -1
- data/lib/puppet/pops/parser/code_merger.rb +2 -2
- data/lib/puppet/pops/parser/egrammar.ra +44 -15
- data/lib/puppet/pops/parser/eparser.rb +1687 -1571
- data/lib/puppet/pops/parser/epp_support.rb +1 -3
- data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +2 -2
- data/lib/puppet/pops/parser/lexer2.rb +4 -4
- data/lib/puppet/pops/parser/lexer_support.rb +2 -2
- data/lib/puppet/pops/parser/locatable.rb +1 -1
- data/lib/puppet/pops/parser/locator.rb +7 -13
- data/lib/puppet/pops/parser/parser_support.rb +3 -3
- data/lib/puppet/pops/parser/slurp_support.rb +0 -3
- data/lib/puppet/pops/pcore.rb +45 -0
- data/lib/puppet/pops/resource/param.rb +1 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +6 -0
- data/lib/puppet/pops/serialization/extension.rb +1 -0
- data/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
- data/lib/puppet/pops/serialization/json_path.rb +2 -1
- data/lib/puppet/pops/serialization/object.rb +3 -4
- data/lib/puppet/pops/serialization/serializer.rb +2 -1
- data/lib/puppet/pops/serialization/to_data_converter.rb +7 -3
- data/lib/puppet/pops/time/timespan.rb +1 -1
- data/lib/puppet/pops/types/iterable.rb +38 -9
- data/lib/puppet/pops/types/p_init_type.rb +1 -1
- data/lib/puppet/pops/types/p_meta_type.rb +4 -0
- data/lib/puppet/pops/types/p_object_type.rb +146 -14
- data/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
- data/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
- data/lib/puppet/pops/types/p_type_set_type.rb +0 -1
- data/lib/puppet/pops/types/p_uri_type.rb +190 -0
- data/lib/puppet/pops/types/puppet_object.rb +15 -1
- data/lib/puppet/pops/types/ruby_generator.rb +46 -54
- data/lib/puppet/pops/types/string_converter.rb +22 -1
- data/lib/puppet/pops/types/type_acceptor.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +13 -4
- data/lib/puppet/pops/types/type_factory.rb +29 -5
- data/lib/puppet/pops/types/type_formatter.rb +67 -4
- data/lib/puppet/pops/types/type_parser.rb +92 -4
- data/lib/puppet/pops/types/type_with_members.rb +43 -0
- data/lib/puppet/pops/types/types.rb +212 -80
- data/lib/puppet/pops/validation/checker4_0.rb +10 -6
- data/lib/puppet/pops/validation/tasks_checker.rb +60 -0
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +6 -1
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +18 -8
- data/lib/puppet/provider/augeas/augeas.rb +3 -4
- data/lib/puppet/provider/exec.rb +0 -2
- data/lib/puppet/provider/group/groupadd.rb +25 -1
- data/lib/puppet/provider/group/windows_adsi.rb +7 -4
- data/lib/puppet/provider/mount.rb +25 -8
- data/lib/puppet/provider/nameservice.rb +9 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/lib/puppet/provider/nameservice/objectadd.rb +13 -24
- data/lib/puppet/provider/nameservice/pw.rb +14 -14
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +2 -2
- data/lib/puppet/provider/package/macports.rb +2 -2
- data/lib/puppet/provider/package/pkg.rb +3 -0
- data/lib/puppet/provider/package/pkgdmg.rb +0 -1
- data/lib/puppet/provider/package/portage.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +23 -8
- data/lib/puppet/provider/package/zypper.rb +2 -2
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/lib/puppet/provider/service/init.rb +1 -0
- data/lib/puppet/provider/service/launchd.rb +6 -7
- data/lib/puppet/provider/service/redhat.rb +3 -2
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +3 -2
- data/lib/puppet/provider/user/openbsd.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +7 -1
- data/lib/puppet/provider/user/useradd.rb +36 -6
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/provider/yumrepo/inifile.rb +2 -4
- data/lib/puppet/provider/zfs/zfs.rb +23 -3
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/reference/configuration.rb +0 -2
- data/lib/puppet/reference/type.rb +0 -1
- data/lib/puppet/resource.rb +1 -2
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/resource/status.rb +0 -1
- data/lib/puppet/resource/type.rb +4 -4
- data/lib/puppet/resource/type_collection.rb +1 -1
- data/lib/puppet/settings/base_setting.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +0 -1
- data/lib/puppet/settings/ini_file.rb +66 -12
- data/lib/puppet/ssl/certificate_authority.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +2 -2
- data/lib/puppet/ssl/certificate_revocation_list.rb +2 -1
- data/lib/puppet/ssl/certificate_signer.rb +11 -0
- data/lib/puppet/ssl/host.rb +2 -2
- data/lib/puppet/syntax_checkers/base64.rb +1 -1
- data/lib/puppet/transaction.rb +37 -14
- data/lib/puppet/transaction/report.rb +3 -1
- data/lib/puppet/type.rb +17 -4
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/exec.rb +5 -4
- data/lib/puppet/type/file.rb +3 -3
- data/lib/puppet/type/file/checksum.rb +7 -1
- data/lib/puppet/type/file/checksum_value.rb +4 -3
- data/lib/puppet/type/group.rb +3 -0
- data/lib/puppet/type/k5login.rb +101 -0
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/mount.rb +6 -2
- data/lib/puppet/type/tidy.rb +6 -4
- data/lib/puppet/type/user.rb +26 -39
- data/lib/puppet/type/yumrepo.rb +9 -0
- data/lib/puppet/type/zfs.rb +4 -0
- data/lib/puppet/util.rb +8 -15
- data/lib/puppet/util/character_encoding.rb +2 -2
- data/lib/puppet/util/checksums.rb +82 -1
- data/lib/puppet/util/errors.rb +0 -2
- data/lib/puppet/util/filetype.rb +2 -2
- data/lib/puppet/util/json_lockfile.rb +1 -1
- data/lib/puppet/util/log.rb +1 -1
- data/lib/puppet/util/log/destinations.rb +10 -1
- data/lib/puppet/util/monkey_patches.rb +1 -1
- data/lib/puppet/util/network_device/cisco/device.rb +5 -5
- data/lib/puppet/util/network_device/config.rb +2 -3
- data/lib/puppet/util/platform.rb +13 -0
- data/lib/puppet/util/plist.rb +4 -4
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
- data/lib/puppet/util/reference.rb +8 -1
- data/lib/puppet/util/windows/adsi.rb +18 -15
- data/lib/puppet/util/windows/principal.rb +6 -7
- data/lib/puppet/util/windows/process.rb +1 -1
- data/lib/puppet/util/windows/registry.rb +2 -2
- data/lib/puppet/util/windows/sid.rb +7 -62
- data/lib/puppet/vendor/deep_merge/README.md +2 -2
- data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +18 -18
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +2 -2
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +5 -5
- data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_pal.rb +874 -0
- data/locales/ja/puppet.po +140 -163
- data/locales/puppet.pot +940 -597
- data/man/man5/puppet.conf.5 +16 -91
- data/man/man8/puppet-agent.8 +2 -6
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +11 -33
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +4 -22
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +2 -11
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/integration/application/lookup_spec.rb +0 -21
- data/spec/integration/parser/compiler_spec.rb +18 -0
- data/spec/integration/parser/script_compiler_spec.rb +113 -0
- data/spec/integration/provider/mount_spec.rb +2 -0
- data/spec/integration/type/file_spec.rb +11 -3
- data/spec/integration/util/windows/adsi_spec.rb +1 -86
- data/spec/integration/util/windows/principal_spec.rb +1 -10
- data/spec/shared_contexts/checksum.rb +4 -1
- data/spec/shared_contexts/digests.rb +46 -1
- data/spec/shared_contexts/types_setup.rb +8 -3
- data/spec/unit/agent_spec.rb +2 -2
- data/spec/unit/application/cert_spec.rb +5 -17
- data/spec/unit/application/device_spec.rb +2 -96
- data/spec/unit/application/filebucket_spec.rb +18 -4
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -32
- data/spec/unit/configurer_spec.rb +3 -3
- data/spec/unit/datatypes_spec.rb +304 -0
- data/spec/unit/defaults_spec.rb +41 -20
- data/spec/unit/face/config_spec.rb +46 -1
- data/spec/unit/face/epp_face_spec.rb +7 -3
- data/spec/unit/face/module/search_spec.rb +11 -0
- data/spec/unit/face/parser_spec.rb +2 -2
- data/spec/unit/file_bucket/dipper_spec.rb +12 -1
- data/spec/unit/forge/module_release_spec.rb +70 -0
- data/spec/unit/functions/break_spec.rb +34 -2
- data/spec/unit/functions/contain_spec.rb +1 -0
- data/spec/unit/functions/convert_to_spec.rb +22 -0
- data/spec/unit/functions/epp_spec.rb +5 -0
- data/spec/unit/functions/include_spec.rb +15 -0
- data/spec/unit/functions/module_directory_spec.rb +43 -0
- data/spec/unit/functions/new_spec.rb +14 -14
- data/spec/unit/functions/require_spec.rb +2 -0
- data/spec/unit/functions/shared.rb +12 -0
- data/spec/unit/functions/step_spec.rb +1 -1
- data/spec/unit/functions4_spec.rb +49 -4
- data/spec/unit/indirector/catalog/compiler_spec.rb +3 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +148 -94
- data/spec/unit/indirector/node/ldap_spec.rb +15 -12
- data/spec/unit/indirector/rest_spec.rb +0 -43
- data/spec/unit/interface/action_spec.rb +33 -0
- data/spec/unit/module_tool/applications/builder_spec.rb +7 -0
- data/spec/unit/module_tool/applications/installer_spec.rb +8 -0
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +8 -0
- data/spec/unit/module_tool/applications/upgrader_spec.rb +6 -0
- data/spec/unit/network/http/connection_spec.rb +1 -1
- data/spec/unit/network/http/factory_spec.rb +28 -35
- data/spec/unit/parser/compiler_spec.rb +0 -8
- data/spec/unit/parser/environment_compiler_spec.rb +36 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +9 -0
- data/spec/unit/parser/functions/inline_template_spec.rb +7 -0
- data/spec/unit/parser/functions/realize_spec.rb +9 -0
- data/spec/unit/parser/functions/tag_spec.rb +7 -0
- data/spec/unit/parser/functions/tagged_spec.rb +25 -0
- data/spec/unit/parser/functions/template_spec.rb +8 -0
- data/spec/unit/parser/scope_spec.rb +19 -0
- data/spec/unit/pops/evaluator/conditionals_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_spec.rb +516 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +11 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +43 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +15 -7
- data/spec/unit/pops/model/model_spec.rb +5 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +15 -0
- data/spec/unit/pops/parser/locator_spec.rb +20 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +33 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +28 -0
- data/spec/unit/pops/parser/parse_conditionals_spec.rb +12 -0
- data/spec/unit/pops/parser/parse_plan_spec.rb +48 -0
- data/spec/unit/pops/serialization/packer_spec.rb +8 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +30 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +31 -0
- data/spec/unit/pops/types/error_spec.rb +207 -0
- data/spec/unit/pops/types/p_init_type_spec.rb +98 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +275 -10
- data/spec/unit/pops/types/p_uri_type_spec.rb +191 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +82 -44
- data/spec/unit/pops/types/task_spec.rb +353 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +76 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +31 -13
- data/spec/unit/pops/types/type_parser_spec.rb +13 -1
- data/spec/unit/pops/types/types_spec.rb +60 -0
- data/spec/unit/pops/validator/validator_spec.rb +76 -0
- data/spec/unit/provider/group/groupadd_spec.rb +77 -1
- data/spec/unit/provider/group/pw_spec.rb +4 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +22 -79
- data/spec/unit/provider/mount_spec.rb +18 -5
- data/spec/unit/provider/nameservice_spec.rb +5 -5
- data/spec/unit/provider/package/dnf_spec.rb +2 -2
- data/spec/unit/provider/package/gem_spec.rb +1 -1
- data/spec/unit/provider/package/pkg_spec.rb +3 -0
- data/spec/unit/provider/package/yum_spec.rb +40 -0
- data/spec/unit/provider/service/launchd_spec.rb +2 -1
- data/spec/unit/provider/service/redhat_spec.rb +5 -0
- data/spec/unit/provider/service/systemd_spec.rb +1 -1
- data/spec/unit/provider/user/hpux_spec.rb +2 -2
- data/spec/unit/provider/user/openbsd_spec.rb +2 -2
- data/spec/unit/provider/user/pw_spec.rb +14 -14
- data/spec/unit/provider/user/user_role_add_spec.rb +19 -2
- data/spec/unit/provider/user/useradd_spec.rb +188 -22
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/provider/zfs/zfs_spec.rb +55 -1
- data/spec/unit/provider_spec.rb +48 -0
- data/spec/unit/puppet_pal_2pec.rb +1005 -0
- data/spec/unit/puppet_pal_spec.rb +11 -0
- data/spec/unit/settings/ini_file_spec.rb +313 -2
- data/spec/unit/ssl/certificate_request_spec.rb +42 -1
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +2 -1
- data/spec/unit/transaction/report_spec.rb +1 -0
- data/spec/unit/transaction_spec.rb +112 -21
- data/spec/unit/type/file/checksum_spec.rb +20 -0
- data/spec/unit/type/file_spec.rb +8 -0
- data/spec/unit/type/group_spec.rb +8 -0
- data/spec/unit/type/k5login_spec.rb +22 -1
- data/spec/unit/type/scheduled_task_spec.rb +15 -0
- data/spec/unit/type/user_spec.rb +11 -1
- data/spec/unit/type/yumrepo_spec.rb +5 -0
- data/spec/unit/util/checksums_spec.rb +3 -3
- data/spec/unit/util/log/destinations_spec.rb +14 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/plist_spec.rb +3 -3
- data/spec/unit/util/windows/adsi_spec.rb +27 -31
- data/spec/unit/util/windows/sid_spec.rb +15 -86
- data/spec/unit/util_spec.rb +17 -3
- data/tasks/manpages.rake +1 -1
- metadata +220 -182
- data/lib/puppet/bindings.rb +0 -148
- data/lib/puppet/configurer/downloader_factory.rb +0 -44
- data/spec/unit/configurer/downloader_factory_spec.rb +0 -129
@@ -188,17 +188,21 @@ module Serialization
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def unknown_key_to_string_with_warning(value)
|
191
|
-
str = value
|
191
|
+
str = unknown_to_string(value)
|
192
192
|
serialization_issue(Issues::SERIALIZATION_UNKNOWN_KEY_CONVERTED_TO_STRING, :path => path_to_s, :klass => value.class, :value => str)
|
193
193
|
str
|
194
194
|
end
|
195
195
|
|
196
196
|
def unknown_to_string_with_warning(value)
|
197
|
-
str = value
|
197
|
+
str = unknown_to_string(value)
|
198
198
|
serialization_issue(Issues::SERIALIZATION_UNKNOWN_CONVERTED_TO_STRING, :path => path_to_s, :klass => value.class, :value => str)
|
199
199
|
str
|
200
200
|
end
|
201
201
|
|
202
|
+
def unknown_to_string(value)
|
203
|
+
value.is_a?(Regexp) ? Puppet::Pops::Types::PRegexpType.regexp_to_s_with_delimiters(value) : value.to_s
|
204
|
+
end
|
205
|
+
|
202
206
|
def non_string_keyed_hash_to_data(hash)
|
203
207
|
if @rich_data
|
204
208
|
to_key_extended_hash(hash)
|
@@ -252,7 +256,7 @@ module Serialization
|
|
252
256
|
end
|
253
257
|
else
|
254
258
|
process(value) do
|
255
|
-
(names,
|
259
|
+
(names, _, required_count) = pcore_type.parameter_info(value.class)
|
256
260
|
args = names.map { |name| value.send(name) }
|
257
261
|
|
258
262
|
# Pop optional arguments that are default
|
@@ -259,7 +259,7 @@ module Time
|
|
259
259
|
add_unless_zero(result, KEY_NANOSECONDS, n % 1000)
|
260
260
|
n /= 1000
|
261
261
|
add_unless_zero(result, KEY_MICROSECONDS, n % 1000)
|
262
|
-
add_unless_zero(result, KEY_MILLISECONDS, n
|
262
|
+
add_unless_zero(result, KEY_MILLISECONDS, n / 1000)
|
263
263
|
end
|
264
264
|
result[KEY_NEGATIVE] = true if negative?
|
265
265
|
end
|
@@ -1,4 +1,12 @@
|
|
1
1
|
module Puppet::Pops::Types
|
2
|
+
|
3
|
+
# Implemented by classes that can produce an iterator to iterate over their contents
|
4
|
+
module IteratorProducer
|
5
|
+
def iterator
|
6
|
+
raise ArgumentError, 'iterator() is not implemented'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
2
10
|
# The runtime Iterable type for an Iterable
|
3
11
|
module Iterable
|
4
12
|
# Produces an `Iterable` for one of the following types with the following characterstics:
|
@@ -25,7 +33,7 @@ module Puppet::Pops::Types
|
|
25
33
|
iter
|
26
34
|
end
|
27
35
|
|
28
|
-
# Produces an `Iterable` for one of the following types with the following
|
36
|
+
# Produces an `Iterable` for one of the following types with the following characteristics:
|
29
37
|
#
|
30
38
|
# `String` - yields each character in the string
|
31
39
|
# `Array` - yields each element in the array
|
@@ -40,11 +48,14 @@ module Puppet::Pops::Types
|
|
40
48
|
# The value `nil` is returned for all other objects.
|
41
49
|
#
|
42
50
|
# @param o [Object] The object to produce an `Iterable` for
|
51
|
+
# @param element_type [PAnyType] the element type for the iterator. Optional (inferred if not provided)
|
43
52
|
# @return [Iterable,nil] The produced `Iterable` or `nil` if it couldn't be produced
|
44
53
|
#
|
45
54
|
# @api public
|
46
|
-
def self.on(o)
|
55
|
+
def self.on(o, element_type = nil)
|
47
56
|
case o
|
57
|
+
when IteratorProducer
|
58
|
+
o.iterator
|
48
59
|
when Iterable
|
49
60
|
o
|
50
61
|
when String
|
@@ -53,18 +64,24 @@ module Puppet::Pops::Types
|
|
53
64
|
if o.empty?
|
54
65
|
Iterator.new(PUnitType::DEFAULT, o.each)
|
55
66
|
else
|
56
|
-
|
57
|
-
|
67
|
+
if element_type.nil?
|
68
|
+
tc = TypeCalculator.singleton
|
69
|
+
element_type = PVariantType.maybe_create(o.map {|e| tc.infer_set(e) })
|
70
|
+
end
|
71
|
+
Iterator.new(element_type, o.each)
|
58
72
|
end
|
59
73
|
when Hash
|
60
74
|
# Each element is a two element [key, value] tuple.
|
61
75
|
if o.empty?
|
62
|
-
|
76
|
+
HashIterator.new(PHashType::DEFAULT_KEY_PAIR_TUPLE, o.each)
|
63
77
|
else
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
78
|
+
if element_type.nil?
|
79
|
+
tc = TypeCalculator.singleton
|
80
|
+
element_type = PTupleType.new([
|
81
|
+
PVariantType.maybe_create(o.keys.map {|e| tc.infer_set(e) }),
|
82
|
+
PVariantType.maybe_create(o.values.map {|e| tc.infer_set(e) })], PHashType::KEY_PAIR_TUPLE_SIZE)
|
83
|
+
end
|
84
|
+
HashIterator.new(element_type, o.each_pair)
|
68
85
|
end
|
69
86
|
when Integer
|
70
87
|
if o == 0
|
@@ -148,6 +165,10 @@ module Puppet::Pops::Types
|
|
148
165
|
super
|
149
166
|
end
|
150
167
|
|
168
|
+
def hash_style?
|
169
|
+
false
|
170
|
+
end
|
171
|
+
|
151
172
|
def unbounded?
|
152
173
|
true
|
153
174
|
end
|
@@ -220,6 +241,14 @@ module Puppet::Pops::Types
|
|
220
241
|
end
|
221
242
|
end
|
222
243
|
|
244
|
+
# Special iterator used when iterating over hashes. Returns `true` for `#hash_style?` so that
|
245
|
+
# it is possible to differentiate between two element arrays and key => value associations
|
246
|
+
class HashIterator < Iterator
|
247
|
+
def hash_style?
|
248
|
+
true
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
223
252
|
# @api private
|
224
253
|
class StepIterator < Iterator
|
225
254
|
include Enumerable
|
@@ -156,7 +156,7 @@ class PInitType < PTypeWithContainedType
|
|
156
156
|
rescue ArgumentError
|
157
157
|
raise ArgumentError, _("Creation of new instance of type '%{type_name}' is not supported") % { type_name: @type.to_s }
|
158
158
|
end
|
159
|
-
param_tuples = new_func.dispatcher.
|
159
|
+
param_tuples = new_func.dispatcher.signatures.map { |closure| closure.type.param_types }
|
160
160
|
|
161
161
|
# An instance of the contained type is always a match to this type.
|
162
162
|
single_types = [@type]
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'ruby_generator'
|
2
|
+
require_relative 'type_with_members'
|
2
3
|
|
3
4
|
module Puppet::Pops
|
4
5
|
module Types
|
@@ -13,9 +14,11 @@ KEY_FUNCTIONS = 'functions'.freeze
|
|
13
14
|
KEY_KIND = 'kind'.freeze
|
14
15
|
KEY_OVERRIDE = 'override'.freeze
|
15
16
|
KEY_PARENT = 'parent'.freeze
|
17
|
+
KEY_TYPE_PARAMETERS = 'type_parameters'.freeze
|
16
18
|
|
17
19
|
# @api public
|
18
20
|
class PObjectType < PMetaType
|
21
|
+
include TypeWithMembers
|
19
22
|
|
20
23
|
ATTRIBUTE_KIND_CONSTANT = 'constant'.freeze
|
21
24
|
ATTRIBUTE_KIND_DERIVED = 'derived'.freeze
|
@@ -34,8 +37,14 @@ class PObjectType < PMetaType
|
|
34
37
|
TypeFactory.optional(KEY_ANNOTATIONS) => TYPE_ANNOTATIONS
|
35
38
|
})
|
36
39
|
|
40
|
+
TYPE_PARAMETER = TypeFactory.struct({
|
41
|
+
KEY_TYPE => PTypeType::DEFAULT,
|
42
|
+
TypeFactory.optional(KEY_ANNOTATIONS) => TYPE_ANNOTATIONS
|
43
|
+
})
|
44
|
+
|
37
45
|
TYPE_CONSTANTS = TypeFactory.hash_kv(Pcore::TYPE_MEMBER_NAME, PAnyType::DEFAULT)
|
38
46
|
TYPE_ATTRIBUTES = TypeFactory.hash_kv(Pcore::TYPE_MEMBER_NAME, TypeFactory.not_undef)
|
47
|
+
TYPE_PARAMETERS = TypeFactory.hash_kv(Pcore::TYPE_MEMBER_NAME, TypeFactory.not_undef)
|
39
48
|
TYPE_ATTRIBUTE_CALLABLE = TypeFactory.callable(0,0)
|
40
49
|
|
41
50
|
TYPE_FUNCTION_TYPE = PTypeType.new(PCallableType::DEFAULT)
|
@@ -46,7 +55,7 @@ class PObjectType < PMetaType
|
|
46
55
|
TypeFactory.optional(KEY_OVERRIDE) => PBooleanType::DEFAULT,
|
47
56
|
TypeFactory.optional(KEY_ANNOTATIONS) => TYPE_ANNOTATIONS
|
48
57
|
})
|
49
|
-
TYPE_FUNCTIONS = TypeFactory.hash_kv(Pcore::TYPE_MEMBER_NAME, TypeFactory.not_undef)
|
58
|
+
TYPE_FUNCTIONS = TypeFactory.hash_kv(PVariantType.new([Pcore::TYPE_MEMBER_NAME, PStringType.new('[]')]), TypeFactory.not_undef)
|
50
59
|
|
51
60
|
TYPE_EQUALITY = TypeFactory.variant(Pcore::TYPE_MEMBER_NAME, TypeFactory.array_of(Pcore::TYPE_MEMBER_NAME))
|
52
61
|
|
@@ -55,6 +64,7 @@ class PObjectType < PMetaType
|
|
55
64
|
TYPE_OBJECT_I12N = TypeFactory.struct({
|
56
65
|
TypeFactory.optional(KEY_NAME) => TYPE_OBJECT_NAME,
|
57
66
|
TypeFactory.optional(KEY_PARENT) => PTypeType::DEFAULT,
|
67
|
+
TypeFactory.optional(KEY_TYPE_PARAMETERS) => TYPE_PARAMETERS,
|
58
68
|
TypeFactory.optional(KEY_ATTRIBUTES) => TYPE_ATTRIBUTES,
|
59
69
|
TypeFactory.optional(KEY_CONSTANTS) => TYPE_CONSTANTS,
|
60
70
|
TypeFactory.optional(KEY_FUNCTIONS) => TYPE_FUNCTIONS,
|
@@ -81,6 +91,7 @@ class PObjectType < PMetaType
|
|
81
91
|
# @api public
|
82
92
|
class PAnnotatedMember
|
83
93
|
include Annotatable
|
94
|
+
include InvocableMember
|
84
95
|
|
85
96
|
# @return [PObjectType] the object type containing this member
|
86
97
|
# @api public
|
@@ -348,6 +359,22 @@ class PObjectType < PMetaType
|
|
348
359
|
end
|
349
360
|
end
|
350
361
|
|
362
|
+
class PTypeParameter < PAttribute
|
363
|
+
# @return [Hash{String=>Object}] the hash
|
364
|
+
# @api private
|
365
|
+
def _pcore_init_hash
|
366
|
+
hash = super
|
367
|
+
hash[KEY_TYPE] = hash[KEY_TYPE].type
|
368
|
+
hash.delete(KEY_VALUE) if hash.include?(KEY_VALUE) && hash[KEY_VALUE].nil?
|
369
|
+
hash
|
370
|
+
end
|
371
|
+
|
372
|
+
# @api private
|
373
|
+
def self.feature_type
|
374
|
+
'type_parameter'
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
351
378
|
# Describes a named Function in an Object type
|
352
379
|
# @api public
|
353
380
|
class PFunction < PAnnotatedMember
|
@@ -372,8 +399,6 @@ class PObjectType < PMetaType
|
|
372
399
|
|
373
400
|
attr_reader :name
|
374
401
|
attr_reader :parent
|
375
|
-
attr_reader :attributes
|
376
|
-
attr_reader :functions
|
377
402
|
attr_reader :equality
|
378
403
|
attr_reader :checks
|
379
404
|
attr_reader :annotations
|
@@ -392,12 +417,15 @@ class PObjectType < PMetaType
|
|
392
417
|
# @overload initialize(init_hash)
|
393
418
|
# Used when the object is created by the {TypeFactory}. The init_hash must be fully resolved.
|
394
419
|
# @param _pcore_init_hash [Hash{String=>Object}] The hash describing the Object features
|
420
|
+
# @param loader [Loaders::Loader,nil] the loader that loaded the type
|
395
421
|
#
|
396
422
|
# @api private
|
397
423
|
def initialize(_pcore_init_hash, init_hash_expression = nil)
|
398
424
|
if _pcore_init_hash.is_a?(Hash)
|
399
425
|
_pcore_init_from_hash(_pcore_init_hash)
|
426
|
+
@loader = init_hash_expression unless init_hash_expression.nil?
|
400
427
|
else
|
428
|
+
@type_parameters = EMPTY_HASH
|
401
429
|
@attributes = EMPTY_HASH
|
402
430
|
@functions = EMPTY_HASH
|
403
431
|
@name = TypeAsserter.assert_instance_of('object name', TYPE_OBJECT_NAME, _pcore_init_hash)
|
@@ -442,7 +470,7 @@ class PObjectType < PMetaType
|
|
442
470
|
# @return [Object] the created instance
|
443
471
|
# @api private
|
444
472
|
def read(value_count, deserializer)
|
445
|
-
reader.read(implementation_class, value_count, deserializer)
|
473
|
+
reader.read(self, implementation_class, value_count, deserializer)
|
446
474
|
end
|
447
475
|
|
448
476
|
# Write an instance of this type using a serializer
|
@@ -456,15 +484,11 @@ class PObjectType < PMetaType
|
|
456
484
|
# @api private
|
457
485
|
def create_new_function
|
458
486
|
impl_class = implementation_class
|
459
|
-
class_name = impl_class.name || "Anonymous Ruby class for #{name}"
|
460
487
|
|
461
488
|
(param_names, param_types, required_param_count) = parameter_info(impl_class)
|
462
489
|
|
463
490
|
# Create the callable with a size that reflects the required and optional parameters
|
464
|
-
param_types
|
465
|
-
param_types << param_names.size
|
466
|
-
|
467
|
-
create_type = TypeFactory.callable(*param_types)
|
491
|
+
create_type = TypeFactory.callable(*param_types, required_param_count, param_names.size)
|
468
492
|
from_hash_type = TypeFactory.callable(init_hash_type, 1, 1)
|
469
493
|
|
470
494
|
# Create and return a #new_XXX function where the dispatchers are added programmatically.
|
@@ -512,6 +536,7 @@ class PObjectType < PMetaType
|
|
512
536
|
if impl_name.nil?
|
513
537
|
# Use generator to create a default implementation
|
514
538
|
@implementation_class = RubyGenerator.new.create_class(self)
|
539
|
+
@implementation_class.class_eval(&@implementation_override) if instance_variable_defined?(:@implementation_override)
|
515
540
|
else
|
516
541
|
# Can the mapping be loaded?
|
517
542
|
class_name = impl_name[0]
|
@@ -532,10 +557,42 @@ class PObjectType < PMetaType
|
|
532
557
|
@implementation_class = cls
|
533
558
|
end
|
534
559
|
|
560
|
+
# The block passed to this method will be passed in a call to `#class_eval` on the dynamically generated
|
561
|
+
# class for this data type. It's indended use is to complement or redefine the generated methods and
|
562
|
+
# attribute readers.
|
563
|
+
#
|
564
|
+
# The method is normally called with the block passed to `#implementation` when a data type is defined using
|
565
|
+
# {Puppet::DataTypes::create_type}.
|
566
|
+
#
|
567
|
+
# @api private
|
568
|
+
def implementation_override=(block)
|
569
|
+
if !@implementation_class.nil? || instance_variable_defined?(:@implementation_override)
|
570
|
+
raise ArgumentError, "attempt to redefine implementation override for #{label}"
|
571
|
+
end
|
572
|
+
@implementation_override = block
|
573
|
+
end
|
574
|
+
|
575
|
+
def extract_init_hash(o)
|
576
|
+
return o._pcore_init_hash if o.respond_to?(:_pcore_init_hash)
|
577
|
+
|
578
|
+
result = {}
|
579
|
+
pic = parameter_info(o.class)
|
580
|
+
attrs = attributes(true)
|
581
|
+
pic[0].each do |name|
|
582
|
+
v = o.send(name)
|
583
|
+
result[name] = v unless attrs[name].default_value?(v)
|
584
|
+
end
|
585
|
+
result
|
586
|
+
end
|
587
|
+
|
535
588
|
# @api private
|
536
589
|
# @return [(Array<String>, Array<PAnyType>, Integer)] array of parameter names, array of parameter types, and a count reflecting the required number of parameters
|
537
590
|
def parameter_info(impl_class)
|
538
591
|
# Create a types and a names array where optional entries ends up last
|
592
|
+
@parameter_info ||= {}
|
593
|
+
pic = @parameter_info[impl_class]
|
594
|
+
return pic if pic
|
595
|
+
|
539
596
|
opt_types = []
|
540
597
|
opt_names = []
|
541
598
|
non_opt_types = []
|
@@ -587,7 +644,9 @@ class PObjectType < PMetaType
|
|
587
644
|
end
|
588
645
|
end
|
589
646
|
|
590
|
-
[param_names, param_types, non_opt_types.size]
|
647
|
+
pic = [param_names.freeze, param_types.freeze, non_opt_types.size].freeze
|
648
|
+
@parameter_info[impl_class] = pic
|
649
|
+
pic
|
591
650
|
end
|
592
651
|
|
593
652
|
# @api private
|
@@ -606,6 +665,7 @@ class PObjectType < PMetaType
|
|
606
665
|
# @api private
|
607
666
|
def _pcore_init_from_hash(init_hash)
|
608
667
|
TypeAsserter.assert_instance_of('object initializer', TYPE_OBJECT_I12N, init_hash)
|
668
|
+
@type_parameters = EMPTY_HASH
|
609
669
|
@attributes = EMPTY_HASH
|
610
670
|
@functions = EMPTY_HASH
|
611
671
|
|
@@ -616,6 +676,7 @@ class PObjectType < PMetaType
|
|
616
676
|
@parent = init_hash[KEY_PARENT]
|
617
677
|
|
618
678
|
parent_members = EMPTY_HASH
|
679
|
+
parent_type_params = EMPTY_HASH
|
619
680
|
parent_object_type = nil
|
620
681
|
unless @parent.nil?
|
621
682
|
check_self_recursion(self)
|
@@ -624,11 +685,35 @@ class PObjectType < PMetaType
|
|
624
685
|
if rp.is_a?(PObjectType)
|
625
686
|
parent_object_type = rp
|
626
687
|
parent_members = rp.members(true)
|
688
|
+
parent_type_params = rp.type_parameters(true)
|
689
|
+
end
|
690
|
+
end
|
691
|
+
|
692
|
+
type_parameters = init_hash[KEY_TYPE_PARAMETERS]
|
693
|
+
unless type_parameters.nil? || type_parameters.empty?
|
694
|
+
@type_parameters = {}
|
695
|
+
type_parameters.each do |key, param_spec|
|
696
|
+
param_value = :undef
|
697
|
+
if param_spec.is_a?(Hash)
|
698
|
+
param_type = param_spec[KEY_TYPE]
|
699
|
+
param_value = param_spec[KEY_VALUE] if param_spec.include?(KEY_VALUE)
|
700
|
+
else
|
701
|
+
param_type = TypeAsserter.assert_instance_of(nil, PTypeType::DEFAULT, param_spec) { "type_parameter #{label}[#{key}]" }
|
702
|
+
end
|
703
|
+
param_type = POptionalType.new(param_type) unless param_type.is_a?(POptionalType)
|
704
|
+
type_param = PTypeParameter.new(key, self, KEY_TYPE => param_type, KEY_VALUE => param_value).assert_override(parent_type_params)
|
705
|
+
@type_parameters[key] = type_param
|
627
706
|
end
|
628
707
|
end
|
629
708
|
|
630
709
|
constants = init_hash[KEY_CONSTANTS]
|
631
|
-
attr_specs = init_hash[KEY_ATTRIBUTES]
|
710
|
+
attr_specs = init_hash[KEY_ATTRIBUTES]
|
711
|
+
if attr_specs.nil?
|
712
|
+
attr_specs = {}
|
713
|
+
else
|
714
|
+
# attr_specs might be frozen
|
715
|
+
attr_specs = Hash[attr_specs]
|
716
|
+
end
|
632
717
|
unless constants.nil? || constants.empty?
|
633
718
|
constants.each do |key, value|
|
634
719
|
if attr_specs.include?(key)
|
@@ -641,7 +726,7 @@ class PObjectType < PMetaType
|
|
641
726
|
KEY_KIND => ATTRIBUTE_KIND_CONSTANT
|
642
727
|
}
|
643
728
|
# Indicate override if parent member exists. Type check etc. will take place later on.
|
644
|
-
attr_spec[KEY_OVERRIDE] =
|
729
|
+
attr_spec[KEY_OVERRIDE] = parent_members.include?(key)
|
645
730
|
attr_specs[key] = attr_spec
|
646
731
|
end
|
647
732
|
end
|
@@ -728,6 +813,7 @@ class PObjectType < PMetaType
|
|
728
813
|
guarded_recursion(guard, nil) do |g|
|
729
814
|
super(visitor, g)
|
730
815
|
@parent.accept(visitor, g) unless parent.nil?
|
816
|
+
@type_parameters.values.each { |p| p.accept(visitor, g) }
|
731
817
|
@attributes.values.each { |a| a.accept(visitor, g) }
|
732
818
|
@functions.values.each { |f| f.accept(visitor, g) }
|
733
819
|
end
|
@@ -784,7 +870,21 @@ class PObjectType < PMetaType
|
|
784
870
|
result = super()
|
785
871
|
result[KEY_NAME] = @name if include_name && !@name.nil?
|
786
872
|
result[KEY_PARENT] = @parent unless @parent.nil?
|
787
|
-
result[
|
873
|
+
result[KEY_TYPE_PARAMETERS] = compressed_members_hash(@type_parameters) unless @type_parameters.empty?
|
874
|
+
unless @attributes.empty?
|
875
|
+
# Divide attributes into constants and others
|
876
|
+
tc = TypeCalculator.singleton
|
877
|
+
constants, others = @attributes.partition do |_, a|
|
878
|
+
a.kind == ATTRIBUTE_KIND_CONSTANT && a.type == tc.infer(a.value).generalize
|
879
|
+
end.map { |ha| Hash[ha] }
|
880
|
+
|
881
|
+
result[KEY_ATTRIBUTES] = compressed_members_hash(others) unless others.empty?
|
882
|
+
unless constants.empty?
|
883
|
+
# { kind => 'constant', type => <type of value>, value => <value> } becomes just <value>
|
884
|
+
constants.each_pair { |key, a| constants[key] = a.value }
|
885
|
+
result[KEY_CONSTANTS] = constants
|
886
|
+
end
|
887
|
+
end
|
788
888
|
result[KEY_FUNCTIONS] = compressed_members_hash(@functions) unless @functions.empty?
|
789
889
|
result[KEY_EQUALITY] = @equality unless @equality.nil?
|
790
890
|
result[KEY_CHECKS] = @checks unless @checks.nil?
|
@@ -795,6 +895,7 @@ class PObjectType < PMetaType
|
|
795
895
|
self.class == o.class &&
|
796
896
|
@name == o.name &&
|
797
897
|
@parent == o.parent &&
|
898
|
+
@type_parameters == o.type_parameters &&
|
798
899
|
@attributes == o.attributes &&
|
799
900
|
@functions == o.functions &&
|
800
901
|
@equality == o.equality &&
|
@@ -802,7 +903,7 @@ class PObjectType < PMetaType
|
|
802
903
|
end
|
803
904
|
|
804
905
|
def hash
|
805
|
-
@name.nil? ? [@parent, @attributes, @functions].hash : @name.hash
|
906
|
+
@name.nil? ? [@parent, @type_parameters, @attributes, @functions].hash : @name.hash
|
806
907
|
end
|
807
908
|
|
808
909
|
def kind_of_callable?(optional=true, guard = nil)
|
@@ -817,6 +918,14 @@ class PObjectType < PMetaType
|
|
817
918
|
@parent.nil? ? false : @parent.iterable_type(guard)
|
818
919
|
end
|
819
920
|
|
921
|
+
def parameterized?
|
922
|
+
if @type_parameters.empty?
|
923
|
+
@parent.is_a?(PObjectType) ? @parent.parameterized? : false
|
924
|
+
else
|
925
|
+
true
|
926
|
+
end
|
927
|
+
end
|
928
|
+
|
820
929
|
# Returns the members (attributes and functions) of this `Object` type. If _include_parent_ is `true`, then all
|
821
930
|
# inherited members will be included in the returned `Hash`.
|
822
931
|
#
|
@@ -891,6 +1000,18 @@ class PObjectType < PMetaType
|
|
891
1000
|
label.split(DOUBLE_COLON).last
|
892
1001
|
end
|
893
1002
|
|
1003
|
+
# Returns the type_parameters of this `Object` type. If _include_parent_ is `true`, then all
|
1004
|
+
# inherited type_parameters will be included in the returned `Hash`.
|
1005
|
+
#
|
1006
|
+
# @param include_parent [Boolean] `true` if inherited type_parameters should be included
|
1007
|
+
# @return [Hash{String=>PTypeParameter}] a hash with the type_parameters
|
1008
|
+
# @api public
|
1009
|
+
def type_parameters(include_parent = false)
|
1010
|
+
all = {}
|
1011
|
+
collect_type_parameters(all, include_parent)
|
1012
|
+
all
|
1013
|
+
end
|
1014
|
+
|
894
1015
|
protected
|
895
1016
|
|
896
1017
|
# An Object type is only assignable from another Object type. The other type
|
@@ -903,6 +1024,8 @@ class PObjectType < PMetaType
|
|
903
1024
|
op = o.parent
|
904
1025
|
op.nil? ? false : assignable?(op, guard)
|
905
1026
|
end
|
1027
|
+
elsif o.is_a?(PObjectTypeExtension)
|
1028
|
+
assignable?(o.base_type, guard)
|
906
1029
|
else
|
907
1030
|
false
|
908
1031
|
end
|
@@ -936,6 +1059,15 @@ class PObjectType < PMetaType
|
|
936
1059
|
nil
|
937
1060
|
end
|
938
1061
|
|
1062
|
+
def collect_type_parameters(collector, include_parent)
|
1063
|
+
if include_parent
|
1064
|
+
parent = resolved_parent
|
1065
|
+
parent.collect_type_parameters(collector, include_parent) if parent.is_a?(PObjectType)
|
1066
|
+
end
|
1067
|
+
collector.merge!(@type_parameters)
|
1068
|
+
nil
|
1069
|
+
end
|
1070
|
+
|
939
1071
|
private
|
940
1072
|
|
941
1073
|
def compressed_members_hash(features)
|