puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-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 (342) hide show
  1. data/CONTRIBUTING.md +5 -0
  2. data/Gemfile +17 -9
  3. data/README.md +1 -0
  4. data/conf/fileserver.conf +4 -3
  5. data/ext/README.environment +8 -0
  6. data/ext/build_defaults.yaml +1 -1
  7. data/ext/debian/control +2 -2
  8. data/ext/debian/puppet-common.dirs +4 -0
  9. data/ext/debian/rules +4 -0
  10. data/ext/emacs/puppet-mode-init.el +1 -1
  11. data/ext/emacs/puppet-mode.el +36 -17
  12. data/ext/redhat/client.init +3 -3
  13. data/ext/redhat/puppet.spec.erb +9 -0
  14. data/ext/systemd/puppet.service +3 -4
  15. data/ext/systemd/puppetmaster.service +1 -3
  16. data/install.rb +1 -1
  17. data/lib/puppet.rb +2 -1
  18. data/lib/puppet/agent.rb +1 -1
  19. data/lib/puppet/application.rb +17 -17
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/configurer.rb +4 -1
  22. data/lib/puppet/configurer/downloader.rb +13 -12
  23. data/lib/puppet/configurer/plugin_handler.rb +3 -3
  24. data/lib/puppet/context.rb +6 -1
  25. data/lib/puppet/defaults.rb +82 -12
  26. data/lib/puppet/environments.rb +169 -13
  27. data/lib/puppet/external/nagios/grammar.ry +2 -0
  28. data/lib/puppet/external/nagios/parser.rb +28 -19
  29. data/lib/puppet/face/config.rb +19 -6
  30. data/lib/puppet/face/module/generate.rb +209 -7
  31. data/lib/puppet/face/module/install.rb +17 -16
  32. data/lib/puppet/face/module/list.rb +83 -82
  33. data/lib/puppet/face/module/search.rb +1 -1
  34. data/lib/puppet/face/module/upgrade.rb +10 -9
  35. data/lib/puppet/face/parser.rb +3 -2
  36. data/lib/puppet/face/plugin.rb +8 -4
  37. data/lib/puppet/file_bucket/dipper.rb +6 -3
  38. data/lib/puppet/file_bucket/file.rb +4 -2
  39. data/lib/puppet/file_serving/metadata.rb +1 -1
  40. data/lib/puppet/file_system/memory_file.rb +27 -1
  41. data/lib/puppet/file_system/memory_impl.rb +15 -1
  42. data/lib/puppet/forge.rb +148 -52
  43. data/lib/puppet/forge/cache.rb +5 -1
  44. data/lib/puppet/forge/errors.rb +10 -0
  45. data/lib/puppet/forge/repository.rb +61 -26
  46. data/lib/puppet/functions.rb +548 -0
  47. data/lib/puppet/functions/assert_type.rb +42 -0
  48. data/lib/puppet/functions/import.rb +7 -0
  49. data/lib/puppet/indirector/facts/facter.rb +1 -1
  50. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
  51. data/lib/puppet/indirector/rest.rb +18 -0
  52. data/lib/puppet/loaders.rb +20 -0
  53. data/lib/puppet/module.rb +2 -2
  54. data/lib/puppet/module_tool.rb +40 -14
  55. data/lib/puppet/module_tool/applications.rb +0 -1
  56. data/lib/puppet/module_tool/applications/application.rb +35 -26
  57. data/lib/puppet/module_tool/applications/builder.rb +16 -6
  58. data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
  59. data/lib/puppet/module_tool/applications/installer.rb +196 -35
  60. data/lib/puppet/module_tool/applications/searcher.rb +1 -0
  61. data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
  62. data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
  63. data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
  64. data/lib/puppet/module_tool/checksums.rb +5 -8
  65. data/lib/puppet/module_tool/errors/installer.rb +12 -44
  66. data/lib/puppet/module_tool/errors/shared.rb +84 -11
  67. data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
  68. data/lib/puppet/module_tool/install_directory.rb +7 -6
  69. data/lib/puppet/module_tool/installed_modules.rb +92 -0
  70. data/lib/puppet/module_tool/local_tarball.rb +91 -0
  71. data/lib/puppet/module_tool/metadata.rb +119 -115
  72. data/lib/puppet/module_tool/modulefile.rb +9 -9
  73. data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
  74. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
  75. data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
  76. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
  77. data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
  78. data/lib/puppet/module_tool/tar.rb +3 -7
  79. data/lib/puppet/module_tool/tar/gnu.rb +21 -9
  80. data/lib/puppet/module_tool/tar/mini.rb +2 -8
  81. data/lib/puppet/network/http/api/v1.rb +1 -1
  82. data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
  83. data/lib/puppet/network/http/issues.rb +1 -0
  84. data/lib/puppet/network/http_pool.rb +15 -6
  85. data/lib/puppet/node/environment.rb +91 -20
  86. data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
  87. data/lib/puppet/parser/collector.rb +1 -1
  88. data/lib/puppet/parser/compiler.rb +50 -7
  89. data/lib/puppet/parser/functions.rb +6 -0
  90. data/lib/puppet/parser/functions/generate.rb +1 -1
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/pops.rb +22 -1
  93. data/lib/puppet/pops/adapters.rb +8 -1
  94. data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
  95. data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
  96. data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
  97. data/lib/puppet/pops/binder/producers.rb +2 -2
  98. data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
  99. data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
  100. data/lib/puppet/pops/evaluator/closure.rb +57 -2
  101. data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
  102. data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
  103. data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
  104. data/lib/puppet/pops/functions/dispatch.rb +71 -0
  105. data/lib/puppet/pops/functions/dispatcher.rb +237 -0
  106. data/lib/puppet/pops/functions/function.rb +77 -0
  107. data/lib/puppet/pops/issues.rb +12 -0
  108. data/lib/puppet/pops/loader/base_loader.rb +102 -0
  109. data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
  110. data/lib/puppet/pops/loader/gem_support.rb +49 -0
  111. data/lib/puppet/pops/loader/loader.rb +180 -0
  112. data/lib/puppet/pops/loader/loader_paths.rb +137 -0
  113. data/lib/puppet/pops/loader/module_loaders.rb +242 -0
  114. data/lib/puppet/pops/loader/null_loader.rb +44 -0
  115. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
  116. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
  117. data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
  118. data/lib/puppet/pops/loader/static_loader.rb +69 -0
  119. data/lib/puppet/pops/loader/uri_helper.rb +22 -0
  120. data/lib/puppet/pops/loaders.rb +240 -0
  121. data/lib/puppet/pops/model/factory.rb +13 -5
  122. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
  123. data/lib/puppet/pops/parser/egrammar.ra +31 -18
  124. data/lib/puppet/pops/parser/eparser.rb +1137 -1106
  125. data/lib/puppet/pops/parser/lexer2.rb +17 -16
  126. data/lib/puppet/pops/semantic_error.rb +17 -0
  127. data/lib/puppet/pops/types/type_calculator.rb +150 -15
  128. data/lib/puppet/pops/types/type_factory.rb +69 -0
  129. data/lib/puppet/pops/types/type_parser.rb +9 -0
  130. data/lib/puppet/pops/types/types.rb +65 -4
  131. data/lib/puppet/pops/validation/checker4_0.rb +1 -1
  132. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
  133. data/lib/puppet/property/list.rb +1 -1
  134. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  135. data/lib/puppet/provider/cron/crontab.rb +13 -2
  136. data/lib/puppet/provider/package.rb +24 -0
  137. data/lib/puppet/provider/package/apt.rb +6 -1
  138. data/lib/puppet/provider/package/gem.rb +8 -2
  139. data/lib/puppet/provider/package/msi.rb +0 -15
  140. data/lib/puppet/provider/package/openbsd.rb +0 -24
  141. data/lib/puppet/provider/package/rpm.rb +3 -29
  142. data/lib/puppet/provider/package/windows.rb +0 -15
  143. data/lib/puppet/provider/package/yum.rb +101 -24
  144. data/lib/puppet/provider/package/yumhelper.py +31 -1
  145. data/lib/puppet/provider/package/zypper.rb +10 -28
  146. data/lib/puppet/provider/service/debian.rb +1 -1
  147. data/lib/puppet/provider/service/init.rb +3 -0
  148. data/lib/puppet/provider/service/openbsd.rb +318 -0
  149. data/lib/puppet/provider/service/redhat.rb +6 -3
  150. data/lib/puppet/provider/service/systemd.rb +2 -2
  151. data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
  152. data/lib/puppet/resource.rb +13 -9
  153. data/lib/puppet/resource/catalog.rb +12 -6
  154. data/lib/puppet/resource/type_collection.rb +3 -3
  155. data/lib/puppet/settings.rb +57 -36
  156. data/lib/puppet/settings/config_file.rb +5 -0
  157. data/lib/puppet/settings/environment_conf.rb +147 -0
  158. data/lib/puppet/settings/ttl_setting.rb +48 -0
  159. data/lib/puppet/ssl/certificate_authority.rb +2 -3
  160. data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
  161. data/lib/puppet/ssl/certificate_request.rb +4 -4
  162. data/lib/puppet/ssl/validator/default_validator.rb +2 -2
  163. data/lib/puppet/status.rb +1 -1
  164. data/lib/puppet/test/test_helper.rb +1 -0
  165. data/lib/puppet/type/augeas.rb +13 -1
  166. data/lib/puppet/type/cron.rb +32 -18
  167. data/lib/puppet/type/file.rb +4 -2
  168. data/lib/puppet/type/file/checksum.rb +15 -5
  169. data/lib/puppet/type/file/content.rb +3 -1
  170. data/lib/puppet/type/file/source.rb +5 -5
  171. data/lib/puppet/type/package.rb +12 -17
  172. data/lib/puppet/type/resources.rb +3 -1
  173. data/lib/puppet/type/scheduled_task.rb +4 -5
  174. data/lib/puppet/type/service.rb +12 -2
  175. data/lib/puppet/type/user.rb +106 -0
  176. data/lib/puppet/type/yumrepo.rb +9 -1
  177. data/lib/puppet/util/checksums.rb +60 -1
  178. data/lib/puppet/util/diff.rb +3 -1
  179. data/lib/puppet/util/execution.rb +20 -16
  180. data/lib/puppet/util/feature.rb +3 -0
  181. data/lib/puppet/util/logging.rb +19 -12
  182. data/lib/puppet/util/rubygems.rb +10 -0
  183. data/lib/puppet/util/watched_file.rb +1 -1
  184. data/lib/puppet/util/windows/security.rb +5 -3
  185. data/lib/puppet/vendor/load_semantic.rb +1 -0
  186. data/lib/puppet/vendor/require_vendored.rb +2 -0
  187. data/lib/puppet/vendor/semantic/Gemfile +20 -0
  188. data/lib/puppet/vendor/semantic/Rakefile +69 -0
  189. data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
  190. data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
  191. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
  192. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
  193. data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
  194. data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
  195. data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
  196. data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
  197. data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
  198. data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
  199. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
  200. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
  201. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
  202. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
  203. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
  204. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
  205. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
  206. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
  207. data/lib/puppet/version.rb +1 -1
  208. data/spec/fixtures/java.tgz +0 -0
  209. data/spec/fixtures/stdlib.tgz +0 -0
  210. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
  211. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
  212. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
  213. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
  214. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
  215. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
  216. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
  217. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
  218. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
  219. data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
  220. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
  221. data/spec/fixtures/unit/type/user/authorized_keys +5 -0
  222. data/spec/integration/application/apply_spec.rb +1 -2
  223. data/spec/integration/configurer_spec.rb +2 -2
  224. data/spec/integration/faces/plugin_spec.rb +62 -0
  225. data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
  226. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  227. data/spec/integration/node/environment_spec.rb +2 -2
  228. data/spec/integration/parser/future_compiler_spec.rb +96 -142
  229. data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
  230. data/spec/integration/provider/cron/crontab_spec.rb +35 -0
  231. data/spec/integration/type/file_spec.rb +74 -72
  232. data/spec/integration/util/windows/security_spec.rb +17 -0
  233. data/spec/lib/matchers/resource.rb +45 -13
  234. data/spec/lib/puppet_spec/files.rb +18 -0
  235. data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
  236. data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
  237. data/spec/shared_contexts/checksums.rb +55 -0
  238. data/spec/unit/application/apply_spec.rb +10 -7
  239. data/spec/unit/application/doc_spec.rb +17 -10
  240. data/spec/unit/application/indirection_base_spec.rb +18 -10
  241. data/spec/unit/application/inspect_spec.rb +22 -20
  242. data/spec/unit/configurer/downloader_spec.rb +7 -6
  243. data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
  244. data/spec/unit/configurer_spec.rb +1 -1
  245. data/spec/unit/context_spec.rb +23 -0
  246. data/spec/unit/environments_spec.rb +274 -16
  247. data/spec/unit/face/config_spec.rb +111 -11
  248. data/spec/unit/face/module/install_spec.rb +14 -85
  249. data/spec/unit/face/module/list_spec.rb +108 -62
  250. data/spec/unit/face/module/search_spec.rb +1 -1
  251. data/spec/unit/face/module/uninstall_spec.rb +21 -42
  252. data/spec/unit/face/parser_spec.rb +5 -2
  253. data/spec/unit/file_bucket/dipper_spec.rb +92 -86
  254. data/spec/unit/file_bucket/file_spec.rb +23 -75
  255. data/spec/unit/file_serving/metadata_spec.rb +74 -74
  256. data/spec/unit/forge/module_release_spec.rb +131 -0
  257. data/spec/unit/forge/repository_spec.rb +21 -20
  258. data/spec/unit/forge_spec.rb +99 -23
  259. data/spec/unit/functions/assert_type_spec.rb +59 -0
  260. data/spec/unit/functions4_spec.rb +671 -0
  261. data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
  262. data/spec/unit/indirector/facts/facter_spec.rb +9 -3
  263. data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
  264. data/spec/unit/indirector/rest_spec.rb +8 -0
  265. data/spec/unit/interface/face_collection_spec.rb +35 -23
  266. data/spec/unit/module_spec.rb +20 -8
  267. data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
  268. data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
  269. data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
  270. data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
  271. data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
  272. data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
  273. data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
  274. data/spec/unit/module_tool/metadata_spec.rb +223 -14
  275. data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
  276. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  277. data/spec/unit/module_tool/tar_spec.rb +4 -18
  278. data/spec/unit/module_tool_spec.rb +123 -27
  279. data/spec/unit/network/formats_spec.rb +2 -2
  280. data/spec/unit/network/http_pool_spec.rb +21 -0
  281. data/spec/unit/network/rights_spec.rb +10 -8
  282. data/spec/unit/node/environment_spec.rb +27 -2
  283. data/spec/unit/parser/collector_spec.rb +1 -1
  284. data/spec/unit/parser/compiler_spec.rb +1 -1
  285. data/spec/unit/parser/functions/generate_spec.rb +4 -0
  286. data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
  287. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
  288. data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
  289. data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
  290. data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
  291. data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
  292. data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
  293. data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
  294. data/spec/unit/pops/types/type_factory_spec.rb +101 -0
  295. data/spec/unit/pops/types/type_parser_spec.rb +22 -0
  296. data/spec/unit/property/list_spec.rb +9 -1
  297. data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
  298. data/spec/unit/provider/cron/crontab_spec.rb +1 -0
  299. data/spec/unit/provider/cron/parsed_spec.rb +15 -0
  300. data/spec/unit/provider/naginator_spec.rb +14 -0
  301. data/spec/unit/provider/package/apt_spec.rb +78 -64
  302. data/spec/unit/provider/package/gem_spec.rb +15 -0
  303. data/spec/unit/provider/package/rpm_spec.rb +6 -6
  304. data/spec/unit/provider/package/windows_spec.rb +1 -1
  305. data/spec/unit/provider/package/yum_spec.rb +199 -104
  306. data/spec/unit/provider/package/zypper_spec.rb +41 -15
  307. data/spec/unit/provider/service/openbsd_spec.rb +129 -22
  308. data/spec/unit/provider/service/redhat_spec.rb +18 -4
  309. data/spec/unit/provider/service/systemd_spec.rb +5 -9
  310. data/spec/unit/provider/service/upstart_spec.rb +1 -1
  311. data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
  312. data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
  313. data/spec/unit/resource/catalog_spec.rb +20 -104
  314. data/spec/unit/resource/type_collection_spec.rb +10 -9
  315. data/spec/unit/settings/config_file_spec.rb +29 -6
  316. data/spec/unit/settings/environment_conf_spec.rb +51 -0
  317. data/spec/unit/settings_spec.rb +97 -12
  318. data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
  319. data/spec/unit/type/augeas_spec.rb +1 -1
  320. data/spec/unit/type/cron_spec.rb +6 -7
  321. data/spec/unit/type/file/checksum_spec.rb +6 -0
  322. data/spec/unit/type/file/content_spec.rb +277 -207
  323. data/spec/unit/type/file_spec.rb +9 -7
  324. data/spec/unit/type/user_spec.rb +106 -18
  325. data/spec/unit/type/yumrepo_spec.rb +8 -0
  326. data/spec/unit/util/checksums_spec.rb +12 -5
  327. data/spec/unit/util/diff_spec.rb +8 -0
  328. data/spec/unit/util/execution_spec.rb +4 -4
  329. data/spec/unit/util/feature_spec.rb +2 -0
  330. data/spec/unit/util/logging_spec.rb +14 -4
  331. data/spec/unit/util/rdoc/parser_spec.rb +5 -4
  332. data/spec/unit/util/rubygems_spec.rb +14 -0
  333. data/tasks/parallel.rake +2 -2
  334. metadata +154 -21
  335. checksums.yaml +0 -7
  336. data/lib/puppet/module_tool/applications/generator.rb +0 -142
  337. data/lib/puppet/module_tool/skeleton.rb +0 -37
  338. data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
  339. data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
  340. data/lib/puppet/module_tool/tar/solaris.rb +0 -5
  341. data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
  342. data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -110,22 +110,23 @@ class Puppet::Pops::Parser::Lexer2
