puppet 5.3.7-x64-mingw32 → 5.4.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (454) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +42 -29
  3. data/README.md +8 -6
  4. data/ext/cert_inspector +2 -2
  5. data/ext/envpuppet +1 -1
  6. data/ext/gentoo/init.d/puppetmaster +4 -4
  7. data/ext/ips/puppet-agent +11 -11
  8. data/ext/ips/puppet-master +11 -11
  9. data/ext/puppet-test +1 -2
  10. data/ext/redhat/client.init +2 -2
  11. data/ext/redhat/logrotate +1 -1
  12. data/ext/solaris/smf/puppet +11 -11
  13. data/ext/solaris/smf/svc-puppetd +5 -5
  14. data/ext/solaris/smf/svc-puppetmasterd +5 -5
  15. data/ext/windows/service/daemon.rb +1 -1
  16. data/install.rb +2 -3
  17. data/lib/puppet/agent.rb +1 -1
  18. data/lib/puppet/application/cert.rb +1 -3
  19. data/lib/puppet/application/describe.rb +0 -1
  20. data/lib/puppet/application/device.rb +12 -99
  21. data/lib/puppet/application/filebucket.rb +32 -11
  22. data/lib/puppet/application/lookup.rb +1 -11
  23. data/lib/puppet/application/script.rb +261 -0
  24. data/lib/puppet/configurer.rb +3 -4
  25. data/lib/puppet/configurer/plugin_handler.rb +26 -9
  26. data/lib/puppet/context.rb +1 -1
  27. data/lib/puppet/datatypes.rb +213 -0
  28. data/lib/puppet/datatypes/error.rb +21 -0
  29. data/lib/puppet/datatypes/impl/error.rb +40 -0
  30. data/lib/puppet/defaults.rb +51 -20
  31. data/lib/puppet/environments.rb +17 -0
  32. data/lib/puppet/error.rb +17 -0
  33. data/lib/puppet/etc.rb +2 -2
  34. data/lib/puppet/external/pson/pure/generator.rb +1 -1
  35. data/lib/puppet/external/pson/pure/parser.rb +1 -1
  36. data/lib/puppet/face/config.rb +45 -0
  37. data/lib/puppet/face/epp.rb +3 -3
  38. data/lib/puppet/face/help/action.erb +3 -0
  39. data/lib/puppet/face/module/build.rb +1 -0
  40. data/lib/puppet/face/module/generate.rb +5 -0
  41. data/lib/puppet/face/module/install.rb +1 -0
  42. data/lib/puppet/face/module/search.rb +6 -2
  43. data/lib/puppet/face/module/uninstall.rb +1 -0
  44. data/lib/puppet/face/module/upgrade.rb +1 -0
  45. data/lib/puppet/face/parser.rb +0 -1
  46. data/lib/puppet/face/plugin.rb +1 -3
  47. data/lib/puppet/feature/base.rb +1 -1
  48. data/lib/puppet/feature/bolt.rb +3 -0
  49. data/lib/puppet/file_bucket/dipper.rb +1 -2
  50. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  51. data/lib/puppet/file_system/uniquefile.rb +2 -2
  52. data/lib/puppet/forge.rb +6 -0
  53. data/lib/puppet/functions.rb +70 -88
  54. data/lib/puppet/functions/all.rb +6 -2
  55. data/lib/puppet/functions/annotate.rb +1 -1
  56. data/lib/puppet/functions/any.rb +7 -3
  57. data/lib/puppet/functions/contain.rb +6 -0
  58. data/lib/puppet/functions/convert_to.rb +32 -0
  59. data/lib/puppet/functions/defined.rb +0 -3
  60. data/lib/puppet/functions/each.rb +10 -6
  61. data/lib/puppet/functions/filter.rb +16 -10
  62. data/lib/puppet/functions/find_file.rb +0 -1
  63. data/lib/puppet/functions/include.rb +6 -0
  64. data/lib/puppet/functions/map.rb +12 -9
  65. data/lib/puppet/functions/module_directory.rb +41 -0
  66. data/lib/puppet/functions/new.rb +1 -4
  67. data/lib/puppet/functions/regsubst.rb +1 -1
  68. data/lib/puppet/functions/require.rb +6 -0
  69. data/lib/puppet/generate/type.rb +1 -1
  70. data/lib/puppet/gettext/config.rb +2 -2
  71. data/lib/puppet/gettext/stubs.rb +1 -1
  72. data/lib/puppet/indirector/catalog/compiler.rb +0 -1
  73. data/lib/puppet/indirector/file_bucket_file/file.rb +6 -2
  74. data/lib/puppet/indirector/file_server.rb +1 -1
  75. data/lib/puppet/indirector/node/ldap.rb +19 -3
  76. data/lib/puppet/indirector/request.rb +10 -6
  77. data/lib/puppet/indirector/rest.rb +11 -12
  78. data/lib/puppet/info_service/class_information_service.rb +1 -1
  79. data/lib/puppet/interface/action.rb +11 -0
  80. data/lib/puppet/interface/action_builder.rb +8 -0
  81. data/lib/puppet/interface/option_manager.rb +1 -1
  82. data/lib/puppet/loaders.rb +2 -0
  83. data/lib/puppet/module.rb +6 -2
  84. data/lib/puppet/module_tool/applications/builder.rb +4 -0
  85. data/lib/puppet/module_tool/applications/installer.rb +3 -0
  86. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
  87. data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  88. data/lib/puppet/module_tool/applications/upgrader.rb +3 -0
  89. data/lib/puppet/module_tool/installed_modules.rb +1 -1
  90. data/lib/puppet/module_tool/metadata.rb +0 -1
  91. data/lib/puppet/network/authstore.rb +1 -1
  92. data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  93. data/lib/puppet/network/http/connection.rb +1 -9
  94. data/lib/puppet/network/http/factory.rb +0 -3
  95. data/lib/puppet/network/http/webrick.rb +1 -0
  96. data/lib/puppet/network/rights.rb +1 -1
  97. data/lib/puppet/node.rb +53 -0
  98. data/lib/puppet/node/environment.rb +1 -1
  99. data/lib/puppet/parameter/boolean.rb +1 -1
  100. data/lib/puppet/parser.rb +1 -0
  101. data/lib/puppet/parser/abstract_compiler.rb +36 -0
  102. data/lib/puppet/parser/ast/branch.rb +1 -1
  103. data/lib/puppet/parser/ast/pops_bridge.rb +8 -52
  104. data/lib/puppet/parser/compiler.rb +4 -54
  105. data/lib/puppet/parser/functions.rb +0 -1
  106. data/lib/puppet/parser/functions/create_resources.rb +6 -0
  107. data/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
  108. data/lib/puppet/parser/functions/inline_template.rb +6 -0
  109. data/lib/puppet/parser/functions/new.rb +47 -32
  110. data/lib/puppet/parser/functions/realize.rb +6 -0
  111. data/lib/puppet/parser/functions/return.rb +1 -22
  112. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  113. data/lib/puppet/parser/functions/scanf.rb +1 -1
  114. data/lib/puppet/parser/functions/sha256.rb +5 -0
  115. data/lib/puppet/parser/functions/tag.rb +6 -0
  116. data/lib/puppet/parser/functions/tagged.rb +6 -0
  117. data/lib/puppet/parser/functions/template.rb +5 -0
  118. data/lib/puppet/parser/scope.rb +28 -4
  119. data/lib/puppet/parser/script_compiler.rb +118 -0
  120. data/lib/puppet/parser/type_loader.rb +1 -1
  121. data/lib/puppet/pops.rb +1 -1
  122. data/lib/puppet/pops/evaluator/access_operator.rb +38 -4
  123. data/lib/puppet/pops/evaluator/closure.rb +12 -4
  124. data/lib/puppet/pops/evaluator/compare_operator.rb +4 -4
  125. data/lib/puppet/pops/evaluator/epp_evaluator.rb +13 -0
  126. data/lib/puppet/pops/evaluator/evaluator_impl.rb +38 -10
  127. data/lib/puppet/pops/evaluator/literal_evaluator.rb +1 -1
  128. data/lib/puppet/pops/evaluator/runtime3_converter.rb +1 -1
  129. data/lib/puppet/pops/evaluator/runtime3_support.rb +2 -3
  130. data/lib/puppet/pops/functions/dispatch.rb +6 -5
  131. data/lib/puppet/pops/functions/function.rb +2 -2
  132. data/lib/puppet/pops/issues.rb +34 -2
  133. data/lib/puppet/pops/loader/base_loader.rb +10 -0
  134. data/lib/puppet/pops/loader/dependency_loader.rb +7 -0
  135. data/lib/puppet/pops/loader/loader.rb +21 -2
  136. data/lib/puppet/pops/loader/loader_paths.rb +180 -30
  137. data/lib/puppet/pops/loader/module_loaders.rb +202 -33
  138. data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
  139. data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +9 -9
  140. data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
  141. data/lib/puppet/pops/loader/runtime3_type_loader.rb +6 -1
  142. data/lib/puppet/pops/loader/static_loader.rb +23 -8
  143. data/lib/puppet/pops/loader/task_instantiator.rb +69 -0
  144. data/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -0
  145. data/lib/puppet/pops/loaders.rb +122 -11
  146. data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
  147. data/lib/puppet/pops/lookup/interpolation.rb +1 -1
  148. data/lib/puppet/pops/lookup/lookup_adapter.rb +0 -1
  149. data/lib/puppet/pops/model/ast.pp +3 -0
  150. data/lib/puppet/pops/model/ast.rb +34 -1
  151. data/lib/puppet/pops/model/factory.rb +30 -3
  152. data/lib/puppet/pops/model/model_label_provider.rb +1 -0
  153. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -1
  154. data/lib/puppet/pops/model/tree_dumper.rb +1 -1
  155. data/lib/puppet/pops/parser/code_merger.rb +2 -2
  156. data/lib/puppet/pops/parser/egrammar.ra +44 -15
  157. data/lib/puppet/pops/parser/eparser.rb +1687 -1571
  158. data/lib/puppet/pops/parser/epp_support.rb +1 -3
  159. data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
  160. data/lib/puppet/pops/parser/interpolation_support.rb +2 -2
  161. data/lib/puppet/pops/parser/lexer2.rb +4 -4
  162. data/lib/puppet/pops/parser/lexer_support.rb +2 -2
  163. data/lib/puppet/pops/parser/locatable.rb +1 -1
  164. data/lib/puppet/pops/parser/locator.rb +7 -13
  165. data/lib/puppet/pops/parser/parser_support.rb +3 -3
  166. data/lib/puppet/pops/parser/slurp_support.rb +0 -3
  167. data/lib/puppet/pops/pcore.rb +45 -0
  168. data/lib/puppet/pops/resource/param.rb +1 -1
  169. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  170. data/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
  171. data/lib/puppet/pops/serialization/abstract_writer.rb +6 -0
  172. data/lib/puppet/pops/serialization/extension.rb +1 -0
  173. data/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
  174. data/lib/puppet/pops/serialization/json_path.rb +2 -1
  175. data/lib/puppet/pops/serialization/object.rb +3 -4
  176. data/lib/puppet/pops/serialization/serializer.rb +2 -1
  177. data/lib/puppet/pops/serialization/to_data_converter.rb +7 -3
  178. data/lib/puppet/pops/time/timespan.rb +1 -1
  179. data/lib/puppet/pops/types/iterable.rb +38 -9
  180. data/lib/puppet/pops/types/p_init_type.rb +1 -1
  181. data/lib/puppet/pops/types/p_meta_type.rb +4 -0
  182. data/lib/puppet/pops/types/p_object_type.rb +146 -14
  183. data/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
  184. data/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
  185. data/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
  186. data/lib/puppet/pops/types/p_type_set_type.rb +0 -1
  187. data/lib/puppet/pops/types/p_uri_type.rb +190 -0
  188. data/lib/puppet/pops/types/puppet_object.rb +15 -1
  189. data/lib/puppet/pops/types/ruby_generator.rb +46 -54
  190. data/lib/puppet/pops/types/string_converter.rb +22 -1
  191. data/lib/puppet/pops/types/type_acceptor.rb +1 -1
  192. data/lib/puppet/pops/types/type_calculator.rb +13 -4
  193. data/lib/puppet/pops/types/type_factory.rb +29 -5
  194. data/lib/puppet/pops/types/type_formatter.rb +67 -4
  195. data/lib/puppet/pops/types/type_parser.rb +92 -4
  196. data/lib/puppet/pops/types/type_with_members.rb +43 -0
  197. data/lib/puppet/pops/types/types.rb +212 -80
  198. data/lib/puppet/pops/validation/checker4_0.rb +10 -6
  199. data/lib/puppet/pops/validation/tasks_checker.rb +60 -0
  200. data/lib/puppet/pops/validation/validator_factory_4_0.rb +6 -1
  201. data/lib/puppet/property.rb +1 -1
  202. data/lib/puppet/provider.rb +18 -8
  203. data/lib/puppet/provider/augeas/augeas.rb +3 -4
  204. data/lib/puppet/provider/exec.rb +0 -2
  205. data/lib/puppet/provider/group/groupadd.rb +25 -1
  206. data/lib/puppet/provider/group/windows_adsi.rb +7 -4
  207. data/lib/puppet/provider/mount.rb +25 -8
  208. data/lib/puppet/provider/nameservice.rb +9 -4
  209. data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
  210. data/lib/puppet/provider/nameservice/objectadd.rb +13 -24
  211. data/lib/puppet/provider/nameservice/pw.rb +14 -14
  212. data/lib/puppet/provider/package/appdmg.rb +0 -1
  213. data/lib/puppet/provider/package/apple.rb +0 -1
  214. data/lib/puppet/provider/package/gem.rb +2 -2
  215. data/lib/puppet/provider/package/macports.rb +2 -2
  216. data/lib/puppet/provider/package/pkg.rb +3 -0
  217. data/lib/puppet/provider/package/pkgdmg.rb +0 -1
  218. data/lib/puppet/provider/package/portage.rb +0 -1
  219. data/lib/puppet/provider/package/yum.rb +23 -8
  220. data/lib/puppet/provider/package/zypper.rb +2 -2
  221. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  222. data/lib/puppet/provider/service/init.rb +1 -0
  223. data/lib/puppet/provider/service/launchd.rb +6 -7
  224. data/lib/puppet/provider/service/redhat.rb +3 -2
  225. data/lib/puppet/provider/service/systemd.rb +2 -2
  226. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  227. data/lib/puppet/provider/user/aix.rb +3 -2
  228. data/lib/puppet/provider/user/openbsd.rb +1 -1
  229. data/lib/puppet/provider/user/pw.rb +1 -1
  230. data/lib/puppet/provider/user/user_role_add.rb +7 -1
  231. data/lib/puppet/provider/user/useradd.rb +36 -6
  232. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  233. data/lib/puppet/provider/yumrepo/inifile.rb +2 -4
  234. data/lib/puppet/provider/zfs/zfs.rb +23 -3
  235. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  236. data/lib/puppet/reference/configuration.rb +0 -2
  237. data/lib/puppet/reference/type.rb +0 -1
  238. data/lib/puppet/resource.rb +1 -2
  239. data/lib/puppet/resource/catalog.rb +1 -1
  240. data/lib/puppet/resource/status.rb +0 -1
  241. data/lib/puppet/resource/type.rb +4 -4
  242. data/lib/puppet/resource/type_collection.rb +1 -1
  243. data/lib/puppet/settings/base_setting.rb +1 -1
  244. data/lib/puppet/settings/environment_conf.rb +0 -1
  245. data/lib/puppet/settings/ini_file.rb +66 -12
  246. data/lib/puppet/ssl/certificate_authority.rb +1 -1
  247. data/lib/puppet/ssl/certificate_request.rb +2 -2
  248. data/lib/puppet/ssl/certificate_revocation_list.rb +2 -1
  249. data/lib/puppet/ssl/certificate_signer.rb +11 -0
  250. data/lib/puppet/ssl/host.rb +2 -2
  251. data/lib/puppet/syntax_checkers/base64.rb +1 -1
  252. data/lib/puppet/transaction.rb +37 -14
  253. data/lib/puppet/transaction/report.rb +3 -1
  254. data/lib/puppet/type.rb +17 -4
  255. data/lib/puppet/type/cron.rb +1 -1
  256. data/lib/puppet/type/exec.rb +5 -4
  257. data/lib/puppet/type/file.rb +3 -3
  258. data/lib/puppet/type/file/checksum.rb +7 -1
  259. data/lib/puppet/type/file/checksum_value.rb +4 -3
  260. data/lib/puppet/type/group.rb +3 -0
  261. data/lib/puppet/type/k5login.rb +101 -0
  262. data/lib/puppet/type/macauthorization.rb +1 -1
  263. data/lib/puppet/type/mount.rb +6 -2
  264. data/lib/puppet/type/tidy.rb +6 -4
  265. data/lib/puppet/type/user.rb +26 -39
  266. data/lib/puppet/type/yumrepo.rb +9 -0
  267. data/lib/puppet/type/zfs.rb +4 -0
  268. data/lib/puppet/util.rb +8 -15
  269. data/lib/puppet/util/character_encoding.rb +2 -2
  270. data/lib/puppet/util/checksums.rb +82 -1
  271. data/lib/puppet/util/errors.rb +0 -2
  272. data/lib/puppet/util/filetype.rb +2 -2
  273. data/lib/puppet/util/json_lockfile.rb +1 -1
  274. data/lib/puppet/util/log.rb +1 -1
  275. data/lib/puppet/util/log/destinations.rb +10 -1
  276. data/lib/puppet/util/monkey_patches.rb +1 -1
  277. data/lib/puppet/util/network_device/cisco/device.rb +5 -5
  278. data/lib/puppet/util/network_device/config.rb +2 -3
  279. data/lib/puppet/util/platform.rb +13 -0
  280. data/lib/puppet/util/plist.rb +4 -4
  281. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
  282. data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
  283. data/lib/puppet/util/reference.rb +8 -1
  284. data/lib/puppet/util/windows/adsi.rb +18 -15
  285. data/lib/puppet/util/windows/principal.rb +6 -7
  286. data/lib/puppet/util/windows/process.rb +1 -1
  287. data/lib/puppet/util/windows/registry.rb +2 -2
  288. data/lib/puppet/util/windows/sid.rb +7 -62
  289. data/lib/puppet/vendor/deep_merge/README.md +2 -2
  290. data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +18 -18
  291. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +2 -2
  292. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +5 -5
  293. data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +1 -1
  294. data/lib/puppet/version.rb +1 -1
  295. data/lib/puppet_pal.rb +874 -0
  296. data/locales/ja/puppet.po +140 -163
  297. data/locales/puppet.pot +940 -597
  298. data/man/man5/puppet.conf.5 +16 -91
  299. data/man/man8/puppet-agent.8 +2 -6
  300. data/man/man8/puppet-apply.8 +2 -2
  301. data/man/man8/puppet-ca.8 +1 -1
  302. data/man/man8/puppet-catalog.8 +1 -1
  303. data/man/man8/puppet-cert.8 +1 -1
  304. data/man/man8/puppet-certificate.8 +1 -1
  305. data/man/man8/puppet-certificate_request.8 +1 -1
  306. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  307. data/man/man8/puppet-config.8 +1 -1
  308. data/man/man8/puppet-describe.8 +1 -1
  309. data/man/man8/puppet-device.8 +11 -33
  310. data/man/man8/puppet-doc.8 +1 -1
  311. data/man/man8/puppet-epp.8 +1 -1
  312. data/man/man8/puppet-facts.8 +1 -1
  313. data/man/man8/puppet-filebucket.8 +4 -22
  314. data/man/man8/puppet-generate.8 +1 -1
  315. data/man/man8/puppet-help.8 +1 -1
  316. data/man/man8/puppet-key.8 +1 -1
  317. data/man/man8/puppet-lookup.8 +1 -1
  318. data/man/man8/puppet-man.8 +1 -1
  319. data/man/man8/puppet-master.8 +1 -1
  320. data/man/man8/puppet-module.8 +2 -11
  321. data/man/man8/puppet-node.8 +1 -1
  322. data/man/man8/puppet-parser.8 +1 -1
  323. data/man/man8/puppet-plugin.8 +1 -1
  324. data/man/man8/puppet-report.8 +1 -1
  325. data/man/man8/puppet-resource.8 +1 -1
  326. data/man/man8/puppet-status.8 +1 -1
  327. data/man/man8/puppet.8 +2 -2
  328. data/spec/integration/application/lookup_spec.rb +0 -21
  329. data/spec/integration/parser/compiler_spec.rb +18 -0
  330. data/spec/integration/parser/script_compiler_spec.rb +113 -0
  331. data/spec/integration/provider/mount_spec.rb +2 -0
  332. data/spec/integration/type/file_spec.rb +11 -3
  333. data/spec/integration/util/windows/adsi_spec.rb +1 -86
  334. data/spec/integration/util/windows/principal_spec.rb +1 -10
  335. data/spec/shared_contexts/checksum.rb +4 -1
  336. data/spec/shared_contexts/digests.rb +46 -1
  337. data/spec/shared_contexts/types_setup.rb +8 -3
  338. data/spec/unit/agent_spec.rb +2 -2
  339. data/spec/unit/application/cert_spec.rb +5 -17
  340. data/spec/unit/application/device_spec.rb +2 -96
  341. data/spec/unit/application/filebucket_spec.rb +18 -4
  342. data/spec/unit/configurer/plugin_handler_spec.rb +5 -32
  343. data/spec/unit/configurer_spec.rb +3 -3
  344. data/spec/unit/datatypes_spec.rb +304 -0
  345. data/spec/unit/defaults_spec.rb +41 -20
  346. data/spec/unit/face/config_spec.rb +46 -1
  347. data/spec/unit/face/epp_face_spec.rb +7 -3
  348. data/spec/unit/face/module/search_spec.rb +11 -0
  349. data/spec/unit/face/parser_spec.rb +2 -2
  350. data/spec/unit/file_bucket/dipper_spec.rb +12 -1
  351. data/spec/unit/forge/module_release_spec.rb +70 -0
  352. data/spec/unit/functions/break_spec.rb +34 -2
  353. data/spec/unit/functions/contain_spec.rb +1 -0
  354. data/spec/unit/functions/convert_to_spec.rb +22 -0
  355. data/spec/unit/functions/epp_spec.rb +5 -0
  356. data/spec/unit/functions/include_spec.rb +15 -0
  357. data/spec/unit/functions/module_directory_spec.rb +43 -0
  358. data/spec/unit/functions/new_spec.rb +14 -14
  359. data/spec/unit/functions/require_spec.rb +2 -0
  360. data/spec/unit/functions/shared.rb +12 -0
  361. data/spec/unit/functions/step_spec.rb +1 -1
  362. data/spec/unit/functions4_spec.rb +49 -4
  363. data/spec/unit/indirector/catalog/compiler_spec.rb +3 -3
  364. data/spec/unit/indirector/file_bucket_file/file_spec.rb +148 -94
  365. data/spec/unit/indirector/node/ldap_spec.rb +15 -12
  366. data/spec/unit/indirector/rest_spec.rb +0 -43
  367. data/spec/unit/interface/action_spec.rb +33 -0
  368. data/spec/unit/module_tool/applications/builder_spec.rb +7 -0
  369. data/spec/unit/module_tool/applications/installer_spec.rb +8 -0
  370. data/spec/unit/module_tool/applications/uninstaller_spec.rb +8 -0
  371. data/spec/unit/module_tool/applications/upgrader_spec.rb +6 -0
  372. data/spec/unit/network/http/connection_spec.rb +1 -1
  373. data/spec/unit/network/http/factory_spec.rb +28 -35
  374. data/spec/unit/parser/compiler_spec.rb +0 -8
  375. data/spec/unit/parser/environment_compiler_spec.rb +36 -0
  376. data/spec/unit/parser/functions/create_resources_spec.rb +9 -0
  377. data/spec/unit/parser/functions/inline_template_spec.rb +7 -0
  378. data/spec/unit/parser/functions/realize_spec.rb +9 -0
  379. data/spec/unit/parser/functions/tag_spec.rb +7 -0
  380. data/spec/unit/parser/functions/tagged_spec.rb +25 -0
  381. data/spec/unit/parser/functions/template_spec.rb +8 -0
  382. data/spec/unit/parser/scope_spec.rb +19 -0
  383. data/spec/unit/pops/evaluator/conditionals_spec.rb +1 -1
  384. data/spec/unit/pops/loaders/loader_spec.rb +516 -0
  385. data/spec/unit/pops/loaders/loaders_spec.rb +11 -0
  386. data/spec/unit/pops/loaders/module_loaders_spec.rb +43 -0
  387. data/spec/unit/pops/loaders/static_loader_spec.rb +15 -7
  388. data/spec/unit/pops/model/model_spec.rb +5 -0
  389. data/spec/unit/pops/parser/lexer2_spec.rb +15 -0
  390. data/spec/unit/pops/parser/locator_spec.rb +20 -0
  391. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +33 -0
  392. data/spec/unit/pops/parser/parse_calls_spec.rb +28 -0
  393. data/spec/unit/pops/parser/parse_conditionals_spec.rb +12 -0
  394. data/spec/unit/pops/parser/parse_plan_spec.rb +48 -0
  395. data/spec/unit/pops/serialization/packer_spec.rb +8 -0
  396. data/spec/unit/pops/serialization/serialization_spec.rb +30 -0
  397. data/spec/unit/pops/serialization/to_from_hr_spec.rb +31 -0
  398. data/spec/unit/pops/types/error_spec.rb +207 -0
  399. data/spec/unit/pops/types/p_init_type_spec.rb +98 -0
  400. data/spec/unit/pops/types/p_object_type_spec.rb +275 -10
  401. data/spec/unit/pops/types/p_uri_type_spec.rb +191 -0
  402. data/spec/unit/pops/types/ruby_generator_spec.rb +82 -44
  403. data/spec/unit/pops/types/task_spec.rb +353 -0
  404. data/spec/unit/pops/types/type_calculator_spec.rb +76 -5
  405. data/spec/unit/pops/types/type_formatter_spec.rb +31 -13
  406. data/spec/unit/pops/types/type_parser_spec.rb +13 -1
  407. data/spec/unit/pops/types/types_spec.rb +60 -0
  408. data/spec/unit/pops/validator/validator_spec.rb +76 -0
  409. data/spec/unit/provider/group/groupadd_spec.rb +77 -1
  410. data/spec/unit/provider/group/pw_spec.rb +4 -4
  411. data/spec/unit/provider/group/windows_adsi_spec.rb +22 -79
  412. data/spec/unit/provider/mount_spec.rb +18 -5
  413. data/spec/unit/provider/nameservice_spec.rb +5 -5
  414. data/spec/unit/provider/package/dnf_spec.rb +2 -2
  415. data/spec/unit/provider/package/gem_spec.rb +1 -1
  416. data/spec/unit/provider/package/pkg_spec.rb +3 -0
  417. data/spec/unit/provider/package/yum_spec.rb +40 -0
  418. data/spec/unit/provider/service/launchd_spec.rb +2 -1
  419. data/spec/unit/provider/service/redhat_spec.rb +5 -0
  420. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  421. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  422. data/spec/unit/provider/user/openbsd_spec.rb +2 -2
  423. data/spec/unit/provider/user/pw_spec.rb +14 -14
  424. data/spec/unit/provider/user/user_role_add_spec.rb +19 -2
  425. data/spec/unit/provider/user/useradd_spec.rb +188 -22
  426. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  427. data/spec/unit/provider/zfs/zfs_spec.rb +55 -1
  428. data/spec/unit/provider_spec.rb +48 -0
  429. data/spec/unit/puppet_pal_2pec.rb +1005 -0
  430. data/spec/unit/puppet_pal_spec.rb +11 -0
  431. data/spec/unit/settings/ini_file_spec.rb +313 -2
  432. data/spec/unit/ssl/certificate_request_spec.rb +42 -1
  433. data/spec/unit/ssl/certificate_revocation_list_spec.rb +2 -1
  434. data/spec/unit/transaction/report_spec.rb +1 -0
  435. data/spec/unit/transaction_spec.rb +112 -21
  436. data/spec/unit/type/file/checksum_spec.rb +20 -0
  437. data/spec/unit/type/file_spec.rb +8 -0
  438. data/spec/unit/type/group_spec.rb +8 -0
  439. data/spec/unit/type/k5login_spec.rb +22 -1
  440. data/spec/unit/type/scheduled_task_spec.rb +15 -0
  441. data/spec/unit/type/user_spec.rb +11 -1
  442. data/spec/unit/type/yumrepo_spec.rb +5 -0
  443. data/spec/unit/util/checksums_spec.rb +3 -3
  444. data/spec/unit/util/log/destinations_spec.rb +14 -0
  445. data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
  446. data/spec/unit/util/plist_spec.rb +3 -3
  447. data/spec/unit/util/windows/adsi_spec.rb +27 -31
  448. data/spec/unit/util/windows/sid_spec.rb +15 -86
  449. data/spec/unit/util_spec.rb +17 -3
  450. data/tasks/manpages.rake +1 -1
  451. metadata +220 -182
  452. data/lib/puppet/bindings.rb +0 -148
  453. data/lib/puppet/configurer/downloader_factory.rb +0 -44
  454. data/spec/unit/configurer/downloader_factory_spec.rb +0 -129
