puppet 5.3.7-x86-mingw32 → 5.4.0-x86-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
@@ -0,0 +1,218 @@
|
|
1
|
+
module Puppet::Pops
|
2
|
+
module Types
|
3
|
+
|
4
|
+
# Base class for Parameterized Object implementations. The wrapper impersonates the base
|
5
|
+
# object and extends it with methods to filter assignable types and instances based on parameter
|
6
|
+
# values.
|
7
|
+
#
|
8
|
+
# @api public
|
9
|
+
class PObjectTypeExtension < PAnyType
|
10
|
+
include TypeWithMembers
|
11
|
+
|
12
|
+
def self.register_ptype(loader, ir)
|
13
|
+
create_ptype(loader, ir, 'AnyType',
|
14
|
+
'base_type' => {
|
15
|
+
KEY_TYPE => PTypeType::DEFAULT
|
16
|
+
},
|
17
|
+
'init_parameters' => {
|
18
|
+
KEY_TYPE => PArrayType::DEFAULT
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :base_type, :parameters
|
24
|
+
|
25
|
+
# @api private
|
26
|
+
def self.create(base_type, init_parameters)
|
27
|
+
impl_class = Loaders.implementation_registry.module_for_type("#{base_type.name}TypeExtension") || self
|
28
|
+
impl_class.new(base_type, init_parameters)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Creates an array of type parameters from the attributes of the given instance that matches the
|
32
|
+
# type parameters by name. Type parameters for which there is no matching attribute
|
33
|
+
# will have `nil` in their corresponding position on the array. The array is then passed
|
34
|
+
# as the `init_parameters` argument in a call to `create`
|
35
|
+
#
|
36
|
+
# @return [PObjectTypeExtension] the created extension
|
37
|
+
# @api private
|
38
|
+
def self.create_from_instance(base_type, instance)
|
39
|
+
type_parameters = base_type.type_parameters(true)
|
40
|
+
attrs = base_type.attributes(true)
|
41
|
+
params = type_parameters.keys.map do |pn|
|
42
|
+
attr = attrs[pn]
|
43
|
+
attr.nil? ? nil : instance.send(pn)
|
44
|
+
end
|
45
|
+
create(base_type, params)
|
46
|
+
end
|
47
|
+
|
48
|
+
def [](name)
|
49
|
+
@base_type[name]
|
50
|
+
end
|
51
|
+
|
52
|
+
# @api private
|
53
|
+
def initialize(base_type, init_parameters)
|
54
|
+
pts = base_type.type_parameters(true)
|
55
|
+
raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using []') % { label: base_type.label } if pts.empty?
|
56
|
+
@base_type = base_type
|
57
|
+
|
58
|
+
named_args = init_parameters.size == 1 && init_parameters[0].is_a?(Hash)
|
59
|
+
if named_args
|
60
|
+
# Catch case when first parameter is an assignable Hash
|
61
|
+
named_args = pts.size >= 1 && !pts.values[0].type.instance?(init_parameters[0])
|
62
|
+
end
|
63
|
+
|
64
|
+
by_name = {}
|
65
|
+
if named_args
|
66
|
+
hash = init_parameters[0]
|
67
|
+
hash.each_pair do |pn, pv|
|
68
|
+
tp = pts[pn]
|
69
|
+
if tp.nil?
|
70
|
+
raise Puppet::ParseError, _("'%{pn}' is not a known type parameter for %{label}-Type") % { pn: pn, label: base_type.label }
|
71
|
+
end
|
72
|
+
by_name[pn] = check_param(tp, pv) unless pv == :default
|
73
|
+
end
|
74
|
+
else
|
75
|
+
pts.values.each_with_index do |tp, idx|
|
76
|
+
if idx < init_parameters.size
|
77
|
+
pv = init_parameters[idx]
|
78
|
+
by_name[tp.name] = check_param(tp, pv) unless pv == :default
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
if by_name.empty?
|
83
|
+
raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using an empty parameter list') % { label: base_type.label }
|
84
|
+
end
|
85
|
+
@parameters = by_name
|
86
|
+
end
|
87
|
+
|
88
|
+
def check_param(type_param, v)
|
89
|
+
TypeAsserter.assert_instance_of(nil, type_param.type, v) { type_param.label }
|
90
|
+
end
|
91
|
+
|
92
|
+
# Return the parameter values as positional arguments with unset values as :default. The
|
93
|
+
# array is stripped from trailing :default values
|
94
|
+
# @return [Array] the parameter values
|
95
|
+
# @api private
|
96
|
+
def init_parameters
|
97
|
+
pts = @base_type.type_parameters(true)
|
98
|
+
if pts.size > 2
|
99
|
+
@parameters
|
100
|
+
else
|
101
|
+
result = pts.values.map do |tp|
|
102
|
+
pn = tp.name
|
103
|
+
@parameters.include?(pn) ? @parameters[pn] : :default
|
104
|
+
end
|
105
|
+
# Remove trailing defaults
|
106
|
+
result.pop while result.last == :default
|
107
|
+
result
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# @api private
|
112
|
+
def eql?(o)
|
113
|
+
super(o) && @base_type.eql?(o.base_type) && @parameters.eql?(o.parameters)
|
114
|
+
end
|
115
|
+
|
116
|
+
# @api private
|
117
|
+
def generalize
|
118
|
+
@base_type
|
119
|
+
end
|
120
|
+
|
121
|
+
# @api private
|
122
|
+
def hash
|
123
|
+
@base_type.hash ^ @parameters.hash
|
124
|
+
end
|
125
|
+
|
126
|
+
# @api private
|
127
|
+
def loader
|
128
|
+
@base_type.loader
|
129
|
+
end
|
130
|
+
|
131
|
+
# @api private
|
132
|
+
def check_self_recursion(originator)
|
133
|
+
@base_type.check_self_recursion(originator)
|
134
|
+
end
|
135
|
+
|
136
|
+
# @api private
|
137
|
+
def create(*args)
|
138
|
+
@base_type.create(*args)
|
139
|
+
end
|
140
|
+
|
141
|
+
# @api private
|
142
|
+
def instance?(o, guard = nil)
|
143
|
+
@base_type.instance?(o, guard) && test_instance?(o, guard)
|
144
|
+
end
|
145
|
+
|
146
|
+
# @api private
|
147
|
+
def new_function
|
148
|
+
@base_type.new_function
|
149
|
+
end
|
150
|
+
|
151
|
+
# @api private
|
152
|
+
def simple_name
|
153
|
+
@base_type.simple_name
|
154
|
+
end
|
155
|
+
|
156
|
+
protected
|
157
|
+
|
158
|
+
# Checks that the given `param_values` hash contains all keys present in the `parameters` of
|
159
|
+
# this instance and that each keyed value is a match for the given parameter. The match is done
|
160
|
+
# using case expression semantics.
|
161
|
+
#
|
162
|
+
# This method is only called when a given type is found to be assignable to the base type of
|
163
|
+
# this extension.
|
164
|
+
#
|
165
|
+
# @param param_values[Hash] the parameter values of the assignable type
|
166
|
+
# @param guard[RecursionGuard] guard against endless recursion
|
167
|
+
# @return [Boolean] true or false to indicate assignability
|
168
|
+
# @api public
|
169
|
+
def test_assignable?(param_values, guard)
|
170
|
+
# Default implementation performs case expression style matching of all parameter values
|
171
|
+
# provided that the value exist (this should always be the case, since all defaults have
|
172
|
+
# been assigned at this point)
|
173
|
+
eval = Parser::EvaluatingParser.singleton.evaluator
|
174
|
+
@parameters.keys.all? do |pn|
|
175
|
+
if param_values.include?(pn)
|
176
|
+
a = param_values[pn]
|
177
|
+
b = @parameters[pn]
|
178
|
+
eval.match?(a, b) || a.is_a?(PAnyType) && b.is_a?(PAnyType) && b.assignable?(a)
|
179
|
+
else
|
180
|
+
false
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Checks that the given instance `o` has one attribute for each key present in the `parameters` of
|
186
|
+
# this instance and that each attribute value is a match for the given parameter. The match is done
|
187
|
+
# using case expression semantics.
|
188
|
+
#
|
189
|
+
# This method is only called when the given value is found to be an instance of the base type of
|
190
|
+
# this extension.
|
191
|
+
#
|
192
|
+
# @param o [Object] the instance to test
|
193
|
+
# @param guard[RecursionGuard] guard against endless recursion
|
194
|
+
# @return [Boolean] true or false to indicate if the value is an instance or not
|
195
|
+
# @api public
|
196
|
+
def test_instance?(o, guard)
|
197
|
+
eval = Parser::EvaluatingParser.singleton.evaluator
|
198
|
+
@parameters.keys.all? do |pn|
|
199
|
+
begin
|
200
|
+
m = o.public_method(pn)
|
201
|
+
m.arity == 0 ? eval.match?(m.call, @parameters[pn]) : false
|
202
|
+
rescue NameError
|
203
|
+
false
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# @api private
|
209
|
+
def _assignable?(o, guard = nil)
|
210
|
+
if o.is_a?(PObjectTypeExtension)
|
211
|
+
@base_type.assignable?(o.base_type, guard) && test_assignable?(o.parameters, guard)
|
212
|
+
else
|
213
|
+
@base_type.assignable?(o, guard) && test_assignable?(EMPTY_HASH, guard)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -107,7 +107,6 @@ class PSemVerRangeType < PAnyType
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def self.new_function(type)
|
110
|
-
range_expr = "\\A#{range_pattern}\\Z"
|
111
110
|
@new_function ||= Puppet::Functions.create_loaded_function(:new_VersionRange, type.loader) do
|
112
111
|
local_types do
|
113
112
|
type 'SemVerRangeString = String[1]'
|
@@ -60,14 +60,14 @@ class PSemVerType < PScalarType
|
|
60
60
|
local_types do
|
61
61
|
type 'PositiveInteger = Integer[0,default]'
|
62
62
|
type 'SemVerQualifier = Pattern[/\A(?<part>[0-9A-Za-z-]+)(?:\.\g<part>)*\Z/]'
|
63
|
-
type
|
63
|
+
type "SemVerPattern = Pattern[/\\A#{SemanticPuppet::Version::REGEX_FULL}\\Z/]"
|
64
64
|
type 'SemVerHash = Struct[{major=>PositiveInteger,minor=>PositiveInteger,patch=>PositiveInteger,Optional[prerelease]=>SemVerQualifier,Optional[build]=>SemVerQualifier}]'
|
65
65
|
end
|
66
66
|
|
67
67
|
# Creates a SemVer from a string as specified by http://semver.org/
|
68
68
|
#
|
69
69
|
dispatch :from_string do
|
70
|
-
param '
|
70
|
+
param 'SemVerPattern', :str
|
71
71
|
end
|
72
72
|
|
73
73
|
# Creates a SemVer from integers, prerelease, and build arguments
|
@@ -86,6 +86,10 @@ class PSemVerType < PScalarType
|
|
86
86
|
param 'SemVerHash', :hash_args
|
87
87
|
end
|
88
88
|
|
89
|
+
argument_mismatch :on_error do
|
90
|
+
param 'String', :str
|
91
|
+
end
|
92
|
+
|
89
93
|
def from_string(str)
|
90
94
|
SemanticPuppet::Version.parse(str)
|
91
95
|
end
|
@@ -97,6 +101,10 @@ class PSemVerType < PScalarType
|
|
97
101
|
def from_hash(hash)
|
98
102
|
SemanticPuppet::Version.new(hash['major'], hash['minor'], hash['patch'], hash['prerelease'], hash['build'])
|
99
103
|
end
|
104
|
+
|
105
|
+
def on_error(str)
|
106
|
+
_("The string '%{str}' cannot be converted to a SemVer") % { str: str }
|
107
|
+
end
|
100
108
|
end
|
101
109
|
end
|
102
110
|
|
@@ -0,0 +1,190 @@
|
|
1
|
+
module Puppet::Pops
|
2
|
+
module Types
|
3
|
+
class PURIType < PAnyType
|
4
|
+
|
5
|
+
# Tell evaluator that an members of instances of this type can be invoked using dot notation
|
6
|
+
include TypeWithMembers
|
7
|
+
|
8
|
+
SCHEME = 'scheme'.freeze
|
9
|
+
USERINFO = 'userinfo'.freeze
|
10
|
+
HOST = 'host'.freeze
|
11
|
+
PORT = 'port'.freeze
|
12
|
+
PATH = 'path'.freeze
|
13
|
+
QUERY = 'query'.freeze
|
14
|
+
FRAGMENT = 'fragment'.freeze
|
15
|
+
OPAQUE = 'opaque'.freeze
|
16
|
+
|
17
|
+
URI_MEMBERS = {
|
18
|
+
SCHEME => AttrReader.new(SCHEME),
|
19
|
+
USERINFO => AttrReader.new(USERINFO),
|
20
|
+
HOST => AttrReader.new(HOST),
|
21
|
+
PORT => AttrReader.new(PORT),
|
22
|
+
PATH => AttrReader.new(PATH),
|
23
|
+
QUERY => AttrReader.new(QUERY),
|
24
|
+
FRAGMENT => AttrReader.new(FRAGMENT),
|
25
|
+
OPAQUE => AttrReader.new(OPAQUE),
|
26
|
+
}
|
27
|
+
|
28
|
+
TYPE_URI_INIT_HASH = TypeFactory.struct(
|
29
|
+
TypeFactory.optional(SCHEME) => PStringType::NON_EMPTY,
|
30
|
+
TypeFactory.optional(USERINFO) => PStringType::NON_EMPTY,
|
31
|
+
TypeFactory.optional(HOST) => PStringType::NON_EMPTY,
|
32
|
+
TypeFactory.optional(PORT) => PIntegerType.new(0),
|
33
|
+
TypeFactory.optional(PATH) => PStringType::NON_EMPTY,
|
34
|
+
TypeFactory.optional(QUERY) => PStringType::NON_EMPTY,
|
35
|
+
TypeFactory.optional(FRAGMENT) => PStringType::NON_EMPTY,
|
36
|
+
TypeFactory.optional(OPAQUE) => PStringType::NON_EMPTY,
|
37
|
+
)
|
38
|
+
|
39
|
+
TYPE_STRING_PARAM = TypeFactory.optional(PVariantType.new([
|
40
|
+
PStringType::NON_EMPTY,
|
41
|
+
PRegexpType::DEFAULT,
|
42
|
+
TypeFactory.type_type(PPatternType::DEFAULT),
|
43
|
+
TypeFactory.type_type(PEnumType::DEFAULT),
|
44
|
+
TypeFactory.type_type(PNotUndefType::DEFAULT),
|
45
|
+
TypeFactory.type_type(PUndefType::DEFAULT),
|
46
|
+
]))
|
47
|
+
|
48
|
+
TYPE_INTEGER_PARAM = TypeFactory.optional(PVariantType.new([
|
49
|
+
PIntegerType.new(0),
|
50
|
+
TypeFactory.type_type(PNotUndefType::DEFAULT),
|
51
|
+
TypeFactory.type_type(PUndefType::DEFAULT),
|
52
|
+
]))
|
53
|
+
|
54
|
+
TYPE_URI_PARAM_HASH_TYPE = TypeFactory.struct(
|
55
|
+
TypeFactory.optional(SCHEME) => TYPE_STRING_PARAM,
|
56
|
+
TypeFactory.optional(USERINFO) => TYPE_STRING_PARAM,
|
57
|
+
TypeFactory.optional(HOST) => TYPE_STRING_PARAM,
|
58
|
+
TypeFactory.optional(PORT) => TYPE_INTEGER_PARAM,
|
59
|
+
TypeFactory.optional(PATH) => TYPE_STRING_PARAM,
|
60
|
+
TypeFactory.optional(QUERY) => TYPE_STRING_PARAM,
|
61
|
+
TypeFactory.optional(FRAGMENT) => TYPE_STRING_PARAM,
|
62
|
+
TypeFactory.optional(OPAQUE) => TYPE_STRING_PARAM,
|
63
|
+
)
|
64
|
+
|
65
|
+
TYPE_URI_PARAM_TYPE = PVariantType.new([PStringType::NON_EMPTY, TYPE_URI_PARAM_HASH_TYPE])
|
66
|
+
|
67
|
+
def self.register_ptype(loader, ir)
|
68
|
+
create_ptype(loader, ir, 'AnyType',
|
69
|
+
{
|
70
|
+
'parameters' => { KEY_TYPE => TypeFactory.optional(TYPE_URI_PARAM_TYPE), KEY_VALUE => nil }
|
71
|
+
}
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.new_function(type)
|
76
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_error, type.loader) do
|
77
|
+
dispatch :create do
|
78
|
+
param 'String[1]', :uri
|
79
|
+
end
|
80
|
+
|
81
|
+
dispatch :from_hash do
|
82
|
+
param TYPE_URI_INIT_HASH, :hash
|
83
|
+
end
|
84
|
+
|
85
|
+
def create(uri)
|
86
|
+
URI.parse(uri)
|
87
|
+
end
|
88
|
+
|
89
|
+
def from_hash(init_hash)
|
90
|
+
sym_hash = {}
|
91
|
+
init_hash.each_pair { |k, v| sym_hash[k.to_sym] = v }
|
92
|
+
scheme = sym_hash[:scheme]
|
93
|
+
scheme_class = scheme.nil? ? URI::Generic : (URI.scheme_list[scheme.upcase] || URI::Generic)
|
94
|
+
scheme_class.build(sym_hash)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
attr_reader :parameters
|
100
|
+
|
101
|
+
def initialize(parameters = nil)
|
102
|
+
if parameters.is_a?(String)
|
103
|
+
parameters = TypeAsserter.assert_instance_of('URI-Type parameter', Pcore::TYPE_URI, parameters, true)
|
104
|
+
@parameters = uri_to_hash(URI.parse(parameters))
|
105
|
+
elsif parameters.is_a?(URI)
|
106
|
+
@parameters = uri_to_hash(parameters)
|
107
|
+
elsif parameters.is_a?(Hash)
|
108
|
+
params = TypeAsserter.assert_instance_of('URI-Type parameter', TYPE_URI_PARAM_TYPE, parameters, true)
|
109
|
+
@parameters = params.empty? ? nil : params
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def eql?(o)
|
114
|
+
self.class == o.class && @parameters == o.parameters
|
115
|
+
end
|
116
|
+
|
117
|
+
def ==(o)
|
118
|
+
eql?(o)
|
119
|
+
end
|
120
|
+
|
121
|
+
def [](key)
|
122
|
+
URI_MEMBERS[key]
|
123
|
+
end
|
124
|
+
|
125
|
+
def generalize
|
126
|
+
DEFAULT
|
127
|
+
end
|
128
|
+
|
129
|
+
def hash
|
130
|
+
self.class.hash ^ @parameters.hash
|
131
|
+
end
|
132
|
+
|
133
|
+
def instance?(o, guard = nil)
|
134
|
+
return false unless o.is_a?(URI)
|
135
|
+
return true if @parameters.nil?
|
136
|
+
|
137
|
+
eval = Parser::EvaluatingParser.singleton.evaluator
|
138
|
+
@parameters.keys.all? { |pn| eval.match?(o.send(pn), @parameters[pn]) }
|
139
|
+
end
|
140
|
+
|
141
|
+
def roundtrip_with_string?
|
142
|
+
true
|
143
|
+
end
|
144
|
+
|
145
|
+
def _pcore_init_hash
|
146
|
+
@parameters == nil? ? EMPTY_HASH : { 'parameters' => @parameters }
|
147
|
+
end
|
148
|
+
|
149
|
+
protected
|
150
|
+
|
151
|
+
def _assignable?(o, guard = nil)
|
152
|
+
return false unless o.class == self.class
|
153
|
+
return true if @parameters.nil?
|
154
|
+
o_params = o.parameters || EMPTY_HASH
|
155
|
+
|
156
|
+
eval = Parser::EvaluatingParser.singleton.evaluator
|
157
|
+
@parameters.keys.all? do |pn|
|
158
|
+
if o_params.include?(pn)
|
159
|
+
a = o_params[pn]
|
160
|
+
b = @parameters[pn]
|
161
|
+
eval.match?(a, b) || a.is_a?(PAnyType) && b.is_a?(PAnyType) && b.assignable?(a)
|
162
|
+
else
|
163
|
+
false
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
private
|
169
|
+
|
170
|
+
def uri_to_hash(uri)
|
171
|
+
result = {}
|
172
|
+
scheme = uri.scheme
|
173
|
+
unless scheme.nil?
|
174
|
+
scheme = scheme.downcase
|
175
|
+
result[SCHEME] = scheme
|
176
|
+
end
|
177
|
+
result[USERINFO] = uri.userinfo unless uri.userinfo.nil?
|
178
|
+
result[HOST] = uri.host.downcase unless uri.host.nil?
|
179
|
+
result[PORT] = uri.port.to_s unless uri.port.nil? || uri.port == 80 && 'http' == scheme || uri.port == 443 && 'https' == scheme
|
180
|
+
result[PATH] = uri.path unless uri.path.nil? || uri.path.empty?
|
181
|
+
result[QUERY] = uri.query unless uri.query.nil?
|
182
|
+
result[FRAGMENT] = uri.fragment unless uri.fragment.nil?
|
183
|
+
result[OPAQUE] = uri.opaque unless uri.opaque.nil?
|
184
|
+
result.empty? ? nil : result
|
185
|
+
end
|
186
|
+
|
187
|
+
DEFAULT = PURIType.new(nil)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|