puppet 8.5.1-universal-darwin → 8.7.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (581) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -2
  3. data/Gemfile.lock +55 -48
  4. data/Rakefile +45 -22
  5. data/examples/hiera/README.md +68 -57
  6. data/examples/hiera/data/common.yaml +12 -0
  7. data/examples/hiera/data/dc1.yaml +6 -0
  8. data/examples/hiera/hiera.yaml +15 -0
  9. data/examples/hiera/modules/ntp/data/common.yaml +4 -0
  10. data/examples/hiera/modules/ntp/hiera.yaml +9 -0
  11. data/examples/hiera/modules/ntp/manifests/config.pp +16 -4
  12. data/examples/hiera/modules/ntp/templates/ntp.conf.epp +3 -0
  13. data/examples/hiera/modules/users/manifests/common.pp +7 -2
  14. data/examples/hiera/modules/users/manifests/dc1.pp +7 -2
  15. data/examples/hiera/site.pp +1 -1
  16. data/ext/project_data.yaml +0 -45
  17. data/ext/windows/service/daemon.rb +49 -55
  18. data/lib/hiera/scope.rb +3 -3
  19. data/lib/hiera_puppet.rb +1 -1
  20. data/lib/puppet/agent/disabler.rb +1 -1
  21. data/lib/puppet/application/agent.rb +2 -2
  22. data/lib/puppet/application/apply.rb +2 -2
  23. data/lib/puppet/application/describe.rb +6 -6
  24. data/lib/puppet/application/device.rb +99 -100
  25. data/lib/puppet/application/doc.rb +1 -1
  26. data/lib/puppet/application/face_base.rb +7 -7
  27. data/lib/puppet/application/filebucket.rb +1 -1
  28. data/lib/puppet/application/lookup.rb +5 -5
  29. data/lib/puppet/application/resource.rb +10 -3
  30. data/lib/puppet/application/ssl.rb +3 -3
  31. data/lib/puppet/application.rb +16 -18
  32. data/lib/puppet/coercion.rb +1 -1
  33. data/lib/puppet/configurer/downloader.rb +9 -4
  34. data/lib/puppet/configurer/fact_handler.rb +12 -13
  35. data/lib/puppet/configurer.rb +16 -18
  36. data/lib/puppet/confine/feature.rb +1 -1
  37. data/lib/puppet/confine/variable.rb +1 -1
  38. data/lib/puppet/confine.rb +2 -2
  39. data/lib/puppet/confine_collection.rb +1 -1
  40. data/lib/puppet/confiner.rb +2 -2
  41. data/lib/puppet/daemon.rb +4 -3
  42. data/lib/puppet/datatypes.rb +5 -6
  43. data/lib/puppet/defaults.rb +14 -8
  44. data/lib/puppet/environments.rb +3 -7
  45. data/lib/puppet/error.rb +3 -3
  46. data/lib/puppet/external/dot.rb +42 -34
  47. data/lib/puppet/face/catalog/select.rb +1 -1
  48. data/lib/puppet/face/epp.rb +7 -9
  49. data/lib/puppet/face/help.rb +12 -12
  50. data/lib/puppet/face/module/changes.rb +1 -3
  51. data/lib/puppet/face/module/list.rb +37 -37
  52. data/lib/puppet/face/node/clean.rb +1 -1
  53. data/lib/puppet/face/parser.rb +6 -8
  54. data/lib/puppet/face/report.rb +5 -7
  55. data/lib/puppet/facter_impl.rb +1 -1
  56. data/lib/puppet/feature/base.rb +9 -11
  57. data/lib/puppet/feature/pe_license.rb +1 -1
  58. data/lib/puppet/feature/ssh.rb +1 -1
  59. data/lib/puppet/feature/telnet.rb +3 -5
  60. data/lib/puppet/feature/zlib.rb +1 -1
  61. data/lib/puppet/ffi/windows/constants.rb +1 -1
  62. data/lib/puppet/ffi/windows/functions.rb +2 -2
  63. data/lib/puppet/ffi/windows/structs.rb +3 -3
  64. data/lib/puppet/file_bucket/dipper.rb +4 -4
  65. data/lib/puppet/file_bucket/file.rb +4 -4
  66. data/lib/puppet/file_serving/base.rb +5 -5
  67. data/lib/puppet/file_serving/configuration/parser.rb +9 -9
  68. data/lib/puppet/file_serving/configuration.rb +3 -3
  69. data/lib/puppet/file_serving/fileset.rb +13 -13
  70. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  71. data/lib/puppet/file_serving/metadata.rb +13 -9
  72. data/lib/puppet/file_serving/mount/file.rb +6 -6
  73. data/lib/puppet/file_serving/mount/locales.rb +2 -4
  74. data/lib/puppet/file_serving/mount/pluginfacts.rb +2 -4
  75. data/lib/puppet/file_serving/mount/plugins.rb +2 -4
  76. data/lib/puppet/file_serving/mount.rb +1 -1
  77. data/lib/puppet/file_system/file_impl.rb +3 -3
  78. data/lib/puppet/file_system/memory_impl.rb +1 -1
  79. data/lib/puppet/file_system/path_pattern.rb +1 -1
  80. data/lib/puppet/file_system/uniquefile.rb +17 -16
  81. data/lib/puppet/file_system/windows.rb +26 -18
  82. data/lib/puppet/forge/cache.rb +2 -2
  83. data/lib/puppet/forge/errors.rb +1 -1
  84. data/lib/puppet/forge/repository.rb +2 -2
  85. data/lib/puppet/forge.rb +13 -19
  86. data/lib/puppet/functions/abs.rb +2 -2
  87. data/lib/puppet/functions/camelcase.rb +1 -1
  88. data/lib/puppet/functions/compare.rb +2 -2
  89. data/lib/puppet/functions/contain.rb +1 -1
  90. data/lib/puppet/functions/defined.rb +2 -2
  91. data/lib/puppet/functions/dig.rb +1 -1
  92. data/lib/puppet/functions/eyaml_lookup_key.rb +11 -13
  93. data/lib/puppet/functions/get.rb +1 -1
  94. data/lib/puppet/functions/hocon_data.rb +3 -5
  95. data/lib/puppet/functions/import.rb +1 -1
  96. data/lib/puppet/functions/json_data.rb +4 -6
  97. data/lib/puppet/functions/max.rb +2 -2
  98. data/lib/puppet/functions/min.rb +2 -2
  99. data/lib/puppet/functions/new.rb +1 -1
  100. data/lib/puppet/functions/reduce.rb +6 -10
  101. data/lib/puppet/functions/regsubst.rb +2 -2
  102. data/lib/puppet/functions/require.rb +1 -1
  103. data/lib/puppet/functions/yaml_data.rb +11 -13
  104. data/lib/puppet/functions.rb +32 -37
  105. data/lib/puppet/generate/type.rb +2 -2
  106. data/lib/puppet/gettext/config.rb +9 -9
  107. data/lib/puppet/graph/rb_tree_map.rb +31 -23
  108. data/lib/puppet/graph/relationship_graph.rb +12 -12
  109. data/lib/puppet/graph/simple_graph.rb +8 -10
  110. data/lib/puppet/http/client.rb +1 -1
  111. data/lib/puppet/http/dns.rb +4 -4
  112. data/lib/puppet/http/external_client.rb +1 -1
  113. data/lib/puppet/http/factory.rb +1 -1
  114. data/lib/puppet/http/proxy.rb +15 -15
  115. data/lib/puppet/http/redirector.rb +6 -2
  116. data/lib/puppet/http/resolver.rb +2 -2
  117. data/lib/puppet/http/retry_after_handler.rb +2 -2
  118. data/lib/puppet/http/service/ca.rb +1 -1
  119. data/lib/puppet/http/service/compiler.rb +4 -4
  120. data/lib/puppet/http/service/file_server.rb +1 -1
  121. data/lib/puppet/http/service/report.rb +2 -2
  122. data/lib/puppet/http/service.rb +9 -13
  123. data/lib/puppet/http/session.rb +1 -1
  124. data/lib/puppet/http/site.rb +1 -1
  125. data/lib/puppet/indirector/catalog/compiler.rb +44 -45
  126. data/lib/puppet/indirector/catalog/rest.rb +7 -5
  127. data/lib/puppet/indirector/catalog/store_configs.rb +1 -1
  128. data/lib/puppet/indirector/exec.rb +2 -2
  129. data/lib/puppet/indirector/face.rb +7 -9
  130. data/lib/puppet/indirector/fact_search.rb +1 -1
  131. data/lib/puppet/indirector/facts/facter.rb +6 -6
  132. data/lib/puppet/indirector/facts/json.rb +1 -1
  133. data/lib/puppet/indirector/facts/store_configs.rb +1 -1
  134. data/lib/puppet/indirector/file_bucket_file/file.rb +17 -17
  135. data/lib/puppet/indirector/file_bucket_file/rest.rb +3 -3
  136. data/lib/puppet/indirector/file_content/rest.rb +1 -1
  137. data/lib/puppet/indirector/file_metadata/rest.rb +1 -1
  138. data/lib/puppet/indirector/hiera.rb +1 -1
  139. data/lib/puppet/indirector/indirection.rb +27 -29
  140. data/lib/puppet/indirector/json.rb +4 -4
  141. data/lib/puppet/indirector/memory.rb +2 -2
  142. data/lib/puppet/indirector/msgpack.rb +5 -5
  143. data/lib/puppet/indirector/node/store_configs.rb +1 -1
  144. data/lib/puppet/indirector/none.rb +1 -1
  145. data/lib/puppet/indirector/report/json.rb +1 -1
  146. data/lib/puppet/indirector/report/yaml.rb +1 -1
  147. data/lib/puppet/indirector/request.rb +4 -4
  148. data/lib/puppet/indirector/resource/ral.rb +2 -4
  149. data/lib/puppet/indirector/resource/store_configs.rb +1 -1
  150. data/lib/puppet/indirector/terminus.rb +4 -4
  151. data/lib/puppet/indirector/yaml.rb +3 -3
  152. data/lib/puppet/info_service/class_information_service.rb +5 -8
  153. data/lib/puppet/info_service/task_information_service.rb +6 -7
  154. data/lib/puppet/interface/action.rb +5 -5
  155. data/lib/puppet/interface/action_manager.rb +5 -5
  156. data/lib/puppet/interface/documentation.rb +5 -5
  157. data/lib/puppet/interface/face_collection.rb +7 -7
  158. data/lib/puppet/interface/option.rb +2 -2
  159. data/lib/puppet/interface/option_manager.rb +6 -6
  160. data/lib/puppet/interface.rb +4 -4
  161. data/lib/puppet/metatype/manager.rb +2 -2
  162. data/lib/puppet/module/plan.rb +10 -10
  163. data/lib/puppet/module/task.rb +8 -8
  164. data/lib/puppet/module.rb +39 -41
  165. data/lib/puppet/module_tool/applications/application.rb +10 -8
  166. data/lib/puppet/module_tool/applications/installer.rb +53 -50
  167. data/lib/puppet/module_tool/applications/unpacker.rb +6 -8
  168. data/lib/puppet/module_tool/applications/upgrader.rb +37 -34
  169. data/lib/puppet/module_tool/checksums.rb +2 -2
  170. data/lib/puppet/module_tool/dependency.rb +1 -1
  171. data/lib/puppet/module_tool/errors/base.rb +1 -1
  172. data/lib/puppet/module_tool/install_directory.rb +1 -1
  173. data/lib/puppet/module_tool/local_tarball.rb +3 -5
  174. data/lib/puppet/module_tool/metadata.rb +12 -8
  175. data/lib/puppet/module_tool/shared_behaviors.rb +27 -12
  176. data/lib/puppet/module_tool/tar/mini.rb +3 -3
  177. data/lib/puppet/module_tool.rb +4 -4
  178. data/lib/puppet/network/client_request.rb +5 -3
  179. data/lib/puppet/network/format.rb +2 -2
  180. data/lib/puppet/network/format_support.rb +1 -1
  181. data/lib/puppet/network/formats.rb +1 -1
  182. data/lib/puppet/network/http/api/indirected_routes.rb +24 -44
  183. data/lib/puppet/network/http/api/server/v3.rb +1 -1
  184. data/lib/puppet/network/http/connection.rb +1 -1
  185. data/lib/puppet/network/http/handler.rb +8 -12
  186. data/lib/puppet/network/http/request.rb +1 -1
  187. data/lib/puppet/network/http/route.rb +9 -9
  188. data/lib/puppet/node/environment.rb +21 -23
  189. data/lib/puppet/node/facts.rb +1 -1
  190. data/lib/puppet/node.rb +5 -5
  191. data/lib/puppet/pal/json_catalog_encoder.rb +1 -1
  192. data/lib/puppet/pal/pal_impl.rb +48 -50
  193. data/lib/puppet/pal/plan_signature.rb +1 -1
  194. data/lib/puppet/pal/task_signature.rb +1 -1
  195. data/lib/puppet/parameter/package_options.rb +1 -1
  196. data/lib/puppet/parameter/value.rb +2 -2
  197. data/lib/puppet/parameter/value_collection.rb +7 -7
  198. data/lib/puppet/parameter.rb +8 -9
  199. data/lib/puppet/parser/ast/block_expression.rb +2 -2
  200. data/lib/puppet/parser/ast/hostclass.rb +1 -1
  201. data/lib/puppet/parser/ast/pops_bridge.rb +3 -4
  202. data/lib/puppet/parser/ast/resource.rb +4 -4
  203. data/lib/puppet/parser/ast/resourceparam.rb +4 -4
  204. data/lib/puppet/parser/ast.rb +14 -15
  205. data/lib/puppet/parser/compiler.rb +26 -28
  206. data/lib/puppet/parser/functions/create_resources.rb +3 -3
  207. data/lib/puppet/parser/functions/fail.rb +1 -1
  208. data/lib/puppet/parser/functions/generate.rb +2 -2
  209. data/lib/puppet/parser/functions/tag.rb +1 -1
  210. data/lib/puppet/parser/functions.rb +2 -2
  211. data/lib/puppet/parser/relationship.rb +3 -1
  212. data/lib/puppet/parser/resource/param.rb +2 -2
  213. data/lib/puppet/parser/resource.rb +23 -23
  214. data/lib/puppet/parser/scope.rb +10 -10
  215. data/lib/puppet/parser/script_compiler.rb +1 -1
  216. data/lib/puppet/parser/templatewrapper.rb +1 -1
  217. data/lib/puppet/parser/type_loader.rb +10 -12
  218. data/lib/puppet/parser.rb +1 -1
  219. data/lib/puppet/pops/adaptable.rb +1 -1
  220. data/lib/puppet/pops/evaluator/access_operator.rb +8 -8
  221. data/lib/puppet/pops/evaluator/callable_signature.rb +4 -4
  222. data/lib/puppet/pops/evaluator/collector_transformer.rb +4 -4
  223. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +7 -7
  224. data/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +6 -6
  225. data/lib/puppet/pops/evaluator/compare_operator.rb +10 -10
  226. data/lib/puppet/pops/evaluator/deferred_resolver.rb +1 -1
  227. data/lib/puppet/pops/evaluator/epp_evaluator.rb +2 -2
  228. data/lib/puppet/pops/evaluator/evaluator_impl.rb +56 -60
  229. data/lib/puppet/pops/evaluator/relationship_operator.rb +2 -2
  230. data/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -3
  231. data/lib/puppet/pops/evaluator/runtime3_support.rb +1 -1
  232. data/lib/puppet/pops/functions/dispatcher.rb +3 -3
  233. data/lib/puppet/pops/functions/function.rb +14 -16
  234. data/lib/puppet/pops/issue_reporter.rb +2 -2
  235. data/lib/puppet/pops/label_provider.rb +2 -2
  236. data/lib/puppet/pops/loader/dependency_loader.rb +3 -3
  237. data/lib/puppet/pops/loader/loader.rb +4 -4
  238. data/lib/puppet/pops/loader/loader_paths.rb +3 -3
  239. data/lib/puppet/pops/loader/module_loaders.rb +11 -11
  240. data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +1 -1
  241. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +1 -1
  242. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +5 -1
  243. data/lib/puppet/pops/loader/static_loader.rb +5 -5
  244. data/lib/puppet/pops/loaders.rb +3 -3
  245. data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
  246. data/lib/puppet/pops/lookup/explainer.rb +2 -2
  247. data/lib/puppet/pops/lookup/global_data_provider.rb +1 -1
  248. data/lib/puppet/pops/lookup/hiera_config.rb +15 -11
  249. data/lib/puppet/pops/lookup/interpolation.rb +3 -3
  250. data/lib/puppet/pops/lookup/key_recorder.rb +1 -1
  251. data/lib/puppet/pops/lookup/location_resolver.rb +1 -1
  252. data/lib/puppet/pops/lookup/lookup_adapter.rb +7 -7
  253. data/lib/puppet/pops/lookup/module_data_provider.rb +9 -9
  254. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  255. data/lib/puppet/pops/merge_strategy.rb +6 -6
  256. data/lib/puppet/pops/migration/migration_checker.rb +1 -1
  257. data/lib/puppet/pops/model/ast_transformer.rb +9 -11
  258. data/lib/puppet/pops/model/factory.rb +4 -5
  259. data/lib/puppet/pops/parser/epp_parser.rb +2 -2
  260. data/lib/puppet/pops/parser/epp_support.rb +1 -1
  261. data/lib/puppet/pops/parser/evaluating_parser.rb +2 -2
  262. data/lib/puppet/pops/parser/heredoc_support.rb +4 -4
  263. data/lib/puppet/pops/parser/interpolation_support.rb +3 -3
  264. data/lib/puppet/pops/parser/lexer2.rb +20 -12
  265. data/lib/puppet/pops/parser/lexer_support.rb +1 -1
  266. data/lib/puppet/pops/parser/locator.rb +4 -4
  267. data/lib/puppet/pops/parser/parser_support.rb +12 -14
  268. data/lib/puppet/pops/parser/pn_parser.rb +3 -3
  269. data/lib/puppet/pops/parser/slurp_support.rb +8 -8
  270. data/lib/puppet/pops/patterns.rb +12 -12
  271. data/lib/puppet/pops/pcore.rb +1 -1
  272. data/lib/puppet/pops/pn.rb +2 -2
  273. data/lib/puppet/pops/puppet_stack.rb +1 -1
  274. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  275. data/lib/puppet/pops/serialization/abstract_reader.rb +2 -2
  276. data/lib/puppet/pops/serialization/abstract_writer.rb +3 -3
  277. data/lib/puppet/pops/time/timestamp.rb +1 -1
  278. data/lib/puppet/pops/types/class_loader.rb +4 -6
  279. data/lib/puppet/pops/types/iterable.rb +1 -1
  280. data/lib/puppet/pops/types/p_binary_type.rb +1 -1
  281. data/lib/puppet/pops/types/p_init_type.rb +1 -1
  282. data/lib/puppet/pops/types/p_object_type.rb +5 -5
  283. data/lib/puppet/pops/types/p_object_type_extension.rb +4 -6
  284. data/lib/puppet/pops/types/p_sem_ver_range_type.rb +1 -1
  285. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  286. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  287. data/lib/puppet/pops/types/p_type_set_type.rb +10 -10
  288. data/lib/puppet/pops/types/p_uri_type.rb +4 -4
  289. data/lib/puppet/pops/types/recursion_guard.rb +4 -4
  290. data/lib/puppet/pops/types/ruby_generator.rb +2 -2
  291. data/lib/puppet/pops/types/string_converter.rb +12 -8
  292. data/lib/puppet/pops/types/tree_iterators.rb +4 -6
  293. data/lib/puppet/pops/types/type_calculator.rb +10 -10
  294. data/lib/puppet/pops/types/type_factory.rb +7 -3
  295. data/lib/puppet/pops/types/type_formatter.rb +22 -24
  296. data/lib/puppet/pops/types/type_mismatch_describer.rb +24 -24
  297. data/lib/puppet/pops/types/types.rb +28 -24
  298. data/lib/puppet/pops/utils.rb +38 -42
  299. data/lib/puppet/pops/validation/checker4_0.rb +10 -10
  300. data/lib/puppet/pops/validation/tasks_checker.rb +1 -1
  301. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
  302. data/lib/puppet/pops/validation.rb +4 -4
  303. data/lib/puppet/pops/visitor.rb +2 -2
  304. data/lib/puppet/property/ensure.rb +12 -14
  305. data/lib/puppet/property/keyvalue.rb +4 -4
  306. data/lib/puppet/property/list.rb +4 -4
  307. data/lib/puppet/property/ordered_list.rb +1 -1
  308. data/lib/puppet/property.rb +31 -33
  309. data/lib/puppet/provider/aix_object.rb +1 -1
  310. data/lib/puppet/provider/exec.rb +2 -2
  311. data/lib/puppet/provider/file/posix.rb +19 -17
  312. data/lib/puppet/provider/file/windows.rb +13 -19
  313. data/lib/puppet/provider/group/directoryservice.rb +3 -2
  314. data/lib/puppet/provider/group/groupadd.rb +32 -11
  315. data/lib/puppet/provider/group/windows_adsi.rb +2 -2
  316. data/lib/puppet/provider/nameservice/directoryservice.rb +29 -29
  317. data/lib/puppet/provider/nameservice/objectadd.rb +2 -4
  318. data/lib/puppet/provider/nameservice/pw.rb +1 -2
  319. data/lib/puppet/provider/nameservice.rb +8 -8
  320. data/lib/puppet/provider/package/aix.rb +19 -19
  321. data/lib/puppet/provider/package/appdmg.rb +2 -2
  322. data/lib/puppet/provider/package/apple.rb +1 -1
  323. data/lib/puppet/provider/package/apt.rb +18 -18
  324. data/lib/puppet/provider/package/aptitude.rb +1 -3
  325. data/lib/puppet/provider/package/aptrpm.rb +9 -9
  326. data/lib/puppet/provider/package/blastwave.rb +10 -14
  327. data/lib/puppet/provider/package/dnfmodule.rb +3 -3
  328. data/lib/puppet/provider/package/dpkg.rb +11 -13
  329. data/lib/puppet/provider/package/fink.rb +14 -14
  330. data/lib/puppet/provider/package/freebsd.rb +1 -1
  331. data/lib/puppet/provider/package/gem.rb +12 -14
  332. data/lib/puppet/provider/package/macports.rb +2 -2
  333. data/lib/puppet/provider/package/nim.rb +10 -10
  334. data/lib/puppet/provider/package/openbsd.rb +22 -22
  335. data/lib/puppet/provider/package/opkg.rb +6 -6
  336. data/lib/puppet/provider/package/pacman.rb +35 -29
  337. data/lib/puppet/provider/package/pip.rb +25 -24
  338. data/lib/puppet/provider/package/pkg.rb +15 -15
  339. data/lib/puppet/provider/package/pkgdmg.rb +10 -10
  340. data/lib/puppet/provider/package/pkgin.rb +2 -2
  341. data/lib/puppet/provider/package/pkgng.rb +5 -5
  342. data/lib/puppet/provider/package/pkgutil.rb +17 -21
  343. data/lib/puppet/provider/package/portage.rb +59 -61
  344. data/lib/puppet/provider/package/ports.rb +12 -11
  345. data/lib/puppet/provider/package/portupgrade.rb +35 -35
  346. data/lib/puppet/provider/package/puppetserver_gem.rb +10 -9
  347. data/lib/puppet/provider/package/rpm.rb +26 -26
  348. data/lib/puppet/provider/package/rug.rb +7 -9
  349. data/lib/puppet/provider/package/sun.rb +4 -4
  350. data/lib/puppet/provider/package/up2date.rb +5 -7
  351. data/lib/puppet/provider/package/urpmi.rb +6 -6
  352. data/lib/puppet/provider/package/windows/exe_package.rb +7 -7
  353. data/lib/puppet/provider/package/windows/msi_package.rb +3 -3
  354. data/lib/puppet/provider/package/windows/package.rb +2 -2
  355. data/lib/puppet/provider/package/windows.rb +3 -5
  356. data/lib/puppet/provider/package/xbps.rb +127 -0
  357. data/lib/puppet/provider/package/yum.rb +33 -37
  358. data/lib/puppet/provider/package/zypper.rb +12 -14
  359. data/lib/puppet/provider/package.rb +1 -1
  360. data/lib/puppet/provider/package_targetable.rb +1 -1
  361. data/lib/puppet/provider/parsedfile.rb +9 -9
  362. data/lib/puppet/provider/service/base.rb +16 -21
  363. data/lib/puppet/provider/service/bsd.rb +4 -4
  364. data/lib/puppet/provider/service/daemontools.rb +31 -31
  365. data/lib/puppet/provider/service/debian.rb +6 -6
  366. data/lib/puppet/provider/service/freebsd.rb +36 -36
  367. data/lib/puppet/provider/service/gentoo.rb +6 -6
  368. data/lib/puppet/provider/service/init.rb +19 -19
  369. data/lib/puppet/provider/service/launchd.rb +22 -22
  370. data/lib/puppet/provider/service/openbsd.rb +10 -10
  371. data/lib/puppet/provider/service/openrc.rb +1 -1
  372. data/lib/puppet/provider/service/openwrt.rb +3 -3
  373. data/lib/puppet/provider/service/rcng.rb +3 -3
  374. data/lib/puppet/provider/service/redhat.rb +4 -4
  375. data/lib/puppet/provider/service/runit.rb +6 -6
  376. data/lib/puppet/provider/service/service.rb +5 -7
  377. data/lib/puppet/provider/service/smf.rb +28 -27
  378. data/lib/puppet/provider/service/src.rb +7 -7
  379. data/lib/puppet/provider/service/systemd.rb +31 -37
  380. data/lib/puppet/provider/service/upstart.rb +17 -17
  381. data/lib/puppet/provider/service/windows.rb +7 -7
  382. data/lib/puppet/provider/user/aix.rb +4 -2
  383. data/lib/puppet/provider/user/directoryservice.rb +34 -36
  384. data/lib/puppet/provider/user/hpux.rb +10 -14
  385. data/lib/puppet/provider/user/pw.rb +1 -1
  386. data/lib/puppet/provider/user/user_role_add.rb +16 -18
  387. data/lib/puppet/provider/user/useradd.rb +7 -7
  388. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  389. data/lib/puppet/provider.rb +8 -8
  390. data/lib/puppet/reference/indirection.rb +3 -0
  391. data/lib/puppet/reference/metaparameter.rb +1 -1
  392. data/lib/puppet/reference/providers.rb +3 -3
  393. data/lib/puppet/reference/type.rb +1 -1
  394. data/lib/puppet/relationship.rb +4 -5
  395. data/lib/puppet/reports/http.rb +1 -1
  396. data/lib/puppet/reports/log.rb +2 -2
  397. data/lib/puppet/reports/store.rb +4 -4
  398. data/lib/puppet/reports.rb +2 -2
  399. data/lib/puppet/resource/catalog.rb +16 -16
  400. data/lib/puppet/resource/status.rb +3 -3
  401. data/lib/puppet/resource/type.rb +8 -8
  402. data/lib/puppet/resource/type_collection.rb +1 -1
  403. data/lib/puppet/resource.rb +41 -41
  404. data/lib/puppet/scheduler/scheduler.rb +1 -1
  405. data/lib/puppet/scheduler/splay_job.rb +9 -0
  406. data/lib/puppet/settings/alias_setting.rb +3 -5
  407. data/lib/puppet/settings/base_setting.rb +11 -11
  408. data/lib/puppet/settings/boolean_setting.rb +2 -2
  409. data/lib/puppet/settings/config_file.rb +5 -4
  410. data/lib/puppet/settings/duration_setting.rb +2 -2
  411. data/lib/puppet/settings/environment_conf.rb +3 -3
  412. data/lib/puppet/settings/file_or_directory_setting.rb +2 -2
  413. data/lib/puppet/settings/file_setting.rb +11 -11
  414. data/lib/puppet/settings/ini_file.rb +3 -3
  415. data/lib/puppet/settings/port_setting.rb +1 -1
  416. data/lib/puppet/settings/priority_setting.rb +2 -2
  417. data/lib/puppet/settings/ttl_setting.rb +2 -2
  418. data/lib/puppet/settings/value_translator.rb +8 -8
  419. data/lib/puppet/settings.rb +65 -70
  420. data/lib/puppet/ssl/base.rb +2 -4
  421. data/lib/puppet/ssl/certificate_request.rb +18 -22
  422. data/lib/puppet/ssl/certificate_request_attributes.rb +3 -3
  423. data/lib/puppet/ssl/oids.rb +2 -2
  424. data/lib/puppet/ssl/openssl_loader.rb +4 -4
  425. data/lib/puppet/syntax_checkers/base64.rb +3 -3
  426. data/lib/puppet/syntax_checkers/epp.rb +3 -3
  427. data/lib/puppet/syntax_checkers/json.rb +3 -3
  428. data/lib/puppet/syntax_checkers/pp.rb +3 -3
  429. data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
  430. data/lib/puppet/transaction/event.rb +2 -2
  431. data/lib/puppet/transaction/event_manager.rb +5 -5
  432. data/lib/puppet/transaction/persistence.rb +12 -14
  433. data/lib/puppet/transaction/report.rb +4 -4
  434. data/lib/puppet/transaction/resource_harness.rb +2 -2
  435. data/lib/puppet/transaction.rb +14 -18
  436. data/lib/puppet/type/component.rb +3 -3
  437. data/lib/puppet/type/exec.rb +51 -45
  438. data/lib/puppet/type/file/checksum_value.rb +1 -1
  439. data/lib/puppet/type/file/content.rb +6 -6
  440. data/lib/puppet/type/file/ctime.rb +2 -2
  441. data/lib/puppet/type/file/data_sync.rb +3 -3
  442. data/lib/puppet/type/file/ensure.rb +16 -15
  443. data/lib/puppet/type/file/mode.rb +9 -9
  444. data/lib/puppet/type/file/mtime.rb +2 -2
  445. data/lib/puppet/type/file/selcontext.rb +14 -14
  446. data/lib/puppet/type/file/source.rb +19 -21
  447. data/lib/puppet/type/file/target.rb +11 -11
  448. data/lib/puppet/type/file.rb +21 -21
  449. data/lib/puppet/type/filebucket.rb +3 -3
  450. data/lib/puppet/type/group.rb +3 -3
  451. data/lib/puppet/type/notify.rb +2 -2
  452. data/lib/puppet/type/package.rb +4 -4
  453. data/lib/puppet/type/resources.rb +6 -6
  454. data/lib/puppet/type/schedule.rb +9 -9
  455. data/lib/puppet/type/service.rb +6 -8
  456. data/lib/puppet/type/tidy.rb +22 -24
  457. data/lib/puppet/type/user.rb +13 -13
  458. data/lib/puppet/type.rb +76 -88
  459. data/lib/puppet/util/at_fork/solaris.rb +33 -37
  460. data/lib/puppet/util/autoload.rb +2 -2
  461. data/lib/puppet/util/backups.rb +9 -9
  462. data/lib/puppet/util/character_encoding.rb +7 -6
  463. data/lib/puppet/util/checksums.rb +2 -2
  464. data/lib/puppet/util/classgen.rb +8 -8
  465. data/lib/puppet/util/colors.rb +1 -1
  466. data/lib/puppet/util/command_line/puppet_option_parser.rb +1 -1
  467. data/lib/puppet/util/command_line/trollop.rb +60 -46
  468. data/lib/puppet/util/command_line.rb +2 -2
  469. data/lib/puppet/util/constant_inflector.rb +2 -2
  470. data/lib/puppet/util/diff.rb +19 -21
  471. data/lib/puppet/util/docs.rb +2 -2
  472. data/lib/puppet/util/errors.rb +9 -9
  473. data/lib/puppet/util/execution.rb +32 -9
  474. data/lib/puppet/util/feature.rb +1 -1
  475. data/lib/puppet/util/fileparsing.rb +12 -16
  476. data/lib/puppet/util/filetype.rb +36 -40
  477. data/lib/puppet/util/inifile.rb +6 -12
  478. data/lib/puppet/util/ldap/connection.rb +1 -1
  479. data/lib/puppet/util/ldap/manager.rb +10 -12
  480. data/lib/puppet/util/lockfile.rb +6 -8
  481. data/lib/puppet/util/log/destination.rb +2 -2
  482. data/lib/puppet/util/log/destinations.rb +4 -4
  483. data/lib/puppet/util/log.rb +12 -9
  484. data/lib/puppet/util/logging.rb +11 -11
  485. data/lib/puppet/util/metric.rb +3 -3
  486. data/lib/puppet/util/monkey_patches.rb +5 -7
  487. data/lib/puppet/util/network_device/config.rb +3 -3
  488. data/lib/puppet/util/package/version/debian.rb +27 -28
  489. data/lib/puppet/util/package/version/pip.rb +5 -5
  490. data/lib/puppet/util/package/version/range/eq.rb +1 -1
  491. data/lib/puppet/util/package/version/rpm.rb +1 -1
  492. data/lib/puppet/util/package.rb +2 -2
  493. data/lib/puppet/util/pidlock.rb +2 -2
  494. data/lib/puppet/util/platform.rb +1 -1
  495. data/lib/puppet/util/plist.rb +8 -10
  496. data/lib/puppet/util/posix.rb +17 -17
  497. data/lib/puppet/util/profiler/aggregate.rb +1 -1
  498. data/lib/puppet/util/provider_features.rb +3 -3
  499. data/lib/puppet/util/rdoc/code_objects.rb +3 -3
  500. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +63 -64
  501. data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +23 -23
  502. data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +12 -12
  503. data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
  504. data/lib/puppet/util/rdoc/parser.rb +1 -1
  505. data/lib/puppet/util/reference.rb +13 -9
  506. data/lib/puppet/util/retry_action.rb +1 -1
  507. data/lib/puppet/util/rpm_compare.rb +18 -19
  508. data/lib/puppet/util/rubygems.rb +1 -1
  509. data/lib/puppet/util/selinux.rb +7 -7
  510. data/lib/puppet/util/storage.rb +10 -12
  511. data/lib/puppet/util/suidmanager.rb +18 -19
  512. data/lib/puppet/util/symbolic_file_mode.rb +71 -75
  513. data/lib/puppet/util/tag_set.rb +2 -2
  514. data/lib/puppet/util/tagging.rb +8 -10
  515. data/lib/puppet/util/terminal.rb +4 -4
  516. data/lib/puppet/util/user_attr.rb +7 -7
  517. data/lib/puppet/util/watcher.rb +3 -5
  518. data/lib/puppet/util/windows/access_control_list.rb +1 -1
  519. data/lib/puppet/util/windows/adsi.rb +42 -42
  520. data/lib/puppet/util/windows/com.rb +2 -2
  521. data/lib/puppet/util/windows/daemon.rb +64 -68
  522. data/lib/puppet/util/windows/error.rb +2 -2
  523. data/lib/puppet/util/windows/file.rb +18 -25
  524. data/lib/puppet/util/windows/monkey_patches/process.rb +1 -1
  525. data/lib/puppet/util/windows/principal.rb +8 -8
  526. data/lib/puppet/util/windows/process.rb +16 -28
  527. data/lib/puppet/util/windows/registry.rb +16 -15
  528. data/lib/puppet/util/windows/root_certs.rb +2 -2
  529. data/lib/puppet/util/windows/security.rb +31 -31
  530. data/lib/puppet/util/windows/service.rb +11 -11
  531. data/lib/puppet/util/windows/sid.rb +8 -8
  532. data/lib/puppet/util/windows/user.rb +18 -20
  533. data/lib/puppet/util/yaml.rb +1 -1
  534. data/lib/puppet/util.rb +55 -46
  535. data/lib/puppet/version.rb +2 -2
  536. data/lib/puppet/x509/pem_store.rb +1 -1
  537. data/lib/puppet.rb +3 -3
  538. data/locales/puppet.pot +604 -600
  539. data/man/man5/puppet.conf.5 +10 -2
  540. data/man/man8/puppet-agent.8 +1 -1
  541. data/man/man8/puppet-apply.8 +1 -1
  542. data/man/man8/puppet-catalog.8 +1 -1
  543. data/man/man8/puppet-config.8 +1 -1
  544. data/man/man8/puppet-describe.8 +1 -1
  545. data/man/man8/puppet-device.8 +1 -1
  546. data/man/man8/puppet-doc.8 +1 -1
  547. data/man/man8/puppet-epp.8 +1 -1
  548. data/man/man8/puppet-facts.8 +1 -1
  549. data/man/man8/puppet-filebucket.8 +1 -1
  550. data/man/man8/puppet-generate.8 +1 -1
  551. data/man/man8/puppet-help.8 +1 -1
  552. data/man/man8/puppet-lookup.8 +1 -1
  553. data/man/man8/puppet-module.8 +1 -1
  554. data/man/man8/puppet-node.8 +1 -1
  555. data/man/man8/puppet-parser.8 +1 -1
  556. data/man/man8/puppet-plugin.8 +1 -1
  557. data/man/man8/puppet-report.8 +1 -1
  558. data/man/man8/puppet-resource.8 +5 -1
  559. data/man/man8/puppet-script.8 +1 -1
  560. data/man/man8/puppet-ssl.8 +1 -1
  561. data/man/man8/puppet.8 +2 -2
  562. metadata +23 -27
  563. data/examples/hiera/etc/hiera.yaml +0 -15
  564. data/examples/hiera/etc/hieradb/common.yaml +0 -3
  565. data/examples/hiera/etc/hieradb/dc1.yaml +0 -6
  566. data/examples/hiera/etc/hieradb/development.yaml +0 -2
  567. data/examples/hiera/etc/puppet.conf +0 -3
  568. data/examples/hiera/modules/data/manifests/common.pp +0 -4
  569. data/examples/hiera/modules/ntp/manifests/data.pp +0 -4
  570. data/examples/hiera/modules/ntp/templates/ntp.conf.erb +0 -3
  571. data/examples/hiera/modules/users/manifests/development.pp +0 -4
  572. data/tasks/benchmark.rake +0 -180
  573. data/tasks/cfpropertylist.rake +0 -15
  574. data/tasks/ci.rake +0 -24
  575. data/tasks/generate_ast_model.rake +0 -90
  576. data/tasks/generate_cert_fixtures.rake +0 -199
  577. data/tasks/manpages.rake +0 -67
  578. data/tasks/memwalk.rake +0 -195
  579. data/tasks/parallel.rake +0 -410
  580. data/tasks/parser.rake +0 -22
  581. data/tasks/yard.rake +0 -59