@@ -7,6 +7,12 @@ Puppet::Parser::Functions::newfunction(:realize, :arity => -2, :doc => "Make a v
7
7
  and, of course, is a bit shorter. You must pass the object using a
8
8
  reference; e.g.: `realize User[luke]`." ) do |vals|
9
9
 
10
+ if Puppet[:tasks]
11
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
12
+ Puppet::Pops::Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING,
13
+ {:operation => 'realize'})
14
+ end
15
+
10
16
  vals = [vals] unless vals.is_a?(Array)
11
17
 
12
18
  coll = Puppet::Pops::Evaluator::Collectors::FixedSetCollector.new(self, vals.flatten)
@@ -4,8 +4,7 @@ Puppet::Parser::Functions::newfunction(
4
4
  :doc => <<-DOC
5
5
  Immediately returns the given optional value from a function, class body or user defined type body.
6
6
  If a value is not given, an `undef` value is returned. This function does not return to the immediate caller.
7
- If this function is called from within a lambda, the return action is from the scope of the
8
- function containing the lambda (top scope), not the function accepting the lambda (local scope).
7
+ If called from within a lambda the return will return from the function evaluating the lambda.
9
8
 
10
9
  The signal produced to return a value bubbles up through
11
10
  the call stack until reaching a function, class definition or
@@ -64,26 +63,6 @@ The code would notice `'bar'` but not `'foo'`
64
63
 
65
64
  Note that the returned value is ignored if used in a class or user defined type.
66
65
 
67
- **Example:** Using `return` in a lambda
68
-
69
- ```puppet
70
- # Concatenate three strings into a single string formatted as a list.
71
- function getFruit() {
72
- with("apples", "oranges", "bananas") |$x, $y, $z| {
73
- return("${x}, ${y}, and ${z}")
74
- }
75
- notice "not reached"
76
- }
77
- $fruit = getFruit()
78
- notice $fruit
79
-
80
- # The output contains "apples, oranges, and bananas".
81
- # "not reached" is not output because the function returns its value within the
82
- # calling function's scope, which stops processing the calling function before
83
- # the `notice "not reached"` statement.
84
- # Using `return()` outside of a calling function results in an error.
85
- ```
86
-
87
66
  * Also see functions `return` and `break`
88
67
  * Since 4.8.0
89
68
  DOC
@@ -40,7 +40,7 @@ $reverse_data = reverse_each($data)
40
40
  When no second argument is present, Puppet returns an `Iterable` that represents the reverse
41
41
  order of its first argument. This allows methods on `Iterable` to be chained.
42
42
 
43
- When a lamdba is given as the second argument, Puppet iterates the first argument in reverse
43
+ When a lambda is given as the second argument, Puppet iterates the first argument in reverse
44
44
  order and passes each value in turn to the lambda, then returns `undef`.
45
45
 
46
46
  **Example:** Using the `reverse_each` function with an array and a one-parameter lambda
@@ -34,5 +34,5 @@ DOC
34
34
  ) do |args|
