puppet 5.0.0 → 6.0.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 +7 -0
- data/CONTRIBUTING.md +52 -42
- data/Gemfile +48 -81
- data/Gemfile.lock +156 -0
- data/MAINTAINERS +0 -19
- data/README.md +19 -17
- data/Rakefile +47 -36
- data/conf/auth.conf +7 -2
- data/conf/environment.conf +1 -1
- data/conf/fileserver.conf +1 -1
- data/conf/puppet.conf +4 -4
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +0 -2
- data/ext/cert_inspector +2 -2
- data/ext/debian/copyright +2 -24
- data/ext/debian/puppetmaster.README.debian +2 -2
- data/ext/envpuppet +1 -1
- data/ext/gentoo/init.d/puppetmaster +4 -4
- data/ext/hiera/hiera.yaml +1 -1
- data/ext/ips/puppet-agent +11 -11
- data/ext/ips/puppet-master +11 -11
- data/ext/project_data.yaml +9 -8
- data/ext/puppet-test +5 -5
- data/ext/redhat/client.init +2 -2
- data/ext/redhat/logrotate +1 -1
- data/ext/redhat/puppet.spec.erb +0 -4
- data/ext/regexp_nodes/regexp_nodes.rb +15 -16
- data/ext/solaris/smf/puppet +11 -11
- data/ext/solaris/smf/svc-puppetd +5 -5
- data/ext/solaris/smf/svc-puppetmasterd +5 -5
- data/ext/upload_facts.rb +2 -2
- data/ext/windows/service/daemon.rb +1 -1
- data/install.rb +2 -3
- data/lib/hiera/puppet_function.rb +5 -2
- data/lib/hiera/scope.rb +24 -2
- data/lib/hiera_puppet.rb +3 -3
- data/lib/puppet/agent/locker.rb +6 -5
- data/lib/puppet/agent.rb +24 -3
- data/lib/puppet/application/agent.rb +19 -14
- data/lib/puppet/application/apply.rb +30 -17
- data/lib/puppet/application/cert.rb +30 -174
- data/lib/puppet/application/config.rb +1 -0
- data/lib/puppet/application/describe.rb +6 -3
- data/lib/puppet/application/device.rb +165 -60
- data/lib/puppet/application/doc.rb +10 -4
- data/lib/puppet/application/face_base.rb +1 -1
- data/lib/puppet/application/facts.rb +5 -0
- data/lib/puppet/application/filebucket.rb +60 -18
- data/lib/puppet/application/help.rb +1 -0
- data/lib/puppet/application/lookup.rb +23 -11
- data/lib/puppet/application/resource.rb +8 -4
- data/lib/puppet/application/script.rb +261 -0
- data/lib/puppet/application/ssl.rb +133 -0
- data/lib/puppet/application.rb +42 -11
- data/lib/puppet/application_support.rb +7 -3
- data/lib/puppet/configurer/downloader.rb +1 -1
- data/lib/puppet/configurer/fact_handler.rb +5 -1
- data/lib/puppet/configurer/plugin_handler.rb +32 -9
- data/lib/puppet/configurer.rb +114 -76
- data/lib/puppet/confine.rb +4 -1
- data/lib/puppet/context.rb +1 -1
- data/lib/puppet/daemon.rb +3 -3
- data/lib/puppet/datatypes/error.rb +21 -0
- data/lib/puppet/datatypes/impl/error.rb +40 -0
- data/lib/puppet/datatypes.rb +213 -0
- data/lib/puppet/defaults.rb +279 -209
- data/lib/puppet/environments.rb +24 -11
- data/lib/puppet/error.rb +35 -18
- data/lib/puppet/etc.rb +6 -7
- data/lib/puppet/external/dot.rb +23 -24
- data/lib/puppet/external/pson/common.rb +2 -2
- data/lib/puppet/external/pson/pure/generator.rb +1 -1
- data/lib/puppet/external/pson/pure/parser.rb +1 -1
- data/lib/puppet/face/catalog.rb +2 -2
- data/lib/puppet/face/config.rb +157 -11
- data/lib/puppet/face/epp.rb +66 -37
- data/lib/puppet/face/facts.rb +49 -0
- data/lib/puppet/face/help/action.erb +4 -1
- data/lib/puppet/face/help/face.erb +1 -1
- data/lib/puppet/face/help/global.erb +2 -2
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/help.rb +78 -64
- data/lib/puppet/face/man.rb +56 -12
- data/lib/puppet/face/module/build.rb +5 -54
- data/lib/puppet/face/module/generate.rb +6 -243
- data/lib/puppet/face/module/install.rb +1 -4
- data/lib/puppet/face/module/list.rb +6 -22
- data/lib/puppet/face/module/search.rb +7 -3
- data/lib/puppet/face/module/uninstall.rb +15 -7
- data/lib/puppet/face/module/upgrade.rb +1 -4
- data/lib/puppet/face/node/clean.rb +14 -10
- data/lib/puppet/face/node.rb +1 -0
- data/lib/puppet/face/parser.rb +30 -4
- data/lib/puppet/face/plugin.rb +1 -3
- data/lib/puppet/face/status.rb +3 -2
- data/lib/puppet/feature/base.rb +8 -27
- data/lib/puppet/feature/bolt.rb +3 -0
- data/lib/puppet/feature/eventlog.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -2
- data/lib/puppet/file_bucket/file.rb +0 -2
- data/lib/puppet/file_serving/base.rb +18 -17
- data/lib/puppet/file_serving/configuration/parser.rb +25 -9
- data/lib/puppet/file_serving/configuration.rb +6 -0
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_serving/metadata.rb +4 -3
- data/lib/puppet/file_serving/mount/locales.rb +35 -0
- data/lib/puppet/file_serving/mount/tasks.rb +21 -0
- data/lib/puppet/file_system/uniquefile.rb +2 -2
- data/lib/puppet/forge/errors.rb +27 -25
- data/lib/puppet/forge/repository.rb +1 -1
- data/lib/puppet/forge.rb +22 -9
- data/lib/puppet/functions/abs.rb +61 -0
- data/lib/puppet/functions/alert.rb +1 -1
- data/lib/puppet/functions/all.rb +104 -0
- data/lib/puppet/functions/annotate.rb +11 -11
- data/lib/puppet/functions/any.rb +109 -0
- data/lib/puppet/functions/assert_type.rb +7 -7
- data/lib/puppet/functions/binary_file.rb +15 -2
- data/lib/puppet/functions/break.rb +34 -9
- data/lib/puppet/functions/call.rb +41 -4
- data/lib/puppet/functions/camelcase.rb +62 -0
- data/lib/puppet/functions/capitalize.rb +61 -0
- data/lib/puppet/functions/ceiling.rb +37 -0
- data/lib/puppet/functions/chomp.rb +57 -0
- data/lib/puppet/functions/chop.rb +67 -0
- data/lib/puppet/functions/compare.rb +125 -0
- data/lib/puppet/functions/contain.rb +25 -3
- data/lib/puppet/functions/convert_to.rb +34 -0
- data/lib/puppet/functions/crit.rb +1 -1
- data/lib/puppet/functions/debug.rb +1 -1
- data/lib/puppet/functions/defined.rb +14 -15
- data/lib/puppet/functions/dig.rb +47 -3
- data/lib/puppet/functions/downcase.rb +89 -0
- data/lib/puppet/functions/each.rb +30 -20
- data/lib/puppet/functions/emerg.rb +1 -1
- data/lib/puppet/functions/empty.rb +77 -0
- data/lib/puppet/functions/epp.rb +3 -0
- data/lib/puppet/functions/err.rb +1 -1
- data/lib/puppet/functions/eyaml_lookup_key.rb +11 -8
- data/lib/puppet/functions/filter.rb +30 -23
- data/lib/puppet/functions/find_file.rb +15 -2
- data/lib/puppet/functions/flatten.rb +64 -0
- data/lib/puppet/functions/floor.rb +37 -0
- data/lib/puppet/functions/get.rb +150 -0
- data/lib/puppet/functions/getvar.rb +87 -0
- data/lib/puppet/functions/hiera.rb +11 -11
- data/lib/puppet/functions/hiera_array.rb +11 -11
- data/lib/puppet/functions/hiera_hash.rb +12 -12
- data/lib/puppet/functions/hiera_include.rb +15 -15
- data/lib/puppet/functions/hocon_data.rb +1 -1
- data/lib/puppet/functions/include.rb +34 -2
- data/lib/puppet/functions/info.rb +1 -1
- data/lib/puppet/functions/inline_epp.rb +2 -2
- data/lib/puppet/functions/join.rb +56 -0
- data/lib/puppet/functions/json_data.rb +3 -3
- data/lib/puppet/functions/keys.rb +25 -0
- data/lib/puppet/functions/length.rb +44 -0
- data/lib/puppet/functions/lest.rb +39 -1
- data/lib/puppet/functions/lookup.rb +7 -5
- data/lib/puppet/functions/lstrip.rb +58 -0
- data/lib/puppet/functions/map.rb +34 -20
- data/lib/puppet/functions/match.rb +17 -6
- data/lib/puppet/functions/max.rb +183 -0
- data/lib/puppet/functions/min.rb +182 -0
- data/lib/puppet/functions/module_directory.rb +41 -0
- data/lib/puppet/functions/new.rb +982 -7
- data/lib/puppet/functions/next.rb +2 -9
- data/lib/puppet/functions/notice.rb +1 -1
- data/lib/puppet/functions/reduce.rb +36 -5
- data/lib/puppet/functions/regsubst.rb +10 -4
- data/lib/puppet/functions/require.rb +42 -2
- data/lib/puppet/functions/return.rb +2 -9
- data/lib/puppet/functions/reverse_each.rb +71 -2
- data/lib/puppet/functions/round.rb +24 -0
- data/lib/puppet/functions/rstrip.rb +58 -0
- data/lib/puppet/functions/size.rb +15 -0
- data/lib/puppet/functions/slice.rb +25 -12
- data/lib/puppet/functions/sort.rb +74 -0
- data/lib/puppet/functions/split.rb +12 -10
- data/lib/puppet/functions/step.rb +73 -1
- data/lib/puppet/functions/strftime.rb +178 -10
- data/lib/puppet/functions/strip.rb +58 -0
- data/lib/puppet/functions/then.rb +65 -2
- data/lib/puppet/functions/tree_each.rb +200 -0
- data/lib/puppet/functions/type.rb +42 -1
- data/lib/puppet/functions/unique.rb +13 -13
- data/lib/puppet/functions/unwrap.rb +8 -4
- data/lib/puppet/functions/upcase.rb +89 -0
- data/lib/puppet/functions/values.rb +25 -0
- data/lib/puppet/functions/versioncmp.rb +1 -1
- data/lib/puppet/functions/warning.rb +1 -1
- data/lib/puppet/functions/with.rb +9 -7
- data/lib/puppet/functions/yaml_data.rb +8 -7
- data/lib/puppet/functions.rb +212 -95
- data/lib/puppet/generate/models/type/property.rb +1 -1
- data/lib/puppet/generate/type.rb +1 -1
- data/lib/puppet/gettext/config.rb +275 -0
- data/lib/puppet/gettext/module_translations.rb +42 -0
- data/lib/puppet/gettext/stubs.rb +11 -0
- data/lib/puppet/graph/relationship_graph.rb +7 -1
- data/lib/puppet/graph/simple_graph.rb +12 -8
- data/lib/puppet/graph.rb +0 -2
- data/lib/puppet/indirector/catalog/compiler.rb +48 -16
- data/lib/puppet/indirector/catalog/json.rb +14 -3
- data/lib/puppet/indirector/catalog/yaml.rb +0 -16
- data/lib/puppet/indirector/certificate/file.rb +0 -1
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +4 -6
- data/lib/puppet/indirector/facts/network_device.rb +2 -2
- data/lib/puppet/indirector/facts/rest.rb +21 -0
- data/lib/puppet/indirector/facts/yaml.rb +4 -6
- data/lib/puppet/indirector/file_bucket_file/file.rb +11 -4
- data/lib/puppet/indirector/file_content/http.rb +3 -1
- data/lib/puppet/indirector/file_server.rb +1 -1
- data/lib/puppet/indirector/indirection.rb +28 -24
- data/lib/puppet/indirector/key/file.rb +1 -6
- data/lib/puppet/indirector/node/exec.rb +2 -4
- data/lib/puppet/indirector/node/yaml.rb +0 -6
- data/lib/puppet/indirector/request.rb +19 -15
- data/lib/puppet/indirector/rest.rb +21 -68
- data/lib/puppet/indirector/ssl_file.rb +5 -46
- data/lib/puppet/indirector/terminus.rb +4 -4
- data/lib/puppet/indirector/yaml.rb +4 -4
- data/lib/puppet/info_service/class_information_service.rb +1 -1
- data/lib/puppet/info_service/task_information_service.rb +36 -0
- data/lib/puppet/info_service.rb +10 -0
- data/lib/puppet/interface/action.rb +54 -29
- data/lib/puppet/interface/action_builder.rb +22 -5
- data/lib/puppet/interface/action_manager.rb +1 -1
- data/lib/puppet/interface/documentation.rb +21 -10
- data/lib/puppet/interface/face_collection.rb +7 -3
- data/lib/puppet/interface/option.rb +36 -15
- data/lib/puppet/interface/option_builder.rb +23 -9
- data/lib/puppet/interface/option_manager.rb +9 -4
- data/lib/puppet/interface.rb +3 -2
- data/lib/puppet/loaders.rb +3 -0
- data/lib/puppet/metatype/manager.rb +9 -7
- data/lib/puppet/module/task.rb +267 -0
- data/lib/puppet/module.rb +70 -14
- data/lib/puppet/module_tool/applications/application.rb +5 -5
- data/lib/puppet/module_tool/applications/checksummer.rb +3 -3
- data/lib/puppet/module_tool/applications/installer.rb +9 -7
- data/lib/puppet/module_tool/applications/uninstaller.rb +4 -2
- data/lib/puppet/module_tool/applications/unpacker.rb +4 -4
- data/lib/puppet/module_tool/applications/upgrader.rb +8 -6
- data/lib/puppet/module_tool/applications.rb +0 -1
- data/lib/puppet/module_tool/dependency.rb +1 -1
- data/lib/puppet/module_tool/errors/installer.rb +18 -20
- data/lib/puppet/module_tool/errors/shared.rb +20 -15
- data/lib/puppet/module_tool/errors/uninstaller.rb +1 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
- data/lib/puppet/module_tool/installed_modules.rb +3 -3
- data/lib/puppet/module_tool/local_tarball.rb +3 -3
- data/lib/puppet/module_tool/metadata.rb +3 -5
- data/lib/puppet/module_tool/shared_behaviors.rb +2 -2
- data/lib/puppet/module_tool/tar/mini.rb +57 -4
- data/lib/puppet/module_tool.rb +2 -5
- data/lib/puppet/network/auth_config_parser.rb +18 -13
- data/lib/puppet/network/authconfig.rb +1 -14
- data/lib/puppet/network/authstore.rb +3 -3
- data/lib/puppet/network/client_request.rb +1 -1
- data/lib/puppet/network/format.rb +3 -3
- data/lib/puppet/network/format_support.rb +14 -9
- data/lib/puppet/network/formats.rb +98 -9
- data/lib/puppet/network/http/api/indirected_routes.rb +11 -3
- data/lib/puppet/network/http/api/indirection_type.rb +1 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +7 -4
- data/lib/puppet/network/http/api/master/v3/environments.rb +2 -2
- data/lib/puppet/network/http/api.rb +1 -10
- data/lib/puppet/network/http/compression.rb +1 -1
- data/lib/puppet/network/http/connection.rb +105 -25
- data/lib/puppet/network/http/error.rb +10 -10
- data/lib/puppet/network/http/factory.rb +8 -0
- data/lib/puppet/network/http/handler.rb +59 -27
- data/lib/puppet/network/http.rb +0 -2
- data/lib/puppet/network/resolver.rb +139 -67
- data/lib/puppet/network/rights.rb +1 -1
- data/lib/puppet/node/environment.rb +23 -20
- data/lib/puppet/node/facts.rb +20 -1
- data/lib/puppet/node.rb +80 -8
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parameter/value_collection.rb +9 -9
- data/lib/puppet/parameter.rb +15 -10
- data/lib/puppet/parser/abstract_compiler.rb +36 -0
- data/lib/puppet/parser/ast/branch.rb +4 -4
- data/lib/puppet/parser/ast/leaf.rb +7 -2
- data/lib/puppet/parser/ast/node.rb +2 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +26 -52
- data/lib/puppet/parser/ast.rb +4 -8
- data/lib/puppet/parser/catalog_compiler.rb +32 -0
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +1 -1
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +9 -2
- data/lib/puppet/parser/compiler.rb +29 -61
- data/lib/puppet/parser/functions/assert_type.rb +4 -4
- data/lib/puppet/parser/functions/binary_file.rb +1 -1
- data/lib/puppet/parser/functions/break.rb +1 -1
- data/lib/puppet/parser/functions/create_resources.rb +7 -7
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/dig.rb +12 -3
- data/lib/puppet/parser/functions/each.rb +3 -3
- data/lib/puppet/parser/functions/epp.rb +4 -1
- data/lib/puppet/parser/functions/filter.rb +3 -3
- data/lib/puppet/parser/functions/find_file.rb +1 -1
- data/lib/puppet/parser/functions/fqdn_rand.rb +16 -1
- data/lib/puppet/parser/functions/generate.rb +3 -5
- data/lib/puppet/parser/functions/hiera.rb +4 -4
- data/lib/puppet/parser/functions/hiera_array.rb +5 -5
- data/lib/puppet/parser/functions/hiera_hash.rb +6 -6
- data/lib/puppet/parser/functions/hiera_include.rb +10 -11
- data/lib/puppet/parser/functions/inline_epp.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +8 -3
- data/lib/puppet/parser/functions/lest.rb +2 -2
- data/lib/puppet/parser/functions/lookup.rb +1 -1
- data/lib/puppet/parser/functions/map.rb +2 -2
- data/lib/puppet/parser/functions/match.rb +1 -1
- data/lib/puppet/parser/functions/new.rb +106 -54
- data/lib/puppet/parser/functions/next.rb +1 -1
- data/lib/puppet/parser/functions/realize.rb +6 -0
- data/lib/puppet/parser/functions/reduce.rb +33 -2
- data/lib/puppet/parser/functions/return.rb +23 -2
- data/lib/puppet/parser/functions/reverse_each.rb +3 -3
- data/lib/puppet/parser/functions/scanf.rb +1 -1
- data/lib/puppet/parser/functions/sha256.rb +5 -0
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/functions/sprintf.rb +28 -3
- data/lib/puppet/parser/functions/step.rb +2 -2
- data/lib/puppet/parser/functions/strftime.rb +1 -1
- data/lib/puppet/parser/functions/tag.rb +6 -0
- data/lib/puppet/parser/functions/tagged.rb +6 -3
- data/lib/puppet/parser/functions/template.rb +11 -2
- data/lib/puppet/parser/functions/then.rb +2 -2
- data/lib/puppet/parser/functions/type.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +5 -5
- data/lib/puppet/parser/functions.rb +40 -7
- data/lib/puppet/parser/parser_factory.rb +1 -1
- data/lib/puppet/parser/relationship.rb +2 -2
- data/lib/puppet/parser/resource/param.rb +12 -5
- data/lib/puppet/parser/resource.rb +39 -12
- data/lib/puppet/parser/scope.rb +55 -24
- data/lib/puppet/parser/script_compiler.rb +123 -0
- data/lib/puppet/parser/templatewrapper.rb +4 -3
- data/lib/puppet/parser/type_loader.rb +12 -12
- data/lib/puppet/parser.rb +1 -0
- data/lib/puppet/pops/adapters.rb +14 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +49 -8
- data/lib/puppet/pops/evaluator/closure.rb +12 -4
- data/lib/puppet/pops/evaluator/collector_transformer.rb +4 -3
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/compare_operator.rb +7 -5
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +127 -0
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +36 -10
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +61 -17
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/relationship_operator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +29 -8
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +4 -4
- data/lib/puppet/pops/evaluator/runtime3_support.rb +17 -20
- data/lib/puppet/pops/functions/dispatch.rb +13 -6
- data/lib/puppet/pops/functions/function.rb +10 -4
- data/lib/puppet/pops/issue_reporter.rb +25 -3
- data/lib/puppet/pops/issues.rb +82 -15
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/loader/base_loader.rb +10 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +7 -0
- data/lib/puppet/pops/loader/loader.rb +22 -3
- data/lib/puppet/pops/loader/loader_paths.rb +183 -31
- data/lib/puppet/pops/loader/module_loaders.rb +239 -41
- data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +10 -10
- data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +39 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +1 -2
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +54 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +6 -1
- data/lib/puppet/pops/loader/static_loader.rb +23 -45
- data/lib/puppet/pops/loader/task_instantiator.rb +97 -0
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +8 -1
- data/lib/puppet/pops/loaders.rb +158 -45
- data/lib/puppet/pops/lookup/context.rb +1 -1
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
- data/lib/puppet/pops/lookup/explainer.rb +2 -1
- data/lib/puppet/pops/lookup/global_data_provider.rb +1 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +4 -4
- data/lib/puppet/pops/lookup/interpolation.rb +1 -1
- data/lib/puppet/pops/lookup/lookup_adapter.rb +61 -12
- data/lib/puppet/pops/merge_strategy.rb +7 -4
- data/lib/puppet/pops/migration/migration_checker.rb +8 -8
- data/lib/puppet/pops/model/ast.pp +19 -0
- data/lib/puppet/pops/model/ast.rb +567 -436
- data/lib/puppet/pops/model/ast_transformer.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +232 -147
- data/lib/puppet/pops/model/model_label_provider.rb +9 -1
- data/lib/puppet/pops/model/model_tree_dumper.rb +17 -2
- data/lib/puppet/pops/model/pn_transformer.rb +400 -0
- data/lib/puppet/pops/model/tree_dumper.rb +1 -1
- data/lib/puppet/pops/parser/code_merger.rb +2 -2
- data/lib/puppet/pops/parser/egrammar.ra +85 -24
- data/lib/puppet/pops/parser/eparser.rb +1791 -1578
- data/lib/puppet/pops/parser/epp_parser.rb +1 -1
- data/lib/puppet/pops/parser/epp_support.rb +7 -5
- data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/lib/puppet/pops/parser/heredoc_support.rb +2 -2
- data/lib/puppet/pops/parser/interpolation_support.rb +2 -2
- data/lib/puppet/pops/parser/lexer2.rb +5 -5
- data/lib/puppet/pops/parser/lexer_support.rb +5 -4
- data/lib/puppet/pops/parser/locatable.rb +1 -1
- data/lib/puppet/pops/parser/locator.rb +7 -15
- data/lib/puppet/pops/parser/parser_support.rb +3 -3
- data/lib/puppet/pops/parser/pn_parser.rb +316 -0
- data/lib/puppet/pops/parser/slurp_support.rb +0 -3
- data/lib/puppet/pops/patterns.rb +2 -1
- data/lib/puppet/pops/pcore.rb +67 -12
- data/lib/puppet/pops/pn.rb +236 -0
- data/lib/puppet/pops/puppet_stack.rb +15 -1
- data/lib/puppet/pops/resource/param.rb +2 -2
- data/lib/puppet/pops/resource/resource_type_impl.rb +4 -4
- data/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +8 -1
- data/lib/puppet/pops/serialization/extension.rb +1 -0
- data/lib/puppet/pops/serialization/from_data_converter.rb +69 -26
- data/lib/puppet/pops/serialization/json.rb +7 -7
- data/lib/puppet/pops/serialization/json_path.rb +3 -2
- data/lib/puppet/pops/serialization/object.rb +3 -4
- data/lib/puppet/pops/serialization/serializer.rb +2 -1
- data/lib/puppet/pops/serialization/to_data_converter.rb +27 -14
- data/lib/puppet/pops/serialization/to_stringified_converter.rb +226 -0
- data/lib/puppet/pops/serialization.rb +3 -2
- data/lib/puppet/pops/time/timespan.rb +1 -1
- data/lib/puppet/pops/time/timestamp.rb +31 -19
- data/lib/puppet/pops/types/annotatable.rb +2 -2
- data/lib/puppet/pops/types/annotation.rb +8 -8
- data/lib/puppet/pops/types/class_loader.rb +9 -6
- data/lib/puppet/pops/types/implementation_registry.rb +29 -36
- data/lib/puppet/pops/types/iterable.rb +42 -11
- data/lib/puppet/pops/types/p_binary_type.rb +12 -6
- data/lib/puppet/pops/types/p_init_type.rb +238 -0
- data/lib/puppet/pops/types/p_meta_type.rb +18 -11
- data/lib/puppet/pops/types/p_object_type.rb +240 -48
- data/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +5 -6
- data/lib/puppet/pops/types/p_sem_ver_type.rb +12 -4
- data/lib/puppet/pops/types/p_sensitive_type.rb +2 -2
- data/lib/puppet/pops/types/p_timespan_type.rb +9 -9
- data/lib/puppet/pops/types/p_timestamp_type.rb +7 -3
- data/lib/puppet/pops/types/p_type_set_type.rb +33 -10
- data/lib/puppet/pops/types/p_uri_type.rb +190 -0
- data/lib/puppet/pops/types/puppet_object.rb +16 -2
- data/lib/puppet/pops/types/ruby_generator.rb +111 -78
- data/lib/puppet/pops/types/ruby_method.rb +2 -2
- data/lib/puppet/pops/types/string_converter.rb +38 -14
- data/lib/puppet/pops/types/tree_iterators.rb +254 -0
- data/lib/puppet/pops/types/type_acceptor.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +31 -20
- data/lib/puppet/pops/types/type_factory.rb +82 -17
- data/lib/puppet/pops/types/type_formatter.rb +77 -9
- data/lib/puppet/pops/types/type_mismatch_describer.rb +106 -137
- data/lib/puppet/pops/types/type_parser.rb +130 -24
- data/lib/puppet/pops/types/type_set_reference.rb +2 -2
- data/lib/puppet/pops/types/type_with_members.rb +43 -0
- data/lib/puppet/pops/types/types.rb +456 -219
- data/lib/puppet/pops/utils.rb +2 -2
- data/lib/puppet/pops/validation/checker4_0.rb +145 -8
- data/lib/puppet/pops/validation/tasks_checker.rb +101 -0
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +13 -8
- data/lib/puppet/pops/validation.rb +14 -12
- data/lib/puppet/pops.rb +2 -1
- data/lib/puppet/property/ensure.rb +2 -2
- data/lib/puppet/property/keyvalue.rb +70 -8
- data/lib/puppet/property.rb +15 -7
- data/lib/puppet/provider/aix_object.rb +483 -0
- data/lib/puppet/provider/exec.rb +0 -2
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/group/aix.rb +51 -110
- data/lib/puppet/provider/group/groupadd.rb +27 -1
- data/lib/puppet/provider/group/windows_adsi.rb +4 -7
- data/lib/puppet/provider/ldap.rb +2 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +7 -6
- data/lib/puppet/provider/nameservice/objectadd.rb +13 -24
- data/lib/puppet/provider/nameservice/pw.rb +14 -14
- data/lib/puppet/provider/nameservice.rb +20 -10
- data/lib/puppet/provider/package/aix.rb +5 -5
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +0 -1
- data/lib/puppet/provider/package/dnf.rb +2 -1
- data/lib/puppet/provider/package/gem.rb +13 -12
- data/lib/puppet/provider/package/macports.rb +2 -2
- data/lib/puppet/provider/package/nim.rb +7 -8
- data/lib/puppet/provider/package/opkg.rb +1 -1
- data/lib/puppet/provider/package/pacman.rb +4 -4
- data/lib/puppet/provider/package/pip.rb +15 -6
- data/lib/puppet/provider/package/pkg.rb +12 -6
- data/lib/puppet/provider/package/pkgdmg.rb +3 -4
- data/lib/puppet/provider/package/pkgutil.rb +5 -5
- data/lib/puppet/provider/package/portage.rb +9 -10
- data/lib/puppet/provider/package/puppet_gem.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/windows/package.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +34 -10
- data/lib/puppet/provider/package/zypper.rb +5 -5
- data/lib/puppet/provider/parsedfile.rb +4 -4
- data/lib/puppet/provider/service/base.rb +23 -10
- data/lib/puppet/provider/service/debian.rb +1 -0
- data/lib/puppet/provider/service/init.rb +2 -1
- data/lib/puppet/provider/service/launchd.rb +7 -8
- data/lib/puppet/provider/service/redhat.rb +3 -2
- data/lib/puppet/provider/service/runit.rb +2 -1
- data/lib/puppet/provider/service/smf.rb +5 -3
- data/lib/puppet/provider/service/systemd.rb +6 -3
- data/lib/puppet/provider/service/upstart.rb +11 -1
- data/lib/puppet/provider/service/windows.rb +37 -40
- data/lib/puppet/provider/user/aix.rb +143 -247
- data/lib/puppet/provider/user/openbsd.rb +3 -2
- data/lib/puppet/provider/user/pw.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +7 -1
- data/lib/puppet/provider/user/useradd.rb +40 -6
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/provider.rb +34 -13
- data/lib/puppet/reference/configuration.rb +12 -2
- data/lib/puppet/reference/providers.rb +1 -1
- data/lib/puppet/reference/report.rb +1 -1
- data/lib/puppet/reference/type.rb +11 -12
- data/lib/puppet/relationship.rb +2 -1
- data/lib/puppet/reports/http.rb +4 -2
- data/lib/puppet/reports/store.rb +1 -1
- data/lib/puppet/reports.rb +2 -2
- data/lib/puppet/resource/capability_finder.rb +49 -27
- data/lib/puppet/resource/catalog.rb +42 -34
- data/lib/puppet/resource/status.rb +11 -3
- data/lib/puppet/resource/type.rb +16 -12
- data/lib/puppet/resource/type_collection.rb +2 -2
- data/lib/puppet/resource.rb +30 -12
- data/lib/puppet/rest/client.rb +83 -0
- data/lib/puppet/rest/errors.rb +14 -0
- data/lib/puppet/rest/response.rb +34 -0
- data/lib/puppet/rest/route.rb +84 -0
- data/lib/puppet/rest/routes.rb +154 -0
- data/lib/puppet/rest/ssl_context.rb +13 -0
- data/lib/puppet/settings/base_setting.rb +29 -9
- data/lib/puppet/settings/certificate_revocation_setting.rb +21 -0
- data/lib/puppet/settings/config_file.rb +16 -7
- data/lib/puppet/settings/environment_conf.rb +29 -11
- data/lib/puppet/settings/file_setting.rb +1 -1
- data/lib/puppet/settings/ini_file.rb +66 -12
- data/lib/puppet/settings/ttl_setting.rb +5 -0
- data/lib/puppet/settings.rb +68 -38
- data/lib/puppet/ssl/base.rb +10 -13
- data/lib/puppet/ssl/certificate.rb +6 -2
- data/lib/puppet/ssl/certificate_request.rb +19 -21
- data/lib/puppet/ssl/certificate_request_attributes.rb +1 -1
- data/lib/puppet/ssl/certificate_signer.rb +11 -0
- data/lib/puppet/ssl/host.rb +413 -174
- data/lib/puppet/ssl/key.rb +1 -5
- data/lib/puppet/ssl/oids.rb +10 -4
- data/lib/puppet/ssl/validator/default_validator.rb +33 -19
- data/lib/puppet/ssl.rb +0 -1
- data/lib/puppet/syntax_checkers/base64.rb +6 -7
- data/lib/puppet/syntax_checkers/json.rb +1 -1
- data/lib/puppet/test/test_helper.rb +2 -3
- data/lib/puppet/transaction/additional_resource_generator.rb +2 -2
- data/lib/puppet/transaction/event.rb +38 -15
- data/lib/puppet/transaction/event_manager.rb +3 -1
- data/lib/puppet/transaction/persistence.rb +17 -2
- data/lib/puppet/transaction/report.rb +33 -16
- data/lib/puppet/transaction.rb +43 -16
- data/lib/puppet/type/exec.rb +23 -20
- data/lib/puppet/type/file/checksum.rb +7 -1
- data/lib/puppet/type/file/checksum_value.rb +4 -3
- data/lib/puppet/type/file/content.rb +17 -5
- data/lib/puppet/type/file/data_sync.rb +2 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +1 -1
- data/lib/puppet/type/file/source.rb +21 -8
- data/lib/puppet/type/file.rb +36 -25
- data/lib/puppet/type/group.rb +7 -6
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +5 -8
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/schedule.rb +73 -112
- data/lib/puppet/type/service.rb +3 -6
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +21 -8
- data/lib/puppet/type/user.rb +98 -50
- data/lib/puppet/type.rb +76 -67
- data/lib/puppet/util/at_fork/solaris.rb +6 -4
- data/lib/puppet/util/autoload.rb +62 -54
- data/lib/puppet/util/backups.rb +1 -1
- data/lib/puppet/util/character_encoding.rb +2 -24
- data/lib/puppet/util/checksums.rb +82 -3
- data/lib/puppet/util/classgen.rb +0 -6
- data/lib/puppet/util/command_line/trollop.rb +6 -5
- data/lib/puppet/util/command_line.rb +5 -1
- data/lib/puppet/util/connection.rb +74 -0
- data/lib/puppet/util/errors.rb +59 -8
- data/lib/puppet/util/execution.rb +70 -17
- data/lib/puppet/util/feature.rb +63 -41
- data/lib/puppet/util/fileparsing.rb +30 -10
- data/lib/puppet/util/filetype.rb +2 -2
- data/lib/puppet/util/http_proxy.rb +18 -8
- data/lib/puppet/util/inifile.rb +3 -4
- data/lib/puppet/util/instance_loader.rb +4 -24
- data/lib/puppet/util/json.rb +69 -0
- data/lib/puppet/util/json_lockfile.rb +3 -3
- data/lib/puppet/util/ldap/connection.rb +7 -7
- data/lib/puppet/util/ldap/manager.rb +6 -3
- data/lib/puppet/util/log/destinations.rb +13 -4
- data/lib/puppet/util/log.rb +30 -33
- data/lib/puppet/util/logging.rb +26 -29
- data/lib/puppet/util/monkey_patches.rb +1 -1
- data/lib/puppet/util/network_device/base.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +22 -15
- data/lib/puppet/util/platform.rb +16 -0
- data/lib/puppet/util/plist.rb +7 -5
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/provider_features.rb +3 -6
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +3 -3
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/reference.rb +8 -15
- data/lib/puppet/util/rubygems.rb +1 -13
- data/lib/puppet/util/run_mode.rb +1 -1
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/ssl.rb +40 -1
- data/lib/puppet/util/storage.rb +3 -3
- data/lib/puppet/util/suidmanager.rb +8 -5
- data/lib/puppet/util/tag_set.rb +1 -1
- data/lib/puppet/util/tagging.rb +18 -5
- data/lib/puppet/util/warnings.rb +0 -2
- data/lib/puppet/util/windows/adsi.rb +160 -214
- data/lib/puppet/util/windows/api_types.rb +9 -5
- data/lib/puppet/util/windows/com.rb +2 -1
- data/lib/puppet/util/windows/eventlog.rb +10 -5
- data/lib/puppet/util/windows/file.rb +113 -12
- data/lib/puppet/util/windows/principal.rb +7 -6
- data/lib/puppet/util/windows/process.rb +10 -2
- data/lib/puppet/util/windows/registry.rb +2 -2
- data/lib/puppet/util/windows/security.rb +26 -14
- data/lib/puppet/util/windows/service.rb +770 -0
- data/lib/puppet/util/windows/sid.rb +60 -9
- data/lib/puppet/util/windows.rb +19 -2
- data/lib/puppet/util/yaml.rb +41 -5
- data/lib/puppet/util.rb +50 -50
- data/lib/puppet/vendor/deep_merge/README.md +2 -2
- data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +18 -18
- data/lib/puppet/vendor/pathspec/lib/pathspec.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +12 -68
- data/lib/puppet_pal.rb +1102 -0
- data/locales/en/puppet.po +19 -0
- data/locales/ja/puppet.po +11128 -0
- data/locales/puppet.pot +3723 -2251
- data/man/man5/puppet.conf.5 +342 -187
- data/man/man8/puppet-agent.8 +36 -10
- data/man/man8/puppet-apply.8 +21 -6
- data/man/man8/puppet-catalog.8 +12 -15
- data/man/man8/puppet-config.8 +40 -6
- data/man/man8/puppet-describe.8 +3 -3
- data/man/man8/puppet-device.8 +48 -14
- data/man/man8/puppet-doc.8 +5 -5
- data/man/man8/puppet-epp.8 +49 -21
- data/man/man8/puppet-facts.8 +58 -9
- data/man/man8/puppet-filebucket.8 +76 -10
- data/man/man8/puppet-generate.8 +84 -0
- data/man/man8/puppet-help.8 +4 -4
- data/man/man8/puppet-key.8 +11 -17
- data/man/man8/puppet-lookup.8 +104 -0
- data/man/man8/puppet-man.8 +13 -7
- data/man/man8/puppet-module.8 +29 -98
- data/man/man8/puppet-node.8 +12 -15
- data/man/man8/puppet-parser.8 +34 -11
- data/man/man8/puppet-plugin.8 +4 -4
- data/man/man8/puppet-report.8 +9 -9
- data/man/man8/puppet-resource.8 +4 -8
- data/man/man8/puppet-script.8 +67 -0
- data/man/man8/puppet-ssl.8 +28 -0
- data/man/man8/puppet-status.8 +9 -9
- data/man/man8/puppet.8 +21 -3
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +2 -0
- data/spec/fixtures/unit/functions/hiera/hiera/backend/hieraspec_backend.rb +22 -0
- data/spec/fixtures/unit/functions/lookup/hiera/backend/custom_backend.rb +18 -0
- data/spec/fixtures/unit/functions/lookup/hiera/backend/other_backend.rb +7 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome2/lib/puppet_x/awesome2/echo_scheme_handler.rb +1 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +6 -6
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_input.out +1 -0
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_output.out +1 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.info +0 -1
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-plugin-output.txt +36 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-simple.txt +1 -0
- data/spec/fixtures/unit/provider/service/base/ps_ef.mixed_encoding +3 -0
- data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +32 -0
- data/spec/integration/agent/logging_spec.rb +4 -2
- data/spec/integration/application/apply_spec.rb +33 -26
- data/spec/integration/application/lookup_spec.rb +21 -0
- data/spec/integration/configurer_spec.rb +2 -5
- data/spec/integration/data_binding_spec.rb +1 -0
- data/spec/integration/defaults_spec.rb +5 -10
- data/spec/integration/faces/config_spec.rb +16 -4
- data/spec/integration/faces/plugin_spec.rb +3 -0
- data/spec/integration/file_bucket/file_spec.rb +20 -22
- data/spec/integration/file_system/uniquefile_spec.rb +26 -29
- data/spec/integration/indirector/facts/facter_spec.rb +4 -14
- data/spec/integration/indirector/file_content/file_server_spec.rb +17 -0
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +10 -0
- data/spec/integration/network/authconfig_spec.rb +2 -2
- data/spec/integration/network/http/api/indirected_routes_spec.rb +9 -38
- data/spec/integration/node/environment_spec.rb +1 -1
- data/spec/integration/node_spec.rb +0 -4
- data/spec/integration/parser/catalog_spec.rb +10 -6
- data/spec/integration/parser/collection_spec.rb +42 -3
- data/spec/integration/parser/compiler_spec.rb +43 -24
- data/spec/integration/parser/pcore_resource_spec.rb +3 -3
- data/spec/integration/parser/scope_spec.rb +18 -5
- data/spec/integration/parser/script_compiler_spec.rb +113 -0
- data/spec/integration/provider/service/init_spec.rb +4 -2
- data/spec/integration/provider/service/systemd_spec.rb +8 -4
- data/spec/integration/provider/service/windows_spec.rb +5 -3
- data/spec/integration/reference/providers_spec.rb +6 -0
- data/spec/integration/ssl/certificate_request_spec.rb +0 -2
- data/spec/integration/ssl/host_spec.rb +16 -24
- data/spec/integration/ssl/key_spec.rb +3 -3
- data/spec/integration/test/test_helper_spec.rb +32 -32
- data/spec/integration/transaction/report_spec.rb +11 -6
- data/spec/integration/type/exec_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +72 -18
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/integration/type_spec.rb +1 -2
- data/spec/integration/util/autoload_spec.rb +9 -6
- data/spec/integration/util/execution_spec.rb +13 -5
- data/spec/integration/util/rdoc/parser_spec.rb +13 -23
- data/spec/integration/util/settings_spec.rb +2 -1
- data/spec/integration/util/windows/adsi_spec.rb +89 -4
- data/spec/integration/util/windows/principal_spec.rb +12 -3
- data/spec/integration/util/windows/process_spec.rb +48 -3
- data/spec/integration/util/windows/registry_spec.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +98 -8
- data/spec/integration/util/windows/user_spec.rb +1 -1
- data/spec/integration/util_spec.rb +3 -3
- data/spec/lib/matchers/json.rb +27 -32
- data/{lib/puppet/ssl → spec/lib/puppet}/certificate_factory.rb +5 -6
- data/spec/lib/puppet/test_ca.rb +109 -0
- data/spec/lib/puppet_spec/compiler.rb +27 -0
- data/spec/lib/puppet_spec/files.rb +28 -23
- data/spec/lib/puppet_spec/language.rb +34 -35
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +2 -2
- data/spec/lib/puppet_spec/modules.rb +20 -0
- data/spec/lib/puppet_spec/ssl.rb +265 -0
- data/spec/lib/puppet_spec/validators.rb +37 -0
- data/spec/shared_behaviours/file_server_terminus.rb +0 -2
- data/spec/shared_behaviours/file_serving_model.rb +0 -19
- data/spec/shared_behaviours/path_parameters.rb +1 -1
- data/spec/shared_behaviours/things_that_declare_options.rb +2 -2
- data/spec/shared_contexts/checksum.rb +4 -1
- data/spec/shared_contexts/digests.rb +46 -1
- data/spec/shared_contexts/types_setup.rb +66 -7
- data/spec/shared_examples/rhel_package_provider.rb +2 -2
- data/spec/spec_helper.rb +7 -14
- data/spec/unit/agent_spec.rb +48 -4
- data/spec/unit/application/agent_spec.rb +5 -20
- data/spec/unit/application/apply_spec.rb +4 -12
- data/spec/unit/application/config_spec.rb +4 -0
- data/spec/unit/application/device_spec.rb +141 -10
- data/spec/unit/application/face_base_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +18 -4
- data/spec/unit/application/lookup_spec.rb +46 -9
- data/spec/unit/application/ssl_spec.rb +322 -0
- data/spec/unit/application_spec.rb +46 -4
- data/spec/unit/capability_spec.rb +11 -9
- data/spec/unit/{ssl/certificate_factory_spec.rb → certificate_factory_spec.rb} +9 -18
- data/spec/unit/configurer/downloader_spec.rb +6 -1
- data/spec/unit/configurer/plugin_handler_spec.rb +46 -18
- data/spec/unit/configurer_spec.rb +90 -33
- data/spec/unit/confine_spec.rb +16 -0
- data/spec/unit/context/trusted_information_spec.rb +3 -2
- data/spec/unit/daemon_spec.rb +3 -2
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +4 -4
- data/spec/unit/datatypes_spec.rb +353 -0
- data/spec/unit/defaults_spec.rb +108 -6
- data/spec/unit/environments_spec.rb +62 -0
- data/spec/unit/etc_spec.rb +1 -1
- data/spec/unit/face/config_spec.rb +185 -21
- data/spec/unit/face/epp_face_spec.rb +70 -6
- data/spec/unit/face/facts_spec.rb +53 -0
- data/spec/unit/face/help_spec.rb +64 -70
- data/spec/unit/face/man_spec.rb +26 -0
- data/spec/unit/face/module/list_spec.rb +0 -61
- data/spec/unit/face/module/search_spec.rb +12 -1
- data/spec/unit/face/node_spec.rb +9 -32
- data/spec/unit/face/parser_spec.rb +80 -2
- data/spec/unit/face/plugin_spec.rb +50 -4
- data/spec/unit/file_bucket/dipper_spec.rb +29 -13
- data/spec/unit/file_serving/base_spec.rb +6 -9
- data/spec/unit/file_serving/configuration/parser_spec.rb +2 -2
- data/spec/unit/file_serving/configuration_spec.rb +14 -4
- data/spec/unit/file_serving/content_spec.rb +0 -1
- data/spec/unit/file_serving/fileset_spec.rb +0 -1
- data/spec/unit/file_serving/metadata_spec.rb +4 -5
- data/spec/unit/file_serving/mount/locales_spec.rb +73 -0
- data/spec/unit/file_serving/mount/modules_spec.rb +1 -1
- data/spec/unit/file_serving/mount/tasks_spec.rb +72 -0
- data/spec/unit/file_serving/terminus_selector_spec.rb +0 -2
- data/spec/unit/file_system/path_pattern_spec.rb +1 -1
- data/spec/unit/file_system/uniquefile_spec.rb +2 -2
- data/spec/unit/file_system_spec.rb +7 -4
- data/spec/unit/forge/forge_spec.rb +2 -2
- data/spec/unit/forge/module_release_spec.rb +70 -0
- data/spec/unit/forge_spec.rb +106 -2
- data/spec/unit/functions/abs_spec.rb +70 -0
- data/spec/unit/functions/all_spec.rb +97 -0
- data/spec/unit/functions/any_spec.rb +109 -0
- data/spec/unit/functions/assert_type_spec.rb +1 -1
- data/spec/unit/functions/break_spec.rb +144 -54
- data/spec/unit/functions/call_spec.rb +59 -5
- data/spec/unit/functions/camelcase_spec.rb +34 -0
- data/spec/unit/functions/capitalize_spec.rb +34 -0
- data/spec/unit/functions/ceiling_spec.rb +65 -0
- data/spec/unit/functions/chomp_spec.rb +46 -0
- data/spec/unit/functions/chop_spec.rb +38 -0
- data/spec/unit/functions/compare_spec.rb +147 -0
- data/spec/unit/functions/contain_spec.rb +1 -0
- data/spec/unit/functions/convert_to_spec.rb +25 -0
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/downcase_spec.rb +34 -0
- data/spec/unit/functions/empty_spec.rb +77 -0
- data/spec/unit/functions/epp_spec.rb +21 -3
- data/spec/unit/functions/filter_spec.rb +4 -4
- data/spec/unit/functions/flatten_spec.rb +31 -0
- data/spec/unit/functions/floor_spec.rb +65 -0
- data/spec/unit/functions/get_spec.rb +135 -0
- data/spec/unit/functions/getvar_spec.rb +121 -0
- data/spec/unit/functions/hiera_spec.rb +19 -49
- data/spec/unit/functions/include_spec.rb +16 -1
- data/spec/unit/functions/inline_epp_spec.rb +1 -1
- data/spec/unit/functions/join_spec.rb +33 -0
- data/spec/unit/functions/keys_spec.rb +31 -0
- data/spec/unit/functions/length_spec.rb +50 -0
- data/spec/unit/functions/lookup_fixture_spec.rb +1 -1
- data/spec/unit/functions/lookup_spec.rb +198 -80
- data/spec/unit/functions/lstrip_spec.rb +30 -0
- data/spec/unit/functions/match_spec.rb +21 -4
- data/spec/unit/functions/max_spec.rb +129 -0
- data/spec/unit/functions/min_spec.rb +129 -0
- data/spec/unit/functions/module_directory_spec.rb +43 -0
- data/spec/unit/functions/new_spec.rb +81 -14
- data/spec/unit/functions/next_spec.rb +1 -1
- data/spec/unit/functions/regsubst_spec.rb +4 -5
- data/spec/unit/functions/require_spec.rb +2 -0
- data/spec/unit/functions/return_spec.rb +2 -2
- data/spec/unit/functions/round_spec.rb +41 -0
- data/spec/unit/functions/rstrip_spec.rb +30 -0
- data/spec/unit/functions/shared.rb +12 -0
- data/spec/unit/functions/size_spec.rb +50 -0
- data/spec/unit/functions/sort_spec.rb +79 -0
- data/spec/unit/functions/split_spec.rb +3 -4
- data/spec/unit/functions/step_spec.rb +1 -1
- data/spec/unit/functions/strftime_spec.rb +2 -2
- data/spec/unit/functions/strip_spec.rb +30 -0
- data/spec/unit/functions/tree_each_spec.rb +493 -0
- data/spec/unit/functions/upcase_spec.rb +34 -0
- data/spec/unit/functions/values_spec.rb +30 -0
- data/spec/unit/functions/versioncmp_spec.rb +3 -4
- data/spec/unit/functions4_spec.rb +146 -76
- data/spec/unit/gettext/config_spec.rb +144 -0
- data/spec/unit/gettext/module_loading_spec.rb +53 -0
- data/spec/unit/graph/relationship_graph_spec.rb +15 -0
- data/spec/unit/graph/simple_graph_spec.rb +43 -3
- data/spec/unit/indirector/catalog/compiler_spec.rb +3 -18
- data/spec/unit/indirector/certificate/file_spec.rb +0 -8
- data/spec/unit/indirector/direct_file_server_spec.rb +44 -46
- data/spec/unit/indirector/exec_spec.rb +29 -23
- data/spec/unit/indirector/facts/rest_spec.rb +45 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +95 -78
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -99
- data/spec/unit/indirector/file_server_spec.rb +122 -116
- data/spec/unit/indirector/indirection_spec.rb +25 -10
- data/spec/unit/indirector/json_spec.rb +0 -11
- data/spec/unit/indirector/key/file_spec.rb +0 -17
- data/spec/unit/indirector/node/exec_spec.rb +43 -22
- data/spec/unit/indirector/request_spec.rb +47 -6
- data/spec/unit/indirector/resource/ral_spec.rb +1 -0
- data/spec/unit/indirector/rest_spec.rb +45 -2
- data/spec/unit/indirector/ssl_file_spec.rb +37 -59
- data/spec/unit/indirector/terminus_spec.rb +3 -3
- data/spec/unit/indirector/yaml_spec.rb +87 -64
- data/spec/unit/indirector_spec.rb +0 -1
- data/spec/unit/info_service_spec.rb +203 -3
- data/spec/unit/interface/action_manager_spec.rb +1 -1
- data/spec/unit/interface/action_spec.rb +34 -1
- data/spec/unit/interface_spec.rb +12 -0
- data/spec/unit/module_spec.rb +89 -4
- data/spec/unit/module_tool/applications/installer_spec.rb +10 -2
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +8 -0
- data/spec/unit/module_tool/applications/unpacker_spec.rb +4 -4
- data/spec/unit/module_tool/applications/upgrader_spec.rb +7 -1
- data/spec/unit/module_tool/tar/mini_spec.rb +34 -5
- data/spec/unit/network/formats_spec.rb +31 -13
- data/spec/unit/network/http/api/indirected_routes_spec.rb +9 -5
- data/spec/unit/network/http/api/master/v3/authorization_spec.rb +5 -7
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +0 -1
- data/spec/unit/network/http/api_spec.rb +0 -26
- data/spec/unit/network/http/compression_spec.rb +6 -3
- data/spec/unit/network/http/connection_spec.rb +99 -47
- data/spec/unit/network/http/factory_spec.rb +32 -11
- data/spec/unit/network/http/handler_spec.rb +3 -2
- data/spec/unit/network/resolver_spec.rb +87 -12
- data/spec/unit/node/environment_spec.rb +38 -6
- data/spec/unit/node/facts_spec.rb +14 -1
- data/spec/unit/node_spec.rb +121 -23
- data/spec/unit/other/selinux_spec.rb +0 -71
- data/spec/unit/parser/ast/leaf_spec.rb +3 -4
- data/spec/unit/parser/compiler_spec.rb +9 -2
- data/spec/unit/parser/environment_compiler_spec.rb +55 -17
- data/spec/unit/parser/functions/create_resources_spec.rb +10 -1
- data/spec/unit/parser/functions/digest_spec.rb +1 -5
- data/spec/unit/parser/functions/fail_spec.rb +1 -5
- data/spec/unit/parser/functions/file_spec.rb +0 -4
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +24 -0
- data/spec/unit/parser/functions/generate_spec.rb +29 -31
- data/spec/unit/parser/functions/inline_template_spec.rb +7 -4
- data/spec/unit/parser/functions/realize_spec.rb +9 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +0 -4
- data/spec/unit/parser/functions/scanf_spec.rb +0 -4
- data/spec/unit/parser/functions/split_spec.rb +0 -4
- data/spec/unit/parser/functions/sprintf_spec.rb +26 -4
- data/spec/unit/parser/functions/tag_spec.rb +7 -4
- data/spec/unit/parser/functions/tagged_spec.rb +37 -0
- data/spec/unit/parser/functions/template_spec.rb +8 -4
- data/spec/unit/parser/functions/versioncmp_spec.rb +0 -4
- data/spec/unit/parser/functions_spec.rb +27 -2
- data/spec/unit/parser/resource/param_spec.rb +2 -2
- data/spec/unit/parser/resource_spec.rb +0 -1
- data/spec/unit/parser/scope_spec.rb +23 -4
- data/spec/unit/parser/type_loader_spec.rb +1 -1
- data/spec/unit/pops/adaptable_spec.rb +0 -1
- data/spec/unit/pops/evaluator/access_ops_spec.rb +5 -0
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +10 -0
- data/spec/unit/pops/evaluator/conditionals_spec.rb +1 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +78 -16
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +4 -8
- data/spec/unit/pops/factory_rspec_helper.rb +1 -1
- data/spec/unit/pops/factory_spec.rb +10 -6
- data/spec/unit/pops/issues_spec.rb +23 -8
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +2 -2
- data/spec/unit/pops/loaders/loader_spec.rb +495 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +64 -19
- data/spec/unit/pops/loaders/module_loaders_spec.rb +75 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +16 -44
- data/spec/unit/pops/lookup/interpolation_spec.rb +5 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +56 -0
- data/spec/unit/pops/model/model_spec.rb +5 -0
- data/spec/unit/pops/model/pn_transformer_spec.rb +53 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +119 -26
- data/spec/unit/pops/parser/locator_spec.rb +20 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +67 -4
- data/spec/unit/pops/parser/parse_calls_spec.rb +28 -0
- data/spec/unit/pops/parser/parse_conditionals_spec.rb +12 -0
- data/spec/unit/pops/parser/parse_containers_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_functions_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +3 -3
- data/spec/unit/pops/parser/parse_lambda_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_plan_spec.rb +48 -0
- data/spec/unit/pops/parser/parse_resource_spec.rb +35 -35
- data/spec/unit/pops/parser/parser_spec.rb +138 -0
- data/spec/unit/pops/parser/pn_parser_spec.rb +101 -0
- data/spec/unit/pops/pn_spec.rb +148 -0
- data/spec/unit/pops/puppet_stack_spec.rb +38 -9
- data/spec/unit/pops/serialization/packer_spec.rb +8 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +38 -6
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +134 -5
- data/spec/unit/pops/serialization/to_stringified_spec.rb +157 -0
- data/spec/unit/pops/types/deferred_spec.rb +87 -0
- data/spec/unit/pops/types/error_spec.rb +207 -0
- data/spec/unit/pops/types/iterable_spec.rb +10 -10
- data/spec/unit/pops/types/p_init_type_spec.rb +383 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +531 -54
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +4 -0
- data/spec/unit/pops/types/p_timespan_type_spec.rb +32 -4
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +64 -3
- data/spec/unit/pops/types/p_type_set_type_spec.rb +108 -4
- data/spec/unit/pops/types/p_uri_type_spec.rb +191 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +285 -73
- data/spec/unit/pops/types/string_converter_spec.rb +63 -17
- data/spec/unit/pops/types/task_spec.rb +485 -0
- data/spec/unit/pops/types/type_acceptor_spec.rb +2 -2
- data/spec/unit/pops/types/type_calculator_spec.rb +224 -63
- data/spec/unit/pops/types/type_factory_spec.rb +6 -6
- data/spec/unit/pops/types/type_formatter_spec.rb +37 -19
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +21 -0
- data/spec/unit/pops/types/type_parser_spec.rb +39 -2
- data/spec/unit/pops/types/types_spec.rb +88 -10
- data/spec/unit/pops/validator/validator_spec.rb +435 -7
- data/spec/unit/property/keyvalue_spec.rb +97 -6
- data/spec/unit/property_spec.rb +14 -5
- data/spec/unit/provider/aix_object_spec.rb +805 -0
- data/spec/unit/provider/exec/posix_spec.rb +8 -8
- data/spec/unit/provider/exec/shell_spec.rb +2 -1
- data/spec/unit/provider/exec/windows_spec.rb +2 -2
- data/spec/unit/provider/file/windows_spec.rb +2 -2
- data/spec/unit/provider/group/aix_spec.rb +76 -0
- data/spec/unit/provider/group/groupadd_spec.rb +77 -1
- data/spec/unit/provider/group/pw_spec.rb +4 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +80 -23
- data/spec/unit/provider/ldap_spec.rb +0 -1
- data/spec/unit/provider/nameservice_spec.rb +11 -11
- data/spec/unit/provider/package/aix_spec.rb +26 -1
- data/spec/unit/provider/package/aptitude_spec.rb +1 -1
- data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
- data/spec/unit/provider/package/dnf_spec.rb +9 -2
- data/spec/unit/provider/package/dpkg_spec.rb +2 -2
- data/spec/unit/provider/package/gem_spec.rb +17 -7
- data/spec/unit/provider/package/nim_spec.rb +2 -11
- data/spec/unit/provider/package/opkg_spec.rb +2 -2
- data/spec/unit/provider/package/pip_spec.rb +38 -41
- data/spec/unit/provider/package/pkg_spec.rb +64 -24
- data/spec/unit/provider/package/pkgng_spec.rb +1 -1
- data/spec/unit/provider/package/puppet_gem_spec.rb +2 -2
- data/spec/unit/provider/package/rpm_spec.rb +33 -14
- data/spec/unit/provider/package/urpmi_spec.rb +9 -3
- data/spec/unit/provider/package/windows/msi_package_spec.rb +1 -1
- data/spec/unit/provider/package/windows/package_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +3 -3
- data/spec/unit/provider/package/yum_spec.rb +69 -0
- data/spec/unit/provider/parsedfile_spec.rb +1 -1
- data/spec/unit/provider/service/base_spec.rb +23 -5
- data/spec/unit/provider/service/bsd_spec.rb +17 -16
- data/spec/unit/provider/service/daemontools_spec.rb +2 -3
- data/spec/unit/provider/service/debian_spec.rb +8 -4
- data/spec/unit/provider/service/freebsd_spec.rb +2 -2
- data/spec/unit/provider/service/gentoo_spec.rb +27 -26
- data/spec/unit/provider/service/init_spec.rb +17 -16
- data/spec/unit/provider/service/launchd_spec.rb +6 -3
- data/spec/unit/provider/service/openbsd_spec.rb +43 -42
- data/spec/unit/provider/service/openrc_spec.rb +35 -34
- data/spec/unit/provider/service/openwrt_spec.rb +7 -5
- data/spec/unit/provider/service/rcng_spec.rb +7 -6
- data/spec/unit/provider/service/redhat_spec.rb +11 -6
- data/spec/unit/provider/service/runit_spec.rb +2 -3
- data/spec/unit/provider/service/smf_spec.rb +7 -7
- data/spec/unit/provider/service/src_spec.rb +3 -4
- data/spec/unit/provider/service/systemd_spec.rb +73 -51
- data/spec/unit/provider/service/upstart_spec.rb +53 -14
- data/spec/unit/provider/service/windows_spec.rb +49 -86
- data/spec/unit/provider/user/aix_spec.rb +126 -121
- data/spec/unit/provider/user/hpux_spec.rb +4 -3
- data/spec/unit/provider/user/openbsd_spec.rb +2 -2
- data/spec/unit/provider/user/pw_spec.rb +14 -14
- data/spec/unit/provider/user/user_role_add_spec.rb +20 -3
- data/spec/unit/provider/user/useradd_spec.rb +194 -22
- data/spec/unit/provider/user/windows_adsi_spec.rb +5 -5
- data/spec/unit/provider_spec.rb +210 -14
- data/spec/unit/puppet_pal_2pec.rb +1020 -0
- data/spec/unit/puppet_pal_catalog_spec.rb +801 -0
- data/spec/unit/puppet_pal_spec.rb +4 -0
- data/spec/unit/puppet_spec.rb +31 -19
- data/spec/unit/resource/capability_finder_spec.rb +16 -18
- data/spec/unit/resource/catalog_spec.rb +27 -12
- data/spec/unit/resource/status_spec.rb +17 -4
- data/spec/unit/resource/type_collection_spec.rb +4 -1
- data/spec/unit/resource/type_spec.rb +24 -9
- data/spec/unit/resource_spec.rb +46 -5
- data/spec/unit/rest/client_spec.rb +135 -0
- data/spec/unit/rest/route_spec.rb +132 -0
- data/spec/unit/settings/autosign_setting_spec.rb +2 -2
- data/spec/unit/settings/certificate_revocation_setting_spec.rb +37 -0
- data/spec/unit/settings/config_file_spec.rb +10 -1
- data/spec/unit/settings/file_setting_spec.rb +17 -9
- data/spec/unit/settings/ini_file_spec.rb +314 -5
- data/spec/unit/settings/path_setting_spec.rb +1 -1
- data/spec/unit/settings_spec.rb +57 -7
- data/spec/unit/ssl/certificate_request_attributes_spec.rb +21 -8
- data/spec/unit/ssl/certificate_request_spec.rb +62 -41
- data/spec/unit/ssl/certificate_spec.rb +4 -7
- data/spec/unit/ssl/host_spec.rb +248 -579
- data/spec/unit/ssl/key_spec.rb +0 -15
- data/spec/unit/ssl/validator_spec.rb +36 -167
- data/spec/unit/task_spec.rb +247 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +64 -62
- data/spec/unit/transaction/event_manager_spec.rb +12 -0
- data/spec/unit/transaction/persistence_spec.rb +43 -1
- data/spec/unit/transaction/report_spec.rb +62 -19
- data/spec/unit/transaction/resource_harness_spec.rb +2 -2
- data/spec/unit/transaction_spec.rb +134 -16
- data/spec/unit/type/exec_spec.rb +11 -13
- data/spec/unit/type/file/checksum_spec.rb +21 -1
- data/spec/unit/type/file/content_spec.rb +13 -1
- data/spec/unit/type/file/selinux_spec.rb +0 -1
- data/spec/unit/type/file/source_spec.rb +15 -9
- data/spec/unit/type/file_spec.rb +37 -22
- data/spec/unit/type/group_spec.rb +8 -0
- data/spec/unit/type/package_spec.rb +10 -0
- data/spec/unit/type/resources_spec.rb +26 -12
- data/spec/unit/type/schedule_spec.rb +15 -1
- data/spec/unit/type/service_spec.rb +36 -10
- data/spec/unit/type/tidy_spec.rb +17 -1
- data/spec/unit/type/user_spec.rb +24 -115
- data/spec/unit/type_spec.rb +177 -98
- data/spec/unit/util/autoload_spec.rb +71 -43
- data/spec/unit/util/character_encoding_spec.rb +0 -43
- data/spec/unit/util/checksums_spec.rb +3 -3
- data/spec/unit/util/diff_spec.rb +11 -3
- data/spec/unit/util/docs_spec.rb +1 -1
- data/spec/unit/util/errors_spec.rb +1 -1
- data/spec/unit/util/execution_spec.rb +229 -95
- data/spec/unit/util/execution_stub_spec.rb +2 -2
- data/spec/unit/util/feature_spec.rb +35 -17
- data/spec/unit/util/filetype_spec.rb +8 -4
- data/spec/unit/util/http_proxy_spec.rb +57 -0
- data/spec/unit/util/inifile_spec.rb +35 -4
- data/spec/unit/util/ldap/manager_spec.rb +1 -16
- data/spec/unit/util/lockfile_spec.rb +1 -1
- data/spec/unit/util/log/destinations_spec.rb +45 -15
- data/spec/unit/util/log_spec.rb +42 -12
- data/spec/unit/util/logging_spec.rb +37 -15
- data/spec/unit/util/monkey_patches_spec.rb +6 -3
- data/spec/unit/util/plist_spec.rb +12 -6
- data/spec/unit/util/profiler/object_counts_spec.rb +2 -1
- data/spec/unit/util/rubygems_spec.rb +0 -34
- data/spec/unit/util/run_mode_spec.rb +7 -7
- data/spec/unit/util/selinux_spec.rb +3 -3
- data/spec/unit/util/storage_spec.rb +13 -1
- data/spec/unit/util/suidmanager_spec.rb +5 -5
- data/spec/unit/util/tag_set_spec.rb +8 -1
- data/spec/unit/util/tagging_spec.rb +27 -8
- data/spec/unit/util/windows/access_control_entry_spec.rb +1 -1
- data/spec/unit/util/windows/access_control_list_spec.rb +1 -1
- data/spec/unit/util/windows/adsi_spec.rb +39 -35
- data/spec/unit/util/windows/api_types_spec.rb +52 -1
- data/spec/unit/util/windows/eventlog_spec.rb +1 -1
- data/spec/unit/util/windows/security_descriptor_spec.rb +1 -1
- data/spec/unit/util/windows/service_spec.rb +424 -0
- data/spec/unit/util/windows/sid_spec.rb +88 -17
- data/spec/unit/util/windows/string_spec.rb +1 -1
- data/spec/unit/util/yaml_spec.rb +162 -28
- data/spec/unit/util_spec.rb +41 -76
- data/spec/watchr.rb +0 -1
- data/tasks/benchmark.rake +41 -0
- data/tasks/ci.rake +0 -5
- data/tasks/generate_ast_model.rake +55 -43
- data/tasks/manpages.rake +19 -3
- data/tasks/parallel.rake +12 -7
- data/tasks/parser.rake +11 -3
- metadata +3262 -3438
- data/ext/rack/config.ru +0 -44
- data/ext/rack/example-passenger-vhost.conf +0 -57
- data/lib/puppet/application/ca.rb +0 -11
- data/lib/puppet/application/certificate.rb +0 -17
- data/lib/puppet/application/certificate_request.rb +0 -7
- data/lib/puppet/application/certificate_revocation_list.rb +0 -7
- data/lib/puppet/application/master.rb +0 -313
- data/lib/puppet/bindings.rb +0 -147
- data/lib/puppet/configurer/downloader_factory.rb +0 -34
- data/lib/puppet/external/nagios/base.rb +0 -472
- data/lib/puppet/external/nagios/grammar.ry +0 -248
- data/lib/puppet/external/nagios/makefile +0 -9
- data/lib/puppet/external/nagios/parser.rb +0 -400
- data/lib/puppet/external/nagios.rb +0 -46
- data/lib/puppet/face/ca.rb +0 -266
- data/lib/puppet/face/certificate.rb +0 -165
- data/lib/puppet/face/certificate_request.rb +0 -56
- data/lib/puppet/face/certificate_revocation_list.rb +0 -56
- data/lib/puppet/feature/rack.rb +0 -19
- data/lib/puppet/graph/random_prioritizer.rb +0 -16
- data/lib/puppet/graph/title_hash_prioritizer.rb +0 -16
- data/lib/puppet/indirector/certificate/ca.rb +0 -9
- data/lib/puppet/indirector/certificate/disabled_ca.rb +0 -22
- data/lib/puppet/indirector/certificate_request/ca.rb +0 -22
- data/lib/puppet/indirector/certificate_request/disabled_ca.rb +0 -22
- data/lib/puppet/indirector/certificate_revocation_list/ca.rb +0 -8
- data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +0 -22
- data/lib/puppet/indirector/certificate_revocation_list/file.rb +0 -8
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -10
- data/lib/puppet/indirector/certificate_status/file.rb +0 -91
- data/lib/puppet/indirector/certificate_status/rest.rb +0 -11
- data/lib/puppet/indirector/certificate_status.rb +0 -4
- data/lib/puppet/indirector/key/ca.rb +0 -16
- data/lib/puppet/indirector/key/disabled_ca.rb +0 -22
- data/lib/puppet/indirector/ldap.rb +0 -80
- data/lib/puppet/indirector/node/ldap.rb +0 -259
- data/lib/puppet/indirector/node/write_only_yaml.rb +0 -37
- data/lib/puppet/module_tool/applications/builder.rb +0 -148
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +0 -18
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +0 -89
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +0 -32
- data/lib/puppet/module_tool/skeleton/templates/generator/examples/init.pp.erb +0 -12
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +0 -48
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +0 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +0 -6
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb +0 -1
- data/lib/puppet/network/http/api/ca/v1.rb +0 -11
- data/lib/puppet/network/http/api/ca.rb +0 -2
- data/lib/puppet/network/http/rack/rest.rb +0 -162
- data/lib/puppet/network/http/rack.rb +0 -33
- data/lib/puppet/network/http/webrick/rest.rb +0 -114
- data/lib/puppet/network/http/webrick.rb +0 -125
- data/lib/puppet/network/server.rb +0 -39
- data/lib/puppet/provider/aixobject.rb +0 -392
- data/lib/puppet/provider/augeas/augeas.rb +0 -567
- data/lib/puppet/provider/cisco.rb +0 -9
- data/lib/puppet/provider/computer/computer.rb +0 -20
- data/lib/puppet/provider/cron/crontab.rb +0 -297
- data/lib/puppet/provider/host/parsed.rb +0 -46
- data/lib/puppet/provider/interface/cisco.rb +0 -27
- data/lib/puppet/provider/macauthorization/macauthorization.rb +0 -298
- data/lib/puppet/provider/mailalias/aliases.rb +0 -50
- data/lib/puppet/provider/maillist/mailman.rb +0 -108
- data/lib/puppet/provider/mcx/mcxcontent.rb +0 -173
- data/lib/puppet/provider/mount/parsed.rb +0 -282
- data/lib/puppet/provider/mount.rb +0 -59
- data/lib/puppet/provider/naginator.rb +0 -63
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +0 -590
- data/lib/puppet/provider/selboolean/getsetsebool.rb +0 -47
- data/lib/puppet/provider/selmodule/semodule.rb +0 -138
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -105
- data/lib/puppet/provider/sshkey/parsed.rb +0 -50
- data/lib/puppet/provider/vlan/cisco.rb +0 -28
- data/lib/puppet/provider/yumrepo/inifile.rb +0 -304
- data/lib/puppet/provider/zfs/zfs.rb +0 -84
- data/lib/puppet/provider/zone/solaris.rb +0 -364
- data/lib/puppet/provider/zpool/zpool.rb +0 -125
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +0 -45
- data/lib/puppet/ssl/certificate_authority/interface.rb +0 -324
- data/lib/puppet/ssl/certificate_authority.rb +0 -553
- data/lib/puppet/ssl/certificate_revocation_list.rb +0 -110
- data/lib/puppet/ssl/configuration.rb +0 -61
- data/lib/puppet/ssl/inventory.rb +0 -55
- data/lib/puppet/type/augeas.rb +0 -211
- data/lib/puppet/type/computer.rb +0 -66
- data/lib/puppet/type/cron.rb +0 -475
- data/lib/puppet/type/host.rb +0 -95
- data/lib/puppet/type/interface.rb +0 -121
- data/lib/puppet/type/k5login.rb +0 -88
- data/lib/puppet/type/macauthorization.rb +0 -167
- data/lib/puppet/type/mailalias.rb +0 -46
- data/lib/puppet/type/maillist.rb +0 -62
- data/lib/puppet/type/mcx.rb +0 -98
- data/lib/puppet/type/mount.rb +0 -310
- data/lib/puppet/type/nagios_command.rb +0 -3
- data/lib/puppet/type/nagios_contact.rb +0 -3
- data/lib/puppet/type/nagios_contactgroup.rb +0 -3
- data/lib/puppet/type/nagios_host.rb +0 -3
- data/lib/puppet/type/nagios_hostdependency.rb +0 -3
- data/lib/puppet/type/nagios_hostescalation.rb +0 -3
- data/lib/puppet/type/nagios_hostextinfo.rb +0 -3
- data/lib/puppet/type/nagios_hostgroup.rb +0 -3
- data/lib/puppet/type/nagios_service.rb +0 -3
- data/lib/puppet/type/nagios_servicedependency.rb +0 -3
- data/lib/puppet/type/nagios_serviceescalation.rb +0 -3
- data/lib/puppet/type/nagios_serviceextinfo.rb +0 -3
- data/lib/puppet/type/nagios_servicegroup.rb +0 -3
- data/lib/puppet/type/nagios_timeperiod.rb +0 -3
- data/lib/puppet/type/router.rb +0 -17
- data/lib/puppet/type/scheduled_task.rb +0 -184
- data/lib/puppet/type/selboolean.rb +0 -26
- data/lib/puppet/type/selmodule.rb +0 -59
- data/lib/puppet/type/ssh_authorized_key.rb +0 -143
- data/lib/puppet/type/sshkey.rb +0 -75
- data/lib/puppet/type/vlan.rb +0 -26
- data/lib/puppet/type/yumrepo.rb +0 -409
- data/lib/puppet/type/zfs.rb +0 -150
- data/lib/puppet/type/zone.rb +0 -382
- data/lib/puppet/type/zpool.rb +0 -91
- data/lib/puppet/util/methodhelper.rb +0 -32
- data/lib/puppet/util/nagios_maker.rb +0 -85
- data/lib/puppet/util/network_device/cisco/device.rb +0 -285
- data/lib/puppet/util/network_device/cisco/facts.rb +0 -72
- data/lib/puppet/util/network_device/cisco/interface.rb +0 -94
- data/lib/puppet/util/network_device/cisco.rb +0 -4
- data/lib/puppet/util/network_device/ipcalc.rb +0 -68
- data/lib/puppet/util/network_device/transport/ssh.rb +0 -126
- data/lib/puppet/util/network_device/transport/telnet.rb +0 -47
- data/lib/puppet/util/windows/taskscheduler.rb +0 -1276
- data/lib/puppet/vendor/load_semantic.rb +0 -1
- data/lib/puppet/vendor/load_semantic_puppet.rb +0 -1
- data/lib/puppet/vendor/semantic/lib/semantic.rb +0 -5
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb +0 -60
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb +0 -117
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +0 -58
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb +0 -25
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb +0 -31
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb +0 -181
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +0 -3
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +0 -203
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +0 -758
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +0 -9
- data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +0 -21
- data/man/man8/puppet-ca.8 +0 -182
- data/man/man8/puppet-cert.8 +0 -101
- data/man/man8/puppet-certificate.8 +0 -224
- data/man/man8/puppet-certificate_request.8 +0 -161
- data/man/man8/puppet-certificate_revocation_list.8 +0 -139
- data/man/man8/puppet-inspect.8 +0 -36
- data/man/man8/puppet-master.8 +0 -85
- data/spec/fixtures/integration/provider/cron/crontab/create_normal_entry +0 -19
- data/spec/fixtures/integration/provider/cron/crontab/create_special_entry +0 -18
- data/spec/fixtures/integration/provider/cron/crontab/crontab_user1 +0 -15
- data/spec/fixtures/integration/provider/cron/crontab/crontab_user2 +0 -4
- data/spec/fixtures/integration/provider/cron/crontab/modify_entry +0 -13
- data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input1 +0 -15
- data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input2 +0 -6
- data/spec/fixtures/integration/provider/cron/crontab/purged +0 -8
- data/spec/fixtures/integration/provider/cron/crontab/remove_named_resource +0 -12
- data/spec/fixtures/integration/provider/cron/crontab/remove_unnamed_resource +0 -14
- data/spec/fixtures/integration/provider/cron/crontab/unspecialized +0 -15
- data/spec/fixtures/integration/provider/mailalias/aliases/test1 +0 -31
- data/spec/fixtures/integration/provider/sshkey/sample +0 -21
- data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +0 -13
- data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +0 -10
- data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +0 -6
- data/spec/fixtures/unit/provider/augeas/augeas/etc/test +0 -3
- data/spec/fixtures/unit/provider/augeas/augeas/test.aug +0 -13
- data/spec/fixtures/unit/provider/host/parsed/valid_hosts +0 -19
- data/spec/fixtures/unit/provider/mount/mount-output.aix.txt +0 -7
- data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +0 -152
- data/spec/fixtures/unit/provider/mount/parsed/aix.mount +0 -11
- data/spec/fixtures/unit/provider/mount/parsed/darwin.mount +0 -6
- data/spec/fixtures/unit/provider/mount/parsed/freebsd.fstab +0 -8
- data/spec/fixtures/unit/provider/mount/parsed/freebsd.mount +0 -3
- data/spec/fixtures/unit/provider/mount/parsed/hpux.mount +0 -17
- data/spec/fixtures/unit/provider/mount/parsed/linux.fstab +0 -11
- data/spec/fixtures/unit/provider/mount/parsed/linux.mount +0 -5
- data/spec/fixtures/unit/provider/mount/parsed/netbsd.fstab +0 -9
- data/spec/fixtures/unit/provider/mount/parsed/netbsd.mount +0 -8
- data/spec/fixtures/unit/provider/mount/parsed/openbsd.fstab +0 -4
- data/spec/fixtures/unit/provider/mount/parsed/openbsd.mount +0 -4
- data/spec/fixtures/unit/provider/mount/parsed/solaris.fstab +0 -11
- data/spec/fixtures/unit/provider/mount/parsed/solaris.mount +0 -6
- data/spec/fixtures/unit/provider/naginator/define_empty_param +0 -6
- data/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys +0 -7
- data/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys1 +0 -3
- data/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys2 +0 -1
- data/spec/fixtures/unit/provider/sshkey/parsed/sample +0 -21
- data/spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines +0 -8
- data/spec/fixtures/unit/provider/zfs/zfs/zfs-list.out +0 -2
- data/spec/fixtures/unit/provider/zpool/zpool/zpool-list.out +0 -2
- data/spec/integration/faces/ca_spec.rb +0 -354
- data/spec/integration/indirector/node/ldap_spec.rb +0 -14
- data/spec/integration/provider/cron/crontab_spec.rb +0 -241
- data/spec/integration/provider/mailalias/aliases_spec.rb +0 -10
- data/spec/integration/provider/mount_spec.rb +0 -161
- data/spec/integration/provider/ssh_authorized_key_spec.rb +0 -219
- data/spec/integration/provider/sshkey_spec.rb +0 -159
- data/spec/integration/provider/yumrepo_spec.rb +0 -130
- data/spec/integration/ssl/autosign_spec.rb +0 -145
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -162
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -34
- data/spec/integration/transaction_spec.rb +0 -522
- data/spec/integration/type/nagios_spec.rb +0 -71
- data/spec/integration/type/user_spec.rb +0 -64
- data/spec/unit/application/cert_spec.rb +0 -240
- data/spec/unit/application/certificate_spec.rb +0 -22
- data/spec/unit/application/master_spec.rb +0 -404
- data/spec/unit/configurer/downloader_factory_spec.rb +0 -96
- data/spec/unit/face/ca_spec.rb +0 -10
- data/spec/unit/face/certificate_request_spec.rb +0 -10
- data/spec/unit/face/certificate_revocation_list_spec.rb +0 -10
- data/spec/unit/face/certificate_spec.rb +0 -231
- data/spec/unit/face/module/build_spec.rb +0 -69
- data/spec/unit/graph/title_hash_prioritizer_spec.rb +0 -49
- data/spec/unit/indirector/certificate/ca_spec.rb +0 -23
- data/spec/unit/indirector/certificate/disabled_ca_spec.rb +0 -33
- data/spec/unit/indirector/certificate_request/ca_spec.rb +0 -57
- data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +0 -33
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -16
- data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +0 -33
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -17
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +0 -26
- data/spec/unit/indirector/certificate_status/file_spec.rb +0 -191
- data/spec/unit/indirector/certificate_status/rest_spec.rb +0 -18
- data/spec/unit/indirector/code_spec.rb +0 -31
- data/spec/unit/indirector/key/ca_spec.rb +0 -23
- data/spec/unit/indirector/key/disabled_ca_spec.rb +0 -33
- data/spec/unit/indirector/ldap_spec.rb +0 -137
- data/spec/unit/indirector/node/ldap_spec.rb +0 -462
- data/spec/unit/indirector/node/write_only_yaml_spec.rb +0 -12
- data/spec/unit/module_tool/applications/builder_spec.rb +0 -432
- data/spec/unit/network/http/api/ca/v1_spec.rb +0 -26
- data/spec/unit/network/http/rack/rest_spec.rb +0 -325
- data/spec/unit/network/http/rack_spec.rb +0 -43
- data/spec/unit/network/http/webrick/rest_spec.rb +0 -231
- data/spec/unit/network/http/webrick_spec.rb +0 -279
- data/spec/unit/network/server_spec.rb +0 -95
- data/spec/unit/provider/aixobject_spec.rb +0 -101
- data/spec/unit/provider/augeas/augeas_spec.rb +0 -1025
- data/spec/unit/provider/cisco_spec.rb +0 -15
- data/spec/unit/provider/cron/crontab_spec.rb +0 -207
- data/spec/unit/provider/cron/parsed_spec.rb +0 -358
- data/spec/unit/provider/host/parsed_spec.rb +0 -233
- data/spec/unit/provider/interface/cisco_spec.rb +0 -57
- data/spec/unit/provider/macauthorization_spec.rb +0 -155
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +0 -192
- data/spec/unit/provider/mount/parsed_spec.rb +0 -317
- data/spec/unit/provider/mount_spec.rb +0 -165
- data/spec/unit/provider/naginator_spec.rb +0 -79
- data/spec/unit/provider/network_device_spec.rb +0 -152
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +0 -2060
- data/spec/unit/provider/selboolean_spec.rb +0 -36
- data/spec/unit/provider/selmodule-example.pp +0 -0
- data/spec/unit/provider/selmodule_spec.rb +0 -73
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +0 -277
- data/spec/unit/provider/sshkey/parsed_spec.rb +0 -95
- data/spec/unit/provider/vlan/cisco_spec.rb +0 -55
- data/spec/unit/provider/yumrepo/inifile_spec.rb +0 -326
- data/spec/unit/provider/zfs/zfs_spec.rb +0 -106
- data/spec/unit/provider/zone/solaris_spec.rb +0 -247
- data/spec/unit/provider/zpool/zpool_spec.rb +0 -251
- data/spec/unit/ssl/certificate_authority/autosign_command_spec.rb +0 -30
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +0 -560
- data/spec/unit/ssl/certificate_authority_spec.rb +0 -1184
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +0 -196
- data/spec/unit/ssl/configuration_spec.rb +0 -141
- data/spec/unit/ssl/inventory_spec.rb +0 -151
- data/spec/unit/type/augeas_spec.rb +0 -119
- data/spec/unit/type/computer_spec.rb +0 -80
- data/spec/unit/type/cron_spec.rb +0 -543
- data/spec/unit/type/host_spec.rb +0 -681
- data/spec/unit/type/interface_spec.rb +0 -129
- data/spec/unit/type/k5login_spec.rb +0 -115
- data/spec/unit/type/macauthorization_spec.rb +0 -113
- data/spec/unit/type/mailalias_spec.rb +0 -49
- data/spec/unit/type/maillist_spec.rb +0 -41
- data/spec/unit/type/mcx_spec.rb +0 -79
- data/spec/unit/type/mount_spec.rb +0 -634
- data/spec/unit/type/nagios_spec.rb +0 -293
- data/spec/unit/type/scheduled_task_spec.rb +0 -103
- data/spec/unit/type/selboolean_spec.rb +0 -44
- data/spec/unit/type/selmodule_spec.rb +0 -17
- data/spec/unit/type/ssh_authorized_key_spec.rb +0 -258
- data/spec/unit/type/sshkey_spec.rb +0 -77
- data/spec/unit/type/vlan_spec.rb +0 -44
- data/spec/unit/type/yumrepo_spec.rb +0 -398
- data/spec/unit/type/zfs_spec.rb +0 -46
- data/spec/unit/type/zone_spec.rb +0 -172
- data/spec/unit/type/zpool_spec.rb +0 -109
- data/spec/unit/util/nagios_maker_spec.rb +0 -122
- data/spec/unit/util/network_device/cisco/device_spec.rb +0 -482
- data/spec/unit/util/network_device/cisco/facts_spec.rb +0 -64
- data/spec/unit/util/network_device/cisco/interface_spec.rb +0 -88
- data/spec/unit/util/network_device/ipcalc_spec.rb +0 -62
- data/spec/unit/util/network_device/transport/ssh_spec.rb +0 -218
- data/spec/unit/util/network_device/transport/telnet_spec.rb +0 -86
|
@@ -57,16 +57,16 @@ class TypedModelObject < Object
|
|
|
57
57
|
def self.register_ptypes(loader, ir)
|
|
58
58
|
types = [
|
|
59
59
|
Annotation.register_ptype(loader, ir),
|
|
60
|
-
RubyMethod.register_ptype(loader, ir)
|
|
60
|
+
RubyMethod.register_ptype(loader, ir),
|
|
61
61
|
]
|
|
62
62
|
Types.constants.each do |c|
|
|
63
|
+
next if c == :PType || c == :PHostClassType
|
|
63
64
|
cls = Types.const_get(c)
|
|
64
65
|
next unless cls.is_a?(Class) && cls < self
|
|
65
66
|
type = cls.register_ptype(loader, ir)
|
|
66
67
|
types << type unless type.nil?
|
|
67
68
|
end
|
|
68
|
-
|
|
69
|
-
types.each { |type| type.resolve(tp, loader) }
|
|
69
|
+
types.each { |type| type.resolve(loader) }
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -129,8 +129,14 @@ class PAnyType < TypedModelObject
|
|
|
129
129
|
assignable?(o.resolved_type, guard)
|
|
130
130
|
end
|
|
131
131
|
when PVariantType
|
|
132
|
-
# Assignable if all contained types are assignable
|
|
133
|
-
|
|
132
|
+
# Assignable if all contained types are assignable, or if this is exactly Any
|
|
133
|
+
return true if self.class == PAnyType
|
|
134
|
+
# An empty variant may be assignable to NotUndef[T] if T is assignable to empty variant
|
|
135
|
+
return _assignable?(o, guard) if is_a?(PNotUndefType) && o.types.empty?
|
|
136
|
+
!o.types.empty? && o.types.all? { |vt| assignable?(vt, guard) }
|
|
137
|
+
when POptionalType
|
|
138
|
+
# Assignable if undef and contained type is assignable
|
|
139
|
+
assignable?(PUndefType::DEFAULT) && (o.type.nil? || assignable?(o.type))
|
|
134
140
|
when PNotUndefType
|
|
135
141
|
if !(o.type.nil? || o.type.assignable?(PUndefType::DEFAULT))
|
|
136
142
|
assignable?(o.type, guard)
|
|
@@ -187,6 +193,12 @@ class PAnyType < TypedModelObject
|
|
|
187
193
|
self
|
|
188
194
|
end
|
|
189
195
|
|
|
196
|
+
# Returns the loader that loaded this type.
|
|
197
|
+
# @return [Loaders::Loader] the loader
|
|
198
|
+
def loader
|
|
199
|
+
Loaders.static_loader
|
|
200
|
+
end
|
|
201
|
+
|
|
190
202
|
# Normalizes the type. This does not change the characteristics of the type but it will remove duplicates
|
|
191
203
|
# and constructs like NotUndef[T] where T is not assignable from Undef and change Variant[*T] where all
|
|
192
204
|
# T are enums into an Enum.
|
|
@@ -202,11 +214,10 @@ class PAnyType < TypedModelObject
|
|
|
202
214
|
# resolve internal type expressions using a loader. Presently, this method is a no-op for all types
|
|
203
215
|
# except the {{PTypeAliasType}}.
|
|
204
216
|
#
|
|
205
|
-
# @param type_parser [TypeParser] type parser
|
|
206
217
|
# @param loader [Loader::Loader] loader to use
|
|
207
218
|
# @return [PTypeAliasType] the receiver of the call, i.e. `self`
|
|
208
219
|
# @api private
|
|
209
|
-
def resolve(
|
|
220
|
+
def resolve(loader)
|
|
210
221
|
self
|
|
211
222
|
end
|
|
212
223
|
|
|
@@ -283,11 +294,10 @@ class PAnyType < TypedModelObject
|
|
|
283
294
|
# an instance of PVariantType will return 'Variant'
|
|
284
295
|
# @return [String] the simple name of this type
|
|
285
296
|
def self.simple_name
|
|
286
|
-
|
|
297
|
+
@simple_name ||= (
|
|
287
298
|
n = name
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
@simple_name
|
|
299
|
+
n[n.rindex(DOUBLE_COLON)+3..n.size-5].freeze
|
|
300
|
+
)
|
|
291
301
|
end
|
|
292
302
|
|
|
293
303
|
def to_alias_expanded_s
|
|
@@ -309,8 +319,15 @@ class PAnyType < TypedModelObject
|
|
|
309
319
|
Loaders.find_loader(nil).load(:function, 'new').call({}, self, *args)
|
|
310
320
|
end
|
|
311
321
|
|
|
312
|
-
|
|
313
|
-
|
|
322
|
+
# Create an instance of this type.
|
|
323
|
+
# The default implementation will just dispatch the call to the class method with the
|
|
324
|
+
# same name and pass `self` as the first argument.
|
|
325
|
+
#
|
|
326
|
+
# @return [Function] the created function
|
|
327
|
+
# @raises ArgumentError
|
|
328
|
+
#
|
|
329
|
+
def new_function
|
|
330
|
+
self.class.new_function(self)
|
|
314
331
|
end
|
|
315
332
|
|
|
316
333
|
# This default implementation of of a new_function raises an Argument Error.
|
|
@@ -318,16 +335,18 @@ class PAnyType < TypedModelObject
|
|
|
318
335
|
# a Puppet Function class by using Puppet:Loaders.create_loaded_function(:new, loader)
|
|
319
336
|
# and return that result.
|
|
320
337
|
#
|
|
338
|
+
# @param type [PAnyType] the type to create a new function for
|
|
339
|
+
# @return [Function] the created function
|
|
321
340
|
# @raises ArgumentError
|
|
322
341
|
#
|
|
323
|
-
def self.new_function(
|
|
324
|
-
raise ArgumentError.new("Creation of new instance of type '#{
|
|
342
|
+
def self.new_function(type)
|
|
343
|
+
raise ArgumentError.new("Creation of new instance of type '#{type.to_s}' is not supported")
|
|
325
344
|
end
|
|
326
345
|
|
|
327
346
|
# Answers the question if instances of this type can represent themselves as a string that
|
|
328
347
|
# can then be passed to the create method
|
|
329
348
|
#
|
|
330
|
-
# @return [Boolean]
|
|
349
|
+
# @return [Boolean] whether or not the instance has a canonical string representation
|
|
331
350
|
def roundtrip_with_string?
|
|
332
351
|
false
|
|
333
352
|
end
|
|
@@ -434,9 +453,9 @@ class PTypeWithContainedType < PAnyType
|
|
|
434
453
|
self.class == o.class && @type == o.type
|
|
435
454
|
end
|
|
436
455
|
|
|
437
|
-
def resolve(
|
|
456
|
+
def resolve(loader)
|
|
438
457
|
rtype = @type
|
|
439
|
-
rtype = rtype.resolve(
|
|
458
|
+
rtype = rtype.resolve(loader) unless rtype.nil?
|
|
440
459
|
rtype.equal?(@type) ? self : self.class.new(rtype)
|
|
441
460
|
end
|
|
442
461
|
end
|
|
@@ -444,17 +463,31 @@ end
|
|
|
444
463
|
# The type of types.
|
|
445
464
|
# @api public
|
|
446
465
|
#
|
|
447
|
-
class
|
|
466
|
+
class PTypeType < PTypeWithContainedType
|
|
448
467
|
|
|
449
468
|
def self.register_ptype(loader, ir)
|
|
450
469
|
create_ptype(loader, ir, 'AnyType',
|
|
451
470
|
'type' => {
|
|
452
|
-
KEY_TYPE => POptionalType.new(
|
|
471
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
453
472
|
KEY_VALUE => nil
|
|
454
473
|
}
|
|
455
474
|
)
|
|
456
475
|
end
|
|
457
476
|
|
|
477
|
+
# Returns a new function that produces a Type instance
|
|
478
|
+
#
|
|
479
|
+
def self.new_function(type)
|
|
480
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_type, type.loader) do
|
|
481
|
+
dispatch :from_string do
|
|
482
|
+
param 'String[1]', :type_string
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
def from_string(type_string)
|
|
486
|
+
TypeParser.singleton.parse(type_string, loader)
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
|
|
458
491
|
def instance?(o, guard = nil)
|
|
459
492
|
if o.is_a?(PAnyType)
|
|
460
493
|
type.nil? || type.assignable?(o, guard)
|
|
@@ -496,29 +529,27 @@ class PType < PTypeWithContainedType
|
|
|
496
529
|
self.class == o.class && @type == o.type
|
|
497
530
|
end
|
|
498
531
|
|
|
499
|
-
|
|
500
|
-
# since this the class is inconsistently named PType and not PTypeType
|
|
501
|
-
'Type'
|
|
502
|
-
end
|
|
503
|
-
|
|
504
|
-
DEFAULT = PType.new(nil)
|
|
532
|
+
DEFAULT = PTypeType.new(nil)
|
|
505
533
|
|
|
506
534
|
protected
|
|
507
535
|
|
|
508
536
|
# @api private
|
|
509
537
|
def _assignable?(o, guard)
|
|
510
|
-
return false unless o.is_a?(
|
|
538
|
+
return false unless o.is_a?(PTypeType)
|
|
511
539
|
return true if @type.nil? # wide enough to handle all types
|
|
512
540
|
return false if o.type.nil? # wider than t
|
|
513
541
|
@type.assignable?(o.type, guard)
|
|
514
542
|
end
|
|
515
543
|
end
|
|
516
544
|
|
|
545
|
+
# For backward compatibility
|
|
546
|
+
PType = PTypeType
|
|
547
|
+
|
|
517
548
|
class PNotUndefType < PTypeWithContainedType
|
|
518
549
|
def self.register_ptype(loader, ir)
|
|
519
550
|
create_ptype(loader, ir, 'AnyType',
|
|
520
551
|
'type' => {
|
|
521
|
-
KEY_TYPE => POptionalType.new(
|
|
552
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
522
553
|
KEY_VALUE => nil
|
|
523
554
|
}
|
|
524
555
|
)
|
|
@@ -545,16 +576,16 @@ class PNotUndefType < PTypeWithContainedType
|
|
|
545
576
|
n.type
|
|
546
577
|
else
|
|
547
578
|
n
|
|
548
|
-
|
|
579
|
+
end
|
|
549
580
|
end
|
|
550
581
|
end
|
|
551
582
|
|
|
552
|
-
def new_function
|
|
583
|
+
def new_function
|
|
553
584
|
# If only NotUndef, then use Unit's null converter
|
|
554
585
|
if type.nil?
|
|
555
|
-
PUnitType.new_function(self
|
|
586
|
+
PUnitType.new_function(self)
|
|
556
587
|
else
|
|
557
|
-
type.new_function
|
|
588
|
+
type.new_function
|
|
558
589
|
end
|
|
559
590
|
end
|
|
560
591
|
|
|
@@ -607,8 +638,8 @@ class PUnitType < PAnyType
|
|
|
607
638
|
end
|
|
608
639
|
|
|
609
640
|
# A "null" implementation - that simply returns the given argument
|
|
610
|
-
def self.new_function(
|
|
611
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_unit, loader) do
|
|
641
|
+
def self.new_function(type)
|
|
642
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_unit, type.loader) do
|
|
612
643
|
dispatch :from_args do
|
|
613
644
|
param 'Any', :from
|
|
614
645
|
end
|
|
@@ -621,7 +652,12 @@ class PUnitType < PAnyType
|
|
|
621
652
|
|
|
622
653
|
DEFAULT = PUnitType.new
|
|
623
654
|
|
|
655
|
+
def assignable?(o, guard=nil)
|
|
656
|
+
true
|
|
657
|
+
end
|
|
658
|
+
|
|
624
659
|
protected
|
|
660
|
+
|
|
625
661
|
# @api private
|
|
626
662
|
def _assignable?(o, guard)
|
|
627
663
|
true
|
|
@@ -636,7 +672,9 @@ class PDefaultType < PAnyType
|
|
|
636
672
|
end
|
|
637
673
|
|
|
638
674
|
def instance?(o, guard = nil)
|
|
639
|
-
|
|
675
|
+
# Ensure that Symbol.== is called here instead of something unknown
|
|
676
|
+
# that is implemented on o
|
|
677
|
+
:default == o
|
|
640
678
|
end
|
|
641
679
|
|
|
642
680
|
DEFAULT = PDefaultType.new
|
|
@@ -676,7 +714,16 @@ class PScalarType < PAnyType
|
|
|
676
714
|
|
|
677
715
|
# @api private
|
|
678
716
|
def _assignable?(o, guard)
|
|
679
|
-
o.is_a?(PScalarType)
|
|
717
|
+
o.is_a?(PScalarType) ||
|
|
718
|
+
PStringType::DEFAULT.assignable?(o, guard) ||
|
|
719
|
+
PIntegerType::DEFAULT.assignable?(o, guard) ||
|
|
720
|
+
PFloatType::DEFAULT.assignable?(o, guard) ||
|
|
721
|
+
PBooleanType::DEFAULT.assignable?(o, guard) ||
|
|
722
|
+
PRegexpType::DEFAULT.assignable?(o, guard) ||
|
|
723
|
+
PSemVerType::DEFAULT.assignable?(o, guard) ||
|
|
724
|
+
PSemVerRangeType::DEFAULT.assignable?(o, guard) ||
|
|
725
|
+
PTimespanType::DEFAULT.assignable?(o, guard) ||
|
|
726
|
+
PTimestampType::DEFAULT.assignable?(o, guard)
|
|
680
727
|
end
|
|
681
728
|
end
|
|
682
729
|
|
|
@@ -698,7 +745,11 @@ class PScalarDataType < PScalarType
|
|
|
698
745
|
|
|
699
746
|
# @api private
|
|
700
747
|
def _assignable?(o, guard)
|
|
701
|
-
o.is_a?(PScalarDataType)
|
|
748
|
+
o.is_a?(PScalarDataType) ||
|
|
749
|
+
PStringType::DEFAULT.assignable?(o, guard) ||
|
|
750
|
+
PIntegerType::DEFAULT.assignable?(o, guard) ||
|
|
751
|
+
PFloatType::DEFAULT.assignable?(o, guard) ||
|
|
752
|
+
PBooleanType::DEFAULT.assignable?(o, guard)
|
|
702
753
|
end
|
|
703
754
|
end
|
|
704
755
|
|
|
@@ -707,13 +758,20 @@ end
|
|
|
707
758
|
#
|
|
708
759
|
class PEnumType < PScalarDataType
|
|
709
760
|
def self.register_ptype(loader, ir)
|
|
710
|
-
create_ptype(loader, ir, 'ScalarDataType',
|
|
761
|
+
create_ptype(loader, ir, 'ScalarDataType',
|
|
762
|
+
'values' => PArrayType.new(PStringType::NON_EMPTY),
|
|
763
|
+
'case_insensitive' => { 'type' => PBooleanType::DEFAULT, 'value' => false })
|
|
711
764
|
end
|
|
712
765
|
|
|
713
|
-
attr_reader :values
|
|
766
|
+
attr_reader :values, :case_insensitive
|
|
714
767
|
|
|
715
|
-
def initialize(values)
|
|
768
|
+
def initialize(values, case_insensitive = false)
|
|
716
769
|
@values = values.uniq.sort.freeze
|
|
770
|
+
@case_insensitive = case_insensitive
|
|
771
|
+
end
|
|
772
|
+
|
|
773
|
+
def case_insensitive?
|
|
774
|
+
@case_insensitive
|
|
717
775
|
end
|
|
718
776
|
|
|
719
777
|
# Returns Enumerator if no block is given, otherwise, calls the given
|
|
@@ -743,15 +801,19 @@ class PEnumType < PScalarDataType
|
|
|
743
801
|
end
|
|
744
802
|
|
|
745
803
|
def hash
|
|
746
|
-
@values.hash
|
|
804
|
+
@values.hash ^ @case_insensitive.hash
|
|
747
805
|
end
|
|
748
806
|
|
|
749
807
|
def eql?(o)
|
|
750
|
-
self.class == o.class && @values == o.values
|
|
808
|
+
self.class == o.class && @values == o.values && @case_insensitive == o.case_insensitive?
|
|
751
809
|
end
|
|
752
810
|
|
|
753
811
|
def instance?(o, guard = nil)
|
|
754
|
-
o.is_a?(String)
|
|
812
|
+
if o.is_a?(String)
|
|
813
|
+
@case_insensitive ? @values.any? { |p| p.casecmp(o) == 0 } : @values.any? { |p| p == o }
|
|
814
|
+
else
|
|
815
|
+
false
|
|
816
|
+
end
|
|
755
817
|
end
|
|
756
818
|
|
|
757
819
|
DEFAULT = PEnumType.new(EMPTY_ARRAY)
|
|
@@ -770,13 +832,26 @@ class PEnumType < PScalarDataType
|
|
|
770
832
|
# if the contained string is found in the set of enums
|
|
771
833
|
instance?(o.value, guard)
|
|
772
834
|
when PEnumType
|
|
773
|
-
!o.values.empty? && o.values.all? { |s| instance?(s, guard) }
|
|
835
|
+
!o.values.empty? && (case_insensitive? || !o.case_insensitive?) && o.values.all? { |s| instance?(s, guard) }
|
|
774
836
|
else
|
|
775
837
|
false
|
|
776
838
|
end
|
|
777
839
|
end
|
|
778
840
|
end
|
|
779
841
|
|
|
842
|
+
INTEGER_HEX = '(?:0[xX][0-9A-Fa-f]+)'
|
|
843
|
+
INTEGER_OCT = '(?:0[0-7]+)'
|
|
844
|
+
INTEGER_BIN = '(?:0[bB][01]+)'
|
|
845
|
+
INTEGER_DEC = '(?:0|[1-9]\d*)'
|
|
846
|
+
SIGN_PREFIX = '[+-]?\s*'
|
|
847
|
+
|
|
848
|
+
OPTIONAL_FRACTION = '(?:\.\d+)?'
|
|
849
|
+
OPTIONAL_EXPONENT = '(?:[eE]-?\d+)?'
|
|
850
|
+
FLOAT_DEC = '(?:' + INTEGER_DEC + OPTIONAL_FRACTION + OPTIONAL_EXPONENT + ')'
|
|
851
|
+
|
|
852
|
+
INTEGER_PATTERN = '\A' + SIGN_PREFIX + '(?:' + INTEGER_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
|
|
853
|
+
FLOAT_PATTERN = '\A' + SIGN_PREFIX + '(?:' + FLOAT_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
|
|
854
|
+
|
|
780
855
|
# @api public
|
|
781
856
|
#
|
|
782
857
|
class PNumericType < PScalarDataType
|
|
@@ -787,10 +862,10 @@ class PNumericType < PScalarDataType
|
|
|
787
862
|
)
|
|
788
863
|
end
|
|
789
864
|
|
|
790
|
-
def self.new_function(
|
|
791
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_numeric, loader) do
|
|
865
|
+
def self.new_function(type)
|
|
866
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_numeric, type.loader) do
|
|
792
867
|
local_types do
|
|
793
|
-
type
|
|
868
|
+
type "Convertible = Variant[Integer, Float, Boolean, Pattern[/#{FLOAT_PATTERN}/], Timespan, Timestamp]"
|
|
794
869
|
type 'NamedArgs = Struct[{from => Convertible, Optional[abs] => Boolean}]'
|
|
795
870
|
end
|
|
796
871
|
|
|
@@ -803,6 +878,11 @@ class PNumericType < PScalarDataType
|
|
|
803
878
|
param 'NamedArgs', :hash_args
|
|
804
879
|
end
|
|
805
880
|
|
|
881
|
+
argument_mismatch :on_error do
|
|
882
|
+
param 'Any', :from
|
|
883
|
+
optional_param 'Boolean', :abs
|
|
884
|
+
end
|
|
885
|
+
|
|
806
886
|
def from_args(from, abs = false)
|
|
807
887
|
result = from_convertible(from)
|
|
808
888
|
abs ? result.abs : result
|
|
@@ -814,8 +894,6 @@ class PNumericType < PScalarDataType
|
|
|
814
894
|
|
|
815
895
|
def from_convertible(from)
|
|
816
896
|
case from
|
|
817
|
-
when NilClass
|
|
818
|
-
throw :undefined_value
|
|
819
897
|
when Float
|
|
820
898
|
from
|
|
821
899
|
when Integer
|
|
@@ -826,21 +904,31 @@ class PNumericType < PScalarDataType
|
|
|
826
904
|
1
|
|
827
905
|
when FalseClass
|
|
828
906
|
0
|
|
829
|
-
|
|
907
|
+
else
|
|
830
908
|
begin
|
|
831
|
-
if from[0] == '0'
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
909
|
+
if from[0] == '0'
|
|
910
|
+
second_char = (from[1] || '').downcase
|
|
911
|
+
if second_char == 'b' || second_char == 'x'
|
|
912
|
+
# use built in conversion
|
|
913
|
+
return Integer(from)
|
|
914
|
+
end
|
|
835
915
|
end
|
|
916
|
+
|
|
917
|
+
Puppet::Pops::Utils.to_n(from)
|
|
836
918
|
rescue TypeError => e
|
|
837
919
|
raise TypeConversionError.new(e.message)
|
|
838
920
|
rescue ArgumentError => e
|
|
839
921
|
raise TypeConversionError.new(e.message)
|
|
840
922
|
end
|
|
923
|
+
end
|
|
924
|
+
end
|
|
925
|
+
|
|
926
|
+
def on_error(from, abs = false)
|
|
927
|
+
if from.is_a?(String)
|
|
928
|
+
_("The string '%{str}' cannot be converted to Numeric") % { str: from }
|
|
841
929
|
else
|
|
842
|
-
t =
|
|
843
|
-
|
|
930
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
|
931
|
+
_("Value of type %{type} cannot be converted to Numeric") % { type: t }
|
|
844
932
|
end
|
|
845
933
|
end
|
|
846
934
|
end
|
|
@@ -896,7 +984,7 @@ class PNumericType < PScalarDataType
|
|
|
896
984
|
end
|
|
897
985
|
|
|
898
986
|
def instance?(o, guard = nil)
|
|
899
|
-
o.is_a?(
|
|
987
|
+
(o.is_a?(Float) || o.is_a?(Integer)) && o >= @from && o <= @to
|
|
900
988
|
end
|
|
901
989
|
|
|
902
990
|
def unbounded?
|
|
@@ -997,11 +1085,11 @@ class PIntegerType < PNumericType
|
|
|
997
1085
|
@from >= 0 ? self : PIntegerType.new(0, @to < 0 ? 0 : @to)
|
|
998
1086
|
end
|
|
999
1087
|
|
|
1000
|
-
def new_function
|
|
1088
|
+
def new_function
|
|
1001
1089
|
@@new_function ||= Puppet::Functions.create_loaded_function(:new, loader) do
|
|
1002
1090
|
local_types do
|
|
1003
1091
|
type 'Radix = Variant[Default, Integer[2,2], Integer[8,8], Integer[10,10], Integer[16,16]]'
|
|
1004
|
-
type
|
|
1092
|
+
type "Convertible = Variant[Numeric, Boolean, Pattern[/#{INTEGER_PATTERN}/], Timespan, Timestamp]"
|
|
1005
1093
|
type 'NamedArgs = Struct[{from => Convertible, Optional[radix] => Radix, Optional[abs] => Boolean}]'
|
|
1006
1094
|
end
|
|
1007
1095
|
|
|
@@ -1015,6 +1103,16 @@ class PIntegerType < PNumericType
|
|
|
1015
1103
|
param 'NamedArgs', :hash_args
|
|
1016
1104
|
end
|
|
1017
1105
|
|
|
1106
|
+
argument_mismatch :on_error_hash do
|
|
1107
|
+
param 'Hash', :hash_args
|
|
1108
|
+
end
|
|
1109
|
+
|
|
1110
|
+
argument_mismatch :on_error do
|
|
1111
|
+
param 'Any', :from
|
|
1112
|
+
optional_param 'Integer', :radix
|
|
1113
|
+
optional_param 'Boolean', :abs
|
|
1114
|
+
end
|
|
1115
|
+
|
|
1018
1116
|
def from_args(from, radix = :default, abs = false)
|
|
1019
1117
|
result = from_convertible(from, radix)
|
|
1020
1118
|
abs ? result.abs : result
|
|
@@ -1026,8 +1124,6 @@ class PIntegerType < PNumericType
|
|
|
1026
1124
|
|
|
1027
1125
|
def from_convertible(from, radix)
|
|
1028
1126
|
case from
|
|
1029
|
-
when NilClass
|
|
1030
|
-
throw :undefined_value
|
|
1031
1127
|
when Float, Time::TimeData
|
|
1032
1128
|
from.to_i
|
|
1033
1129
|
when Integer
|
|
@@ -1036,9 +1132,9 @@ class PIntegerType < PNumericType
|
|
|
1036
1132
|
1
|
|
1037
1133
|
when FalseClass
|
|
1038
1134
|
0
|
|
1039
|
-
|
|
1135
|
+
else
|
|
1040
1136
|
begin
|
|
1041
|
-
radix == :default ? Integer(from) : Integer(from,
|
|
1137
|
+
radix == :default ? Integer(from) : Integer(from, radix)
|
|
1042
1138
|
rescue TypeError => e
|
|
1043
1139
|
raise TypeConversionError.new(e.message)
|
|
1044
1140
|
rescue ArgumentError => e
|
|
@@ -1054,17 +1150,34 @@ class PIntegerType < PNumericType
|
|
|
1054
1150
|
end
|
|
1055
1151
|
raise TypeConversionError.new(e.message)
|
|
1056
1152
|
end
|
|
1153
|
+
end
|
|
1154
|
+
end
|
|
1155
|
+
|
|
1156
|
+
def on_error_hash(args_hash)
|
|
1157
|
+
if args_hash.include?('from')
|
|
1158
|
+
from = args_hash['from']
|
|
1159
|
+
return on_error(from) unless loader.load(:type, 'convertible').instance?(from)
|
|
1160
|
+
end
|
|
1161
|
+
radix = args_hash['radix']
|
|
1162
|
+
assert_radix(radix) unless radix.nil? || radix == :default
|
|
1163
|
+
TypeAsserter.assert_instance_of('Integer.new', loader.load(:type, 'namedargs'), args_hash)
|
|
1164
|
+
end
|
|
1165
|
+
|
|
1166
|
+
def on_error(from, radix = :default, abs = nil)
|
|
1167
|
+
assert_radix(radix) unless radix == :default
|
|
1168
|
+
if from.is_a?(String)
|
|
1169
|
+
_("The string '%{str}' cannot be converted to Integer") % { str: from }
|
|
1057
1170
|
else
|
|
1058
|
-
t =
|
|
1059
|
-
|
|
1171
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
|
1172
|
+
_("Value of type %{type} cannot be converted to Integer") % { type: t }
|
|
1060
1173
|
end
|
|
1061
1174
|
end
|
|
1062
1175
|
|
|
1063
1176
|
def assert_radix(radix)
|
|
1064
1177
|
case radix
|
|
1065
|
-
when 2, 8, 10, 16
|
|
1178
|
+
when 2, 8, 10, 16
|
|
1066
1179
|
else
|
|
1067
|
-
raise ArgumentError.new("Illegal radix:
|
|
1180
|
+
raise ArgumentError.new(_("Illegal radix: %{radix}, expected 2, 8, 10, 16, or default") % { radix: radix })
|
|
1068
1181
|
end
|
|
1069
1182
|
radix
|
|
1070
1183
|
end
|
|
@@ -1108,10 +1221,10 @@ class PFloatType < PNumericType
|
|
|
1108
1221
|
|
|
1109
1222
|
# Returns a new function that produces a Float value
|
|
1110
1223
|
#
|
|
1111
|
-
def self.new_function(
|
|
1112
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_float, loader) do
|
|
1224
|
+
def self.new_function(type)
|
|
1225
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_float, type.loader) do
|
|
1113
1226
|
local_types do
|
|
1114
|
-
type
|
|
1227
|
+
type "Convertible = Variant[Numeric, Boolean, Pattern[/#{FLOAT_PATTERN}/], Timespan, Timestamp]"
|
|
1115
1228
|
type 'NamedArgs = Struct[{from => Convertible, Optional[abs] => Boolean}]'
|
|
1116
1229
|
end
|
|
1117
1230
|
|
|
@@ -1124,6 +1237,11 @@ class PFloatType < PNumericType
|
|
|
1124
1237
|
param 'NamedArgs', :hash_args
|
|
1125
1238
|
end
|
|
1126
1239
|
|
|
1240
|
+
argument_mismatch :on_error do
|
|
1241
|
+
param 'Any', :from
|
|
1242
|
+
optional_param 'Boolean', :abs
|
|
1243
|
+
end
|
|
1244
|
+
|
|
1127
1245
|
def from_args(from, abs = false)
|
|
1128
1246
|
result = from_convertible(from)
|
|
1129
1247
|
abs ? result.abs : result
|
|
@@ -1135,8 +1253,6 @@ class PFloatType < PNumericType
|
|
|
1135
1253
|
|
|
1136
1254
|
def from_convertible(from)
|
|
1137
1255
|
case from
|
|
1138
|
-
when NilClass
|
|
1139
|
-
throw :undefined_value
|
|
1140
1256
|
when Float
|
|
1141
1257
|
from
|
|
1142
1258
|
when Integer
|
|
@@ -1147,7 +1263,7 @@ class PFloatType < PNumericType
|
|
|
1147
1263
|
1.0
|
|
1148
1264
|
when FalseClass
|
|
1149
1265
|
0.0
|
|
1150
|
-
|
|
1266
|
+
else
|
|
1151
1267
|
begin
|
|
1152
1268
|
# support a binary as float
|
|
1153
1269
|
if from[0] == '0' && from[1].downcase == 'b'
|
|
@@ -1169,9 +1285,15 @@ class PFloatType < PNumericType
|
|
|
1169
1285
|
end
|
|
1170
1286
|
raise TypeConversionError.new(e.message)
|
|
1171
1287
|
end
|
|
1288
|
+
end
|
|
1289
|
+
end
|
|
1290
|
+
|
|
1291
|
+
def on_error(from, _ = false)
|
|
1292
|
+
if from.is_a?(String)
|
|
1293
|
+
_("The string '%{str}' cannot be converted to Float") % { str: from }
|
|
1172
1294
|
else
|
|
1173
|
-
t =
|
|
1174
|
-
|
|
1295
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
|
1296
|
+
_("Value of type %{type} cannot be converted to Float") % { type: t }
|
|
1175
1297
|
end
|
|
1176
1298
|
end
|
|
1177
1299
|
end
|
|
@@ -1186,7 +1308,7 @@ class PCollectionType < PAnyType
|
|
|
1186
1308
|
def self.register_ptype(loader, ir)
|
|
1187
1309
|
create_ptype(loader, ir, 'AnyType',
|
|
1188
1310
|
'size_type' => {
|
|
1189
|
-
KEY_TYPE => POptionalType.new(
|
|
1311
|
+
KEY_TYPE => POptionalType.new(PTypeType.new(PIntegerType::DEFAULT)),
|
|
1190
1312
|
KEY_VALUE => nil
|
|
1191
1313
|
}
|
|
1192
1314
|
)
|
|
@@ -1195,7 +1317,7 @@ class PCollectionType < PAnyType
|
|
|
1195
1317
|
attr_reader :size_type
|
|
1196
1318
|
|
|
1197
1319
|
def initialize(size_type)
|
|
1198
|
-
@size_type = size_type
|
|
1320
|
+
@size_type = size_type.nil? ? nil : size_type.to_size
|
|
1199
1321
|
end
|
|
1200
1322
|
|
|
1201
1323
|
def accept(visitor, guard)
|
|
@@ -1278,7 +1400,7 @@ class PIterableType < PTypeWithContainedType
|
|
|
1278
1400
|
def self.register_ptype(loader, ir)
|
|
1279
1401
|
create_ptype(loader, ir, 'AnyType',
|
|
1280
1402
|
'type' => {
|
|
1281
|
-
KEY_TYPE => POptionalType.new(
|
|
1403
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
1282
1404
|
KEY_VALUE => nil
|
|
1283
1405
|
}
|
|
1284
1406
|
)
|
|
@@ -1298,6 +1420,8 @@ class PIterableType < PTypeWithContainedType
|
|
|
1298
1420
|
o >= 0
|
|
1299
1421
|
when PIntegerType
|
|
1300
1422
|
o.finite_range?
|
|
1423
|
+
when PTypeAliasType
|
|
1424
|
+
instance?(o.resolved_type, guard)
|
|
1301
1425
|
else
|
|
1302
1426
|
false
|
|
1303
1427
|
end
|
|
@@ -1336,7 +1460,7 @@ class PIteratorType < PTypeWithContainedType
|
|
|
1336
1460
|
def self.register_ptype(loader, ir)
|
|
1337
1461
|
create_ptype(loader, ir, 'AnyType',
|
|
1338
1462
|
'type' => {
|
|
1339
|
-
KEY_TYPE => POptionalType.new(
|
|
1463
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
1340
1464
|
KEY_VALUE => nil
|
|
1341
1465
|
}
|
|
1342
1466
|
)
|
|
@@ -1374,7 +1498,7 @@ class PStringType < PScalarDataType
|
|
|
1374
1498
|
def self.register_ptype(loader, ir)
|
|
1375
1499
|
create_ptype(loader, ir, 'ScalarDataType',
|
|
1376
1500
|
'size_type_or_value' => {
|
|
1377
|
-
KEY_TYPE => POptionalType.new(PVariantType.new([PStringType::DEFAULT,
|
|
1501
|
+
KEY_TYPE => POptionalType.new(PVariantType.new([PStringType::DEFAULT, PTypeType.new(PIntegerType::DEFAULT)])),
|
|
1378
1502
|
KEY_VALUE => nil
|
|
1379
1503
|
})
|
|
1380
1504
|
end
|
|
@@ -1384,11 +1508,13 @@ class PStringType < PScalarDataType
|
|
|
1384
1508
|
def initialize(size_type_or_value, deprecated_multi_args = EMPTY_ARRAY)
|
|
1385
1509
|
unless deprecated_multi_args.empty?
|
|
1386
1510
|
if Puppet[:strict] != :off
|
|
1387
|
-
|
|
1511
|
+
#TRANSLATORS 'PStringType#initialize' is a class and method name and should not be translated
|
|
1512
|
+
Puppet.warn_once('deprecations', "PStringType#initialize_multi_args",
|
|
1513
|
+
_("Passing more than one argument to PStringType#initialize is deprecated"))
|
|
1388
1514
|
end
|
|
1389
1515
|
size_type_or_value = deprecated_multi_args[0]
|
|
1390
1516
|
end
|
|
1391
|
-
@size_type_or_value = size_type_or_value
|
|
1517
|
+
@size_type_or_value = size_type_or_value.is_a?(PIntegerType) ? size_type_or_value.to_size : size_type_or_value
|
|
1392
1518
|
end
|
|
1393
1519
|
|
|
1394
1520
|
def accept(visitor, guard)
|
|
@@ -1437,7 +1563,8 @@ class PStringType < PScalarDataType
|
|
|
1437
1563
|
# @api private
|
|
1438
1564
|
def values
|
|
1439
1565
|
if Puppet[:strict] != :off
|
|
1440
|
-
|
|
1566
|
+
#TRANSLATORS 'PStringType#values' and '#value' are classes and method names and should not be translated
|
|
1567
|
+
Puppet.warn_once('deprecations', "PStringType#values", _("Method PStringType#values is deprecated. Use #value instead"))
|
|
1441
1568
|
end
|
|
1442
1569
|
@value.is_a?(String) ? [@value] : EMPTY_ARRAY
|
|
1443
1570
|
end
|
|
@@ -1446,10 +1573,6 @@ class PStringType < PScalarDataType
|
|
|
1446
1573
|
@size_type_or_value.is_a?(PIntegerType) ? @size_type_or_value : nil
|
|
1447
1574
|
end
|
|
1448
1575
|
|
|
1449
|
-
def size_type
|
|
1450
|
-
@size_type_or_value.is_a?(PIntegerType) ? @size_type_or_value : nil
|
|
1451
|
-
end
|
|
1452
|
-
|
|
1453
1576
|
def derived_size_type
|
|
1454
1577
|
if @size_type_or_value.is_a?(PIntegerType)
|
|
1455
1578
|
@size_type_or_value
|
|
@@ -1461,12 +1584,12 @@ class PStringType < PScalarDataType
|
|
|
1461
1584
|
end
|
|
1462
1585
|
end
|
|
1463
1586
|
|
|
1464
|
-
def self.new_function(
|
|
1465
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_string, loader) do
|
|
1587
|
+
def self.new_function(type)
|
|
1588
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_string, type.loader) do
|
|
1466
1589
|
local_types do
|
|
1467
|
-
type
|
|
1590
|
+
type "Format = Pattern[/#{StringConverter::Format::FMT_PATTERN_STR}/]"
|
|
1468
1591
|
type 'ContainerFormat = Struct[{
|
|
1469
|
-
Optional[format] =>
|
|
1592
|
+
Optional[format] => Format,
|
|
1470
1593
|
Optional[separator] => String,
|
|
1471
1594
|
Optional[separator2] => String,
|
|
1472
1595
|
Optional[string_formats] => Hash[Type, Format]
|
|
@@ -1532,7 +1655,7 @@ class PStringType < PScalarDataType
|
|
|
1532
1655
|
# Must match exactly when value is a string
|
|
1533
1656
|
@size_type_or_value.nil? || @size_type_or_value == o.size_type_or_value
|
|
1534
1657
|
when PEnumType
|
|
1535
|
-
@size_type_or_value.nil? ? true : o.values.size == 1 &&
|
|
1658
|
+
@size_type_or_value.nil? ? true : o.values.size == 1 && !o.case_insensitive? && o.values[0]
|
|
1536
1659
|
when PPatternType
|
|
1537
1660
|
@size_type_or_value.nil?
|
|
1538
1661
|
else
|
|
@@ -1557,8 +1680,8 @@ class PRegexpType < PScalarType
|
|
|
1557
1680
|
|
|
1558
1681
|
# Returns a new function that produces a Regexp instance
|
|
1559
1682
|
#
|
|
1560
|
-
def self.new_function(
|
|
1561
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_float, loader) do
|
|
1683
|
+
def self.new_function(type)
|
|
1684
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_float, type.loader) do
|
|
1562
1685
|
dispatch :from_string do
|
|
1563
1686
|
param 'String', :pattern
|
|
1564
1687
|
end
|
|
@@ -1571,10 +1694,41 @@ class PRegexpType < PScalarType
|
|
|
1571
1694
|
|
|
1572
1695
|
attr_reader :pattern
|
|
1573
1696
|
|
|
1697
|
+
# @param regexp [Regexp] the regular expression
|
|
1698
|
+
# @return [String] the Regexp as a slash delimited string with slashes escaped
|
|
1699
|
+
def self.regexp_to_s_with_delimiters(regexp)
|
|
1700
|
+
regexp.options == 0 ? regexp.inspect : "/#{regexp.to_s}/"
|
|
1701
|
+
end
|
|
1702
|
+
|
|
1703
|
+
# @param regexp [Regexp] the regular expression
|
|
1704
|
+
# @return [String] the Regexp as a string without escaped slash
|
|
1705
|
+
def self.regexp_to_s(regexp)
|
|
1706
|
+
append_flags_group(regexp.source, regexp.options)
|
|
1707
|
+
end
|
|
1708
|
+
|
|
1709
|
+
def self.append_flags_group(rx_string, options)
|
|
1710
|
+
if options == 0
|
|
1711
|
+
rx_string
|
|
1712
|
+
else
|
|
1713
|
+
bld = '(?'
|
|
1714
|
+
bld << 'i' if (options & Regexp::IGNORECASE) != 0
|
|
1715
|
+
bld << 'm' if (options & Regexp::MULTILINE) != 0
|
|
1716
|
+
bld << 'x' if (options & Regexp::EXTENDED) != 0
|
|
1717
|
+
unless options == (Regexp::IGNORECASE | Regexp::MULTILINE | Regexp::EXTENDED)
|
|
1718
|
+
bld << '-'
|
|
1719
|
+
bld << 'i' if (options & Regexp::IGNORECASE) == 0
|
|
1720
|
+
bld << 'm' if (options & Regexp::MULTILINE) == 0
|
|
1721
|
+
bld << 'x' if (options & Regexp::EXTENDED) == 0
|
|
1722
|
+
end
|
|
1723
|
+
bld << ':' << rx_string << ')'
|
|
1724
|
+
bld.freeze
|
|
1725
|
+
end
|
|
1726
|
+
end
|
|
1727
|
+
|
|
1574
1728
|
def initialize(pattern)
|
|
1575
1729
|
if pattern.is_a?(Regexp)
|
|
1576
1730
|
@regexp = pattern
|
|
1577
|
-
@pattern =
|
|
1731
|
+
@pattern = PRegexpType.regexp_to_s(pattern)
|
|
1578
1732
|
else
|
|
1579
1733
|
@pattern = pattern
|
|
1580
1734
|
end
|
|
@@ -1593,7 +1747,7 @@ class PRegexpType < PScalarType
|
|
|
1593
1747
|
end
|
|
1594
1748
|
|
|
1595
1749
|
def instance?(o, guard=nil)
|
|
1596
|
-
o.is_a?(Regexp) &&
|
|
1750
|
+
o.is_a?(Regexp) && @pattern.nil? || regexp == o
|
|
1597
1751
|
end
|
|
1598
1752
|
|
|
1599
1753
|
DEFAULT = PRegexpType.new(nil)
|
|
@@ -1687,46 +1841,73 @@ class PBooleanType < PScalarDataType
|
|
|
1687
1841
|
create_ptype(loader, ir, 'ScalarDataType')
|
|
1688
1842
|
end
|
|
1689
1843
|
|
|
1844
|
+
attr_reader :value
|
|
1845
|
+
|
|
1846
|
+
def initialize(value = nil)
|
|
1847
|
+
@value = value
|
|
1848
|
+
end
|
|
1849
|
+
|
|
1850
|
+
def eql?(o)
|
|
1851
|
+
o.is_a?(PBooleanType) && @value == o.value
|
|
1852
|
+
end
|
|
1853
|
+
|
|
1854
|
+
def generalize
|
|
1855
|
+
PBooleanType::DEFAULT
|
|
1856
|
+
end
|
|
1857
|
+
|
|
1858
|
+
def hash
|
|
1859
|
+
31 ^ @value.hash
|
|
1860
|
+
end
|
|
1861
|
+
|
|
1690
1862
|
def instance?(o, guard = nil)
|
|
1691
|
-
o == true || o == false
|
|
1863
|
+
(o == true || o == false) && (@value.nil? || value == o)
|
|
1692
1864
|
end
|
|
1693
1865
|
|
|
1694
|
-
def self.new_function(
|
|
1695
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_boolean, loader) do
|
|
1866
|
+
def self.new_function(type)
|
|
1867
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_boolean, type.loader) do
|
|
1696
1868
|
dispatch :from_args do
|
|
1697
|
-
param
|
|
1869
|
+
param "Variant[Integer, Float, Boolean, Enum['false','true','yes','no','y','n',true]]", :from
|
|
1870
|
+
end
|
|
1871
|
+
|
|
1872
|
+
argument_mismatch :on_error do
|
|
1873
|
+
param 'Any', :from
|
|
1698
1874
|
end
|
|
1699
1875
|
|
|
1700
1876
|
def from_args(from)
|
|
1701
1877
|
from = from.downcase if from.is_a?(String)
|
|
1702
1878
|
case from
|
|
1703
|
-
when NilClass
|
|
1704
|
-
throw :undefined_value
|
|
1705
1879
|
when Float
|
|
1706
1880
|
from != 0.0
|
|
1707
1881
|
when Integer
|
|
1708
1882
|
from != 0
|
|
1709
|
-
when
|
|
1710
|
-
from
|
|
1711
|
-
when 'false', 'no', 'n'
|
|
1883
|
+
when false, 'false', 'no', 'n'
|
|
1712
1884
|
false
|
|
1713
|
-
|
|
1885
|
+
else
|
|
1714
1886
|
true
|
|
1887
|
+
end
|
|
1888
|
+
end
|
|
1889
|
+
|
|
1890
|
+
def on_error(from)
|
|
1891
|
+
if from.is_a?(String)
|
|
1892
|
+
_("The string '%{str}' cannot be converted to Boolean") % { str: from }
|
|
1715
1893
|
else
|
|
1716
|
-
|
|
1894
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
|
1895
|
+
_("Value of type %{type} cannot be converted to Boolean") % { type: t }
|
|
1717
1896
|
end
|
|
1718
1897
|
end
|
|
1719
1898
|
end
|
|
1720
1899
|
end
|
|
1721
1900
|
|
|
1722
1901
|
DEFAULT = PBooleanType.new
|
|
1902
|
+
TRUE = PBooleanType.new(true)
|
|
1903
|
+
FALSE = PBooleanType.new(false)
|
|
1723
1904
|
|
|
1724
1905
|
protected
|
|
1725
1906
|
|
|
1726
1907
|
# @api private
|
|
1727
1908
|
#
|
|
1728
1909
|
def _assignable?(o, guard)
|
|
1729
|
-
o.is_a?(PBooleanType)
|
|
1910
|
+
o.is_a?(PBooleanType) && (@value.nil? || @value == o.value)
|
|
1730
1911
|
end
|
|
1731
1912
|
end
|
|
1732
1913
|
|
|
@@ -1737,8 +1918,8 @@ end
|
|
|
1737
1918
|
class PStructElement < TypedModelObject
|
|
1738
1919
|
def self.register_ptype(loader, ir)
|
|
1739
1920
|
@type = Pcore::create_object_type(loader, ir, self, 'Pcore::StructElement'.freeze, nil,
|
|
1740
|
-
'key_type' =>
|
|
1741
|
-
'value_type' =>
|
|
1921
|
+
'key_type' => PTypeType::DEFAULT,
|
|
1922
|
+
'value_type' => PTypeType::DEFAULT)
|
|
1742
1923
|
end
|
|
1743
1924
|
|
|
1744
1925
|
attr_accessor :key_type, :value_type
|
|
@@ -1773,11 +1954,9 @@ class PStructElement < TypedModelObject
|
|
|
1773
1954
|
@value_type.equal?(nv_type) ? self : PStructElement.new(@key_type, nv_type)
|
|
1774
1955
|
end
|
|
1775
1956
|
|
|
1776
|
-
def resolve(
|
|
1777
|
-
rkey_type = @key_type
|
|
1778
|
-
|
|
1779
|
-
rvalue_type = @value_type
|
|
1780
|
-
rvalue_type = rvalue_type.resolve(type_parser, loader) unless rvalue_type.nil?
|
|
1957
|
+
def resolve(loader)
|
|
1958
|
+
rkey_type = @key_type.resolve(loader)
|
|
1959
|
+
rvalue_type = @value_type.resolve(loader)
|
|
1781
1960
|
rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type)
|
|
1782
1961
|
end
|
|
1783
1962
|
|
|
@@ -1860,7 +2039,6 @@ class PStructType < PAnyType
|
|
|
1860
2039
|
if self == DEFAULT
|
|
1861
2040
|
PIterableType.new(PHashType::DEFAULT_KEY_PAIR_TUPLE)
|
|
1862
2041
|
else
|
|
1863
|
-
tc = TypeCalculator.singleton
|
|
1864
2042
|
PIterableType.new(
|
|
1865
2043
|
PTupleType.new([
|
|
1866
2044
|
PVariantType.maybe_create(@elements.map {|se| se.key_type }),
|
|
@@ -1869,10 +2047,10 @@ class PStructType < PAnyType
|
|
|
1869
2047
|
end
|
|
1870
2048
|
end
|
|
1871
2049
|
|
|
1872
|
-
def resolve(
|
|
2050
|
+
def resolve(loader)
|
|
1873
2051
|
changed = false
|
|
1874
2052
|
relements = @elements.map do |elem|
|
|
1875
|
-
relem = elem.resolve(
|
|
2053
|
+
relem = elem.resolve(loader)
|
|
1876
2054
|
changed ||= !relem.equal?(elem)
|
|
1877
2055
|
relem
|
|
1878
2056
|
end
|
|
@@ -1904,10 +2082,10 @@ class PStructType < PAnyType
|
|
|
1904
2082
|
end && matched == o.size
|
|
1905
2083
|
end
|
|
1906
2084
|
|
|
1907
|
-
def new_function
|
|
2085
|
+
def new_function
|
|
1908
2086
|
# Simply delegate to Hash type and let the higher level assertion deal with
|
|
1909
2087
|
# compliance with the Struct type regarding the produced result.
|
|
1910
|
-
PHashType.new_function(self
|
|
2088
|
+
PHashType.new_function(self)
|
|
1911
2089
|
end
|
|
1912
2090
|
|
|
1913
2091
|
DEFAULT = PStructType.new(EMPTY_ARRAY)
|
|
@@ -1965,9 +2143,9 @@ class PTupleType < PAnyType
|
|
|
1965
2143
|
|
|
1966
2144
|
def self.register_ptype(loader, ir)
|
|
1967
2145
|
create_ptype(loader, ir, 'AnyType',
|
|
1968
|
-
'types' => PArrayType.new(
|
|
2146
|
+
'types' => PArrayType.new(PTypeType::DEFAULT),
|
|
1969
2147
|
'size_type' => {
|
|
1970
|
-
KEY_TYPE => POptionalType.new(
|
|
2148
|
+
KEY_TYPE => POptionalType.new(PTypeType.new(PIntegerType::DEFAULT)),
|
|
1971
2149
|
KEY_VALUE => nil
|
|
1972
2150
|
}
|
|
1973
2151
|
)
|
|
@@ -2050,10 +2228,10 @@ class PTupleType < PAnyType
|
|
|
2050
2228
|
end
|
|
2051
2229
|
end
|
|
2052
2230
|
|
|
2053
|
-
def resolve(
|
|
2231
|
+
def resolve(loader)
|
|
2054
2232
|
changed = false
|
|
2055
2233
|
rtypes = @types.map do |type|
|
|
2056
|
-
rtype = type.resolve(
|
|
2234
|
+
rtype = type.resolve(loader)
|
|
2057
2235
|
changed ||= !rtype.equal?(type)
|
|
2058
2236
|
rtype
|
|
2059
2237
|
end
|
|
@@ -2115,10 +2293,10 @@ class PTupleType < PAnyType
|
|
|
2115
2293
|
self.class == o.class && @types == o.types && @size_type == o.size_type
|
|
2116
2294
|
end
|
|
2117
2295
|
|
|
2118
|
-
def new_function
|
|
2296
|
+
def new_function
|
|
2119
2297
|
# Simply delegate to Array type and let the higher level assertion deal with
|
|
2120
2298
|
# compliance with the Tuple type regarding the produced result.
|
|
2121
|
-
PArrayType.new_function(self
|
|
2299
|
+
PArrayType.new_function(self)
|
|
2122
2300
|
end
|
|
2123
2301
|
|
|
2124
2302
|
DEFAULT = PTupleType.new(EMPTY_ARRAY)
|
|
@@ -2164,15 +2342,15 @@ class PCallableType < PAnyType
|
|
|
2164
2342
|
def self.register_ptype(loader, ir)
|
|
2165
2343
|
create_ptype(loader, ir, 'AnyType',
|
|
2166
2344
|
'param_types' => {
|
|
2167
|
-
KEY_TYPE => POptionalType.new(PTupleType::DEFAULT),
|
|
2345
|
+
KEY_TYPE => POptionalType.new(PTypeType.new(PTupleType::DEFAULT)),
|
|
2168
2346
|
KEY_VALUE => nil
|
|
2169
2347
|
},
|
|
2170
2348
|
'block_type' => {
|
|
2171
|
-
KEY_TYPE => POptionalType.new(PCallableType::DEFAULT),
|
|
2349
|
+
KEY_TYPE => POptionalType.new(PTypeType.new(PCallableType::DEFAULT)),
|
|
2172
2350
|
KEY_VALUE => nil
|
|
2173
2351
|
},
|
|
2174
2352
|
'return_type' => {
|
|
2175
|
-
KEY_TYPE => POptionalType.new(
|
|
2353
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
2176
2354
|
KEY_VALUE => PAnyType::DEFAULT
|
|
2177
2355
|
}
|
|
2178
2356
|
)
|
|
@@ -2250,7 +2428,7 @@ class PCallableType < PAnyType
|
|
|
2250
2428
|
|
|
2251
2429
|
# @api private
|
|
2252
2430
|
def callable_args?(required_callable_t, guard)
|
|
2253
|
-
# If the required callable is
|
|
2431
|
+
# If the required callable is equal or more specific than self, self is acceptable arguments
|
|
2254
2432
|
required_callable_t.assignable?(self, guard)
|
|
2255
2433
|
end
|
|
2256
2434
|
|
|
@@ -2290,10 +2468,10 @@ class PCallableType < PAnyType
|
|
|
2290
2468
|
self.class == o.class && @param_types == o.param_types && @block_type == o.block_type && @return_type == o.return_type
|
|
2291
2469
|
end
|
|
2292
2470
|
|
|
2293
|
-
def resolve(
|
|
2294
|
-
params_t = @param_types.nil? ? nil : @param_types.resolve(
|
|
2295
|
-
block_t = @block_type.nil? ? nil : @block_type.resolve(
|
|
2296
|
-
return_t = @return_type.nil? ? nil : @return_type.resolve(
|
|
2471
|
+
def resolve(loader)
|
|
2472
|
+
params_t = @param_types.nil? ? nil : @param_types.resolve(loader)
|
|
2473
|
+
block_t = @block_type.nil? ? nil : @block_type.resolve(loader)
|
|
2474
|
+
return_t = @return_type.nil? ? nil : @return_type.resolve(loader)
|
|
2297
2475
|
@param_types.equal?(params_t) && @block_type.equal?(block_t) && @return_type.equal?(return_t) ? self : self.class.new(params_t, block_t, return_t)
|
|
2298
2476
|
end
|
|
2299
2477
|
|
|
@@ -2329,7 +2507,7 @@ class PArrayType < PCollectionType
|
|
|
2329
2507
|
def self.register_ptype(loader, ir)
|
|
2330
2508
|
create_ptype(loader, ir, 'CollectionType',
|
|
2331
2509
|
'element_type' => {
|
|
2332
|
-
KEY_TYPE => POptionalType.new(
|
|
2510
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
2333
2511
|
KEY_VALUE => PAnyType::DEFAULT
|
|
2334
2512
|
}
|
|
2335
2513
|
)
|
|
@@ -2385,8 +2563,8 @@ class PArrayType < PCollectionType
|
|
|
2385
2563
|
end
|
|
2386
2564
|
end
|
|
2387
2565
|
|
|
2388
|
-
def resolve(
|
|
2389
|
-
relement_type = @element_type.resolve(
|
|
2566
|
+
def resolve(loader)
|
|
2567
|
+
relement_type = @element_type.resolve(loader)
|
|
2390
2568
|
relement_type.equal?(@element_type) ? self : self.class.new(relement_type, @size_type)
|
|
2391
2569
|
end
|
|
2392
2570
|
|
|
@@ -2404,44 +2582,46 @@ class PArrayType < PCollectionType
|
|
|
2404
2582
|
|
|
2405
2583
|
# Returns a new function that produces an Array
|
|
2406
2584
|
#
|
|
2407
|
-
def self.new_function(
|
|
2408
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_array, loader) do
|
|
2585
|
+
def self.new_function(type)
|
|
2586
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_array, type.loader) do
|
|
2409
2587
|
|
|
2410
|
-
dispatch :
|
|
2411
|
-
param '
|
|
2412
|
-
optional_param 'Boolean',
|
|
2588
|
+
dispatch :to_array do
|
|
2589
|
+
param 'Variant[Array,Hash,Binary,Iterable]', :from
|
|
2590
|
+
optional_param 'Boolean[false]', :wrap
|
|
2591
|
+
end
|
|
2592
|
+
|
|
2593
|
+
dispatch :wrapped do
|
|
2594
|
+
param 'Any', :from
|
|
2595
|
+
param 'Boolean[true]', :wrap
|
|
2596
|
+
end
|
|
2597
|
+
|
|
2598
|
+
argument_mismatch :on_error do
|
|
2599
|
+
param 'Any', :from
|
|
2600
|
+
optional_param 'Boolean', :wrap
|
|
2601
|
+
end
|
|
2602
|
+
|
|
2603
|
+
def wrapped(from, _)
|
|
2604
|
+
from.is_a?(Array) ? from : [from]
|
|
2413
2605
|
end
|
|
2414
2606
|
|
|
2415
|
-
def
|
|
2607
|
+
def to_array(from, _ = false)
|
|
2416
2608
|
case from
|
|
2417
|
-
when NilClass
|
|
2418
|
-
if wrap
|
|
2419
|
-
[nil]
|
|
2420
|
-
else
|
|
2421
|
-
throw :undefined_value
|
|
2422
|
-
end
|
|
2423
2609
|
when Array
|
|
2424
2610
|
from
|
|
2425
2611
|
when Hash
|
|
2426
|
-
|
|
2427
|
-
|
|
2612
|
+
from.to_a
|
|
2428
2613
|
when PBinaryType::Binary
|
|
2429
2614
|
# For older rubies, the #bytes method returns an Enumerator that must be rolled out
|
|
2430
|
-
|
|
2431
|
-
|
|
2615
|
+
from.binary_buffer.bytes.to_a
|
|
2432
2616
|
else
|
|
2433
|
-
|
|
2434
|
-
[from]
|
|
2435
|
-
else
|
|
2436
|
-
if PIterableType::DEFAULT.instance?(from)
|
|
2437
|
-
Iterable.on(from).to_a
|
|
2438
|
-
else
|
|
2439
|
-
t = Puppet::Pops::Types::TypeCalculator.singleton.infer(from).generalize
|
|
2440
|
-
raise TypeConversionError.new("Value of type '#{t}' cannot be converted to Array")
|
|
2441
|
-
end
|
|
2442
|
-
end
|
|
2617
|
+
Iterable.on(from).to_a
|
|
2443
2618
|
end
|
|
2444
2619
|
end
|
|
2620
|
+
|
|
2621
|
+
def on_error(from, _ = false)
|
|
2622
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
|
2623
|
+
_("Value of type %{type} cannot be converted to Array") % { type: t }
|
|
2624
|
+
end
|
|
2445
2625
|
end
|
|
2446
2626
|
end
|
|
2447
2627
|
|
|
@@ -2477,11 +2657,11 @@ class PHashType < PCollectionType
|
|
|
2477
2657
|
def self.register_ptype(loader, ir)
|
|
2478
2658
|
create_ptype(loader, ir, 'CollectionType',
|
|
2479
2659
|
'key_type' => {
|
|
2480
|
-
KEY_TYPE => POptionalType.new(
|
|
2660
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
2481
2661
|
KEY_VALUE => PAnyType::DEFAULT
|
|
2482
2662
|
},
|
|
2483
2663
|
'value_type' => {
|
|
2484
|
-
KEY_TYPE => POptionalType.new(
|
|
2664
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
2485
2665
|
KEY_VALUE => PAnyType::DEFAULT
|
|
2486
2666
|
}
|
|
2487
2667
|
)
|
|
@@ -2508,8 +2688,9 @@ class PHashType < PCollectionType
|
|
|
2508
2688
|
|
|
2509
2689
|
def element_type
|
|
2510
2690
|
if Puppet[:strict] != :off
|
|
2691
|
+
#TRANSLATOR 'Puppet::Pops::Types::PHashType#element_type' and '#value_type' are class and method names and should not be translated
|
|
2511
2692
|
Puppet.warn_once('deprecations', 'Puppet::Pops::Types::PHashType#element_type',
|
|
2512
|
-
'Puppet::Pops::Types::PHashType#element_type is deprecated, use #value_type instead')
|
|
2693
|
+
_('Puppet::Pops::Types::PHashType#element_type is deprecated, use #value_type instead'))
|
|
2513
2694
|
end
|
|
2514
2695
|
@value_type
|
|
2515
2696
|
end
|
|
@@ -2571,18 +2752,32 @@ class PHashType < PCollectionType
|
|
|
2571
2752
|
self == EMPTY
|
|
2572
2753
|
end
|
|
2573
2754
|
|
|
2574
|
-
def resolve(
|
|
2575
|
-
rkey_type = @key_type.resolve(
|
|
2576
|
-
rvalue_type = @value_type.resolve(
|
|
2755
|
+
def resolve(loader)
|
|
2756
|
+
rkey_type = @key_type.resolve(loader)
|
|
2757
|
+
rvalue_type = @value_type.resolve(loader)
|
|
2577
2758
|
rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type, @size_type)
|
|
2578
2759
|
end
|
|
2579
2760
|
|
|
2761
|
+
def self.array_as_hash(value)
|
|
2762
|
+
return value unless value.is_a?(Array)
|
|
2763
|
+
result = {}
|
|
2764
|
+
value.each_with_index {|v, idx| result[idx] = array_as_hash(v) }
|
|
2765
|
+
result
|
|
2766
|
+
end
|
|
2767
|
+
|
|
2580
2768
|
# Returns a new function that produces a Hash
|
|
2581
2769
|
#
|
|
2582
|
-
def self.new_function(
|
|
2583
|
-
@new_function ||= Puppet::Functions.create_loaded_function(:new_hash, loader) do
|
|
2770
|
+
def self.new_function(type)
|
|
2771
|
+
@new_function ||= Puppet::Functions.create_loaded_function(:new_hash, type.loader) do
|
|
2584
2772
|
local_types do
|
|
2585
2773
|
type 'KeyValueArray = Array[Tuple[Any,Any],1]'
|
|
2774
|
+
type 'TreeArray = Array[Tuple[Array,Any],1]'
|
|
2775
|
+
type 'NewHashOption = Enum[tree, hash_tree]'
|
|
2776
|
+
end
|
|
2777
|
+
|
|
2778
|
+
dispatch :from_tree do
|
|
2779
|
+
param 'TreeArray', :from
|
|
2780
|
+
optional_param 'NewHashOption', :build_option
|
|
2586
2781
|
end
|
|
2587
2782
|
|
|
2588
2783
|
dispatch :from_tuples do
|
|
@@ -2597,16 +2792,42 @@ class PHashType < PCollectionType
|
|
|
2597
2792
|
Hash[tuple_array]
|
|
2598
2793
|
end
|
|
2599
2794
|
|
|
2795
|
+
def from_tree(tuple_array, build_option = nil)
|
|
2796
|
+
if build_option.nil?
|
|
2797
|
+
return from_tuples(tuple_array)
|
|
2798
|
+
end
|
|
2799
|
+
# only remaining possible options is 'tree' or 'hash_tree'
|
|
2800
|
+
|
|
2801
|
+
all_hashes = build_option == 'hash_tree'
|
|
2802
|
+
result = {}
|
|
2803
|
+
tuple_array.each do |entry|
|
|
2804
|
+
path = entry[0]
|
|
2805
|
+
value = entry[1]
|
|
2806
|
+
if path.empty?
|
|
2807
|
+
# root node (index [] was included - values merge into the result)
|
|
2808
|
+
# An array must be changed to a hash first as this is the root
|
|
2809
|
+
# (Cannot return an array from a Hash.new)
|
|
2810
|
+
if value.is_a?(Array)
|
|
2811
|
+
value.each_with_index {|v, idx| result[idx] = v }
|
|
2812
|
+
else
|
|
2813
|
+
result.merge!(value)
|
|
2814
|
+
end
|
|
2815
|
+
else
|
|
2816
|
+
r = path[0..-2].reduce(result) {|memo, idx| (memo.is_a?(Array) || memo.has_key?(idx)) ? memo[idx] : memo[idx] = {}}
|
|
2817
|
+
r[path[-1]]= (all_hashes ? PHashType.array_as_hash(value) : value)
|
|
2818
|
+
end
|
|
2819
|
+
end
|
|
2820
|
+
result
|
|
2821
|
+
end
|
|
2822
|
+
|
|
2600
2823
|
def from_array(from)
|
|
2601
2824
|
case from
|
|
2602
|
-
when NilClass
|
|
2603
|
-
throw :undefined_value
|
|
2604
2825
|
when Array
|
|
2605
2826
|
if from.size == 0
|
|
2606
2827
|
{}
|
|
2607
2828
|
else
|
|
2608
2829
|
unless from.size % 2 == 0
|
|
2609
|
-
raise TypeConversionError.new(
|
|
2830
|
+
raise TypeConversionError.new(_('odd number of arguments for Hash'))
|
|
2610
2831
|
end
|
|
2611
2832
|
Hash[*from]
|
|
2612
2833
|
end
|
|
@@ -2616,8 +2837,8 @@ class PHashType < PCollectionType
|
|
|
2616
2837
|
if PIterableType::DEFAULT.instance?(from)
|
|
2617
2838
|
Hash[*Iterable.on(from).to_a]
|
|
2618
2839
|
else
|
|
2619
|
-
t =
|
|
2620
|
-
raise TypeConversionError.new("Value of type
|
|
2840
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
|
2841
|
+
raise TypeConversionError.new(_("Value of type %{type} cannot be converted to Hash") % { type: t })
|
|
2621
2842
|
end
|
|
2622
2843
|
end
|
|
2623
2844
|
end
|
|
@@ -2660,7 +2881,7 @@ class PVariantType < PAnyType
|
|
|
2660
2881
|
include Enumerable
|
|
2661
2882
|
|
|
2662
2883
|
def self.register_ptype(loader, ir)
|
|
2663
|
-
create_ptype(loader, ir, 'AnyType', 'types' => PArrayType.new(
|
|
2884
|
+
create_ptype(loader, ir, 'AnyType', 'types' => PArrayType.new(PTypeType::DEFAULT))
|
|
2664
2885
|
end
|
|
2665
2886
|
|
|
2666
2887
|
attr_reader :types
|
|
@@ -2770,6 +2991,7 @@ class PVariantType < PAnyType
|
|
|
2770
2991
|
def really_instance?(o, guard = nil)
|
|
2771
2992
|
@types.reduce(-1) do |memo, type|
|
|
2772
2993
|
ri = type.really_instance?(o, guard)
|
|
2994
|
+
break ri if ri > 0
|
|
2773
2995
|
ri > memo ? ri : memo
|
|
2774
2996
|
end
|
|
2775
2997
|
end
|
|
@@ -2778,35 +3000,32 @@ class PVariantType < PAnyType
|
|
|
2778
3000
|
@types.all? { |type| type.kind_of_callable?(optional, guard) }
|
|
2779
3001
|
end
|
|
2780
3002
|
|
|
2781
|
-
def resolved?
|
|
2782
|
-
@types.all? { |type| type.resolved? }
|
|
2783
|
-
end
|
|
2784
|
-
|
|
2785
3003
|
def eql?(o)
|
|
2786
3004
|
self.class == o.class && @types.size == o.types.size && (@types - o.types).empty?
|
|
2787
3005
|
end
|
|
2788
3006
|
|
|
2789
3007
|
DEFAULT = PVariantType.new(EMPTY_ARRAY)
|
|
2790
3008
|
|
|
3009
|
+
def assignable?(o, guard = nil)
|
|
3010
|
+
# an empty Variant does not match Undef (it is void - not even undef)
|
|
3011
|
+
if o.is_a?(PUndefType) && types.empty?
|
|
3012
|
+
return false
|
|
3013
|
+
end
|
|
3014
|
+
|
|
3015
|
+
return super unless o.is_a?(PVariantType)
|
|
3016
|
+
# If empty, all Variant types match irrespective of the types they hold (including being empty)
|
|
3017
|
+
return true if types.empty?
|
|
3018
|
+
# Since this variant is not empty, an empty Variant cannot match, because it matches nothing
|
|
3019
|
+
# otherwise all types in o must be assignable to this
|
|
3020
|
+
!o.types.empty? && o.types.all? { |vt| super(vt, guard) }
|
|
3021
|
+
end
|
|
3022
|
+
|
|
2791
3023
|
protected
|
|
2792
3024
|
|
|
2793
3025
|
# @api private
|
|
2794
3026
|
def _assignable?(o, guard)
|
|
2795
|
-
if o
|
|
2796
|
-
|
|
2797
|
-
return true if self == o
|
|
2798
|
-
o.types.all? do |other|
|
|
2799
|
-
# if the other is a Variant, all of its options, but be assignable to one of this type's options
|
|
2800
|
-
if other.is_a?(PVariantType)
|
|
2801
|
-
assignable?(other, guard)
|
|
2802
|
-
else
|
|
2803
|
-
types.any? {|option_t| option_t.assignable?(other, guard) }
|
|
2804
|
-
end
|
|
2805
|
-
end
|
|
2806
|
-
else
|
|
2807
|
-
# A variant is assignable if o is assignable to any of its types
|
|
2808
|
-
types.any? { |option_t| option_t.assignable?(o, guard) }
|
|
2809
|
-
end
|
|
3027
|
+
# A variant is assignable if o is assignable to any of its types
|
|
3028
|
+
types.any? { |option_t| option_t.assignable?(o, guard) }
|
|
2810
3029
|
end
|
|
2811
3030
|
|
|
2812
3031
|
# @api private
|
|
@@ -2825,8 +3044,9 @@ class PVariantType < PAnyType
|
|
|
2825
3044
|
|
|
2826
3045
|
# @api private
|
|
2827
3046
|
def merge_enums(array)
|
|
3047
|
+
# Merge case sensitive enums and strings
|
|
2828
3048
|
if array.size > 1
|
|
2829
|
-
parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? || t.is_a?(PStringType) && !t.value.nil? }
|
|
3049
|
+
parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? && !t.case_insensitive? || t.is_a?(PStringType) && !t.value.nil? }
|
|
2830
3050
|
enums = parts[0]
|
|
2831
3051
|
if enums.size > 1
|
|
2832
3052
|
others = parts[1]
|
|
@@ -2834,6 +3054,20 @@ class PVariantType < PAnyType
|
|
|
2834
3054
|
array = others
|
|
2835
3055
|
end
|
|
2836
3056
|
end
|
|
3057
|
+
|
|
3058
|
+
# Merge case insensitive enums
|
|
3059
|
+
if array.size > 1
|
|
3060
|
+
parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? && t.case_insensitive? }
|
|
3061
|
+
enums = parts[0]
|
|
3062
|
+
if enums.size > 1
|
|
3063
|
+
others = parts[1]
|
|
3064
|
+
values = []
|
|
3065
|
+
enums.each { |enum| enum.values.each { |value| values << value.downcase }}
|
|
3066
|
+
values.uniq!
|
|
3067
|
+
others << PEnumType.new(values, true)
|
|
3068
|
+
array = others
|
|
3069
|
+
end
|
|
3070
|
+
end
|
|
2837
3071
|
array
|
|
2838
3072
|
end
|
|
2839
3073
|
|
|
@@ -2915,7 +3149,7 @@ end
|
|
|
2915
3149
|
# Represents a (host-) class in the Puppet Language.
|
|
2916
3150
|
# @api public
|
|
2917
3151
|
#
|
|
2918
|
-
class
|
|
3152
|
+
class PClassType < PCatalogEntryType
|
|
2919
3153
|
attr_reader :class_name
|
|
2920
3154
|
|
|
2921
3155
|
def self.register_ptype(loader, ir)
|
|
@@ -2927,8 +3161,6 @@ class PHostClassType < PCatalogEntryType
|
|
|
2927
3161
|
)
|
|
2928
3162
|
end
|
|
2929
3163
|
|
|
2930
|
-
NAME = 'Class'.freeze
|
|
2931
|
-
|
|
2932
3164
|
def initialize(class_name)
|
|
2933
3165
|
@class_name = class_name
|
|
2934
3166
|
end
|
|
@@ -2940,17 +3172,13 @@ class PHostClassType < PCatalogEntryType
|
|
|
2940
3172
|
self.class == o.class && @class_name == o.class_name
|
|
2941
3173
|
end
|
|
2942
3174
|
|
|
2943
|
-
|
|
2944
|
-
NAME
|
|
2945
|
-
end
|
|
2946
|
-
|
|
2947
|
-
DEFAULT = PHostClassType.new(nil)
|
|
3175
|
+
DEFAULT = PClassType.new(nil)
|
|
2948
3176
|
|
|
2949
3177
|
protected
|
|
2950
3178
|
|
|
2951
3179
|
# @api private
|
|
2952
3180
|
def _assignable?(o, guard)
|
|
2953
|
-
return false unless o.is_a?(
|
|
3181
|
+
return false unless o.is_a?(PClassType)
|
|
2954
3182
|
# Class = Class[name}, Class[name] != Class
|
|
2955
3183
|
return true if @class_name.nil?
|
|
2956
3184
|
# Class[name] = Class[name]
|
|
@@ -2958,6 +3186,10 @@ class PHostClassType < PCatalogEntryType
|
|
|
2958
3186
|
end
|
|
2959
3187
|
end
|
|
2960
3188
|
|
|
3189
|
+
# For backward compatibility
|
|
3190
|
+
PHostClassType = PClassType
|
|
3191
|
+
|
|
3192
|
+
|
|
2961
3193
|
# Represents a Resource Type in the Puppet Language
|
|
2962
3194
|
# @api public
|
|
2963
3195
|
#
|
|
@@ -3011,7 +3243,7 @@ class POptionalType < PTypeWithContainedType
|
|
|
3011
3243
|
def self.register_ptype(loader, ir)
|
|
3012
3244
|
create_ptype(loader, ir, 'AnyType',
|
|
3013
3245
|
'type' => {
|
|
3014
|
-
KEY_TYPE => POptionalType.new(
|
|
3246
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
3015
3247
|
KEY_VALUE => nil
|
|
3016
3248
|
}
|
|
3017
3249
|
)
|
|
@@ -3046,8 +3278,8 @@ class POptionalType < PTypeWithContainedType
|
|
|
3046
3278
|
end
|
|
3047
3279
|
end
|
|
3048
3280
|
|
|
3049
|
-
def new_function
|
|
3050
|
-
optional_type.new_function
|
|
3281
|
+
def new_function
|
|
3282
|
+
optional_type.new_function
|
|
3051
3283
|
end
|
|
3052
3284
|
|
|
3053
3285
|
DEFAULT = POptionalType.new(nil)
|
|
@@ -3094,8 +3326,8 @@ class PTypeReferenceType < PAnyType
|
|
|
3094
3326
|
super && o.type_string == @type_string
|
|
3095
3327
|
end
|
|
3096
3328
|
|
|
3097
|
-
def resolve(
|
|
3098
|
-
|
|
3329
|
+
def resolve(loader)
|
|
3330
|
+
TypeParser.singleton.parse(@type_string, loader)
|
|
3099
3331
|
end
|
|
3100
3332
|
|
|
3101
3333
|
protected
|
|
@@ -3122,13 +3354,13 @@ class PTypeAliasType < PAnyType
|
|
|
3122
3354
|
'name' => PStringType::NON_EMPTY,
|
|
3123
3355
|
'type_expr' => PAnyType::DEFAULT,
|
|
3124
3356
|
'resolved_type' => {
|
|
3125
|
-
KEY_TYPE => POptionalType.new(
|
|
3357
|
+
KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
|
|
3126
3358
|
KEY_VALUE => nil
|
|
3127
3359
|
}
|
|
3128
3360
|
)
|
|
3129
3361
|
end
|
|
3130
3362
|
|
|
3131
|
-
attr_reader :name
|
|
3363
|
+
attr_reader :loader, :name
|
|
3132
3364
|
|
|
3133
3365
|
# @param name [String] The name of the type
|
|
3134
3366
|
# @param type_expr [Model::PopsObject] The expression that describes the aliased type
|
|
@@ -3233,16 +3465,17 @@ class PTypeAliasType < PAnyType
|
|
|
3233
3465
|
# @param loader [Loader::Loader] loader to use when loading type aliases
|
|
3234
3466
|
# @return [PTypeAliasType] the receiver of the call, i.e. `self`
|
|
3235
3467
|
# @api private
|
|
3236
|
-
def resolve(
|
|
3468
|
+
def resolve(loader)
|
|
3469
|
+
@loader = loader
|
|
3237
3470
|
if @resolved_type.nil?
|
|
3238
3471
|
# resolved to PTypeReferenceType::DEFAULT during resolve to avoid endless recursion
|
|
3239
3472
|
@resolved_type = PTypeReferenceType::DEFAULT
|
|
3240
3473
|
@self_recursion = true # assumed while it being found out below
|
|
3241
3474
|
begin
|
|
3242
3475
|
if @type_expr.is_a?(PTypeReferenceType)
|
|
3243
|
-
@resolved_type = @type_expr.resolve(
|
|
3476
|
+
@resolved_type = @type_expr.resolve(loader)
|
|
3244
3477
|
else
|
|
3245
|
-
@resolved_type =
|
|
3478
|
+
@resolved_type = TypeParser.singleton.interpret(@type_expr, loader).normalize
|
|
3246
3479
|
end
|
|
3247
3480
|
|
|
3248
3481
|
# Find out if this type is recursive. A recursive type has performance implications
|
|
@@ -3267,7 +3500,7 @@ class PTypeAliasType < PAnyType
|
|
|
3267
3500
|
else
|
|
3268
3501
|
# An alias may appoint an Object type that isn't resolved yet. The default type
|
|
3269
3502
|
# reference is used to prevent endless recursion and should not be resolved here.
|
|
3270
|
-
@resolved_type.resolve(
|
|
3503
|
+
@resolved_type.resolve(loader) unless @resolved_type.equal?(PTypeReferenceType::DEFAULT)
|
|
3271
3504
|
end
|
|
3272
3505
|
self
|
|
3273
3506
|
end
|
|
@@ -3330,8 +3563,8 @@ class PTypeAliasType < PAnyType
|
|
|
3330
3563
|
resolved_type.assignable?(o, guard)
|
|
3331
3564
|
end
|
|
3332
3565
|
|
|
3333
|
-
def new_function
|
|
3334
|
-
resolved_type.new_function
|
|
3566
|
+
def new_function
|
|
3567
|
+
resolved_type.new_function
|
|
3335
3568
|
end
|
|
3336
3569
|
|
|
3337
3570
|
private
|
|
@@ -3390,5 +3623,9 @@ require_relative 'p_type_set_type'
|
|
|
3390
3623
|
require_relative 'p_timespan_type'
|
|
3391
3624
|
require_relative 'p_timestamp_type'
|
|
3392
3625
|
require_relative 'p_binary_type'
|
|
3626
|
+
require_relative 'p_init_type'
|
|
3627
|
+
require_relative 'p_object_type_extension'
|
|
3628
|
+
require_relative 'p_uri_type'
|
|
3393
3629
|
require_relative 'type_set_reference'
|
|
3394
3630
|
require_relative 'implementation_registry'
|
|
3631
|
+
require_relative 'tree_iterators'
|