@@ -20,13 +20,13 @@ module Puppet::Util::CharacterEncoding
20
20
  string_copy = string.dup
21
21
  begin
22
22
  if original_encoding == Encoding::UTF_8
23
- if !string_copy.valid_encoding?
23
+ unless string_copy.valid_encoding?
24
24
  Puppet.debug {
25
25
  _("%{value} is already labeled as UTF-8 but this encoding is invalid. It cannot be transcoded by Puppet.") % { value: string.dump }
26
26
  }
27
27
  end
28
28
  # String is already valid UTF-8 - noop
29
- return string_copy
29
+ string_copy
30
30
  else
31
31
  # If the string comes to us as BINARY encoded, we don't know what it
32
32
  # started as. However, to encode! we need a starting place, and our
@@ -34,7 +34,7 @@ module Puppet::Util::CharacterEncoding
34
34
  # So set external_encoding to default_external before we try to
35
35
  # transcode to UTF-8.
36
36
  string_copy.force_encoding(Encoding.default_external) if original_encoding == Encoding::BINARY
37
- return string_copy.encode(Encoding::UTF_8)
37
+ string_copy.encode(Encoding::UTF_8)
38
38
  end
39
39
  rescue EncodingError => detail
40
40
  # Set the encoding on our copy back to its original if we modified it