35
35
  data = args[0]
36
36
  format = args[1]
37
- result = data.scanf(format)
37
+ data.scanf(format)
38
38
  end
@@ -0,0 +1,5 @@
1
+ require 'digest/sha2'
2
+
3
+ Puppet::Parser::Functions::newfunction(:sha256, :type => :rvalue, :arity => 1, :doc => "Returns a SHA256 hash value from a provided string.") do |args|
4
+ Digest::SHA256.hexdigest(args[0])
5
+ end
@@ -2,5 +2,11 @@
2
2
  Puppet::Parser::Functions::newfunction(:tag, :arity => -2, :doc => "Add the specified tags to the containing class
3
3
  or definition. All contained objects will then acquire that tag, also.
4
4
  ") do |vals|
5
+ if Puppet[:tasks]
6
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
7
+ Puppet::Pops::Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING,
8
+ {:operation => 'tag'})
9
+ end
10
+
5
11
  self.resource.tag(*vals)
6
12
  end
@@ -3,6 +3,12 @@ Puppet::Parser::Functions::newfunction(:tagged, :type => :rvalue, :arity => -2,
3
3
  tells you whether the current container is tagged with the specified tags.
4
4
  The tags are ANDed, so that all of the specified tags must be included for
5
5
  the function to return true.") do |vals|
6
+ if Puppet[:tasks]
7
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
8
+ Puppet::Pops::Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING,
9
+ {:operation => 'tagged'})
10
+ end
11
+
6
12
  configtags = compiler.catalog.tags