110
110
  # Booleans are pre-calculated (rather than evaluating the strings "false" "true" repeatedly.
111
111
  #
112
112
  KEYWORDS = {
113
- "case" => [:CASE, 'case', 4],
114
- "class" => [:CLASS, 'class', 5],
115
- "default" => [:DEFAULT, 'default', 7],
116
- "define" => [:DEFINE, 'define', 6],
117
- "if" => [:IF, 'if', 2],
118
- "elsif" => [:ELSIF, 'elsif', 5],
119
- "else" => [:ELSE, 'else', 4],
120
- "inherits" => [:INHERITS,'inherits', 8],
121
- "node" => [:NODE, 'node', 4],
122
- "and" => [:AND, 'and', 3],
123
- "or" => [:OR, 'or', 2],
124
- "undef" => [:UNDEF, 'undef', 5],
125
- "false" => [:BOOLEAN, false, 5],
126
- "true" => [:BOOLEAN, true, 4],
127
- "in" => [:IN, 'in', 2],
128
- "unless" => [:UNLESS, 'unless', 6],
113
+ "case" => [:CASE, 'case', 4],
114
+ "class" => [:CLASS, 'class', 5],
115
+ "default" => [:DEFAULT, 'default', 7],
116
+ "define" => [:DEFINE, 'define', 6],
117
+ "if" => [:IF, 'if', 2],
118
+ "elsif" => [:ELSIF, 'elsif', 5],
119
+ "else" => [:ELSE, 'else', 4],
120
+ "inherits" => [:INHERITS, 'inherits', 8],
121
+ "node" => [:NODE, 'node', 4],
122
+ "and" => [:AND, 'and', 3],
123
+ "or" => [:OR, 'or', 2],
124
+ "undef" => [:UNDEF, 'undef', 5],
125
+ "false" => [:BOOLEAN, false, 5],
126
+ "true" => [:BOOLEAN, true, 4],
127
+ "in" => [:IN, 'in', 2],
128
+ "unless" => [:UNLESS, 'unless', 6],
129
+ "function" => [:FUNCTION, 'function', 8],
129
130
  }