@@ -46,7 +46,7 @@ module Puppet::Util::CharacterEncoding
46
46
  Puppet.debug {
47
47
  _("%{error}: %{value} cannot be transcoded by Puppet.") % { error: detail.inspect, value: string.dump }
48
48
  }
49
- return string_copy
49
+ string_copy
50
50
  end
51
51
  end
52
52
 
@@ -68,14 +68,15 @@ module Puppet::Util::CharacterEncoding
68
68
  string_copy = string.dup
69
69
  original_encoding = string_copy.encoding
70
70
  return string_copy if original_encoding == Encoding::UTF_8
71
+
71
72
  if string_copy.force_encoding(Encoding::UTF_8).valid_encoding?
72
- return string_copy
73
+ string_copy
73
74
  else
74
75
  Puppet.debug {
75
76
  _("%{value} is not valid UTF-8 and result of overriding encoding would be invalid.") % { value: string.dump }
76
77
  }
77
78
  # Set copy back to its original encoding before returning
78
- return string_copy.force_encoding(original_encoding)
79
+ string_copy.force_encoding(original_encoding)
79
80
  end
80
81
  end
81
82
  end
@@ -45,12 +45,12 @@ module Puppet::Util::Checksums
45
45
 
46
46
  # Strip the checksum type from an existing checksum