7
13
  resourcetags = resource.tags
8
14
 
@@ -12,6 +12,11 @@ Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :arity => -2
12
12
  * An absolute path, which can load a template file from anywhere on disk.
13
13
  * Multiple arguments, which will evaluate all of the specified templates and
14
14
  return their outputs concatenated into a single string.") do |vals|
15
+ if Puppet[:tasks]
16
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
17
+ Puppet::Pops::Issues::FEATURE_NOT_SUPPORTED_WHEN_SCRIPTING,
18
+ {:feature => 'ERB template'})
19
+ end
15
20
  vals.collect do |file|
16
21
  # Use a wrapper, so the template can't get access to the full
17
22
  # Scope object.
@@ -375,7 +375,7 @@ class Puppet::Parser::Scope
375
375
 
376
376
  # Initialize our new scope. Defaults to having no parent.
377
377
  def initialize(compiler, options = EMPTY_HASH)
378
- if compiler.is_a? Puppet::Parser::Compiler
378
+ if compiler.is_a? Puppet::Parser::AbstractCompiler
379
379
  @compiler = compiler
380
380
  else
381
381
  raise Puppet::DevError, _("you must pass a compiler instance to a new scope object")
@@ -708,7 +708,8 @@ class Puppet::Parser::Scope
708
708
 