130
131
  KEYWORDS.each {|k,v| v[1].freeze; v.freeze }
131
132
  KEYWORDS.freeze
@@ -0,0 +1,17 @@
1
+ # Error that is used to raise an Issue. See {Puppet::Pops::Issues}.
2
+ #
3
+ class Puppet::Pops::SemanticError < RuntimeError
4
+ attr_accessor :issue
5
+ attr_accessor :semantic
6
+ attr_accessor :options
7
+
8
+ # @param issue [Puppet::Pops::Issues::Issue] the issue describing the severity and message
9
+ # @param semantic [Puppet::Pops::Model::Locatable, nil] the expression causing the failure, or nil if unknown
10
+ # @param options [Hash] an options hash with Symbol to valu mapping - these are the arguments to the issue
11
+ #
12
+ def initialize(issue, semantic=nil, options = {})
13
+ @issue = issue
14
+ @semantic = semantic
15
+ @options = options
16
+ end
17
+ end
@@ -102,7 +102,22 @@ class Puppet::Pops::Types::TypeCalculator
102
102
  singleton.assignable?(t1,t2)
103
103
  end
104
104
 
105
+ # Answers, does the given callable accept the arguments given in args (an array or a tuple)
106
+ # @param callable [Puppet::Pops::Types::PCallableType] - the callable
107
+ # @param args [Puppet::Pops::Types::PArrayType, Puppet::Pops::Types::PTupleType] args optionally including a lambda callable at the end
108
+ # @return [Boolan] true if the callable accepts the arguments
109
+ #
110
+ # @api public
111
+ def self.callable?(callable, args)
112
+ singleton.callable?(callable, args)
113
+ end
114
+
115
+ # Produces a String representation of the given type.
116
+ # @param t [Puppet::Pops::Types::PAbstractType] the type to produce a string form
117
+ # @return [String] the type in string form
118
+ #
105
119
  # @api public
