puppet 4.1.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/COMMITTERS.md +2 -2
- data/CONTRIBUTING.md +34 -10
- data/Gemfile +26 -9
- data/LICENSE +3 -3
- data/MAINTAINERS +71 -0
- data/README.md +9 -11
- data/Rakefile +35 -0
- data/conf/auth.conf +2 -2
- data/conf/puppet.conf +1 -1
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +2 -2
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +3 -5
- data/ext/debian/copyright +4 -4
- data/ext/debian/puppet.init +0 -1
- 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 +31 -15
- 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 +17 -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 +35 -19
- data/lib/puppet/application/apply.rb +46 -14
- data/lib/puppet/application/ca.rb +1 -0
- data/lib/puppet/application/cert.rb +52 -3
- data/lib/puppet/application/device.rb +2 -2
- 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 +5 -2
- data/lib/puppet/application/lookup.rb +344 -0
- data/lib/puppet/application/master.rb +7 -3
- data/lib/puppet/application/resource.rb +2 -6
- data/lib/puppet/application.rb +20 -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 +177 -37
- 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 +273 -59
- data/lib/puppet/environments.rb +104 -9
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/etc.rb +125 -0
- 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/hiera_eyaml.rb +3 -0
- 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 +18 -2
- data/lib/puppet/file_serving/terminus_selector.rb +2 -0
- data/lib/puppet/file_system/file_impl.rb +7 -2
- data/lib/puppet/file_system/memory_impl.rb +5 -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 +28 -13
- data/lib/puppet/file_system.rb +33 -5
- data/lib/puppet/forge/repository.rb +3 -35
- data/lib/puppet/forge.rb +7 -7
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/assert_type.rb +53 -19
- 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 +88 -58
- 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/eyaml_lookup_key.rb +90 -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 +35 -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 +29 -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 +22 -25
- 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 +2 -2
- 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 +38 -0
- data/lib/puppet/functions.rb +180 -32
- 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 +195 -8
- 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 +3 -6
- data/lib/puppet/indirector/file_bucket_file/file.rb +137 -25
- 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/key/file.rb +2 -1
- 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/ssl_file.rb +24 -3
- 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 +5 -0
- data/lib/puppet/metatype/manager.rb +25 -8
- data/lib/puppet/module.rb +65 -31
- 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/compression.rb +2 -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 +49 -14
- data/lib/puppet/node/facts.rb +1 -1
- data/lib/puppet/node.rb +22 -7
- 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 +97 -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 +325 -42
- 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 -93
- 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/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 +344 -88
- 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 +114 -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 +246 -147
- data/lib/puppet/pops/evaluator/callable_signature.rb +7 -0
- data/lib/puppet/pops/evaluator/closure.rb +231 -115
- data/lib/puppet/pops/evaluator/collector_transformer.rb +44 -15
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +69 -12
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +9 -8
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +194 -106
- 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 +111 -79
- data/lib/puppet/pops/functions/dispatch.rb +27 -7
- data/lib/puppet/pops/functions/dispatcher.rb +15 -20
- data/lib/puppet/pops/functions/function.rb +30 -4
- data/lib/puppet/pops/issue_reporter.rb +7 -5
- data/lib/puppet/pops/issues.rb +177 -17
- data/lib/puppet/pops/label_provider.rb +18 -4
- data/lib/puppet/pops/loader/base_loader.rb +74 -20
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +43 -49
- data/lib/puppet/pops/loader/loader_paths.rb +48 -2
- data/lib/puppet/pops/loader/module_loaders.rb +53 -20
- 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 +26 -20
- 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 +204 -26
- data/lib/puppet/pops/lookup/configured_data_provider.rb +93 -0
- data/lib/puppet/pops/lookup/context.rb +200 -0
- data/lib/puppet/pops/lookup/data_adapter.rb +27 -0
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +145 -0
- data/lib/puppet/pops/lookup/data_hash_function_provider.rb +126 -0
- data/lib/puppet/pops/lookup/data_provider.rb +107 -0
- data/lib/puppet/pops/lookup/environment_data_provider.rb +35 -0
- data/lib/puppet/pops/lookup/explainer.rb +594 -0
- data/lib/puppet/pops/lookup/function_provider.rb +110 -0
- data/lib/puppet/pops/lookup/global_data_provider.rb +78 -0
- data/lib/puppet/pops/lookup/hiera_config.rb +782 -0
- data/lib/puppet/pops/lookup/interpolation.rb +153 -0
- data/lib/puppet/pops/lookup/invocation.rb +251 -0
- data/lib/puppet/pops/lookup/location_resolver.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_adapter.rb +510 -0
- data/lib/puppet/pops/lookup/lookup_key.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +92 -0
- data/lib/puppet/pops/lookup/module_data_provider.rb +81 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +90 -0
- data/lib/puppet/pops/lookup.rb +47 -49
- data/lib/puppet/pops/merge_strategy.rb +183 -47
- data/lib/puppet/pops/migration/migration_checker.rb +4 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +254 -162
- data/lib/puppet/pops/model/model.rb +25 -8
- data/lib/puppet/pops/model/model_label_provider.rb +28 -6
- data/lib/puppet/pops/model/model_meta.rb +45 -2
- 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 +150 -32
- data/lib/puppet/pops/parser/eparser.rb +1887 -1321
- data/lib/puppet/pops/parser/epp_support.rb +15 -9
- data/lib/puppet/pops/parser/evaluating_parser.rb +21 -13
- data/lib/puppet/pops/parser/heredoc_support.rb +16 -13
- data/lib/puppet/pops/parser/interpolation_support.rb +7 -0
- data/lib/puppet/pops/parser/lexer2.rb +465 -396
- data/lib/puppet/pops/parser/lexer_support.rb +85 -7
- data/lib/puppet/pops/parser/locator.rb +63 -9
- data/lib/puppet/pops/parser/parser_support.rb +40 -28
- data/lib/puppet/pops/parser/slurp_support.rb +23 -14
- 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 +886 -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 -1287
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +222 -169
- data/lib/puppet/pops/types/type_formatter.rb +686 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1105 -0
- data/lib/puppet/pops/types/type_parser.rb +364 -281
- data/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/lib/puppet/pops/types/types.rb +3286 -307
- data/lib/puppet/pops/utils.rb +11 -10
- data/lib/puppet/pops/validation/checker4_0.rb +238 -56
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +13 -5
- data/lib/puppet/pops/validation.rb +31 -16
- data/lib/puppet/pops/visitor.rb +9 -6
- data/lib/puppet/pops.rb +40 -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 +10 -3
- 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 +15 -3
- 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 +16 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +55 -62
- data/lib/puppet/provider/nameservice.rb +23 -8
- data/lib/puppet/provider/package/appdmg.rb +7 -6
- data/lib/puppet/provider/package/apple.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 +72 -20
- 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 +15 -6
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +48 -8
- data/lib/puppet/provider/package/puppet_gem.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +123 -17
- 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 -8
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
- 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 +19 -0
- 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 +7 -0
- data/lib/puppet/provider/selmodule/semodule.rb +20 -16
- 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 +20 -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 +66 -39
- 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 +11 -5
- data/lib/puppet/provider/user/directoryservice.rb +43 -66
- data/lib/puppet/provider/user/hpux.rb +1 -1
- 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 +11 -5
- 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 +1 -1
- 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 -36
- 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 +211 -145
- 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 +98 -45
- data/lib/puppet/ssl/base.rb +14 -1
- data/lib/puppet/ssl/certificate.rb +1 -1
- data/lib/puppet/ssl/certificate_authority/interface.rb +166 -26
- data/lib/puppet/ssl/certificate_authority.rb +49 -13
- data/lib/puppet/ssl/certificate_factory.rb +3 -3
- data/lib/puppet/ssl/certificate_request.rb +5 -5
- data/lib/puppet/ssl/certificate_signer.rb +1 -1
- data/lib/puppet/ssl/configuration.rb +4 -1
- data/lib/puppet/ssl/host.rb +26 -4
- data/lib/puppet/ssl/inventory.rb +10 -3
- data/lib/puppet/ssl/key.rb +7 -3
- 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 +21 -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 +43 -19
- 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 +21 -18
- 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 +145 -46
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +26 -8
- 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 +16 -1
- 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 +1 -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 +7 -4
- data/lib/puppet/type/user.rb +51 -26
- data/lib/puppet/type/yumrepo.rb +23 -3
- data/lib/puppet/type/zone.rb +6 -6
- data/lib/puppet/type.rb +175 -41
- data/lib/puppet/util/autoload.rb +16 -11
- data/lib/puppet/util/character_encoding.rb +95 -0
- 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 +35 -16
- 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.rb +28 -1
- data/lib/puppet/util/logging.rb +46 -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/reference.rb +4 -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 +2 -2
- 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 +97 -32
- 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 +112 -19
- 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 +125 -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 +7 -3
- data/lib/puppet.rb +86 -2
- data/lib/puppet_x.rb +7 -1
- data/lib/semver.rb +36 -13
- data/locales/config.yaml +29 -0
- data/locales/puppet.pot +93 -0
- data/man/man5/puppet.conf.5 +13 -13
- data/man/man8/extlookup2hiera.8 +1 -1
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +2 -2
- data/man/man8/puppet-catalog.8 +2 -2
- data/man/man8/puppet-cert.8 +2 -2
- data/man/man8/puppet-certificate.8 +2 -2
- data/man/man8/puppet-certificate_request.8 +2 -2
- data/man/man8/puppet-certificate_revocation_list.8 +2 -2
- data/man/man8/puppet-config.8 +3 -3
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +2 -2
- data/man/man8/puppet-facts.8 +2 -2
- data/man/man8/puppet-file.8 +2 -2
- data/man/man8/puppet-filebucket.8 +2 -2
- data/man/man8/puppet-help.8 +2 -2
- data/man/man8/puppet-inspect.8 +2 -2
- data/man/man8/puppet-key.8 +2 -2
- data/man/man8/puppet-man.8 +2 -2
- data/man/man8/puppet-master.8 +2 -2
- data/man/man8/puppet-module.8 +9 -9
- data/man/man8/puppet-node.8 +2 -2
- data/man/man8/puppet-parser.8 +2 -2
- data/man/man8/puppet-plugin.8 +2 -2
- data/man/man8/puppet-report.8 +2 -2
- data/man/man8/puppet-resource.8 +2 -2
- data/man/man8/puppet-resource_type.8 +2 -2
- data/man/man8/puppet-status.8 +3 -3
- data/man/man8/puppet.8 +1 -1
- 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/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/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/no_modules/manifests/site.pp +10 -0
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +0 -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/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 +383 -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/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 +38 -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 +225 -864
- 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 +9 -7
- data/spec/integration/parser/scope_spec.rb +20 -2
- 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/autosign_spec.rb +18 -3
- 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/ssl/key_spec.rb +104 -0
- 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 +125 -1
- data/spec/integration/type/exec_spec.rb +0 -0
- data/spec/integration/type/file_spec.rb +237 -12
- data/spec/integration/type/package_spec.rb +72 -1
- data/spec/integration/type/tidy_spec.rb +21 -9
- data/spec/integration/type/user_spec.rb +13 -6
- 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 +61 -16
- 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/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/language.rb +3 -1
- 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 +23 -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 +28 -10
- data/spec/unit/application/lookup_spec.rb +532 -0
- data/spec/unit/application/master_spec.rb +2 -2
- 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 +21 -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/etc_spec.rb +234 -0
- 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 +10 -2
- 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/module/search_spec.rb +1 -1
- 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 +50 -0
- 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 +0 -0
- 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 +335 -6
- data/spec/unit/forge/repository_spec.rb +27 -0
- 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 +2 -2
- 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 +447 -47
- 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 +2904 -265
- 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 +26 -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 +3 -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 +270 -79
- 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 +3 -10
- 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 +86 -4
- 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 +1 -1
- 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 +4 -4
- 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 +118 -74
- 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 +40 -9
- 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 +18 -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 +35 -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 +134 -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 +0 -0
- 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 +0 -0
- 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 +83 -16
- data/spec/unit/parser/templatewrapper_spec.rb +0 -0
- 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 +115 -19
- 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 +76 -23
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +29 -25
- 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 +1 -1
- 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 +323 -27
- data/spec/unit/pops/loaders/module_loaders_spec.rb +63 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +83 -18
- data/spec/unit/pops/lookup/context_spec.rb +334 -0
- data/spec/unit/pops/lookup/interpolation_spec.rb +333 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +262 -0
- data/spec/unit/pops/merge_strategy_spec.rb +18 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +236 -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_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 +625 -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 +965 -934
- 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 +228 -0
- data/spec/unit/pops/types/type_parser_spec.rb +203 -36
- data/spec/unit/pops/types/types_spec.rb +599 -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 +31 -9
- 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 +0 -0
- 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 +54 -12
- 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 +0 -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 +164 -46
- data/spec/unit/provider/package/pkg_spec.rb +139 -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 +16 -2
- 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 +170 -12
- 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/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 +14 -0
- data/spec/unit/provider/parsedfile_spec.rb +0 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +211 -0
- 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 +6 -0
- 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 +34 -4
- data/spec/unit/provider/service/freebsd_spec.rb +16 -0
- data/spec/unit/provider/service/gentoo_spec.rb +7 -0
- data/spec/unit/provider/service/init_spec.rb +24 -1
- data/spec/unit/provider/service/launchd_spec.rb +124 -25
- data/spec/unit/provider/service/openbsd_spec.rb +0 -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 +8 -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 +31 -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 +30 -6
- 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 +169 -12
- data/spec/unit/resource_spec.rb +137 -48
- data/spec/unit/semver_spec.rb +241 -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 +105 -3
- data/spec/unit/ssl/base_spec.rb +9 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +180 -13
- data/spec/unit/ssl/certificate_authority_spec.rb +82 -28
- data/spec/unit/ssl/certificate_factory_spec.rb +2 -2
- data/spec/unit/ssl/certificate_request_attributes_spec.rb +6 -0
- data/spec/unit/ssl/certificate_request_spec.rb +4 -5
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +3 -3
- data/spec/unit/ssl/certificate_spec.rb +1 -1
- data/spec/unit/ssl/configuration_spec.rb +11 -2
- data/spec/unit/ssl/host_spec.rb +3 -3
- data/spec/unit/ssl/inventory_spec.rb +27 -3
- data/spec/unit/ssl/key_spec.rb +7 -7
- 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 +57 -12
- 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 +165 -35
- 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/character_encoding_spec.rb +88 -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 +13 -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 +91 -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 +12 -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 +82 -40
- 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 -14
- data/spec/unit/util/yaml_spec.rb +13 -1
- data/spec/unit/util_spec.rb +219 -15
- data/spec/unit/version_spec.rb +19 -0
- data/spec/watchr.rb +0 -0
- data/tasks/cfpropertylist.rake +15 -0
- metadata +724 -115
- 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 -234
- 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,47 +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
|
-
t2_class = t2.class
|
|
272
|
-
|
|
273
|
-
# Unit can be assigned to anything
|
|
274
|
-
return true if t2_class == Types::PUnitType
|
|
275
|
-
|
|
276
|
-
if t2_class == Types::PVariantType
|
|
277
|
-
# Assignable if all contained types are assignable
|
|
278
|
-
t2.types.all? { |vt| @@assignable_visitor.visit_this_1(self, t, vt) }
|
|
279
|
-
else
|
|
280
|
-
# Turn NotUndef[T] into T when T is not assignable from Undef
|
|
281
|
-
if t2_class == Types::PNotUndefType && !(t2.type.nil? || assignable?(t2.type, @nil_t))
|
|
282
|
-
assignable?(t, t2.type)
|
|
283
|
-
else
|
|
284
|
-
@@assignable_visitor.visit_this_1(self, t, t2)
|
|
285
|
-
end
|
|
286
|
-
end
|
|
207
|
+
t.is_a?(PAnyType) ? t.assignable?(t2) : false
|
|
287
208
|
end
|
|
288
209
|
|
|
289
|
-
# Returns an
|
|
210
|
+
# Returns an iterable if the t represents something that can be iterated
|
|
290
211
|
def enumerable(t)
|
|
291
|
-
|
|
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)
|
|
292
220
|
end
|
|
293
221
|
|
|
294
222
|
# Answers, does the given callable accept the arguments given in args (an array or a tuple)
|
|
295
223
|
#
|
|
296
224
|
def callable?(callable, args)
|
|
297
|
-
|
|
298
|
-
# Note that polymorphism is for the args type, the callable is always a callable
|
|
299
|
-
@@callable_visitor.visit_this_1(self, args, callable)
|
|
225
|
+
callable.is_a?(PAnyType) && callable.callable?(args)
|
|
300
226
|
end
|
|
301
227
|
|
|
302
228
|
# Answers if the two given types describe the same type
|
|
303
229
|
def equals(left, right)
|
|
304
|
-
return false unless left.is_a?(
|
|
230
|
+
return false unless left.is_a?(PAnyType) && right.is_a?(PAnyType)
|
|
305
231
|
# Types compare per class only - an extra test must be made if the are mutually assignable
|
|
306
232
|
# to find all types that represent the same type of instance
|
|
307
233
|
#
|
|
@@ -309,90 +235,46 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
309
235
|
end
|
|
310
236
|
|
|
311
237
|
# Answers 'what is the Puppet Type corresponding to the given Ruby class'
|
|
312
|
-
# @param c [
|
|
238
|
+
# @param c [Module] the class for which a puppet type is wanted
|
|
313
239
|
# @api public
|
|
314
240
|
#
|
|
315
241
|
def type(c)
|
|
316
|
-
raise ArgumentError,
|
|
242
|
+
raise ArgumentError, 'Argument must be a Module' unless c.is_a? Module
|
|
317
243
|
|
|
318
244
|
# Can't use a visitor here since we don't have an instance of the class
|
|
319
245
|
case
|
|
320
246
|
when c <= Integer
|
|
321
|
-
type =
|
|
247
|
+
type = PIntegerType::DEFAULT
|
|
322
248
|
when c == Float
|
|
323
|
-
type =
|
|
249
|
+
type = PFloatType::DEFAULT
|
|
324
250
|
when c == Numeric
|
|
325
|
-
type =
|
|
251
|
+
type = PNumericType::DEFAULT
|
|
326
252
|
when c == String
|
|
327
|
-
type =
|
|
253
|
+
type = PStringType::DEFAULT
|
|
328
254
|
when c == Regexp
|
|
329
|
-
type =
|
|
255
|
+
type = PRegexpType::DEFAULT
|
|
330
256
|
when c == NilClass
|
|
331
|
-
type =
|
|
257
|
+
type = PUndefType::DEFAULT
|
|
332
258
|
when c == FalseClass, c == TrueClass
|
|
333
|
-
type =
|
|
259
|
+
type = PBooleanType::DEFAULT
|
|
334
260
|
when c == Class
|
|
335
|
-
type =
|
|
261
|
+
type = PType::DEFAULT
|
|
336
262
|
when c == Array
|
|
337
263
|
# Assume array of data values
|
|
338
|
-
type =
|
|
339
|
-
type.element_type = Types::PDataType.new()
|
|
264
|
+
type = PArrayType::DATA
|
|
340
265
|
when c == Hash
|
|
341
266
|
# Assume hash with scalar keys and data values
|
|
342
|
-
type =
|
|
343
|
-
|
|
344
|
-
type
|
|
345
|
-
else
|
|
346
|
-
type = Types::PRuntimeType.new(:runtime => :ruby, :runtime_type_name => c.name)
|
|
267
|
+
type = PHashType::DATA
|
|
268
|
+
else
|
|
269
|
+
type = PRuntimeType.new(:ruby, c.name)
|
|
347
270
|
end
|
|
348
271
|
type
|
|
349
272
|
end
|
|
350
273
|
|
|
351
|
-
# Generalizes value specific types. The
|
|
274
|
+
# Generalizes value specific types. The generalized type is returned.
|
|
352
275
|
# @api public
|
|
353
|
-
def generalize
|
|
354
|
-
|
|
355
|
-
o.eAllContents.each { |x| @@generalize_visitor.visit_this_0(self, x) }
|
|
356
|
-
o
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
def generalize_Object(o)
|
|
360
|
-
# do nothing, there is nothing to change for most types
|
|
361
|
-
end
|
|
362
|
-
|
|
363
|
-
# @return [Boolean] true if the given argument is contained in a struct element key
|
|
364
|
-
def is_struct_element_key?(o)
|
|
365
|
-
c = o.eContainer
|
|
366
|
-
if c.is_a?(Types::POptionalType)
|
|
367
|
-
o = c
|
|
368
|
-
c = c.eContainer
|
|
369
|
-
end
|
|
370
|
-
c.is_a?(Types::PStructElement) && c.key_type.equal?(o)
|
|
371
|
-
end
|
|
372
|
-
private :is_struct_element_key?
|
|
373
|
-
|
|
374
|
-
def generalize_PStringType(o)
|
|
375
|
-
# Skip generalization if the string is contained in a PStructElement key.
|
|
376
|
-
unless is_struct_element_key?(o)
|
|
377
|
-
o.values = []
|
|
378
|
-
o.size_type = nil
|
|
379
|
-
end
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
def generalize_PCollectionType(o)
|
|
383
|
-
# erase the size constraint from Array and Hash (if one exists, it is transformed to -Infinity - + Infinity, which is
|
|
384
|
-
# not desirable.
|
|
385
|
-
o.size_type = nil
|
|
386
|
-
end
|
|
387
|
-
|
|
388
|
-
def generalize_PFloatType(o)
|
|
389
|
-
o.to = nil
|
|
390
|
-
o.from = nil
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
def generalize_PIntegerType(o)
|
|
394
|
-
o.to = nil
|
|
395
|
-
o.from = nil
|
|
276
|
+
def generalize(o)
|
|
277
|
+
o.is_a?(PAnyType) ? o.generalize : o
|
|
396
278
|
end
|
|
397
279
|
|
|
398
280
|
# Answers 'what is the single common Puppet Type describing o', or if o is an Array or Hash, what is the
|
|
@@ -400,153 +282,72 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
400
282
|
# @api public
|
|
401
283
|
#
|
|
402
284
|
def infer(o)
|
|
403
|
-
|
|
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
|
|
404
300
|
end
|
|
405
301
|
|
|
406
302
|
def infer_generic(o)
|
|
407
|
-
|
|
408
|
-
result
|
|
303
|
+
generalize(infer(o))
|
|
409
304
|
end
|
|
410
305
|
|
|
411
306
|
# Answers 'what is the set of Puppet Types of o'
|
|
412
307
|
# @api public
|
|
413
308
|
#
|
|
414
309
|
def infer_set(o)
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
def instance_of_Object(t, o)
|
|
423
|
-
# Undef is Undef and Any, but nothing else when checking instance?
|
|
424
|
-
return false if (o.nil?) && t.class != Types::PAnyType
|
|
425
|
-
assignable?(t, infer(o))
|
|
426
|
-
end
|
|
427
|
-
|
|
428
|
-
# Anything is an instance of Unit
|
|
429
|
-
# @api private
|
|
430
|
-
def instance_of_PUnitType(t, o)
|
|
431
|
-
true
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
def instance_of_PArrayType(t, o)
|
|
435
|
-
return false unless o.is_a?(Array)
|
|
436
|
-
return false unless o.all? {|element| instance_of(t.element_type, element) }
|
|
437
|
-
size_t = t.size_type || @collection_default_size_t
|
|
438
|
-
# optimize by calling directly
|
|
439
|
-
return instance_of_PIntegerType(size_t, o.size)
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
# @api private
|
|
443
|
-
def instance_of_PIntegerType(t, o)
|
|
444
|
-
return false unless o.is_a?(Integer)
|
|
445
|
-
x = t.from
|
|
446
|
-
x = -Float::INFINITY if x.nil? || x == :default
|
|
447
|
-
y = t.to
|
|
448
|
-
y = Float::INFINITY if y.nil? || y == :default
|
|
449
|
-
return x < y ? x <= o && y >= o : y <= o && x >= o
|
|
450
|
-
end
|
|
451
|
-
|
|
452
|
-
# @api private
|
|
453
|
-
def instance_of_PStringType(t, o)
|
|
454
|
-
return false unless o.is_a?(String)
|
|
455
|
-
# true if size compliant
|
|
456
|
-
size_t = t.size_type
|
|
457
|
-
if size_t.nil? || instance_of_PIntegerType(size_t, o.size)
|
|
458
|
-
values = t.values
|
|
459
|
-
values.empty? || values.include?(o)
|
|
460
|
-
else
|
|
461
|
-
false
|
|
462
|
-
end
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
def instance_of_PTupleType(t, o)
|
|
466
|
-
return false unless o.is_a?(Array)
|
|
467
|
-
# compute the tuple's min/max size, and check if that size matches
|
|
468
|
-
size_t = t.size_type || Puppet::Pops::Types::TypeFactory.range(*t.size_range)
|
|
469
|
-
|
|
470
|
-
return false unless instance_of_PIntegerType(size_t, o.size)
|
|
471
|
-
o.each_with_index do |element, index|
|
|
472
|
-
return false unless instance_of(t.types[index] || t.types[-1], element)
|
|
473
|
-
end
|
|
474
|
-
true
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
def instance_of_PStructType(t, o)
|
|
478
|
-
return false unless o.is_a?(Hash)
|
|
479
|
-
matched = 0
|
|
480
|
-
t.elements.all? do |e|
|
|
481
|
-
key = e.name
|
|
482
|
-
v = o[key]
|
|
483
|
-
if v.nil? && !o.include?(key)
|
|
484
|
-
# Entry is missing. Only OK when key is optional
|
|
485
|
-
assignable?(e.key_type, @nil_t)
|
|
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)
|
|
486
317
|
else
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
end
|
|
490
|
-
end && matched == o.size
|
|
491
|
-
end
|
|
492
|
-
|
|
493
|
-
def instance_of_PHashType(t, o)
|
|
494
|
-
return false unless o.is_a?(Hash)
|
|
495
|
-
key_t = t.key_type
|
|
496
|
-
element_t = t.element_type
|
|
497
|
-
return false unless o.keys.all? {|key| instance_of(key_t, key) } && o.values.all? {|value| instance_of(element_t, value) }
|
|
498
|
-
size_t = t.size_type || @collection_default_size_t
|
|
499
|
-
# optimize by calling directly
|
|
500
|
-
return instance_of_PIntegerType(size_t, o.size)
|
|
501
|
-
end
|
|
502
|
-
|
|
503
|
-
def instance_of_PDataType(t, o)
|
|
504
|
-
instance_of(@data_variant_t, o)
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
def instance_of_PNotUndefType(t, o)
|
|
508
|
-
!(o.nil? || o == :undef) && (t.type.nil? || instance_of(t.type, o))
|
|
509
|
-
end
|
|
510
|
-
|
|
511
|
-
def instance_of_PUndefType(t, o)
|
|
512
|
-
o.nil? || o == :undef
|
|
513
|
-
end
|
|
514
|
-
|
|
515
|
-
def instance_of_POptionalType(t, o)
|
|
516
|
-
instance_of_PUndefType(t, o) || instance_of(t.optional_type, o)
|
|
517
|
-
end
|
|
518
|
-
|
|
519
|
-
def instance_of_PVariantType(t, o)
|
|
520
|
-
# instance of variant if o is instance? of any of variant's types
|
|
521
|
-
t.types.any? { |option_t| instance_of(option_t, o) }
|
|
318
|
+
infer_set_Object(o)
|
|
319
|
+
end
|
|
522
320
|
end
|
|
523
321
|
|
|
524
322
|
# Answers 'is o an instance of type t'
|
|
525
323
|
# @api public
|
|
526
324
|
#
|
|
527
325
|
def self.instance?(t, o)
|
|
528
|
-
singleton.
|
|
326
|
+
singleton.instance?(t,o)
|
|
529
327
|
end
|
|
530
328
|
|
|
531
329
|
# Answers 'is o an instance of type t'
|
|
532
330
|
# @api public
|
|
533
331
|
#
|
|
534
332
|
def instance?(t, o)
|
|
535
|
-
|
|
333
|
+
if t.is_a?(Module)
|
|
334
|
+
t = type(t)
|
|
335
|
+
end
|
|
336
|
+
t.is_a?(PAnyType) ? t.instance?(o) : false
|
|
536
337
|
end
|
|
537
338
|
|
|
538
339
|
# Answers if t is a puppet type
|
|
539
340
|
# @api public
|
|
540
341
|
#
|
|
541
342
|
def is_ptype?(t)
|
|
542
|
-
|
|
343
|
+
t.is_a?(PAnyType)
|
|
543
344
|
end
|
|
544
345
|
|
|
545
346
|
# Answers if t represents the puppet type PUndefType
|
|
546
347
|
# @api public
|
|
547
348
|
#
|
|
548
349
|
def is_pnil?(t)
|
|
549
|
-
|
|
350
|
+
t.nil? || t.is_a?(PUndefType)
|
|
550
351
|
end
|
|
551
352
|
|
|
552
353
|
# Answers, 'What is the common type of t1 and t2?'
|
|
@@ -567,9 +368,9 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
567
368
|
end
|
|
568
369
|
|
|
569
370
|
# If either side is Unit, it is the other type
|
|
570
|
-
if t1.is_a?(
|
|
371
|
+
if t1.is_a?(PUnitType)
|
|
571
372
|
return t2
|
|
572
|
-
elsif t2.is_a?(
|
|
373
|
+
elsif t2.is_a?(PUnitType)
|
|
573
374
|
return t1
|
|
574
375
|
end
|
|
575
376
|
|
|
@@ -581,133 +382,113 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
581
382
|
end
|
|
582
383
|
|
|
583
384
|
# when both are arrays, return an array with common element type
|
|
584
|
-
if t1.is_a?(
|
|
585
|
-
|
|
586
|
-
type.element_type = common_type(t1.element_type, t2.element_type)
|
|
587
|
-
return type
|
|
385
|
+
if t1.is_a?(PArrayType) && t2.is_a?(PArrayType)
|
|
386
|
+
return PArrayType.new(common_type(t1.element_type, t2.element_type))
|
|
588
387
|
end
|
|
589
388
|
|
|
590
389
|
# when both are hashes, return a hash with common key- and element type
|
|
591
|
-
if t1.is_a?(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
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)
|
|
596
394
|
end
|
|
597
395
|
|
|
598
396
|
# when both are host-classes, reduce to PHostClass[] (since one was not assignable to the other)
|
|
599
|
-
if t1.is_a?(
|
|
600
|
-
return
|
|
397
|
+
if t1.is_a?(PHostClassType) && t2.is_a?(PHostClassType)
|
|
398
|
+
return PHostClassType::DEFAULT
|
|
601
399
|
end
|
|
602
400
|
|
|
603
401
|
# when both are resources, reduce to Resource[T] or Resource[] (since one was not assignable to the other)
|
|
604
|
-
if t1.is_a?(
|
|
605
|
-
result = Types::PResourceType.new()
|
|
402
|
+
if t1.is_a?(PResourceType) && t2.is_a?(PResourceType)
|
|
606
403
|
# only Resource[] unless the type name is the same
|
|
607
|
-
|
|
608
|
-
# the cross assignability test above has already determined that they do not have the same type and title
|
|
609
|
-
return result
|
|
404
|
+
return t1.type_name == t2.type_name ? PResourceType.new(t1.type_name, nil) : PResourceType::DEFAULT
|
|
610
405
|
end
|
|
611
406
|
|
|
612
407
|
# Integers have range, expand the range to the common range
|
|
613
|
-
if t1.is_a?(
|
|
614
|
-
|
|
615
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
616
|
-
t = Types::PIntegerType.new()
|
|
617
|
-
from = [t1range[0], t2range[0]].min
|
|
618
|
-
to = [t1range[1], t2range[1]].max
|
|
619
|
-
t.from = from unless from == Float::INFINITY
|
|
620
|
-
t.to = to unless to == Float::INFINITY
|
|
621
|
-
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)
|
|
622
410
|
end
|
|
623
411
|
|
|
624
412
|
# Floats have range, expand the range to the common range
|
|
625
|
-
if t1.is_a?(
|
|
626
|
-
|
|
627
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
628
|
-
t = Types::PFloatType.new()
|
|
629
|
-
from = [t1range[0], t2range[0]].min
|
|
630
|
-
to = [t1range[1], t2range[1]].max
|
|
631
|
-
t.from = from unless from == Float::INFINITY
|
|
632
|
-
t.to = to unless to == Float::INFINITY
|
|
633
|
-
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)
|
|
634
415
|
end
|
|
635
416
|
|
|
636
|
-
if t1.is_a?(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
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))
|
|
641
427
|
end
|
|
642
428
|
|
|
643
|
-
if t1.is_a?(
|
|
644
|
-
|
|
645
|
-
# must make copies since patterns are contained types, not data-types
|
|
646
|
-
t.patterns = (t1.patterns | t2.patterns).map(&:copy)
|
|
647
|
-
return t
|
|
429
|
+
if t1.is_a?(PPatternType) && t2.is_a?(PPatternType)
|
|
430
|
+
return PPatternType.new(t1.patterns | t2.patterns)
|
|
648
431
|
end
|
|
649
432
|
|
|
650
|
-
if t1.is_a?(
|
|
433
|
+
if t1.is_a?(PEnumType) && (t2.is_a?(PStringType) || t2.is_a?(PEnumType))
|
|
651
434
|
# The common type is one that complies with either set
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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])
|
|
655
440
|
end
|
|
656
441
|
|
|
657
|
-
if t1.is_a?(
|
|
442
|
+
if t1.is_a?(PVariantType) && t2.is_a?(PVariantType)
|
|
658
443
|
# The common type is one that complies with either set
|
|
659
|
-
|
|
660
|
-
t.types = (t1.types | t2.types).map(&:copy)
|
|
661
|
-
return t
|
|
444
|
+
return PVariantType.maybe_create(t1.types | t2.types)
|
|
662
445
|
end
|
|
663
446
|
|
|
664
|
-
if t1.is_a?(
|
|
447
|
+
if t1.is_a?(PRegexpType) && t2.is_a?(PRegexpType)
|
|
665
448
|
# if they were identical, the general rule would return a parameterized regexp
|
|
666
449
|
# since they were not, the result is a generic regexp type
|
|
667
|
-
return
|
|
450
|
+
return PRegexpType::DEFAULT
|
|
668
451
|
end
|
|
669
452
|
|
|
670
|
-
if t1.is_a?(
|
|
453
|
+
if t1.is_a?(PCallableType) && t2.is_a?(PCallableType)
|
|
671
454
|
# They do not have the same signature, and one is not assignable to the other,
|
|
672
455
|
# what remains is the most general form of Callable
|
|
673
|
-
return
|
|
456
|
+
return PCallableType::DEFAULT
|
|
674
457
|
end
|
|
675
458
|
|
|
676
459
|
# Common abstract types, from most specific to most general
|
|
677
460
|
if common_numeric?(t1, t2)
|
|
678
|
-
return
|
|
461
|
+
return PNumericType::DEFAULT
|
|
679
462
|
end
|
|
680
463
|
|
|
681
464
|
if common_scalar?(t1, t2)
|
|
682
|
-
return
|
|
465
|
+
return PScalarType::DEFAULT
|
|
683
466
|
end
|
|
684
467
|
|
|
685
468
|
if common_data?(t1,t2)
|
|
686
|
-
return
|
|
469
|
+
return PDataType::DEFAULT
|
|
687
470
|
end
|
|
688
471
|
|
|
689
472
|
# Meta types Type[Integer] + Type[String] => Type[Data]
|
|
690
|
-
if t1.is_a?(
|
|
691
|
-
|
|
692
|
-
type.type = common_type(t1.type, t2.type)
|
|
693
|
-
return type
|
|
473
|
+
if t1.is_a?(PType) && t2.is_a?(PType)
|
|
474
|
+
return PType.new(common_type(t1.type, t2.type))
|
|
694
475
|
end
|
|
695
476
|
|
|
696
477
|
# If both are Runtime types
|
|
697
|
-
if t1.is_a?(
|
|
478
|
+
if t1.is_a?(PRuntimeType) && t2.is_a?(PRuntimeType)
|
|
698
479
|
if t1.runtime == t2.runtime && t1.runtime_type_name == t2.runtime_type_name
|
|
699
480
|
return t1
|
|
700
481
|
end
|
|
701
482
|
# finding the common super class requires that names are resolved to class
|
|
702
483
|
# NOTE: This only supports runtime type of :ruby
|
|
703
|
-
c1 =
|
|
704
|
-
c2 =
|
|
484
|
+
c1 = ClassLoader.provide_from_type(t1)
|
|
485
|
+
c2 = ClassLoader.provide_from_type(t2)
|
|
705
486
|
if c1 && c2
|
|
706
487
|
c2_superclasses = superclasses(c2)
|
|
707
488
|
superclasses(c1).each do|c1_super|
|
|
708
489
|
c2_superclasses.each do |c2_super|
|
|
709
490
|
if c1_super == c2_super
|
|
710
|
-
return
|
|
491
|
+
return PRuntimeType.new(:ruby, c1_super.name)
|
|
711
492
|
end
|
|
712
493
|
end
|
|
713
494
|
end
|
|
@@ -715,9 +496,7 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
715
496
|
end
|
|
716
497
|
|
|
717
498
|
# They better both be Any type, or the wrong thing was asked and nil is returned
|
|
718
|
-
|
|
719
|
-
return Types::PAnyType.new()
|
|
720
|
-
end
|
|
499
|
+
t1.is_a?(PAnyType) && t2.is_a?(PAnyType) ? PAnyType::DEFAULT : nil
|
|
721
500
|
end
|
|
722
501
|
|
|
723
502
|
# Produces the superclasses of the given class, including the class
|
|
@@ -734,14 +513,16 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
734
513
|
# @api public
|
|
735
514
|
#
|
|
736
515
|
def string(t)
|
|
737
|
-
|
|
516
|
+
Puppet.deprecation_warning('TypeCalculator.string is deprecated. Use TypeFormatter')
|
|
517
|
+
TypeFormatter.singleton.string(t)
|
|
738
518
|
end
|
|
739
519
|
|
|
740
520
|
# Produces a debug string representing the type (possibly with more information that the regular string format)
|
|
741
521
|
# @api public
|
|
742
522
|
#
|
|
743
523
|
def debug_string(t)
|
|
744
|
-
|
|
524
|
+
Puppet.deprecation_warning('TypeCalculator.debug_string is deprecated. Use TypeFormatter')
|
|
525
|
+
TypeFormatter.singleton.debug_string(t)
|
|
745
526
|
end
|
|
746
527
|
|
|
747
528
|
|
|
@@ -756,19 +537,24 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
756
537
|
# @api public
|
|
757
538
|
#
|
|
758
539
|
def infer_and_reduce_type(enumerable)
|
|
759
|
-
reduce_type(enumerable.
|
|
540
|
+
reduce_type(enumerable.map {|o| infer(o) })
|
|
760
541
|
end
|
|
761
542
|
|
|
762
|
-
# The type of all
|
|
543
|
+
# The type of all modules is PType
|
|
763
544
|
# @api private
|
|
764
545
|
#
|
|
765
|
-
def
|
|
766
|
-
|
|
546
|
+
def infer_Module(o)
|
|
547
|
+
PType::new(PRuntimeType.new(:ruby, o.name))
|
|
767
548
|
end
|
|
768
549
|
|
|
769
550
|
# @api private
|
|
770
551
|
def infer_Closure(o)
|
|
771
|
-
o.type
|
|
552
|
+
o.type
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
# @api private
|
|
556
|
+
def infer_Iterator(o)
|
|
557
|
+
PIteratorType.new(o.element_type)
|
|
772
558
|
end
|
|
773
559
|
|
|
774
560
|
# @api private
|
|
@@ -778,16 +564,21 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
778
564
|
|
|
779
565
|
# @api private
|
|
780
566
|
def infer_Object(o)
|
|
781
|
-
|
|
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
|
|
782
575
|
end
|
|
783
576
|
|
|
784
577
|
# The type of all types is PType
|
|
785
578
|
# @api private
|
|
786
579
|
#
|
|
787
580
|
def infer_PAnyType(o)
|
|
788
|
-
|
|
789
|
-
type.type = o.copy
|
|
790
|
-
type
|
|
581
|
+
PType.new(o)
|
|
791
582
|
end
|
|
792
583
|
|
|
793
584
|
# The type of all types is PType
|
|
@@ -795,45 +586,32 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
795
586
|
# @api private
|
|
796
587
|
#
|
|
797
588
|
def infer_PType(o)
|
|
798
|
-
|
|
799
|
-
type.type = o.copy
|
|
800
|
-
type
|
|
589
|
+
PType.new(o)
|
|
801
590
|
end
|
|
802
591
|
|
|
803
592
|
# @api private
|
|
804
593
|
def infer_String(o)
|
|
805
|
-
|
|
806
|
-
t.addValues(o)
|
|
807
|
-
t.size_type = size_as_type(o)
|
|
808
|
-
t
|
|
594
|
+
PStringType.new(o)
|
|
809
595
|
end
|
|
810
596
|
|
|
811
597
|
# @api private
|
|
812
598
|
def infer_Float(o)
|
|
813
|
-
|
|
814
|
-
t.from = o
|
|
815
|
-
t.to = o
|
|
816
|
-
t
|
|
599
|
+
PFloatType.new(o, o)
|
|
817
600
|
end
|
|
818
601
|
|
|
819
602
|
# @api private
|
|
820
603
|
def infer_Integer(o)
|
|
821
|
-
|
|
822
|
-
t.from = o
|
|
823
|
-
t.to = o
|
|
824
|
-
t
|
|
604
|
+
PIntegerType.new(o, o)
|
|
825
605
|
end
|
|
826
606
|
|
|
827
607
|
# @api private
|
|
828
608
|
def infer_Regexp(o)
|
|
829
|
-
|
|
830
|
-
t.pattern = o.source
|
|
831
|
-
t
|
|
609
|
+
PRegexpType.new(o.source)
|
|
832
610
|
end
|
|
833
611
|
|
|
834
612
|
# @api private
|
|
835
613
|
def infer_NilClass(o)
|
|
836
|
-
|
|
614
|
+
PUndefType::DEFAULT
|
|
837
615
|
end
|
|
838
616
|
|
|
839
617
|
# @api private
|
|
@@ -845,16 +623,15 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
845
623
|
case p[0]
|
|
846
624
|
when :rest
|
|
847
625
|
max = :default
|
|
848
|
-
break
|
|
626
|
+
break PAnyType::DEFAULT
|
|
849
627
|
when :req
|
|
850
628
|
min += 1
|
|
851
629
|
end
|
|
852
630
|
max += 1
|
|
853
|
-
|
|
631
|
+
PAnyType::DEFAULT
|
|
854
632
|
end
|
|
855
|
-
mapped_types
|
|
856
|
-
|
|
857
|
-
Types::TypeFactory.callable(*mapped_types)
|
|
633
|
+
param_types = Types::PTupleType.new(mapped_types, Types::PIntegerType.new(min, max))
|
|
634
|
+
Types::PCallableType.new(param_types)
|
|
858
635
|
end
|
|
859
636
|
|
|
860
637
|
# @api private
|
|
@@ -867,72 +644,88 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
867
644
|
def infer_Symbol(o)
|
|
868
645
|
case o
|
|
869
646
|
when :default
|
|
870
|
-
|
|
647
|
+
PDefaultType::DEFAULT
|
|
648
|
+
when :undef
|
|
649
|
+
PUndefType::DEFAULT
|
|
871
650
|
else
|
|
872
651
|
infer_Object(o)
|
|
873
652
|
end
|
|
874
653
|
end
|
|
875
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
|
+
|
|
876
670
|
# @api private
|
|
877
671
|
def infer_TrueClass(o)
|
|
878
|
-
|
|
672
|
+
PBooleanType::DEFAULT
|
|
879
673
|
end
|
|
880
674
|
|
|
881
675
|
# @api private
|
|
882
676
|
def infer_FalseClass(o)
|
|
883
|
-
|
|
677
|
+
PBooleanType::DEFAULT
|
|
884
678
|
end
|
|
885
679
|
|
|
886
680
|
# @api private
|
|
887
681
|
# A Puppet::Parser::Resource, or Puppet::Resource
|
|
888
682
|
#
|
|
889
683
|
def infer_Resource(o)
|
|
890
|
-
t = Types::PResourceType.new()
|
|
891
|
-
t.type_name = o.type.to_s.downcase
|
|
892
684
|
# Only Puppet::Resource can have a title that is a symbol :undef, a PResource cannot.
|
|
893
685
|
# A mapping must be made to empty string. A nil value will result in an error later
|
|
894
686
|
title = o.title
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
type.type = t
|
|
898
|
-
type
|
|
687
|
+
title = '' if :undef == title
|
|
688
|
+
PType.new(PResourceType.new(o.type.to_s, title))
|
|
899
689
|
end
|
|
900
690
|
|
|
901
691
|
# @api private
|
|
902
692
|
def infer_Array(o)
|
|
903
|
-
type = Types::PArrayType.new()
|
|
904
|
-
type.element_type =
|
|
905
693
|
if o.empty?
|
|
906
|
-
|
|
694
|
+
PArrayType::EMPTY
|
|
907
695
|
else
|
|
908
|
-
infer_and_reduce_type(o)
|
|
696
|
+
PArrayType.new(infer_and_reduce_type(o), size_as_type(o))
|
|
909
697
|
end
|
|
910
|
-
|
|
911
|
-
|
|
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
|
|
912
713
|
end
|
|
913
714
|
|
|
914
715
|
# @api private
|
|
915
716
|
def infer_Hash(o)
|
|
916
|
-
type = Types::PHashType.new()
|
|
917
717
|
if o.empty?
|
|
918
|
-
|
|
919
|
-
etype = Types::PUndefType.new()
|
|
718
|
+
PHashType::EMPTY
|
|
920
719
|
else
|
|
921
|
-
ktype = infer_and_reduce_type(o.keys
|
|
922
|
-
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))
|
|
923
723
|
end
|
|
924
|
-
type.key_type = ktype
|
|
925
|
-
type.element_type = etype
|
|
926
|
-
type.size_type = size_as_type(o)
|
|
927
|
-
type
|
|
928
724
|
end
|
|
929
725
|
|
|
930
726
|
def size_as_type(collection)
|
|
931
727
|
size = collection.size
|
|
932
|
-
|
|
933
|
-
t.from = size
|
|
934
|
-
t.to = size
|
|
935
|
-
t
|
|
728
|
+
PIntegerType.new(size, size)
|
|
936
729
|
end
|
|
937
730
|
|
|
938
731
|
# Common case for everything that intrinsically only has a single type
|
|
@@ -942,104 +735,37 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
942
735
|
|
|
943
736
|
def infer_set_Array(o)
|
|
944
737
|
if o.empty?
|
|
945
|
-
|
|
946
|
-
type.element_type = Types::PUndefType.new()
|
|
947
|
-
type.size_type = size_as_type(o)
|
|
738
|
+
PArrayType::EMPTY
|
|
948
739
|
else
|
|
949
|
-
|
|
950
|
-
type.types = o.map() {|x| infer_set(x) }
|
|
740
|
+
PTupleType.new(o.map {|x| infer_set(x) })
|
|
951
741
|
end
|
|
952
|
-
type
|
|
953
742
|
end
|
|
954
743
|
|
|
955
744
|
def infer_set_Hash(o)
|
|
956
745
|
if o.empty?
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
type.size_type = size_as_type(o)
|
|
961
|
-
elsif o.keys.all? {|k| instance_of_PStringType(@non_empty_string_t, k) }
|
|
962
|
-
type = Types::PStructType.new
|
|
963
|
-
type.elements = o.map do |k,v|
|
|
964
|
-
element = Types::PStructElement.new
|
|
965
|
-
element.key_type = infer_String(k)
|
|
966
|
-
element.value_type = infer_set(v)
|
|
967
|
-
element
|
|
968
|
-
end
|
|
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)) })
|
|
969
749
|
else
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
ktype
|
|
973
|
-
etype = Types::PVariantType.new
|
|
974
|
-
etype.types = o.values.map {|e| infer_set(e) }
|
|
975
|
-
type.key_type = unwrap_single_variant(ktype)
|
|
976
|
-
type.element_type = unwrap_single_variant(etype)
|
|
977
|
-
type.size_type = size_as_type(o)
|
|
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))
|
|
978
753
|
end
|
|
979
|
-
|
|
754
|
+
end
|
|
755
|
+
|
|
756
|
+
# @api private
|
|
757
|
+
def infer_set_Version(o)
|
|
758
|
+
PSemVerType.new([SemanticPuppet::VersionRange.new(o, o)])
|
|
980
759
|
end
|
|
981
760
|
|
|
982
761
|
def unwrap_single_variant(possible_variant)
|
|
983
|
-
if possible_variant.is_a?(
|
|
762
|
+
if possible_variant.is_a?(PVariantType) && possible_variant.types.size == 1
|
|
984
763
|
possible_variant.types[0]
|
|
985
764
|
else
|
|
986
765
|
possible_variant
|
|
987
766
|
end
|
|
988
767
|
end
|
|
989
768
|
|
|
990
|
-
# False in general type calculator
|
|
991
|
-
# @api private
|
|
992
|
-
def assignable_Object(t, t2)
|
|
993
|
-
false
|
|
994
|
-
end
|
|
995
|
-
|
|
996
|
-
# @api private
|
|
997
|
-
def assignable_PAnyType(t, t2)
|
|
998
|
-
t2.is_a?(Types::PAnyType)
|
|
999
|
-
end
|
|
1000
|
-
|
|
1001
|
-
# @api private
|
|
1002
|
-
def assignable_PNotUndefType(t, t2)
|
|
1003
|
-
!assignable?(t2, @nil_t) && (t.type.nil? || assignable?(t.type, t2))
|
|
1004
|
-
end
|
|
1005
|
-
|
|
1006
|
-
# @api private
|
|
1007
|
-
def assignable_PUndefType(t, t2)
|
|
1008
|
-
# Only undef/nil is assignable to nil type
|
|
1009
|
-
t2.is_a?(Types::PUndefType)
|
|
1010
|
-
end
|
|
1011
|
-
|
|
1012
|
-
# Anything is assignable to a Unit type
|
|
1013
|
-
# @api private
|
|
1014
|
-
def assignable_PUnitType(t, t2)
|
|
1015
|
-
true
|
|
1016
|
-
end
|
|
1017
|
-
|
|
1018
|
-
# @api private
|
|
1019
|
-
def assignable_PDefaultType(t, t2)
|
|
1020
|
-
# Only default is assignable to default type
|
|
1021
|
-
t2.is_a?(Types::PDefaultType)
|
|
1022
|
-
end
|
|
1023
|
-
|
|
1024
|
-
# @api private
|
|
1025
|
-
def assignable_PScalarType(t, t2)
|
|
1026
|
-
t2.is_a?(Types::PScalarType)
|
|
1027
|
-
end
|
|
1028
|
-
|
|
1029
|
-
# @api private
|
|
1030
|
-
def assignable_PNumericType(t, t2)
|
|
1031
|
-
t2.is_a?(Types::PNumericType)
|
|
1032
|
-
end
|
|
1033
|
-
|
|
1034
|
-
# @api private
|
|
1035
|
-
def assignable_PIntegerType(t, t2)
|
|
1036
|
-
return false unless t2.is_a?(Types::PIntegerType)
|
|
1037
|
-
trange = from_to_ordered(t.from, t.to)
|
|
1038
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
1039
|
-
# If t2 min and max are within the range of t
|
|
1040
|
-
trange[0] <= t2range[0] && trange[1] >= t2range[1]
|
|
1041
|
-
end
|
|
1042
|
-
|
|
1043
769
|
# Transform int range to a size constraint
|
|
1044
770
|
# if range == nil the constraint is 1,1
|
|
1045
771
|
# if range.from == nil min size = 1
|
|
@@ -1050,125 +776,13 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1050
776
|
from = range.from
|
|
1051
777
|
to = range.to
|
|
1052
778
|
x = from.nil? ? 1 : from
|
|
1053
|
-
y = to.nil? ?
|
|
1054
|
-
|
|
1055
|
-
[x, y]
|
|
1056
|
-
else
|
|
1057
|
-
[y, x]
|
|
1058
|
-
end
|
|
1059
|
-
end
|
|
1060
|
-
|
|
1061
|
-
# @api private
|
|
1062
|
-
def from_to_ordered(from, to)
|
|
1063
|
-
x = (from.nil? || from == :default) ? -Float::INFINITY : from
|
|
1064
|
-
y = (to.nil? || to == :default) ? Float::INFINITY : to
|
|
1065
|
-
if x < y
|
|
1066
|
-
[x, y]
|
|
1067
|
-
else
|
|
1068
|
-
[y, x]
|
|
1069
|
-
end
|
|
1070
|
-
end
|
|
1071
|
-
|
|
1072
|
-
# @api private
|
|
1073
|
-
def assignable_PVariantType(t, t2)
|
|
1074
|
-
# Data is a specific variant
|
|
1075
|
-
t2 = @data_variant_t if t2.is_a?(Types::PDataType)
|
|
1076
|
-
if t2.is_a?(Types::PVariantType)
|
|
1077
|
-
# A variant is assignable if all of its options are assignable to one of this type's options
|
|
1078
|
-
return true if t == t2
|
|
1079
|
-
t2.types.all? do |other|
|
|
1080
|
-
# if the other is a Variant, all of its options, but be assignable to one of this type's options
|
|
1081
|
-
other = other.is_a?(Types::PDataType) ? @data_variant_t : other
|
|
1082
|
-
if other.is_a?(Types::PVariantType)
|
|
1083
|
-
assignable?(t, other)
|
|
1084
|
-
else
|
|
1085
|
-
t.types.any? {|option_t| assignable?(option_t, other) }
|
|
1086
|
-
end
|
|
1087
|
-
end
|
|
1088
|
-
else
|
|
1089
|
-
# A variant is assignable if t2 is assignable to any of its types
|
|
1090
|
-
t.types.any? { |option_t| assignable?(option_t, t2) }
|
|
1091
|
-
end
|
|
1092
|
-
end
|
|
1093
|
-
|
|
1094
|
-
# Catch all not callable combinations
|
|
1095
|
-
def callable_Object(o, callable_t)
|
|
1096
|
-
false
|
|
1097
|
-
end
|
|
1098
|
-
|
|
1099
|
-
def callable_PTupleType(args_tuple, callable_t)
|
|
1100
|
-
if args_tuple.size_type
|
|
1101
|
-
raise ArgumentError, "Callable tuple may not have a size constraint when used as args"
|
|
1102
|
-
end
|
|
1103
|
-
|
|
1104
|
-
params_tuple = callable_t.param_types
|
|
1105
|
-
param_block_t = callable_t.block_type
|
|
1106
|
-
arg_types = args_tuple.types
|
|
1107
|
-
arg_block_t = arg_types.last()
|
|
1108
|
-
if self.class.is_kind_of_callable?(arg_block_t)
|
|
1109
|
-
# Can't pass a block to a callable that doesn't accept one
|
|
1110
|
-
return false if param_block_t.nil?
|
|
1111
|
-
|
|
1112
|
-
# Check that the block is of the right tyṕe
|
|
1113
|
-
return false unless assignable?(param_block_t, arg_block_t)
|
|
1114
|
-
|
|
1115
|
-
# Check other arguments
|
|
1116
|
-
arg_count = arg_types.size - 1
|
|
1117
|
-
params_size_t = params_tuple.size_type || Types::TypeFactory.range(*params_tuple.size_range)
|
|
1118
|
-
return false unless assignable?(params_size_t, Types::TypeFactory.range(arg_count, arg_count))
|
|
1119
|
-
|
|
1120
|
-
ctypes = params_tuple.types
|
|
1121
|
-
args_assignable = false
|
|
1122
|
-
arg_count.times do |index|
|
|
1123
|
-
return false unless assignable?((ctypes[index] || ctypes[-1]), arg_types[index])
|
|
1124
|
-
end
|
|
1125
|
-
return true
|
|
1126
|
-
end
|
|
1127
|
-
|
|
1128
|
-
# Check that tuple is assignable and that the block (if declared) is optional
|
|
1129
|
-
assignable?(params_tuple, args_tuple) && (param_block_t.nil? || assignable?(param_block_t, @nil_t))
|
|
779
|
+
y = to.nil? ? TheInfinity : to
|
|
780
|
+
[x, y]
|
|
1130
781
|
end
|
|
1131
782
|
|
|
1132
783
|
# @api private
|
|
1133
784
|
def self.is_kind_of_callable?(t, optional = true)
|
|
1134
|
-
|
|
1135
|
-
when Types::PCallableType
|
|
1136
|
-
true
|
|
1137
|
-
when Types::POptionalType
|
|
1138
|
-
optional && is_kind_of_callable?(t.optional_type, optional)
|
|
1139
|
-
when Types::PVariantType
|
|
1140
|
-
t.types.all? {|t2| is_kind_of_callable?(t2, optional) }
|
|
1141
|
-
else
|
|
1142
|
-
false
|
|
1143
|
-
end
|
|
1144
|
-
end
|
|
1145
|
-
|
|
1146
|
-
# @api private
|
|
1147
|
-
def self.is_kind_of_optional?(t, optional = true)
|
|
1148
|
-
case t
|
|
1149
|
-
when Types::POptionalType
|
|
1150
|
-
true
|
|
1151
|
-
when Types::PVariantType
|
|
1152
|
-
t.types.all? {|t2| is_kind_of_optional?(t2, optional) }
|
|
1153
|
-
else
|
|
1154
|
-
false
|
|
1155
|
-
end
|
|
1156
|
-
end
|
|
1157
|
-
|
|
1158
|
-
def callable_PArrayType(args_array, callable_t)
|
|
1159
|
-
return false unless assignable?(callable_t.param_types, args_array)
|
|
1160
|
-
# does not support calling with a block, but have to check that callable is ok with missing block
|
|
1161
|
-
assignable?(callable_t.block_type || @nil_t, @nil_t)
|
|
1162
|
-
end
|
|
1163
|
-
|
|
1164
|
-
def callable_PUndefType(nil_t, callable_t)
|
|
1165
|
-
# if callable_t is Optional (or indeed PUndefType), this means that 'missing callable' is accepted
|
|
1166
|
-
assignable?(callable_t, nil_t)
|
|
1167
|
-
end
|
|
1168
|
-
|
|
1169
|
-
def callable_PCallableType(given_callable_t, required_callable_t)
|
|
1170
|
-
# If the required callable is euqal or more specific than the given, the given is callable
|
|
1171
|
-
assignable?(required_callable_t, given_callable_t)
|
|
785
|
+
t.is_a?(PAnyType) && t.kind_of_callable?(optional)
|
|
1172
786
|
end
|
|
1173
787
|
|
|
1174
788
|
def max(a,b)
|
|
@@ -1179,41 +793,6 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1179
793
|
a <= b ? a : b
|
|
1180
794
|
end
|
|
1181
795
|
|
|
1182
|
-
def assignable_PTupleType(t, t2)
|
|
1183
|
-
return true if t == t2 || t.types.empty? && (t2.is_a?(Types::PArrayType))
|
|
1184
|
-
size_t = t.size_type || Puppet::Pops::Types::TypeFactory.range(*t.size_range)
|
|
1185
|
-
|
|
1186
|
-
if t2.is_a?(Types::PTupleType)
|
|
1187
|
-
size_t2 = t2.size_type || Puppet::Pops::Types::TypeFactory.range(*t2.size_range)
|
|
1188
|
-
|
|
1189
|
-
# not assignable if the number of types in t2 is outside number of types in t1
|
|
1190
|
-
if assignable?(size_t, size_t2)
|
|
1191
|
-
t2.types.size.times do |index|
|
|
1192
|
-
return false unless assignable?((t.types[index] || t.types[-1]), t2.types[index])
|
|
1193
|
-
end
|
|
1194
|
-
return true
|
|
1195
|
-
else
|
|
1196
|
-
return false
|
|
1197
|
-
end
|
|
1198
|
-
elsif t2.is_a?(Types::PArrayType)
|
|
1199
|
-
t2_entry = t2.element_type
|
|
1200
|
-
|
|
1201
|
-
# Array of anything can not be assigned (unless tuple is tuple of anything) - this case
|
|
1202
|
-
# was handled at the top of this method.
|
|
1203
|
-
#
|
|
1204
|
-
return false if t2_entry.nil?
|
|
1205
|
-
size_t = t.size_type || Puppet::Pops::Types::TypeFactory.range(*t.size_range)
|
|
1206
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1207
|
-
return false unless assignable?(size_t, size_t2)
|
|
1208
|
-
min(t.types.size, size_t2.range()[1]).times do |index|
|
|
1209
|
-
return false unless assignable?((t.types[index] || t.types[-1]), t2_entry)
|
|
1210
|
-
end
|
|
1211
|
-
true
|
|
1212
|
-
else
|
|
1213
|
-
false
|
|
1214
|
-
end
|
|
1215
|
-
end
|
|
1216
|
-
|
|
1217
796
|
# Produces the tuple entry at the given index given a tuple type, its from/to constraints on the last
|
|
1218
797
|
# type, and an index.
|
|
1219
798
|
# Produces nil if the index is out of bounds
|
|
@@ -1233,614 +812,6 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1233
812
|
end
|
|
1234
813
|
end
|
|
1235
814
|
|
|
1236
|
-
# @api private
|
|
1237
|
-
#
|
|
1238
|
-
def assignable_PStructType(t, t2)
|
|
1239
|
-
if t2.is_a?(Types::PStructType)
|
|
1240
|
-
h2 = t2.hashed_elements
|
|
1241
|
-
matched = 0
|
|
1242
|
-
t.elements.all? do |e1|
|
|
1243
|
-
e2 = h2[e1.name]
|
|
1244
|
-
if e2.nil?
|
|
1245
|
-
assignable?(e1.key_type, @nil_t)
|
|
1246
|
-
else
|
|
1247
|
-
matched += 1
|
|
1248
|
-
assignable?(e1.key_type, e2.key_type) && assignable?(e1.value_type, e2.value_type)
|
|
1249
|
-
end
|
|
1250
|
-
end && matched == h2.size
|
|
1251
|
-
elsif t2.is_a?(Types::PHashType)
|
|
1252
|
-
required = 0
|
|
1253
|
-
required_elements_assignable = t.elements.all? do |e|
|
|
1254
|
-
if assignable?(e.key_type, @nil_t)
|
|
1255
|
-
true
|
|
1256
|
-
else
|
|
1257
|
-
required += 1
|
|
1258
|
-
assignable?(e.value_type, t2.element_type)
|
|
1259
|
-
end
|
|
1260
|
-
end
|
|
1261
|
-
if required_elements_assignable
|
|
1262
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1263
|
-
size_t = Types::PIntegerType.new
|
|
1264
|
-
size_t.from = required
|
|
1265
|
-
size_t.to = t.elements.size
|
|
1266
|
-
assignable_PIntegerType(size_t, size_t2)
|
|
1267
|
-
end
|
|
1268
|
-
else
|
|
1269
|
-
false
|
|
1270
|
-
end
|
|
1271
|
-
end
|
|
1272
|
-
|
|
1273
|
-
# @api private
|
|
1274
|
-
def assignable_POptionalType(t, t2)
|
|
1275
|
-
return true if t2.is_a?(Types::PUndefType)
|
|
1276
|
-
return true if t.optional_type.nil?
|
|
1277
|
-
if t2.is_a?(Types::POptionalType)
|
|
1278
|
-
assignable?(t.optional_type, t2.optional_type || @t)
|
|
1279
|
-
else
|
|
1280
|
-
assignable?(t.optional_type, t2)
|
|
1281
|
-
end
|
|
1282
|
-
end
|
|
1283
|
-
|
|
1284
|
-
# @api private
|
|
1285
|
-
def assignable_PEnumType(t, t2)
|
|
1286
|
-
return true if t == t2
|
|
1287
|
-
if t.values.empty?
|
|
1288
|
-
return true if t2.is_a?(Types::PStringType) || t2.is_a?(Types::PEnumType) || t2.is_a?(Types::PPatternType)
|
|
1289
|
-
end
|
|
1290
|
-
case t2
|
|
1291
|
-
when Types::PStringType
|
|
1292
|
-
# if the set of strings are all found in the set of enums
|
|
1293
|
-
!t2.values.empty?() && t2.values.all? { |s| t.values.any? { |e| e == s }}
|
|
1294
|
-
when Types::PVariantType
|
|
1295
|
-
t2.types.all? {|variant_t| assignable_PEnumType(t, variant_t) }
|
|
1296
|
-
when Types::PEnumType
|
|
1297
|
-
# empty means any enum
|
|
1298
|
-
return true if t.values.empty?
|
|
1299
|
-
!t2.values.empty? && t2.values.all? { |s| t.values.any? {|e| e == s }}
|
|
1300
|
-
else
|
|
1301
|
-
false
|
|
1302
|
-
end
|
|
1303
|
-
end
|
|
1304
|
-
|
|
1305
|
-
# @api private
|
|
1306
|
-
def assignable_PStringType(t, t2)
|
|
1307
|
-
if t.values.empty?
|
|
1308
|
-
# A general string is assignable by any other string or pattern restricted string
|
|
1309
|
-
# if the string has a size constraint it does not match since there is no reasonable way
|
|
1310
|
-
# to compute the min/max length a pattern will match. For enum, it is possible to test that
|
|
1311
|
-
# each enumerator value is within range
|
|
1312
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1313
|
-
case t2
|
|
1314
|
-
when Types::PStringType
|
|
1315
|
-
# true if size compliant
|
|
1316
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1317
|
-
assignable_PIntegerType(size_t, size_t2)
|
|
1318
|
-
|
|
1319
|
-
when Types::PPatternType
|
|
1320
|
-
# true if size constraint is at least 0 to +Infinity (which is the same as the default)
|
|
1321
|
-
assignable_PIntegerType(size_t, @collection_default_size_t)
|
|
1322
|
-
|
|
1323
|
-
when Types::PEnumType
|
|
1324
|
-
if t2.values && !t2.values.empty?
|
|
1325
|
-
# true if all enum values are within range
|
|
1326
|
-
min, max = t2.values.map(&:size).minmax
|
|
1327
|
-
trange = from_to_ordered(size_t.from, size_t.to)
|
|
1328
|
-
t2range = [min, max]
|
|
1329
|
-
# If t2 min and max are within the range of t
|
|
1330
|
-
trange[0] <= t2range[0] && trange[1] >= t2range[1]
|
|
1331
|
-
else
|
|
1332
|
-
# enum represents all enums, and thus all strings, a sized constrained string can thus not
|
|
1333
|
-
# be assigned any enum (unless it is max size).
|
|
1334
|
-
assignable_PIntegerType(size_t, @collection_default_size_t)
|
|
1335
|
-
end
|
|
1336
|
-
else
|
|
1337
|
-
# no other type matches string
|
|
1338
|
-
false
|
|
1339
|
-
end
|
|
1340
|
-
elsif t2.is_a?(Types::PStringType)
|
|
1341
|
-
# A specific string acts as a set of strings - must have exactly the same strings
|
|
1342
|
-
# In this case, size does not matter since the definition is very precise anyway
|
|
1343
|
-
Set.new(t.values) == Set.new(t2.values)
|
|
1344
|
-
else
|
|
1345
|
-
# All others are false, since no other type describes the same set of specific strings
|
|
1346
|
-
false
|
|
1347
|
-
end
|
|
1348
|
-
end
|
|
1349
|
-
|
|
1350
|
-
# @api private
|
|
1351
|
-
def assignable_PPatternType(t, t2)
|
|
1352
|
-
return true if t == t2
|
|
1353
|
-
case t2
|
|
1354
|
-
when Types::PStringType, Types::PEnumType
|
|
1355
|
-
values = t2.values
|
|
1356
|
-
when Types::PVariantType
|
|
1357
|
-
return t2.types.all? {|variant_t| assignable_PPatternType(t, variant_t) }
|
|
1358
|
-
when Types::PPatternType
|
|
1359
|
-
return t.patterns.empty? ? true : false
|
|
1360
|
-
else
|
|
1361
|
-
return false
|
|
1362
|
-
end
|
|
1363
|
-
|
|
1364
|
-
if t2.values.empty?
|
|
1365
|
-
# Strings / Enums (unknown which ones) cannot all match a pattern, but if there is no pattern it is ok
|
|
1366
|
-
# (There should really always be a pattern, but better safe than sorry).
|
|
1367
|
-
return t.patterns.empty? ? true : false
|
|
1368
|
-
end
|
|
1369
|
-
# all strings in String/Enum type must match one of the patterns in Pattern type,
|
|
1370
|
-
# or Pattern represents all Patterns == all Strings
|
|
1371
|
-
regexps = t.patterns.map {|p| p.regexp }
|
|
1372
|
-
regexps.empty? || t2.values.all? { |v| regexps.any? {|re| re.match(v) } }
|
|
1373
|
-
end
|
|
1374
|
-
|
|
1375
|
-
# @api private
|
|
1376
|
-
def assignable_PFloatType(t, t2)
|
|
1377
|
-
return false unless t2.is_a?(Types::PFloatType)
|
|
1378
|
-
trange = from_to_ordered(t.from, t.to)
|
|
1379
|
-
t2range = from_to_ordered(t2.from, t2.to)
|
|
1380
|
-
# If t2 min and max are within the range of t
|
|
1381
|
-
trange[0] <= t2range[0] && trange[1] >= t2range[1]
|
|
1382
|
-
end
|
|
1383
|
-
|
|
1384
|
-
# @api private
|
|
1385
|
-
def assignable_PBooleanType(t, t2)
|
|
1386
|
-
t2.is_a?(Types::PBooleanType)
|
|
1387
|
-
end
|
|
1388
|
-
|
|
1389
|
-
# @api private
|
|
1390
|
-
def assignable_PRegexpType(t, t2)
|
|
1391
|
-
t2.is_a?(Types::PRegexpType) && (t.pattern.nil? || t.pattern == t2.pattern)
|
|
1392
|
-
end
|
|
1393
|
-
|
|
1394
|
-
# @api private
|
|
1395
|
-
def assignable_PCallableType(t, t2)
|
|
1396
|
-
return false unless t2.is_a?(Types::PCallableType)
|
|
1397
|
-
# nil param_types means, any other Callable is assignable
|
|
1398
|
-
return true if t.param_types.nil?
|
|
1399
|
-
|
|
1400
|
-
# NOTE: these tests are made in reverse as it is calling the callable that is constrained
|
|
1401
|
-
# (it's lower bound), not its upper bound
|
|
1402
|
-
return false unless assignable?(t2.param_types, t.param_types)
|
|
1403
|
-
# names are ignored, they are just information
|
|
1404
|
-
# Blocks must be compatible
|
|
1405
|
-
this_block_t = t.block_type || @nil_t
|
|
1406
|
-
that_block_t = t2.block_type || @nil_t
|
|
1407
|
-
assignable?(that_block_t, this_block_t)
|
|
1408
|
-
|
|
1409
|
-
end
|
|
1410
|
-
|
|
1411
|
-
# @api private
|
|
1412
|
-
def assignable_PCollectionType(t, t2)
|
|
1413
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1414
|
-
case t2
|
|
1415
|
-
when Types::PCollectionType
|
|
1416
|
-
size_t2 = t2.size_type || @collection_default_size_t
|
|
1417
|
-
assignable_PIntegerType(size_t, size_t2)
|
|
1418
|
-
when Types::PTupleType
|
|
1419
|
-
# compute the tuple's min/max size, and check if that size matches
|
|
1420
|
-
from, to = size_range(t2.size_type)
|
|
1421
|
-
t2s = Types::PIntegerType.new()
|
|
1422
|
-
t2s.from = t2.types.size - 1 + from
|
|
1423
|
-
t2s.to = t2.types.size - 1 + to
|
|
1424
|
-
assignable_PIntegerType(size_t, t2s)
|
|
1425
|
-
when Types::PStructType
|
|
1426
|
-
from = to = t2.elements.size
|
|
1427
|
-
t2s = Types::PIntegerType.new()
|
|
1428
|
-
t2s.from = from
|
|
1429
|
-
t2s.to = to
|
|
1430
|
-
assignable_PIntegerType(size_t, t2s)
|
|
1431
|
-
else
|
|
1432
|
-
false
|
|
1433
|
-
end
|
|
1434
|
-
end
|
|
1435
|
-
|
|
1436
|
-
# @api private
|
|
1437
|
-
def assignable_PType(t, t2)
|
|
1438
|
-
return false unless t2.is_a?(Types::PType)
|
|
1439
|
-
return true if t.type.nil? # wide enough to handle all types
|
|
1440
|
-
return false if t2.type.nil? # wider than t
|
|
1441
|
-
assignable?(t.type, t2.type)
|
|
1442
|
-
end
|
|
1443
|
-
|
|
1444
|
-
# Array is assignable if t2 is an Array and t2's element type is assignable, or if t2 is a Tuple
|
|
1445
|
-
# @api private
|
|
1446
|
-
def assignable_PArrayType(t, t2)
|
|
1447
|
-
if t2.is_a?(Types::PArrayType)
|
|
1448
|
-
return false unless t.element_type.nil? || assignable?(t.element_type, t2.element_type || @t)
|
|
1449
|
-
assignable_PCollectionType(t, t2)
|
|
1450
|
-
|
|
1451
|
-
elsif t2.is_a?(Types::PTupleType)
|
|
1452
|
-
return false unless t.element_type.nil? || t2.types.all? {|t2_element| assignable?(t.element_type, t2_element) }
|
|
1453
|
-
t2_regular = t2.types[0..-2]
|
|
1454
|
-
t2_ranged = t2.types[-1]
|
|
1455
|
-
t2_from, t2_to = size_range(t2.size_type)
|
|
1456
|
-
t2_required = t2_regular.size + t2_from
|
|
1457
|
-
|
|
1458
|
-
t_entry = t.element_type
|
|
1459
|
-
|
|
1460
|
-
# Tuple of anything can not be assigned (unless array is tuple of anything) - this case
|
|
1461
|
-
# was handled at the top of this method.
|
|
1462
|
-
#
|
|
1463
|
-
return false if t_entry.nil?
|
|
1464
|
-
|
|
1465
|
-
# array type may be size constrained
|
|
1466
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1467
|
-
min, max = size_t.range
|
|
1468
|
-
# Tuple with fewer min entries can not be assigned
|
|
1469
|
-
return false if t2_required < min
|
|
1470
|
-
# Tuple with more optionally available entries can not be assigned
|
|
1471
|
-
return false if t2_regular.size + t2_to > max
|
|
1472
|
-
# each tuple type must be assignable to the element type
|
|
1473
|
-
t2_required.times do |index|
|
|
1474
|
-
t2_entry = tuple_entry_at(t2, t2_from, t2_to, index)
|
|
1475
|
-
return false unless assignable?(t_entry, t2_entry)
|
|
1476
|
-
end
|
|
1477
|
-
# ... and so must the last, possibly optional (ranged) type
|
|
1478
|
-
return assignable?(t_entry, t2_ranged)
|
|
1479
|
-
else
|
|
1480
|
-
false
|
|
1481
|
-
end
|
|
1482
|
-
end
|
|
1483
|
-
|
|
1484
|
-
# Hash is assignable if t2 is a Hash and t2's key and element types are assignable
|
|
1485
|
-
# @api private
|
|
1486
|
-
def assignable_PHashType(t, t2)
|
|
1487
|
-
case t2
|
|
1488
|
-
when Types::PHashType
|
|
1489
|
-
return true if (t.size_type.nil? || t.size_type.from == 0) && t2.is_the_empty_hash?
|
|
1490
|
-
return false unless t.key_type.nil? || assignable?(t.key_type, t2.key_type || @t)
|
|
1491
|
-
return false unless t.element_type.nil? || assignable?(t.element_type, t2.element_type || @t)
|
|
1492
|
-
assignable_PCollectionType(t, t2)
|
|
1493
|
-
when Types::PStructType
|
|
1494
|
-
# hash must accept String as key type
|
|
1495
|
-
# hash must accept all value types
|
|
1496
|
-
# hash must accept the size of the struct
|
|
1497
|
-
size_t = t.size_type || @collection_default_size_t
|
|
1498
|
-
min, max = size_t.range
|
|
1499
|
-
struct_size = t2.elements.size
|
|
1500
|
-
key_type = t.key_type
|
|
1501
|
-
element_type = t.element_type
|
|
1502
|
-
( struct_size >= min && struct_size <= max &&
|
|
1503
|
-
t2.elements.all? {|e| (key_type.nil? || instance_of(key_type, e.name)) && (element_type.nil? || assignable?(element_type, e.value_type)) })
|
|
1504
|
-
else
|
|
1505
|
-
false
|
|
1506
|
-
end
|
|
1507
|
-
end
|
|
1508
|
-
|
|
1509
|
-
# @api private
|
|
1510
|
-
def assignable_PCatalogEntryType(t1, t2)
|
|
1511
|
-
t2.is_a?(Types::PCatalogEntryType)
|
|
1512
|
-
end
|
|
1513
|
-
|
|
1514
|
-
# @api private
|
|
1515
|
-
def assignable_PHostClassType(t1, t2)
|
|
1516
|
-
return false unless t2.is_a?(Types::PHostClassType)
|
|
1517
|
-
# Class = Class[name}, Class[name] != Class
|
|
1518
|
-
return true if t1.class_name.nil?
|
|
1519
|
-
# Class[name] = Class[name]
|
|
1520
|
-
return t1.class_name == t2.class_name
|
|
1521
|
-
end
|
|
1522
|
-
|
|
1523
|
-
# @api private
|
|
1524
|
-
def assignable_PResourceType(t1, t2)
|
|
1525
|
-
return false unless t2.is_a?(Types::PResourceType)
|
|
1526
|
-
return true if t1.type_name.nil?
|
|
1527
|
-
return false if t1.type_name != t2.type_name
|
|
1528
|
-
return true if t1.title.nil?
|
|
1529
|
-
return t1.title == t2.title
|
|
1530
|
-
end
|
|
1531
|
-
|
|
1532
|
-
# Data is assignable by other Data and by Array[Data] and Hash[Scalar, Data]
|
|
1533
|
-
# @api private
|
|
1534
|
-
def assignable_PDataType(t, t2)
|
|
1535
|
-
# We cannot put the NotUndefType[Data] in the @data_variant_t since that causes an endless recursion
|
|
1536
|
-
case t2
|
|
1537
|
-
when Types::PDataType
|
|
1538
|
-
true
|
|
1539
|
-
when Types::PNotUndefType
|
|
1540
|
-
assignable?(t, t2.type || @t)
|
|
1541
|
-
else
|
|
1542
|
-
assignable?(@data_variant_t, t2)
|
|
1543
|
-
end
|
|
1544
|
-
end
|
|
1545
|
-
|
|
1546
|
-
# Assignable if t2's has the same runtime and the runtime name resolves to
|
|
1547
|
-
# a class that is the same or subclass of t1's resolved runtime type name
|
|
1548
|
-
# @api private
|
|
1549
|
-
def assignable_PRuntimeType(t1, t2)
|
|
1550
|
-
return false unless t2.is_a?(Types::PRuntimeType)
|
|
1551
|
-
return false unless t1.runtime == t2.runtime
|
|
1552
|
-
return true if t1.runtime_type_name.nil? # t1 is wider
|
|
1553
|
-
return false if t2.runtime_type_name.nil? # t1 not nil, so t2 can not be wider
|
|
1554
|
-
|
|
1555
|
-
# NOTE: This only supports Ruby, must change when/if the set of runtimes is expanded
|
|
1556
|
-
c1 = class_from_string(t1.runtime_type_name)
|
|
1557
|
-
c2 = class_from_string(t2.runtime_type_name)
|
|
1558
|
-
return false unless c1.is_a?(Class) && c2.is_a?(Class)
|
|
1559
|
-
!!(c2 <= c1)
|
|
1560
|
-
end
|
|
1561
|
-
|
|
1562
|
-
# @api private
|
|
1563
|
-
def debug_string_Object(t)
|
|
1564
|
-
string(t)
|
|
1565
|
-
end
|
|
1566
|
-
|
|
1567
|
-
# @api private
|
|
1568
|
-
def string_PType(t)
|
|
1569
|
-
if t.type.nil?
|
|
1570
|
-
"Type"
|
|
1571
|
-
else
|
|
1572
|
-
"Type[#{string(t.type)}]"
|
|
1573
|
-
end
|
|
1574
|
-
end
|
|
1575
|
-
|
|
1576
|
-
# @api private
|
|
1577
|
-
def string_NilClass(t) ; '?' ; end
|
|
1578
|
-
|
|
1579
|
-
# @api private
|
|
1580
|
-
def string_String(t) ; t ; end
|
|
1581
|
-
|
|
1582
|
-
# @api private
|
|
1583
|
-
def string_Symbol(t) ; t.to_s ; end
|
|
1584
|
-
|
|
1585
|
-
def string_PAnyType(t) ; "Any" ; end
|
|
1586
|
-
|
|
1587
|
-
# @api private
|
|
1588
|
-
def string_PUndefType(t) ; 'Undef' ; end
|
|
1589
|
-
|
|
1590
|
-
# @api private
|
|
1591
|
-
def string_PDefaultType(t) ; 'Default' ; end
|
|
1592
|
-
|
|
1593
|
-
# @api private
|
|
1594
|
-
def string_PBooleanType(t) ; "Boolean" ; end
|
|
1595
|
-
|
|
1596
|
-
# @api private
|
|
1597
|
-
def string_PScalarType(t) ; "Scalar" ; end
|
|
1598
|
-
|
|
1599
|
-
# @api private
|
|
1600
|
-
def string_PDataType(t) ; "Data" ; end
|
|
1601
|
-
|
|
1602
|
-
# @api private
|
|
1603
|
-
def string_PNumericType(t) ; "Numeric" ; end
|
|
1604
|
-
|
|
1605
|
-
# @api private
|
|
1606
|
-
def string_PIntegerType(t)
|
|
1607
|
-
range = range_array_part(t)
|
|
1608
|
-
unless range.empty?
|
|
1609
|
-
"Integer[#{range.join(', ')}]"
|
|
1610
|
-
else
|
|
1611
|
-
"Integer"
|
|
1612
|
-
end
|
|
1613
|
-
end
|
|
1614
|
-
|
|
1615
|
-
# Produces a string from an Integer range type that is used inside other type strings
|
|
1616
|
-
# @api private
|
|
1617
|
-
def range_array_part(t)
|
|
1618
|
-
return [] if t.nil? || (t.from.nil? && t.to.nil?)
|
|
1619
|
-
[t.from.nil? ? 'default' : t.from , t.to.nil? ? 'default' : t.to ]
|
|
1620
|
-
end
|
|
1621
|
-
|
|
1622
|
-
# @api private
|
|
1623
|
-
def string_PFloatType(t)
|
|
1624
|
-
range = range_array_part(t)
|
|
1625
|
-
unless range.empty?
|
|
1626
|
-
"Float[#{range.join(', ')}]"
|
|
1627
|
-
else
|
|
1628
|
-
"Float"
|
|
1629
|
-
end
|
|
1630
|
-
end
|
|
1631
|
-
|
|
1632
|
-
# @api private
|
|
1633
|
-
def string_PRegexpType(t)
|
|
1634
|
-
t.pattern.nil? ? "Regexp" : "Regexp[#{t.regexp.inspect}]"
|
|
1635
|
-
end
|
|
1636
|
-
|
|
1637
|
-
# @api private
|
|
1638
|
-
def string_PStringType(t)
|
|
1639
|
-
# skip values in regular output - see debug_string
|
|
1640
|
-
range = range_array_part(t.size_type)
|
|
1641
|
-
unless range.empty?
|
|
1642
|
-
"String[#{range.join(', ')}]"
|
|
1643
|
-
else
|
|
1644
|
-
"String"
|
|
1645
|
-
end
|
|
1646
|
-
end
|
|
1647
|
-
|
|
1648
|
-
# @api private
|
|
1649
|
-
def debug_string_PStringType(t)
|
|
1650
|
-
range = range_array_part(t.size_type)
|
|
1651
|
-
range_part = range.empty? ? '' : '[' << range.join(' ,') << '], '
|
|
1652
|
-
"String[" << range_part << (t.values.map {|s| "'#{s}'" }).join(', ') << ']'
|
|
1653
|
-
end
|
|
1654
|
-
|
|
1655
|
-
# @api private
|
|
1656
|
-
def string_PEnumType(t)
|
|
1657
|
-
return "Enum" if t.values.empty?
|
|
1658
|
-
"Enum[" << t.values.map {|s| "'#{s}'" }.join(', ') << ']'
|
|
1659
|
-
end
|
|
1660
|
-
|
|
1661
|
-
# @api private
|
|
1662
|
-
def string_PVariantType(t)
|
|
1663
|
-
return "Variant" if t.types.empty?
|
|
1664
|
-
"Variant[" << t.types.map {|t2| string(t2) }.join(', ') << ']'
|
|
1665
|
-
end
|
|
1666
|
-
|
|
1667
|
-
# @api private
|
|
1668
|
-
def string_PTupleType(t)
|
|
1669
|
-
range = range_array_part(t.size_type)
|
|
1670
|
-
return "Tuple" if t.types.empty?
|
|
1671
|
-
s = "Tuple[" << t.types.map {|t2| string(t2) }.join(', ')
|
|
1672
|
-
unless range.empty?
|
|
1673
|
-
s << ", " << range.join(', ')
|
|
1674
|
-
end
|
|
1675
|
-
s << "]"
|
|
1676
|
-
s
|
|
1677
|
-
end
|
|
1678
|
-
|
|
1679
|
-
# @api private
|
|
1680
|
-
def string_PCallableType(t)
|
|
1681
|
-
# generic
|
|
1682
|
-
return "Callable" if t.param_types.nil?
|
|
1683
|
-
|
|
1684
|
-
if t.param_types.types.empty?
|
|
1685
|
-
range = [0, 0]
|
|
1686
|
-
else
|
|
1687
|
-
range = range_array_part(t.param_types.size_type)
|
|
1688
|
-
end
|
|
1689
|
-
# translate to string, and skip Unit types
|
|
1690
|
-
types = t.param_types.types.map {|t2| string(t2) unless t2.class == Types::PUnitType }.compact
|
|
1691
|
-
|
|
1692
|
-
s = "Callable[" << types.join(', ')
|
|
1693
|
-
unless range.empty?
|
|
1694
|
-
(s << ', ') unless types.empty?
|
|
1695
|
-
s << range.join(', ')
|
|
1696
|
-
end
|
|
1697
|
-
# Add block T last (after min, max) if present)
|
|
1698
|
-
#
|
|
1699
|
-
unless t.block_type.nil?
|
|
1700
|
-
(s << ', ') unless types.empty? && range.empty?
|
|
1701
|
-
s << string(t.block_type)
|
|
1702
|
-
end
|
|
1703
|
-
s << "]"
|
|
1704
|
-
s
|
|
1705
|
-
end
|
|
1706
|
-
|
|
1707
|
-
# @api private
|
|
1708
|
-
def string_PStructType(t)
|
|
1709
|
-
return "Struct" if t.elements.empty?
|
|
1710
|
-
"Struct[{" << t.elements.map {|element| string(element) }.join(', ') << "}]"
|
|
1711
|
-
end
|
|
1712
|
-
|
|
1713
|
-
def string_PStructElement(t)
|
|
1714
|
-
k = t.key_type
|
|
1715
|
-
value_optional = assignable?(t.value_type, @nil_t)
|
|
1716
|
-
key_string =
|
|
1717
|
-
if k.is_a?(Types::POptionalType)
|
|
1718
|
-
# Output as literal String
|
|
1719
|
-
value_optional ? "'#{t.name}'" : string(k)
|
|
1720
|
-
else
|
|
1721
|
-
value_optional ? "NotUndef['#{t.name}']" : "'#{t.name}'"
|
|
1722
|
-
end
|
|
1723
|
-
"#{key_string}=>#{string(t.value_type)}"
|
|
1724
|
-
end
|
|
1725
|
-
|
|
1726
|
-
# @api private
|
|
1727
|
-
def string_PPatternType(t)
|
|
1728
|
-
return "Pattern" if t.patterns.empty?
|
|
1729
|
-
"Pattern[" << t.patterns.map {|s| "#{s.regexp.inspect}" }.join(', ') << ']'
|
|
1730
|
-
end
|
|
1731
|
-
|
|
1732
|
-
# @api private
|
|
1733
|
-
def string_PCollectionType(t)
|
|
1734
|
-
range = range_array_part(t.size_type)
|
|
1735
|
-
unless range.empty?
|
|
1736
|
-
"Collection[#{range.join(', ')}]"
|
|
1737
|
-
else
|
|
1738
|
-
"Collection"
|
|
1739
|
-
end
|
|
1740
|
-
end
|
|
1741
|
-
|
|
1742
|
-
# @api private
|
|
1743
|
-
def string_PUnitType(t)
|
|
1744
|
-
"Unit"
|
|
1745
|
-
end
|
|
1746
|
-
|
|
1747
|
-
# @api private
|
|
1748
|
-
def string_PRuntimeType(t) ; "Runtime[#{string(t.runtime)}, #{string(t.runtime_type_name)}]" ; end
|
|
1749
|
-
|
|
1750
|
-
# @api private
|
|
1751
|
-
def string_PArrayType(t)
|
|
1752
|
-
parts = [string(t.element_type)] + range_array_part(t.size_type)
|
|
1753
|
-
"Array[#{parts.join(', ')}]"
|
|
1754
|
-
end
|
|
1755
|
-
|
|
1756
|
-
# @api private
|
|
1757
|
-
def string_PHashType(t)
|
|
1758
|
-
parts = [string(t.key_type), string(t.element_type)] + range_array_part(t.size_type)
|
|
1759
|
-
"Hash[#{parts.join(', ')}]"
|
|
1760
|
-
end
|
|
1761
|
-
|
|
1762
|
-
# @api private
|
|
1763
|
-
def string_PCatalogEntryType(t)
|
|
1764
|
-
"CatalogEntry"
|
|
1765
|
-
end
|
|
1766
|
-
|
|
1767
|
-
# @api private
|
|
1768
|
-
def string_PHostClassType(t)
|
|
1769
|
-
if t.class_name
|
|
1770
|
-
"Class[#{t.class_name}]"
|
|
1771
|
-
else
|
|
1772
|
-
"Class"
|
|
1773
|
-
end
|
|
1774
|
-
end
|
|
1775
|
-
|
|
1776
|
-
# @api private
|
|
1777
|
-
def string_PResourceType(t)
|
|
1778
|
-
if t.type_name
|
|
1779
|
-
if t.title
|
|
1780
|
-
"#{capitalize_segments(t.type_name)}['#{t.title}']"
|
|
1781
|
-
else
|
|
1782
|
-
capitalize_segments(t.type_name)
|
|
1783
|
-
end
|
|
1784
|
-
else
|
|
1785
|
-
"Resource"
|
|
1786
|
-
end
|
|
1787
|
-
end
|
|
1788
|
-
|
|
1789
|
-
# @api private
|
|
1790
|
-
def string_PNotUndefType(t)
|
|
1791
|
-
contained_type = t.type
|
|
1792
|
-
if contained_type.nil? || contained_type.class == Puppet::Pops::Types::PAnyType
|
|
1793
|
-
'NotUndef'
|
|
1794
|
-
else
|
|
1795
|
-
if contained_type.is_a?(Puppet::Pops::Types::PStringType) && contained_type.values.size == 1
|
|
1796
|
-
"NotUndef['#{contained_type.values[0]}']"
|
|
1797
|
-
else
|
|
1798
|
-
"NotUndef[#{string(contained_type)}]"
|
|
1799
|
-
end
|
|
1800
|
-
end
|
|
1801
|
-
end
|
|
1802
|
-
|
|
1803
|
-
def string_POptionalType(t)
|
|
1804
|
-
optional_type = t.optional_type
|
|
1805
|
-
if optional_type.nil?
|
|
1806
|
-
"Optional"
|
|
1807
|
-
else
|
|
1808
|
-
if optional_type.is_a?(Puppet::Pops::Types::PStringType) && optional_type.values.size == 1
|
|
1809
|
-
"Optional['#{optional_type.values[0]}']"
|
|
1810
|
-
else
|
|
1811
|
-
"Optional[#{string(optional_type)}]"
|
|
1812
|
-
end
|
|
1813
|
-
end
|
|
1814
|
-
end
|
|
1815
|
-
|
|
1816
|
-
# Catches all non enumerable types
|
|
1817
|
-
# @api private
|
|
1818
|
-
def enumerable_Object(o)
|
|
1819
|
-
nil
|
|
1820
|
-
end
|
|
1821
|
-
|
|
1822
|
-
# @api private
|
|
1823
|
-
def enumerable_PIntegerType(t)
|
|
1824
|
-
# Not enumerable if representing an infinite range
|
|
1825
|
-
return nil if t.size == Float::INFINITY
|
|
1826
|
-
t
|
|
1827
|
-
end
|
|
1828
|
-
|
|
1829
|
-
def self.copy_as_tuple(t)
|
|
1830
|
-
case t
|
|
1831
|
-
when Types::PTupleType
|
|
1832
|
-
t.copy
|
|
1833
|
-
when Types::PArrayType
|
|
1834
|
-
# transform array to tuple
|
|
1835
|
-
result = Types::PTupleType.new
|
|
1836
|
-
result.addTypes(t.element_type.copy)
|
|
1837
|
-
result.size_type = t.size_type.nil? ? nil : t.size_type.copy
|
|
1838
|
-
result
|
|
1839
|
-
else
|
|
1840
|
-
raise ArgumentError, "Internal Error: Only Array and Tuple can be given to copy_as_tuple"
|
|
1841
|
-
end
|
|
1842
|
-
end
|
|
1843
|
-
|
|
1844
815
|
# Debugging to_s to reduce the amount of output
|
|
1845
816
|
def to_s
|
|
1846
817
|
'[a TypeCalculator]'
|
|
@@ -1848,32 +819,18 @@ class Puppet::Pops::Types::TypeCalculator
|
|
|
1848
819
|
|
|
1849
820
|
private
|
|
1850
821
|
|
|
1851
|
-
NAME_SEGMENT_SEPARATOR = '::'.freeze
|
|
1852
|
-
|
|
1853
|
-
def capitalize_segments(s)
|
|
1854
|
-
s.split(NAME_SEGMENT_SEPARATOR).map(&:capitalize).join(NAME_SEGMENT_SEPARATOR)
|
|
1855
|
-
end
|
|
1856
|
-
|
|
1857
|
-
def class_from_string(str)
|
|
1858
|
-
begin
|
|
1859
|
-
str.split(NAME_SEGMENT_SEPARATOR).inject(Object) do |memo, name_segment|
|
|
1860
|
-
memo.const_get(name_segment)
|
|
1861
|
-
end
|
|
1862
|
-
rescue NameError
|
|
1863
|
-
return nil
|
|
1864
|
-
end
|
|
1865
|
-
end
|
|
1866
|
-
|
|
1867
822
|
def common_data?(t1, t2)
|
|
1868
|
-
assignable?(
|
|
823
|
+
PDataType::DEFAULT.assignable?(t1) && PDataType::DEFAULT.assignable?(t2)
|
|
1869
824
|
end
|
|
1870
825
|
|
|
1871
826
|
def common_scalar?(t1, t2)
|
|
1872
|
-
assignable?(
|
|
827
|
+
PScalarType::DEFAULT.assignable?(t1) && PScalarType::DEFAULT.assignable?(t2)
|
|
1873
828
|
end
|
|
1874
829
|
|
|
1875
830
|
def common_numeric?(t1, t2)
|
|
1876
|
-
assignable?(
|
|
831
|
+
PNumericType::DEFAULT.assignable?(t1) && PNumericType::DEFAULT.assignable?(t2)
|
|
1877
832
|
end
|
|
1878
833
|
|
|
1879
834
|
end
|
|
835
|
+
end
|
|
836
|
+
end
|