709
709
  # Merge all settings for the given _env_name_ into this scope
710
710
  # @param env_name [Symbol] the name of the environment
711
- def merge_settings(env_name)
711
+ # @param set_in_this_scope [Boolean] if the settings variables should also be set in this instance of scope
712
+ def merge_settings(env_name, set_in_this_scope=true)
712
713
  settings = Puppet.settings
713
714
  table = effective_symtable(false)
714
715
  global_table = compiler.qualified_variables
@@ -717,7 +718,9 @@ class Puppet::Parser::Scope
717
718
  next if :name == name
718
719
  key = name.to_s
719
720
  value = transform_setting(settings.value_sym(name, env_name))
720
- table[key] = value
721
+ if set_in_this_scope
722
+ table[key] = value
723
+ end
721
724
  all_local[key] = value
722
725
  # also write the fqn into global table for direct lookup
723
726
  global_table["settings::#{key}"] = value
@@ -868,7 +871,25 @@ class Puppet::Parser::Scope
868
871
 
869
872
  # Used mainly for logging
870
873
  def to_s
871
- "Scope(#{@resource})"
874
+ # As this is used for logging, this should really not be done in this class at all...
875
+ return "Scope(#{@resource})" unless @resource.nil?
876
+
877
+ # For logging of function-scope - it is now showing the file and line.
878
+ detail = Puppet::Pops::PuppetStack.stacktrace[0]
879
+ return "Scope()" unless detail.is_a?(Array)
880
+
881
+ # shorten the path if possible
882
+ path = detail[0]
883
+ env_path = nil
884
+ env_path = environment.configuration.path_to_env unless (environment.nil? || environment.configuration.nil?)
885
+ # check module paths first since they may be in the environment (i.e. they are longer)
886
+ if module_path = environment.full_modulepath.detect {|m_path| path.start_with?(m_path) }
887
+ path = "<module>" + path[module_path.length..-1]
888
+ elsif env_path && path && path.start_with?(env_path)
889
+ path = "<env>" + path[env_path.length..-1]
890
+ end
891
+ # Make the output appear as "Scope(path, line)"
892
+ "Scope(#{[path, detail[1]].join(', ')})"
872
893
  end
