puppet 4.0.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COMMITTERS.md +2 -2
- data/CONTRIBUTING.md +10 -10
- data/Gemfile +6 -8
- data/LICENSE +3 -3
- data/README.md +14 -10
- data/Rakefile +20 -0
- data/conf/auth.conf +2 -2
- data/conf/puppet.conf +1 -1
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +9 -36
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +1 -1
- data/ext/debian/copyright +4 -4
- data/ext/debian/puppet.default +0 -5
- data/ext/debian/puppet.init +1 -16
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/debian/puppetmaster.README.debian +11 -9
- data/ext/emacs/puppet-mode.el +1 -1
- data/ext/envpuppet +2 -2
- data/ext/ips/puppetagent.xml +1 -1
- data/ext/ips/puppetmaster.xml +1 -1
- data/ext/osx/puppet.plist +30 -0
- data/ext/project_data.yaml +11 -1
- data/ext/puppet-test +3 -3
- data/ext/rack/example-passenger-vhost.conf +1 -1
- data/ext/redhat/client.init +67 -17
- data/ext/redhat/client.sysconfig +1 -10
- data/ext/redhat/logrotate +15 -3
- data/ext/redhat/puppet.spec.erb +6 -11
- data/ext/redhat/server.init +1 -1
- data/ext/regexp_nodes/regexp_nodes.rb +1 -1
- data/ext/solaris/pkginfo +1 -1
- data/ext/solaris/smf/puppet +44 -0
- data/ext/solaris/smf/puppet.xml +44 -0
- data/ext/suse/client.init +30 -33
- data/ext/suse/puppet.spec +2 -2
- data/ext/suse/server.init +2 -2
- data/ext/systemd/puppet.service +3 -1
- data/ext/upload_facts.rb +1 -1
- data/ext/windows/puppet_interactive.bat +6 -0
- data/ext/windows/puppet_shell.bat +9 -0
- data/ext/windows/run_puppet_interactive.bat +9 -0
- data/ext/yaml_nodes.rb +1 -1
- data/install.rb +51 -59
- data/lib/hiera/puppet_function.rb +18 -7
- data/lib/hiera/scope.rb +1 -1
- data/lib/hiera_puppet.rb +6 -14
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/agent.rb +9 -24
- data/lib/puppet/application/agent.rb +39 -19
- data/lib/puppet/application/apply.rb +68 -15
- data/lib/puppet/application/ca.rb +1 -0
- data/lib/puppet/application/cert.rb +17 -1
- data/lib/puppet/application/device.rb +9 -4
- data/lib/puppet/application/filebucket.rb +79 -5
- data/lib/puppet/application/inspect.rb +2 -2
- data/lib/puppet/application/lookup.rb +342 -0
- data/lib/puppet/application/master.rb +22 -7
- data/lib/puppet/application/resource.rb +1 -5
- data/lib/puppet/configurer/plugin_handler.rb +6 -2
- data/lib/puppet/configurer.rb +116 -31
- data/lib/puppet/context/trusted_information.rb +21 -1
- data/lib/puppet/context.rb +16 -1
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- data/lib/puppet/data_providers/data_adapter.rb +7 -68
- data/lib/puppet/data_providers/data_function_support.rb +5 -26
- data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
- data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
- data/lib/puppet/data_providers/hiera_config.rb +129 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +19 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
- data/lib/puppet/data_providers/hiera_support.rb +37 -0
- data/lib/puppet/data_providers/json_data_provider_factory.rb +24 -0
- data/lib/puppet/data_providers/lookup_adapter.rb +247 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +26 -0
- data/lib/puppet/data_providers.rb +12 -13
- data/lib/puppet/defaults.rb +202 -47
- data/lib/puppet/environments.rb +98 -8
- data/lib/puppet/error.rb +31 -1
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/face/epp.rb +1 -1
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/face/parser.rb +12 -9
- data/lib/puppet/face/plugin.rb +7 -14
- data/lib/puppet/face/status.rb +2 -1
- data/lib/puppet/feature/cfacter.rb +1 -0
- data/lib/puppet/feature/cfpropertylist.rb +3 -0
- data/lib/puppet/feature/telnet.rb +9 -0
- data/lib/puppet/file_bucket/dipper.rb +58 -2
- data/lib/puppet/file_serving/http_metadata.rb +46 -0
- data/lib/puppet/file_serving/metadata.rb +30 -9
- data/lib/puppet/file_serving/terminus_helper.rb +7 -8
- data/lib/puppet/file_serving/terminus_selector.rb +2 -0
- data/lib/puppet/file_system/file_impl.rb +6 -2
- data/lib/puppet/file_system/memory_impl.rb +5 -1
- data/lib/puppet/file_system/uniquefile.rb +3 -3
- data/lib/puppet/file_system/windows.rb +12 -16
- data/lib/puppet/file_system.rb +15 -2
- data/lib/puppet/forge/repository.rb +1 -32
- data/lib/puppet/forge.rb +1 -1
- data/lib/puppet/functions/assert_type.rb +57 -21
- data/lib/puppet/functions/defined.rb +161 -0
- data/lib/puppet/functions/dig.rb +39 -0
- data/lib/puppet/functions/each.rb +89 -39
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/filter.rb +64 -38
- data/lib/puppet/functions/hiera.rb +76 -3
- data/lib/puppet/functions/hiera_array.rb +65 -3
- data/lib/puppet/functions/hiera_hash.rb +74 -2
- data/lib/puppet/functions/hiera_include.rb +77 -4
- data/lib/puppet/functions/inline_epp.rb +44 -71
- data/lib/puppet/functions/lest.rb +53 -0
- data/lib/puppet/functions/lookup.rb +172 -184
- data/lib/puppet/functions/map.rb +60 -33
- data/lib/puppet/functions/match.rb +30 -12
- data/lib/puppet/functions/new.rb +502 -0
- data/lib/puppet/functions/reduce.rb +99 -70
- data/lib/puppet/functions/regsubst.rb +12 -11
- data/lib/puppet/functions/reverse_each.rb +82 -0
- data/lib/puppet/functions/scanf.rb +15 -18
- data/lib/puppet/functions/slice.rb +22 -36
- data/lib/puppet/functions/split.rb +3 -3
- data/lib/puppet/functions/step.rb +88 -0
- data/lib/puppet/functions/then.rb +74 -0
- data/lib/puppet/functions/type.rb +70 -0
- data/lib/puppet/functions/versioncmp.rb +36 -0
- data/lib/puppet/functions/with.rb +15 -7
- data/lib/puppet/functions.rb +149 -13
- data/lib/puppet/graph/rb_tree_map.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +196 -9
- data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/facts/facter.rb +8 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
- data/lib/puppet/indirector/file_content/http.rb +15 -0
- data/lib/puppet/indirector/file_metadata/http.rb +27 -0
- data/lib/puppet/indirector/generic_http.rb +16 -0
- data/lib/puppet/indirector/hiera.rb +7 -1
- data/lib/puppet/indirector/indirection.rb +12 -3
- data/lib/puppet/indirector/json.rb +3 -3
- data/lib/puppet/indirector/msgpack.rb +2 -2
- data/lib/puppet/indirector/node/exec.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +1 -1
- data/lib/puppet/indirector/request.rb +7 -8
- data/lib/puppet/indirector/resource_type/parser.rb +10 -3
- data/lib/puppet/indirector/rest.rb +7 -2
- data/lib/puppet/indirector/terminus.rb +4 -4
- data/lib/puppet/info_service/class_information_service.rb +112 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/loaders.rb +4 -0
- data/lib/puppet/metatype/manager.rb +19 -2
- data/lib/puppet/module.rb +26 -17
- data/lib/puppet/module_tool/applications/application.rb +1 -1
- data/lib/puppet/module_tool/applications/builder.rb +2 -2
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +32 -9
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +14 -3
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +19 -4
- data/lib/puppet/module_tool/skeleton/templates/generator/{tests → examples}/init.pp.erb +2 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +25 -18
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +1 -2
- data/lib/puppet/module_tool/tar/mini.rb +3 -3
- data/lib/puppet/network/auth_config_parser.rb +1 -1
- data/lib/puppet/network/authconfig.rb +21 -1
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +0 -2
- data/lib/puppet/network/http/api/master/v3/environment.rb +63 -0
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/network/http/factory.rb +8 -4
- data/lib/puppet/network/http/pool.rb +9 -0
- data/lib/puppet/network/http/rack/rest.rb +10 -1
- data/lib/puppet/node/environment.rb +35 -11
- data/lib/puppet/node.rb +39 -8
- data/lib/puppet/parser/ast/pops_bridge.rb +85 -24
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +60 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
- data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
- data/lib/puppet/parser/compiler.rb +305 -15
- data/lib/puppet/parser/e4_parser_adapter.rb +13 -12
- data/lib/puppet/parser/environment_compiler.rb +164 -0
- data/lib/puppet/parser/functions/assert_type.rb +46 -16
- data/lib/puppet/parser/functions/defined.rb +105 -44
- data/lib/puppet/parser/functions/each.rb +85 -27
- data/lib/puppet/parser/functions/epp.rb +29 -37
- data/lib/puppet/parser/functions/file.rb +3 -1
- data/lib/puppet/parser/functions/filter.rb +59 -23
- data/lib/puppet/parser/functions/fqdn_rand.rb +3 -3
- data/lib/puppet/parser/functions/hiera.rb +83 -27
- data/lib/puppet/parser/functions/hiera_array.rb +71 -28
- data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
- data/lib/puppet/parser/functions/hiera_include.rb +81 -40
- data/lib/puppet/parser/functions/inline_epp.rb +35 -60
- data/lib/puppet/parser/functions/inline_template.rb +2 -2
- data/lib/puppet/parser/functions/lookup.rb +125 -149
- data/lib/puppet/parser/functions/map.rb +55 -20
- data/lib/puppet/parser/functions/match.rb +28 -12
- data/lib/puppet/parser/functions/reduce.rb +97 -60
- data/lib/puppet/parser/functions/scanf.rb +15 -26
- data/lib/puppet/parser/functions/slice.rb +17 -24
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +16 -8
- data/lib/puppet/parser/functions.rb +28 -16
- data/lib/puppet/parser/resource.rb +119 -26
- data/lib/puppet/parser/scope.rb +233 -24
- data/lib/puppet/parser/templatewrapper.rb +2 -1
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/plugins/configuration.rb +3 -2
- data/lib/puppet/plugins/data_providers/data_provider.rb +336 -0
- data/lib/puppet/plugins/data_providers/registry.rb +84 -0
- data/lib/puppet/plugins/data_providers.rb +12 -60
- data/lib/puppet/pops/adaptable.rb +4 -1
- data/lib/puppet/pops/adapters.rb +96 -12
- data/lib/puppet/pops/binder/binder.rb +21 -17
- data/lib/puppet/pops/binder/binder_issues.rb +8 -6
- data/lib/puppet/pops/binder/bindings_checker.rb +12 -8
- data/lib/puppet/pops/binder/bindings_composer.rb +16 -12
- data/lib/puppet/pops/binder/bindings_factory.rb +108 -104
- data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
- data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
- data/lib/puppet/pops/binder/bindings_model.rb +49 -47
- data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
- data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +10 -6
- data/lib/puppet/pops/binder/injector.rb +55 -50
- data/lib/puppet/pops/binder/key_factory.rb +10 -12
- data/lib/puppet/pops/binder/producers.rb +67 -62
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
- data/lib/puppet/pops/evaluator/access_operator.rb +189 -138
- data/lib/puppet/pops/evaluator/closure.rb +151 -104
- data/lib/puppet/pops/evaluator/collector_transformer.rb +35 -25
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -1
- data/lib/puppet/pops/evaluator/compare_operator.rb +87 -10
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +16 -10
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +204 -111
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +85 -0
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +88 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +19 -11
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +19 -2
- data/lib/puppet/pops/evaluator/runtime3_support.rb +95 -44
- data/lib/puppet/pops/functions/dispatch.rb +6 -1
- data/lib/puppet/pops/functions/dispatcher.rb +10 -4
- data/lib/puppet/pops/functions/function.rb +6 -2
- data/lib/puppet/pops/issue_reporter.rb +48 -20
- data/lib/puppet/pops/issues.rb +194 -17
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/loader/base_loader.rb +48 -7
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +23 -0
- data/lib/puppet/pops/loader/loader_paths.rb +82 -6
- data/lib/puppet/pops/loader/module_loaders.rb +36 -21
- data/lib/puppet/pops/loader/predefined_loader.rb +29 -0
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +83 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +16 -3
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +57 -0
- data/lib/puppet/pops/loader/static_loader.rb +92 -5
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +77 -0
- data/lib/puppet/pops/loaders.rb +133 -19
- data/lib/puppet/pops/lookup/explainer.rb +509 -0
- data/lib/puppet/pops/lookup/interpolation.rb +115 -0
- data/lib/puppet/pops/lookup/invocation.rb +119 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +86 -0
- data/lib/puppet/pops/lookup.rb +35 -52
- data/lib/puppet/pops/merge_strategy.rb +85 -30
- data/lib/puppet/pops/migration/migration_checker.rb +54 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +242 -158
- data/lib/puppet/pops/model/model.rb +25 -8
- data/lib/puppet/pops/model/model_label_provider.rb +25 -6
- data/lib/puppet/pops/model/model_meta.rb +48 -3
- data/lib/puppet/pops/model/model_tree_dumper.rb +30 -0
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +133 -30
- data/lib/puppet/pops/parser/eparser.rb +1738 -1254
- data/lib/puppet/pops/parser/epp_support.rb +27 -12
- data/lib/puppet/pops/parser/evaluating_parser.rb +27 -13
- data/lib/puppet/pops/parser/heredoc_support.rb +19 -14
- data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
- data/lib/puppet/pops/parser/lexer2.rb +452 -379
- data/lib/puppet/pops/parser/lexer_support.rb +132 -25
- data/lib/puppet/pops/parser/locator.rb +30 -5
- data/lib/puppet/pops/parser/parser_support.rb +49 -37
- data/lib/puppet/pops/parser/slurp_support.rb +32 -8
- data/lib/puppet/pops/patterns.rb +3 -0
- data/lib/puppet/pops/pcore.rb +30 -0
- data/lib/puppet/pops/types/class_loader.rb +25 -23
- data/lib/puppet/pops/types/enumeration.rb +9 -27
- data/lib/puppet/pops/types/implementation_registry.rb +146 -0
- data/lib/puppet/pops/types/iterable.rb +308 -0
- data/lib/puppet/pops/types/p_object_type.rb +846 -0
- data/lib/puppet/pops/types/p_runtime_type.rb +102 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +164 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +113 -0
- data/lib/puppet/pops/types/puppet_object.rb +21 -0
- data/lib/puppet/pops/types/recursion_guard.rb +92 -0
- data/lib/puppet/pops/types/ruby_generator.rb +258 -0
- data/lib/puppet/pops/types/string_converter.rb +922 -0
- data/lib/puppet/pops/types/type_acceptor.rb +25 -0
- data/lib/puppet/pops/types/type_asserter.rb +21 -19
- data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
- data/lib/puppet/pops/types/type_calculator.rb +213 -1184
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +216 -157
- data/lib/puppet/pops/types/type_formatter.rb +569 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1001 -0
- data/lib/puppet/pops/types/type_parser.rb +332 -279
- data/lib/puppet/pops/types/types.rb +2770 -288
- data/lib/puppet/pops/utils.rb +11 -10
- data/lib/puppet/pops/validation/checker4_0.rb +266 -72
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +12 -5
- data/lib/puppet/pops/validation.rb +43 -13
- data/lib/puppet/pops/visitor.rb +3 -1
- data/lib/puppet/pops.rb +29 -24
- data/lib/puppet/property/ensure.rb +1 -1
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider/aixobject.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +57 -2
- data/lib/puppet/provider/cron/crontab.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/exec.rb +6 -1
- data/lib/puppet/provider/group/directoryservice.rb +10 -0
- data/lib/puppet/provider/group/pw.rb +1 -0
- data/lib/puppet/provider/group/windows_adsi.rb +19 -6
- data/lib/puppet/provider/macauthorization/macauthorization.rb +10 -9
- data/lib/puppet/provider/mount/parsed.rb +159 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +35 -50
- data/lib/puppet/provider/package/appdmg.rb +3 -2
- data/lib/puppet/provider/package/apt.rb +1 -1
- data/lib/puppet/provider/package/dnf.rb +41 -0
- data/lib/puppet/provider/package/gem.rb +23 -2
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/openbsd.rb +7 -7
- data/lib/puppet/provider/package/pacman.rb +9 -8
- data/lib/puppet/provider/package/pip.rb +80 -20
- data/lib/puppet/provider/package/pip3.rb +20 -0
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +7 -4
- data/lib/puppet/provider/package/pkgin.rb +3 -3
- data/lib/puppet/provider/package/pkgng.rb +143 -0
- data/lib/puppet/provider/package/portage.rb +1 -1
- data/lib/puppet/provider/package/ports.rb +0 -3
- data/lib/puppet/provider/package/puppet_gem.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +120 -14
- data/lib/puppet/provider/package/windows/exe_package.rb +10 -9
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -4
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/windows.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +31 -80
- data/lib/puppet/provider/package/zypper.rb +69 -15
- data/lib/puppet/provider/package.rb +6 -2
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
- data/lib/puppet/provider/service/base.rb +3 -2
- data/lib/puppet/provider/service/bsd.rb +8 -8
- data/lib/puppet/provider/service/daemontools.rb +3 -3
- data/lib/puppet/provider/service/debian.rb +12 -3
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/init.rb +22 -0
- data/lib/puppet/provider/service/launchd.rb +41 -18
- data/lib/puppet/provider/service/rcng.rb +51 -0
- data/lib/puppet/provider/service/redhat.rb +2 -1
- data/lib/puppet/provider/service/runit.rb +3 -3
- data/lib/puppet/provider/service/smf.rb +48 -4
- data/lib/puppet/provider/service/src.rb +27 -0
- data/lib/puppet/provider/service/systemd.rb +104 -22
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +20 -10
- data/lib/puppet/provider/user/aix.rb +1 -1
- data/lib/puppet/provider/user/directoryservice.rb +33 -58
- data/lib/puppet/provider/user/openbsd.rb +1 -0
- data/lib/puppet/provider/user/pw.rb +1 -0
- data/lib/puppet/provider/user/user_role_add.rb +3 -1
- data/lib/puppet/provider/user/windows_adsi.rb +45 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +6 -3
- data/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/provider.rb +5 -0
- data/lib/puppet/reference/configuration.rb +11 -5
- data/lib/puppet/reference/indirection.rb +1 -1
- data/lib/puppet/reference/providers.rb +2 -3
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource/capability_finder.rb +102 -0
- data/lib/puppet/resource/catalog.rb +133 -36
- data/lib/puppet/resource/status.rb +19 -3
- data/lib/puppet/resource/type.rb +236 -49
- data/lib/puppet/resource/type_collection.rb +83 -10
- data/lib/puppet/resource.rb +116 -119
- data/lib/puppet/settings/base_setting.rb +9 -3
- data/lib/puppet/settings/config_file.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +13 -5
- data/lib/puppet/settings/file_setting.rb +10 -9
- data/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/lib/puppet/settings.rb +68 -20
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/ssl/certificate_factory.rb +3 -3
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/certificate_signer.rb +1 -1
- data/lib/puppet/ssl/oids.rb +33 -3
- data/lib/puppet/ssl/validator/default_validator.rb +1 -1
- data/lib/puppet/test/test_helper.rb +16 -5
- data/lib/puppet/transaction/additional_resource_generator.rb +89 -8
- data/lib/puppet/transaction/report.rb +31 -1
- data/lib/puppet/transaction/resource_harness.rb +0 -20
- data/lib/puppet/transaction.rb +46 -36
- data/lib/puppet/type/augeas.rb +10 -1
- data/lib/puppet/type/cron.rb +12 -12
- data/lib/puppet/type/exec.rb +27 -18
- data/lib/puppet/type/file/checksum_value.rb +53 -0
- data/lib/puppet/type/file/content.rb +32 -117
- data/lib/puppet/type/file/data_sync.rb +84 -0
- data/lib/puppet/type/file/ensure.rb +22 -19
- data/lib/puppet/type/file/selcontext.rb +1 -1
- data/lib/puppet/type/file/source.rb +121 -34
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/file.rb +107 -44
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +15 -3
- data/lib/puppet/type/interface.rb +8 -3
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/mount.rb +29 -2
- data/lib/puppet/type/package.rb +31 -11
- data/lib/puppet/type/schedule.rb +5 -5
- data/lib/puppet/type/scheduled_task.rb +13 -0
- data/lib/puppet/type/service.rb +24 -0
- data/lib/puppet/type/sshkey.rb +5 -3
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +6 -4
- data/lib/puppet/type/user.rb +55 -19
- data/lib/puppet/type/yumrepo.rb +25 -5
- data/lib/puppet/type/zone.rb +5 -5
- data/lib/puppet/type.rb +95 -18
- data/lib/puppet/util/autoload.rb +16 -11
- data/lib/puppet/util/checksums.rb +74 -31
- data/lib/puppet/util/command_line.rb +4 -0
- data/lib/puppet/util/execution.rb +21 -5
- data/lib/puppet/util/feature.rb +1 -1
- data/lib/puppet/util/http_proxy.rb +132 -0
- data/lib/puppet/util/log/destinations.rb +23 -2
- data/lib/puppet/util/log.rb +53 -9
- data/lib/puppet/util/logging.rb +80 -2
- data/lib/puppet/util/monkey_patches.rb +20 -7
- data/lib/puppet/util/multi_match.rb +51 -0
- data/lib/puppet/util/network_device/cisco/device.rb +24 -6
- data/lib/puppet/util/network_device/cisco/interface.rb +21 -9
- data/lib/puppet/util/network_device/transport/ssh.rb +7 -3
- data/lib/puppet/util/network_device/transport/telnet.rb +39 -36
- data/lib/puppet/util/plist.rb +130 -0
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/run_mode.rb +3 -16
- data/lib/puppet/util/skip_tags.rb +9 -0
- data/lib/puppet/util/splayer.rb +18 -0
- data/lib/puppet/util/tagging.rb +7 -1
- data/lib/puppet/util/windows/access_control_entry.rb +1 -1
- data/lib/puppet/util/windows/access_control_list.rb +3 -3
- data/lib/puppet/util/windows/adsi.rb +186 -74
- data/lib/puppet/util/windows/api_types.rb +24 -18
- data/lib/puppet/util/windows/com.rb +3 -3
- data/lib/puppet/util/windows/error.rb +1 -1
- data/lib/puppet/util/windows/file.rb +48 -18
- data/lib/puppet/util/windows/principal.rb +190 -0
- data/lib/puppet/util/windows/process.rb +78 -11
- data/lib/puppet/util/windows/registry.rb +22 -16
- data/lib/puppet/util/windows/root_certs.rb +5 -5
- data/lib/puppet/util/windows/security.rb +37 -36
- data/lib/puppet/util/windows/security_descriptor.rb +1 -1
- data/lib/puppet/util/windows/sid.rb +84 -15
- data/lib/puppet/util/windows/taskscheduler.rb +16 -16
- data/lib/puppet/util/windows/user.rb +10 -10
- data/lib/puppet/util/windows.rb +5 -0
- data/lib/puppet/util.rb +123 -23
- data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +1 -1
- data/lib/puppet/vendor/pathspec/LICENSE +2 -2
- data/lib/puppet/vendor/pathspec/README.md +1 -1
- data/lib/puppet/vendor/rgen/README.rdoc +1 -1
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +14 -0
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +30 -1
- data/lib/semver.rb +17 -1
- data/man/man5/puppet.conf.5 +60 -18
- data/man/man8/extlookup2hiera.8 +2 -2
- data/man/man8/puppet-agent.8 +6 -3
- data/man/man8/puppet-apply.8 +6 -3
- data/man/man8/puppet-ca.8 +3 -3
- data/man/man8/puppet-catalog.8 +3 -3
- data/man/man8/puppet-cert.8 +3 -3
- data/man/man8/puppet-certificate.8 +3 -3
- data/man/man8/puppet-certificate_request.8 +3 -3
- data/man/man8/puppet-certificate_revocation_list.8 +3 -3
- data/man/man8/puppet-config.8 +4 -4
- data/man/man8/puppet-describe.8 +2 -2
- data/man/man8/puppet-device.8 +7 -4
- data/man/man8/puppet-doc.8 +2 -2
- data/man/man8/puppet-epp.8 +3 -3
- data/man/man8/puppet-facts.8 +3 -3
- data/man/man8/puppet-file.8 +3 -3
- data/man/man8/puppet-filebucket.8 +3 -3
- data/man/man8/puppet-help.8 +3 -3
- data/man/man8/puppet-inspect.8 +3 -3
- data/man/man8/puppet-key.8 +3 -3
- data/man/man8/puppet-man.8 +3 -3
- data/man/man8/puppet-master.8 +6 -3
- data/man/man8/puppet-module.8 +10 -10
- data/man/man8/puppet-node.8 +3 -3
- data/man/man8/puppet-parser.8 +3 -3
- data/man/man8/puppet-plugin.8 +3 -3
- data/man/man8/puppet-report.8 +3 -3
- data/man/man8/puppet-resource.8 +3 -3
- data/man/man8/puppet-resource_type.8 +3 -3
- data/man/man8/puppet-status.8 +4 -4
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/module.tar.gz +0 -0
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +20 -0
- data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/production/manifests/site.pp +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/functions/data.pp +10 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/third_utf8.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/utf8.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +22 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/data/common.yaml +6 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/manifests/init.pp +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/manifests/init.pp +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +0 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/data/empty.json +0 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/data/empty_key.json +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/data/empty_key.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/data/empty.yaml +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +4 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
- data/spec/fixtures/unit/module/trailing-comma.json +1 -1
- data/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/functions/usee_puppet.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/functions/usee/usee_ruby.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/type/usee_type.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/manifests/init.pp +8 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/types/zero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee2/lib/puppet/functions/usee2/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet_init.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_ruby.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/caller2.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet_init.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_ruby.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +87 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/metadata.json +2 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseeone.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseezero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
- data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
- data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-broken-notices.txt +187 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-obsoletes.txt +195 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
- data/spec/fixtures/unit/provider/service/smf/svcs.out +4 -3
- data/spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines +8 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_not_update_if_content_on_disk_is_up-to-date.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_update_if_content_differs_on_disk.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_mtime_is_older_on_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_no_header_specified.yml +197 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_not_update_if_mtime_is_newer_on_disk.yml +205 -0
- data/spec/integration/agent/logging_spec.rb +0 -0
- data/spec/integration/application/apply_spec.rb +121 -30
- data/spec/integration/application/doc_spec.rb +0 -0
- data/spec/integration/configurer_spec.rb +0 -0
- data/spec/integration/data_binding_spec.rb +195 -0
- data/spec/integration/defaults_spec.rb +14 -2
- data/spec/integration/faces/ca_spec.rb +0 -0
- data/spec/integration/faces/documentation_spec.rb +0 -0
- data/spec/integration/faces/plugin_spec.rb +0 -4
- data/spec/integration/file_bucket/file_spec.rb +2 -2
- data/spec/integration/file_serving/fileset_spec.rb +0 -0
- data/spec/integration/file_serving/terminus_helper_spec.rb +0 -0
- data/spec/integration/file_system/uniquefile_spec.rb +29 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +0 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +0 -0
- data/spec/integration/indirector/facts/facter_spec.rb +97 -0
- data/spec/integration/indirector/file_content/file_server_spec.rb +0 -0
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -0
- data/spec/integration/indirector/node/ldap_spec.rb +0 -0
- data/spec/integration/module_tool/tar/mini_spec.rb +28 -0
- data/spec/integration/network/formats_spec.rb +0 -0
- data/spec/integration/node/environment_spec.rb +13 -0
- data/spec/integration/node/facts_spec.rb +0 -0
- data/spec/integration/node_spec.rb +0 -0
- data/spec/integration/parser/catalog_spec.rb +14 -2
- data/spec/integration/parser/collection_spec.rb +8 -0
- data/spec/integration/parser/compiler_spec.rb +949 -2
- data/spec/integration/parser/dynamic_scoping_spec.rb +67 -0
- data/spec/integration/parser/functions/require_spec.rb +0 -0
- data/spec/integration/parser/parameter_defaults_spec.rb +354 -0
- data/spec/integration/parser/resource_expressions_spec.rb +8 -5
- data/spec/integration/parser/scope_spec.rb +46 -7
- data/spec/integration/parser/undef_param_spec.rb +9 -1
- data/spec/integration/provider/mailalias/aliases_spec.rb +0 -0
- data/spec/integration/provider/mount_spec.rb +23 -36
- data/spec/integration/provider/service/init_spec.rb +0 -0
- data/spec/integration/provider/ssh_authorized_key_spec.rb +0 -0
- data/spec/integration/provider/yumrepo_spec.rb +1 -1
- data/spec/integration/reference/providers_spec.rb +0 -0
- data/spec/integration/reports_spec.rb +0 -0
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/resource/type_collection_spec.rb +8 -0
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/test/test_helper_spec.rb +28 -0
- data/spec/integration/transaction/report_spec.rb +16 -0
- data/spec/integration/transaction_spec.rb +52 -2
- data/spec/integration/type/exec_spec.rb +0 -0
- data/spec/integration/type/file_spec.rb +548 -45
- data/spec/integration/type/package_spec.rb +72 -1
- data/spec/integration/type/tidy_spec.rb +21 -9
- data/spec/integration/type_spec.rb +0 -0
- data/spec/integration/util/autoload_spec.rb +0 -0
- data/spec/integration/util/execution_spec.rb +22 -0
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +26 -0
- data/spec/integration/util/windows/principal_spec.rb +201 -0
- data/spec/integration/util/windows/process_spec.rb +31 -0
- data/spec/{unit → integration}/util/windows/registry_spec.rb +91 -1
- data/spec/integration/util/windows/security_spec.rb +40 -13
- data/spec/integration/util/windows/user_spec.rb +1 -1
- data/spec/integration/util_spec.rb +49 -27
- data/spec/lib/matchers/include_in_order.rb +2 -3
- data/spec/lib/matchers/resource.rb +22 -1
- data/spec/lib/puppet/face/1.0.0/huzzah.rb +0 -0
- data/spec/lib/puppet/face/basetest.rb +0 -0
- data/spec/lib/puppet/face/huzzah.rb +0 -0
- data/spec/lib/puppet_spec/compiler.rb +27 -3
- data/spec/lib/puppet_spec/files.rb +16 -2
- data/spec/lib/puppet_spec/fixtures.rb +0 -0
- data/spec/lib/puppet_spec/matchers.rb +6 -4
- data/spec/lib/puppet_spec/pops.rb +13 -0
- data/spec/lib/puppet_spec/verbose.rb +0 -0
- data/spec/shared_behaviours/all_parsedfile_providers.rb +0 -0
- data/spec/shared_behaviours/file_server_terminus.rb +0 -0
- data/spec/shared_behaviours/file_serving.rb +0 -0
- data/spec/shared_behaviours/iterative_functions.rb +9 -9
- data/spec/shared_behaviours/memory_terminus.rb +0 -0
- data/spec/shared_behaviours/path_parameters.rb +0 -0
- data/spec/shared_behaviours/things_that_declare_options.rb +0 -0
- data/spec/shared_contexts/types_setup.rb +100 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +1 -46
- data/spec/unit/application/agent_spec.rb +15 -0
- data/spec/unit/application/apply_spec.rb +31 -1
- data/spec/unit/application/cert_spec.rb +0 -0
- data/spec/unit/application/certificate_spec.rb +0 -0
- data/spec/unit/application/config_spec.rb +0 -0
- data/spec/unit/application/describe_spec.rb +0 -0
- data/spec/unit/application/device_spec.rb +0 -0
- data/spec/unit/application/doc_spec.rb +0 -0
- data/spec/unit/application/face_base_spec.rb +0 -0
- data/spec/unit/application/facts_spec.rb +0 -0
- data/spec/unit/application/filebucket_spec.rb +88 -2
- data/spec/unit/application/indirection_base_spec.rb +0 -0
- data/spec/unit/application/inspect_spec.rb +19 -8
- data/spec/unit/application/lookup_spec.rb +387 -0
- data/spec/unit/application/master_spec.rb +33 -7
- data/spec/unit/application/resource_spec.rb +0 -0
- data/spec/unit/application_spec.rb +3 -3
- data/spec/unit/appmgmt_spec.rb +666 -0
- data/spec/unit/capability_spec.rb +394 -0
- data/spec/unit/configurer/downloader_factory_spec.rb +0 -0
- data/spec/unit/configurer/downloader_spec.rb +5 -5
- data/spec/unit/configurer/fact_handler_spec.rb +0 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +42 -13
- data/spec/unit/configurer_spec.rb +282 -39
- data/spec/unit/confine/exists_spec.rb +0 -0
- data/spec/unit/confine/false_spec.rb +0 -0
- data/spec/unit/confine/feature_spec.rb +0 -0
- data/spec/unit/confine/true_spec.rb +0 -0
- data/spec/unit/confine/variable_spec.rb +0 -0
- data/spec/unit/confine_collection_spec.rb +0 -0
- data/spec/unit/confine_spec.rb +0 -0
- data/spec/unit/confiner_spec.rb +0 -0
- data/spec/unit/context/trusted_information_spec.rb +24 -1
- data/spec/unit/daemon_spec.rb +18 -8
- data/spec/unit/data_providers/function_data_provider_spec.rb +28 -1
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +378 -0
- data/spec/unit/defaults_spec.rb +33 -0
- data/spec/unit/environments_spec.rb +26 -4
- data/spec/unit/external/pson_spec.rb +0 -0
- data/spec/unit/face/catalog_spec.rb +0 -0
- data/spec/unit/face/certificate_spec.rb +0 -0
- data/spec/unit/face/config_spec.rb +0 -0
- data/spec/unit/face/epp_face_spec.rb +2 -2
- data/spec/unit/face/facts_spec.rb +0 -0
- data/spec/unit/face/file_spec.rb +0 -0
- data/spec/unit/face/help_spec.rb +0 -0
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/face/parser_spec.rb +43 -2
- data/spec/unit/face/plugin_spec.rb +33 -4
- data/spec/unit/face_spec.rb +0 -0
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/file_bucket/file_spec.rb +0 -0
- data/spec/unit/file_serving/base_spec.rb +0 -0
- data/spec/unit/file_serving/configuration/parser_spec.rb +25 -30
- data/spec/unit/file_serving/configuration_spec.rb +1 -1
- data/spec/unit/file_serving/content_spec.rb +0 -0
- data/spec/unit/file_serving/fileset_spec.rb +0 -0
- data/spec/unit/file_serving/http_metadata_spec.rb +85 -0
- data/spec/unit/file_serving/metadata_spec.rb +51 -1
- data/spec/unit/file_serving/mount/file_spec.rb +0 -0
- data/spec/unit/file_serving/mount/modules_spec.rb +0 -0
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +0 -0
- data/spec/unit/file_serving/mount/plugins_spec.rb +0 -0
- data/spec/unit/file_serving/mount_spec.rb +0 -0
- data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
- data/spec/unit/file_serving/terminus_selector_spec.rb +12 -2
- data/spec/unit/file_system/uniquefile_spec.rb +20 -0
- data/spec/unit/file_system_spec.rb +145 -0
- data/spec/unit/functions/assert_type_spec.rb +48 -8
- data/spec/unit/functions/defined_spec.rb +289 -0
- data/spec/unit/functions/dig_spec.rb +58 -0
- data/spec/unit/functions/epp_spec.rb +17 -9
- data/spec/unit/functions/filter_spec.rb +18 -0
- data/spec/unit/functions/hiera_spec.rb +10 -8
- data/spec/unit/functions/inline_epp_spec.rb +4 -4
- data/spec/unit/functions/lest_spec.rb +34 -0
- data/spec/unit/functions/lookup_spec.rb +391 -22
- data/spec/unit/functions/new_spec.rb +543 -0
- data/spec/unit/functions/regsubst_spec.rb +29 -8
- data/spec/unit/functions/reverse_each_spec.rb +108 -0
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/functions/split_spec.rb +10 -2
- data/spec/unit/functions/step_spec.rb +113 -0
- data/spec/unit/functions/then_spec.rb +40 -0
- data/spec/unit/functions/type_spec.rb +35 -0
- data/spec/unit/functions/versioncmp_spec.rb +36 -0
- data/spec/unit/functions4_spec.rb +275 -70
- data/spec/unit/graph/relationship_graph_spec.rb +0 -0
- data/spec/unit/graph/sequential_prioritizer_spec.rb +1 -1
- data/spec/unit/graph/simple_graph_spec.rb +0 -0
- data/spec/unit/hiera/scope_spec.rb +5 -2
- data/spec/unit/hiera_puppet_spec.rb +49 -8
- data/spec/unit/indirector/catalog/compiler_spec.rb +752 -8
- data/spec/unit/indirector/catalog/json_spec.rb +0 -0
- data/spec/unit/indirector/catalog/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/catalog/rest_spec.rb +0 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
- data/spec/unit/indirector/catalog/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/catalog/yaml_spec.rb +0 -0
- data/spec/unit/indirector/certificate/ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate/rest_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/rest_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +0 -0
- data/spec/unit/indirector/certificate_status/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate_status/rest_spec.rb +0 -0
- data/spec/unit/indirector/code_spec.rb +0 -0
- data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
- data/spec/unit/indirector/direct_file_server_spec.rb +0 -0
- data/spec/unit/indirector/envelope_spec.rb +0 -0
- data/spec/unit/indirector/exec_spec.rb +0 -0
- data/spec/unit/indirector/face_spec.rb +0 -0
- data/spec/unit/indirector/facts/facter_spec.rb +8 -0
- data/spec/unit/indirector/facts/network_device_spec.rb +0 -0
- data/spec/unit/indirector/facts/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +0 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +53 -2
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_spec.rb +0 -0
- data/spec/unit/indirector/file_content/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_server_spec.rb +0 -0
- data/spec/unit/indirector/indirection_spec.rb +13 -2
- data/spec/unit/indirector/json_spec.rb +1 -1
- data/spec/unit/indirector/key/ca_spec.rb +0 -0
- data/spec/unit/indirector/key/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/key/file_spec.rb +0 -0
- data/spec/unit/indirector/ldap_spec.rb +0 -0
- data/spec/unit/indirector/memory_spec.rb +0 -0
- data/spec/unit/indirector/msgpack_spec.rb +11 -1
- data/spec/unit/indirector/node/exec_spec.rb +0 -0
- data/spec/unit/indirector/node/ldap_spec.rb +0 -0
- data/spec/unit/indirector/node/memory_spec.rb +0 -0
- data/spec/unit/indirector/node/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/node/plain_spec.rb +0 -0
- data/spec/unit/indirector/node/rest_spec.rb +0 -0
- data/spec/unit/indirector/node/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/node/yaml_spec.rb +0 -0
- data/spec/unit/indirector/plain_spec.rb +0 -0
- data/spec/unit/indirector/report/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/report/processor_spec.rb +0 -0
- data/spec/unit/indirector/report/rest_spec.rb +0 -0
- data/spec/unit/indirector/report/yaml_spec.rb +0 -0
- data/spec/unit/indirector/request_spec.rb +8 -8
- data/spec/unit/indirector/resource/ral_spec.rb +0 -0
- data/spec/unit/indirector/resource/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +5 -0
- data/spec/unit/indirector/resource_type/rest_spec.rb +0 -0
- data/spec/unit/indirector/rest_spec.rb +12 -0
- data/spec/unit/indirector/ssl_file_spec.rb +1 -1
- data/spec/unit/indirector/status/rest_spec.rb +0 -0
- data/spec/unit/indirector/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/terminus_spec.rb +0 -0
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/indirector_spec.rb +0 -0
- data/spec/unit/info_service_spec.rb +298 -0
- data/spec/unit/interface/action_builder_spec.rb +0 -0
- data/spec/unit/interface/action_manager_spec.rb +0 -0
- data/spec/unit/interface/action_spec.rb +0 -0
- data/spec/unit/interface/documentation_spec.rb +0 -0
- data/spec/unit/interface/face_collection_spec.rb +0 -0
- data/spec/unit/interface/option_builder_spec.rb +0 -0
- data/spec/unit/interface/option_spec.rb +0 -0
- data/spec/unit/interface_spec.rb +0 -0
- data/spec/unit/man_spec.rb +0 -0
- data/spec/unit/module_spec.rb +42 -27
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +28 -8
- data/spec/unit/module_tool/metadata_spec.rb +31 -2
- data/spec/unit/module_tool_spec.rb +0 -0
- data/spec/unit/network/auth_config_parser_spec.rb +16 -0
- data/spec/unit/network/authconfig_spec.rb +62 -32
- data/spec/unit/network/authorization_spec.rb +30 -2
- data/spec/unit/network/authstore_spec.rb +2 -2
- data/spec/unit/network/format_handler_spec.rb +0 -0
- data/spec/unit/network/format_spec.rb +0 -0
- data/spec/unit/network/formats_spec.rb +0 -0
- data/spec/unit/network/http/api/indirected_routes_spec.rb +21 -13
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +60 -0
- data/spec/unit/network/http/api/master/v3_spec.rb +0 -0
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +15 -19
- data/spec/unit/network/http/factory_spec.rb +14 -0
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/network/http/nocache_pool_spec.rb +0 -0
- data/spec/unit/network/http/pool_spec.rb +30 -0
- data/spec/unit/network/http/rack/rest_spec.rb +7 -0
- data/spec/unit/network/http/rack_spec.rb +0 -0
- data/spec/unit/network/http/session_spec.rb +0 -0
- data/spec/unit/network/http/site_spec.rb +0 -0
- data/spec/unit/network/http/webrick/rest_spec.rb +0 -0
- data/spec/unit/network/http/webrick_spec.rb +0 -0
- data/spec/unit/network/http_pool_spec.rb +0 -0
- data/spec/unit/network/http_spec.rb +0 -0
- data/spec/unit/network/resolver_spec.rb +0 -0
- data/spec/unit/network/rights_spec.rb +3 -3
- data/spec/unit/network/server_spec.rb +0 -0
- data/spec/unit/node/environment_spec.rb +10 -0
- data/spec/unit/node/facts_spec.rb +0 -0
- data/spec/unit/node_spec.rb +41 -0
- data/spec/unit/other/selinux_spec.rb +0 -0
- data/spec/unit/parameter/path_spec.rb +0 -0
- data/spec/unit/parameter/value_collection_spec.rb +0 -0
- data/spec/unit/parameter/value_spec.rb +0 -0
- data/spec/unit/parameter_spec.rb +0 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +103 -2
- data/spec/unit/parser/files_spec.rb +0 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +2 -2
- data/spec/unit/parser/functions/defined_spec.rb +0 -0
- data/spec/unit/parser/functions/digest_spec.rb +0 -0
- data/spec/unit/parser/functions/fail_spec.rb +0 -0
- data/spec/unit/parser/functions/file_spec.rb +7 -1
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +6 -2
- data/spec/unit/parser/functions/generate_spec.rb +3 -12
- data/spec/unit/parser/functions/hiera_spec.rb +0 -0
- data/spec/unit/parser/functions/include_spec.rb +0 -0
- data/spec/unit/parser/functions/inline_template_spec.rb +0 -0
- data/spec/unit/parser/functions/realize_spec.rb +0 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +0 -0
- data/spec/unit/parser/functions/require_spec.rb +0 -0
- data/spec/unit/parser/functions/scanf_spec.rb +0 -0
- data/spec/unit/parser/functions/shared.rb +1 -1
- data/spec/unit/parser/functions/shellquote_spec.rb +0 -0
- data/spec/unit/parser/functions/split_spec.rb +0 -0
- data/spec/unit/parser/functions/sprintf_spec.rb +0 -0
- data/spec/unit/parser/functions/tag_spec.rb +0 -0
- data/spec/unit/parser/functions/template_spec.rb +1 -1
- data/spec/unit/parser/functions/versioncmp_spec.rb +0 -0
- data/spec/unit/parser/functions_spec.rb +0 -0
- data/spec/unit/parser/relationship_spec.rb +0 -0
- data/spec/unit/parser/resource/param_spec.rb +0 -0
- data/spec/unit/parser/resource_spec.rb +10 -21
- data/spec/unit/parser/scope_spec.rb +84 -13
- data/spec/unit/parser/templatewrapper_spec.rb +1 -1
- data/spec/unit/parser/type_loader_spec.rb +0 -0
- data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +3 -3
- data/spec/unit/pops/evaluator/access_ops_spec.rb +52 -17
- data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
- data/spec/unit/pops/evaluator/comparison_ops_spec.rb +3 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +125 -36
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +4 -4
- data/spec/unit/pops/evaluator/json_strict_literal_evaluator_spec.rb +63 -0
- data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +25 -0
- data/spec/unit/pops/evaluator/variables_spec.rb +2 -2
- data/spec/unit/pops/issues_spec.rb +16 -16
- data/spec/unit/pops/label_provider_spec.rb +5 -1
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +53 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +230 -47
- data/spec/unit/pops/loaders/static_loader_spec.rb +92 -1
- data/spec/unit/pops/lookup/interpolation_spec.rb +313 -0
- data/spec/unit/pops/migration_spec.rb +53 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +326 -6
- data/spec/unit/pops/parser/parse_application_spec.rb +35 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +23 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +8 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +40 -0
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
- data/spec/unit/pops/parser/parse_site_spec.rb +47 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +6 -0
- data/spec/unit/pops/parser/parser_spec.rb +28 -0
- data/spec/unit/pops/parser/source_pos_adapter_spec.rb +26 -0
- data/spec/unit/pops/types/enumeration_spec.rb +13 -12
- data/spec/unit/pops/types/iterable_spec.rb +262 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +1060 -0
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +285 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +93 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +261 -0
- data/spec/unit/pops/types/string_converter_spec.rb +904 -0
- data/spec/unit/pops/types/type_acceptor_spec.rb +105 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +43 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +960 -849
- data/spec/unit/pops/types/type_factory_spec.rb +132 -91
- data/spec/unit/pops/types/type_formatter_spec.rb +352 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +177 -0
- data/spec/unit/pops/types/type_parser_spec.rb +119 -32
- data/spec/unit/pops/types/types_spec.rb +561 -0
- data/spec/unit/pops/validation_spec.rb +66 -0
- data/spec/unit/pops/validator/validator_spec.rb +303 -17
- data/spec/unit/property/ensure_spec.rb +0 -0
- data/spec/unit/property/keyvalue_spec.rb +0 -0
- data/spec/unit/property/list_spec.rb +0 -0
- data/spec/unit/property/ordered_list_spec.rb +0 -0
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +59 -0
- data/spec/unit/provider/cisco_spec.rb +0 -0
- data/spec/unit/provider/command_spec.rb +0 -0
- data/spec/unit/provider/cron/crontab_spec.rb +0 -0
- data/spec/unit/provider/cron/parsed_spec.rb +1 -0
- data/spec/unit/provider/exec/posix_spec.rb +0 -0
- data/spec/unit/provider/exec/shell_spec.rb +0 -0
- data/spec/unit/provider/exec/windows_spec.rb +0 -0
- data/spec/unit/provider/exec_spec.rb +0 -0
- data/spec/unit/provider/file/posix_spec.rb +0 -0
- data/spec/unit/provider/file/windows_spec.rb +0 -0
- data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
- data/spec/unit/provider/group/groupadd_spec.rb +0 -0
- data/spec/unit/provider/group/ldap_spec.rb +0 -0
- data/spec/unit/provider/group/pw_spec.rb +0 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +73 -17
- data/spec/unit/provider/host/parsed_spec.rb +0 -0
- data/spec/unit/provider/interface/cisco_spec.rb +0 -0
- data/spec/unit/provider/ldap_spec.rb +0 -0
- data/spec/unit/provider/macauthorization_spec.rb +5 -2
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +0 -0
- data/spec/unit/provider/mount/parsed_spec.rb +31 -5
- data/spec/unit/provider/mount_spec.rb +0 -0
- data/spec/unit/provider/naginator_spec.rb +0 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +14 -19
- data/spec/unit/provider/nameservice_spec.rb +0 -0
- data/spec/unit/provider/network_device_spec.rb +0 -0
- data/spec/unit/provider/package/aix_spec.rb +0 -0
- data/spec/unit/provider/package/appdmg_spec.rb +3 -3
- data/spec/unit/provider/package/apt_spec.rb +5 -0
- data/spec/unit/provider/package/aptitude_spec.rb +0 -0
- data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
- data/spec/unit/provider/package/base_spec.rb +18 -0
- data/spec/unit/provider/package/dnf_spec.rb +108 -0
- data/spec/unit/provider/package/dpkg_spec.rb +0 -0
- data/spec/unit/provider/package/freebsd_spec.rb +0 -0
- data/spec/unit/provider/package/gem_spec.rb +77 -0
- data/spec/unit/provider/package/hpux_spec.rb +0 -0
- data/spec/unit/provider/package/macports_spec.rb +0 -0
- data/spec/unit/provider/package/nim_spec.rb +6 -6
- data/spec/unit/provider/package/openbsd_spec.rb +0 -0
- data/spec/unit/provider/package/opkg_spec.rb +0 -0
- data/spec/unit/provider/package/pacman_spec.rb +55 -0
- data/spec/unit/provider/package/pip3_spec.rb +22 -0
- data/spec/unit/provider/package/pip_spec.rb +159 -46
- data/spec/unit/provider/package/pkg_spec.rb +0 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +35 -8
- data/spec/unit/provider/package/pkgin_spec.rb +23 -13
- data/spec/unit/provider/package/pkgng_spec.rb +174 -0
- data/spec/unit/provider/package/pkgutil_spec.rb +0 -0
- data/spec/unit/provider/package/puppet_gem_spec.rb +0 -0
- data/spec/unit/provider/package/rpm_spec.rb +160 -3
- data/spec/unit/provider/package/sun_spec.rb +0 -0
- data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
- data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
- data/spec/unit/provider/package/windows/package_spec.rb +41 -0
- data/spec/unit/provider/package/windows_spec.rb +0 -0
- data/spec/unit/provider/package/yum_spec.rb +81 -147
- data/spec/unit/provider/package/zypper_spec.rb +64 -19
- data/spec/unit/provider/parsedfile_spec.rb +0 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +322 -70
- data/spec/unit/provider/selboolean_spec.rb +0 -0
- data/spec/unit/provider/selmodule_spec.rb +0 -0
- data/spec/unit/provider/service/base_spec.rb +38 -27
- data/spec/unit/provider/service/bsd_spec.rb +130 -0
- data/spec/unit/provider/service/daemontools_spec.rb +0 -0
- data/spec/unit/provider/service/debian_spec.rb +29 -0
- data/spec/unit/provider/service/freebsd_spec.rb +17 -0
- data/spec/unit/provider/service/gentoo_spec.rb +2 -0
- data/spec/unit/provider/service/init_spec.rb +35 -1
- data/spec/unit/provider/service/launchd_spec.rb +89 -21
- data/spec/unit/provider/service/openbsd_spec.rb +1 -0
- data/spec/unit/provider/service/openrc_spec.rb +1 -0
- data/spec/unit/provider/service/openwrt_spec.rb +0 -0
- data/spec/unit/provider/service/rcng_spec.rb +41 -0
- data/spec/unit/provider/service/redhat_spec.rb +9 -1
- data/spec/unit/provider/service/runit_spec.rb +0 -0
- data/spec/unit/provider/service/smf_spec.rb +43 -6
- data/spec/unit/provider/service/src_spec.rb +20 -4
- data/spec/unit/provider/service/systemd_spec.rb +169 -37
- data/spec/unit/provider/service/upstart_spec.rb +58 -0
- data/spec/unit/provider/service/windows_spec.rb +0 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +42 -18
- data/spec/unit/provider/user/directoryservice_spec.rb +40 -59
- data/spec/unit/provider/user/hpux_spec.rb +0 -0
- data/spec/unit/provider/user/ldap_spec.rb +0 -0
- data/spec/unit/provider/user/openbsd_spec.rb +0 -0
- data/spec/unit/provider/user/pw_spec.rb +0 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +0 -0
- data/spec/unit/provider/user/useradd_spec.rb +0 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +137 -7
- data/spec/unit/provider/vlan/cisco_spec.rb +0 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +16 -0
- data/spec/unit/provider/zfs/zfs_spec.rb +0 -0
- data/spec/unit/provider/zone/solaris_spec.rb +64 -12
- data/spec/unit/provider/zpool/zpool_spec.rb +0 -0
- data/spec/unit/provider_spec.rb +0 -0
- data/spec/unit/puppet_spec.rb +1 -1
- data/spec/unit/relationship_spec.rb +0 -0
- data/spec/unit/reports/http_spec.rb +0 -0
- data/spec/unit/reports/store_spec.rb +0 -0
- data/spec/unit/reports_spec.rb +10 -0
- data/spec/unit/resource/capability_finder_spec.rb +77 -0
- data/spec/unit/resource/catalog_spec.rb +95 -8
- data/spec/unit/resource/status_spec.rb +0 -0
- data/spec/unit/resource/type_collection_helper_spec.rb +0 -0
- data/spec/unit/resource/type_collection_spec.rb +23 -2
- data/spec/unit/resource/type_spec.rb +150 -8
- data/spec/unit/resource_spec.rb +115 -48
- data/spec/unit/settings/directory_setting_spec.rb +0 -0
- data/spec/unit/settings/duration_setting_spec.rb +0 -0
- data/spec/unit/settings/environment_conf_spec.rb +18 -1
- data/spec/unit/settings/file_setting_spec.rb +37 -0
- data/spec/unit/settings/path_setting_spec.rb +0 -0
- data/spec/unit/settings/priority_setting_spec.rb +0 -0
- data/spec/unit/settings_spec.rb +103 -3
- data/spec/unit/ssl/base_spec.rb +0 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +5 -3
- data/spec/unit/ssl/certificate_factory_spec.rb +0 -0
- data/spec/unit/ssl/certificate_request_spec.rb +0 -0
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +3 -3
- data/spec/unit/ssl/certificate_spec.rb +0 -0
- data/spec/unit/ssl/configuration_spec.rb +0 -0
- data/spec/unit/ssl/host_spec.rb +2 -2
- data/spec/unit/ssl/inventory_spec.rb +0 -0
- data/spec/unit/ssl/key_spec.rb +0 -0
- data/spec/unit/ssl/oids_spec.rb +8 -0
- data/spec/unit/status_spec.rb +0 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +120 -32
- data/spec/unit/transaction/event_manager_spec.rb +0 -0
- data/spec/unit/transaction/event_spec.rb +0 -0
- data/spec/unit/transaction/report_spec.rb +51 -1
- data/spec/unit/transaction/resource_harness_spec.rb +0 -47
- data/spec/unit/transaction_spec.rb +12 -0
- data/spec/unit/type/augeas_spec.rb +0 -0
- data/spec/unit/type/component_spec.rb +0 -0
- data/spec/unit/type/computer_spec.rb +0 -0
- data/spec/unit/type/cron_spec.rb +0 -0
- data/spec/unit/type/exec_spec.rb +16 -8
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/checksum_value_spec.rb +286 -0
- data/spec/unit/type/file/content_spec.rb +12 -193
- data/spec/unit/type/file/ctime_spec.rb +0 -0
- data/spec/unit/type/file/ensure_spec.rb +0 -0
- data/spec/unit/type/file/group_spec.rb +0 -0
- data/spec/unit/type/file/mode_spec.rb +0 -0
- data/spec/unit/type/file/mtime_spec.rb +0 -0
- data/spec/unit/type/file/owner_spec.rb +0 -0
- data/spec/unit/type/file/selinux_spec.rb +0 -0
- data/spec/unit/type/file/source_spec.rb +211 -119
- data/spec/unit/type/file/type_spec.rb +0 -0
- data/spec/unit/type/file_spec.rb +133 -34
- data/spec/unit/type/filebucket_spec.rb +0 -0
- data/spec/unit/type/group_spec.rb +0 -0
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/interface_spec.rb +32 -0
- data/spec/unit/type/k5login_spec.rb +0 -0
- data/spec/unit/type/macauthorization_spec.rb +4 -1
- data/spec/unit/type/mailalias_spec.rb +0 -0
- data/spec/unit/type/maillist_spec.rb +0 -0
- data/spec/unit/type/mcx_spec.rb +0 -0
- data/spec/unit/type/mount_spec.rb +59 -10
- data/spec/unit/type/nagios_spec.rb +0 -0
- data/spec/unit/type/noop_metaparam_spec.rb +0 -0
- data/spec/unit/type/package/package_settings_spec.rb +0 -0
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/resources_spec.rb +0 -0
- data/spec/unit/type/schedule_spec.rb +0 -0
- data/spec/unit/type/selboolean_spec.rb +0 -0
- data/spec/unit/type/selmodule_spec.rb +0 -0
- data/spec/unit/type/service_spec.rb +21 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +0 -0
- data/spec/unit/type/sshkey_spec.rb +0 -0
- data/spec/unit/type/stage_spec.rb +0 -0
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/user_spec.rb +14 -7
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type/whit_spec.rb +0 -0
- data/spec/unit/type/yumrepo_spec.rb +2 -2
- data/spec/unit/type/zfs_spec.rb +0 -0
- data/spec/unit/type/zone_spec.rb +0 -0
- data/spec/unit/type/zpool_spec.rb +0 -0
- data/spec/unit/type_spec.rb +15 -1
- data/spec/unit/util/autoload_spec.rb +0 -0
- data/spec/unit/util/backups_spec.rb +0 -0
- data/spec/unit/util/checksums_spec.rb +0 -0
- data/spec/unit/util/colors_spec.rb +0 -0
- data/spec/unit/util/command_line_spec.rb +0 -0
- data/spec/unit/util/constant_inflector_spec.rb +0 -0
- data/spec/unit/util/diff_spec.rb +0 -0
- data/spec/unit/util/errors_spec.rb +0 -0
- data/spec/unit/util/execution_spec.rb +0 -0
- data/spec/unit/util/execution_stub_spec.rb +0 -0
- data/spec/unit/util/feature_spec.rb +1 -1
- data/spec/unit/util/filetype_spec.rb +1 -1
- data/spec/unit/util/http_proxy_spec.rb +87 -0
- data/spec/unit/util/ldap/connection_spec.rb +0 -0
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/ldap/manager_spec.rb +0 -0
- data/spec/unit/util/log/destinations_spec.rb +0 -2
- data/spec/unit/util/log_spec.rb +125 -1
- data/spec/unit/util/logging_spec.rb +69 -0
- data/spec/unit/util/metric_spec.rb +0 -0
- data/spec/unit/util/monkey_patches_spec.rb +79 -3
- data/spec/unit/util/multi_match_spec.rb +39 -0
- data/spec/unit/util/nagios_maker_spec.rb +0 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +253 -216
- data/spec/unit/util/network_device/cisco/facts_spec.rb +0 -0
- data/spec/unit/util/network_device/cisco/interface_spec.rb +0 -0
- data/spec/unit/util/network_device/config_spec.rb +0 -0
- data/spec/unit/util/network_device/ipcalc_spec.rb +0 -0
- data/spec/unit/util/network_device/transport/base_spec.rb +0 -0
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -1
- data/spec/unit/util/network_device/transport/telnet_spec.rb +60 -58
- data/spec/unit/util/network_device_spec.rb +1 -1
- data/spec/unit/util/package_spec.rb +0 -0
- data/spec/unit/util/plist_spec.rb +110 -0
- data/spec/unit/util/posix_spec.rb +0 -0
- data/spec/unit/util/rdoc_spec.rb +0 -0
- data/spec/unit/util/resource_template_spec.rb +2 -2
- data/spec/unit/util/retry_action_spec.rb +0 -0
- data/spec/unit/util/run_mode_spec.rb +27 -3
- data/spec/unit/util/selinux_spec.rb +0 -0
- data/spec/unit/util/splayer_spec.rb +45 -0
- data/spec/unit/util/storage_spec.rb +5 -1
- data/spec/unit/util/suidmanager_spec.rb +0 -0
- data/spec/unit/util/symbolic_file_mode_spec.rb +0 -0
- data/spec/unit/util/tagging_spec.rb +0 -0
- data/spec/unit/util/user_attr_spec.rb +0 -0
- data/spec/unit/util/warnings_spec.rb +0 -0
- data/spec/unit/util/windows/adsi_spec.rb +175 -60
- data/spec/unit/util/windows/api_types_spec.rb +42 -0
- data/spec/unit/util/windows/file_spec.rb +34 -0
- data/spec/unit/util/windows/root_certs_spec.rb +0 -0
- data/spec/unit/util/windows/security_descriptor_spec.rb +3 -3
- data/spec/unit/util/windows/sid_spec.rb +48 -21
- data/spec/unit/util_spec.rb +144 -15
- data/spec/watchr.rb +0 -0
- data/tasks/cfpropertylist.rake +15 -0
- metadata +3427 -2981
- checksums.yaml +0 -7
- data/ext/puppet-nm-dispatcher +0 -13
- data/ext/systemd/puppetmaster.service +0 -11
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/lib/puppet/pops/types/types_meta.rb +0 -223
- data/lib/puppet/vendor/load_plist.rb +0 -1
- data/lib/puppet/vendor/plist/CHANGELOG +0 -82
- data/lib/puppet/vendor/plist/MIT-LICENSE +0 -21
- data/lib/puppet/vendor/plist/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/plist/README +0 -36
- data/lib/puppet/vendor/plist/Rakefile +0 -144
- data/lib/puppet/vendor/plist/docs/USAGE +0 -104
- data/lib/puppet/vendor/plist/docs/jamis-template.rb +0 -591
- data/lib/puppet/vendor/plist/lib/plist/generator.rb +0 -224
- data/lib/puppet/vendor/plist/lib/plist/parser.rb +0 -225
- data/lib/puppet/vendor/plist/lib/plist.rb +0 -22
- data/lib/puppet/vendor/plist/test/assets/AlbumData.xml +0 -203
- data/lib/puppet/vendor/plist/test/assets/Cookies.plist +0 -104
- data/lib/puppet/vendor/plist/test/assets/commented.plist +0 -9
- data/lib/puppet/vendor/plist/test/assets/example_data.bin +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.jpg +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.plist +0 -259
- data/lib/puppet/vendor/plist/test/assets/test_data_elements.plist +0 -24
- data/lib/puppet/vendor/plist/test/assets/test_empty_key.plist +0 -13
- data/lib/puppet/vendor/plist/test/test_data_elements.rb +0 -115
- data/lib/puppet/vendor/plist/test/test_generator.rb +0 -59
- data/lib/puppet/vendor/plist/test/test_generator_basic_types.rb +0 -58
- data/lib/puppet/vendor/plist/test/test_generator_collections.rb +0 -82
- data/lib/puppet/vendor/plist/test/test_parser.rb +0 -90
- data/spec/integration/data_binding.rb +0 -104
- data/spec/integration/provider/package_spec.rb +0 -33
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{usee → modules/usee}/lib/puppet/functions/usee/callee.rb +0 -0
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/lib/puppet/functions/user/caller.rb +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
module Puppet::Pops
|
|
2
|
+
module Types
|
|
1
3
|
# The TypeCalculator can answer questions about puppet types.
|
|
2
4
|
#
|
|
3
5
|
# The Puppet type system is primarily based on sub-classing. When asking the type calculator to infer types from Ruby in general, it
|
|
@@ -41,8 +43,8 @@
|
|
|
41
43
|
#
|
|
42
44
|
# Creation of Type instances
|
|
43
45
|
# --------------------------
|
|
44
|
-
# Instance of the classes in the {
|
|
45
|
-
# to use the {
|
|
46
|
+
# Instance of the classes in the {Types type model} are used to denote a specific type. It is most convenient
|
|
47
|
+
# to use the {TypeFactory} when creating instances.
|
|
46
48
|
#
|
|
47
49
|
# @note
|
|
48
50
|
# In general, new instances of the wanted type should be created as they are assigned to models using containment, and a
|
|
@@ -82,9 +84,9 @@
|
|
|
82
84
|
# no instances present in the first place. If however the classes are not present, the type
|
|
83
85
|
# calculator will fall back and state that the two types at least have Any in common.
|
|
84
86
|
#
|
|
85
|
-
# @see
|
|
86
|
-
# @see
|
|
87
|
-
# @see
|
|
87
|
+
# @see TypeFactory for how to create instances of types
|
|
88
|
+
# @see TypeParser how to construct a type instance from a String
|
|
89
|
+
# @see Types for details about the type model
|
|
88
90
|
#
|
|
89
91
|
# Using the Type Calculator
|
|
90
92
|
# -----
|
|
@@ -96,9 +98,7 @@
|
|
|
96
98
|
#
|
|
97
99
|
# @api public
|
|
98
100
|
#
|
|
99
|
-
class
|
|
100
|
-
|
|
101
|
-
Types = Puppet::Pops::Types
|
|
101
|
+
class TypeCalculator
|
|
102
102
|
|
|
103
103
|
# @api public
|
|
104
104
|
def self.assignable?(t1, t2)
|
|
@@ -106,8 +106,8 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
# Answers, does the given callable accept the arguments given in args (an array or a tuple)
|
|
109
|
-
# @param callable [
|
|
110
|
-
# @param args [
|
|
109
|
+
# @param callable [PCallableType] - the callable
|
|
110
|
+
# @param args [PArrayType, PTupleType] args optionally including a lambda callable at the end
|
|
111
111
|
# @return [Boolan] true if the callable accepts the arguments
|
|
112
112
|
#
|
|
113
113
|
# @api public
|
|
@@ -116,13 +116,14 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
# Produces a String representation of the given type.
|
|
119
|
-
# @param t [
|
|
119
|
+
# @param t [PAnyType] the type to produce a string form
|
|
120
120
|
# @return [String] the type in string form
|
|
121
121
|
#
|
|
122
122
|
# @api public
|
|
123
123
|
#
|
|
124
124
|
def self.string(t)
|
|
125
|
-
|
|
125
|
+
Puppet.deprecation_warning('TypeCalculator.string is deprecated. Use TypeFormatter')
|
|
126
|
+
TypeFormatter.string(t)
|
|
126
127
|
end
|
|
127
128
|
|
|
128
129
|
# @api public
|
|
@@ -131,8 +132,8 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
131
132
|
end
|
|
132
133
|
|
|
133
134
|
# @api public
|
|
134
|
-
def self.generalize
|
|
135
|
-
singleton.generalize
|
|
135
|
+
def self.generalize(o)
|
|
136
|
+
singleton.generalize(o)
|
|
136
137
|
end
|
|
137
138
|
|
|
138
139
|
# @api public
|
|
@@ -142,94 +143,33 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
142
143
|
|
|
143
144
|
# @api public
|
|
144
145
|
def self.debug_string(t)
|
|
145
|
-
|
|
146
|
+
Puppet.deprecation_warning('TypeCalculator.debug_string is deprecated. Use TypeFormatter')
|
|
147
|
+
TypeFormatter.debug_string(t)
|
|
146
148
|
end
|
|
147
149
|
|
|
148
150
|
# @api public
|
|
149
151
|
def self.enumerable(t)
|
|
150
|
-
|
|
152
|
+
Puppet.deprecation_warning('TypeCalculator.enumerable is deprecated. Use iterable')
|
|
153
|
+
singleton.iterable(t)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# @api public
|
|
157
|
+
def self.iterable(t)
|
|
158
|
+
singleton.iterable(t)
|
|
151
159
|
end
|
|
152
160
|
|
|
161
|
+
# @return [TypeCalculator] the singleton instance
|
|
162
|
+
#
|
|
153
163
|
# @api private
|
|
154
|
-
def self.singleton
|
|
164
|
+
def self.singleton
|
|
155
165
|
@tc_instance ||= new
|
|
156
166
|
end
|
|
157
167
|
|
|
158
168
|
# @api public
|
|
159
169
|
#
|
|
160
170
|
def initialize
|
|
161
|
-
@@
|
|
162
|
-
@@
|
|
163
|
-
@@infer_set_visitor ||= Puppet::Pops::Visitor.new(nil,"infer_set",0,0)
|
|
164
|
-
@@instance_of_visitor ||= Puppet::Pops::Visitor.new(nil,"instance_of",1,1)
|
|
165
|
-
@@string_visitor ||= Puppet::Pops::Visitor.new(nil,"string",0,0)
|
|
166
|
-
@@inspect_visitor ||= Puppet::Pops::Visitor.new(nil,"debug_string",0,0)
|
|
167
|
-
@@enumerable_visitor ||= Puppet::Pops::Visitor.new(nil,"enumerable",0,0)
|
|
168
|
-
@@extract_visitor ||= Puppet::Pops::Visitor.new(nil,"extract",0,0)
|
|
169
|
-
@@generalize_visitor ||= Puppet::Pops::Visitor.new(nil,"generalize",0,0)
|
|
170
|
-
@@callable_visitor ||= Puppet::Pops::Visitor.new(nil,"callable",1,1)
|
|
171
|
-
|
|
172
|
-
da = Types::PArrayType.new()
|
|
173
|
-
da.element_type = Types::PDataType.new()
|
|
174
|
-
@data_array = da
|
|
175
|
-
|
|
176
|
-
h = Types::PHashType.new()
|
|
177
|
-
h.element_type = Types::PDataType.new()
|
|
178
|
-
h.key_type = Types::PScalarType.new()
|
|
179
|
-
@data_hash = h
|
|
180
|
-
|
|
181
|
-
@data_t = Types::PDataType.new()
|
|
182
|
-
@scalar_t = Types::PScalarType.new()
|
|
183
|
-
@numeric_t = Types::PNumericType.new()
|
|
184
|
-
@t = Types::PAnyType.new()
|
|
185
|
-
|
|
186
|
-
# Data accepts a Tuple that has 0-infinity Data compatible entries (e.g. a Tuple equivalent to Array).
|
|
187
|
-
data_tuple = Types::PTupleType.new()
|
|
188
|
-
data_tuple.addTypes(Types::PDataType.new())
|
|
189
|
-
data_tuple.size_type = Types::PIntegerType.new()
|
|
190
|
-
data_tuple.size_type.from = 0
|
|
191
|
-
data_tuple.size_type.to = nil # infinity
|
|
192
|
-
@data_tuple_t = data_tuple
|
|
193
|
-
|
|
194
|
-
# Variant type compatible with Data
|
|
195
|
-
data_variant = Types::PVariantType.new()
|
|
196
|
-
data_variant.addTypes(@data_hash.copy)
|
|
197
|
-
data_variant.addTypes(@data_array.copy)
|
|
198
|
-
data_variant.addTypes(Types::PScalarType.new)
|
|
199
|
-
data_variant.addTypes(Types::PUndefType.new)
|
|
200
|
-
data_variant.addTypes(@data_tuple_t.copy)
|
|
201
|
-
@data_variant_t = data_variant
|
|
202
|
-
|
|
203
|
-
collection_default_size = Types::PIntegerType.new()
|
|
204
|
-
collection_default_size.from = 0
|
|
205
|
-
collection_default_size.to = nil # infinity
|
|
206
|
-
@collection_default_size_t = collection_default_size
|
|
207
|
-
|
|
208
|
-
non_empty_string = Types::PStringType.new
|
|
209
|
-
non_empty_string.size_type = Types::PIntegerType.new()
|
|
210
|
-
non_empty_string.size_type.from = 1
|
|
211
|
-
non_empty_string.size_type.to = nil # infinity
|
|
212
|
-
@non_empty_string_t = non_empty_string
|
|
213
|
-
|
|
214
|
-
@nil_t = Types::PUndefType.new
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# Convenience method to get a data type for comparisons
|
|
218
|
-
# @api private the returned value may not be contained in another element
|
|
219
|
-
#
|
|
220
|
-
def data
|
|
221
|
-
@data_t
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
# Convenience method to get a variant compatible with the Data type.
|
|
225
|
-
# @api private the returned value may not be contained in another element
|
|
226
|
-
#
|
|
227
|
-
def data_variant
|
|
228
|
-
@data_variant_t
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
def self.data_variant
|
|
232
|
-
singleton.data_variant
|
|
171
|
+
@@infer_visitor ||= Visitor.new(nil, 'infer',0,0)
|
|
172
|
+
@@extract_visitor ||= Visitor.new(nil, 'extract',0,0)
|
|
233
173
|
end
|
|
234
174
|
|
|
235
175
|
# Answers the question 'is it possible to inject an instance of the given class'
|
|
@@ -242,13 +182,13 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
242
182
|
#
|
|
243
183
|
def injectable_class(klazz)
|
|
244
184
|
# Handle case when we get a PType instead of a class
|
|
245
|
-
if klazz.is_a?(
|
|
246
|
-
klazz =
|
|
185
|
+
if klazz.is_a?(PRuntimeType)
|
|
186
|
+
klazz = ClassLoader.provide(klazz)
|
|
247
187
|
end
|
|
248
188
|
|
|
249
189
|
# data types can not be injected (check again, it is not safe to assume that given RubyRuntime klazz arg was ok)
|
|
250
|
-
return false unless type(klazz).is_a?(
|
|
251
|
-
if (klazz.respond_to?(:inject) && klazz.method(:inject).arity
|
|
190
|
+
return false unless type(klazz).is_a?(PRuntimeType)
|
|
191
|
+
if (klazz.respond_to?(:inject) && klazz.method(:inject).arity == -4) || klazz.instance_method(:initialize).arity == 0
|
|
252
192
|
klazz
|
|
253
193
|
else
|
|
254
194
|
nil
|
|
@@ -261,40 +201,33 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
261
201
|
# @api public
|
|
262
202
|
#
|
|
263
203
|
def assignable?(t, t2)
|
|
264
|
-
if t.is_a?(
|
|
204
|
+
if t.is_a?(Module)
|
|
265
205
|
t = type(t)
|
|
266
206
|
end
|
|
267
|
-
|
|
268
|
-
if t2.is_a?(Class)
|
|
269
|
-
t2 = type(t2)
|
|
270
|
-
end
|
|
271
|
-
# Unit can be assigned to anything
|
|
272
|
-
return true if t2.class == Types::PUnitType
|
|
273
|
-
|
|
274
|
-
if t2.class == Types::PVariantType
|
|
275
|
-
# Assignable if all contained types are assignable
|
|
276
|
-
t2.types.all? { |vt| @@assignable_visitor.visit_this_1(self, t, vt) }
|
|
277
|
-
else
|
|
278
|
-
@@assignable_visitor.visit_this_1(self, t, t2)
|
|
279
|
-
end
|
|
207
|
+
t.is_a?(PAnyType) ? t.assignable?(t2) : false
|
|
280
208
|
end
|
|
281
209
|
|
|
282
|
-
# Returns an
|
|
210
|
+
# Returns an iterable if the t represents something that can be iterated
|
|
283
211
|
def enumerable(t)
|
|
284
|
-
|
|
212
|
+
Puppet.deprecation_warning('TypeCalculator.enumerable is deprecated. Use iterable')
|
|
213
|
+
iterable(t)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Returns an iterable if the t represents something that can be iterated
|
|
217
|
+
def iterable(t)
|
|
218
|
+
# Create an iterable on the type if possible
|
|
219
|
+
Iterable.on(t)
|
|
285
220
|
end
|
|
286
221
|
|
|
287
222
|
# Answers, does the given callable accept the arguments given in args (an array or a tuple)
|
|
288
223
|
#
|
|
289
224
|
def callable?(callable, args)
|
|
290
|
-
|
|
291
|
-
# Note that polymorphism is for the args type, the callable is always a callable
|
|
292
|
-
@@callable_visitor.visit_this_1(self, args, callable)
|
|
225
|
+
callable.is_a?(PAnyType) && callable.callable?(args)
|
|
293
226
|
end
|
|
294
227
|
|
|
295
228
|
# Answers if the two given types describe the same type
|
|
296
229
|
def equals(left, right)
|
|
297
|
-
return false unless left.is_a?(
|
|
230
|
+
return false unless left.is_a?(PAnyType) && right.is_a?(PAnyType)
|
|
298
231
|
# Types compare per class only - an extra test must be made if the are mutually assignable
|
|
299
232
|
# to find all types that represent the same type of instance
|
|
300
233
|
#
|
|
@@ -302,77 +235,46 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
302
235
|
end
|
|
303
236
|
|
|
304
237
|
# Answers 'what is the Puppet Type corresponding to the given Ruby class'
|
|
305
|
-
# @param c [
|
|
238
|
+
# @param c [Module] the class for which a puppet type is wanted
|
|
306
239
|
# @api public
|
|
307
240
|
#
|
|
308
241
|
def type(c)
|
|
309
|
-
raise ArgumentError,
|
|
242
|
+
raise ArgumentError, 'Argument must be a Module' unless c.is_a? Module
|
|
310
243
|
|
|
311
244
|
# Can't use a visitor here since we don't have an instance of the class
|
|
312
245
|
case
|
|
313
246
|
when c <= Integer
|
|
314
|
-
type =
|
|
247
|
+
type = PIntegerType::DEFAULT
|
|
315
248
|
when c == Float
|
|
316
|
-
type =
|
|
249
|
+
type = PFloatType::DEFAULT
|
|
317
250
|
when c == Numeric
|
|
318
|
-
type =
|
|
251
|
+
type = PNumericType::DEFAULT
|
|
319
252
|
when c == String
|
|
320
|
-
type =
|
|
253
|
+
type = PStringType::DEFAULT
|
|
321
254
|
when c == Regexp
|
|
322
|
-
type =
|
|
255
|
+
type = PRegexpType::DEFAULT
|
|
323
256
|
when c == NilClass
|
|
324
|
-
type =
|
|
257
|
+
type = PUndefType::DEFAULT
|
|
325
258
|
when c == FalseClass, c == TrueClass
|
|
326
|
-
type =
|
|
259
|
+
type = PBooleanType::DEFAULT
|
|
327
260
|
when c == Class
|
|
328
|
-
type =
|
|
261
|
+
type = PType::DEFAULT
|
|
329
262
|
when c == Array
|
|
330
263
|
# Assume array of data values
|
|
331
|
-
type =
|
|
332
|
-
type.element_type = Types::PDataType.new()
|
|
264
|
+
type = PArrayType::DATA
|
|
333
265
|
when c == Hash
|
|
334
266
|
# Assume hash with scalar keys and data values
|
|
335
|
-
type =
|
|
336
|
-
|
|
337
|
-
type
|
|
338
|
-
else
|
|
339
|
-
type = Types::PRuntimeType.new(:runtime => :ruby, :runtime_type_name => c.name)
|
|
267
|
+
type = PHashType::DATA
|
|
268
|
+
else
|
|
269
|
+
type = PRuntimeType.new(:ruby, c.name)
|
|
340
270
|
end
|
|
341
271
|
type
|
|
342
272
|
end
|
|
343
273
|
|
|
344
|
-
# Generalizes value specific types. The
|
|
274
|
+
# Generalizes value specific types. The generalized type is returned.
|
|
345
275
|
# @api public
|
|
346
|
-
def generalize
|
|
347
|
-
|
|
348
|
-
o.eAllContents.each { |x| @@generalize_visitor.visit_this_0(self, x) }
|
|
349
|
-
o
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
def generalize_Object(o)
|
|
353
|
-
# do nothing, there is nothing to change for most types
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
def generalize_PStringType(o)
|
|
357
|
-
o.values = []
|
|
358
|
-
o.size_type = nil
|
|
359
|
-
[]
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
def generalize_PCollectionType(o)
|
|
363
|
-
# erase the size constraint from Array and Hash (if one exists, it is transformed to -Infinity - + Infinity, which is
|
|
364
|
-
# not desirable.
|
|
365
|
-
o.size_type = nil
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
def generalize_PFloatType(o)
|
|
369
|
-
o.to = nil
|
|
370
|
-
o.from = nil
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
def generalize_PIntegerType(o)
|
|
374
|
-
o.to = nil
|
|
375
|
-
o.from = nil
|
|
276
|
+
def generalize(o)
|
|
277
|
+
o.is_a?(PAnyType) ? o.generalize : o
|
|
376
278
|
end
|
|
377
279
|
|
|
378
280
|
# Answers 'what is the single common Puppet Type describing o', or if o is an Array or Hash, what is the
|
|
@@ -380,135 +282,72 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
380
282
|
# @api public
|
|
381
283
|
#
|
|
382
284
|
def infer(o)
|
|
383
|
-
|
|
285
|
+
# Optimize the most common cases into direct calls.
|
|
286
|
+
case o
|
|
287
|
+
when String
|
|
288
|
+
infer_String(o)
|
|
289
|
+
when Integer
|
|
290
|
+
infer_Integer(o)
|
|
291
|
+
when Array
|
|
292
|
+
infer_Array(o)
|
|
293
|
+
when Hash
|
|
294
|
+
infer_Hash(o)
|
|
295
|
+
when Evaluator::PuppetProc
|
|
296
|
+
infer_PuppetProc(o)
|
|
297
|
+
else
|
|
298
|
+
@@infer_visitor.visit_this_0(self, o)
|
|
299
|
+
end
|
|
384
300
|
end
|
|
385
301
|
|
|
386
302
|
def infer_generic(o)
|
|
387
|
-
|
|
388
|
-
result
|
|
303
|
+
generalize(infer(o))
|
|
389
304
|
end
|
|
390
305
|
|
|
391
306
|
# Answers 'what is the set of Puppet Types of o'
|
|
392
307
|
# @api public
|
|
393
308
|
#
|
|
394
309
|
def infer_set(o)
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return false if (o.nil?) && t.class != Types::PAnyType
|
|
405
|
-
assignable?(t, infer(o))
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
# Anything is an instance of Unit
|
|
409
|
-
# @api private
|
|
410
|
-
def instance_of_PUnitType(t, o)
|
|
411
|
-
true
|
|
412
|
-
end
|
|
413
|
-
|
|
414
|
-
def instance_of_PArrayType(t, o)
|
|
415
|
-
return false unless o.is_a?(Array)
|
|
416
|
-
return false unless o.all? {|element| instance_of(t.element_type, element) }
|
|
417
|
-
size_t = t.size_type || @collection_default_size_t
|
|
418
|
-
# optimize by calling directly
|
|
419
|
-
return instance_of_PIntegerType(size_t, o.size)
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
# @api private
|
|
423
|
-
def instance_of_PIntegerType(t, o)
|
|
424
|
-
return false unless o.is_a?(Integer)
|
|
425
|
-
x = t.from
|
|
426
|
-
x = -Float::INFINITY if x.nil? || x == :default
|
|
427
|
-
y = t.to
|
|
428
|
-
y = Float::INFINITY if y.nil? || y == :default
|
|
429
|
-
return x < y ? x <= o && y >= o : y <= o && x >= o
|
|
430
|
-
end
|
|
431
|
-
|
|
432
|
-
# @api private
|
|
433
|
-
def instance_of_PStringType(t, o)
|
|
434
|
-
return false unless o.is_a?(String)
|
|
435
|
-
# true if size compliant
|
|
436
|
-
size_t = t.size_type || @collection_default_size_t
|
|
437
|
-
instance_of_PIntegerType(size_t, o.size)
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
def instance_of_PTupleType(t, o)
|
|
441
|
-
return false unless o.is_a?(Array)
|
|
442
|
-
# compute the tuple's min/max size, and check if that size matches
|
|
443
|
-
size_t = t.size_type || Puppet::Pops::Types::TypeFactory.range(*t.size_range)
|
|
444
|
-
|
|
445
|
-
return false unless instance_of_PIntegerType(size_t, o.size)
|
|
446
|
-
o.each_with_index do |element, index|
|
|
447
|
-
return false unless instance_of(t.types[index] || t.types[-1], element)
|
|
310
|
+
case o
|
|
311
|
+
when Array
|
|
312
|
+
infer_set_Array(o)
|
|
313
|
+
when Hash
|
|
314
|
+
infer_set_Hash(o)
|
|
315
|
+
when Semantic::Version
|
|
316
|
+
infer_set_Version(o)
|
|
317
|
+
else
|
|
318
|
+
infer_set_Object(o)
|
|
448
319
|
end
|
|
449
|
-
true
|
|
450
|
-
end
|
|
451
|
-
|
|
452
|
-
def instance_of_PStructType(t, o)
|
|
453
|
-
return false unless o.is_a?(Hash)
|
|
454
|
-
h = t.hashed_elements
|
|
455
|
-
# all keys must be present and have a value (even if nil/undef)
|
|
456
|
-
(o.keys - h.keys).empty? && h.all? { |k,v| instance_of(v, o[k]) }
|
|
457
|
-
end
|
|
458
|
-
|
|
459
|
-
def instance_of_PHashType(t, o)
|
|
460
|
-
return false unless o.is_a?(Hash)
|
|
461
|
-
key_t = t.key_type
|
|
462
|
-
element_t = t.element_type
|
|
463
|
-
return false unless o.keys.all? {|key| instance_of(key_t, key) } && o.values.all? {|value| instance_of(element_t, value) }
|
|
464
|
-
size_t = t.size_type || @collection_default_size_t
|
|
465
|
-
# optimize by calling directly
|
|
466
|
-
return instance_of_PIntegerType(size_t, o.size)
|
|
467
|
-
end
|
|
468
|
-
|
|
469
|
-
def instance_of_PDataType(t, o)
|
|
470
|
-
instance_of(@data_variant_t, o)
|
|
471
|
-
end
|
|
472
|
-
|
|
473
|
-
def instance_of_PUndefType(t, o)
|
|
474
|
-
o.nil? || o == :undef
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
def instance_of_POptionalType(t, o)
|
|
478
|
-
instance_of_PUndefType(t, o) || instance_of(t.optional_type, o)
|
|
479
|
-
end
|
|
480
|
-
|
|
481
|
-
def instance_of_PVariantType(t, o)
|
|
482
|
-
# instance of variant if o is instance? of any of variant's types
|
|
483
|
-
t.types.any? { |option_t| instance_of(option_t, o) }
|
|
484
320
|
end
|
|
485
321
|
|
|
486
322
|
# Answers 'is o an instance of type t'
|
|
487
323
|
# @api public
|
|
488
324
|
#
|
|
489
325
|
def self.instance?(t, o)
|
|
490
|
-
singleton.
|
|
326
|
+
singleton.instance?(t,o)
|
|
491
327
|
end
|
|
492
328
|
|
|
493
329
|
# Answers 'is o an instance of type t'
|
|
494
330
|
# @api public
|
|
495
331
|
#
|
|
496
332
|
def instance?(t, o)
|
|
497
|
-
|
|
333
|
+
if t.is_a?(Module)
|
|
334
|
+
t = type(t)
|
|
335
|
+
end
|
|
336
|
+
t.is_a?(PAnyType) ? t.instance?(o) : false
|
|
498
337
|
end
|
|
499
338
|
|
|
500
339
|
# Answers if t is a puppet type
|
|
501
340
|
# @api public
|
|
502
341
|
#
|
|
503
342
|
def is_ptype?(t)
|
|
504
|
-
|
|
343
|
+
t.is_a?(PAnyType)
|
|
505
344
|
end
|
|
506
345
|
|
|
507
346
|
# Answers if t represents the puppet type PUndefType
|
|
508
347
|
# @api public
|
|
509
348
|
#
|
|
510
349
|
def is_pnil?(t)
|
|
511
|
-
|
|
350
|
+
t.nil? || t.is_a?(PUndefType)
|
|
512
351
|
end
|
|
513
352
|
|
|
514
353
|
# Answers, 'What is the common type of t1 and t2?'
|
|
@@ -529,9 +368,9 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
529
368
|
end
|
|
530
369
|
|
|
531
370
|
# If either side is Unit, it is the other type
|
|
532
|
-
if t1.is_a?(
|
|
371
|
+
if t1.is_a?(PUnitType)
|
|
533
372
|
return t2
|
|
534
|
-
elsif t2.is_a?(
|
|
373
|
+
elsif t2.is_a?(PUnitType)
|
|
535
374
|
return t1
|
|
536
375
|
end
|
|
537
376
|
|
|
@@ -543,132 +382,103 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
543
382
|
end
|
|
544
383
|
|
|
545
384
|
# when both are arrays, return an array with common element type
|
|
546
|
-
if t1.is_a?(
|
|
547
|
-
|
|
548
|
-
type.element_type = common_type(t1.element_type, t2.element_type)
|
|
549
|
-
return type
|
|
385
|
+
if t1.is_a?(PArrayType) && t2.is_a?(PArrayType)
|
|
386
|
+
return PArrayType.new(common_type(t1.element_type, t2.element_type))
|
|
550
387
|
end
|
|
551
388
|
|
|
552
389
|
# when both are hashes, return a hash with common key- and element type
|
|
553
|
-
if t1.is_a?(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return type
|
|
390
|
+
if t1.is_a?(PHashType) && t2.is_a?(PHashType)
|
|
391
|
+
key_type = common_type(t1.key_type, t2.key_type)
|
|
392
|
+
element_type = common_type(t1.element_type, t2.element_type)
|
|
393
|
+
return PHashType.new(key_type, element_type)
|
|
558
394
|
end
|
|
559
395
|
|
|
560
396
|
# when both are host-classes, reduce to PHostClass[] (since one was not assignable to the other)
|
|
561
|
-
if t1.is_a?(
|
|
562
|
-
return
|
|
397
|
+
if t1.is_a?(PHostClassType) && t2.is_a?(PHostClassType)
|
|
398
|
+
return PHostClassType::DEFAULT
|
|
563
399
|
end
|
|
564
400
|
|
|
565
401
|
# when both are resources, reduce to Resource[T] or Resource[] (since one was not assignable to the other)
|
|
566
|
-
if t1.is_a?(
|
|
567
|
-
result = Types::PResourceType.new()
|
|
402
|
+
if t1.is_a?(PResourceType) && t2.is_a?(PResourceType)
|
|
568
403
|
# only Resource[] unless the type name is the same
|
|
569
|
-
|
|
570
|
-
# the cross assignability test above has already determined that they do not have the same type and title
|
|
571
|
-
return result
|
|
404
|
+
return t1.type_name == t2.type_name ? PResourceType.new(t1.type_name, nil) : PResourceType::DEFAULT
|
|
572
405
|
end
|
|
573
406
|
|
|
574
407
|
# Integers have range, expand the range to the common range
|
|
575
|
-
if t1.is_a?(
|
|
576
|
-
|
|
577
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
578
|
-
t = Types::PIntegerType.new()
|
|
579
|
-
from = [t1range[0], t2range[0]].min
|
|
580
|
-
to = [t1range[1], t2range[1]].max
|
|
581
|
-
t.from = from unless from == Float::INFINITY
|
|
582
|
-
t.to = to unless to == Float::INFINITY
|
|
583
|
-
return t
|
|
408
|
+
if t1.is_a?(PIntegerType) && t2.is_a?(PIntegerType)
|
|
409
|
+
return PIntegerType.new([t1.numeric_from, t2.numeric_from].min, [t1.numeric_to, t2.numeric_to].max)
|
|
584
410
|
end
|
|
585
411
|
|
|
586
412
|
# Floats have range, expand the range to the common range
|
|
587
|
-
if t1.is_a?(
|
|
588
|
-
|
|
589
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
590
|
-
t = Types::PFloatType.new()
|
|
591
|
-
from = [t1range[0], t2range[0]].min
|
|
592
|
-
to = [t1range[1], t2range[1]].max
|
|
593
|
-
t.from = from unless from == Float::INFINITY
|
|
594
|
-
t.to = to unless to == Float::INFINITY
|
|
595
|
-
return t
|
|
413
|
+
if t1.is_a?(PFloatType) && t2.is_a?(PFloatType)
|
|
414
|
+
return PFloatType.new([t1.numeric_from, t2.numeric_from].min, [t1.numeric_to, t2.numeric_to].max)
|
|
596
415
|
end
|
|
597
416
|
|
|
598
|
-
if t1.is_a?(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
return
|
|
417
|
+
if t1.is_a?(PStringType) && t2.is_a?(PStringType)
|
|
418
|
+
common_size_type = common_type(t1.size_type, t2.size_type) unless t1.size_type.nil? || t2.size_type.nil?
|
|
419
|
+
common_strings = t1.values.empty? || t2.values.empty? ? [] : t1.values | t2.values
|
|
420
|
+
return PStringType.new(common_size_type, common_strings)
|
|
602
421
|
end
|
|
603
422
|
|
|
604
|
-
if t1.is_a?(
|
|
605
|
-
|
|
606
|
-
# must make copies since patterns are contained types, not data-types
|
|
607
|
-
t.patterns = (t1.patterns | t2.patterns).map(&:copy)
|
|
608
|
-
return t
|
|
423
|
+
if t1.is_a?(PPatternType) && t2.is_a?(PPatternType)
|
|
424
|
+
return PPatternType.new(t1.patterns | t2.patterns)
|
|
609
425
|
end
|
|
610
426
|
|
|
611
|
-
if t1.is_a?(
|
|
427
|
+
if t1.is_a?(PEnumType) && t2.is_a?(PEnumType)
|
|
612
428
|
# The common type is one that complies with either set
|
|
613
|
-
|
|
614
|
-
t.values = t1.values | t2.values
|
|
615
|
-
return t
|
|
429
|
+
return PEnumType.new(t1.values | t2.values)
|
|
616
430
|
end
|
|
617
431
|
|
|
618
|
-
if t1.is_a?(
|
|
432
|
+
if t1.is_a?(PVariantType) && t2.is_a?(PVariantType)
|
|
619
433
|
# The common type is one that complies with either set
|
|
620
|
-
|
|
621
|
-
t.types = (t1.types | t2.types).map(&:copy)
|
|
622
|
-
return t
|
|
434
|
+
return PVariantType.maybe_create(t1.types | t2.types)
|
|
623
435
|
end
|
|
624
436
|
|
|
625
|
-
if t1.is_a?(
|
|
437
|
+
if t1.is_a?(PRegexpType) && t2.is_a?(PRegexpType)
|
|
626
438
|
# if they were identical, the general rule would return a parameterized regexp
|
|
627
439
|
# since they were not, the result is a generic regexp type
|
|
628
|
-
return
|
|
440
|
+
return PPatternType::DEFAULT
|
|
629
441
|
end
|
|
630
442
|
|
|
631
|
-
if t1.is_a?(
|
|
443
|
+
if t1.is_a?(PCallableType) && t2.is_a?(PCallableType)
|
|
632
444
|
# They do not have the same signature, and one is not assignable to the other,
|
|
633
445
|
# what remains is the most general form of Callable
|
|
634
|
-
return
|
|
446
|
+
return PCallableType::DEFAULT
|
|
635
447
|
end
|
|
636
448
|
|
|
637
449
|
# Common abstract types, from most specific to most general
|
|
638
450
|
if common_numeric?(t1, t2)
|
|
639
|
-
return
|
|
451
|
+
return PNumericType::DEFAULT
|
|
640
452
|
end
|
|
641
453
|
|
|
642
454
|
if common_scalar?(t1, t2)
|
|
643
|
-
return
|
|
455
|
+
return PScalarType::DEFAULT
|
|
644
456
|
end
|
|
645
457
|
|
|
646
458
|
if common_data?(t1,t2)
|
|
647
|
-
return
|
|
459
|
+
return PDataType::DEFAULT
|
|
648
460
|
end
|
|
649
461
|
|
|
650
462
|
# Meta types Type[Integer] + Type[String] => Type[Data]
|
|
651
|
-
if t1.is_a?(
|
|
652
|
-
|
|
653
|
-
type.type = common_type(t1.type, t2.type)
|
|
654
|
-
return type
|
|
463
|
+
if t1.is_a?(PType) && t2.is_a?(PType)
|
|
464
|
+
return PType.new(common_type(t1.type, t2.type))
|
|
655
465
|
end
|
|
656
466
|
|
|
657
467
|
# If both are Runtime types
|
|
658
|
-
if t1.is_a?(
|
|
468
|
+
if t1.is_a?(PRuntimeType) && t2.is_a?(PRuntimeType)
|
|
659
469
|
if t1.runtime == t2.runtime && t1.runtime_type_name == t2.runtime_type_name
|
|
660
470
|
return t1
|
|
661
471
|
end
|
|
662
472
|
# finding the common super class requires that names are resolved to class
|
|
663
473
|
# NOTE: This only supports runtime type of :ruby
|
|
664
|
-
c1 =
|
|
665
|
-
c2 =
|
|
474
|
+
c1 = ClassLoader.provide_from_type(t1)
|
|
475
|
+
c2 = ClassLoader.provide_from_type(t2)
|
|
666
476
|
if c1 && c2
|
|
667
477
|
c2_superclasses = superclasses(c2)
|
|
668
478
|
superclasses(c1).each do|c1_super|
|
|
669
479
|
c2_superclasses.each do |c2_super|
|
|
670
480
|
if c1_super == c2_super
|
|
671
|
-
return
|
|
481
|
+
return PRuntimeType.new(:ruby, c1_super.name)
|
|
672
482
|
end
|
|
673
483
|
end
|
|
674
484
|
end
|
|
@@ -676,9 +486,7 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
676
486
|
end
|
|
677
487
|
|
|
678
488
|
# They better both be Any type, or the wrong thing was asked and nil is returned
|
|
679
|
-
|
|
680
|
-
return Types::PAnyType.new()
|
|
681
|
-
end
|
|
489
|
+
t1.is_a?(PAnyType) && t2.is_a?(PAnyType) ? PAnyType::DEFAULT : nil
|
|
682
490
|
end
|
|
683
491
|
|
|
684
492
|
# Produces the superclasses of the given class, including the class
|
|
@@ -695,14 +503,16 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
695
503
|
# @api public
|
|
696
504
|
#
|
|
697
505
|
def string(t)
|
|
698
|
-
|
|
506
|
+
Puppet.deprecation_warning('TypeCalculator.string is deprecated. Use TypeFormatter')
|
|
507
|
+
TypeFormatter.singleton.string(t)
|
|
699
508
|
end
|
|
700
509
|
|
|
701
510
|
# Produces a debug string representing the type (possibly with more information that the regular string format)
|
|
702
511
|
# @api public
|
|
703
512
|
#
|
|
704
513
|
def debug_string(t)
|
|
705
|
-
|
|
514
|
+
Puppet.deprecation_warning('TypeCalculator.debug_string is deprecated. Use TypeFormatter')
|
|
515
|
+
TypeFormatter.singleton.debug_string(t)
|
|
706
516
|
end
|
|
707
517
|
|
|
708
518
|
|
|
@@ -717,19 +527,24 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
717
527
|
# @api public
|
|
718
528
|
#
|
|
719
529
|
def infer_and_reduce_type(enumerable)
|
|
720
|
-
reduce_type(enumerable.
|
|
530
|
+
reduce_type(enumerable.map {|o| infer(o) })
|
|
721
531
|
end
|
|
722
532
|
|
|
723
|
-
# The type of all
|
|
533
|
+
# The type of all modules is PType
|
|
724
534
|
# @api private
|
|
725
535
|
#
|
|
726
|
-
def
|
|
727
|
-
|
|
536
|
+
def infer_Module(o)
|
|
537
|
+
PType::new(PRuntimeType.new(:ruby, o.name))
|
|
728
538
|
end
|
|
729
539
|
|
|
730
540
|
# @api private
|
|
731
541
|
def infer_Closure(o)
|
|
732
|
-
o.type
|
|
542
|
+
o.type
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
# @api private
|
|
546
|
+
def infer_Iterator(o)
|
|
547
|
+
PIteratorType.new(o.element_type)
|
|
733
548
|
end
|
|
734
549
|
|
|
735
550
|
# @api private
|
|
@@ -739,16 +554,21 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
739
554
|
|
|
740
555
|
# @api private
|
|
741
556
|
def infer_Object(o)
|
|
742
|
-
|
|
557
|
+
if o.is_a?(PuppetObject)
|
|
558
|
+
o._ptype
|
|
559
|
+
else
|
|
560
|
+
name = o.class.name
|
|
561
|
+
ir = Loaders.implementation_registry
|
|
562
|
+
type = ir.nil? ? nil : ir.type_for_module(name)
|
|
563
|
+
type.nil? ? PRuntimeType.new(:ruby, name) : type
|
|
564
|
+
end
|
|
743
565
|
end
|
|
744
566
|
|
|
745
567
|
# The type of all types is PType
|
|
746
568
|
# @api private
|
|
747
569
|
#
|
|
748
570
|
def infer_PAnyType(o)
|
|
749
|
-
|
|
750
|
-
type.type = o.copy
|
|
751
|
-
type
|
|
571
|
+
PType.new(o)
|
|
752
572
|
end
|
|
753
573
|
|
|
754
574
|
# The type of all types is PType
|
|
@@ -756,45 +576,32 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
756
576
|
# @api private
|
|
757
577
|
#
|
|
758
578
|
def infer_PType(o)
|
|
759
|
-
|
|
760
|
-
type.type = o.copy
|
|
761
|
-
type
|
|
579
|
+
PType.new(o)
|
|
762
580
|
end
|
|
763
581
|
|
|
764
582
|
# @api private
|
|
765
583
|
def infer_String(o)
|
|
766
|
-
|
|
767
|
-
t.addValues(o)
|
|
768
|
-
t.size_type = size_as_type(o)
|
|
769
|
-
t
|
|
584
|
+
PStringType.new(size_as_type(o), [o])
|
|
770
585
|
end
|
|
771
586
|
|
|
772
587
|
# @api private
|
|
773
588
|
def infer_Float(o)
|
|
774
|
-
|
|
775
|
-
t.from = o
|
|
776
|
-
t.to = o
|
|
777
|
-
t
|
|
589
|
+
PFloatType.new(o, o)
|
|
778
590
|
end
|
|
779
591
|
|
|
780
592
|
# @api private
|
|
781
593
|
def infer_Integer(o)
|
|
782
|
-
|
|
783
|
-
t.from = o
|
|
784
|
-
t.to = o
|
|
785
|
-
t
|
|
594
|
+
PIntegerType.new(o, o)
|
|
786
595
|
end
|
|
787
596
|
|
|
788
597
|
# @api private
|
|
789
598
|
def infer_Regexp(o)
|
|
790
|
-
|
|
791
|
-
t.pattern = o.source
|
|
792
|
-
t
|
|
599
|
+
PRegexpType.new(o.source)
|
|
793
600
|
end
|
|
794
601
|
|
|
795
602
|
# @api private
|
|
796
603
|
def infer_NilClass(o)
|
|
797
|
-
|
|
604
|
+
PUndefType::DEFAULT
|
|
798
605
|
end
|
|
799
606
|
|
|
800
607
|
# @api private
|
|
@@ -806,16 +613,16 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
806
613
|
case p[0]
|
|
807
614
|
when :rest
|
|
808
615
|
max = :default
|
|
809
|
-
break
|
|
616
|
+
break PAnyType::DEFAULT
|
|
810
617
|
when :req
|
|
811
618
|
min += 1
|
|
812
619
|
end
|
|
813
620
|
max += 1
|
|
814
|
-
|
|
621
|
+
PAnyType::DEFAULT
|
|
815
622
|
end
|
|
816
623
|
mapped_types << min
|
|
817
624
|
mapped_types << max
|
|
818
|
-
|
|
625
|
+
TypeFactory.callable(*mapped_types)
|
|
819
626
|
end
|
|
820
627
|
|
|
821
628
|
# @api private
|
|
@@ -828,7 +635,9 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
828
635
|
def infer_Symbol(o)
|
|
829
636
|
case o
|
|
830
637
|
when :default
|
|
831
|
-
|
|
638
|
+
PDefaultType::DEFAULT
|
|
639
|
+
when :undef
|
|
640
|
+
PUndefType::DEFAULT
|
|
832
641
|
else
|
|
833
642
|
infer_Object(o)
|
|
834
643
|
end
|
|
@@ -836,64 +645,58 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
836
645
|
|
|
837
646
|
# @api private
|
|
838
647
|
def infer_TrueClass(o)
|
|
839
|
-
|
|
648
|
+
PBooleanType::DEFAULT
|
|
840
649
|
end
|
|
841
650
|
|
|
842
651
|
# @api private
|
|
843
652
|
def infer_FalseClass(o)
|
|
844
|
-
|
|
653
|
+
PBooleanType::DEFAULT
|
|
845
654
|
end
|
|
846
655
|
|
|
847
656
|
# @api private
|
|
848
657
|
# A Puppet::Parser::Resource, or Puppet::Resource
|
|
849
658
|
#
|
|
850
659
|
def infer_Resource(o)
|
|
851
|
-
t = Types::PResourceType.new()
|
|
852
|
-
t.type_name = o.type.to_s.downcase
|
|
853
660
|
# Only Puppet::Resource can have a title that is a symbol :undef, a PResource cannot.
|
|
854
661
|
# A mapping must be made to empty string. A nil value will result in an error later
|
|
855
662
|
title = o.title
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
type.type = t
|
|
859
|
-
type
|
|
663
|
+
title = '' if :undef == title
|
|
664
|
+
PType.new(PResourceType.new(o.type.to_s, title))
|
|
860
665
|
end
|
|
861
666
|
|
|
862
667
|
# @api private
|
|
863
668
|
def infer_Array(o)
|
|
864
|
-
type = Types::PArrayType.new()
|
|
865
|
-
type.element_type =
|
|
866
669
|
if o.empty?
|
|
867
|
-
|
|
670
|
+
PArrayType::EMPTY
|
|
868
671
|
else
|
|
869
|
-
infer_and_reduce_type(o)
|
|
672
|
+
PArrayType.new(infer_and_reduce_type(o), size_as_type(o))
|
|
870
673
|
end
|
|
871
|
-
|
|
872
|
-
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
# @api private
|
|
677
|
+
def infer_Version(o)
|
|
678
|
+
PSemVerType::DEFAULT
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
# @api private
|
|
682
|
+
def infer_VersionRange(o)
|
|
683
|
+
PSemVerRangeType::DEFAULT
|
|
873
684
|
end
|
|
874
685
|
|
|
875
686
|
# @api private
|
|
876
687
|
def infer_Hash(o)
|
|
877
|
-
type = Types::PHashType.new()
|
|
878
688
|
if o.empty?
|
|
879
|
-
|
|
880
|
-
etype = Types::PUndefType.new()
|
|
689
|
+
PHashType::EMPTY
|
|
881
690
|
else
|
|
882
|
-
ktype = infer_and_reduce_type(o.keys
|
|
883
|
-
etype = infer_and_reduce_type(o.values
|
|
691
|
+
ktype = infer_and_reduce_type(o.keys)
|
|
692
|
+
etype = infer_and_reduce_type(o.values)
|
|
693
|
+
PHashType.new(ktype, etype, size_as_type(o))
|
|
884
694
|
end
|
|
885
|
-
type.key_type = ktype
|
|
886
|
-
type.element_type = etype
|
|
887
|
-
type.size_type = size_as_type(o)
|
|
888
|
-
type
|
|
889
695
|
end
|
|
890
696
|
|
|
891
697
|
def size_as_type(collection)
|
|
892
698
|
size = collection.size
|
|
893
|
-
|
|
894
|
-
t.from = size
|
|
895
|
-
t.to = size
|
|
896
|
-
t
|
|
699
|
+
PIntegerType.new(size, size)
|
|
897
700
|
end
|
|
898
701
|
|
|
899
702
|
# Common case for everything that intrinsically only has a single type
|
|
@@ -903,103 +706,37 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
903
706
|
|
|
904
707
|
def infer_set_Array(o)
|
|
905
708
|
if o.empty?
|
|
906
|
-
|
|
907
|
-
type.element_type = Types::PUndefType.new()
|
|
908
|
-
type.size_type = size_as_type(o)
|
|
709
|
+
PArrayType::EMPTY
|
|
909
710
|
else
|
|
910
|
-
|
|
911
|
-
type.types = o.map() {|x| infer_set(x) }
|
|
711
|
+
PTupleType.new(o.map {|x| infer_set(x) })
|
|
912
712
|
end
|
|
913
|
-
type
|
|
914
713
|
end
|
|
915
714
|
|
|
916
715
|
def infer_set_Hash(o)
|
|
917
716
|
if o.empty?
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
type.size_type = size_as_type(o)
|
|
717
|
+
PHashType::EMPTY
|
|
718
|
+
elsif o.keys.all? {|k| PStringType::NON_EMPTY.instance?(k) }
|
|
719
|
+
PStructType.new(o.each_pair.map { |k,v| PStructElement.new(PStringType.new(size_as_type(k), [k]), infer_set(v)) })
|
|
922
720
|
else
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
ktype.types = o.keys.map {|k| infer_set(k) }
|
|
927
|
-
etype = Types::PVariantType.new
|
|
928
|
-
etype.types = o.values.map {|e| infer_set(e) }
|
|
929
|
-
type.key_type = unwrap_single_variant(ktype)
|
|
930
|
-
type.element_type = unwrap_single_variant(etype)
|
|
931
|
-
type.size_type = size_as_type(o)
|
|
932
|
-
else
|
|
933
|
-
elements = []
|
|
934
|
-
o.each_pair do |k,v|
|
|
935
|
-
element = Types::PStructElement.new
|
|
936
|
-
element.name = k
|
|
937
|
-
element.type = infer_set(v)
|
|
938
|
-
elements << element
|
|
939
|
-
end
|
|
940
|
-
type = Types::PStructType.new
|
|
941
|
-
type.elements = elements
|
|
942
|
-
end
|
|
721
|
+
ktype = PVariantType.maybe_create(o.keys.map {|k| infer_set(k) })
|
|
722
|
+
etype = PVariantType.maybe_create(o.values.map {|e| infer_set(e) })
|
|
723
|
+
PHashType.new(unwrap_single_variant(ktype), unwrap_single_variant(etype), size_as_type(o))
|
|
943
724
|
end
|
|
944
|
-
|
|
725
|
+
end
|
|
726
|
+
|
|
727
|
+
# @api private
|
|
728
|
+
def infer_set_Version(o)
|
|
729
|
+
PSemVerType.new(Semantic::VersionRange.new(o, o))
|
|
945
730
|
end
|
|
946
731
|
|
|
947
732
|
def unwrap_single_variant(possible_variant)
|
|
948
|
-
if possible_variant.is_a?(
|
|
733
|
+
if possible_variant.is_a?(PVariantType) && possible_variant.types.size == 1
|
|
949
734
|
possible_variant.types[0]
|
|
950
735
|
else
|
|
951
736
|
possible_variant
|
|
952
737
|
end
|
|
953
738
|
end
|
|
954
739
|
|
|
955
|
-
# False in general type calculator
|
|
956
|
-
# @api private
|
|
957
|
-
def assignable_Object(t, t2)
|
|
958
|
-
false
|
|
959
|
-
end
|
|
960
|
-
|
|
961
|
-
# @api private
|
|
962
|
-
def assignable_PAnyType(t, t2)
|
|
963
|
-
t2.is_a?(Types::PAnyType)
|
|
964
|
-
end
|
|
965
|
-
|
|
966
|
-
# @api private
|
|
967
|
-
def assignable_PUndefType(t, t2)
|
|
968
|
-
# Only undef/nil is assignable to nil type
|
|
969
|
-
t2.is_a?(Types::PUndefType)
|
|
970
|
-
end
|
|
971
|
-
|
|
972
|
-
# Anything is assignable to a Unit type
|
|
973
|
-
# @api private
|
|
974
|
-
def assignable_PUnitType(t, t2)
|
|
975
|
-
true
|
|
976
|
-
end
|
|
977
|
-
|
|
978
|
-
# @api private
|
|
979
|
-
def assignable_PDefaultType(t, t2)
|
|
980
|
-
# Only default is assignable to default type
|
|
981
|
-
t2.is_a?(Types::PDefaultType)
|
|
982
|
-
end
|
|
983
|
-
|
|
984
|
-
# @api private
|
|
985
|
-
def assignable_PScalarType(t, t2)
|
|
986
|
-
t2.is_a?(Types::PScalarType)
|
|
987
|
-
end
|
|
988
|
-
|
|
989
|
-
# @api private
|
|
990
|
-
def assignable_PNumericType(t, t2)
|
|
991
|
-
t2.is_a?(Types::PNumericType)
|
|
992
|
-
end
|
|
993
|
-
|
|
994
|
-
# @api private
|
|
995
|
-
def assignable_PIntegerType(t, t2)
|
|
996
|
-
return false unless t2.is_a?(Types::PIntegerType)
|
|
997
|
-
trange = from_to_ordered(t.from, t.to)
|
|
998
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
999
|
-
# If t2 min and max are within the range of t
|
|
1000
|
-
trange[0] <= t2range[0] && trange[1] >= t2range[1]
|
|
1001
|
-
end
|
|
1002
|
-
|
|
1003
740
|
# Transform int range to a size constraint
|
|
1004
741
|
# if range == nil the constraint is 1,1
|
|
1005
742
|
# if range.from == nil min size = 1
|
|
@@ -1010,114 +747,13 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1010
747
|
from = range.from
|
|
1011
748
|
to = range.to
|
|
1012
749
|
x = from.nil? ? 1 : from
|
|
1013
|
-
y = to.nil? ?
|
|
1014
|
-
|
|
1015
|
-
[x, y]
|
|
1016
|
-
else
|
|
1017
|
-
[y, x]
|
|
1018
|
-
end
|
|
1019
|
-
end
|
|
1020
|
-
|
|
1021
|
-
# @api private
|
|
1022
|
-
def from_to_ordered(from, to)
|
|
1023
|
-
x = (from.nil? || from == :default) ? -Float::INFINITY : from
|
|
1024
|
-
y = (to.nil? || to == :default) ? Float::INFINITY : to
|
|
1025
|
-
if x < y
|
|
1026
|
-
[x, y]
|
|
1027
|
-
else
|
|
1028
|
-
[y, x]
|
|
1029
|
-
end
|
|
1030
|
-
end
|
|
1031
|
-
|
|
1032
|
-
# @api private
|
|
1033
|
-
def assignable_PVariantType(t, t2)
|
|
1034
|
-
# Data is a specific variant
|
|
1035
|
-
t2 = @data_variant_t if t2.is_a?(Types::PDataType)
|
|
1036
|
-
if t2.is_a?(Types::PVariantType)
|
|
1037
|
-
# A variant is assignable if all of its options are assignable to one of this type's options
|
|
1038
|
-
return true if t == t2
|
|
1039
|
-
t2.types.all? do |other|
|
|
1040
|
-
# if the other is a Variant, all of its options, but be assignable to one of this type's options
|
|
1041
|
-
other = other.is_a?(Types::PDataType) ? @data_variant_t : other
|
|
1042
|
-
if other.is_a?(Types::PVariantType)
|
|
1043
|
-
assignable?(t, other)
|
|
1044
|
-
else
|
|
1045
|
-
t.types.any? {|option_t| assignable?(option_t, other) }
|
|
1046
|
-
end
|
|
1047
|
-
end
|
|
1048
|
-
else
|
|
1049
|
-
# A variant is assignable if t2 is assignable to any of its types
|
|
1050
|
-
t.types.any? { |option_t| assignable?(option_t, t2) }
|
|
1051
|
-
end
|
|
1052
|
-
end
|
|
1053
|
-
|
|
1054
|
-
# Catch all not callable combinations
|
|
1055
|
-
def callable_Object(o, callable_t)
|
|
1056
|
-
false
|
|
1057
|
-
end
|
|
1058
|
-
|
|
1059
|
-
def callable_PTupleType(args_tuple, callable_t)
|
|
1060
|
-
if args_tuple.size_type
|
|
1061
|
-
raise ArgumentError, "Callable tuple may not have a size constraint when used as args"
|
|
1062
|
-
end
|
|
1063
|
-
|
|
1064
|
-
params_tuple = callable_t.param_types
|
|
1065
|
-
param_block_t = callable_t.block_type
|
|
1066
|
-
arg_types = args_tuple.types
|
|
1067
|
-
arg_block_t = arg_types.last()
|
|
1068
|
-
if self.class.is_kind_of_callable?(arg_block_t)
|
|
1069
|
-
# Can't pass a block to a callable that doesn't accept one
|
|
1070
|
-
return false if param_block_t.nil?
|
|
1071
|
-
|
|
1072
|
-
# Check that the block is of the right tyṕe
|
|
1073
|
-
return false unless assignable?(param_block_t, arg_block_t)
|
|
1074
|
-
|
|
1075
|
-
# Check other arguments
|
|
1076
|
-
arg_count = arg_types.size - 1
|
|
1077
|
-
params_size_t = params_tuple.size_type || Types::TypeFactory.range(*params_tuple.size_range)
|
|
1078
|
-
return false unless assignable?(params_size_t, Types::TypeFactory.range(arg_count, arg_count))
|
|
1079
|
-
|
|
1080
|
-
ctypes = params_tuple.types
|
|
1081
|
-
args_assignable = false
|
|
1082
|
-
arg_count.times do |index|
|
|
1083
|
-
return false unless assignable?((ctypes[index] || ctypes[-1]), arg_types[index])
|
|
1084
|
-
end
|
|
1085
|
-
return true
|
|
1086
|
-
end
|
|
1087
|
-
|
|
1088
|
-
# Check that tuple is assignable and that the block (if declared) is optional
|
|
1089
|
-
assignable?(params_tuple, args_tuple) && (param_block_t.nil? || assignable?(param_block_t, @nil_t))
|
|
750
|
+
y = to.nil? ? TheInfinity : to
|
|
751
|
+
[x, y]
|
|
1090
752
|
end
|
|
1091
753
|
|
|
1092
754
|
# @api private
|
|
1093
755
|
def self.is_kind_of_callable?(t, optional = true)
|
|
1094
|
-
|
|
1095
|
-
when Types::PCallableType
|
|
1096
|
-
true
|
|
1097
|
-
when Types::POptionalType
|
|
1098
|
-
optional && is_kind_of_callable?(t.optional_type, optional)
|
|
1099
|
-
when Types::PVariantType
|
|
1100
|
-
t.types.all? {|t2| is_kind_of_callable?(t2, optional) }
|
|
1101
|
-
else
|
|
1102
|
-
false
|
|
1103
|
-
end
|
|
1104
|
-
end
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
def callable_PArrayType(args_array, callable_t)
|
|
1108
|
-
return false unless assignable?(callable_t.param_types, args_array)
|
|
1109
|
-
# does not support calling with a block, but have to check that callable is ok with missing block
|
|
1110
|
-
assignable?(callable_t.block_type || @nil_t, @nil_t)
|
|
1111
|
-
end
|
|
1112
|
-
|
|
1113
|
-
def callable_PUndefType(nil_t, callable_t)
|
|
1114
|
-
# if callable_t is Optional (or indeed PUndefType), this means that 'missing callable' is accepted
|
|
1115
|
-
assignable?(callable_t, nil_t)
|
|
1116
|
-
end
|
|
1117
|
-
|
|
1118
|
-
def callable_PCallableType(given_callable_t, required_callable_t)
|
|
1119
|
-
# If the required callable is euqal or more specific than the given, the given is callable
|
|
1120
|
-
assignable?(required_callable_t, given_callable_t)
|
|
756
|
+
t.is_a?(PAnyType) && t.kind_of_callable?(optional)
|
|
1121
757
|
end
|
|
1122
758
|
|
|
1123
759
|
def max(a,b)
|
|
@@ -1128,41 +764,6 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1128
764
|
a <= b ? a : b
|
|
1129
765
|
end
|
|
1130
766
|
|
|
1131
|
-
def assignable_PTupleType(t, t2)
|
|
1132
|
-
return true if t == t2 || t.types.empty? && (t2.is_a?(Types::PArrayType))
|
|
1133
|
-
size_t = t.size_type || Puppet::Pops::Types::TypeFactory.range(*t.size_range)
|
|
1134
|
-
|
|
1135
|
-
if t2.is_a?(Types::PTupleType)
|
|
1136
|
-
size_t2 = t2.size_type || Puppet::Pops::Types::TypeFactory.range(*t2.size_range)
|
|
1137
|
-
|
|
1138
|
-
# not assignable if the number of types in t2 is outside number of types in t1
|
|
1139
|
-
if assignable?(size_t, size_t2)
|
|
1140
|
-
t2.types.size.times do |index|
|
|
1141
|
-
return false unless assignable?((t.types[index] || t.types[-1]), t2.types[index])
|
|
1142
|
-
end
|
|
1143
|
-
return true
|
|
1144
|
-
else
|
|
1145
|
-
return false
|
|
1146
|
-
end
|
|
1147
|
-
elsif t2.is_a?(Types::PArrayType)
|
|
1148
|
-
t2_entry = t2.element_type
|
|
1149
|
-
|
|
1150
|
-
# Array of anything can not be assigned (unless tuple is tuple of anything) - this case
|
|
1151
|
-
# was handled at the top of this method.
|
|
1152
|
-
#
|
|
1153
|
-
return false if t2_entry.nil?
|
|
1154
|
-
size_t = t.size_type || Puppet::Pops::Types::TypeFactory.range(*t.size_range)
|
|
1155
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1156
|
-
return false unless assignable?(size_t, size_t2)
|
|
1157
|
-
min(t.types.size, size_t2.range()[1]).times do |index|
|
|
1158
|
-
return false unless assignable?((t.types[index] || t.types[-1]), t2_entry)
|
|
1159
|
-
end
|
|
1160
|
-
true
|
|
1161
|
-
else
|
|
1162
|
-
false
|
|
1163
|
-
end
|
|
1164
|
-
end
|
|
1165
|
-
|
|
1166
767
|
# Produces the tuple entry at the given index given a tuple type, its from/to constraints on the last
|
|
1167
768
|
# type, and an index.
|
|
1168
769
|
# Produces nil if the index is out of bounds
|
|
@@ -1182,564 +783,6 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1182
783
|
end
|
|
1183
784
|
end
|
|
1184
785
|
|
|
1185
|
-
# @api private
|
|
1186
|
-
#
|
|
1187
|
-
def assignable_PStructType(t, t2)
|
|
1188
|
-
if t2.is_a?(Types::PStructType)
|
|
1189
|
-
h = t.hashed_elements
|
|
1190
|
-
h2 = t2.hashed_elements
|
|
1191
|
-
(h2.keys - h.keys).empty? && h.all? {|k, v| v2 = h2[k]; assignable?(v, v2.nil? ? @nil_t : v2) }
|
|
1192
|
-
elsif t2.is_a?(Types::PHashType)
|
|
1193
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1194
|
-
size_t = Types::PIntegerType.new
|
|
1195
|
-
elements = t.elements
|
|
1196
|
-
size_t.from = elements.count {|e| !assignable?(e.type, @nil_t) }
|
|
1197
|
-
size_t.to = elements.size
|
|
1198
|
-
# compatible size
|
|
1199
|
-
# hash key type must be string of min 1 size
|
|
1200
|
-
# hash value t must be assignable to each key
|
|
1201
|
-
element_type = t2.element_type
|
|
1202
|
-
assignable_PIntegerType(size_t, size_t2) &&
|
|
1203
|
-
(size_t2.to == 0 || assignable?(@non_empty_string_t, t2.key_type)) &&
|
|
1204
|
-
elements.all? {|e| assignable?(e.type, element_type) }
|
|
1205
|
-
else
|
|
1206
|
-
false
|
|
1207
|
-
end
|
|
1208
|
-
end
|
|
1209
|
-
|
|
1210
|
-
# @api private
|
|
1211
|
-
def assignable_POptionalType(t, t2)
|
|
1212
|
-
return true if t2.is_a?(Types::PUndefType)
|
|
1213
|
-
if t2.is_a?(Types::POptionalType)
|
|
1214
|
-
assignable?(t.optional_type, t2.optional_type)
|
|
1215
|
-
else
|
|
1216
|
-
assignable?(t.optional_type, t2)
|
|
1217
|
-
end
|
|
1218
|
-
end
|
|
1219
|
-
|
|
1220
|
-
# @api private
|
|
1221
|
-
def assignable_PEnumType(t, t2)
|
|
1222
|
-
return true if t == t2
|
|
1223
|
-
if t.values.empty?
|
|
1224
|
-
return true if t2.is_a?(Types::PStringType) || t2.is_a?(Types::PEnumType) || t2.is_a?(Types::PPatternType)
|
|
1225
|
-
end
|
|
1226
|
-
case t2
|
|
1227
|
-
when Types::PStringType
|
|
1228
|
-
# if the set of strings are all found in the set of enums
|
|
1229
|
-
!t2.values.empty?() && t2.values.all? { |s| t.values.any? { |e| e == s }}
|
|
1230
|
-
when Types::PVariantType
|
|
1231
|
-
t2.types.all? {|variant_t| assignable_PEnumType(t, variant_t) }
|
|
1232
|
-
when Types::PEnumType
|
|
1233
|
-
# empty means any enum
|
|
1234
|
-
return true if t.values.empty?
|
|
1235
|
-
!t2.values.empty? && t2.values.all? { |s| t.values.any? {|e| e == s }}
|
|
1236
|
-
else
|
|
1237
|
-
false
|
|
1238
|
-
end
|
|
1239
|
-
end
|
|
1240
|
-
|
|
1241
|
-
# @api private
|
|
1242
|
-
def assignable_PStringType(t, t2)
|
|
1243
|
-
if t.values.empty?
|
|
1244
|
-
# A general string is assignable by any other string or pattern restricted string
|
|
1245
|
-
# if the string has a size constraint it does not match since there is no reasonable way
|
|
1246
|
-
# to compute the min/max length a pattern will match. For enum, it is possible to test that
|
|
1247
|
-
# each enumerator value is within range
|
|
1248
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1249
|
-
case t2
|
|
1250
|
-
when Types::PStringType
|
|
1251
|
-
# true if size compliant
|
|
1252
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1253
|
-
assignable_PIntegerType(size_t, size_t2)
|
|
1254
|
-
|
|
1255
|
-
when Types::PPatternType
|
|
1256
|
-
# true if size constraint is at least 0 to +Infinity (which is the same as the default)
|
|
1257
|
-
assignable_PIntegerType(size_t, @collection_default_size_t)
|
|
1258
|
-
|
|
1259
|
-
when Types::PEnumType
|
|
1260
|
-
if t2.values && !t2.values.empty?
|
|
1261
|
-
# true if all enum values are within range
|
|
1262
|
-
min, max = t2.values.map(&:size).minmax
|
|
1263
|
-
trange = from_to_ordered(size_t.from, size_t.to)
|
|
1264
|
-
t2range = [min, max]
|
|
1265
|
-
# If t2 min and max are within the range of t
|
|
1266
|
-
trange[0] <= t2range[0] && trange[1] >= t2range[1]
|
|
1267
|
-
else
|
|
1268
|
-
# enum represents all enums, and thus all strings, a sized constrained string can thus not
|
|
1269
|
-
# be assigned any enum (unless it is max size).
|
|
1270
|
-
assignable_PIntegerType(size_t, @collection_default_size_t)
|
|
1271
|
-
end
|
|
1272
|
-
else
|
|
1273
|
-
# no other type matches string
|
|
1274
|
-
false
|
|
1275
|
-
end
|
|
1276
|
-
elsif t2.is_a?(Types::PStringType)
|
|
1277
|
-
# A specific string acts as a set of strings - must have exactly the same strings
|
|
1278
|
-
# In this case, size does not matter since the definition is very precise anyway
|
|
1279
|
-
Set.new(t.values) == Set.new(t2.values)
|
|
1280
|
-
else
|
|
1281
|
-
# All others are false, since no other type describes the same set of specific strings
|
|
1282
|
-
false
|
|
1283
|
-
end
|
|
1284
|
-
end
|
|
1285
|
-
|
|
1286
|
-
# @api private
|
|
1287
|
-
def assignable_PPatternType(t, t2)
|
|
1288
|
-
return true if t == t2
|
|
1289
|
-
case t2
|
|
1290
|
-
when Types::PStringType, Types::PEnumType
|
|
1291
|
-
values = t2.values
|
|
1292
|
-
when Types::PVariantType
|
|
1293
|
-
return t2.types.all? {|variant_t| assignable_PPatternType(t, variant_t) }
|
|
1294
|
-
when Types::PPatternType
|
|
1295
|
-
return t.patterns.empty? ? true : false
|
|
1296
|
-
else
|
|
1297
|
-
return false
|
|
1298
|
-
end
|
|
1299
|
-
|
|
1300
|
-
if t2.values.empty?
|
|
1301
|
-
# Strings / Enums (unknown which ones) cannot all match a pattern, but if there is no pattern it is ok
|
|
1302
|
-
# (There should really always be a pattern, but better safe than sorry).
|
|
1303
|
-
return t.patterns.empty? ? true : false
|
|
1304
|
-
end
|
|
1305
|
-
# all strings in String/Enum type must match one of the patterns in Pattern type,
|
|
1306
|
-
# or Pattern represents all Patterns == all Strings
|
|
1307
|
-
regexps = t.patterns.map {|p| p.regexp }
|
|
1308
|
-
regexps.empty? || t2.values.all? { |v| regexps.any? {|re| re.match(v) } }
|
|
1309
|
-
end
|
|
1310
|
-
|
|
1311
|
-
# @api private
|
|
1312
|
-
def assignable_PFloatType(t, t2)
|
|
1313
|
-
return false unless t2.is_a?(Types::PFloatType)
|
|
1314
|
-
trange = from_to_ordered(t.from, t.to)
|
|
1315
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
1316
|
-
# If t2 min and max are within the range of t
|
|
1317
|
-
trange[0] <= t2range[0] && trange[1] >= t2range[1]
|
|
1318
|
-
end
|
|
1319
|
-
|
|
1320
|
-
# @api private
|
|
1321
|
-
def assignable_PBooleanType(t, t2)
|
|
1322
|
-
t2.is_a?(Types::PBooleanType)
|
|
1323
|
-
end
|
|
1324
|
-
|
|
1325
|
-
# @api private
|
|
1326
|
-
def assignable_PRegexpType(t, t2)
|
|
1327
|
-
t2.is_a?(Types::PRegexpType) && (t.pattern.nil? || t.pattern == t2.pattern)
|
|
1328
|
-
end
|
|
1329
|
-
|
|
1330
|
-
# @api private
|
|
1331
|
-
def assignable_PCallableType(t, t2)
|
|
1332
|
-
return false unless t2.is_a?(Types::PCallableType)
|
|
1333
|
-
# nil param_types means, any other Callable is assignable
|
|
1334
|
-
return true if t.param_types.nil?
|
|
1335
|
-
|
|
1336
|
-
# NOTE: these tests are made in reverse as it is calling the callable that is constrained
|
|
1337
|
-
# (it's lower bound), not its upper bound
|
|
1338
|
-
return false unless assignable?(t2.param_types, t.param_types)
|
|
1339
|
-
# names are ignored, they are just information
|
|
1340
|
-
# Blocks must be compatible
|
|
1341
|
-
this_block_t = t.block_type || @nil_t
|
|
1342
|
-
that_block_t = t2.block_type || @nil_t
|
|
1343
|
-
assignable?(that_block_t, this_block_t)
|
|
1344
|
-
|
|
1345
|
-
end
|
|
1346
|
-
|
|
1347
|
-
# @api private
|
|
1348
|
-
def assignable_PCollectionType(t, t2)
|
|
1349
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1350
|
-
case t2
|
|
1351
|
-
when Types::PCollectionType
|
|
1352
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1353
|
-
assignable_PIntegerType(size_t, size_t2)
|
|
1354
|
-
when Types::PTupleType
|
|
1355
|
-
# compute the tuple's min/max size, and check if that size matches
|
|
1356
|
-
from, to = size_range(t2.size_type)
|
|
1357
|
-
t2s = Types::PIntegerType.new()
|
|
1358
|
-
t2s.from = t2.types.size - 1 + from
|
|
1359
|
-
t2s.to = t2.types.size - 1 + to
|
|
1360
|
-
assignable_PIntegerType(size_t, t2s)
|
|
1361
|
-
when Types::PStructType
|
|
1362
|
-
from = to = t2.elements.size
|
|
1363
|
-
t2s = Types::PIntegerType.new()
|
|
1364
|
-
t2s.from = from
|
|
1365
|
-
t2s.to = to
|
|
1366
|
-
assignable_PIntegerType(size_t, t2s)
|
|
1367
|
-
else
|
|
1368
|
-
false
|
|
1369
|
-
end
|
|
1370
|
-
end
|
|
1371
|
-
|
|
1372
|
-
# @api private
|
|
1373
|
-
def assignable_PType(t, t2)
|
|
1374
|
-
return false unless t2.is_a?(Types::PType)
|
|
1375
|
-
return true if t.type.nil? # wide enough to handle all types
|
|
1376
|
-
return false if t2.type.nil? # wider than t
|
|
1377
|
-
assignable?(t.type, t2.type)
|
|
1378
|
-
end
|
|
1379
|
-
|
|
1380
|
-
# Array is assignable if t2 is an Array and t2's element type is assignable, or if t2 is a Tuple
|
|
1381
|
-
# @api private
|
|
1382
|
-
def assignable_PArrayType(t, t2)
|
|
1383
|
-
if t2.is_a?(Types::PArrayType)
|
|
1384
|
-
return false unless assignable?(t.element_type, t2.element_type)
|
|
1385
|
-
assignable_PCollectionType(t, t2)
|
|
1386
|
-
|
|
1387
|
-
elsif t2.is_a?(Types::PTupleType)
|
|
1388
|
-
return false unless t2.types.all? {|t2_element| assignable?(t.element_type, t2_element) }
|
|
1389
|
-
t2_regular = t2.types[0..-2]
|
|
1390
|
-
t2_ranged = t2.types[-1]
|
|
1391
|
-
t2_from, t2_to = size_range(t2.size_type)
|
|
1392
|
-
t2_required = t2_regular.size + t2_from
|
|
1393
|
-
|
|
1394
|
-
t_entry = t.element_type
|
|
1395
|
-
|
|
1396
|
-
# Tuple of anything can not be assigned (unless array is tuple of anything) - this case
|
|
1397
|
-
# was handled at the top of this method.
|
|
1398
|
-
#
|
|
1399
|
-
return false if t_entry.nil?
|
|
1400
|
-
|
|
1401
|
-
# array type may be size constrained
|
|
1402
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1403
|
-
min, max = size_t.range
|
|
1404
|
-
# Tuple with fewer min entries can not be assigned
|
|
1405
|
-
return false if t2_required < min
|
|
1406
|
-
# Tuple with more optionally available entries can not be assigned
|
|
1407
|
-
return false if t2_regular.size + t2_to > max
|
|
1408
|
-
# each tuple type must be assignable to the element type
|
|
1409
|
-
t2_required.times do |index|
|
|
1410
|
-
t2_entry = tuple_entry_at(t2, t2_from, t2_to, index)
|
|
1411
|
-
return false unless assignable?(t_entry, t2_entry)
|
|
1412
|
-
end
|
|
1413
|
-
# ... and so must the last, possibly optional (ranged) type
|
|
1414
|
-
return assignable?(t_entry, t2_ranged)
|
|
1415
|
-
else
|
|
1416
|
-
false
|
|
1417
|
-
end
|
|
1418
|
-
end
|
|
1419
|
-
|
|
1420
|
-
# Hash is assignable if t2 is a Hash and t2's key and element types are assignable
|
|
1421
|
-
# @api private
|
|
1422
|
-
def assignable_PHashType(t, t2)
|
|
1423
|
-
case t2
|
|
1424
|
-
when Types::PHashType
|
|
1425
|
-
return true if (t.size_type.nil? || t.size_type.from == 0) && t2.is_the_empty_hash?
|
|
1426
|
-
return false unless assignable?(t.key_type, t2.key_type) && assignable?(t.element_type, t2.element_type)
|
|
1427
|
-
assignable_PCollectionType(t, t2)
|
|
1428
|
-
when Types::PStructType
|
|
1429
|
-
# hash must accept String as key type
|
|
1430
|
-
# hash must accept all value types
|
|
1431
|
-
# hash must accept the size of the struct
|
|
1432
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1433
|
-
min, max = size_t.range
|
|
1434
|
-
struct_size = t2.elements.size
|
|
1435
|
-
key_type = t.key_type
|
|
1436
|
-
element_type = t.element_type
|
|
1437
|
-
( struct_size >= min && struct_size <= max &&
|
|
1438
|
-
t2.elements.all? {|e| instance_of(key_type, e.name) && assignable?(element_type, e.type) })
|
|
1439
|
-
else
|
|
1440
|
-
false
|
|
1441
|
-
end
|
|
1442
|
-
end
|
|
1443
|
-
|
|
1444
|
-
# @api private
|
|
1445
|
-
def assignable_PCatalogEntryType(t1, t2)
|
|
1446
|
-
t2.is_a?(Types::PCatalogEntryType)
|
|
1447
|
-
end
|
|
1448
|
-
|
|
1449
|
-
# @api private
|
|
1450
|
-
def assignable_PHostClassType(t1, t2)
|
|
1451
|
-
return false unless t2.is_a?(Types::PHostClassType)
|
|
1452
|
-
# Class = Class[name}, Class[name] != Class
|
|
1453
|
-
return true if t1.class_name.nil?
|
|
1454
|
-
# Class[name] = Class[name]
|
|
1455
|
-
return t1.class_name == t2.class_name
|
|
1456
|
-
end
|
|
1457
|
-
|
|
1458
|
-
# @api private
|
|
1459
|
-
def assignable_PResourceType(t1, t2)
|
|
1460
|
-
return false unless t2.is_a?(Types::PResourceType)
|
|
1461
|
-
return true if t1.type_name.nil?
|
|
1462
|
-
return false if t1.type_name != t2.type_name
|
|
1463
|
-
return true if t1.title.nil?
|
|
1464
|
-
return t1.title == t2.title
|
|
1465
|
-
end
|
|
1466
|
-
|
|
1467
|
-
# Data is assignable by other Data and by Array[Data] and Hash[Scalar, Data]
|
|
1468
|
-
# @api private
|
|
1469
|
-
def assignable_PDataType(t, t2)
|
|
1470
|
-
t2.is_a?(Types::PDataType) || assignable?(@data_variant_t, t2)
|
|
1471
|
-
end
|
|
1472
|
-
|
|
1473
|
-
# Assignable if t2's has the same runtime and the runtime name resolves to
|
|
1474
|
-
# a class that is the same or subclass of t1's resolved runtime type name
|
|
1475
|
-
# @api private
|
|
1476
|
-
def assignable_PRuntimeType(t1, t2)
|
|
1477
|
-
return false unless t2.is_a?(Types::PRuntimeType)
|
|
1478
|
-
return false unless t1.runtime == t2.runtime
|
|
1479
|
-
return true if t1.runtime_type_name.nil? # t1 is wider
|
|
1480
|
-
return false if t2.runtime_type_name.nil? # t1 not nil, so t2 can not be wider
|
|
1481
|
-
|
|
1482
|
-
# NOTE: This only supports Ruby, must change when/if the set of runtimes is expanded
|
|
1483
|
-
c1 = class_from_string(t1.runtime_type_name)
|
|
1484
|
-
c2 = class_from_string(t2.runtime_type_name)
|
|
1485
|
-
return false unless c1.is_a?(Class) && c2.is_a?(Class)
|
|
1486
|
-
!!(c2 <= c1)
|
|
1487
|
-
end
|
|
1488
|
-
|
|
1489
|
-
# @api private
|
|
1490
|
-
def debug_string_Object(t)
|
|
1491
|
-
string(t)
|
|
1492
|
-
end
|
|
1493
|
-
|
|
1494
|
-
# @api private
|
|
1495
|
-
def string_PType(t)
|
|
1496
|
-
if t.type.nil?
|
|
1497
|
-
"Type"
|
|
1498
|
-
else
|
|
1499
|
-
"Type[#{string(t.type)}]"
|
|
1500
|
-
end
|
|
1501
|
-
end
|
|
1502
|
-
|
|
1503
|
-
# @api private
|
|
1504
|
-
def string_NilClass(t) ; '?' ; end
|
|
1505
|
-
|
|
1506
|
-
# @api private
|
|
1507
|
-
def string_String(t) ; t ; end
|
|
1508
|
-
|
|
1509
|
-
# @api private
|
|
1510
|
-
def string_Symbol(t) ; t.to_s ; end
|
|
1511
|
-
|
|
1512
|
-
def string_PAnyType(t) ; "Any" ; end
|
|
1513
|
-
|
|
1514
|
-
# @api private
|
|
1515
|
-
def string_PUndefType(t) ; 'Undef' ; end
|
|
1516
|
-
|
|
1517
|
-
# @api private
|
|
1518
|
-
def string_PDefaultType(t) ; 'Default' ; end
|
|
1519
|
-
|
|
1520
|
-
# @api private
|
|
1521
|
-
def string_PBooleanType(t) ; "Boolean" ; end
|
|
1522
|
-
|
|
1523
|
-
# @api private
|
|
1524
|
-
def string_PScalarType(t) ; "Scalar" ; end
|
|
1525
|
-
|
|
1526
|
-
# @api private
|
|
1527
|
-
def string_PDataType(t) ; "Data" ; end
|
|
1528
|
-
|
|
1529
|
-
# @api private
|
|
1530
|
-
def string_PNumericType(t) ; "Numeric" ; end
|
|
1531
|
-
|
|
1532
|
-
# @api private
|
|
1533
|
-
def string_PIntegerType(t)
|
|
1534
|
-
range = range_array_part(t)
|
|
1535
|
-
unless range.empty?
|
|
1536
|
-
"Integer[#{range.join(', ')}]"
|
|
1537
|
-
else
|
|
1538
|
-
"Integer"
|
|
1539
|
-
end
|
|
1540
|
-
end
|
|
1541
|
-
|
|
1542
|
-
# Produces a string from an Integer range type that is used inside other type strings
|
|
1543
|
-
# @api private
|
|
1544
|
-
def range_array_part(t)
|
|
1545
|
-
return [] if t.nil? || (t.from.nil? && t.to.nil?)
|
|
1546
|
-
[t.from.nil? ? 'default' : t.from , t.to.nil? ? 'default' : t.to ]
|
|
1547
|
-
end
|
|
1548
|
-
|
|
1549
|
-
# @api private
|
|
1550
|
-
def string_PFloatType(t)
|
|
1551
|
-
range = range_array_part(t)
|
|
1552
|
-
unless range.empty?
|
|
1553
|
-
"Float[#{range.join(', ')}]"
|
|
1554
|
-
else
|
|
1555
|
-
"Float"
|
|
1556
|
-
end
|
|
1557
|
-
end
|
|
1558
|
-
|
|
1559
|
-
# @api private
|
|
1560
|
-
def string_PRegexpType(t)
|
|
1561
|
-
t.pattern.nil? ? "Regexp" : "Regexp[#{t.regexp.inspect}]"
|
|
1562
|
-
end
|
|
1563
|
-
|
|
1564
|
-
# @api private
|
|
1565
|
-
def string_PStringType(t)
|
|
1566
|
-
# skip values in regular output - see debug_string
|
|
1567
|
-
range = range_array_part(t.size_type)
|
|
1568
|
-
unless range.empty?
|
|
1569
|
-
"String[#{range.join(', ')}]"
|
|
1570
|
-
else
|
|
1571
|
-
"String"
|
|
1572
|
-
end
|
|
1573
|
-
end
|
|
1574
|
-
|
|
1575
|
-
# @api private
|
|
1576
|
-
def debug_string_PStringType(t)
|
|
1577
|
-
range = range_array_part(t.size_type)
|
|
1578
|
-
range_part = range.empty? ? '' : '[' << range.join(' ,') << '], '
|
|
1579
|
-
"String[" << range_part << (t.values.map {|s| "'#{s}'" }).join(', ') << ']'
|
|
1580
|
-
end
|
|
1581
|
-
|
|
1582
|
-
# @api private
|
|
1583
|
-
def string_PEnumType(t)
|
|
1584
|
-
return "Enum" if t.values.empty?
|
|
1585
|
-
"Enum[" << t.values.map {|s| "'#{s}'" }.join(', ') << ']'
|
|
1586
|
-
end
|
|
1587
|
-
|
|
1588
|
-
# @api private
|
|
1589
|
-
def string_PVariantType(t)
|
|
1590
|
-
return "Variant" if t.types.empty?
|
|
1591
|
-
"Variant[" << t.types.map {|t2| string(t2) }.join(', ') << ']'
|
|
1592
|
-
end
|
|
1593
|
-
|
|
1594
|
-
# @api private
|
|
1595
|
-
def string_PTupleType(t)
|
|
1596
|
-
range = range_array_part(t.size_type)
|
|
1597
|
-
return "Tuple" if t.types.empty?
|
|
1598
|
-
s = "Tuple[" << t.types.map {|t2| string(t2) }.join(', ')
|
|
1599
|
-
unless range.empty?
|
|
1600
|
-
s << ", " << range.join(', ')
|
|
1601
|
-
end
|
|
1602
|
-
s << "]"
|
|
1603
|
-
s
|
|
1604
|
-
end
|
|
1605
|
-
|
|
1606
|
-
# @api private
|
|
1607
|
-
def string_PCallableType(t)
|
|
1608
|
-
# generic
|
|
1609
|
-
return "Callable" if t.param_types.nil?
|
|
1610
|
-
|
|
1611
|
-
if t.param_types.types.empty?
|
|
1612
|
-
range = [0, 0]
|
|
1613
|
-
else
|
|
1614
|
-
range = range_array_part(t.param_types.size_type)
|
|
1615
|
-
end
|
|
1616
|
-
# translate to string, and skip Unit types
|
|
1617
|
-
types = t.param_types.types.map {|t2| string(t2) unless t2.class == Types::PUnitType }.compact
|
|
1618
|
-
|
|
1619
|
-
s = "Callable[" << types.join(', ')
|
|
1620
|
-
unless range.empty?
|
|
1621
|
-
(s << ', ') unless types.empty?
|
|
1622
|
-
s << range.join(', ')
|
|
1623
|
-
end
|
|
1624
|
-
# Add block T last (after min, max) if present)
|
|
1625
|
-
#
|
|
1626
|
-
unless t.block_type.nil?
|
|
1627
|
-
(s << ', ') unless types.empty? && range.empty?
|
|
1628
|
-
s << string(t.block_type)
|
|
1629
|
-
end
|
|
1630
|
-
s << "]"
|
|
1631
|
-
s
|
|
1632
|
-
end
|
|
1633
|
-
|
|
1634
|
-
# @api private
|
|
1635
|
-
def string_PStructType(t)
|
|
1636
|
-
return "Struct" if t.elements.empty?
|
|
1637
|
-
"Struct[{" << t.elements.map {|element| string(element) }.join(', ') << "}]"
|
|
1638
|
-
end
|
|
1639
|
-
|
|
1640
|
-
def string_PStructElement(t)
|
|
1641
|
-
"'#{t.name}'=>#{string(t.type)}"
|
|
1642
|
-
end
|
|
1643
|
-
|
|
1644
|
-
# @api private
|
|
1645
|
-
def string_PPatternType(t)
|
|
1646
|
-
return "Pattern" if t.patterns.empty?
|
|
1647
|
-
"Pattern[" << t.patterns.map {|s| "#{s.regexp.inspect}" }.join(', ') << ']'
|
|
1648
|
-
end
|
|
1649
|
-
|
|
1650
|
-
# @api private
|
|
1651
|
-
def string_PCollectionType(t)
|
|
1652
|
-
range = range_array_part(t.size_type)
|
|
1653
|
-
unless range.empty?
|
|
1654
|
-
"Collection[#{range.join(', ')}]"
|
|
1655
|
-
else
|
|
1656
|
-
"Collection"
|
|
1657
|
-
end
|
|
1658
|
-
end
|
|
1659
|
-
|
|
1660
|
-
# @api private
|
|
1661
|
-
def string_PUnitType(t)
|
|
1662
|
-
"Unit"
|
|
1663
|
-
end
|
|
1664
|
-
|
|
1665
|
-
# @api private
|
|
1666
|
-
def string_PRuntimeType(t) ; "Runtime[#{string(t.runtime)}, #{string(t.runtime_type_name)}]" ; end
|
|
1667
|
-
|
|
1668
|
-
# @api private
|
|
1669
|
-
def string_PArrayType(t)
|
|
1670
|
-
parts = [string(t.element_type)] + range_array_part(t.size_type)
|
|
1671
|
-
"Array[#{parts.join(', ')}]"
|
|
1672
|
-
end
|
|
1673
|
-
|
|
1674
|
-
# @api private
|
|
1675
|
-
def string_PHashType(t)
|
|
1676
|
-
parts = [string(t.key_type), string(t.element_type)] + range_array_part(t.size_type)
|
|
1677
|
-
"Hash[#{parts.join(', ')}]"
|
|
1678
|
-
end
|
|
1679
|
-
|
|
1680
|
-
# @api private
|
|
1681
|
-
def string_PCatalogEntryType(t)
|
|
1682
|
-
"CatalogEntry"
|
|
1683
|
-
end
|
|
1684
|
-
|
|
1685
|
-
# @api private
|
|
1686
|
-
def string_PHostClassType(t)
|
|
1687
|
-
if t.class_name
|
|
1688
|
-
"Class[#{t.class_name}]"
|
|
1689
|
-
else
|
|
1690
|
-
"Class"
|
|
1691
|
-
end
|
|
1692
|
-
end
|
|
1693
|
-
|
|
1694
|
-
# @api private
|
|
1695
|
-
def string_PResourceType(t)
|
|
1696
|
-
if t.type_name
|
|
1697
|
-
if t.title
|
|
1698
|
-
"#{capitalize_segments(t.type_name)}['#{t.title}']"
|
|
1699
|
-
else
|
|
1700
|
-
capitalize_segments(t.type_name)
|
|
1701
|
-
end
|
|
1702
|
-
else
|
|
1703
|
-
"Resource"
|
|
1704
|
-
end
|
|
1705
|
-
end
|
|
1706
|
-
|
|
1707
|
-
def string_POptionalType(t)
|
|
1708
|
-
if t.optional_type.nil?
|
|
1709
|
-
"Optional"
|
|
1710
|
-
else
|
|
1711
|
-
"Optional[#{string(t.optional_type)}]"
|
|
1712
|
-
end
|
|
1713
|
-
end
|
|
1714
|
-
|
|
1715
|
-
# Catches all non enumerable types
|
|
1716
|
-
# @api private
|
|
1717
|
-
def enumerable_Object(o)
|
|
1718
|
-
nil
|
|
1719
|
-
end
|
|
1720
|
-
|
|
1721
|
-
# @api private
|
|
1722
|
-
def enumerable_PIntegerType(t)
|
|
1723
|
-
# Not enumerable if representing an infinite range
|
|
1724
|
-
return nil if t.size == Float::INFINITY
|
|
1725
|
-
t
|
|
1726
|
-
end
|
|
1727
|
-
|
|
1728
|
-
def self.copy_as_tuple(t)
|
|
1729
|
-
case t
|
|
1730
|
-
when Types::PTupleType
|
|
1731
|
-
t.copy
|
|
1732
|
-
when Types::PArrayType
|
|
1733
|
-
# transform array to tuple
|
|
1734
|
-
result = Types::PTupleType.new
|
|
1735
|
-
result.addTypes(t.element_type.copy)
|
|
1736
|
-
result.size_type = t.size_type.nil? ? nil : t.size_type.copy
|
|
1737
|
-
result
|
|
1738
|
-
else
|
|
1739
|
-
raise ArgumentError, "Internal Error: Only Array and Tuple can be given to copy_as_tuple"
|
|
1740
|
-
end
|
|
1741
|
-
end
|
|
1742
|
-
|
|
1743
786
|
# Debugging to_s to reduce the amount of output
|
|
1744
787
|
def to_s
|
|
1745
788
|
'[a TypeCalculator]'
|
|
@@ -1747,32 +790,18 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1747
790
|
|
|
1748
791
|
private
|
|
1749
792
|
|
|
1750
|
-
NAME_SEGMENT_SEPARATOR = '::'.freeze
|
|
1751
|
-
|
|
1752
|
-
def capitalize_segments(s)
|
|
1753
|
-
s.split(NAME_SEGMENT_SEPARATOR).map(&:capitalize).join(NAME_SEGMENT_SEPARATOR)
|
|
1754
|
-
end
|
|
1755
|
-
|
|
1756
|
-
def class_from_string(str)
|
|
1757
|
-
begin
|
|
1758
|
-
str.split(NAME_SEGMENT_SEPARATOR).inject(Object) do |memo, name_segment|
|
|
1759
|
-
memo.const_get(name_segment)
|
|
1760
|
-
end
|
|
1761
|
-
rescue NameError
|
|
1762
|
-
return nil
|
|
1763
|
-
end
|
|
1764
|
-
end
|
|
1765
|
-
|
|
1766
793
|
def common_data?(t1, t2)
|
|
1767
|
-
assignable?(
|
|
794
|
+
PDataType::DEFAULT.assignable?(t1) && PDataType::DEFAULT.assignable?(t2)
|
|
1768
795
|
end
|
|
1769
796
|
|
|
1770
797
|
def common_scalar?(t1, t2)
|
|
1771
|
-
assignable?(
|
|
798
|
+
PScalarType::DEFAULT.assignable?(t1) && PScalarType::DEFAULT.assignable?(t2)
|
|
1772
799
|
end
|
|
1773
800
|
|
|
1774
801
|
def common_numeric?(t1, t2)
|
|
1775
|
-
assignable?(
|
|
802
|
+
PNumericType::DEFAULT.assignable?(t1) && PNumericType::DEFAULT.assignable?(t2)
|
|
1776
803
|
end
|
|
1777
804
|
|
|
1778
805
|
end
|
|
806
|
+
end
|
|
807
|
+
end
|