120
+ #
106
121
  def self.string(t)
107
122
  singleton.string(t)
108
123
  end
@@ -149,6 +164,7 @@ class Puppet::Pops::Types::TypeCalculator
149
164
  @@enumerable_visitor ||= Puppet::Pops::Visitor.new(nil,"enumerable",0,0)
150
165
  @@extract_visitor ||= Puppet::Pops::Visitor.new(nil,"extract",0,0)
151
166
  @@generalize_visitor ||= Puppet::Pops::Visitor.new(nil,"generalize",0,0)
167
+ @@callable_visitor ||= Puppet::Pops::Visitor.new(nil,"callable",1,1)
152
168
 
153
169
  da = Types::PArrayType.new()
154
170
  da.element_type = Types::PDataType.new()
@@ -191,6 +207,8 @@ class Puppet::Pops::Types::TypeCalculator
191
207
  non_empty_string.size_type.from = 1
192
208
  non_empty_string.size_type.to = nil # infinity
193
209
  @non_empty_string_t = non_empty_string
210
+
211
+ @nil_t = Types::PNilType.new
194
212
  end
195
213
 
196
214
  # Convenience method to get a data type for comparisons
@@ -234,13 +252,12 @@ class Puppet::Pops::Types::TypeCalculator
234
252
  end