47
47
  def sumdata(checksum)
48
- checksum =~ /^\{(\w+)\}(.+)/ ? $2 : nil
48
+ checksum =~ /^\{(\w+)\}(.+)/ ? ::Regexp.last_match(2) : nil
49
49
  end
50
50
 
51
51
  # Strip the checksum type from an existing checksum
52
52
  def sumtype(checksum)
53
- checksum =~ /^\{(\w+)\}/ ? $1 : nil
53
+ checksum =~ /^\{(\w+)\}/ ? ::Regexp.last_match(1) : nil
54
54
  end
55
55
 
56
56
  # Calculate a checksum using Digest::SHA256.
@@ -177,11 +177,11 @@ module Puppet::Util::ClassGen
177
177
 
178
178
  [:include, :extend].each do |method|
179
179
  set = options[method]
180
- if set
181
- set = [set] unless set.is_a?(Array)
182
- set.each do |mod|
183
- klass.send(method, mod)
184
- end
180
+ next unless set
181
+
182
+ set = [set] unless set.is_a?(Array)
183
+ set.each do |mod|
184
+ klass.send(method, mod)
185
185
  end
186
186
  end
187
187
 
@@ -210,9 +210,9 @@ module Puppet::Util::ClassGen
210
210
  # If we were told to stick it in a hash, then do so