873
894
 
874
895
  alias_method :inspect, :to_s
@@ -1045,7 +1066,10 @@ class Puppet::Parser::Scope
1045
1066
  def transform_and_assert_classnames(names)
1046
1067
  names.map do |name|
1047
1068
  case name
1069
+ when NilClass
1070
+ raise ArgumentError, _("Cannot use undef as a class name")
1048
1071
  when String
1072
+ raise ArgumentError, _("Cannot use empty string as a class name") if name.empty?
1049
1073
  name.sub(/^([^:]{1,2})/, '::\1')
1050
1074
 
1051
1075
  when Puppet::Resource
@@ -0,0 +1,118 @@
1
+ require 'puppet/loaders'
2
+ require 'puppet/pops'
3
+
4
+ # A Script "compiler" that does not support catalog operations
5
+ #
6
+ # The Script compiler is "one shot" - it does not support rechecking if underlying source has changed or
7
+ # deal with possible errors in a cached environment.
8
+ #
9
+ class Puppet::Parser::ScriptCompiler
10
+ # Allows the ScriptCompiler to use the 3.x Scope class without being an actual "Compiler"
11
+ #
12
+ include Puppet::Parser::AbstractCompiler
13
+
14
+ # @api private
15
+ attr_reader :topscope
16
+
17
+ # @api private
18
+ attr_reader :qualified_variables
19
+
20
+ # Access to the configured loaders for 4x
21
+ # @return [Puppet::Pops::Loader::Loaders] the configured loaders
22
+ # @api private
23
+ attr_reader :loaders
24
+
25
+ # @api private
26
+ attr_reader :environment
27
+
28
+ # @api private
29
+ attr_reader :node_name
30
+
31
+ def with_context_overrides(description = '', &block)
32
+ Puppet.override( @context_overrides , description, &block)
33
+ end
34
+
35
+ # Evaluates the configured setup for a script + code in an environment with modules
36
+ #
37
+ def compile
38
+ Puppet[:strict_variables] = true
39
+ Puppet[:strict] = :error
40
+
41
+ # TRANSLATORS, "For running script" is not user facing
42
+ Puppet.override( @context_overrides , "For running script") do
43
+
44
+ #TRANSLATORS "main" is a function name and should not be translated
45
+ result = Puppet::Util::Profiler.profile(_("Script: Evaluated main"), [:script, :evaluate_main]) { evaluate_main }
46
+ if block_given?
47
+ yield self
48
+ else
49
+ result
50
+ end
51
+ end
52
+
53
+ rescue Puppet::ParseErrorWithIssue => detail
54
+ detail.node = node_name
55
+ Puppet.log_exception(detail)
56
+ raise
57
+ rescue => detail
58
+ message = "#{detail} on node #{node_name}"
59
+ Puppet.log_exception(detail, message)
60
+ raise Puppet::Error, message, detail.backtrace
61
+ end
62
+
63
+ # Constructs the overrides for the context
64
+ def context_overrides()
65
+ {
66
+ :current_environment => environment,
67
+ :global_scope => @topscope, # 4x placeholder for new global scope
68
+ :loaders => @loaders, # 4x loaders
69
+ }
70
+ end
71
+
72
+ # Create a script compiler for the given environment where errors are logged as coming
73
+ # from the given node_name
74
+ #
75
+ def initialize(environment, node_name)
76
+ @environment = environment
77
+ @node_name = node_name
78
+
79
+ # Create the initial scope, it is needed early
80
+ @topscope = Puppet::Parser::Scope.new(self)
81
+
82
+ # Initialize loaders and Pcore
83
+ @loaders = Puppet::Pops::Loaders.new(environment)
84
+
85
+ # Need to compute overrides here, and remember them, because we are about to
86
+ # Expensive entries in the context are bound lazily.
87
+ @context_overrides = context_overrides()
88
+
89
+ # Resolutions of fully qualified variable names
90
+ @qualified_variables = {}
91
+ end
92
+
93
+ # Having multiple named scopes hanging from top scope is not supported when scripting
94
+ # in the regular compiler this is used to create one named scope per class.
95
+ # When scripting, the "main class" is just a container of the top level code to evaluate
96
+ # and it is not evaluated as a class added to a catalog. Since classes are not supported
97
+ # there is no need to support the concept of "named scopes" as all variables are local
98
+ # or in the top scope itself (notably, the $settings:: namespace is initialized
99
+ # as just a set of variables in that namespace - there is no named scope for 'settings'
100
+ # when scripting.
101
+ #
102
+ # Keeping this method here to get specific error as being unsure if there are functions/logic
103
+ # that will call this. The AbstractCompiler defines this method, but maybe it does not
104
+ # have to (TODO).
105
+ #
106
+ def newscope(parent, options = {})
107
+ raise _('having multiple named scopes is not supported when scripting')
108
+ end
109
+
110
+ private
111
+
112
+ # Find and evaluate the top level code.
113
+ def evaluate_main
114
+ @loaders.pre_load
115
+ program = @loaders.load_main_manifest
116
+ return program.nil? ? nil : Puppet::Pops::Parser::EvaluatingParser.singleton.evaluator.evaluate(program, @topscope)
117
+ end
118
+ end
@@ -70,7 +70,7 @@ class Puppet::Parser::TypeLoader
70
70
  Puppet.debug {"Automatically imported #{fqname} from #{filename} into #{environment}"}
