puppet 4.0.0 → 4.9.1
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 +34 -10
- data/Gemfile +25 -9
- data/LICENSE +3 -3
- data/MAINTAINERS +71 -0
- data/README.md +9 -11
- data/Rakefile +29 -0
- data/conf/auth.conf +2 -2
- data/conf/puppet.conf +1 -1
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +10 -37
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +3 -5
- 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 +29 -13
- 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 +13 -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/windows/service/daemon.rb +2 -1
- data/ext/yaml_nodes.rb +1 -1
- data/install.rb +98 -65
- data/lib/hiera/puppet_function.rb +27 -18
- data/lib/hiera/scope.rb +12 -14
- data/lib/hiera_puppet.rb +6 -14
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/agent.rb +12 -27
- data/lib/puppet/application/agent.rb +40 -19
- data/lib/puppet/application/apply.rb +69 -16
- data/lib/puppet/application/ca.rb +1 -0
- data/lib/puppet/application/cert.rb +52 -3
- data/lib/puppet/application/device.rb +10 -5
- data/lib/puppet/application/face_base.rb +4 -0
- data/lib/puppet/application/filebucket.rb +79 -5
- data/lib/puppet/application/generate.rb +5 -0
- data/lib/puppet/application/inspect.rb +2 -2
- data/lib/puppet/application/lookup.rb +344 -0
- data/lib/puppet/application/master.rb +22 -7
- data/lib/puppet/application/resource.rb +2 -6
- data/lib/puppet/application.rb +6 -4
- data/lib/puppet/application_support.rb +1 -1
- data/lib/puppet/compilable_resource_type.rb +15 -0
- data/lib/puppet/configurer/plugin_handler.rb +7 -5
- data/lib/puppet/configurer.rb +184 -42
- 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 +14 -68
- data/lib/puppet/data_providers/data_function_support.rb +13 -26
- data/lib/puppet/data_providers/function_env_data_provider.rb +7 -9
- data/lib/puppet/data_providers/function_module_data_provider.rb +7 -22
- data/lib/puppet/data_providers/hiera_config.rb +151 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +25 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +21 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +30 -0
- data/lib/puppet/data_providers/hiera_support.rb +42 -0
- data/lib/puppet/data_providers/json_data_provider_factory.rb +38 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +40 -0
- data/lib/puppet/data_providers.rb +17 -14
- data/lib/puppet/defaults.rb +279 -57
- data/lib/puppet/environments.rb +105 -10
- data/lib/puppet/error.rb +31 -1
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/face/ca.rb +6 -1
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/certificate.rb +7 -1
- data/lib/puppet/face/certificate_request.rb +2 -0
- data/lib/puppet/face/certificate_revocation_list.rb +2 -0
- data/lib/puppet/face/config.rb +2 -2
- data/lib/puppet/face/epp.rb +63 -17
- data/lib/puppet/face/file.rb +3 -0
- data/lib/puppet/face/generate.rb +64 -0
- data/lib/puppet/face/help/face.erb +3 -0
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/help.rb +35 -27
- data/lib/puppet/face/key.rb +1 -0
- data/lib/puppet/face/man.rb +5 -3
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/face/module/generate.rb +1 -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 +4 -1
- data/lib/puppet/feature/base.rb +9 -2
- data/lib/puppet/feature/cfacter.rb +1 -0
- data/lib/puppet/feature/cfpropertylist.rb +3 -0
- data/lib/puppet/feature/external_facts.rb +1 -1
- data/lib/puppet/feature/hocon.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 +11 -2
- data/lib/puppet/file_system/memory_impl.rb +9 -1
- data/lib/puppet/file_system/path_pattern.rb +1 -0
- data/lib/puppet/file_system/uniquefile.rb +3 -3
- data/lib/puppet/file_system/windows.rb +36 -13
- data/lib/puppet/file_system.rb +46 -5
- data/lib/puppet/forge/repository.rb +2 -34
- data/lib/puppet/forge.rb +7 -7
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/assert_type.rb +57 -21
- data/lib/puppet/functions/binary_file.rb +19 -0
- data/lib/puppet/functions/break.rb +22 -0
- data/lib/puppet/functions/contain.rb +33 -0
- data/lib/puppet/functions/crit.rb +14 -0
- data/lib/puppet/functions/debug.rb +14 -0
- data/lib/puppet/functions/defined.rb +160 -0
- data/lib/puppet/functions/dig.rb +23 -0
- data/lib/puppet/functions/each.rb +89 -39
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/filter.rb +64 -38
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/hiera.rb +76 -3
- data/lib/puppet/functions/hiera_array.rb +66 -4
- data/lib/puppet/functions/hiera_hash.rb +74 -2
- data/lib/puppet/functions/hiera_include.rb +78 -5
- data/lib/puppet/functions/hocon_data.rb +24 -0
- data/lib/puppet/functions/include.rb +21 -0
- data/lib/puppet/functions/info.rb +14 -0
- data/lib/puppet/functions/inline_epp.rb +44 -71
- data/lib/puppet/functions/json_data.rb +18 -0
- data/lib/puppet/functions/lest.rb +17 -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 +31 -0
- data/lib/puppet/functions/next.rb +23 -0
- data/lib/puppet/functions/notice.rb +14 -0
- data/lib/puppet/functions/reduce.rb +99 -70
- data/lib/puppet/functions/regsubst.rb +23 -26
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/reverse_each.rb +25 -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 +26 -0
- data/lib/puppet/functions/strftime.rb +35 -0
- data/lib/puppet/functions/then.rb +14 -0
- data/lib/puppet/functions/type.rb +31 -0
- data/lib/puppet/functions/unwrap.rb +40 -0
- data/lib/puppet/functions/versioncmp.rb +36 -0
- data/lib/puppet/functions/warning.rb +14 -0
- data/lib/puppet/functions/with.rb +15 -7
- data/lib/puppet/functions/yaml_data.rb +21 -0
- data/lib/puppet/functions.rb +164 -31
- data/lib/puppet/generate/models/type/property.rb +70 -0
- data/lib/puppet/generate/models/type/type.rb +61 -0
- data/lib/puppet/generate/templates/type/pcore.erb +42 -0
- data/lib/puppet/generate/type.rb +239 -0
- data/lib/puppet/graph/rb_tree_map.rb +1 -1
- data/lib/puppet/graph/simple_graph.rb +6 -8
- data/lib/puppet/indirector/catalog/compiler.rb +196 -9
- data/lib/puppet/indirector/catalog/static_compiler.rb +50 -31
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/face.rb +6 -1
- data/lib/puppet/indirector/facts/facter.rb +9 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +68 -3
- 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/key/ca.rb +2 -2
- 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 +36 -12
- data/lib/puppet/indirector/resource_type/parser.rb +10 -3
- data/lib/puppet/indirector/rest.rb +80 -5
- data/lib/puppet/indirector/terminus.rb +4 -4
- data/lib/puppet/info_service/class_information_service.rb +111 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/interface/documentation.rb +1 -1
- data/lib/puppet/interface/face_collection.rb +1 -1
- data/lib/puppet/interface.rb +14 -2
- data/lib/puppet/loaders.rb +6 -0
- data/lib/puppet/metatype/manager.rb +25 -8
- data/lib/puppet/module.rb +48 -20
- data/lib/puppet/module_tool/applications/application.rb +1 -1
- data/lib/puppet/module_tool/applications/builder.rb +5 -4
- data/lib/puppet/module_tool/applications/installer.rb +14 -14
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/applications/upgrader.rb +13 -13
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/errors/installer.rb +2 -2
- data/lib/puppet/module_tool/installed_modules.rb +7 -7
- data/lib/puppet/module_tool/local_tarball.rb +3 -3
- data/lib/puppet/module_tool/metadata.rb +34 -11
- 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/module_tool.rb +5 -5
- 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 +23 -34
- 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/connection.rb +2 -0
- data/lib/puppet/network/http/error.rb +1 -1
- data/lib/puppet/network/http/factory.rb +8 -4
- data/lib/puppet/network/http/handler.rb +3 -2
- data/lib/puppet/network/http/pool.rb +9 -0
- data/lib/puppet/network/http/rack/rest.rb +25 -2
- data/lib/puppet/network/http/webrick.rb +2 -1
- data/lib/puppet/network/rights.rb +1 -11
- data/lib/puppet/node/environment.rb +53 -14
- data/lib/puppet/node/facts.rb +1 -1
- data/lib/puppet/node.rb +39 -8
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter.rb +23 -3
- data/lib/puppet/parser/ast/pops_bridge.rb +101 -27
- data/lib/puppet/parser/ast/resource.rb +5 -0
- data/lib/puppet/parser/ast/resource_instance.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +5 -0
- data/lib/puppet/parser/ast.rb +5 -0
- 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 +343 -28
- data/lib/puppet/parser/e4_parser_adapter.rb +13 -12
- data/lib/puppet/parser/environment_compiler.rb +201 -0
- data/lib/puppet/parser/functions/assert_type.rb +47 -17
- data/lib/puppet/parser/functions/binary_file.rb +24 -0
- data/lib/puppet/parser/functions/break.rb +39 -0
- data/lib/puppet/parser/functions/contain.rb +7 -15
- data/lib/puppet/parser/functions/create_resources.rb +39 -23
- data/lib/puppet/parser/functions/defined.rb +106 -69
- data/lib/puppet/parser/functions/dig.rb +29 -0
- data/lib/puppet/parser/functions/each.rb +86 -28
- data/lib/puppet/parser/functions/epp.rb +30 -38
- data/lib/puppet/parser/functions/file.rb +3 -1
- data/lib/puppet/parser/functions/filter.rb +60 -24
- data/lib/puppet/parser/functions/find_file.rb +28 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +3 -3
- data/lib/puppet/parser/functions/hiera.rb +98 -28
- data/lib/puppet/parser/functions/hiera_array.rb +86 -29
- data/lib/puppet/parser/functions/hiera_hash.rb +96 -31
- data/lib/puppet/parser/functions/hiera_include.rb +96 -41
- data/lib/puppet/parser/functions/include.rb +4 -8
- data/lib/puppet/parser/functions/inline_epp.rb +36 -61
- data/lib/puppet/parser/functions/inline_template.rb +2 -2
- data/lib/puppet/parser/functions/lest.rb +49 -0
- data/lib/puppet/parser/functions/lookup.rb +129 -151
- data/lib/puppet/parser/functions/map.rb +56 -21
- data/lib/puppet/parser/functions/match.rb +29 -13
- data/lib/puppet/parser/functions/new.rb +926 -0
- data/lib/puppet/parser/functions/next.rb +38 -0
- data/lib/puppet/parser/functions/reduce.rb +98 -61
- data/lib/puppet/parser/functions/regsubst.rb +4 -2
- data/lib/puppet/parser/functions/require.rb +4 -27
- data/lib/puppet/parser/functions/return.rb +71 -0
- data/lib/puppet/parser/functions/reverse_each.rb +83 -0
- data/lib/puppet/parser/functions/scanf.rb +25 -31
- data/lib/puppet/parser/functions/slice.rb +18 -25
- data/lib/puppet/parser/functions/split.rb +2 -2
- data/lib/puppet/parser/functions/step.rb +84 -0
- data/lib/puppet/parser/functions/strftime.rb +185 -0
- data/lib/puppet/parser/functions/then.rb +73 -0
- data/lib/puppet/parser/functions/type.rb +53 -0
- data/lib/puppet/parser/functions/with.rb +17 -9
- data/lib/puppet/parser/functions.rb +34 -16
- data/lib/puppet/parser/resource.rb +149 -35
- data/lib/puppet/parser/scope.rb +296 -73
- data/lib/puppet/parser/templatewrapper.rb +2 -1
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/parser.rb +3 -1
- data/lib/puppet/plugins/configuration.rb +11 -2
- data/lib/puppet/plugins/data_providers/data_provider.rb +406 -0
- data/lib/puppet/plugins/data_providers/registry.rb +51 -0
- data/lib/puppet/plugins/data_providers.rb +15 -60
- data/lib/puppet/pops/adaptable.rb +4 -4
- data/lib/puppet/pops/adapters.rb +115 -31
- 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 +70 -65
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
- data/lib/puppet/pops/evaluator/access_operator.rb +261 -142
- data/lib/puppet/pops/evaluator/closure.rb +251 -109
- data/lib/puppet/pops/evaluator/collector_transformer.rb +45 -26
- 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 +5 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +110 -10
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +16 -10
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +239 -117
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +84 -0
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +18 -11
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +60 -51
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +119 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +119 -82
- data/lib/puppet/pops/functions/dispatch.rb +15 -3
- data/lib/puppet/pops/functions/dispatcher.rb +13 -5
- data/lib/puppet/pops/functions/function.rb +30 -4
- data/lib/puppet/pops/issue_reporter.rb +48 -20
- data/lib/puppet/pops/issues.rb +208 -18
- data/lib/puppet/pops/label_provider.rb +18 -4
- data/lib/puppet/pops/loader/base_loader.rb +64 -18
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +53 -48
- data/lib/puppet/pops/loader/loader_paths.rb +110 -6
- data/lib/puppet/pops/loader/module_loaders.rb +72 -28
- data/lib/puppet/pops/loader/null_loader.rb +17 -1
- data/lib/puppet/pops/loader/predefined_loader.rb +29 -0
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +84 -0
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +80 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +16 -4
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +96 -0
- data/lib/puppet/pops/loader/static_loader.rb +139 -38
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +93 -0
- data/lib/puppet/pops/loader/typed_name.rb +48 -0
- data/lib/puppet/pops/loaders.rb +207 -29
- data/lib/puppet/pops/lookup/configured_data_provider.rb +87 -0
- data/lib/puppet/pops/lookup/context.rb +136 -0
- data/lib/puppet/pops/lookup/data_adapter.rb +27 -0
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +55 -0
- data/lib/puppet/pops/lookup/data_hash_function_provider.rb +111 -0
- data/lib/puppet/pops/lookup/data_provider.rb +102 -0
- data/lib/puppet/pops/lookup/environment_data_provider.rb +27 -0
- data/lib/puppet/pops/lookup/explainer.rb +593 -0
- data/lib/puppet/pops/lookup/function_provider.rb +82 -0
- data/lib/puppet/pops/lookup/global_data_provider.rb +49 -0
- data/lib/puppet/pops/lookup/hiera_config.rb +601 -0
- data/lib/puppet/pops/lookup/interpolation.rb +136 -0
- data/lib/puppet/pops/lookup/invocation.rb +212 -0
- data/lib/puppet/pops/lookup/location_resolver.rb +72 -0
- data/lib/puppet/pops/lookup/lookup_adapter.rb +451 -0
- data/lib/puppet/pops/lookup/lookup_key.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +119 -0
- data/lib/puppet/pops/lookup/module_data_provider.rb +58 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +90 -0
- data/lib/puppet/pops/lookup.rb +45 -49
- data/lib/puppet/pops/merge_strategy.rb +183 -47
- data/lib/puppet/pops/migration/migration_checker.rb +58 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +257 -161
- data/lib/puppet/pops/model/model.rb +25 -8
- data/lib/puppet/pops/model/model_label_provider.rb +30 -6
- data/lib/puppet/pops/model/model_meta.rb +50 -3
- data/lib/puppet/pops/model/model_tree_dumper.rb +44 -0
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +155 -38
- data/lib/puppet/pops/parser/eparser.rb +1894 -1314
- 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 +20 -16
- data/lib/puppet/pops/parser/interpolation_support.rb +14 -1
- data/lib/puppet/pops/parser/lexer2.rb +465 -379
- data/lib/puppet/pops/parser/lexer_support.rb +132 -25
- data/lib/puppet/pops/parser/locator.rb +63 -9
- data/lib/puppet/pops/parser/parser_support.rb +49 -40
- data/lib/puppet/pops/parser/slurp_support.rb +37 -12
- data/lib/puppet/pops/patterns.rb +16 -1
- data/lib/puppet/pops/pcore.rb +96 -0
- data/lib/puppet/pops/puppet_stack.rb +43 -0
- data/lib/puppet/pops/resource/param.rb +55 -0
- data/lib/puppet/pops/resource/resource_type_impl.rb +314 -0
- data/lib/puppet/pops/resource/resource_type_set.pcore +22 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +176 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +207 -0
- data/lib/puppet/pops/serialization/deserializer.rb +77 -0
- data/lib/puppet/pops/serialization/extension.rb +157 -0
- data/lib/puppet/pops/serialization/instance_reader.rb +19 -0
- data/lib/puppet/pops/serialization/instance_writer.rb +14 -0
- data/lib/puppet/pops/serialization/json.rb +297 -0
- data/lib/puppet/pops/serialization/object.rb +71 -0
- data/lib/puppet/pops/serialization/rgen.rb +152 -0
- data/lib/puppet/pops/serialization/serializer.rb +118 -0
- data/lib/puppet/pops/serialization/time_factory.rb +67 -0
- data/lib/puppet/pops/serialization.rb +17 -0
- data/lib/puppet/pops/time/timespan.rb +718 -0
- data/lib/puppet/pops/time/timestamp.rb +148 -0
- data/lib/puppet/pops/types/annotatable.rb +36 -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 +141 -0
- data/lib/puppet/pops/types/iterable.rb +308 -0
- data/lib/puppet/pops/types/p_binary_type.rb +220 -0
- data/lib/puppet/pops/types/p_meta_type.rb +83 -0
- data/lib/puppet/pops/types/p_object_type.rb +888 -0
- data/lib/puppet/pops/types/p_runtime_type.rb +115 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +187 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +141 -0
- data/lib/puppet/pops/types/p_sensitive_type.rb +73 -0
- data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
- data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
- data/lib/puppet/pops/types/p_type_set_type.rb +352 -0
- data/lib/puppet/pops/types/puppet_object.rb +16 -0
- data/lib/puppet/pops/types/recursion_guard.rb +136 -0
- data/lib/puppet/pops/types/ruby_generator.rb +275 -0
- data/lib/puppet/pops/types/string_converter.rb +1033 -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 +244 -1186
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +270 -164
- data/lib/puppet/pops/types/type_formatter.rb +686 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1087 -0
- data/lib/puppet/pops/types/type_parser.rb +376 -278
- data/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/lib/puppet/pops/types/types.rb +3247 -287
- data/lib/puppet/pops/utils.rb +11 -10
- data/lib/puppet/pops/validation/checker4_0.rb +289 -75
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +13 -5
- data/lib/puppet/pops/validation.rb +56 -18
- data/lib/puppet/pops/visitor.rb +9 -6
- data/lib/puppet/pops.rb +44 -25
- data/lib/puppet/property/ensure.rb +1 -1
- data/lib/puppet/property.rb +67 -7
- data/lib/puppet/provider/aixobject.rb +4 -4
- 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/aix.rb +4 -4
- 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 +23 -7
- data/lib/puppet/provider/macauthorization/macauthorization.rb +11 -10
- data/lib/puppet/provider/mailalias/aliases.rb +1 -1
- data/lib/puppet/provider/mcx/mcxcontent.rb +5 -4
- data/lib/puppet/provider/mount/parsed.rb +159 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +55 -62
- data/lib/puppet/provider/nameservice.rb +15 -0
- data/lib/puppet/provider/package/appdmg.rb +7 -6
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +1 -1
- data/lib/puppet/provider/package/dnf.rb +46 -0
- data/lib/puppet/provider/package/gem.rb +29 -3
- data/lib/puppet/provider/package/nim.rb +2 -2
- data/lib/puppet/provider/package/openbsd.rb +7 -7
- data/lib/puppet/provider/package/pacman.rb +11 -10
- data/lib/puppet/provider/package/pip.rb +83 -22
- data/lib/puppet/provider/package/pip3.rb +20 -0
- data/lib/puppet/provider/package/pkg.rb +12 -8
- data/lib/puppet/provider/package/pkgdmg.rb +11 -8
- data/lib/puppet/provider/package/pkgin.rb +4 -4
- data/lib/puppet/provider/package/pkgng.rb +143 -0
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +48 -8
- 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 +122 -16
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/tdnf.rb +28 -0
- 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 +62 -83
- data/lib/puppet/provider/package/zypper.rb +69 -15
- data/lib/puppet/provider/package.rb +6 -2
- data/lib/puppet/provider/parsedfile.rb +2 -2
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +39 -7
- data/lib/puppet/provider/service/base.rb +4 -3
- data/lib/puppet/provider/service/bsd.rb +9 -9
- data/lib/puppet/provider/service/daemontools.rb +5 -5
- data/lib/puppet/provider/service/debian.rb +14 -5
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/init.rb +27 -3
- data/lib/puppet/provider/service/launchd.rb +57 -19
- 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 +4 -4
- data/lib/puppet/provider/service/smf.rb +59 -8
- data/lib/puppet/provider/service/src.rb +27 -0
- data/lib/puppet/provider/service/systemd.rb +141 -22
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +20 -10
- data/lib/puppet/provider/user/aix.rb +4 -3
- data/lib/puppet/provider/user/directoryservice.rb +43 -66
- data/lib/puppet/provider/user/hpux.rb +1 -1
- 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 +19 -2
- data/lib/puppet/provider/user/windows_adsi.rb +51 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +9 -6
- data/lib/puppet/provider/zfs/zfs.rb +2 -2
- data/lib/puppet/provider/zone/solaris.rb +6 -3
- data/lib/puppet/provider/zpool/zpool.rb +2 -2
- data/lib/puppet/provider.rb +9 -7
- data/lib/puppet/reference/configuration.rb +13 -5
- data/lib/puppet/reference/indirection.rb +2 -2
- data/lib/puppet/reference/providers.rb +2 -3
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reference/type.rb +1 -1
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource/capability_finder.rb +128 -0
- data/lib/puppet/resource/catalog.rb +167 -40
- data/lib/puppet/resource/status.rb +30 -5
- data/lib/puppet/resource/type.rb +247 -50
- data/lib/puppet/resource/type_collection.rb +83 -10
- data/lib/puppet/resource.rb +212 -146
- data/lib/puppet/settings/base_setting.rb +9 -3
- data/lib/puppet/settings/config_file.rb +3 -2
- data/lib/puppet/settings/directory_setting.rb +6 -0
- data/lib/puppet/settings/environment_conf.rb +26 -6
- data/lib/puppet/settings/file_or_directory_setting.rb +6 -0
- data/lib/puppet/settings/file_setting.rb +20 -9
- data/lib/puppet/settings/ini_file.rb +2 -2
- data/lib/puppet/settings/server_list_setting.rb +20 -0
- data/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/lib/puppet/settings.rb +87 -28
- data/lib/puppet/ssl/certificate_authority/interface.rb +166 -26
- data/lib/puppet/ssl/certificate_authority.rb +45 -11
- 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/host.rb +26 -4
- data/lib/puppet/ssl/oids.rb +43 -3
- data/lib/puppet/ssl/validator/default_validator.rb +3 -3
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +0 -2
- data/lib/puppet/test/test_helper.rb +18 -7
- data/lib/puppet/transaction/additional_resource_generator.rb +101 -8
- data/lib/puppet/transaction/event.rb +29 -2
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/transaction/persistence.rb +84 -0
- data/lib/puppet/transaction/report.rb +86 -4
- data/lib/puppet/transaction/resource_harness.rb +95 -35
- data/lib/puppet/transaction.rb +64 -36
- data/lib/puppet/type/augeas.rb +13 -4
- data/lib/puppet/type/component.rb +11 -0
- data/lib/puppet/type/cron.rb +13 -13
- data/lib/puppet/type/exec.rb +27 -18
- data/lib/puppet/type/file/checksum.rb +1 -0
- data/lib/puppet/type/file/checksum_value.rb +53 -0
- data/lib/puppet/type/file/content.rb +36 -121
- data/lib/puppet/type/file/data_sync.rb +92 -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 +146 -46
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +15 -3
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/interface.rb +8 -3
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/mount.rb +25 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +32 -12
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/schedule.rb +5 -5
- data/lib/puppet/type/scheduled_task.rb +14 -1
- data/lib/puppet/type/service.rb +24 -0
- data/lib/puppet/type/ssh_authorized_key.rb +17 -11
- data/lib/puppet/type/sshkey.rb +5 -3
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +10 -5
- data/lib/puppet/type/user.rb +80 -25
- data/lib/puppet/type/yumrepo.rb +28 -8
- data/lib/puppet/type/zone.rb +6 -6
- data/lib/puppet/type.rb +162 -40
- data/lib/puppet/util/autoload.rb +16 -11
- data/lib/puppet/util/checksums.rb +74 -31
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/command_line.rb +10 -2
- data/lib/puppet/util/execution.rb +26 -10
- data/lib/puppet/util/feature.rb +1 -1
- data/lib/puppet/util/filetype.rb +11 -5
- data/lib/puppet/util/http_proxy.rb +132 -0
- data/lib/puppet/util/inifile.rb +1 -1
- data/lib/puppet/util/instance_loader.rb +1 -1
- data/lib/puppet/util/log/destinations.rb +23 -2
- data/lib/puppet/util/log.rb +78 -9
- data/lib/puppet/util/logging.rb +82 -3
- 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/config.rb +1 -1
- 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 +151 -0
- data/lib/puppet/util/profiler/aggregate.rb +1 -1
- data/lib/puppet/util/profiler/around_profiler.rb +1 -1
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/psych_support.rb +1 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +2 -1
- data/lib/puppet/util/rdoc.rb +2 -2
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/rubygems.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 +8 -2
- data/lib/puppet/util/watcher/periodic_watcher.rb +2 -2
- data/lib/puppet/util/windows/access_control_entry.rb +2 -2
- data/lib/puppet/util/windows/access_control_list.rb +3 -3
- data/lib/puppet/util/windows/adsi.rb +212 -75
- 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 +107 -18
- data/lib/puppet/util/windows/principal.rb +190 -0
- data/lib/puppet/util/windows/process.rb +88 -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 +38 -37
- 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 +99 -43
- data/lib/puppet/util/windows/user.rb +32 -14
- data/lib/puppet/util/windows.rb +5 -0
- data/lib/puppet/util/yaml.rb +15 -3
- data/lib/puppet/util.rb +124 -23
- data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +1 -1
- data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +1 -1
- data/lib/puppet/vendor/load_semantic_puppet.rb +1 -0
- data/lib/puppet/vendor/pathspec/LICENSE +2 -2
- data/lib/puppet/vendor/pathspec/README.md +1 -1
- data/lib/puppet/vendor/pathspec/lib/pathspec.rb +2 -1
- data/lib/puppet/vendor/require_vendored.rb +0 -1
- data/lib/puppet/vendor/rgen/README.rdoc +1 -1
- data/lib/puppet/vendor/rgen_patch.rb +1 -1
- data/lib/puppet/vendor/semantic/lib/semantic.rb +4 -6
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/graph.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/graph_node.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/module_release.rb +17 -5
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/source.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/unsatisfiable_graph.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency.rb +7 -7
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +3 -0
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/locales/config.yaml +21 -0
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/version.rb +48 -21
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/version_range.rb +15 -17
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +17 -0
- data/lib/puppet/version.rb +2 -2
- data/lib/puppet.rb +85 -2
- data/lib/puppet_x.rb +7 -1
- data/lib/semver.rb +36 -13
- data/locales/config.yaml +29 -0
- data/locales/puppet.pot +79 -0
- data/man/man5/puppet.conf.5 +61 -19
- 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 +22 -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/environment/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 +48 -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 +2 -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/server1.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server2.yaml +1 -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 +20 -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/backend/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/lib/puppet/bindings/backend/default.rb +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/lib/puppet_x/backend/special_data_provider_factory.rb +23 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +2 -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/data_providers/environments/sample/modules/dataprovider/manifests/init.pp +1 -1
- data/spec/fixtures/unit/functions/lookup/data/common.yaml +19 -0
- data/spec/fixtures/unit/functions/lookup_fixture/data/common.yaml +19 -0
- data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/bad_data/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/data/empty.json +0 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/data/empty_key.json +1 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/data/empty_key.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/data/empty.yaml +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/data/first.json +4 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/hiera.yaml +8 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/meta/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/meta/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/metawcp/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup_fixture/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/no_modules/manifests/site.pp +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 +15 -14
- data/spec/integration/application/apply_spec.rb +432 -29
- data/spec/integration/application/doc_spec.rb +0 -0
- data/spec/integration/application/lookup_spec.rb +155 -0
- data/spec/integration/configurer_spec.rb +0 -0
- data/spec/integration/data_binding_spec.rb +195 -0
- data/spec/integration/defaults_spec.rb +27 -2
- data/spec/integration/directory_environments_spec.rb +16 -0
- data/spec/integration/environments/default_manifest_spec.rb +16 -16
- data/spec/integration/environments/setting_hooks_spec.rb +1 -1
- data/spec/integration/environments/settings_spec.rb +32 -4
- data/spec/integration/faces/ca_spec.rb +0 -0
- data/spec/integration/faces/config_spec.rb +80 -0
- data/spec/integration/faces/documentation_spec.rb +1 -1
- 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/network/http/api/indirected_routes_spec.rb +33 -0
- data/spec/integration/node/environment_spec.rb +34 -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 +18 -0
- data/spec/integration/parser/compiler_spec.rb +877 -666
- data/spec/integration/parser/dynamic_scoping_spec.rb +67 -0
- data/spec/integration/parser/parameter_defaults_spec.rb +358 -0
- data/spec/integration/parser/pcore_resource_spec.rb +245 -0
- data/spec/integration/parser/resource_expressions_spec.rb +10 -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/service/windows_spec.rb +3 -2
- data/spec/integration/provider/ssh_authorized_key_spec.rb +0 -0
- data/spec/integration/provider/yumrepo_spec.rb +4 -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 +32 -0
- data/spec/integration/transaction/report_spec.rb +682 -0
- data/spec/integration/transaction_spec.rb +126 -2
- data/spec/integration/type/exec_spec.rb +0 -0
- data/spec/integration/type/file_spec.rb +553 -51
- 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 +30 -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/adsi_spec.rb +99 -0
- data/spec/integration/util/windows/principal_spec.rb +250 -0
- data/spec/integration/util/windows/process_spec.rb +35 -2
- data/spec/{unit → integration}/util/windows/registry_spec.rb +92 -2
- data/spec/integration/util/windows/security_spec.rb +75 -21
- data/spec/integration/util/windows/user_spec.rb +27 -5
- 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 +32 -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/module_tool/shared_functions.rb +2 -2
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +1 -1
- data/spec/lib/puppet_spec/network.rb +12 -8
- data/spec/lib/puppet_spec/pops.rb +13 -0
- data/spec/lib/puppet_spec/unindent.rb +5 -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 +106 -0
- data/spec/shared_examples/rhel_package_provider.rb +357 -0
- data/spec/spec_helper.rb +16 -2
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +12 -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 +20 -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 +16 -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 +532 -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/capability_spec.rb +416 -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 +18 -15
- data/spec/unit/configurer_spec.rb +336 -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/{sample_data_provider_spec.rb → custom_data_provider_spec.rb} +14 -16
- data/spec/unit/data_providers/function_data_provider_spec.rb +30 -3
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +361 -0
- data/spec/unit/defaults_spec.rb +47 -0
- data/spec/unit/environments_spec.rb +26 -4
- data/spec/unit/external/pson_spec.rb +0 -0
- data/spec/unit/face/ca_spec.rb +10 -0
- data/spec/unit/face/catalog_spec.rb +0 -0
- data/spec/unit/face/certificate_request_spec.rb +10 -0
- data/spec/unit/face/certificate_revocation_list_spec.rb +10 -0
- data/spec/unit/face/certificate_spec.rb +0 -0
- data/spec/unit/face/config_spec.rb +47 -0
- data/spec/unit/face/epp_face_spec.rb +24 -5
- data/spec/unit/face/facts_spec.rb +0 -0
- data/spec/unit/face/file_spec.rb +4 -0
- data/spec/unit/face/generate_spec.rb +230 -0
- data/spec/unit/face/help_spec.rb +70 -0
- data/spec/unit/face/key_spec.rb +10 -0
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/face/parser_spec.rb +49 -2
- data/spec/unit/face/plugin_spec.rb +29 -4
- data/spec/unit/face/status_spec.rb +10 -0
- 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 +373 -6
- data/spec/unit/functions/assert_type_spec.rb +48 -8
- data/spec/unit/functions/binary_file_spec.rb +46 -0
- data/spec/unit/functions/break_spec.rb +89 -0
- data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
- 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/find_file_spec.rb +69 -0
- data/spec/unit/functions/hiera_spec.rb +261 -49
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/inline_epp_spec.rb +4 -4
- data/spec/unit/functions/lest_spec.rb +34 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_fixture_spec.rb +693 -0
- data/spec/unit/functions/lookup_spec.rb +1352 -272
- data/spec/unit/functions/match_spec.rb +2 -2
- data/spec/unit/functions/new_spec.rb +694 -0
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/regsubst_spec.rb +30 -9
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/functions/reverse_each_spec.rb +108 -0
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/{parser/functions → functions}/shared.rb +15 -12
- data/spec/unit/functions/split_spec.rb +11 -3
- data/spec/unit/functions/step_spec.rb +113 -0
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions/then_spec.rb +40 -0
- data/spec/unit/functions/type_spec.rb +35 -0
- data/spec/unit/functions/unwrap_spec.rb +29 -0
- data/spec/unit/functions/versioncmp_spec.rb +36 -0
- data/spec/unit/functions4_spec.rb +321 -71
- data/spec/unit/graph/rb_tree_map_spec.rb +1 -1
- 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 +1 -1
- data/spec/unit/hiera/scope_spec.rb +6 -3
- 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 +10 -2
- data/spec/unit/indirector/facts/facter_spec.rb +7 -7
- 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 +17 -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 +107 -9
- 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 +27 -0
- data/spec/unit/man_spec.rb +1 -1
- data/spec/unit/module_spec.rb +84 -33
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +44 -9
- data/spec/unit/module_tool/applications/installer_spec.rb +11 -2
- data/spec/unit/module_tool/applications/unpacker_spec.rb +2 -1
- data/spec/unit/module_tool/applications/upgrader_spec.rb +9 -1
- data/spec/unit/module_tool/installed_modules_spec.rb +6 -6
- data/spec/unit/module_tool/metadata_spec.rb +31 -2
- data/spec/unit/module_tool/tar/mini_spec.rb +3 -3
- data/spec/unit/module_tool_spec.rb +3 -3
- 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 +70 -71
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +60 -0
- data/spec/unit/network/http/api/master/v3_spec.rb +22 -4
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +25 -19
- data/spec/unit/network/http/error_spec.rb +2 -1
- data/spec/unit/network/http/factory_spec.rb +14 -0
- data/spec/unit/network/http/handler_spec.rb +11 -8
- 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 +1 -1
- 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 +4 -4
- 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 +11 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +120 -33
- data/spec/unit/parser/environment_compiler_spec.rb +688 -0
- data/spec/unit/parser/files_spec.rb +0 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +86 -5
- 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_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/inline_template_spec.rb +0 -0
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/realize_spec.rb +0 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/scanf_spec.rb +0 -0
- data/spec/unit/parser/functions/shellquote_spec.rb +0 -0
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- 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 +31 -32
- data/spec/unit/parser/scope_spec.rb +85 -18
- 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 +133 -18
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
- 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 +155 -41
- 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 +133 -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 +66 -1
- data/spec/unit/pops/loaders/environment_loader_spec.rb +172 -0
- data/spec/unit/pops/loaders/loader_paths_spec.rb +1 -1
- data/spec/unit/pops/loaders/loaders_spec.rb +292 -51
- data/spec/unit/pops/loaders/module_loaders_spec.rb +2 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +83 -18
- data/spec/unit/pops/lookup/context_spec.rb +178 -0
- data/spec/unit/pops/lookup/interpolation_spec.rb +333 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +197 -0
- data/spec/unit/pops/merge_strategy_spec.rb +18 -0
- data/spec/unit/pops/migration_spec.rb +53 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +369 -10
- data/spec/unit/pops/parser/parse_application_spec.rb +35 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +31 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +25 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +40 -0
- data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
- data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_site_spec.rb +51 -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/puppet_stack_spec.rb +79 -0
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +111 -0
- data/spec/unit/pops/serialization/packer_spec.rb +154 -0
- data/spec/unit/pops/serialization/rgen_spec.rb +88 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +314 -0
- data/spec/unit/pops/time/timespan_spec.rb +121 -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_binary_type_spec.rb +243 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +1167 -0
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +327 -0
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +169 -0
- data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +453 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +93 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +577 -0
- data/spec/unit/pops/types/string_converter_spec.rb +1029 -0
- data/spec/unit/pops/types/type_acceptor_spec.rb +106 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +43 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +1107 -871
- data/spec/unit/pops/types/type_factory_spec.rb +132 -91
- data/spec/unit/pops/types/type_formatter_spec.rb +396 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +219 -0
- data/spec/unit/pops/types/type_parser_spec.rb +206 -36
- data/spec/unit/pops/types/types_spec.rb +600 -0
- data/spec/unit/pops/validation_spec.rb +66 -0
- data/spec/unit/pops/validator/validator_spec.rb +400 -18
- 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 +49 -12
- 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 +88 -18
- 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 +42 -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 +3 -3
- data/spec/unit/provider/package/base_spec.rb +18 -0
- data/spec/unit/provider/package/dnf_spec.rb +30 -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 +173 -46
- data/spec/unit/provider/package/pkg_spec.rb +137 -99
- data/spec/unit/provider/package/pkgdmg_spec.rb +32 -8
- data/spec/unit/provider/package/pkgin_spec.rb +23 -13
- data/spec/unit/provider/package/pkgng_spec.rb +186 -0
- data/spec/unit/provider/package/pkgutil_spec.rb +0 -0
- data/spec/unit/provider/package/portage_spec.rb +64 -8
- data/spec/unit/provider/package/puppet_gem_spec.rb +0 -0
- data/spec/unit/provider/package/rpm_spec.rb +168 -11
- data/spec/unit/provider/package/sun_spec.rb +0 -0
- data/spec/unit/provider/package/tdnf_spec.rb +18 -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 +45 -1
- data/spec/unit/provider/package/windows_spec.rb +8 -2
- data/spec/unit/provider/package/yum_spec.rb +29 -466
- 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 +523 -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 +44 -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 +38 -0
- data/spec/unit/provider/service/freebsd_spec.rb +17 -0
- data/spec/unit/provider/service/gentoo_spec.rb +8 -0
- data/spec/unit/provider/service/init_spec.rb +42 -1
- data/spec/unit/provider/service/launchd_spec.rb +124 -25
- data/spec/unit/provider/service/openbsd_spec.rb +1 -0
- data/spec/unit/provider/service/openrc_spec.rb +7 -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 +77 -13
- data/spec/unit/provider/service/src_spec.rb +26 -4
- data/spec/unit/provider/service/systemd_spec.rb +228 -39
- data/spec/unit/provider/service/upstart_spec.rb +64 -0
- data/spec/unit/provider/service/windows_spec.rb +0 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +42 -18
- data/spec/unit/provider/user/aix_spec.rb +7 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +164 -83
- 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 +1 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +160 -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 +15 -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 +147 -0
- data/spec/unit/resource/catalog_spec.rb +235 -10
- data/spec/unit/resource/status_spec.rb +0 -0
- data/spec/unit/resource/type_collection_spec.rb +23 -2
- data/spec/unit/resource/type_spec.rb +161 -10
- data/spec/unit/resource_spec.rb +137 -48
- data/spec/unit/semver_spec.rb +14 -0
- 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/ini_file_spec.rb +58 -1
- 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 +116 -3
- data/spec/unit/ssl/base_spec.rb +0 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +180 -13
- data/spec/unit/ssl/certificate_authority_spec.rb +80 -26
- data/spec/unit/ssl/certificate_factory_spec.rb +0 -0
- data/spec/unit/ssl/certificate_request_spec.rb +1 -1
- 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 +3 -3
- 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 +24 -13
- data/spec/unit/status_spec.rb +0 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +160 -31
- data/spec/unit/transaction/event_manager_spec.rb +0 -0
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/persistence_spec.rb +178 -0
- data/spec/unit/transaction/report_spec.rb +138 -2
- data/spec/unit/transaction/resource_harness_spec.rb +81 -37
- data/spec/unit/transaction_spec.rb +50 -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 +59 -208
- 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 +161 -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 +50 -8
- 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 +40 -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 +3 -7
- 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 +119 -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 +11 -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 +1 -1
- 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 +4 -4
- 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 +95 -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 +135 -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 +8 -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 +4 -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 +196 -60
- data/spec/unit/util/windows/api_types_spec.rb +42 -0
- data/spec/unit/util/windows/file_spec.rb +89 -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 +76 -24
- data/spec/unit/util/yaml_spec.rb +13 -1
- data/spec/unit/util_spec.rb +219 -15
- data/spec/unit/version_spec.rb +15 -0
- data/spec/watchr.rb +0 -0
- data/tasks/cfpropertylist.rake +15 -0
- data/tasks/i18n.rake +20 -0
- metadata +3701 -3043
- checksums.yaml +0 -7
- data/ext/puppet-nm-dispatcher +0 -13
- data/ext/puppetlisten/puppetlisten.rb +0 -77
- data/ext/puppetlisten/puppetrun.rb +0 -38
- 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/resource/type_collection_helper.rb +0 -7
- 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/lib/puppet/vendor/semantic/Gemfile +0 -20
- data/lib/puppet/vendor/semantic/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/semantic/Rakefile +0 -69
- data/lib/puppet/vendor/semantic/spec/spec_helper.rb +0 -24
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +0 -141
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +0 -162
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +0 -143
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +0 -5
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +0 -44
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +0 -383
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +0 -307
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +0 -608
- data/spec/fixtures/unit/data_providers/environments/sample/manifests/site.pp +0 -6
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +0 -3
- data/spec/integration/data_binding.rb +0 -104
- data/spec/integration/parser/functions/require_spec.rb +0 -43
- data/spec/integration/provider/package_spec.rb +0 -33
- data/spec/unit/parser/functions/defined_spec.rb +0 -120
- data/spec/unit/parser/functions/include_spec.rb +0 -55
- data/spec/unit/parser/functions/require_spec.rb +0 -68
- data/spec/unit/resource/type_collection_helper_spec.rb +0 -24
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/environment.conf +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/lib/puppet/functions/environment/data.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/lib/puppet/bindings/abc/default.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/manifests/init.pp +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bad_data/lib/puppet/bindings/bad_data/default.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/lib/puppet/bindings/bca/default.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/lib/puppet/functions/bca/data.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/manifests/init.pp +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/no_provider/manifests/init.pp +0 -0
- /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 SemanticPuppet::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,113 @@ 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
|
+
value_type = common_type(t1.value_type, t2.value_type)
|
|
393
|
+
return PHashType.new(key_type, value_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
|
-
|
|
417
|
+
if t1.is_a?(PStringType) && (t2.is_a?(PStringType) || t2.is_a?(PEnumType))
|
|
418
|
+
if(t2.is_a?(PEnumType))
|
|
419
|
+
return t1.value.nil? ? PEnumType::DEFAULT : PEnumType.new(t2.values | [t1.value])
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
if t1.size_type.nil? || t2.size_type.nil?
|
|
423
|
+
return t1.value.nil? || t2.value.nil? ? PStringType::DEFAULT : PEnumType.new([t1.value, t2.value])
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
return PStringType.new(common_type(t1.size_type, t2.size_type))
|
|
602
427
|
end
|
|
603
428
|
|
|
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
|
|
429
|
+
if t1.is_a?(PPatternType) && t2.is_a?(PPatternType)
|
|
430
|
+
return PPatternType.new(t1.patterns | t2.patterns)
|
|
609
431
|
end
|
|
610
432
|
|
|
611
|
-
if t1.is_a?(
|
|
433
|
+
if t1.is_a?(PEnumType) && (t2.is_a?(PStringType) || t2.is_a?(PEnumType))
|
|
612
434
|
# The common type is one that complies with either set
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
435
|
+
if t2.is_a?(PEnumType)
|
|
436
|
+
return PEnumType.new(t1.values | t2.values)
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
return t2.value.nil? ? PEnumType::DEFAULT : PEnumType.new(t1.values | [t2.value])
|
|
616
440
|
end
|
|
617
441
|
|
|
618
|
-
if t1.is_a?(
|
|
442
|
+
if t1.is_a?(PVariantType) && t2.is_a?(PVariantType)
|
|
619
443
|
# The common type is one that complies with either set
|
|
620
|
-
|
|
621
|
-
t.types = (t1.types | t2.types).map(&:copy)
|
|
622
|
-
return t
|
|
444
|
+
return PVariantType.maybe_create(t1.types | t2.types)
|
|
623
445
|
end
|
|
624
446
|
|
|
625
|
-
if t1.is_a?(
|
|
447
|
+
if t1.is_a?(PRegexpType) && t2.is_a?(PRegexpType)
|
|
626
448
|
# if they were identical, the general rule would return a parameterized regexp
|
|
627
449
|
# since they were not, the result is a generic regexp type
|
|
628
|
-
return
|
|
450
|
+
return PRegexpType::DEFAULT
|
|
629
451
|
end
|
|
630
452
|
|
|
631
|
-
if t1.is_a?(
|
|
453
|
+
if t1.is_a?(PCallableType) && t2.is_a?(PCallableType)
|
|
632
454
|
# They do not have the same signature, and one is not assignable to the other,
|
|
633
455
|
# what remains is the most general form of Callable
|
|
634
|
-
return
|
|
456
|
+
return PCallableType::DEFAULT
|
|
635
457
|
end
|
|
636
458
|
|
|
637
459
|
# Common abstract types, from most specific to most general
|
|
638
460
|
if common_numeric?(t1, t2)
|
|
639
|
-
return
|
|
461
|
+
return PNumericType::DEFAULT
|
|
640
462
|
end
|
|
641
463
|
|
|
642
464
|
if common_scalar?(t1, t2)
|
|
643
|
-
return
|
|
465
|
+
return PScalarType::DEFAULT
|
|
644
466
|
end
|
|
645
467
|
|
|
646
468
|
if common_data?(t1,t2)
|
|
647
|
-
return
|
|
469
|
+
return PDataType::DEFAULT
|
|
648
470
|
end
|
|
649
471
|
|
|
650
472
|
# 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
|
|
473
|
+
if t1.is_a?(PType) && t2.is_a?(PType)
|
|
474
|
+
return PType.new(common_type(t1.type, t2.type))
|
|
655
475
|
end
|
|
656
476
|
|
|
657
477
|
# If both are Runtime types
|
|
658
|
-
if t1.is_a?(
|
|
478
|
+
if t1.is_a?(PRuntimeType) && t2.is_a?(PRuntimeType)
|
|
659
479
|
if t1.runtime == t2.runtime && t1.runtime_type_name == t2.runtime_type_name
|
|
660
480
|
return t1
|
|
661
481
|
end
|
|
662
482
|
# finding the common super class requires that names are resolved to class
|
|
663
483
|
# NOTE: This only supports runtime type of :ruby
|
|
664
|
-
c1 =
|
|
665
|
-
c2 =
|
|
484
|
+
c1 = ClassLoader.provide_from_type(t1)
|
|
485
|
+
c2 = ClassLoader.provide_from_type(t2)
|
|
666
486
|
if c1 && c2
|
|
667
487
|
c2_superclasses = superclasses(c2)
|
|
668
488
|
superclasses(c1).each do|c1_super|
|
|
669
489
|
c2_superclasses.each do |c2_super|
|
|
670
490
|
if c1_super == c2_super
|
|
671
|
-
return
|
|
491
|
+
return PRuntimeType.new(:ruby, c1_super.name)
|
|
672
492
|
end
|
|
673
493
|
end
|
|
674
494
|
end
|
|
@@ -676,9 +496,7 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
676
496
|
end
|
|
677
497
|
|
|
678
498
|
# They better both be Any type, or the wrong thing was asked and nil is returned
|
|
679
|
-
|
|
680
|
-
return Types::PAnyType.new()
|
|
681
|
-
end
|
|
499
|
+
t1.is_a?(PAnyType) && t2.is_a?(PAnyType) ? PAnyType::DEFAULT : nil
|
|
682
500
|
end
|
|
683
501
|
|
|
684
502
|
# Produces the superclasses of the given class, including the class
|
|
@@ -695,14 +513,16 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
695
513
|
# @api public
|
|
696
514
|
#
|
|
697
515
|
def string(t)
|
|
698
|
-
|
|
516
|
+
Puppet.deprecation_warning('TypeCalculator.string is deprecated. Use TypeFormatter')
|
|
517
|
+
TypeFormatter.singleton.string(t)
|
|
699
518
|
end
|
|
700
519
|
|
|
701
520
|
# Produces a debug string representing the type (possibly with more information that the regular string format)
|
|
702
521
|
# @api public
|
|
703
522
|
#
|
|
704
523
|
def debug_string(t)
|
|
705
|
-
|
|
524
|
+
Puppet.deprecation_warning('TypeCalculator.debug_string is deprecated. Use TypeFormatter')
|
|
525
|
+
TypeFormatter.singleton.debug_string(t)
|
|
706
526
|
end
|
|
707
527
|
|
|
708
528
|
|
|
@@ -717,19 +537,24 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
717
537
|
# @api public
|
|
718
538
|
#
|
|
719
539
|
def infer_and_reduce_type(enumerable)
|
|
720
|
-
reduce_type(enumerable.
|
|
540
|
+
reduce_type(enumerable.map {|o| infer(o) })
|
|
721
541
|
end
|
|
722
542
|
|
|
723
|
-
# The type of all
|
|
543
|
+
# The type of all modules is PType
|
|
724
544
|
# @api private
|
|
725
545
|
#
|
|
726
|
-
def
|
|
727
|
-
|
|
546
|
+
def infer_Module(o)
|
|
547
|
+
PType::new(PRuntimeType.new(:ruby, o.name))
|
|
728
548
|
end
|
|
729
549
|
|
|
730
550
|
# @api private
|
|
731
551
|
def infer_Closure(o)
|
|
732
|
-
o.type
|
|
552
|
+
o.type
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
# @api private
|
|
556
|
+
def infer_Iterator(o)
|
|
557
|
+
PIteratorType.new(o.element_type)
|
|
733
558
|
end
|
|
734
559
|
|
|
735
560
|
# @api private
|
|
@@ -739,16 +564,21 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
739
564
|
|
|
740
565
|
# @api private
|
|
741
566
|
def infer_Object(o)
|
|
742
|
-
|
|
567
|
+
if o.is_a?(PuppetObject)
|
|
568
|
+
o._ptype
|
|
569
|
+
else
|
|
570
|
+
name = o.class.name
|
|
571
|
+
ir = Loaders.implementation_registry
|
|
572
|
+
type = ir.nil? ? nil : ir.type_for_module(name)
|
|
573
|
+
type.nil? ? PRuntimeType.new(:ruby, name) : type
|
|
574
|
+
end
|
|
743
575
|
end
|
|
744
576
|
|
|
745
577
|
# The type of all types is PType
|
|
746
578
|
# @api private
|
|
747
579
|
#
|
|
748
580
|
def infer_PAnyType(o)
|
|
749
|
-
|
|
750
|
-
type.type = o.copy
|
|
751
|
-
type
|
|
581
|
+
PType.new(o)
|
|
752
582
|
end
|
|
753
583
|
|
|
754
584
|
# The type of all types is PType
|
|
@@ -756,45 +586,32 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
756
586
|
# @api private
|
|
757
587
|
#
|
|
758
588
|
def infer_PType(o)
|
|
759
|
-
|
|
760
|
-
type.type = o.copy
|
|
761
|
-
type
|
|
589
|
+
PType.new(o)
|
|
762
590
|
end
|
|
763
591
|
|
|
764
592
|
# @api private
|
|
765
593
|
def infer_String(o)
|
|
766
|
-
|
|
767
|
-
t.addValues(o)
|
|
768
|
-
t.size_type = size_as_type(o)
|
|
769
|
-
t
|
|
594
|
+
PStringType.new(o)
|
|
770
595
|
end
|
|
771
596
|
|
|
772
597
|
# @api private
|
|
773
598
|
def infer_Float(o)
|
|
774
|
-
|
|
775
|
-
t.from = o
|
|
776
|
-
t.to = o
|
|
777
|
-
t
|
|
599
|
+
PFloatType.new(o, o)
|
|
778
600
|
end
|
|
779
601
|
|
|
780
602
|
# @api private
|
|
781
603
|
def infer_Integer(o)
|
|
782
|
-
|
|
783
|
-
t.from = o
|
|
784
|
-
t.to = o
|
|
785
|
-
t
|
|
604
|
+
PIntegerType.new(o, o)
|
|
786
605
|
end
|
|
787
606
|
|
|
788
607
|
# @api private
|
|
789
608
|
def infer_Regexp(o)
|
|
790
|
-
|
|
791
|
-
t.pattern = o.source
|
|
792
|
-
t
|
|
609
|
+
PRegexpType.new(o.source)
|
|
793
610
|
end
|
|
794
611
|
|
|
795
612
|
# @api private
|
|
796
613
|
def infer_NilClass(o)
|
|
797
|
-
|
|
614
|
+
PUndefType::DEFAULT
|
|
798
615
|
end
|
|
799
616
|
|
|
800
617
|
# @api private
|
|
@@ -806,16 +623,15 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
806
623
|
case p[0]
|
|
807
624
|
when :rest
|
|
808
625
|
max = :default
|
|
809
|
-
break
|
|
626
|
+
break PAnyType::DEFAULT
|
|
810
627
|
when :req
|
|
811
628
|
min += 1
|
|
812
629
|
end
|
|
813
630
|
max += 1
|
|
814
|
-
|
|
631
|
+
PAnyType::DEFAULT
|
|
815
632
|
end
|
|
816
|
-
mapped_types
|
|
817
|
-
|
|
818
|
-
Types::TypeFactory.callable(*mapped_types)
|
|
633
|
+
param_types = Types::PTupleType.new(mapped_types, Types::PIntegerType.new(min, max))
|
|
634
|
+
Types::PCallableType.new(param_types)
|
|
819
635
|
end
|
|
820
636
|
|
|
821
637
|
# @api private
|
|
@@ -828,72 +644,88 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
828
644
|
def infer_Symbol(o)
|
|
829
645
|
case o
|
|
830
646
|
when :default
|
|
831
|
-
|
|
647
|
+
PDefaultType::DEFAULT
|
|
648
|
+
when :undef
|
|
649
|
+
PUndefType::DEFAULT
|
|
832
650
|
else
|
|
833
651
|
infer_Object(o)
|
|
834
652
|
end
|
|
835
653
|
end
|
|
836
654
|
|
|
655
|
+
# @api private
|
|
656
|
+
def infer_Sensitive(o)
|
|
657
|
+
PSensitiveType.new(infer(o.unwrap))
|
|
658
|
+
end
|
|
659
|
+
|
|
660
|
+
# @api private
|
|
661
|
+
def infer_Timespan(o)
|
|
662
|
+
PTimespanType.new(o, o)
|
|
663
|
+
end
|
|
664
|
+
|
|
665
|
+
# @api private
|
|
666
|
+
def infer_Timestamp(o)
|
|
667
|
+
PTimestampType.new(o, o)
|
|
668
|
+
end
|
|
669
|
+
|
|
837
670
|
# @api private
|
|
838
671
|
def infer_TrueClass(o)
|
|
839
|
-
|
|
672
|
+
PBooleanType::DEFAULT
|
|
840
673
|
end
|
|
841
674
|
|
|
842
675
|
# @api private
|
|
843
676
|
def infer_FalseClass(o)
|
|
844
|
-
|
|
677
|
+
PBooleanType::DEFAULT
|
|
845
678
|
end
|
|
846
679
|
|
|
847
680
|
# @api private
|
|
848
681
|
# A Puppet::Parser::Resource, or Puppet::Resource
|
|
849
682
|
#
|
|
850
683
|
def infer_Resource(o)
|
|
851
|
-
t = Types::PResourceType.new()
|
|
852
|
-
t.type_name = o.type.to_s.downcase
|
|
853
684
|
# Only Puppet::Resource can have a title that is a symbol :undef, a PResource cannot.
|
|
854
685
|
# A mapping must be made to empty string. A nil value will result in an error later
|
|
855
686
|
title = o.title
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
type.type = t
|
|
859
|
-
type
|
|
687
|
+
title = '' if :undef == title
|
|
688
|
+
PType.new(PResourceType.new(o.type.to_s, title))
|
|
860
689
|
end
|
|
861
690
|
|
|
862
691
|
# @api private
|
|
863
692
|
def infer_Array(o)
|
|
864
|
-
type = Types::PArrayType.new()
|
|
865
|
-
type.element_type =
|
|
866
693
|
if o.empty?
|
|
867
|
-
|
|
694
|
+
PArrayType::EMPTY
|
|
868
695
|
else
|
|
869
|
-
infer_and_reduce_type(o)
|
|
696
|
+
PArrayType.new(infer_and_reduce_type(o), size_as_type(o))
|
|
870
697
|
end
|
|
871
|
-
|
|
872
|
-
|
|
698
|
+
end
|
|
699
|
+
|
|
700
|
+
# @api private
|
|
701
|
+
def infer_Binary(o)
|
|
702
|
+
PBinaryType::DEFAULT
|
|
703
|
+
end
|
|
704
|
+
|
|
705
|
+
# @api private
|
|
706
|
+
def infer_Version(o)
|
|
707
|
+
PSemVerType::DEFAULT
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
# @api private
|
|
711
|
+
def infer_VersionRange(o)
|
|
712
|
+
PSemVerRangeType::DEFAULT
|
|
873
713
|
end
|
|
874
714
|
|
|
875
715
|
# @api private
|
|
876
716
|
def infer_Hash(o)
|
|
877
|
-
type = Types::PHashType.new()
|
|
878
717
|
if o.empty?
|
|
879
|
-
|
|
880
|
-
etype = Types::PUndefType.new()
|
|
718
|
+
PHashType::EMPTY
|
|
881
719
|
else
|
|
882
|
-
ktype = infer_and_reduce_type(o.keys
|
|
883
|
-
etype = infer_and_reduce_type(o.values
|
|
720
|
+
ktype = infer_and_reduce_type(o.keys)
|
|
721
|
+
etype = infer_and_reduce_type(o.values)
|
|
722
|
+
PHashType.new(ktype, etype, size_as_type(o))
|
|
884
723
|
end
|
|
885
|
-
type.key_type = ktype
|
|
886
|
-
type.element_type = etype
|
|
887
|
-
type.size_type = size_as_type(o)
|
|
888
|
-
type
|
|
889
724
|
end
|
|
890
725
|
|
|
891
726
|
def size_as_type(collection)
|
|
892
727
|
size = collection.size
|
|
893
|
-
|
|
894
|
-
t.from = size
|
|
895
|
-
t.to = size
|
|
896
|
-
t
|
|
728
|
+
PIntegerType.new(size, size)
|
|
897
729
|
end
|
|
898
730
|
|
|
899
731
|
# Common case for everything that intrinsically only has a single type
|
|
@@ -903,103 +735,37 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
903
735
|
|
|
904
736
|
def infer_set_Array(o)
|
|
905
737
|
if o.empty?
|
|
906
|
-
|
|
907
|
-
type.element_type = Types::PUndefType.new()
|
|
908
|
-
type.size_type = size_as_type(o)
|
|
738
|
+
PArrayType::EMPTY
|
|
909
739
|
else
|
|
910
|
-
|
|
911
|
-
type.types = o.map() {|x| infer_set(x) }
|
|
740
|
+
PTupleType.new(o.map {|x| infer_set(x) })
|
|
912
741
|
end
|
|
913
|
-
type
|
|
914
742
|
end
|
|
915
743
|
|
|
916
744
|
def infer_set_Hash(o)
|
|
917
745
|
if o.empty?
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
type.size_type = size_as_type(o)
|
|
746
|
+
PHashType::EMPTY
|
|
747
|
+
elsif o.keys.all? {|k| PStringType::NON_EMPTY.instance?(k) }
|
|
748
|
+
PStructType.new(o.each_pair.map { |k,v| PStructElement.new(PStringType.new(k), infer_set(v)) })
|
|
922
749
|
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
|
|
750
|
+
ktype = PVariantType.maybe_create(o.keys.map {|k| infer_set(k) })
|
|
751
|
+
etype = PVariantType.maybe_create(o.values.map {|e| infer_set(e) })
|
|
752
|
+
PHashType.new(unwrap_single_variant(ktype), unwrap_single_variant(etype), size_as_type(o))
|
|
943
753
|
end
|
|
944
|
-
|
|
754
|
+
end
|
|
755
|
+
|
|
756
|
+
# @api private
|
|
757
|
+
def infer_set_Version(o)
|
|
758
|
+
PSemVerType.new([SemanticPuppet::VersionRange.new(o, o)])
|
|
945
759
|
end
|
|
946
760
|
|
|
947
761
|
def unwrap_single_variant(possible_variant)
|
|
948
|
-
if possible_variant.is_a?(
|
|
762
|
+
if possible_variant.is_a?(PVariantType) && possible_variant.types.size == 1
|
|
949
763
|
possible_variant.types[0]
|
|
950
764
|
else
|
|
951
765
|
possible_variant
|
|
952
766
|
end
|
|
953
767
|
end
|
|
954
768
|
|
|
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
769
|
# Transform int range to a size constraint
|
|
1004
770
|
# if range == nil the constraint is 1,1
|
|
1005
771
|
# if range.from == nil min size = 1
|
|
@@ -1010,114 +776,13 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1010
776
|
from = range.from
|
|
1011
777
|
to = range.to
|
|
1012
778
|
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))
|
|
779
|
+
y = to.nil? ? TheInfinity : to
|
|
780
|
+
[x, y]
|
|
1090
781
|
end
|
|
1091
782
|
|
|
1092
783
|
# @api private
|
|
1093
784
|
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)
|
|
785
|
+
t.is_a?(PAnyType) && t.kind_of_callable?(optional)
|
|
1121
786
|
end
|
|
1122
787
|
|
|
1123
788
|
def max(a,b)
|
|
@@ -1128,41 +793,6 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1128
793
|
a <= b ? a : b
|
|
1129
794
|
end
|
|
1130
795
|
|
|
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
796
|
# Produces the tuple entry at the given index given a tuple type, its from/to constraints on the last
|
|
1167
797
|
# type, and an index.
|
|
1168
798
|
# Produces nil if the index is out of bounds
|
|
@@ -1182,564 +812,6 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1182
812
|
end
|
|
1183
813
|
end
|
|
1184
814
|
|
|
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
815
|
# Debugging to_s to reduce the amount of output
|
|
1744
816
|
def to_s
|
|
1745
817
|
'[a TypeCalculator]'
|
|
@@ -1747,32 +819,18 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1747
819
|
|
|
1748
820
|
private
|
|
1749
821
|
|
|
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
822
|
def common_data?(t1, t2)
|
|
1767
|
-
assignable?(
|
|
823
|
+
PDataType::DEFAULT.assignable?(t1) && PDataType::DEFAULT.assignable?(t2)
|
|
1768
824
|
end
|
|
1769
825
|
|
|
1770
826
|
def common_scalar?(t1, t2)
|
|
1771
|
-
assignable?(
|
|
827
|
+
PScalarType::DEFAULT.assignable?(t1) && PScalarType::DEFAULT.assignable?(t2)
|
|
1772
828
|
end
|
|
1773
829
|
|
|
1774
830
|
def common_numeric?(t1, t2)
|
|
1775
|
-
assignable?(
|
|
831
|
+
PNumericType::DEFAULT.assignable?(t1) && PNumericType::DEFAULT.assignable?(t2)
|
|
1776
832
|
end
|
|
1777
833
|
|
|
1778
834
|
end
|
|
835
|
+
end
|
|
836
|
+
end
|