211
211
  array = options[:array]
212
212
  if array
213
- if (klass.respond_to? :name and
214
- array.find { |c| c.name == klassname } and
215
- !options[:overwrite])
213
+ if klass.respond_to? :name and
214
+ array.find { |c| c.name == klassname } and
215
+ !options[:overwrite]
216
216
  raise Puppet::SubclassAlreadyDefined,
217
217
  _("Already a generated class named %{klassname}") % { klassname: klassname }
218
218
  end
@@ -97,6 +97,6 @@ module Puppet::Util::Colors
97
97
 
98
98
  def html_color(color, str)
99
99
  span = '<span style="%s">' % Colormap[color][:html]
100
- "#{span}%s</span>" % str.gsub(/<span .*?<\/span>/, "</span>\\0#{span}")
100
+ "#{span}%s</span>" % str.gsub(%r{<span .*?</span>}, "</span>\\0#{span}")
101
101
  end
102
102
  end
@@ -63,7 +63,7 @@ module Puppet
63
63
  when :NONE
64
64
  options[:type] = :flag
65
65
  else
66
- raise PuppetOptionError.new(_("Unsupported type: '%{type}'") % { type: type })
66
+ raise PuppetOptionError, _("Unsupported type: '%{type}'") % { type: type }
67
67
  end