71
71
  return result
72
72
  end
73
- rescue TypeLoaderError => detail
73
+ rescue TypeLoaderError
74
74
  # I'm not convinced we should just drop these errors, but this
75
75
  # preserves existing behaviours.
76
76
  end
@@ -113,8 +113,8 @@ module Puppet
113
113
  end
114
114
 
115
115
  require 'puppet/parser/ast/pops_bridge'
116
- require 'puppet/bindings'
117
116
  require 'puppet/functions'
117
+ require 'puppet/datatypes'
118
118
 
119
119
  Puppet::Pops::Model.register_pcore_types
120
120
  end
@@ -27,6 +27,11 @@ class AccessOperator
27
27
  protected
28
28
 
29
29
  def access_Object(o, scope, keys)
30
+ type = Puppet::Pops::Types::TypeCalculator.infer(o)
31
+ if type.is_a?(Puppet::Pops::Types::TypeWithMembers)
32
+ access_func = type['[]']
33
+ return access_func.invoke(o, scope, keys) unless access_func.nil?
34
+ end
30
35
  fail(Issues::OPERATOR_NOT_APPLICABLE, @semantic.left_expr, :operator=>'[]', :left_value => o)
31
36
  end
32
37
 
@@ -144,10 +149,22 @@ class AccessOperator
144
149
  end