235
253
  end
236
254
 
237
- # Answers 'can an instance of type t2 be assigned to a variable of type t'
255
+ # Answers 'can an instance of type t2 be assigned to a variable of type t'.
256
+ # Does not accept nil/undef unless the type accepts it.
257
+ #
238
258
  # @api public
239
259
  #
240
260
  def assignable?(t, t2)
241
- # nil is assignable to anything except to required types
242
- return true if is_pnil?(t2)
243
-
244
261
  if t.is_a?(Class)
245
262
  t = type(t)
246
263
  end
@@ -257,6 +274,14 @@ class Puppet::Pops::Types::TypeCalculator
257
274
  @@enumerable_visitor.visit_this_0(self, t)
258
275
  end
259
276
 
277
+ # Answers, does the given callable accept the arguments given in args (an array or a tuple)
278
+ #
279
+ def callable?(callable, args)
280
+ return false if !callable.is_a?(Types::PCallableType)
281
+ # Note that polymorphism is for the args type, the callable is always a callable
282
+ @@callable_visitor.visit_this_1(self, args, callable)
283
+ end
284
+
260
285
  # Answers if the two given types describe the same type
261
286
  def equals(left, right)
262
287
  return false unless left.is_a?(Types::PAbstractType) && right.is_a?(Types::PAbstractType)