68
68
 
69
69
  @parser.opt long.sub("^--", "").intern, desc, options
@@ -33,10 +33,10 @@ class CommandLine
33
33
  class VersionNeeded < StandardError; end
34
34
 
35
35
  ## Regex for floating point numbers
36
- FLOAT_RE = /^-?((\d+(\.\d+)?)|(\.\d+))([eE][-+]?[\d]+)?$/
36
+ FLOAT_RE = /^-?((\d+(\.\d+)?)|(\.\d+))([eE][-+]?\d+)?$/
37
37
 
38
38
  ## Regex for parameters
39
- PARAM_RE = /^-(-|\.$|[^\d\.])/
39
+ PARAM_RE = /^-(-|\.$|[^\d.])/
40
40
 
41
41
  ## The commandline parser. In typical usage, the methods in this class
42
42
  ## will be handled internally by Trollop::options. In this case, only the
@@ -221,7 +221,7 @@ class CommandLine
221
221
  opts[:long] =
222
222
  case opts[:long]
223
223
  when /^--([^-].*)$/
224
- $1
224
+ ::Regexp.last_match(1)
225
225
  when /^[^-]/
226
226
  opts[:long]
227
227
  else
@@ -234,7 +234,7 @@ class CommandLine
234
234
  opts[:short] = opts[:short].to_s if opts[:short]
235
235
  end
236
236
  opts[:short] = case opts[:short]
237
- when /^-(.)$/; $1
237
+ when /^-(.)$/; ::Regexp.last_match(1)
238
238
  when nil, :none, /^.$/; opts[:short]
239
239
  else raise ArgumentError, _("invalid short option name '%{name}'") % { name: opts[:short].inspect }
240
240
  end
@@ -333,11 +333,29 @@ class CommandLine
333
333
  @leftovers = each_arg cmdline do |arg, params|
334
334
  sym = case arg
335
335
  when /^-([^-])$/
336
- @short[$1]
336
+ @short[::Regexp.last_match(1)]
337
337
  when /^--no-([^-]\S*)$/
338
- @long["[no-]#{$1}"]
338
+ possible_match = @long["[no-]#{::Regexp.last_match(1)}"]
339
+ if !possible_match
340
+ partial_match = @long["[no-]#{::Regexp.last_match(1).tr('-', '_')}"] || @long["[no-]#{::Regexp.last_match(1).tr('_', '-')}"]
341
+ if partial_match
342
+ Puppet.deprecation_warning _("Partial argument match detected: correct argument is %{partial_match}, got %{arg}. Partial argument matching is deprecated and will be removed in a future release.") % { arg: arg, partial_match: partial_match }
343
+ end
344
+ partial_match
345
+ else
346
+ possible_match
347
+ end
339
348
  when /^--([^-]\S*)$/
340
- @long[$1] ? @long[$1] : @long["[no-]#{$1}"]
349
+ possible_match = @long[::Regexp.last_match(1)] || @long["[no-]#{::Regexp.last_match(1)}"]
350
+ if !possible_match
351
+ partial_match = @long[::Regexp.last_match(1).tr('-', '_')] || @long[::Regexp.last_match(1).tr('_', '-')] || @long["[no-]#{::Regexp.last_match(1).tr('-', '_')}"] || @long["[no-]#{::Regexp.last_match(1).tr('_', '-')}"]
352
+ if partial_match
353
+ Puppet.deprecation_warning _("Partial argument match detected: correct argument is %{partial_match}, got %{arg}. Partial argument matching is deprecated and will be removed in a future release.") % { arg: arg, partial_match: partial_match }
354
+ end
355
+ partial_match
356
+ else
357
+ possible_match
358
+ end
341
359
  else
342
360
  raise CommandlineError, _("invalid argument syntax: '%{arg}'") % { arg: arg }
343
361
  end
@@ -417,7 +435,7 @@ class CommandLine
417
435
  when :float, :floats
418
436
  vals[sym] = params.map { |pg| pg.map { |p| parse_float_parameter p, arg } }
419
437
  when :string, :strings
420
- vals[sym] = params.map { |pg| pg.map { |p| p.to_s } }
438
+ vals[sym] = params.map { |pg| pg.map(&:to_s) }
421
439
  when :io, :ios
422
440
  vals[sym] = params.map { |pg| pg.map { |p| parse_io_parameter p, arg } }
423
441
  when :date, :dates
@@ -425,13 +443,13 @@ class CommandLine
425
443
  end
426
444
 
427
445
  if SINGLE_ARG_TYPES.include?(opts[:type])
428
- unless opts[:multi] # single parameter
429
- vals[sym] = vals[sym][0][0]
430
- else # multiple options, each with a single parameter
446
+ if opts[:multi] # multiple options, each with a single parameter
431
447
  vals[sym] = vals[sym].map { |p| p[0] }
448
+ else # single parameter
449
+ vals[sym] = vals[sym][0][0]
432
450
  end
433
451
  elsif MULTI_ARG_TYPES.include?(opts[:type]) && !opts[:multi]
434
- vals[sym] = vals[sym][0] # single option, with multiple parameters
452
+ vals[sym] = vals[sym][0] # single option, with multiple parameters
435
453
  end
436
454
  # else: multiple options, with multiple parameters
437
455
 
@@ -454,15 +472,13 @@ class CommandLine
454
472
 
455
473
  def parse_date_parameter param, arg # :nodoc:
456
474
  begin
457
- begin
458
- time = Chronic.parse(param)
459
- rescue NameError
460
- # chronic is not available
461
- end
462
- time ? Date.new(time.year, time.month, time.day) : Date.parse(param)
463
- rescue ArgumentError
464
- raise CommandlineError, _("option '%{arg}' needs a date") % { arg: arg }, $!.backtrace
475
+ time = Chronic.parse(param)
476
+ rescue NameError
477
+ # chronic is not available
465
478
  end
479
+ time ? Date.new(time.year, time.month, time.day) : Date.parse(param)
480
+ rescue ArgumentError => e
481
+ raise CommandlineError, _("option '%{arg}' needs a date") % { arg: arg }, e.backtrace
466
482
  end
467
483
 
468
484
  ## Print the help message to +stream+.
@@ -489,11 +505,11 @@ class CommandLine
489
505
  end
490
506
  end
491
507
 
492
- leftcol_width = left.values.map { |s| s.length }.max || 0
508
+ leftcol_width = left.values.map(&:length).max || 0
493
509
  rightcol_start = leftcol_width + 6 # spaces
494
510
 
495
511
  unless @order.size > 0 && @order.first.first == :text
496
- stream.puts "#@version\n" if @version
512
+ stream.puts "#{@version}\n" if @version
497
513
  stream.puts _("Options:")
498
514
  end
499
515
 
@@ -582,11 +598,14 @@ class CommandLine
582
598
  remains += args[(i + 1)..]
583
599
  return remains
584
600
  when /^--(\S+?)=(.*)$/ # long argument with equals
585
- yield "--#{$1}", [$2]
601
+ yield "--#{::Regexp.last_match(1)}", [::Regexp.last_match(2)]
586
602
  i += 1
587
603
  when /^--(\S+)$/ # long argument
588
604
  params = collect_argument_parameters(args, i + 1)
589
- unless params.empty?
605
+ if params.empty? # long argument no parameter
606
+ yield args[i], nil
607
+ i += 1
608
+ else
590
609
  num_params_taken = yield args[i], params
591
610
  unless num_params_taken
592
611
  if @stop_on_unknown