145
150
  end
146
151
 
152
+ def access_PBooleanType(o, scope, keys)
153
+ keys.flatten!
154
+ assert_keys(keys, o, 1, 1, TrueClass, FalseClass)
155
+ Types::TypeFactory.boolean(keys[0])
156
+ end
157
+
147
158
  def access_PEnumType(o, scope, keys)
148
159
  keys.flatten!
160
+ last = keys.last
161
+ case_insensitive = false
162
+ if last == true || last == false
163
+ keys = keys[0...-1]
164
+ case_insensitive = last
165
+ end
149
166
  assert_keys(keys, o, 1, Float::INFINITY, String)
150
- Types::TypeFactory.enum(*keys)
167
+ Types::PEnumType.new(keys, case_insensitive)
151
168
  end
152
169
 
153
170
  def access_PVariantType(o, scope, keys)
@@ -278,6 +295,19 @@ class AccessOperator
278
295
  Types::TypeFactory.pattern(*keys)
279
296
  end
280
297
 
298
+ def access_PURIType(o, scope, keys)
299
+ keys.flatten!
300
+ if keys.size == 1
301
+ param = keys[0]
302
+ unless Types::PURIType::TYPE_URI_PARAM_TYPE.instance?(param)
303
+ fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'URI-Type', :actual => param.class})
304
+ end
305
+ Types::PURIType.new(param)
306
+ else
307
+ fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'URI-Type', :min => 1, :actual => keys.size})
308
+ end
309
+ end
310
+
281
311
  def access_POptionalType(o, scope, keys)
282
312
  keys.flatten!
283
313
  if keys.size == 1
@@ -310,10 +340,14 @@ class AccessOperator
310
340
 
311
341
  def access_PObjectType(o, scope, keys)
312
342
  keys.flatten!
313
- if keys.size == 1
314
- Types::TypeFactory.object(keys[0])
343
+ if o.resolved? && !o.name.nil?
344
+ Types::PObjectTypeExtension.create(o, keys)
315
345
  else
316
- fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Object-Type', :min => 1, :actual => keys.size})
346
+ if keys.size == 1
347
+ Types::TypeFactory.object(keys[0])
348
+ else
349
+ fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Object-Type', :min => 1, :actual => keys.size})
350
+ end
317
351
  end
318
352
  end
319
353
 
@@ -78,13 +78,20 @@ class Closure < CallableSignature
78
78
  end
79
79
  end
80
80
 
81
- # Call closure with argument assignment by name
81
+ def call_by_name_with_scope(scope, args_hash, enforce_parameters)
82
+ call_by_name_internal(scope, args_hash, enforce_parameters)
83
+ end
84
+
82
85
  def call_by_name(args_hash, enforce_parameters)
83
- closure_scope = enclosing_scope
86
+ call_by_name_internal(enclosing_scope, args_hash, enforce_parameters)
87
+ end
88
+
89
+ # Call closure with argument assignment by name
90
+ def call_by_name_internal(closure_scope, args_hash, enforce_parameters)
84
91
  if enforce_parameters
85
92
  # Push a temporary parameter scope used while resolving the parameter defaults
86
93
  closure_scope.with_parameter_scope(closure_name, parameter_names) do |param_scope|
87
- # Assign all non-nil values, even those that represent non-existent paramaters.
94
+ # Assign all non-nil values, even those that represent non-existent parameters.
88
95
  args_hash.each { |k, v| param_scope[k] = v unless v.nil? }
89
96
  parameters.each do |p|
90
97
  name = p.name
@@ -112,6 +119,7 @@ class Closure < CallableSignature
112
119
  @evaluator.evaluate_block_with_bindings(closure_scope, args_hash, @model.body)
113
120
  end
114
121
  end
122
+ private :call_by_name_internal
115
123
 
116
124
  def parameters
117
125
  @model.parameters
@@ -310,7 +318,7 @@ class Closure < CallableSignature
310
318
  closure_scope = enclosing_scope
311
319
 
312
320
  parameters.each do |param|
313
- arg_type, param_range = create_param_type(param, closure_scope)
321
+ arg_type, _ = create_param_type(param, closure_scope)
314
322
  key_type = type_factory.string(param.name.to_s)
315
323
  key_type = type_factory.optional(key_type) unless param.value.nil?
316
324
  members[key_type] = arg_type
@@ -34,7 +34,7 @@ class CompareOperator
34
34
  end
35
35
 
36
36
  # Performs a match of a and b, and returns true if b matches a
37
- def match(a, b, scope)
37
+ def match(a, b, scope = nil)
38
38
  @@match_visitor.visit_this_2(self, b, a, scope)
39
39
  end
40
40
 
@@ -133,7 +133,7 @@ class CompareOperator
133
133
  def include_String(a, b, scope)
134
134
  case b
135
135
  when String
136
- # subsstring search downcased
136
+ # substring search downcased
137
137
  a.downcase.include?(b.downcase)
138
138
  when Regexp
139
139
  matched = a.match(b) # nil, or MatchData
@@ -200,7 +200,7 @@ class CompareOperator
200
200
  def match_Regexp(regexp, left, scope)
201
201
  return false unless left.is_a? String
202
202
  matched = regexp.match(left)
203
- set_match_data(matched, scope) # creates or clears ephemeral
203
+ set_match_data(matched, scope) unless scope.nil? # creates or clears ephemeral
204
204
  !!matched # convert to boolean
205
205
  end
206
206
 
@@ -245,7 +245,7 @@ class CompareOperator
245
245
 
246
246
  def match_Symbol(symbol, left, scope)
247
247
  return true if symbol == :default
248
- equals(left, default, scope)
248
+ equals(left, default)
249
249
  end
250
250
  end
251
251
  end