@@ -362,7 +387,6 @@ class Puppet::Pops::Types::TypeCalculator
362
387
  end
363
388
 
364
389
  def instance_of(t, o)
365
- # return true if o.nil? && !t.is_a?(Types::PRequiredType)
366
390
  @@instance_of_visitor.visit_this_1(self, t, o)
367
391
  end
368
392
 
@@ -566,6 +590,12 @@ class Puppet::Pops::Types::TypeCalculator
566
590
  return Types::PPatternType.new()
567
591
  end
568
592
 
593
+ if t1.is_a?(Types::PCallableType) && t2.is_a?(Types::PCallableType)
594
+ # They do not have the same signature, and one is not assignable to the other,
595
+ # what remains is the most general form of Callable
596
+ return Types::PCallableType.new()
597
+ end
598
+
569
599
  # Common abstract types, from most specific to most general
570
600
  if common_numeric?(t1, t2)
571
601
  return Types::PNumericType.new()
@@ -659,6 +689,16 @@ class Puppet::Pops::Types::TypeCalculator
659
689
  Types::PType.new()
660
690
  end
661
691
 
692
+ # @api private
693
+ def infer_Closure(o)
694
+ o.type()
695
+ end
696
+
697
+ # @api private
698
+ def infer_Function(o)
699
+ o.class.dispatcher.to_type
700
+ end
701
+
662
702
  # @api private
663
703
  def infer_Object(o)
664
704
  type = Types::PRubyType.new()
@@ -669,7 +709,7 @@ class Puppet::Pops::Types::TypeCalculator
669
709
  # The type of all types is PType
670
710
  # @api private
671
711
  #
672
- def infer_PObjectType(o)
712
+ def infer_PAbstractType(o)
673
713
  type = Types::PType.new()
674
714
  type.type = o.copy
675
715
  type
@@ -743,7 +783,10 @@ class Puppet::Pops::Types::TypeCalculator
743
783
  def infer_Resource(o)
744
784
  t = Types::PResourceType.new()
745
785
  t.type_name = o.type.to_s
746
- t.title = o.title
786
+ # Only Puppet::Resource can have a title that is a symbol :undef, a PResource cannot.
787
+ # A mapping must be made to empty string. A nil value will result in an error later
788
+ title = o.title
789
+ t.title = (title == :undef ? '' : title)
747
790
  t
748
791
  end
749
792
 
@@ -790,15 +833,14 @@ class Puppet::Pops::Types::TypeCalculator
790
833
  end
791
834
 
792
835
  def infer_set_Array(o)
793
- type = Types::PArrayType.new()
794
- type.element_type = if o.empty?
795
- Types::PNilType.new()
836
+ if o.empty?
837
+ type = Types::PArrayType.new()
838
+ type.element_type = Types::PNilType.new()
839
+ type.size_type = size_as_type(o)
796
840
  else
797
- t = Types::PVariantType.new()
798
- t.types = o.map() {|x| infer_set(x) }
799
- t.types.size == 1 ? t.types[0] : t
841
+ type = Types::PTupleType.new()
842
+ type.types = o.map() {|x| infer_set(x) }
800
843
  end
801
- type.size_type = size_as_type(o)
802
844
  type
803
845
  end
804
846
 
@@ -913,6 +955,39 @@ class Puppet::Pops::Types::TypeCalculator
913
955
  end
914
956
  end
915
957
 