@@ -597,16 +616,16 @@ class CommandLine
597
616
  end
598
617
  end
599
618
  i += 1 + num_params_taken
600
- else # long argument no parameter
601
- yield args[i], nil
602
- i += 1
603
619
  end
604
620
  when /^-(\S+)$/ # one or more short arguments
605
- shortargs = $1.split(//)
621
+ shortargs = ::Regexp.last_match(1).split(//)
606
622
  shortargs.each_with_index do |a, j|
607
623
  if j == (shortargs.length - 1)
608
624
  params = collect_argument_parameters(args, i + 1)
609
- unless params.empty?
625
+ if params.empty? # argument no parameter
626
+ yield "-#{a}", nil
627
+ i += 1
628
+ else
610
629
  num_params_taken = yield "-#{a}", params
611
630
  unless num_params_taken
612
631
  if @stop_on_unknown
@@ -617,9 +636,6 @@ class CommandLine
617
636
  end
618
637
  end
619
638
  i += 1 + num_params_taken
620
- else # argument no parameter
621
- yield "-#{a}", nil
622
- i += 1
623
639
  end
624
640
  else
625
641
  yield "-#{a}", nil
@@ -667,7 +683,7 @@ class CommandLine
667
683
  def collect_argument_parameters args, start_at
668
684
  params = []
669
685
  pos = start_at
670
- while args[pos] && args[pos] !~ PARAM_RE && !@stop_words.member?(args[pos]) do
686
+ while args[pos] && args[pos] !~ PARAM_RE && !@stop_words.member?(args[pos])
671
687
  params << args[pos]
672
688
  pos += 1
673
689
  end
@@ -784,19 +800,17 @@ class CommandLine
784
800
  ## Requires passing in the parser object.
785
801
 
786
802
  def with_standard_exception_handling parser
787
- begin
788
- yield
789
- rescue CommandlineError => e
790
- $stderr.puts _("Error: %{value0}.") % { value0: e.message }
791
- $stderr.puts _("Try --help for help.")
792
- exit(-1)
793
- rescue HelpNeeded
794
- parser.educate
795
- exit
796
- rescue VersionNeeded
797
- puts parser.version
798
- exit
799
- end
803
+ yield
804
+ rescue CommandlineError => e
805
+ $stderr.puts _("Error: %{value0}.") % { value0: e.message }
806
+ $stderr.puts _("Try --help for help.")
807
+ exit(-1)
808
+ rescue HelpNeeded
809
+ parser.educate
810
+ exit
811
+ rescue VersionNeeded
812
+ puts parser.version
813
+ exit
800
814
  end
801
815
 
802
816
  ## Informs the user that their usage of 'arg' was wrong, as detailed by
@@ -4,7 +4,7 @@
4
4
  # load gems. If Bundler is loaded, let it determine what can be
5
5
  # loaded. If it's not loaded, then use rubygems. But do this before
6
6
  # loading any puppet code, so that our gem loading system is sane.
7
- if not defined? ::Bundler
7
+ unless defined? ::Bundler
8
8
  begin
9
9
  require 'rubygems'
10
10
  rescue LoadError
@@ -31,7 +31,7 @@ module Puppet
31
31
  # @param zero [String] the name of the executable
32
32
  # @param argv [Array<String>] the arguments passed on the command line
33
33
  # @param stdin [IO] (unused)
34
- def initialize(zero = $0, argv = ARGV, stdin = STDIN)
34
+ def initialize(zero = $PROGRAM_NAME, argv = ARGV, stdin = STDIN)
35
35
  @command = File.basename(zero, '.rb')
36
36
  @argv = argv
37
37
  end
@@ -12,12 +12,12 @@ module Puppet
12
12
  module Util
13
13
  module ConstantInflector
14
14
  def file2constant(file)
15
- file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |_term| $1.capitalize }
15
+ file.split("/").collect(&:capitalize).join("::").gsub(/_+(.)/) { |_term| ::Regexp.last_match(1).capitalize }
16
16
  end
17
17
  module_function :file2constant
18
18
 
19
19
  def constant2file(constant)
20
- constant.to_s.gsub(/([a-z])([A-Z])/) { |_term| $1 + "_#{$2}" }.gsub("::", "/").downcase
20
+ constant.to_s.gsub(/([a-z])([A-Z])/) { |_term| ::Regexp.last_match(1) + "_#{::Regexp.last_match(2)}" }.gsub("::", "/").downcase
21
21
  end
22
22
  module_function :constant2file
23
23
  end
@@ -32,8 +32,8 @@ module Puppet::Util::Diff
32
32
  Puppet.warning _("Cannot provide diff without the diff/lcs Ruby library")
33
33
  return ""
34
34
  end
35
- data_old = data_old.split(/\n/).map! { |e| e.chomp }
36
- data_new = data_new.split(/\n/).map! { |e| e.chomp }
35
+ data_old = data_old.split(/\n/).map!(&:chomp)
36
+ data_new = data_new.split(/\n/).map!(&:chomp)
37
37
 
38
38
  output = ''.dup
39
39
 
@@ -44,27 +44,25 @@ module Puppet::Util::Diff
44
44
  file_length_difference = 0
45
45
 
46
46
  diffs.each do |piece|
47
- begin
48
- hunk = ::Diff::LCS::Hunk.new(
49
- data_old, data_new, piece,
50
- context_lines,
51
- file_length_difference
52
- )
53
- file_length_difference = hunk.file_length_difference
54
- next unless oldhunk
47
+ hunk = ::Diff::LCS::Hunk.new(
48
+ data_old, data_new, piece,
49
+ context_lines,
50
+ file_length_difference
51
+ )
52
+ file_length_difference = hunk.file_length_difference
53
+ next unless oldhunk
55
54
 
56
- # Hunks may overlap, which is why we need to be careful when our
57
- # diff includes lines of context. Otherwise, we might print
58
- # redundant lines.
59
- if (context_lines > 0) and hunk.overlaps?(oldhunk)
60
- hunk.unshift(oldhunk)
61
- else
62
- output << oldhunk.diff(format)
63
- end
64
- ensure
65
- oldhunk = hunk
66
- output << "\n"
55
+ # Hunks may overlap, which is why we need to be careful when our
56
+ # diff includes lines of context. Otherwise, we might print
57
+ # redundant lines.
58
+ if (context_lines > 0) and hunk.overlaps?(oldhunk)
59
+ hunk.unshift(oldhunk)
60
+ else
61
+ output << oldhunk.diff(format)
67
62
  end
63
+ ensure
64
+ oldhunk = hunk
65
+ output << "\n"
68
66
  end
69
67
 
70
68
  # Handle the last remaining hunk
@@ -21,7 +21,7 @@ module Puppet::Util::Docs
21
21
  # Generate the full doc string.
22
22
  def doc
23
23
  extra = methods.find_all { |m| m.to_s =~ /^dochook_.+/ }.sort.filter_map { |m|
24
- self.send(m)
24
+ send(m)
25
25
  }.collect { |r| "* #{r}" }.join("\n")
26
26
 
27
27
  if @doc
@@ -125,7 +125,7 @@ module Puppet::Util::Docs
125
125
  text = text.gsub(/^#{indent}/, '')
126
126
  end
127
127
  # Clean trailing space
128
- text.lines.map { |line| line.rstrip }.join("\n").rstrip
128
+ text.lines.map(&:rstrip).join("\n").rstrip
129
129
  end
130
130
 
131
131
  module_function :scrub
@@ -22,8 +22,8 @@ module Puppet::Util::Errors
22
22
  # @param other [Exception] original exception, source of backtrace info
23
23
  # @return [Exception] error parameter
24
24
  def adderrorcontext(error, other = nil)
25
- error.line ||= self.line if error.respond_to?(:line=) and self.respond_to?(:line) and self.line
26
- error.file ||= self.file if error.respond_to?(:file=) and self.respond_to?(:file) and self.file
25
+ error.line ||= line if error.respond_to?(:line=) and respond_to?(:line) and line
26
+ error.file ||= file if error.respond_to?(:file=) and respond_to?(:file) and file
27
27
  error.original ||= other if error.respond_to?(:original=)
28
28
 
29
29
  error.set_backtrace(other.backtrace) if other and other.respond_to?(:backtrace)
@@ -42,9 +42,9 @@ module Puppet::Util::Errors
42
42
  # @return [String] description of file, line, and column
43
43
  #
44
44
  def self.error_location(file, line = nil, column = nil)
45
- file = nil if (file.is_a?(String) && file.empty?)
46
- line = nil if (line.is_a?(String) && line.empty?)
47
- column = nil if (column.is_a?(String) && column.empty?)
45
+ file = nil if file.is_a?(String) && file.empty?
46
+ line = nil if line.is_a?(String) && line.empty?
47
+ column = nil if column.is_a?(String) && column.empty?
48
48
  if file and line and column
49
49
  _("(file: %{file}, line: %{line}, column: %{column})") % { file: file, line: line, column: column }
50
50
  elsif file and line
@@ -85,10 +85,10 @@ module Puppet::Util::Errors
85
85
  # @param line [String] the line number for the error (nil or "", for not known)
86
86
  # @return [String] description of file, and line
87
87
  def self.error_location_with_unknowns(file, line)
88
- file = nil if (file.is_a?(String) && file.empty?)
89
- line = nil if (line.is_a?(String) && line.empty?)
90
- file = _('unknown') unless file
91
- line = _('unknown') unless line
88
+ file = nil if file.is_a?(String) && file.empty?
89
+ line = nil if line.is_a?(String) && line.empty?
90
+ file ||= _('unknown')
91
+ line ||= _('unknown')
92
92
  error_location(file, line)
93
93
  end
94
94
 
@@ -212,13 +212,25 @@ module Puppet::Util::Execution
212
212
  execution_stub = Puppet::Util::ExecutionStub.current_value
213
213
  if execution_stub
214
214
  child_pid = execution_stub.call(*exec_args)
215
- [stdin, stdout, stderr].each { |io| io.close rescue nil }
215
+ [stdin, stdout, stderr].each { |io|
216
+ begin
217
+ io.close
218
+ rescue
219
+ nil
220
+ end
221
+ }
216
222
  return child_pid
217
223
  elsif Puppet.features.posix?
218
224
  child_pid = nil
219
225
  begin
220
226
  child_pid = execute_posix(*exec_args)
221
- [stdin, stdout, stderr].each { |io| io.close rescue nil }
227
+ [stdin, stdout, stderr].each { |io|
228
+ begin
229
+ io.close
230
+ rescue
231
+ nil
232
+ end
233
+ }
222
234
  if options[:squelch]
223
235
  exit_status = Process.waitpid2(child_pid).last.exitstatus
224
236
  else
@@ -276,7 +288,13 @@ module Puppet::Util::Execution
276
288
  elsif Puppet::Util::Platform.windows?
277
289
  process_info = execute_windows(*exec_args)
278
290
  begin
279
- [stdin, stderr].each { |io| io.close rescue nil }
291
+ [stdin, stderr].each { |io|
292
+ begin
293
+ io.close
294
+ rescue
295
+ nil
296
+ end
297
+ }
280
298
  exit_status = Puppet::Util::Windows::Process.wait_process(process_info.process_handle)
281
299
 
282
300
  # read output in if required
@@ -295,8 +313,14 @@ module Puppet::Util::Execution
295
313
  end
296
314
  ensure
297
315
  # Make sure all handles are closed in case an exception was thrown attempting to execute.
298
- [stdin, stdout, stderr].each { |io| io.close rescue nil }
299
- if !options[:squelch]
316
+ [stdin, stdout, stderr].each { |io|
317
+ begin
318
+ io.close
319
+ rescue
320
+ nil
321
+ end
322
+ }
323
+ unless options[:squelch]
300
324
  # if we opened a pipe, we need to clean it up.
301
325
  reader.close if reader
302
326
  stdout.close! if Puppet::Util::Platform.windows?
@@ -327,7 +351,7 @@ module Puppet::Util::Execution
327
351
  # @api private
328
352
  #
329
353
  def self.execute_posix(command, options, stdin, stdout, stderr)
330
- child_pid = Puppet::Util.safe_posix_fork(stdin, stdout, stderr) do
354
+ Puppet::Util.safe_posix_fork(stdin, stdout, stderr) do
331
355
  # We can't just call Array(command), and rely on it returning
332
356
  # things like ['foo'], when passed ['foo'], because
333
357
  # Array(command) will call command.to_a internally, which when
@@ -345,7 +369,7 @@ module Puppet::Util::Execution
345
369
  Puppet::Util::SUIDManager.change_privileges(options[:uid], options[:gid], true)
346
370
 
347
371
  # if the caller has requested that we override locale environment variables,
348
- if (options[:override_locale]) then
372
+ if options[:override_locale] then
349
373
  # loop over them and clear them
350
374
  Puppet::Util::POSIX::LOCALE_ENV_VARS.each { |name| ENV.delete(name) }
351
375
  # set LANG and LC_ALL to 'C' so that the command will have consistent, predictable output
@@ -371,7 +395,6 @@ module Puppet::Util::Execution
371
395
  exit!(1)
372
396
  end
373
397
  end
374
- child_pid
375
398
  end
376
399
  private_class_method :execute_posix
377
400
 
@@ -381,7 +404,7 @@ module Puppet::Util::Execution
381
404
  #
382
405
  def self.execute_windows(command, options, stdin, stdout, stderr)
383
406
  command = command.map do |part|
384
- part.include?(' ') ? %Q["#{part.gsub(/"/, '\"')}"] : part
407
+ part.include?(' ') ? %Q("#{part.gsub(/"/, '\"')}") : part
385
408
  end.join(" ") if command.is_a?(Array)
386
409
 
387
410
  options[:custom_environment] ||= {}
@@ -77,7 +77,7 @@ class Puppet::Util::Feature
77
77
  feature = method.to_s.sub(/\?$/, '')
78
78
  @loader.load(feature, Puppet.lookup(:current_environment))
79
79
 
80
- respond_to?(method) && self.send(method)
80
+ respond_to?(method) && send(method)
81
81
  end
82
82
 
83
83
  # Actually test whether the feature is present. We only want to test when
@@ -42,7 +42,7 @@ module Puppet::Util::FileParsing
42
42
  def fields=(fields)
43
43
  @fields = fields.collect do |field|
44
44
  r = field.intern
45
- raise ArgumentError.new(_("Cannot have fields named %{name}") % { name: r }) if INVALID_FIELDS.include?(r)
45
+ raise ArgumentError, _("Cannot have fields named %{name}") % { name: r } if INVALID_FIELDS.include?(r)
46
46
 
47
47
  r
48
48
  end
@@ -121,9 +121,7 @@ module Puppet::Util::FileParsing
121
121
 
122
122
  # Customize this so we can do a bit of validation.
123
123
  def optional=(optional)
124
- @optional = optional.collect do |field|
125
- field.intern
126
- end
124
+ @optional = optional.collect(&:intern)
127
125
  end
128
126
 
129
127
  # Create a hook that modifies the hash resulting from parsing.
@@ -230,9 +228,9 @@ module Puppet::Util::FileParsing
230
228
 
231
229
  if ret
232
230
  ret[:record_type] = record.name
233
- return ret
231
+ ret
234
232
  else
235
- return nil
233
+ nil
236
234
  end
237
235
  end
238
236
 
@@ -246,7 +244,7 @@ module Puppet::Util::FileParsing
246
244
  def lines(text)
247
245
  # NOTE: We do not have to remove trailing separators because split will ignore
248
246
  # them by default (unless you pass -1 as a second parameter)
249
- text.split(self.line_separator)
247
+ text.split(line_separator)
250
248
  end
251
249
 
252
250
  # Split a bunch of text into lines and then parse them individually.
@@ -346,7 +344,7 @@ module Puppet::Util::FileParsing
346
344
  end
347
345
 
348
346
  case record.type
349
- when :text; return details[:line]
347
+ when :text; details[:line]
350
348
  else
351
349
  return record.to_line(details) if record.respond_to?(:to_line)
352
350
 
@@ -358,9 +356,9 @@ module Puppet::Util::FileParsing
358
356
  if regex == true
359
357
  regex = /\s+$/
360
358
  end
361
- return line.sub(regex, '')
359
+ line.sub(regex, '')
362
360
  else
363
- return line
361
+ line
364
362
  end
365
363
  end
366
364
  end
@@ -368,9 +366,9 @@ module Puppet::Util::FileParsing
368
366
  # Whether to add a trailing separator to the file. Defaults to true
369
367
  def trailing_separator
370
368
  if defined?(@trailing_separator)
371
- return @trailing_separator
369
+ @trailing_separator
372
370
  else
373
- return true
371
+ true
374
372
  end
375
373
  end
376
374
 
@@ -378,11 +376,9 @@ module Puppet::Util::FileParsing
378
376
  type = type.intern
379
377
  record = record_type(type)
380
378
  if record && record.fields.include?(attr.intern)
381
- return true
382
- elsif attr.intern == :ensure
383
- return true
379
+ true
384
380
  else
385
- false
381
+ attr.intern == :ensure
386
382
  end
387
383
  end
388
384