958
+ # Catch all not callable combinations
959
+ def callable_Object(o, callable_t)
960
+ false
961
+ end
962
+
963
+ def callable_PTupleType(args_tuple, callable_t)
964
+ if args_tuple.size_type
965
+ raise ArgumentError, "Callable tuple may not have a size constraint when used as args"
966
+ end
967
+ # Assume no block was given - i.e. it is nil, and its type is PNilType
968
+ block_t = @nil_t
969
+ if args_tuple.types.last.is_a?(Types::PCallableType)
970
+ # a split is needed to make it possible to use required, optional, and varargs semantics
971
+ # of the tuple type.
972
+ #
973
+ args_tuple = args_tuple.copy
974
+ # to drop the callable, it must be removed explicitly since this is an rgen array
975
+ args_tuple.removeTypes(block_t = args_tuple.types.last())
976
+ else
977
+ # no block was given, if it is required, the below will fail
978
+ end
979
+ # unless argument types match parameter types
980
+ return false unless assignable?(callable_t.param_types, args_tuple)
981
+ # unless given block (or no block) matches expected block (or no block)
982
+ assignable?(callable_t.block_type || @nil_t, block_t)
983
+ end
984
+
985
+ def callable_PArrayType(args_array, callable_t)
986
+ return false unless assignable?(callable_t.param_types, args_array)
987
+ # does not support calling with a block, but have to check that callable expects it
988
+ assignable?(callable_t.block_type || @nil_t, @nil_t)
989
+ end
990
+
916
991
  def max(a,b)
917
992
  a >=b ? a : b
918
993
  end
@@ -1048,6 +1123,9 @@ class Puppet::Pops::Types::TypeCalculator
1048
1123
  # no string can match this enum anyway since it does not accept anything
1049
1124
  false
1050
1125
  end
1126
+ else
1127
+ # no other type matches string
1128
+ false
1051
1129
  end
1052
1130
  elsif t2.is_a?(Types::PStringType)
1053
1131
  # A specific string acts as a set of strings - must have exactly the same strings
@@ -1093,6 +1171,19 @@ class Puppet::Pops::Types::TypeCalculator
1093
1171
  t2.is_a?(Types::PRegexpType) && (t.pattern.nil? || t.pattern == t2.pattern)
1094
1172
  end
1095
1173
 
1174
+ # @api private
1175
+ def assignable_PCallableType(t, t2)
1176
+ return false unless t2.is_a?(Types::PCallableType)
1177
+ # nil param_types means, any other Callable is assignable
1178
+ return true if t.param_types.nil?
1179
+ return false unless assignable?(t.param_types, t2.param_types)
1180
+ # names are ignored, they are just information
1181
+ # Blocks must be compatible
1182
+ this_block_t = t.block_type || @nil_t
1183
+ that_block_t = t2.block_type || @nil_t
1184
+ assignable?(this_block_t, that_block_t)
1185
+ end
1186
+
1096
1187
  # @api private
1097
1188
  def assignable_PCollectionType(t, t2)
1098
1189
  size_t = t.size_type || @collection_default_size_t
@@ -1183,7 +1274,7 @@ class Puppet::Pops::Types::TypeCalculator
1183
1274
  struct_size = t2.elements.size
1184
1275
  element_type = t.element_type
1185
1276
  ( struct_size >= min && struct_size <= max &&
1186
- assignable?(t.key_type, @non_emptry_string_t) &&
1277
+ assignable?(t.key_type, @non_empty_string_t) &&
1187
1278
  t2.hashed_elements.all? {|k,v| assignable?(element_type, v) })
1188
1279
  else
1189
1280
  false
@@ -1343,6 +1434,35 @@ class Puppet::Pops::Types::TypeCalculator
1343
1434
  s
1344
1435
  end
1345
1436
 
1437
+ # @api private
1438
+ def string_PCallableType(t)
1439
+ # generic
1440
+ return "Callable" if t.param_types.nil?
1441
+
1442
+ if t.param_types.types.empty?
1443
+ range = [0, 0]
1444
+ else
1445
+ range = range_array_part(t.param_types.size_type)
1446
+ end
1447
+ types = t.param_types.types.map {|t2| string(t2) }
1448
+
1449
+ params_part= types.join(', ')
1450
+
1451
+ s = "Callable[" << types.join(', ')
1452
+ unless range.empty?
1453
+ (s << ', ') unless types.empty?
1454
+ s << range.join(', ')
1455
+ end
1456
+ # Add block T last (after min, max) if present)
1457
+ #
1458
+ unless t.block_type.nil?
1459
+ (s << ', ') unless types.empty? && range.empty?
1460
+ s << string(t.block_type)
1461
+ end
1462
+ s << "]"
1463
+ s
1464
+ end
1465
+
1346
1466
  # @api private
1347
1467
  def string_PStructType(t)
1348
1468
  return "Struct" if t.elements.empty?
@@ -1432,6 +1552,21 @@ class Puppet::Pops::Types::TypeCalculator
1432
1552
  t
1433
1553
  end
1434
1554
 
1555
+ def self.copy_as_tuple(t)
1556
+ case t
1557
+ when Types::PTupleType
1558
+ t.copy
1559
+ when Types::PArrayType
1560
+ # transform array to tuple
1561
+ result = Types::PTupleType.new
1562
+ result.addTypes(t.element_type.copy)
1563
+ result.size_type = t.size_type.nil? ? nil : t.size_type.copy
1564
+ result
1565
+ else
1566
+ raise ArgumentError, "Internal Error: Only Array and Tuple can be given to copy_as_tuple"
1567
+ end
1568
+ end
1569
+
1435
1570
  private
1436
1571
 
1437
1572
  def class_from_string(str)
@@ -70,6 +70,11 @@ module Puppet::Pops::Types::TypeFactory
70
70
  t
71
71
  end
72
72
 
73
+ # Convenience method to produce an Optional[Object] type
74
+ def self.optional_object()
75
+ optional(object())
76
+ end
77
+
73
78
  # Produces the Enum type, optionally with specific string values
74
79
  # @api public
75
80
  #
@@ -135,6 +140,7 @@ module Puppet::Pops::Types::TypeFactory
135
140
  if pattern
136
141
  t.pattern = pattern.is_a?(Regexp) ? pattern.inspect[1..-2] : pattern
137
142
  end
143
+ t.regexp() unless pattern.nil? # compile pattern to catch errors
138
144
  t
139
145
  end
140
146
 
@@ -145,6 +151,7 @@ module Puppet::Pops::Types::TypeFactory
145
151
  when String
146
152
  re_T = Types::PRegexpType.new()
147
153
  re_T.pattern = re
154
+ re_T.regexp() # compile it to catch errors
148
155
  t.addPatterns(re_T)
149
156
 
150
157
  when Regexp
@@ -177,6 +184,68 @@ module Puppet::Pops::Types::TypeFactory
177
184
  Types::PScalarType.new()
178
185
  end
179
186
 
187
+ # Produces a CallableType matching all callables
188
+ # @api public
189
+ #
190
+ def self.all_callables()
191
+ return Puppet::Pops::Types::PCallableType.new
192
+ end
193
+
194
+ # Produces a Callable type with one signature without support for a block
195
+ # Use #with_block, or #with_optional_block to add a block to the callable
196
+ # If no parameters are given, the Callable will describe a signature
197
+ # that does not accept parameters. To create a Callable that matches all callables
198
+ # use {#all_callables}.
199
+ #
200
+ # The params is a list of types, where the three last entries may be
201
+ # optionally followed by min, max count, and a Callable which is taken as the block_type.
202
+ # If neither min or max are specified the parameters must match exactly.
203
+ # A min < params.size means that the difference are optional.
204
+ # If max > params.size means that the last type repeats.
205
+ # if max is :default, the max value is unbound (infinity).
206
+ #
207
+ # Params are given as a sequence of arguments to {#type_of}.
208
+ #
209
+ def self.callable(*params)
210
+ case params.last
211
+ when Types::PCallableType
212
+ last_callable = true
213
+ when Types::POptionalType
214
+ last_callable = true if params.last.optional_type.is_a?(Types::PCallableType)
215
+ end
216
+ block_t = last_callable ? params.pop : nil
217
+
218
+ # compute a size_type for the signature based on the two last parameters
219
+ if is_range_parameter?(params[-2]) && is_range_parameter?(params[-1])
220
+ size_type = range(params[-2], params[-1])
221
+ params = params[0, params.size - 2]
222
+ elsif is_range_parameter?(params[-1])
223
+ size_type = range(params[-1], :default)
224
+ params = params[0, params.size - 1]
225
+ end
226
+
227
+ types = params.map {|p| type_of(p) }
228
+
229
+ # create a signature
230
+ callable_t = Types::PCallableType.new()
231
+ tuple_t = tuple(*types)
232
+ tuple_t.size_type = size_type unless size_type.nil?
233
+ callable_t.param_types = tuple_t
234
+
235
+ callable_t.block_type = block_t
236
+ callable_t
237
+ end
238
+
239
+ def self.with_block(callable, *block_params)
240
+ callable.block_type = callable(*block_params)
241
+ callable
242
+ end
243
+
244
+ def self.with_optional_block(callable, *block_params)
245
+ callable.block_type = optional(callable(*block_params))
246
+ callable
247
+ end
248
+
180
249
  # Produces the abstract type Collection
181
250
  # @api public
182
251
  #
@@ -180,6 +180,11 @@ class Puppet::Pops::Types::TypeParser
180
180
 
181
181
  when "struct"
182
182
  TYPES.struct()
183
+
184
+ when "callable"
185
+ # A generic callable as opposed to one that does not accept arguments
186
+ TYPES.all_callables()
187
+
183
188
  else
184
189
  TYPES.resource(name_ast.value)
185
190
  end
@@ -329,6 +334,10 @@ class Puppet::Pops::Types::TypeParser
329
334
  end
330
335
  t
331
336
 
337
+ when "callable"
338
+ # 1..m parameters being types (last three optionally integer or literal default, and a callable)
339
+ TYPES.callable(*parameters)
340
+
332
341
  when "struct"
333
342
  # 1..m parameters being types (last two optionally integer or literal default
334
343
  raise_invalid_parameters_error("Struct", "1", parameters.size) unless parameters.size == 1