bolt 0.24.0 → 0.25.0

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

Potentially problematic release.


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

Files changed (1155) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/datatypes/applyresult.rb +19 -0
  3. data/bolt-modules/boltlib/lib/puppet/datatypes/resultset.rb +3 -3
  4. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +2 -1
  5. data/lib/bolt/analytics.rb +0 -1
  6. data/lib/bolt/applicator.rb +7 -54
  7. data/lib/bolt/apply_result.rb +116 -0
  8. data/lib/bolt/outputter/human.rb +13 -8
  9. data/lib/bolt/pal.rb +6 -2
  10. data/lib/bolt/transport/ssh.rb +2 -1
  11. data/lib/bolt/version.rb +1 -1
  12. data/lib/bolt_spec/run.rb +1 -0
  13. data/libexec/apply_catalog.rb +25 -30
  14. metadata +37 -1212
  15. data/vendored/facter/lib/facter.rb +0 -261
  16. data/vendored/facter/lib/facter/Cfkey.rb +0 -42
  17. data/vendored/facter/lib/facter/application.rb +0 -206
  18. data/vendored/facter/lib/facter/architecture.rb +0 -50
  19. data/vendored/facter/lib/facter/augeasversion.rb +0 -28
  20. data/vendored/facter/lib/facter/blockdevices.rb +0 -105
  21. data/vendored/facter/lib/facter/core/aggregate.rb +0 -220
  22. data/vendored/facter/lib/facter/core/directed_graph.rb +0 -46
  23. data/vendored/facter/lib/facter/core/execution.rb +0 -123
  24. data/vendored/facter/lib/facter/core/execution/base.rb +0 -81
  25. data/vendored/facter/lib/facter/core/execution/posix.rb +0 -50
  26. data/vendored/facter/lib/facter/core/execution/windows.rb +0 -57
  27. data/vendored/facter/lib/facter/core/logging.rb +0 -197
  28. data/vendored/facter/lib/facter/core/resolvable.rb +0 -94
  29. data/vendored/facter/lib/facter/core/suitable.rb +0 -113
  30. data/vendored/facter/lib/facter/dhcp_servers.rb +0 -45
  31. data/vendored/facter/lib/facter/domain.rb +0 -99
  32. data/vendored/facter/lib/facter/ec2.rb +0 -68
  33. data/vendored/facter/lib/facter/ec2/rest.rb +0 -137
  34. data/vendored/facter/lib/facter/facterversion.rb +0 -15
  35. data/vendored/facter/lib/facter/filesystems.rb +0 -45
  36. data/vendored/facter/lib/facter/fqdn.rb +0 -24
  37. data/vendored/facter/lib/facter/gce.rb +0 -16
  38. data/vendored/facter/lib/facter/gce/metadata.rb +0 -87
  39. data/vendored/facter/lib/facter/gid.rb +0 -25
  40. data/vendored/facter/lib/facter/hardwareisa.rb +0 -20
  41. data/vendored/facter/lib/facter/hardwaremodel.rb +0 -67
  42. data/vendored/facter/lib/facter/hostname.rb +0 -31
  43. data/vendored/facter/lib/facter/id.rb +0 -21
  44. data/vendored/facter/lib/facter/interfaces.rb +0 -58
  45. data/vendored/facter/lib/facter/ipaddress.rb +0 -169
  46. data/vendored/facter/lib/facter/ipaddress6.rb +0 -82
  47. data/vendored/facter/lib/facter/iphostnumber.rb +0 -29
  48. data/vendored/facter/lib/facter/kernel.rb +0 -22
  49. data/vendored/facter/lib/facter/kernelmajversion.rb +0 -23
  50. data/vendored/facter/lib/facter/kernelrelease.rb +0 -45
  51. data/vendored/facter/lib/facter/kernelversion.rb +0 -22
  52. data/vendored/facter/lib/facter/ldom.rb +0 -51
  53. data/vendored/facter/lib/facter/lsbdistcodename.rb +0 -20
  54. data/vendored/facter/lib/facter/lsbdistdescription.rb +0 -21
  55. data/vendored/facter/lib/facter/lsbdistid.rb +0 -20
  56. data/vendored/facter/lib/facter/lsbdistrelease.rb +0 -20
  57. data/vendored/facter/lib/facter/lsbmajdistrelease.rb +0 -22
  58. data/vendored/facter/lib/facter/lsbminordistrelease.rb +0 -22
  59. data/vendored/facter/lib/facter/lsbrelease.rb +0 -20
  60. data/vendored/facter/lib/facter/macaddress.rb +0 -99
  61. data/vendored/facter/lib/facter/macosx.rb +0 -56
  62. data/vendored/facter/lib/facter/manufacturer.rb +0 -68
  63. data/vendored/facter/lib/facter/memory.rb +0 -168
  64. data/vendored/facter/lib/facter/netmask.rb +0 -43
  65. data/vendored/facter/lib/facter/network.rb +0 -20
  66. data/vendored/facter/lib/facter/operatingsystem.rb +0 -24
  67. data/vendored/facter/lib/facter/operatingsystem/base.rb +0 -61
  68. data/vendored/facter/lib/facter/operatingsystem/cumuluslinux.rb +0 -27
  69. data/vendored/facter/lib/facter/operatingsystem/implementation.rb +0 -33
  70. data/vendored/facter/lib/facter/operatingsystem/linux.rb +0 -484
  71. data/vendored/facter/lib/facter/operatingsystem/osreleaselinux.rb +0 -28
  72. data/vendored/facter/lib/facter/operatingsystem/sunos.rb +0 -54
  73. data/vendored/facter/lib/facter/operatingsystem/vmkernel.rb +0 -11
  74. data/vendored/facter/lib/facter/operatingsystem/windows.rb +0 -43
  75. data/vendored/facter/lib/facter/operatingsystemmajrelease.rb +0 -31
  76. data/vendored/facter/lib/facter/operatingsystemrelease.rb +0 -29
  77. data/vendored/facter/lib/facter/os.rb +0 -98
  78. data/vendored/facter/lib/facter/osfamily.rb +0 -18
  79. data/vendored/facter/lib/facter/partitions.rb +0 -39
  80. data/vendored/facter/lib/facter/path.rb +0 -14
  81. data/vendored/facter/lib/facter/physicalprocessorcount.rb +0 -27
  82. data/vendored/facter/lib/facter/processor.rb +0 -52
  83. data/vendored/facter/lib/facter/processors.rb +0 -66
  84. data/vendored/facter/lib/facter/processors/os.rb +0 -244
  85. data/vendored/facter/lib/facter/ps.rb +0 -31
  86. data/vendored/facter/lib/facter/puppetversion.rb +0 -20
  87. data/vendored/facter/lib/facter/rackspace.rb +0 -37
  88. data/vendored/facter/lib/facter/rubyplatform.rb +0 -12
  89. data/vendored/facter/lib/facter/rubysitedir.rb +0 -15
  90. data/vendored/facter/lib/facter/rubyversion.rb +0 -12
  91. data/vendored/facter/lib/facter/selinux.rb +0 -154
  92. data/vendored/facter/lib/facter/ssh.rb +0 -73
  93. data/vendored/facter/lib/facter/system32.rb +0 -21
  94. data/vendored/facter/lib/facter/system_uptime.rb +0 -44
  95. data/vendored/facter/lib/facter/timezone.rb +0 -14
  96. data/vendored/facter/lib/facter/uniqueid.rb +0 -4
  97. data/vendored/facter/lib/facter/uptime.rb +0 -16
  98. data/vendored/facter/lib/facter/uptime_days.rb +0 -13
  99. data/vendored/facter/lib/facter/uptime_hours.rb +0 -13
  100. data/vendored/facter/lib/facter/uptime_seconds.rb +0 -20
  101. data/vendored/facter/lib/facter/util/architecture.rb +0 -19
  102. data/vendored/facter/lib/facter/util/collection.rb +0 -161
  103. data/vendored/facter/lib/facter/util/composite_loader.rb +0 -12
  104. data/vendored/facter/lib/facter/util/config.rb +0 -88
  105. data/vendored/facter/lib/facter/util/confine.rb +0 -66
  106. data/vendored/facter/lib/facter/util/dhcp_servers.rb +0 -58
  107. data/vendored/facter/lib/facter/util/directory_loader.rb +0 -88
  108. data/vendored/facter/lib/facter/util/ec2.rb +0 -106
  109. data/vendored/facter/lib/facter/util/fact.rb +0 -204
  110. data/vendored/facter/lib/facter/util/file_read.rb +0 -37
  111. data/vendored/facter/lib/facter/util/formatter.rb +0 -39
  112. data/vendored/facter/lib/facter/util/ip.rb +0 -340
  113. data/vendored/facter/lib/facter/util/ip/windows.rb +0 -215
  114. data/vendored/facter/lib/facter/util/loader.rb +0 -155
  115. data/vendored/facter/lib/facter/util/macaddress.rb +0 -43
  116. data/vendored/facter/lib/facter/util/macosx.rb +0 -73
  117. data/vendored/facter/lib/facter/util/manufacturer.rb +0 -99
  118. data/vendored/facter/lib/facter/util/memory.rb +0 -228
  119. data/vendored/facter/lib/facter/util/netmask.rb +0 -40
  120. data/vendored/facter/lib/facter/util/normalization.rb +0 -94
  121. data/vendored/facter/lib/facter/util/nothing_loader.rb +0 -12
  122. data/vendored/facter/lib/facter/util/operatingsystem.rb +0 -21
  123. data/vendored/facter/lib/facter/util/parser.rb +0 -168
  124. data/vendored/facter/lib/facter/util/partitions.rb +0 -47
  125. data/vendored/facter/lib/facter/util/partitions/linux.rb +0 -71
  126. data/vendored/facter/lib/facter/util/partitions/openbsd.rb +0 -40
  127. data/vendored/facter/lib/facter/util/plist.rb +0 -24
  128. data/vendored/facter/lib/facter/util/plist/generator.rb +0 -228
  129. data/vendored/facter/lib/facter/util/plist/parser.rb +0 -226
  130. data/vendored/facter/lib/facter/util/posix.rb +0 -16
  131. data/vendored/facter/lib/facter/util/processor.rb +0 -289
  132. data/vendored/facter/lib/facter/util/registry.rb +0 -11
  133. data/vendored/facter/lib/facter/util/resolution.rb +0 -160
  134. data/vendored/facter/lib/facter/util/solaris_zones.rb +0 -158
  135. data/vendored/facter/lib/facter/util/unix_root.rb +0 -5
  136. data/vendored/facter/lib/facter/util/uptime.rb +0 -83
  137. data/vendored/facter/lib/facter/util/values.rb +0 -109
  138. data/vendored/facter/lib/facter/util/virtual.rb +0 -212
  139. data/vendored/facter/lib/facter/util/vlans.rb +0 -21
  140. data/vendored/facter/lib/facter/util/windows.rb +0 -10
  141. data/vendored/facter/lib/facter/util/windows/api_types.rb +0 -135
  142. data/vendored/facter/lib/facter/util/windows/dir.rb +0 -43
  143. data/vendored/facter/lib/facter/util/windows/error.rb +0 -87
  144. data/vendored/facter/lib/facter/util/windows/process.rb +0 -294
  145. data/vendored/facter/lib/facter/util/windows/user.rb +0 -186
  146. data/vendored/facter/lib/facter/util/windows_root.rb +0 -7
  147. data/vendored/facter/lib/facter/util/wmi.rb +0 -49
  148. data/vendored/facter/lib/facter/util/xendomains.rb +0 -28
  149. data/vendored/facter/lib/facter/version.rb +0 -86
  150. data/vendored/facter/lib/facter/virtual.rb +0 -330
  151. data/vendored/facter/lib/facter/vlans.rb +0 -17
  152. data/vendored/facter/lib/facter/xendomains.rb +0 -20
  153. data/vendored/facter/lib/facter/zfs_version.rb +0 -14
  154. data/vendored/facter/lib/facter/zonename.rb +0 -6
  155. data/vendored/facter/lib/facter/zones.rb +0 -18
  156. data/vendored/facter/lib/facter/zpool_version.rb +0 -10
  157. data/vendored/hiera/lib/hiera.rb +0 -119
  158. data/vendored/hiera/lib/hiera/backend.rb +0 -360
  159. data/vendored/hiera/lib/hiera/backend/json_backend.rb +0 -58
  160. data/vendored/hiera/lib/hiera/backend/yaml_backend.rb +0 -63
  161. data/vendored/hiera/lib/hiera/config.rb +0 -97
  162. data/vendored/hiera/lib/hiera/console_logger.rb +0 -13
  163. data/vendored/hiera/lib/hiera/error.rb +0 -4
  164. data/vendored/hiera/lib/hiera/fallback_logger.rb +0 -41
  165. data/vendored/hiera/lib/hiera/filecache.rb +0 -86
  166. data/vendored/hiera/lib/hiera/interpolate.rb +0 -121
  167. data/vendored/hiera/lib/hiera/noop_logger.rb +0 -8
  168. data/vendored/hiera/lib/hiera/puppet_logger.rb +0 -17
  169. data/vendored/hiera/lib/hiera/recursive_guard.rb +0 -20
  170. data/vendored/hiera/lib/hiera/util.rb +0 -65
  171. data/vendored/hiera/lib/hiera/util/win32.rb +0 -40
  172. data/vendored/hiera/lib/hiera/version.rb +0 -89
  173. data/vendored/puppet/lib/hiera/puppet_function.rb +0 -84
  174. data/vendored/puppet/lib/hiera/scope.rb +0 -83
  175. data/vendored/puppet/lib/hiera_puppet.rb +0 -79
  176. data/vendored/puppet/lib/puppet.rb +0 -299
  177. data/vendored/puppet/lib/puppet/agent.rb +0 -134
  178. data/vendored/puppet/lib/puppet/agent/disabler.rb +0 -53
  179. data/vendored/puppet/lib/puppet/agent/locker.rb +0 -53
  180. data/vendored/puppet/lib/puppet/application.rb +0 -509
  181. data/vendored/puppet/lib/puppet/application/agent.rb +0 -469
  182. data/vendored/puppet/lib/puppet/application/apply.rb +0 -407
  183. data/vendored/puppet/lib/puppet/application/catalog.rb +0 -4
  184. data/vendored/puppet/lib/puppet/application/cert.rb +0 -76
  185. data/vendored/puppet/lib/puppet/application/config.rb +0 -5
  186. data/vendored/puppet/lib/puppet/application/describe.rb +0 -257
  187. data/vendored/puppet/lib/puppet/application/device.rb +0 -386
  188. data/vendored/puppet/lib/puppet/application/doc.rb +0 -232
  189. data/vendored/puppet/lib/puppet/application/epp.rb +0 -5
  190. data/vendored/puppet/lib/puppet/application/face_base.rb +0 -268
  191. data/vendored/puppet/lib/puppet/application/facts.rb +0 -9
  192. data/vendored/puppet/lib/puppet/application/filebucket.rb +0 -300
  193. data/vendored/puppet/lib/puppet/application/generate.rb +0 -5
  194. data/vendored/puppet/lib/puppet/application/help.rb +0 -5
  195. data/vendored/puppet/lib/puppet/application/indirection_base.rb +0 -4
  196. data/vendored/puppet/lib/puppet/application/key.rb +0 -4
  197. data/vendored/puppet/lib/puppet/application/lookup.rb +0 -369
  198. data/vendored/puppet/lib/puppet/application/man.rb +0 -4
  199. data/vendored/puppet/lib/puppet/application/module.rb +0 -4
  200. data/vendored/puppet/lib/puppet/application/node.rb +0 -4
  201. data/vendored/puppet/lib/puppet/application/parser.rb +0 -5
  202. data/vendored/puppet/lib/puppet/application/plugin.rb +0 -3
  203. data/vendored/puppet/lib/puppet/application/report.rb +0 -4
  204. data/vendored/puppet/lib/puppet/application/resource.rb +0 -231
  205. data/vendored/puppet/lib/puppet/application/script.rb +0 -261
  206. data/vendored/puppet/lib/puppet/application/ssl.rb +0 -133
  207. data/vendored/puppet/lib/puppet/application/status.rb +0 -4
  208. data/vendored/puppet/lib/puppet/application_support.rb +0 -61
  209. data/vendored/puppet/lib/puppet/coercion.rb +0 -40
  210. data/vendored/puppet/lib/puppet/compilable_resource_type.rb +0 -15
  211. data/vendored/puppet/lib/puppet/configurer.rb +0 -484
  212. data/vendored/puppet/lib/puppet/configurer/downloader.rb +0 -67
  213. data/vendored/puppet/lib/puppet/configurer/fact_handler.rb +0 -50
  214. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +0 -48
  215. data/vendored/puppet/lib/puppet/confine.rb +0 -83
  216. data/vendored/puppet/lib/puppet/confine/any.rb +0 -26
  217. data/vendored/puppet/lib/puppet/confine/exists.rb +0 -19
  218. data/vendored/puppet/lib/puppet/confine/false.rb +0 -19
  219. data/vendored/puppet/lib/puppet/confine/feature.rb +0 -17
  220. data/vendored/puppet/lib/puppet/confine/true.rb +0 -20
  221. data/vendored/puppet/lib/puppet/confine/variable.rb +0 -59
  222. data/vendored/puppet/lib/puppet/confine_collection.rb +0 -50
  223. data/vendored/puppet/lib/puppet/confiner.rb +0 -46
  224. data/vendored/puppet/lib/puppet/context.rb +0 -116
  225. data/vendored/puppet/lib/puppet/context/trusted_information.rb +0 -76
  226. data/vendored/puppet/lib/puppet/daemon.rb +0 -195
  227. data/vendored/puppet/lib/puppet/data_binding.rb +0 -14
  228. data/vendored/puppet/lib/puppet/datatypes.rb +0 -213
  229. data/vendored/puppet/lib/puppet/datatypes/error.rb +0 -21
  230. data/vendored/puppet/lib/puppet/datatypes/impl/error.rb +0 -40
  231. data/vendored/puppet/lib/puppet/defaults.rb +0 -2003
  232. data/vendored/puppet/lib/puppet/environments.rb +0 -505
  233. data/vendored/puppet/lib/puppet/error.rb +0 -117
  234. data/vendored/puppet/lib/puppet/etc.rb +0 -160
  235. data/vendored/puppet/lib/puppet/external/dot.rb +0 -325
  236. data/vendored/puppet/lib/puppet/external/pson/common.rb +0 -374
  237. data/vendored/puppet/lib/puppet/external/pson/pure.rb +0 -15
  238. data/vendored/puppet/lib/puppet/external/pson/pure/generator.rb +0 -395
  239. data/vendored/puppet/lib/puppet/external/pson/pure/parser.rb +0 -307
  240. data/vendored/puppet/lib/puppet/external/pson/version.rb +0 -8
  241. data/vendored/puppet/lib/puppet/face.rb +0 -12
  242. data/vendored/puppet/lib/puppet/face/catalog.rb +0 -130
  243. data/vendored/puppet/lib/puppet/face/catalog/select.rb +0 -49
  244. data/vendored/puppet/lib/puppet/face/config.rb +0 -265
  245. data/vendored/puppet/lib/puppet/face/epp.rb +0 -554
  246. data/vendored/puppet/lib/puppet/face/facts.rb +0 -87
  247. data/vendored/puppet/lib/puppet/face/generate.rb +0 -64
  248. data/vendored/puppet/lib/puppet/face/help.rb +0 -215
  249. data/vendored/puppet/lib/puppet/face/key.rb +0 -16
  250. data/vendored/puppet/lib/puppet/face/man.rb +0 -145
  251. data/vendored/puppet/lib/puppet/face/module.rb +0 -19
  252. data/vendored/puppet/lib/puppet/face/module/build.rb +0 -14
  253. data/vendored/puppet/lib/puppet/face/module/changes.rb +0 -42
  254. data/vendored/puppet/lib/puppet/face/module/generate.rb +0 -14
  255. data/vendored/puppet/lib/puppet/face/module/install.rb +0 -146
  256. data/vendored/puppet/lib/puppet/face/module/list.rb +0 -263
  257. data/vendored/puppet/lib/puppet/face/module/search.rb +0 -98
  258. data/vendored/puppet/lib/puppet/face/module/uninstall.rb +0 -89
  259. data/vendored/puppet/lib/puppet/face/module/upgrade.rb +0 -87
  260. data/vendored/puppet/lib/puppet/face/node.rb +0 -43
  261. data/vendored/puppet/lib/puppet/face/node/clean.rb +0 -100
  262. data/vendored/puppet/lib/puppet/face/parser.rb +0 -187
  263. data/vendored/puppet/lib/puppet/face/plugin.rb +0 -56
  264. data/vendored/puppet/lib/puppet/face/report.rb +0 -54
  265. data/vendored/puppet/lib/puppet/face/resource.rb +0 -53
  266. data/vendored/puppet/lib/puppet/face/status.rb +0 -51
  267. data/vendored/puppet/lib/puppet/feature/base.rb +0 -76
  268. data/vendored/puppet/lib/puppet/feature/bolt.rb +0 -3
  269. data/vendored/puppet/lib/puppet/feature/cfpropertylist.rb +0 -3
  270. data/vendored/puppet/lib/puppet/feature/eventlog.rb +0 -5
  271. data/vendored/puppet/lib/puppet/feature/hiera_eyaml.rb +0 -3
  272. data/vendored/puppet/lib/puppet/feature/hocon.rb +0 -3
  273. data/vendored/puppet/lib/puppet/feature/libuser.rb +0 -8
  274. data/vendored/puppet/lib/puppet/feature/msgpack.rb +0 -3
  275. data/vendored/puppet/lib/puppet/feature/pe_license.rb +0 -4
  276. data/vendored/puppet/lib/puppet/feature/selinux.rb +0 -3
  277. data/vendored/puppet/lib/puppet/feature/ssh.rb +0 -3
  278. data/vendored/puppet/lib/puppet/feature/telnet.rb +0 -9
  279. data/vendored/puppet/lib/puppet/feature/zlib.rb +0 -5
  280. data/vendored/puppet/lib/puppet/file_bucket.rb +0 -4
  281. data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +0 -173
  282. data/vendored/puppet/lib/puppet/file_bucket/file.rb +0 -129
  283. data/vendored/puppet/lib/puppet/file_serving.rb +0 -3
  284. data/vendored/puppet/lib/puppet/file_serving/base.rb +0 -86
  285. data/vendored/puppet/lib/puppet/file_serving/configuration.rb +0 -115
  286. data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +0 -137
  287. data/vendored/puppet/lib/puppet/file_serving/content.rb +0 -43
  288. data/vendored/puppet/lib/puppet/file_serving/fileset.rb +0 -174
  289. data/vendored/puppet/lib/puppet/file_serving/http_metadata.rb +0 -46
  290. data/vendored/puppet/lib/puppet/file_serving/metadata.rb +0 -164
  291. data/vendored/puppet/lib/puppet/file_serving/mount.rb +0 -39
  292. data/vendored/puppet/lib/puppet/file_serving/mount/file.rb +0 -121
  293. data/vendored/puppet/lib/puppet/file_serving/mount/locales.rb +0 -35
  294. data/vendored/puppet/lib/puppet/file_serving/mount/modules.rb +0 -24
  295. data/vendored/puppet/lib/puppet/file_serving/mount/pluginfacts.rb +0 -35
  296. data/vendored/puppet/lib/puppet/file_serving/mount/plugins.rb +0 -35
  297. data/vendored/puppet/lib/puppet/file_serving/mount/tasks.rb +0 -21
  298. data/vendored/puppet/lib/puppet/file_serving/terminus_helper.rb +0 -31
  299. data/vendored/puppet/lib/puppet/file_serving/terminus_selector.rb +0 -32
  300. data/vendored/puppet/lib/puppet/file_system.rb +0 -404
  301. data/vendored/puppet/lib/puppet/file_system/file_impl.rb +0 -154
  302. data/vendored/puppet/lib/puppet/file_system/memory_file.rb +0 -66
  303. data/vendored/puppet/lib/puppet/file_system/memory_impl.rb +0 -86
  304. data/vendored/puppet/lib/puppet/file_system/path_pattern.rb +0 -98
  305. data/vendored/puppet/lib/puppet/file_system/posix.rb +0 -46
  306. data/vendored/puppet/lib/puppet/file_system/uniquefile.rb +0 -190
  307. data/vendored/puppet/lib/puppet/file_system/windows.rb +0 -130
  308. data/vendored/puppet/lib/puppet/forge.rb +0 -241
  309. data/vendored/puppet/lib/puppet/forge/cache.rb +0 -60
  310. data/vendored/puppet/lib/puppet/forge/errors.rb +0 -114
  311. data/vendored/puppet/lib/puppet/forge/repository.rb +0 -155
  312. data/vendored/puppet/lib/puppet/functions.rb +0 -863
  313. data/vendored/puppet/lib/puppet/functions/abs.rb +0 -61
  314. data/vendored/puppet/lib/puppet/functions/alert.rb +0 -14
  315. data/vendored/puppet/lib/puppet/functions/all.rb +0 -104
  316. data/vendored/puppet/lib/puppet/functions/annotate.rb +0 -108
  317. data/vendored/puppet/lib/puppet/functions/any.rb +0 -109
  318. data/vendored/puppet/lib/puppet/functions/assert_type.rb +0 -93
  319. data/vendored/puppet/lib/puppet/functions/binary_file.rb +0 -32
  320. data/vendored/puppet/lib/puppet/functions/break.rb +0 -47
  321. data/vendored/puppet/lib/puppet/functions/call.rb +0 -79
  322. data/vendored/puppet/lib/puppet/functions/camelcase.rb +0 -62
  323. data/vendored/puppet/lib/puppet/functions/capitalize.rb +0 -61
  324. data/vendored/puppet/lib/puppet/functions/ceiling.rb +0 -37
  325. data/vendored/puppet/lib/puppet/functions/chomp.rb +0 -57
  326. data/vendored/puppet/lib/puppet/functions/chop.rb +0 -67
  327. data/vendored/puppet/lib/puppet/functions/compare.rb +0 -125
  328. data/vendored/puppet/lib/puppet/functions/contain.rb +0 -55
  329. data/vendored/puppet/lib/puppet/functions/convert_to.rb +0 -34
  330. data/vendored/puppet/lib/puppet/functions/crit.rb +0 -14
  331. data/vendored/puppet/lib/puppet/functions/debug.rb +0 -14
  332. data/vendored/puppet/lib/puppet/functions/defined.rb +0 -159
  333. data/vendored/puppet/lib/puppet/functions/dig.rb +0 -67
  334. data/vendored/puppet/lib/puppet/functions/downcase.rb +0 -89
  335. data/vendored/puppet/lib/puppet/functions/each.rb +0 -169
  336. data/vendored/puppet/lib/puppet/functions/emerg.rb +0 -14
  337. data/vendored/puppet/lib/puppet/functions/empty.rb +0 -77
  338. data/vendored/puppet/lib/puppet/functions/epp.rb +0 -48
  339. data/vendored/puppet/lib/puppet/functions/err.rb +0 -14
  340. data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +0 -97
  341. data/vendored/puppet/lib/puppet/functions/filter.rb +0 -144
  342. data/vendored/puppet/lib/puppet/functions/find_file.rb +0 -44
  343. data/vendored/puppet/lib/puppet/functions/flatten.rb +0 -64
  344. data/vendored/puppet/lib/puppet/functions/floor.rb +0 -37
  345. data/vendored/puppet/lib/puppet/functions/get.rb +0 -150
  346. data/vendored/puppet/lib/puppet/functions/getvar.rb +0 -87
  347. data/vendored/puppet/lib/puppet/functions/hiera.rb +0 -88
  348. data/vendored/puppet/lib/puppet/functions/hiera_array.rb +0 -81
  349. data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +0 -92
  350. data/vendored/puppet/lib/puppet/functions/hiera_include.rb +0 -104
  351. data/vendored/puppet/lib/puppet/functions/hocon_data.rb +0 -41
  352. data/vendored/puppet/lib/puppet/functions/import.rb +0 -7
  353. data/vendored/puppet/lib/puppet/functions/include.rb +0 -53
  354. data/vendored/puppet/lib/puppet/functions/info.rb +0 -14
  355. data/vendored/puppet/lib/puppet/functions/inline_epp.rb +0 -59
  356. data/vendored/puppet/lib/puppet/functions/join.rb +0 -56
  357. data/vendored/puppet/lib/puppet/functions/json_data.rb +0 -33
  358. data/vendored/puppet/lib/puppet/functions/keys.rb +0 -25
  359. data/vendored/puppet/lib/puppet/functions/length.rb +0 -44
  360. data/vendored/puppet/lib/puppet/functions/lest.rb +0 -55
  361. data/vendored/puppet/lib/puppet/functions/lookup.rb +0 -224
  362. data/vendored/puppet/lib/puppet/functions/lstrip.rb +0 -58
  363. data/vendored/puppet/lib/puppet/functions/map.rb +0 -136
  364. data/vendored/puppet/lib/puppet/functions/match.rb +0 -131
  365. data/vendored/puppet/lib/puppet/functions/max.rb +0 -183
  366. data/vendored/puppet/lib/puppet/functions/min.rb +0 -182
  367. data/vendored/puppet/lib/puppet/functions/module_directory.rb +0 -41
  368. data/vendored/puppet/lib/puppet/functions/new.rb +0 -1006
  369. data/vendored/puppet/lib/puppet/functions/next.rb +0 -16
  370. data/vendored/puppet/lib/puppet/functions/notice.rb +0 -14
  371. data/vendored/puppet/lib/puppet/functions/reduce.rb +0 -164
  372. data/vendored/puppet/lib/puppet/functions/regsubst.rb +0 -82
  373. data/vendored/puppet/lib/puppet/functions/require.rb +0 -77
  374. data/vendored/puppet/lib/puppet/functions/return.rb +0 -15
  375. data/vendored/puppet/lib/puppet/functions/reverse_each.rb +0 -94
  376. data/vendored/puppet/lib/puppet/functions/round.rb +0 -24
  377. data/vendored/puppet/lib/puppet/functions/rstrip.rb +0 -58
  378. data/vendored/puppet/lib/puppet/functions/scanf.rb +0 -44
  379. data/vendored/puppet/lib/puppet/functions/size.rb +0 -15
  380. data/vendored/puppet/lib/puppet/functions/slice.rb +0 -124
  381. data/vendored/puppet/lib/puppet/functions/sort.rb +0 -74
  382. data/vendored/puppet/lib/puppet/functions/split.rb +0 -49
  383. data/vendored/puppet/lib/puppet/functions/step.rb +0 -98
  384. data/vendored/puppet/lib/puppet/functions/strftime.rb +0 -211
  385. data/vendored/puppet/lib/puppet/functions/strip.rb +0 -58
  386. data/vendored/puppet/lib/puppet/functions/then.rb +0 -77
  387. data/vendored/puppet/lib/puppet/functions/tree_each.rb +0 -200
  388. data/vendored/puppet/lib/puppet/functions/type.rb +0 -72
  389. data/vendored/puppet/lib/puppet/functions/unique.rb +0 -132
  390. data/vendored/puppet/lib/puppet/functions/unwrap.rb +0 -44
  391. data/vendored/puppet/lib/puppet/functions/upcase.rb +0 -89
  392. data/vendored/puppet/lib/puppet/functions/values.rb +0 -25
  393. data/vendored/puppet/lib/puppet/functions/versioncmp.rb +0 -36
  394. data/vendored/puppet/lib/puppet/functions/warning.rb +0 -14
  395. data/vendored/puppet/lib/puppet/functions/with.rb +0 -32
  396. data/vendored/puppet/lib/puppet/functions/yaml_data.rb +0 -43
  397. data/vendored/puppet/lib/puppet/generate/models/type/property.rb +0 -70
  398. data/vendored/puppet/lib/puppet/generate/models/type/type.rb +0 -62
  399. data/vendored/puppet/lib/puppet/generate/type.rb +0 -239
  400. data/vendored/puppet/lib/puppet/gettext/config.rb +0 -275
  401. data/vendored/puppet/lib/puppet/gettext/module_translations.rb +0 -42
  402. data/vendored/puppet/lib/puppet/gettext/stubs.rb +0 -11
  403. data/vendored/puppet/lib/puppet/graph.rb +0 -9
  404. data/vendored/puppet/lib/puppet/graph/key.rb +0 -26
  405. data/vendored/puppet/lib/puppet/graph/prioritizer.rb +0 -29
  406. data/vendored/puppet/lib/puppet/graph/rb_tree_map.rb +0 -388
  407. data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +0 -283
  408. data/vendored/puppet/lib/puppet/graph/sequential_prioritizer.rb +0 -31
  409. data/vendored/puppet/lib/puppet/graph/simple_graph.rb +0 -543
  410. data/vendored/puppet/lib/puppet/indirector.rb +0 -61
  411. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +0 -416
  412. data/vendored/puppet/lib/puppet/indirector/catalog/json.rb +0 -35
  413. data/vendored/puppet/lib/puppet/indirector/catalog/msgpack.rb +0 -6
  414. data/vendored/puppet/lib/puppet/indirector/catalog/rest.rb +0 -6
  415. data/vendored/puppet/lib/puppet/indirector/catalog/store_configs.rb +0 -8
  416. data/vendored/puppet/lib/puppet/indirector/catalog/yaml.rb +0 -6
  417. data/vendored/puppet/lib/puppet/indirector/certificate/file.rb +0 -8
  418. data/vendored/puppet/lib/puppet/indirector/certificate/rest.rb +0 -16
  419. data/vendored/puppet/lib/puppet/indirector/certificate_request/file.rb +0 -8
  420. data/vendored/puppet/lib/puppet/indirector/certificate_request/memory.rb +0 -6
  421. data/vendored/puppet/lib/puppet/indirector/certificate_request/rest.rb +0 -10
  422. data/vendored/puppet/lib/puppet/indirector/code.rb +0 -6
  423. data/vendored/puppet/lib/puppet/indirector/data_binding/hiera.rb +0 -7
  424. data/vendored/puppet/lib/puppet/indirector/data_binding/none.rb +0 -8
  425. data/vendored/puppet/lib/puppet/indirector/direct_file_server.rb +0 -17
  426. data/vendored/puppet/lib/puppet/indirector/envelope.rb +0 -11
  427. data/vendored/puppet/lib/puppet/indirector/errors.rb +0 -5
  428. data/vendored/puppet/lib/puppet/indirector/exec.rb +0 -38
  429. data/vendored/puppet/lib/puppet/indirector/face.rb +0 -153
  430. data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +0 -88
  431. data/vendored/puppet/lib/puppet/indirector/facts/memory.rb +0 -9
  432. data/vendored/puppet/lib/puppet/indirector/facts/network_device.rb +0 -27
  433. data/vendored/puppet/lib/puppet/indirector/facts/rest.rb +0 -21
  434. data/vendored/puppet/lib/puppet/indirector/facts/store_configs.rb +0 -11
  435. data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +0 -84
  436. data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +0 -262
  437. data/vendored/puppet/lib/puppet/indirector/file_bucket_file/rest.rb +0 -8
  438. data/vendored/puppet/lib/puppet/indirector/file_bucket_file/selector.rb +0 -53
  439. data/vendored/puppet/lib/puppet/indirector/file_content.rb +0 -5
  440. data/vendored/puppet/lib/puppet/indirector/file_content/file.rb +0 -7
  441. data/vendored/puppet/lib/puppet/indirector/file_content/file_server.rb +0 -7
  442. data/vendored/puppet/lib/puppet/indirector/file_content/http.rb +0 -17
  443. data/vendored/puppet/lib/puppet/indirector/file_content/rest.rb +0 -9
  444. data/vendored/puppet/lib/puppet/indirector/file_content/selector.rb +0 -30
  445. data/vendored/puppet/lib/puppet/indirector/file_metadata.rb +0 -5
  446. data/vendored/puppet/lib/puppet/indirector/file_metadata/file.rb +0 -7
  447. data/vendored/puppet/lib/puppet/indirector/file_metadata/file_server.rb +0 -7
  448. data/vendored/puppet/lib/puppet/indirector/file_metadata/http.rb +0 -27
  449. data/vendored/puppet/lib/puppet/indirector/file_metadata/rest.rb +0 -9
  450. data/vendored/puppet/lib/puppet/indirector/file_metadata/selector.rb +0 -30
  451. data/vendored/puppet/lib/puppet/indirector/file_server.rb +0 -59
  452. data/vendored/puppet/lib/puppet/indirector/generic_http.rb +0 -16
  453. data/vendored/puppet/lib/puppet/indirector/hiera.rb +0 -94
  454. data/vendored/puppet/lib/puppet/indirector/indirection.rb +0 -340
  455. data/vendored/puppet/lib/puppet/indirector/json.rb +0 -75
  456. data/vendored/puppet/lib/puppet/indirector/key/file.rb +0 -45
  457. data/vendored/puppet/lib/puppet/indirector/key/memory.rb +0 -6
  458. data/vendored/puppet/lib/puppet/indirector/memory.rb +0 -34
  459. data/vendored/puppet/lib/puppet/indirector/msgpack.rb +0 -83
  460. data/vendored/puppet/lib/puppet/indirector/node/exec.rb +0 -69
  461. data/vendored/puppet/lib/puppet/indirector/node/memory.rb +0 -10
  462. data/vendored/puppet/lib/puppet/indirector/node/msgpack.rb +0 -7
  463. data/vendored/puppet/lib/puppet/indirector/node/plain.rb +0 -21
  464. data/vendored/puppet/lib/puppet/indirector/node/rest.rb +0 -7
  465. data/vendored/puppet/lib/puppet/indirector/node/store_configs.rb +0 -8
  466. data/vendored/puppet/lib/puppet/indirector/node/yaml.rb +0 -7
  467. data/vendored/puppet/lib/puppet/indirector/none.rb +0 -9
  468. data/vendored/puppet/lib/puppet/indirector/plain.rb +0 -9
  469. data/vendored/puppet/lib/puppet/indirector/report/msgpack.rb +0 -11
  470. data/vendored/puppet/lib/puppet/indirector/report/processor.rb +0 -59
  471. data/vendored/puppet/lib/puppet/indirector/report/rest.rb +0 -28
  472. data/vendored/puppet/lib/puppet/indirector/report/yaml.rb +0 -11
  473. data/vendored/puppet/lib/puppet/indirector/request.rb +0 -278
  474. data/vendored/puppet/lib/puppet/indirector/resource/ral.rb +0 -63
  475. data/vendored/puppet/lib/puppet/indirector/resource/store_configs.rb +0 -12
  476. data/vendored/puppet/lib/puppet/indirector/resource/validator.rb +0 -8
  477. data/vendored/puppet/lib/puppet/indirector/rest.rb +0 -301
  478. data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +0 -160
  479. data/vendored/puppet/lib/puppet/indirector/status.rb +0 -3
  480. data/vendored/puppet/lib/puppet/indirector/status/local.rb +0 -12
  481. data/vendored/puppet/lib/puppet/indirector/status/rest.rb +0 -9
  482. data/vendored/puppet/lib/puppet/indirector/store_configs.rb +0 -30
  483. data/vendored/puppet/lib/puppet/indirector/terminus.rb +0 -169
  484. data/vendored/puppet/lib/puppet/indirector/yaml.rb +0 -63
  485. data/vendored/puppet/lib/puppet/info_service.rb +0 -17
  486. data/vendored/puppet/lib/puppet/info_service/class_information_service.rb +0 -110
  487. data/vendored/puppet/lib/puppet/info_service/task_information_service.rb +0 -36
  488. data/vendored/puppet/lib/puppet/interface.rb +0 -237
  489. data/vendored/puppet/lib/puppet/interface/action.rb +0 -399
  490. data/vendored/puppet/lib/puppet/interface/action_builder.rb +0 -166
  491. data/vendored/puppet/lib/puppet/interface/action_manager.rb +0 -97
  492. data/vendored/puppet/lib/puppet/interface/documentation.rb +0 -353
  493. data/vendored/puppet/lib/puppet/interface/face_collection.rb +0 -134
  494. data/vendored/puppet/lib/puppet/interface/option.rb +0 -171
  495. data/vendored/puppet/lib/puppet/interface/option_builder.rb +0 -105
  496. data/vendored/puppet/lib/puppet/interface/option_manager.rb +0 -104
  497. data/vendored/puppet/lib/puppet/loaders.rb +0 -28
  498. data/vendored/puppet/lib/puppet/metatype/manager.rb +0 -197
  499. data/vendored/puppet/lib/puppet/module.rb +0 -441
  500. data/vendored/puppet/lib/puppet/module/task.rb +0 -258
  501. data/vendored/puppet/lib/puppet/module_tool.rb +0 -193
  502. data/vendored/puppet/lib/puppet/module_tool/applications.rb +0 -13
  503. data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +0 -90
  504. data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +0 -62
  505. data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +0 -354
  506. data/vendored/puppet/lib/puppet/module_tool/applications/searcher.rb +0 -29
  507. data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +0 -120
  508. data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +0 -100
  509. data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +0 -280
  510. data/vendored/puppet/lib/puppet/module_tool/checksums.rb +0 -49
  511. data/vendored/puppet/lib/puppet/module_tool/contents_description.rb +0 -88
  512. data/vendored/puppet/lib/puppet/module_tool/dependency.rb +0 -41
  513. data/vendored/puppet/lib/puppet/module_tool/errors.rb +0 -11
  514. data/vendored/puppet/lib/puppet/module_tool/errors/base.rb +0 -15
  515. data/vendored/puppet/lib/puppet/module_tool/errors/installer.rb +0 -93
  516. data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +0 -195
  517. data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +0 -50
  518. data/vendored/puppet/lib/puppet/module_tool/errors/upgrader.rb +0 -63
  519. data/vendored/puppet/lib/puppet/module_tool/install_directory.rb +0 -45
  520. data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +0 -96
  521. data/vendored/puppet/lib/puppet/module_tool/local_tarball.rb +0 -90
  522. data/vendored/puppet/lib/puppet/module_tool/metadata.rb +0 -222
  523. data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +0 -180
  524. data/vendored/puppet/lib/puppet/module_tool/tar.rb +0 -18
  525. data/vendored/puppet/lib/puppet/module_tool/tar/gnu.rb +0 -19
  526. data/vendored/puppet/lib/puppet/module_tool/tar/mini.rb +0 -106
  527. data/vendored/puppet/lib/puppet/network.rb +0 -3
  528. data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +0 -90
  529. data/vendored/puppet/lib/puppet/network/authconfig.rb +0 -99
  530. data/vendored/puppet/lib/puppet/network/authorization.rb +0 -41
  531. data/vendored/puppet/lib/puppet/network/authstore.rb +0 -282
  532. data/vendored/puppet/lib/puppet/network/client_request.rb +0 -29
  533. data/vendored/puppet/lib/puppet/network/format.rb +0 -110
  534. data/vendored/puppet/lib/puppet/network/format_handler.rb +0 -108
  535. data/vendored/puppet/lib/puppet/network/format_support.rb +0 -139
  536. data/vendored/puppet/lib/puppet/network/formats.rb +0 -260
  537. data/vendored/puppet/lib/puppet/network/http.rb +0 -28
  538. data/vendored/puppet/lib/puppet/network/http/api.rb +0 -35
  539. data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +0 -286
  540. data/vendored/puppet/lib/puppet/network/http/api/indirection_type.rb +0 -32
  541. data/vendored/puppet/lib/puppet/network/http/api/master.rb +0 -2
  542. data/vendored/puppet/lib/puppet/network/http/api/master/v3.rb +0 -28
  543. data/vendored/puppet/lib/puppet/network/http/api/master/v3/authorization.rb +0 -18
  544. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +0 -85
  545. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environments.rb +0 -35
  546. data/vendored/puppet/lib/puppet/network/http/compression.rb +0 -120
  547. data/vendored/puppet/lib/puppet/network/http/connection.rb +0 -319
  548. data/vendored/puppet/lib/puppet/network/http/error.rb +0 -73
  549. data/vendored/puppet/lib/puppet/network/http/factory.rb +0 -55
  550. data/vendored/puppet/lib/puppet/network/http/handler.rb +0 -215
  551. data/vendored/puppet/lib/puppet/network/http/issues.rb +0 -12
  552. data/vendored/puppet/lib/puppet/network/http/memory_response.rb +0 -13
  553. data/vendored/puppet/lib/puppet/network/http/nocache_pool.rb +0 -21
  554. data/vendored/puppet/lib/puppet/network/http/pool.rb +0 -129
  555. data/vendored/puppet/lib/puppet/network/http/request.rb +0 -70
  556. data/vendored/puppet/lib/puppet/network/http/response.rb +0 -23
  557. data/vendored/puppet/lib/puppet/network/http/route.rb +0 -100
  558. data/vendored/puppet/lib/puppet/network/http/session.rb +0 -17
  559. data/vendored/puppet/lib/puppet/network/http/site.rb +0 -39
  560. data/vendored/puppet/lib/puppet/network/http_pool.rb +0 -61
  561. data/vendored/puppet/lib/puppet/network/resolver.rb +0 -158
  562. data/vendored/puppet/lib/puppet/network/rest_controller.rb +0 -2
  563. data/vendored/puppet/lib/puppet/network/rights.rb +0 -209
  564. data/vendored/puppet/lib/puppet/node.rb +0 -281
  565. data/vendored/puppet/lib/puppet/node/environment.rb +0 -575
  566. data/vendored/puppet/lib/puppet/node/facts.rb +0 -147
  567. data/vendored/puppet/lib/puppet/parameter.rb +0 -572
  568. data/vendored/puppet/lib/puppet/parameter/boolean.rb +0 -15
  569. data/vendored/puppet/lib/puppet/parameter/package_options.rb +0 -31
  570. data/vendored/puppet/lib/puppet/parameter/path.rb +0 -57
  571. data/vendored/puppet/lib/puppet/parameter/value.rb +0 -91
  572. data/vendored/puppet/lib/puppet/parameter/value_collection.rb +0 -212
  573. data/vendored/puppet/lib/puppet/parser.rb +0 -20
  574. data/vendored/puppet/lib/puppet/parser/abstract_compiler.rb +0 -36
  575. data/vendored/puppet/lib/puppet/parser/ast.rb +0 -61
  576. data/vendored/puppet/lib/puppet/parser/ast/block_expression.rb +0 -15
  577. data/vendored/puppet/lib/puppet/parser/ast/branch.rb +0 -19
  578. data/vendored/puppet/lib/puppet/parser/ast/hostclass.rb +0 -27
  579. data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +0 -80
  580. data/vendored/puppet/lib/puppet/parser/ast/node.rb +0 -17
  581. data/vendored/puppet/lib/puppet/parser/ast/pops_bridge.rb +0 -291
  582. data/vendored/puppet/lib/puppet/parser/ast/resource.rb +0 -66
  583. data/vendored/puppet/lib/puppet/parser/ast/resource_instance.rb +0 -10
  584. data/vendored/puppet/lib/puppet/parser/ast/resourceparam.rb +0 -31
  585. data/vendored/puppet/lib/puppet/parser/ast/top_level_construct.rb +0 -4
  586. data/vendored/puppet/lib/puppet/parser/catalog_compiler.rb +0 -56
  587. data/vendored/puppet/lib/puppet/parser/compiler.rb +0 -798
  588. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator.rb +0 -33
  589. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +0 -64
  590. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +0 -64
  591. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +0 -20
  592. data/vendored/puppet/lib/puppet/parser/e4_parser_adapter.rb +0 -60
  593. data/vendored/puppet/lib/puppet/parser/environment_compiler.rb +0 -199
  594. data/vendored/puppet/lib/puppet/parser/files.rb +0 -92
  595. data/vendored/puppet/lib/puppet/parser/functions.rb +0 -311
  596. data/vendored/puppet/lib/puppet/parser/functions/assert_type.rb +0 -60
  597. data/vendored/puppet/lib/puppet/parser/functions/binary_file.rb +0 -24
  598. data/vendored/puppet/lib/puppet/parser/functions/break.rb +0 -39
  599. data/vendored/puppet/lib/puppet/parser/functions/contain.rb +0 -30
  600. data/vendored/puppet/lib/puppet/parser/functions/create_resources.rb +0 -106
  601. data/vendored/puppet/lib/puppet/parser/functions/defined.rb +0 -107
  602. data/vendored/puppet/lib/puppet/parser/functions/dig.rb +0 -38
  603. data/vendored/puppet/lib/puppet/parser/functions/digest.rb +0 -5
  604. data/vendored/puppet/lib/puppet/parser/functions/each.rb +0 -104
  605. data/vendored/puppet/lib/puppet/parser/functions/epp.rb +0 -39
  606. data/vendored/puppet/lib/puppet/parser/functions/fail.rb +0 -4
  607. data/vendored/puppet/lib/puppet/parser/functions/file.rb +0 -33
  608. data/vendored/puppet/lib/puppet/parser/functions/filter.rb +0 -78
  609. data/vendored/puppet/lib/puppet/parser/functions/find_file.rb +0 -28
  610. data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +0 -36
  611. data/vendored/puppet/lib/puppet/parser/functions/generate.rb +0 -36
  612. data/vendored/puppet/lib/puppet/parser/functions/hiera.rb +0 -103
  613. data/vendored/puppet/lib/puppet/parser/functions/hiera_array.rb +0 -92
  614. data/vendored/puppet/lib/puppet/parser/functions/hiera_hash.rb +0 -102
  615. data/vendored/puppet/lib/puppet/parser/functions/hiera_include.rb +0 -101
  616. data/vendored/puppet/lib/puppet/parser/functions/include.rb +0 -34
  617. data/vendored/puppet/lib/puppet/parser/functions/inline_epp.rb +0 -51
  618. data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +0 -26
  619. data/vendored/puppet/lib/puppet/parser/functions/lest.rb +0 -49
  620. data/vendored/puppet/lib/puppet/parser/functions/lookup.rb +0 -132
  621. data/vendored/puppet/lib/puppet/parser/functions/map.rb +0 -76
  622. data/vendored/puppet/lib/puppet/parser/functions/match.rb +0 -43
  623. data/vendored/puppet/lib/puppet/parser/functions/md5.rb +0 -5
  624. data/vendored/puppet/lib/puppet/parser/functions/new.rb +0 -991
  625. data/vendored/puppet/lib/puppet/parser/functions/next.rb +0 -38
  626. data/vendored/puppet/lib/puppet/parser/functions/realize.rb +0 -20
  627. data/vendored/puppet/lib/puppet/parser/functions/reduce.rb +0 -137
  628. data/vendored/puppet/lib/puppet/parser/functions/regsubst.rb +0 -62
  629. data/vendored/puppet/lib/puppet/parser/functions/require.rb +0 -40
  630. data/vendored/puppet/lib/puppet/parser/functions/return.rb +0 -92
  631. data/vendored/puppet/lib/puppet/parser/functions/reverse_each.rb +0 -83
  632. data/vendored/puppet/lib/puppet/parser/functions/scanf.rb +0 -38
  633. data/vendored/puppet/lib/puppet/parser/functions/sha1.rb +0 -5
  634. data/vendored/puppet/lib/puppet/parser/functions/sha256.rb +0 -5
  635. data/vendored/puppet/lib/puppet/parser/functions/shellquote.rb +0 -61
  636. data/vendored/puppet/lib/puppet/parser/functions/slice.rb +0 -39
  637. data/vendored/puppet/lib/puppet/parser/functions/split.rb +0 -28
  638. data/vendored/puppet/lib/puppet/parser/functions/sprintf.rb +0 -61
  639. data/vendored/puppet/lib/puppet/parser/functions/step.rb +0 -84
  640. data/vendored/puppet/lib/puppet/parser/functions/strftime.rb +0 -185
  641. data/vendored/puppet/lib/puppet/parser/functions/tag.rb +0 -12
  642. data/vendored/puppet/lib/puppet/parser/functions/tagged.rb +0 -21
  643. data/vendored/puppet/lib/puppet/parser/functions/template.rb +0 -39
  644. data/vendored/puppet/lib/puppet/parser/functions/then.rb +0 -73
  645. data/vendored/puppet/lib/puppet/parser/functions/type.rb +0 -53
  646. data/vendored/puppet/lib/puppet/parser/functions/versioncmp.rb +0 -30
  647. data/vendored/puppet/lib/puppet/parser/functions/with.rb +0 -28
  648. data/vendored/puppet/lib/puppet/parser/parser_factory.rb +0 -30
  649. data/vendored/puppet/lib/puppet/parser/relationship.rb +0 -83
  650. data/vendored/puppet/lib/puppet/parser/resource.rb +0 -416
  651. data/vendored/puppet/lib/puppet/parser/resource/param.rb +0 -29
  652. data/vendored/puppet/lib/puppet/parser/scope.rb +0 -1123
  653. data/vendored/puppet/lib/puppet/parser/script_compiler.rb +0 -123
  654. data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +0 -102
  655. data/vendored/puppet/lib/puppet/parser/type_loader.rb +0 -149
  656. data/vendored/puppet/lib/puppet/plugins.rb +0 -9
  657. data/vendored/puppet/lib/puppet/plugins/configuration.rb +0 -25
  658. data/vendored/puppet/lib/puppet/plugins/syntax_checkers.rb +0 -98
  659. data/vendored/puppet/lib/puppet/pops.rb +0 -121
  660. data/vendored/puppet/lib/puppet/pops/adaptable.rb +0 -206
  661. data/vendored/puppet/lib/puppet/pops/adapters.rb +0 -152
  662. data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +0 -719
  663. data/vendored/puppet/lib/puppet/pops/evaluator/callable_signature.rb +0 -107
  664. data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +0 -373
  665. data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +0 -234
  666. data/vendored/puppet/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +0 -86
  667. data/vendored/puppet/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +0 -29
  668. data/vendored/puppet/lib/puppet/pops/evaluator/collectors/exported_collector.rb +0 -69
  669. data/vendored/puppet/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +0 -37
  670. data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +0 -254
  671. data/vendored/puppet/lib/puppet/pops/evaluator/deferred_resolver.rb +0 -130
  672. data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +0 -120
  673. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +0 -1299
  674. data/vendored/puppet/lib/puppet/pops/evaluator/external_syntax_support.rb +0 -45
  675. data/vendored/puppet/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +0 -82
  676. data/vendored/puppet/lib/puppet/pops/evaluator/literal_evaluator.rb +0 -87
  677. data/vendored/puppet/lib/puppet/pops/evaluator/puppet_proc.rb +0 -69
  678. data/vendored/puppet/lib/puppet/pops/evaluator/relationship_operator.rb +0 -185
  679. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +0 -221
  680. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +0 -117
  681. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +0 -534
  682. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +0 -107
  683. data/vendored/puppet/lib/puppet/pops/functions/dispatcher.rb +0 -71
  684. data/vendored/puppet/lib/puppet/pops/functions/function.rb +0 -141
  685. data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +0 -137
  686. data/vendored/puppet/lib/puppet/pops/issues.rb +0 -921
  687. data/vendored/puppet/lib/puppet/pops/label_provider.rb +0 -90
  688. data/vendored/puppet/lib/puppet/pops/loader/base_loader.rb +0 -166
  689. data/vendored/puppet/lib/puppet/pops/loader/dependency_loader.rb +0 -92
  690. data/vendored/puppet/lib/puppet/pops/loader/gem_support.rb +0 -49
  691. data/vendored/puppet/lib/puppet/pops/loader/loader.rb +0 -209
  692. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +0 -377
  693. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +0 -549
  694. data/vendored/puppet/lib/puppet/pops/loader/null_loader.rb +0 -60
  695. data/vendored/puppet/lib/puppet/pops/loader/predefined_loader.rb +0 -24
  696. data/vendored/puppet/lib/puppet/pops/loader/puppet_function_instantiator.rb +0 -84
  697. data/vendored/puppet/lib/puppet/pops/loader/puppet_plan_instantiator.rb +0 -84
  698. data/vendored/puppet/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +0 -79
  699. data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +0 -39
  700. data/vendored/puppet/lib/puppet/pops/loader/ruby_function_instantiator.rb +0 -45
  701. data/vendored/puppet/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +0 -62
  702. data/vendored/puppet/lib/puppet/pops/loader/runtime3_type_loader.rb +0 -101
  703. data/vendored/puppet/lib/puppet/pops/loader/simple_environment_loader.rb +0 -20
  704. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -127
  705. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +0 -40
  706. data/vendored/puppet/lib/puppet/pops/loader/type_definition_instantiator.rb +0 -100
  707. data/vendored/puppet/lib/puppet/pops/loader/typed_name.rb +0 -54
  708. data/vendored/puppet/lib/puppet/pops/loader/uri_helper.rb +0 -22
  709. data/vendored/puppet/lib/puppet/pops/loaders.rb +0 -533
  710. data/vendored/puppet/lib/puppet/pops/lookup.rb +0 -96
  711. data/vendored/puppet/lib/puppet/pops/lookup/configured_data_provider.rb +0 -93
  712. data/vendored/puppet/lib/puppet/pops/lookup/context.rb +0 -200
  713. data/vendored/puppet/lib/puppet/pops/lookup/data_adapter.rb +0 -27
  714. data/vendored/puppet/lib/puppet/pops/lookup/data_dig_function_provider.rb +0 -145
  715. data/vendored/puppet/lib/puppet/pops/lookup/data_hash_function_provider.rb +0 -126
  716. data/vendored/puppet/lib/puppet/pops/lookup/data_provider.rb +0 -92
  717. data/vendored/puppet/lib/puppet/pops/lookup/environment_data_provider.rb +0 -35
  718. data/vendored/puppet/lib/puppet/pops/lookup/explainer.rb +0 -595
  719. data/vendored/puppet/lib/puppet/pops/lookup/function_provider.rb +0 -110
  720. data/vendored/puppet/lib/puppet/pops/lookup/global_data_provider.rb +0 -75
  721. data/vendored/puppet/lib/puppet/pops/lookup/hiera_config.rb +0 -761
  722. data/vendored/puppet/lib/puppet/pops/lookup/interpolation.rb +0 -154
  723. data/vendored/puppet/lib/puppet/pops/lookup/invocation.rb +0 -261
  724. data/vendored/puppet/lib/puppet/pops/lookup/location_resolver.rb +0 -99
  725. data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +0 -520
  726. data/vendored/puppet/lib/puppet/pops/lookup/lookup_key.rb +0 -99
  727. data/vendored/puppet/lib/puppet/pops/lookup/lookup_key_function_provider.rb +0 -92
  728. data/vendored/puppet/lib/puppet/pops/lookup/module_data_provider.rb +0 -89
  729. data/vendored/puppet/lib/puppet/pops/lookup/sub_lookup.rb +0 -92
  730. data/vendored/puppet/lib/puppet/pops/merge_strategy.rb +0 -437
  731. data/vendored/puppet/lib/puppet/pops/migration/migration_checker.rb +0 -58
  732. data/vendored/puppet/lib/puppet/pops/model/ast.rb +0 -4964
  733. data/vendored/puppet/lib/puppet/pops/model/ast_transformer.rb +0 -131
  734. data/vendored/puppet/lib/puppet/pops/model/factory.rb +0 -1163
  735. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +0 -139
  736. data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +0 -467
  737. data/vendored/puppet/lib/puppet/pops/model/pn_transformer.rb +0 -400
  738. data/vendored/puppet/lib/puppet/pops/model/tree_dumper.rb +0 -59
  739. data/vendored/puppet/lib/puppet/pops/parser/code_merger.rb +0 -29
  740. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +0 -3361
  741. data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +0 -51
  742. data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +0 -264
  743. data/vendored/puppet/lib/puppet/pops/parser/evaluating_parser.rb +0 -165
  744. data/vendored/puppet/lib/puppet/pops/parser/heredoc_support.rb +0 -143
  745. data/vendored/puppet/lib/puppet/pops/parser/interpolation_support.rb +0 -244
  746. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +0 -772
  747. data/vendored/puppet/lib/puppet/pops/parser/lexer_support.rb +0 -221
  748. data/vendored/puppet/lib/puppet/pops/parser/locatable.rb +0 -23
  749. data/vendored/puppet/lib/puppet/pops/parser/locator.rb +0 -336
  750. data/vendored/puppet/lib/puppet/pops/parser/parser_support.rb +0 -247
  751. data/vendored/puppet/lib/puppet/pops/parser/pn_parser.rb +0 -316
  752. data/vendored/puppet/lib/puppet/pops/parser/slurp_support.rb +0 -117
  753. data/vendored/puppet/lib/puppet/pops/patterns.rb +0 -60
  754. data/vendored/puppet/lib/puppet/pops/pcore.rb +0 -135
  755. data/vendored/puppet/lib/puppet/pops/pn.rb +0 -236
  756. data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +0 -57
  757. data/vendored/puppet/lib/puppet/pops/resource/param.rb +0 -55
  758. data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +0 -314
  759. data/vendored/puppet/lib/puppet/pops/semantic_error.rb +0 -29
  760. data/vendored/puppet/lib/puppet/pops/serialization.rb +0 -43
  761. data/vendored/puppet/lib/puppet/pops/serialization/abstract_reader.rb +0 -180
  762. data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +0 -222
  763. data/vendored/puppet/lib/puppet/pops/serialization/deserializer.rb +0 -80
  764. data/vendored/puppet/lib/puppet/pops/serialization/extension.rb +0 -158
  765. data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +0 -224
  766. data/vendored/puppet/lib/puppet/pops/serialization/instance_reader.rb +0 -19
  767. data/vendored/puppet/lib/puppet/pops/serialization/instance_writer.rb +0 -14
  768. data/vendored/puppet/lib/puppet/pops/serialization/json.rb +0 -297
  769. data/vendored/puppet/lib/puppet/pops/serialization/json_path.rb +0 -127
  770. data/vendored/puppet/lib/puppet/pops/serialization/object.rb +0 -70
  771. data/vendored/puppet/lib/puppet/pops/serialization/serializer.rb +0 -140
  772. data/vendored/puppet/lib/puppet/pops/serialization/time_factory.rb +0 -67
  773. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +0 -313
  774. data/vendored/puppet/lib/puppet/pops/serialization/to_stringified_converter.rb +0 -226
  775. data/vendored/puppet/lib/puppet/pops/time/timespan.rb +0 -718
  776. data/vendored/puppet/lib/puppet/pops/time/timestamp.rb +0 -160
  777. data/vendored/puppet/lib/puppet/pops/types/annotatable.rb +0 -36
  778. data/vendored/puppet/lib/puppet/pops/types/annotation.rb +0 -71
  779. data/vendored/puppet/lib/puppet/pops/types/class_loader.rb +0 -132
  780. data/vendored/puppet/lib/puppet/pops/types/enumeration.rb +0 -16
  781. data/vendored/puppet/lib/puppet/pops/types/implementation_registry.rb +0 -134
  782. data/vendored/puppet/lib/puppet/pops/types/iterable.rb +0 -339
  783. data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +0 -232
  784. data/vendored/puppet/lib/puppet/pops/types/p_init_type.rb +0 -238
  785. data/vendored/puppet/lib/puppet/pops/types/p_meta_type.rb +0 -94
  786. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +0 -1117
  787. data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +0 -218
  788. data/vendored/puppet/lib/puppet/pops/types/p_runtime_type.rb +0 -115
  789. data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -190
  790. data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_type.rb +0 -149
  791. data/vendored/puppet/lib/puppet/pops/types/p_sensitive_type.rb +0 -73
  792. data/vendored/puppet/lib/puppet/pops/types/p_timespan_type.rb +0 -192
  793. data/vendored/puppet/lib/puppet/pops/types/p_timestamp_type.rb +0 -73
  794. data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +0 -383
  795. data/vendored/puppet/lib/puppet/pops/types/p_uri_type.rb +0 -190
  796. data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +0 -40
  797. data/vendored/puppet/lib/puppet/pops/types/recursion_guard.rb +0 -136
  798. data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +0 -472
  799. data/vendored/puppet/lib/puppet/pops/types/ruby_method.rb +0 -31
  800. data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +0 -1123
  801. data/vendored/puppet/lib/puppet/pops/types/tree_iterators.rb +0 -254
  802. data/vendored/puppet/lib/puppet/pops/types/type_acceptor.rb +0 -25
  803. data/vendored/puppet/lib/puppet/pops/types/type_asserter.rb +0 -47
  804. data/vendored/puppet/lib/puppet/pops/types/type_assertion_error.rb +0 -27
  805. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +0 -809
  806. data/vendored/puppet/lib/puppet/pops/types/type_conversion_error.rb +0 -15
  807. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +0 -631
  808. data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +0 -802
  809. data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +0 -1075
  810. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +0 -685
  811. data/vendored/puppet/lib/puppet/pops/types/type_set_reference.rb +0 -59
  812. data/vendored/puppet/lib/puppet/pops/types/type_with_members.rb +0 -43
  813. data/vendored/puppet/lib/puppet/pops/types/types.rb +0 -3631
  814. data/vendored/puppet/lib/puppet/pops/utils.rb +0 -119
  815. data/vendored/puppet/lib/puppet/pops/validation.rb +0 -466
  816. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +0 -1127
  817. data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +0 -101
  818. data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +0 -43
  819. data/vendored/puppet/lib/puppet/pops/visitable.rb +0 -6
  820. data/vendored/puppet/lib/puppet/pops/visitor.rb +0 -116
  821. data/vendored/puppet/lib/puppet/property.rb +0 -608
  822. data/vendored/puppet/lib/puppet/property/boolean.rb +0 -7
  823. data/vendored/puppet/lib/puppet/property/ensure.rb +0 -105
  824. data/vendored/puppet/lib/puppet/property/keyvalue.rb +0 -157
  825. data/vendored/puppet/lib/puppet/property/list.rb +0 -69
  826. data/vendored/puppet/lib/puppet/property/ordered_list.rb +0 -29
  827. data/vendored/puppet/lib/puppet/provider.rb +0 -624
  828. data/vendored/puppet/lib/puppet/provider/aix_object.rb +0 -483
  829. data/vendored/puppet/lib/puppet/provider/command.rb +0 -25
  830. data/vendored/puppet/lib/puppet/provider/confine.rb +0 -6
  831. data/vendored/puppet/lib/puppet/provider/exec.rb +0 -96
  832. data/vendored/puppet/lib/puppet/provider/exec/posix.rb +0 -48
  833. data/vendored/puppet/lib/puppet/provider/exec/shell.rb +0 -25
  834. data/vendored/puppet/lib/puppet/provider/exec/windows.rb +0 -55
  835. data/vendored/puppet/lib/puppet/provider/file/posix.rb +0 -136
  836. data/vendored/puppet/lib/puppet/provider/file/windows.rb +0 -104
  837. data/vendored/puppet/lib/puppet/provider/group/aix.rb +0 -82
  838. data/vendored/puppet/lib/puppet/provider/group/directoryservice.rb +0 -22
  839. data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +0 -111
  840. data/vendored/puppet/lib/puppet/provider/group/ldap.rb +0 -45
  841. data/vendored/puppet/lib/puppet/provider/group/pw.rb +0 -49
  842. data/vendored/puppet/lib/puppet/provider/group/windows_adsi.rb +0 -106
  843. data/vendored/puppet/lib/puppet/provider/ldap.rb +0 -137
  844. data/vendored/puppet/lib/puppet/provider/nameservice.rb +0 -325
  845. data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +0 -508
  846. data/vendored/puppet/lib/puppet/provider/nameservice/objectadd.rb +0 -22
  847. data/vendored/puppet/lib/puppet/provider/nameservice/pw.rb +0 -21
  848. data/vendored/puppet/lib/puppet/provider/network_device.rb +0 -72
  849. data/vendored/puppet/lib/puppet/provider/package.rb +0 -56
  850. data/vendored/puppet/lib/puppet/provider/package/aix.rb +0 -152
  851. data/vendored/puppet/lib/puppet/provider/package/appdmg.rb +0 -109
  852. data/vendored/puppet/lib/puppet/provider/package/apple.rb +0 -46
  853. data/vendored/puppet/lib/puppet/provider/package/apt.rb +0 -116
  854. data/vendored/puppet/lib/puppet/provider/package/aptitude.rb +0 -29
  855. data/vendored/puppet/lib/puppet/provider/package/aptrpm.rb +0 -83
  856. data/vendored/puppet/lib/puppet/provider/package/blastwave.rb +0 -111
  857. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +0 -47
  858. data/vendored/puppet/lib/puppet/provider/package/dpkg.rb +0 -165
  859. data/vendored/puppet/lib/puppet/provider/package/fink.rb +0 -79
  860. data/vendored/puppet/lib/puppet/provider/package/freebsd.rb +0 -47
  861. data/vendored/puppet/lib/puppet/provider/package/gem.rb +0 -175
  862. data/vendored/puppet/lib/puppet/provider/package/hpux.rb +0 -44
  863. data/vendored/puppet/lib/puppet/provider/package/macports.rb +0 -107
  864. data/vendored/puppet/lib/puppet/provider/package/nim.rb +0 -282
  865. data/vendored/puppet/lib/puppet/provider/package/openbsd.rb +0 -242
  866. data/vendored/puppet/lib/puppet/provider/package/opkg.rb +0 -81
  867. data/vendored/puppet/lib/puppet/provider/package/pacman.rb +0 -267
  868. data/vendored/puppet/lib/puppet/provider/package/pip.rb +0 -188
  869. data/vendored/puppet/lib/puppet/provider/package/pip3.rb +0 -20
  870. data/vendored/puppet/lib/puppet/provider/package/pkg.rb +0 -255
  871. data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +0 -151
  872. data/vendored/puppet/lib/puppet/provider/package/pkgin.rb +0 -87
  873. data/vendored/puppet/lib/puppet/provider/package/pkgng.rb +0 -143
  874. data/vendored/puppet/lib/puppet/provider/package/pkgutil.rb +0 -186
  875. data/vendored/puppet/lib/puppet/provider/package/portage.rb +0 -300
  876. data/vendored/puppet/lib/puppet/provider/package/ports.rb +0 -91
  877. data/vendored/puppet/lib/puppet/provider/package/portupgrade.rb +0 -239
  878. data/vendored/puppet/lib/puppet/provider/package/puppet_gem.rb +0 -17
  879. data/vendored/puppet/lib/puppet/provider/package/rpm.rb +0 -405
  880. data/vendored/puppet/lib/puppet/provider/package/rug.rb +0 -51
  881. data/vendored/puppet/lib/puppet/provider/package/sun.rb +0 -133
  882. data/vendored/puppet/lib/puppet/provider/package/sunfreeware.rb +0 -9
  883. data/vendored/puppet/lib/puppet/provider/package/tdnf.rb +0 -28
  884. data/vendored/puppet/lib/puppet/provider/package/up2date.rb +0 -40
  885. data/vendored/puppet/lib/puppet/provider/package/urpmi.rb +0 -55
  886. data/vendored/puppet/lib/puppet/provider/package/windows.rb +0 -113
  887. data/vendored/puppet/lib/puppet/provider/package/windows/exe_package.rb +0 -71
  888. data/vendored/puppet/lib/puppet/provider/package/windows/msi_package.rb +0 -62
  889. data/vendored/puppet/lib/puppet/provider/package/windows/package.rb +0 -100
  890. data/vendored/puppet/lib/puppet/provider/package/yum.rb +0 -293
  891. data/vendored/puppet/lib/puppet/provider/package/zypper.rb +0 -145
  892. data/vendored/puppet/lib/puppet/provider/parsedfile.rb +0 -459
  893. data/vendored/puppet/lib/puppet/provider/service/base.rb +0 -134
  894. data/vendored/puppet/lib/puppet/provider/service/bsd.rb +0 -51
  895. data/vendored/puppet/lib/puppet/provider/service/daemontools.rb +0 -194
  896. data/vendored/puppet/lib/puppet/provider/service/debian.rb +0 -75
  897. data/vendored/puppet/lib/puppet/provider/service/freebsd.rb +0 -143
  898. data/vendored/puppet/lib/puppet/provider/service/gentoo.rb +0 -45
  899. data/vendored/puppet/lib/puppet/provider/service/init.rb +0 -194
  900. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +0 -345
  901. data/vendored/puppet/lib/puppet/provider/service/openbsd.rb +0 -100
  902. data/vendored/puppet/lib/puppet/provider/service/openrc.rb +0 -71
  903. data/vendored/puppet/lib/puppet/provider/service/openwrt.rb +0 -36
  904. data/vendored/puppet/lib/puppet/provider/service/rcng.rb +0 -51
  905. data/vendored/puppet/lib/puppet/provider/service/redhat.rb +0 -72
  906. data/vendored/puppet/lib/puppet/provider/service/runit.rb +0 -112
  907. data/vendored/puppet/lib/puppet/provider/service/service.rb +0 -42
  908. data/vendored/puppet/lib/puppet/provider/service/smf.rb +0 -169
  909. data/vendored/puppet/lib/puppet/provider/service/src.rb +0 -147
  910. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +0 -189
  911. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +0 -369
  912. data/vendored/puppet/lib/puppet/provider/service/windows.rb +0 -103
  913. data/vendored/puppet/lib/puppet/provider/user/aix.rb +0 -271
  914. data/vendored/puppet/lib/puppet/provider/user/directoryservice.rb +0 -632
  915. data/vendored/puppet/lib/puppet/provider/user/hpux.rb +0 -95
  916. data/vendored/puppet/lib/puppet/provider/user/ldap.rb +0 -128
  917. data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +0 -76
  918. data/vendored/puppet/lib/puppet/provider/user/pw.rb +0 -98
  919. data/vendored/puppet/lib/puppet/provider/user/user_role_add.rb +0 -233
  920. data/vendored/puppet/lib/puppet/provider/user/useradd.rb +0 -265
  921. data/vendored/puppet/lib/puppet/provider/user/windows_adsi.rb +0 -148
  922. data/vendored/puppet/lib/puppet/reference/configuration.rb +0 -92
  923. data/vendored/puppet/lib/puppet/reference/function.rb +0 -17
  924. data/vendored/puppet/lib/puppet/reference/indirection.rb +0 -71
  925. data/vendored/puppet/lib/puppet/reference/metaparameter.rb +0 -35
  926. data/vendored/puppet/lib/puppet/reference/providers.rb +0 -118
  927. data/vendored/puppet/lib/puppet/reference/report.rb +0 -20
  928. data/vendored/puppet/lib/puppet/reference/type.rb +0 -113
  929. data/vendored/puppet/lib/puppet/relationship.rb +0 -89
  930. data/vendored/puppet/lib/puppet/reports.rb +0 -93
  931. data/vendored/puppet/lib/puppet/reports/http.rb +0 -37
  932. data/vendored/puppet/lib/puppet/reports/log.rb +0 -14
  933. data/vendored/puppet/lib/puppet/reports/store.rb +0 -68
  934. data/vendored/puppet/lib/puppet/resource.rb +0 -687
  935. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +0 -150
  936. data/vendored/puppet/lib/puppet/resource/catalog.rb +0 -675
  937. data/vendored/puppet/lib/puppet/resource/status.rb +0 -229
  938. data/vendored/puppet/lib/puppet/resource/type.rb +0 -528
  939. data/vendored/puppet/lib/puppet/resource/type_collection.rb +0 -263
  940. data/vendored/puppet/lib/puppet/rest/client.rb +0 -83
  941. data/vendored/puppet/lib/puppet/rest/errors.rb +0 -14
  942. data/vendored/puppet/lib/puppet/rest/response.rb +0 -34
  943. data/vendored/puppet/lib/puppet/rest/route.rb +0 -84
  944. data/vendored/puppet/lib/puppet/rest/routes.rb +0 -154
  945. data/vendored/puppet/lib/puppet/rest/ssl_context.rb +0 -13
  946. data/vendored/puppet/lib/puppet/scheduler.rb +0 -16
  947. data/vendored/puppet/lib/puppet/scheduler/job.rb +0 -53
  948. data/vendored/puppet/lib/puppet/scheduler/scheduler.rb +0 -44
  949. data/vendored/puppet/lib/puppet/scheduler/splay_job.rb +0 -32
  950. data/vendored/puppet/lib/puppet/scheduler/timer.rb +0 -13
  951. data/vendored/puppet/lib/puppet/settings.rb +0 -1485
  952. data/vendored/puppet/lib/puppet/settings/array_setting.rb +0 -17
  953. data/vendored/puppet/lib/puppet/settings/autosign_setting.rb +0 -22
  954. data/vendored/puppet/lib/puppet/settings/base_setting.rb +0 -197
  955. data/vendored/puppet/lib/puppet/settings/boolean_setting.rb +0 -32
  956. data/vendored/puppet/lib/puppet/settings/certificate_revocation_setting.rb +0 -21
  957. data/vendored/puppet/lib/puppet/settings/config_file.rb +0 -152
  958. data/vendored/puppet/lib/puppet/settings/directory_setting.rb +0 -18
  959. data/vendored/puppet/lib/puppet/settings/duration_setting.rb +0 -32
  960. data/vendored/puppet/lib/puppet/settings/enum_setting.rb +0 -16
  961. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +0 -222
  962. data/vendored/puppet/lib/puppet/settings/errors.rb +0 -11
  963. data/vendored/puppet/lib/puppet/settings/file_or_directory_setting.rb +0 -40
  964. data/vendored/puppet/lib/puppet/settings/file_setting.rb +0 -245
  965. data/vendored/puppet/lib/puppet/settings/ini_file.rb +0 -225
  966. data/vendored/puppet/lib/puppet/settings/path_setting.rb +0 -8
  967. data/vendored/puppet/lib/puppet/settings/priority_setting.rb +0 -42
  968. data/vendored/puppet/lib/puppet/settings/server_list_setting.rb +0 -20
  969. data/vendored/puppet/lib/puppet/settings/string_setting.rb +0 -9
  970. data/vendored/puppet/lib/puppet/settings/symbolic_enum_setting.rb +0 -17
  971. data/vendored/puppet/lib/puppet/settings/terminus_setting.rb +0 -14
  972. data/vendored/puppet/lib/puppet/settings/ttl_setting.rb +0 -51
  973. data/vendored/puppet/lib/puppet/settings/value_translator.rb +0 -15
  974. data/vendored/puppet/lib/puppet/ssl.rb +0 -12
  975. data/vendored/puppet/lib/puppet/ssl/base.rb +0 -150
  976. data/vendored/puppet/lib/puppet/ssl/certificate.rb +0 -99
  977. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +0 -325
  978. data/vendored/puppet/lib/puppet/ssl/certificate_request_attributes.rb +0 -37
  979. data/vendored/puppet/lib/puppet/ssl/certificate_signer.rb +0 -33
  980. data/vendored/puppet/lib/puppet/ssl/digest.rb +0 -20
  981. data/vendored/puppet/lib/puppet/ssl/host.rb +0 -626
  982. data/vendored/puppet/lib/puppet/ssl/key.rb +0 -59
  983. data/vendored/puppet/lib/puppet/ssl/oids.rb +0 -193
  984. data/vendored/puppet/lib/puppet/ssl/validator.rb +0 -60
  985. data/vendored/puppet/lib/puppet/ssl/validator/default_validator.rb +0 -187
  986. data/vendored/puppet/lib/puppet/ssl/validator/no_validator.rb +0 -20
  987. data/vendored/puppet/lib/puppet/status.rb +0 -40
  988. data/vendored/puppet/lib/puppet/syntax_checkers.rb +0 -3
  989. data/vendored/puppet/lib/puppet/syntax_checkers/base64.rb +0 -40
  990. data/vendored/puppet/lib/puppet/syntax_checkers/json.rb +0 -35
  991. data/vendored/puppet/lib/puppet/test/test_helper.rb +0 -251
  992. data/vendored/puppet/lib/puppet/transaction.rb +0 -444
  993. data/vendored/puppet/lib/puppet/transaction/additional_resource_generator.rb +0 -220
  994. data/vendored/puppet/lib/puppet/transaction/event.rb +0 -167
  995. data/vendored/puppet/lib/puppet/transaction/event_manager.rb +0 -169
  996. data/vendored/puppet/lib/puppet/transaction/persistence.rb +0 -99
  997. data/vendored/puppet/lib/puppet/transaction/report.rb +0 -471
  998. data/vendored/puppet/lib/puppet/transaction/resource_harness.rb +0 -318
  999. data/vendored/puppet/lib/puppet/type.rb +0 -2673
  1000. data/vendored/puppet/lib/puppet/type/component.rb +0 -88
  1001. data/vendored/puppet/lib/puppet/type/exec.rb +0 -625
  1002. data/vendored/puppet/lib/puppet/type/file.rb +0 -1042
  1003. data/vendored/puppet/lib/puppet/type/file/checksum.rb +0 -50
  1004. data/vendored/puppet/lib/puppet/type/file/checksum_value.rb +0 -54
  1005. data/vendored/puppet/lib/puppet/type/file/content.rb +0 -172
  1006. data/vendored/puppet/lib/puppet/type/file/ctime.rb +0 -20
  1007. data/vendored/puppet/lib/puppet/type/file/data_sync.rb +0 -93
  1008. data/vendored/puppet/lib/puppet/type/file/ensure.rb +0 -192
  1009. data/vendored/puppet/lib/puppet/type/file/group.rb +0 -41
  1010. data/vendored/puppet/lib/puppet/type/file/mode.rb +0 -177
  1011. data/vendored/puppet/lib/puppet/type/file/mtime.rb +0 -18
  1012. data/vendored/puppet/lib/puppet/type/file/owner.rb +0 -44
  1013. data/vendored/puppet/lib/puppet/type/file/selcontext.rb +0 -141
  1014. data/vendored/puppet/lib/puppet/type/file/source.rb +0 -369
  1015. data/vendored/puppet/lib/puppet/type/file/target.rb +0 -87
  1016. data/vendored/puppet/lib/puppet/type/file/type.rb +0 -19
  1017. data/vendored/puppet/lib/puppet/type/filebucket.rb +0 -117
  1018. data/vendored/puppet/lib/puppet/type/group.rb +0 -207
  1019. data/vendored/puppet/lib/puppet/type/notify.rb +0 -46
  1020. data/vendored/puppet/lib/puppet/type/package.rb +0 -568
  1021. data/vendored/puppet/lib/puppet/type/resources.rb +0 -180
  1022. data/vendored/puppet/lib/puppet/type/schedule.rb +0 -430
  1023. data/vendored/puppet/lib/puppet/type/service.rb +0 -255
  1024. data/vendored/puppet/lib/puppet/type/stage.rb +0 -27
  1025. data/vendored/puppet/lib/puppet/type/tidy.rb +0 -349
  1026. data/vendored/puppet/lib/puppet/type/user.rb +0 -818
  1027. data/vendored/puppet/lib/puppet/type/whit.rb +0 -34
  1028. data/vendored/puppet/lib/puppet/util.rb +0 -705
  1029. data/vendored/puppet/lib/puppet/util/at_fork.rb +0 -35
  1030. data/vendored/puppet/lib/puppet/util/at_fork/noop.rb +0 -18
  1031. data/vendored/puppet/lib/puppet/util/at_fork/solaris.rb +0 -160
  1032. data/vendored/puppet/lib/puppet/util/autoload.rb +0 -234
  1033. data/vendored/puppet/lib/puppet/util/backups.rb +0 -86
  1034. data/vendored/puppet/lib/puppet/util/character_encoding.rb +0 -76
  1035. data/vendored/puppet/lib/puppet/util/checksums.rb +0 -361
  1036. data/vendored/puppet/lib/puppet/util/classgen.rb +0 -222
  1037. data/vendored/puppet/lib/puppet/util/colors.rb +0 -100
  1038. data/vendored/puppet/lib/puppet/util/command_line.rb +0 -189
  1039. data/vendored/puppet/lib/puppet/util/command_line/puppet_option_parser.rb +0 -87
  1040. data/vendored/puppet/lib/puppet/util/command_line/trollop.rb +0 -825
  1041. data/vendored/puppet/lib/puppet/util/connection.rb +0 -74
  1042. data/vendored/puppet/lib/puppet/util/constant_inflector.rb +0 -24
  1043. data/vendored/puppet/lib/puppet/util/diff.rb +0 -79
  1044. data/vendored/puppet/lib/puppet/util/docs.rb +0 -128
  1045. data/vendored/puppet/lib/puppet/util/errors.rb +0 -159
  1046. data/vendored/puppet/lib/puppet/util/execution.rb +0 -412
  1047. data/vendored/puppet/lib/puppet/util/execution_stub.rb +0 -26
  1048. data/vendored/puppet/lib/puppet/util/feature.rb +0 -117
  1049. data/vendored/puppet/lib/puppet/util/file_watcher.rb +0 -28
  1050. data/vendored/puppet/lib/puppet/util/fileparsing.rb +0 -397
  1051. data/vendored/puppet/lib/puppet/util/filetype.rb +0 -309
  1052. data/vendored/puppet/lib/puppet/util/http_proxy.rb +0 -207
  1053. data/vendored/puppet/lib/puppet/util/inifile.rb +0 -340
  1054. data/vendored/puppet/lib/puppet/util/instance_loader.rb +0 -61
  1055. data/vendored/puppet/lib/puppet/util/json.rb +0 -69
  1056. data/vendored/puppet/lib/puppet/util/json_lockfile.rb +0 -44
  1057. data/vendored/puppet/lib/puppet/util/ldap.rb +0 -2
  1058. data/vendored/puppet/lib/puppet/util/ldap/connection.rb +0 -71
  1059. data/vendored/puppet/lib/puppet/util/ldap/generator.rb +0 -42
  1060. data/vendored/puppet/lib/puppet/util/ldap/manager.rb +0 -281
  1061. data/vendored/puppet/lib/puppet/util/libuser.rb +0 -12
  1062. data/vendored/puppet/lib/puppet/util/limits.rb +0 -12
  1063. data/vendored/puppet/lib/puppet/util/lockfile.rb +0 -66
  1064. data/vendored/puppet/lib/puppet/util/log.rb +0 -415
  1065. data/vendored/puppet/lib/puppet/util/log/destination.rb +0 -49
  1066. data/vendored/puppet/lib/puppet/util/log/destinations.rb +0 -258
  1067. data/vendored/puppet/lib/puppet/util/logging.rb +0 -311
  1068. data/vendored/puppet/lib/puppet/util/metaid.rb +0 -21
  1069. data/vendored/puppet/lib/puppet/util/metric.rb +0 -64
  1070. data/vendored/puppet/lib/puppet/util/monkey_patches.rb +0 -108
  1071. data/vendored/puppet/lib/puppet/util/multi_match.rb +0 -51
  1072. data/vendored/puppet/lib/puppet/util/network_device.rb +0 -17
  1073. data/vendored/puppet/lib/puppet/util/network_device/base.rb +0 -23
  1074. data/vendored/puppet/lib/puppet/util/network_device/config.rb +0 -105
  1075. data/vendored/puppet/lib/puppet/util/network_device/transport.rb +0 -5
  1076. data/vendored/puppet/lib/puppet/util/network_device/transport/base.rb +0 -26
  1077. data/vendored/puppet/lib/puppet/util/package.rb +0 -31
  1078. data/vendored/puppet/lib/puppet/util/pidlock.rb +0 -62
  1079. data/vendored/puppet/lib/puppet/util/platform.rb +0 -38
  1080. data/vendored/puppet/lib/puppet/util/plist.rb +0 -155
  1081. data/vendored/puppet/lib/puppet/util/posix.rb +0 -137
  1082. data/vendored/puppet/lib/puppet/util/profiler.rb +0 -53
  1083. data/vendored/puppet/lib/puppet/util/profiler/aggregate.rb +0 -85
  1084. data/vendored/puppet/lib/puppet/util/profiler/around_profiler.rb +0 -67
  1085. data/vendored/puppet/lib/puppet/util/profiler/logging.rb +0 -48
  1086. data/vendored/puppet/lib/puppet/util/profiler/object_counts.rb +0 -17
  1087. data/vendored/puppet/lib/puppet/util/profiler/wall_clock.rb +0 -35
  1088. data/vendored/puppet/lib/puppet/util/provider_features.rb +0 -181
  1089. data/vendored/puppet/lib/puppet/util/psych_support.rb +0 -30
  1090. data/vendored/puppet/lib/puppet/util/rdoc.rb +0 -60
  1091. data/vendored/puppet/lib/puppet/util/rdoc/code_objects.rb +0 -294
  1092. data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +0 -910
  1093. data/vendored/puppet/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +0 -1085
  1094. data/vendored/puppet/lib/puppet/util/rdoc/parser.rb +0 -12
  1095. data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +0 -259
  1096. data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +0 -14
  1097. data/vendored/puppet/lib/puppet/util/reference.rb +0 -119
  1098. data/vendored/puppet/lib/puppet/util/resource_template.rb +0 -61
  1099. data/vendored/puppet/lib/puppet/util/retry_action.rb +0 -46
  1100. data/vendored/puppet/lib/puppet/util/rubygems.rb +0 -63
  1101. data/vendored/puppet/lib/puppet/util/run_mode.rb +0 -110
  1102. data/vendored/puppet/lib/puppet/util/selinux.rb +0 -264
  1103. data/vendored/puppet/lib/puppet/util/skip_tags.rb +0 -9
  1104. data/vendored/puppet/lib/puppet/util/splayer.rb +0 -18
  1105. data/vendored/puppet/lib/puppet/util/ssl.rb +0 -92
  1106. data/vendored/puppet/lib/puppet/util/storage.rb +0 -89
  1107. data/vendored/puppet/lib/puppet/util/suidmanager.rb +0 -167
  1108. data/vendored/puppet/lib/puppet/util/symbolic_file_mode.rb +0 -144
  1109. data/vendored/puppet/lib/puppet/util/tag_set.rb +0 -27
  1110. data/vendored/puppet/lib/puppet/util/tagging.rb +0 -131
  1111. data/vendored/puppet/lib/puppet/util/terminal.rb +0 -16
  1112. data/vendored/puppet/lib/puppet/util/user_attr.rb +0 -21
  1113. data/vendored/puppet/lib/puppet/util/warnings.rb +0 -31
  1114. data/vendored/puppet/lib/puppet/util/watched_file.rb +0 -37
  1115. data/vendored/puppet/lib/puppet/util/watcher.rb +0 -17
  1116. data/vendored/puppet/lib/puppet/util/watcher/change_watcher.rb +0 -33
  1117. data/vendored/puppet/lib/puppet/util/watcher/periodic_watcher.rb +0 -37
  1118. data/vendored/puppet/lib/puppet/util/watcher/timer.rb +0 -19
  1119. data/vendored/puppet/lib/puppet/util/windows.rb +0 -52
  1120. data/vendored/puppet/lib/puppet/util/windows/access_control_entry.rb +0 -84
  1121. data/vendored/puppet/lib/puppet/util/windows/access_control_list.rb +0 -113
  1122. data/vendored/puppet/lib/puppet/util/windows/adsi.rb +0 -494
  1123. data/vendored/puppet/lib/puppet/util/windows/api_types.rb +0 -282
  1124. data/vendored/puppet/lib/puppet/util/windows/com.rb +0 -225
  1125. data/vendored/puppet/lib/puppet/util/windows/error.rb +0 -83
  1126. data/vendored/puppet/lib/puppet/util/windows/eventlog.rb +0 -197
  1127. data/vendored/puppet/lib/puppet/util/windows/file.rb +0 -589
  1128. data/vendored/puppet/lib/puppet/util/windows/principal.rb +0 -192
  1129. data/vendored/puppet/lib/puppet/util/windows/process.rb +0 -497
  1130. data/vendored/puppet/lib/puppet/util/windows/registry.rb +0 -374
  1131. data/vendored/puppet/lib/puppet/util/windows/root_certs.rb +0 -108
  1132. data/vendored/puppet/lib/puppet/util/windows/security.rb +0 -869
  1133. data/vendored/puppet/lib/puppet/util/windows/security_descriptor.rb +0 -62
  1134. data/vendored/puppet/lib/puppet/util/windows/service.rb +0 -770
  1135. data/vendored/puppet/lib/puppet/util/windows/sid.rb +0 -282
  1136. data/vendored/puppet/lib/puppet/util/windows/string.rb +0 -16
  1137. data/vendored/puppet/lib/puppet/util/windows/user.rb +0 -309
  1138. data/vendored/puppet/lib/puppet/util/yaml.rb +0 -72
  1139. data/vendored/puppet/lib/puppet/vendor.rb +0 -57
  1140. data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge.rb +0 -2
  1141. data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge/core.rb +0 -210
  1142. data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge/deep_merge_hash.rb +0 -28
  1143. data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge/rails_compat.rb +0 -27
  1144. data/vendored/puppet/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +0 -608
  1145. data/vendored/puppet/lib/puppet/vendor/load_deep_merge.rb +0 -1
  1146. data/vendored/puppet/lib/puppet/vendor/load_pathspec.rb +0 -1
  1147. data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec.rb +0 -122
  1148. data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +0 -275
  1149. data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec/regexspec.rb +0 -17
  1150. data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec/spec.rb +0 -14
  1151. data/vendored/puppet/lib/puppet/vendor/require_vendored.rb +0 -6
  1152. data/vendored/puppet/lib/puppet/version.rb +0 -93
  1153. data/vendored/puppet/lib/puppet_pal.rb +0 -1135
  1154. data/vendored/puppet/lib/puppet_x.rb +0 -14
  1155. data/vendored/require_vendored.rb +0 -3
@@ -1,59 +0,0 @@
1
- module Puppet::Pops
2
- module Types
3
- class TypeSetReference
4
- include Annotatable
5
-
6
- attr_reader :name_authority
7
- attr_reader :name
8
- attr_reader :version_range
9
- attr_reader :type_set
10
-
11
- def initialize(owner, init_hash)
12
- @owner = owner
13
- @name_authority = (init_hash[KEY_NAME_AUTHORITY] || owner.name_authority).freeze
14
- @name = init_hash[KEY_NAME].freeze
15
- @version_range = PSemVerRangeType.convert(init_hash[KEY_VERSION_RANGE])
16
- init_annotatable(init_hash)
17
- end
18
-
19
- def accept(visitor, guard)
20
- annotatable_accept(visitor, guard)
21
- end
22
-
23
- def eql?(o)
24
- self.class == o.class && @name_authority.eql?(o.name_authority) && @name.eql?(o.name) && @version_range.eql?(o.version_range)
25
- end
26
-
27
- def hash
28
- [@name_authority, @name, @version_range].hash
29
- end
30
-
31
- def _pcore_init_hash
32
- result = super
33
- result[KEY_NAME_AUTHORITY] = @name_authority unless @name_authority == @owner.name_authority
34
- result[KEY_NAME] = @name
35
- result[KEY_VERSION_RANGE] = @version_range.to_s
36
- result
37
- end
38
-
39
- def resolve(loader)
40
- typed_name = Loader::TypedName.new(:type, @name, @name_authority)
41
- loaded_entry = loader.load_typed(typed_name)
42
- type_set = loaded_entry.nil? ? nil : loaded_entry.value
43
-
44
- raise ArgumentError, "#{self} cannot be resolved" if type_set.nil?
45
- raise ArgumentError, "#{self} resolves to a #{type_set.name}" unless type_set.is_a?(PTypeSetType)
46
-
47
- @type_set = type_set.resolve(loader)
48
- unless @version_range.include?(@type_set.version)
49
- raise ArgumentError, "#{self} resolves to an incompatible version. Expected #{@version_range}, got #{type_set.version}"
50
- end
51
- nil
52
- end
53
-
54
- def to_s
55
- "#{@owner.label} reference to TypeSet named '#{@name}'"
56
- end
57
- end
58
- end
59
- end
@@ -1,43 +0,0 @@
1
- module Puppet::Pops
2
- module Types
3
-
4
- # Interface implemented by a type that has InvocableMembers
5
- module TypeWithMembers
6
- # @return [InvocableMember,nil] An invocable member if it exists, or `nil`
7
- def [](member_name)
8
- raise NotImplementedError, "'#{self.class.name}' should implement #[]"
9
- end
10
- end
11
-
12
- # Interface implemented by attribute and function members
13
- module InvocableMember
14
- # Performs type checking of arguments and invokes the method that corresponds to this
15
- # method. The result of the invocation is returned
16
- #
17
- # @param receiver [Object] The receiver of the call
18
- # @param scope [Puppet::Parser::Scope] The caller scope
19
- # @param args [Array] Array of arguments.
20
- # @return [Object] The result returned by the member function or attribute
21
- #
22
- # @api private
23
- def invoke(receiver, scope, args, &block)
24
- raise NotImplementedError, "'#{self.class.name}' should implement #invoke"
25
- end
26
- end
27
-
28
- # Plays the same role as an PAttribute in the PObjectType. Provides
29
- # access to known attr_readers and plain reader methods.
30
- class AttrReader
31
- include InvocableMember
32
-
33
- def initialize(message)
34
- @message = message.to_sym
35
- end
36
-
37
- def invoke(receiver, scope, args, &block)
38
- receiver.send(@message)
39
- end
40
- end
41
- end
42
- end
43
-
@@ -1,3631 +0,0 @@
1
- require_relative 'iterable'
2
- require_relative 'enumeration'
3
- require_relative 'recursion_guard'
4
- require_relative 'type_acceptor'
5
- require_relative 'type_asserter'
6
- require_relative 'type_assertion_error'
7
- require_relative 'type_conversion_error'
8
- require_relative 'type_formatter'
9
- require_relative 'type_calculator'
10
- require_relative 'type_factory'
11
- require_relative 'type_parser'
12
- require_relative 'class_loader'
13
- require_relative 'type_mismatch_describer'
14
- require_relative 'puppet_object'
15
-
16
- module Puppet::Pops
17
- module Types
18
-
19
- # The EMPTY_xxx declarations is for backward compatibility. They should not be explicitly referenced
20
-
21
- # @api private
22
- # @deprecated
23
- EMPTY_HASH = Puppet::Pops::EMPTY_HASH
24
-
25
- # @api private
26
- # @deprecated
27
- EMPTY_ARRAY = Puppet::Pops::EMPTY_ARRAY
28
-
29
- # @api private
30
- # @deprecated
31
- EMPTY_STRING = Puppet::Pops::EMPTY_STRING
32
-
33
- # The Types model is a model of Puppet Language types.
34
- #
35
- # The {TypeCalculator} should be used to answer questions about types. The {TypeFactory} or {TypeParser} should be used
36
- # to create an instance of a type whenever one is needed.
37
- #
38
- # The implementation of the Types model contains methods that are required for the type objects to behave as
39
- # expected when comparing them and using them as keys in hashes. (No other logic is, or should be included directly in
40
- # the model's classes).
41
- #
42
- # @api public
43
- #
44
- class TypedModelObject < Object
45
- include PuppetObject
46
- include Visitable
47
- include Adaptable
48
-
49
- def self._pcore_type
50
- @type
51
- end
52
-
53
- def self.create_ptype(loader, ir, parent_name, attributes_hash = EMPTY_HASH)
54
- @type = Pcore::create_object_type(loader, ir, self, "Pcore::#{simple_name}Type", "Pcore::#{parent_name}", attributes_hash)
55
- end
56
-
57
- def self.register_ptypes(loader, ir)
58
- types = [
59
- Annotation.register_ptype(loader, ir),
60
- RubyMethod.register_ptype(loader, ir),
61
- ]
62
- Types.constants.each do |c|
63
- next if c == :PType || c == :PHostClassType
64
- cls = Types.const_get(c)
65
- next unless cls.is_a?(Class) && cls < self
66
- type = cls.register_ptype(loader, ir)
67
- types << type unless type.nil?
68
- end
69
- types.each { |type| type.resolve(loader) }
70
- end
71
- end
72
-
73
- # Base type for all types
74
- # @api public
75
- #
76
- class PAnyType < TypedModelObject
77
-
78
- def self.register_ptype(loader, ir)
79
- @type = Pcore::create_object_type(loader, ir, self, 'Pcore::AnyType', 'Any', EMPTY_HASH)
80
- end
81
-
82
- def self.create(*args)
83
- # NOTE! Important to use self::DEFAULT and not just DEFAULT since the latter yields PAnyType::DEFAULT
84
- args.empty? ? self::DEFAULT : new(*args)
85
- end
86
-
87
- # Accept a visitor that will be sent the message `visit`, once with `self` as the
88
- # argument. The visitor will then visit all types that this type contains.
89
- #
90
- def accept(visitor, guard)
91
- visitor.visit(self, guard)
92
- end
93
-
94
- # Checks if _o_ is a type that is assignable to this type.
95
- # If _o_ is a `Class` then it is first converted to a type.
96
- # If _o_ is a Variant, then it is considered assignable when all its types are assignable
97
- #
98
- # The check for assignable must be guarded against self recursion since `self`, the given type _o_,
99
- # or both, might be a `TypeAlias`. The initial caller of this method will typically never care
100
- # about this and hence pass only the first argument, but as soon as a check of a contained type
101
- # encounters a `TypeAlias`, then a `RecursionGuard` instance is created and passed on in all
102
- # subsequent calls. The recursion is allowed to continue until self recursion has been detected in
103
- # both `self` and in the given type. At that point the given type is considered to be assignable
104
- # to `self` since all checks up to that point were positive.
105
- #
106
- # @param o [Class,PAnyType] the class or type to test
107
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
108
- # @return [Boolean] `true` when _o_ is assignable to this type
109
- # @api public
110
- def assignable?(o, guard = nil)
111
- case o
112
- when Class
113
- # Safe to call _assignable directly since a Class never is a Unit or Variant
114
- _assignable?(TypeCalculator.singleton.type(o), guard)
115
- when PUnitType
116
- true
117
- when PTypeAliasType
118
- # An alias may contain self recursive constructs.
119
- if o.self_recursion?
120
- guard ||= RecursionGuard.new
121
- if guard.add_that(o) == RecursionGuard::SELF_RECURSION_IN_BOTH
122
- # Recursion detected both in self and other. This means that other is assignable
123
- # to self. This point would not have been reached otherwise
124
- true
125
- else
126
- assignable?(o.resolved_type, guard)
127
- end
128
- else
129
- assignable?(o.resolved_type, guard)
130
- end
131
- when PVariantType
132
- # Assignable if all contained types are assignable, or if this is exactly Any
133
- return true if self.class == PAnyType
134
- # An empty variant may be assignable to NotUndef[T] if T is assignable to empty variant
135
- return _assignable?(o, guard) if is_a?(PNotUndefType) && o.types.empty?
136
- !o.types.empty? && o.types.all? { |vt| assignable?(vt, guard) }
137
- when POptionalType
138
- # Assignable if undef and contained type is assignable
139
- assignable?(PUndefType::DEFAULT) && (o.type.nil? || assignable?(o.type))
140
- when PNotUndefType
141
- if !(o.type.nil? || o.type.assignable?(PUndefType::DEFAULT))
142
- assignable?(o.type, guard)
143
- else
144
- _assignable?(o, guard)
145
- end
146
- else
147
- _assignable?(o, guard)
148
- end
149
- end
150
-
151
- # Returns `true` if this instance is a callable that accepts the given _args_type_ type
152
- #
153
- # @param args_type [PAnyType] the arguments to test
154
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
155
- # @return [Boolean] `true` if this instance is a callable that accepts the given _args_
156
- def callable?(args_type, guard = nil)
157
- args_type.is_a?(PAnyType) && kind_of_callable? && args_type.callable_args?(self, guard)
158
- end
159
-
160
- # Returns `true` if this instance is a callable that accepts the given _args_
161
- #
162
- # @param args [Array] the arguments to test
163
- # @param block [Proc] block, or nil if not called with a block
164
- # @return [Boolean] `true` if this instance is a callable that accepts the given _args_
165
- def callable_with?(args, block = nil)
166
- false
167
- end
168
-
169
- # Returns `true` if this instance is considered valid as arguments to the given `callable`
170
- # @param callable [PAnyType] the callable
171
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
172
- # @return [Boolean] `true` if this instance is considered valid as arguments to the given `callable`
173
- # @api private
174
- def callable_args?(callable, guard)
175
- false
176
- end
177
-
178
- # Called from the `PTypeAliasType` when it detects self recursion. The default is to do nothing
179
- # but some self recursive constructs are illegal such as when a `PObjectType` somehow inherits itself
180
- # @param originator [PTypeAliasType] the starting point for the check
181
- # @raise Puppet::Error if an illegal self recursion is detected
182
- # @api private
183
- def check_self_recursion(originator)
184
- end
185
-
186
- # Generalizes value specific types. Types that are not value specific will return `self` otherwise
187
- # the generalized type is returned.
188
- #
189
- # @return [PAnyType] The generalized type
190
- # @api public
191
- def generalize
192
- # Applicable to all types that have no variables
193
- self
194
- end
195
-
196
- # Returns the loader that loaded this type.
197
- # @return [Loaders::Loader] the loader
198
- def loader
199
- Loaders.static_loader
200
- end
201
-
202
- # Normalizes the type. This does not change the characteristics of the type but it will remove duplicates
203
- # and constructs like NotUndef[T] where T is not assignable from Undef and change Variant[*T] where all
204
- # T are enums into an Enum.
205
- #
206
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
207
- # @return [PAnyType] The iterable type that this type is assignable to or `nil`
208
- # @api public
209
- def normalize(guard = nil)
210
- self
211
- end
212
-
213
- # Called from the TypeParser once it has found a type using the Loader to enable that this type can
214
- # resolve internal type expressions using a loader. Presently, this method is a no-op for all types
215
- # except the {{PTypeAliasType}}.
216
- #
217
- # @param loader [Loader::Loader] loader to use
218
- # @return [PTypeAliasType] the receiver of the call, i.e. `self`
219
- # @api private
220
- def resolve(loader)
221
- self
222
- end
223
-
224
- # Responds `true` for all callables, variants of callables and unless _optional_ is
225
- # false, all optional callables.
226
- # @param optional [Boolean]
227
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
228
- # @return [Boolean] `true`if this type is considered callable
229
- # @api private
230
- def kind_of_callable?(optional = true, guard = nil)
231
- false
232
- end
233
-
234
- # Returns `true` if an instance of this type is iterable, `false` otherwise
235
- # The method #iterable_type must produce a `PIterableType` instance when this
236
- # method returns `true`
237
- #
238
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
239
- # @return [Boolean] flag to indicate if instances of this type is iterable.
240
- def iterable?(guard = nil)
241
- false
242
- end
243
-
244
- # Returns the `PIterableType` that this type should be assignable to, or `nil` if no such type exists.
245
- # A type that returns a `PIterableType` must respond `true` to `#iterable?`.
246
- #
247
- # @example
248
- # Any Collection[T] is assignable to an Iterable[T]
249
- # A String is assignable to an Iterable[String] iterating over the strings characters
250
- # An Integer is assignable to an Iterable[Integer] iterating over the 'times' enumerator
251
- # A Type[T] is assignable to an Iterable[Type[T]] if T is an Integer or Enum
252
- #
253
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
254
- # @return [PIterableType,nil] The iterable type that this type is assignable to or `nil`
255
- # @api private
256
- def iterable_type(guard = nil)
257
- nil
258
- end
259
-
260
- def hash
261
- self.class.hash
262
- end
263
-
264
- # Returns true if the given argument _o_ is an instance of this type
265
- # @param guard [RecursionGuard] guard against recursion. Only used by internal calls
266
- # @return [Boolean]
267
- # @api public
268
- def instance?(o, guard = nil)
269
- true
270
- end
271
-
272
- # An object is considered to really be an instance of a type when something other than a
273
- # TypeAlias or a Variant responds true to a call to {#instance?}.
274
- #
275
- # @return [Integer] -1 = is not instance, 0 = recursion detected, 1 = is instance
276
- # @api private
277
- def really_instance?(o, guard = nil)
278
- instance?(o, guard) ? 1 : -1
279
- end
280
-
281
- def eql?(o)
282
- self.class == o.class
283
- end
284
-
285
- def ==(o)
286
- eql?(o)
287
- end
288
-
289
- def simple_name
290
- self.class.simple_name
291
- end
292
-
293
- # Strips the class name from all module prefixes, the leading 'P' and the ending 'Type'. I.e.
294
- # an instance of PVariantType will return 'Variant'
295
- # @return [String] the simple name of this type
296
- def self.simple_name
297
- @simple_name ||= (
298
- n = name
299
- n[n.rindex(DOUBLE_COLON)+3..n.size-5].freeze
300
- )
301
- end
302
-
303
- def to_alias_expanded_s
304
- TypeFormatter.new.alias_expanded_string(self)
305
- end
306
-
307
- def to_s
308
- TypeFormatter.string(self)
309
- end
310
-
311
- # Returns the name of the type, without parameters
312
- # @return [String] the name of the type
313
- # @api public
314
- def name
315
- simple_name
316
- end
317
-
318
- def create(*args)
319
- Loaders.find_loader(nil).load(:function, 'new').call({}, self, *args)
320
- end
321
-
322
- # Create an instance of this type.
323
- # The default implementation will just dispatch the call to the class method with the
324
- # same name and pass `self` as the first argument.
325
- #
326
- # @return [Function] the created function
327
- # @raises ArgumentError
328
- #
329
- def new_function
330
- self.class.new_function(self)
331
- end
332
-
333
- # This default implementation of of a new_function raises an Argument Error.
334
- # Types for which creating a new instance is supported, should create and return
335
- # a Puppet Function class by using Puppet:Loaders.create_loaded_function(:new, loader)
336
- # and return that result.
337
- #
338
- # @param type [PAnyType] the type to create a new function for
339
- # @return [Function] the created function
340
- # @raises ArgumentError
341
- #
342
- def self.new_function(type)
343
- raise ArgumentError.new("Creation of new instance of type '#{type.to_s}' is not supported")
344
- end
345
-
346
- # Answers the question if instances of this type can represent themselves as a string that
347
- # can then be passed to the create method
348
- #
349
- # @return [Boolean] whether or not the instance has a canonical string representation
350
- def roundtrip_with_string?
351
- false
352
- end
353
-
354
- # The default instance of this type. Each type in the type system has this constant
355
- # declared.
356
- #
357
- DEFAULT = PAnyType.new
358
-
359
- protected
360
-
361
- # @api private
362
- def _assignable?(o, guard)
363
- o.is_a?(PAnyType)
364
- end
365
-
366
- # Produces the tuple entry at the given index given a tuple type, its from/to constraints on the last
367
- # type, and an index.
368
- # Produces nil if the index is out of bounds
369
- # from must be less than to, and from may not be less than 0
370
- #
371
- # @api private
372
- #
373
- def tuple_entry_at(tuple_t, to, index)
374
- regular = (tuple_t.types.size - 1)
375
- if index < regular
376
- tuple_t.types[index]
377
- elsif index < regular + to
378
- # in the varargs part
379
- tuple_t.types[-1]
380
- else
381
- nil
382
- end
383
- end
384
-
385
- # Applies a transformation by sending the given _method_ and _method_args_ to each of the types of the given array
386
- # and collecting the results in a new array. If all transformation calls returned the type instance itself (i.e. no
387
- # transformation took place), then this method will return `self`. If a transformation did occur, then this method
388
- # will either return the transformed array or in case a block was given, the result of calling a given block with
389
- # the transformed array.
390
- #
391
- # @param types [Array<PAnyType>] the array of types to transform
392
- # @param method [Symbol] The method to call on each type
393
- # @param method_args [Object] The arguments to pass to the method, if any
394
- # @return [Object] self, the transformed array, or the result of calling a given block with the transformed array
395
- # @yieldparam altered_types [Array<PAnyType>] the altered type array
396
- # @api private
397
- def alter_type_array(types, method, *method_args)
398
- modified = false
399
- modified_types = types.map do |t|
400
- t_mod = t.send(method, *method_args)
401
- modified = !t.equal?(t_mod) unless modified
402
- t_mod
403
- end
404
- if modified
405
- block_given? ? yield(modified_types) : modified_types
406
- else
407
- self
408
- end
409
- end
410
- end
411
-
412
- # @abstract Encapsulates common behavior for a type that contains one type
413
- # @api public
414
- class PTypeWithContainedType < PAnyType
415
- def self.register_ptype(loader, ir)
416
- # Abstract type. It doesn't register anything
417
- end
418
-
419
- attr_reader :type
420
-
421
- def initialize(type)
422
- @type = type
423
- end
424
-
425
- def accept(visitor, guard)
426
- super
427
- @type.accept(visitor, guard) unless @type.nil?
428
- end
429
-
430
- def generalize
431
- if @type.nil?
432
- self.class::DEFAULT
433
- else
434
- ge_type = @type.generalize
435
- @type.equal?(ge_type) ? self : self.class.new(ge_type)
436
- end
437
- end
438
-
439
- def normalize(guard = nil)
440
- if @type.nil?
441
- self.class::DEFAULT
442
- else
443
- ne_type = @type.normalize(guard)
444
- @type.equal?(ne_type) ? self : self.class.new(ne_type)
445
- end
446
- end
447
-
448
- def hash
449
- self.class.hash ^ @type.hash
450
- end
451
-
452
- def eql?(o)
453
- self.class == o.class && @type == o.type
454
- end
455
-
456
- def resolve(loader)
457
- rtype = @type
458
- rtype = rtype.resolve(loader) unless rtype.nil?
459
- rtype.equal?(@type) ? self : self.class.new(rtype)
460
- end
461
- end
462
-
463
- # The type of types.
464
- # @api public
465
- #
466
- class PTypeType < PTypeWithContainedType
467
-
468
- def self.register_ptype(loader, ir)
469
- create_ptype(loader, ir, 'AnyType',
470
- 'type' => {
471
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
472
- KEY_VALUE => nil
473
- }
474
- )
475
- end
476
-
477
- # Returns a new function that produces a Type instance
478
- #
479
- def self.new_function(type)
480
- @new_function ||= Puppet::Functions.create_loaded_function(:new_type, type.loader) do
481
- dispatch :from_string do
482
- param 'String[1]', :type_string
483
- end
484
-
485
- def from_string(type_string)
486
- TypeParser.singleton.parse(type_string, loader)
487
- end
488
- end
489
- end
490
-
491
- def instance?(o, guard = nil)
492
- if o.is_a?(PAnyType)
493
- type.nil? || type.assignable?(o, guard)
494
- elsif o.is_a?(Module) || o.is_a?(Puppet::Resource) || o.is_a?(Puppet::Parser::Resource)
495
- @type.nil? ? true : assignable?(TypeCalculator.infer(o))
496
- else
497
- false
498
- end
499
- end
500
-
501
- def iterable?(guard = nil)
502
- case @type
503
- when PEnumType
504
- true
505
- when PIntegerType
506
- @type.finite_range?
507
- else
508
- false
509
- end
510
- end
511
-
512
- def iterable_type(guard = nil)
513
- # The types PIntegerType and PEnumType are Iterable
514
- case @type
515
- when PEnumType
516
- # @type describes the element type perfectly since the iteration is made over the
517
- # contained choices.
518
- PIterableType.new(@type)
519
- when PIntegerType
520
- # @type describes the element type perfectly since the iteration is made over the
521
- # specified range.
522
- @type.finite_range? ? PIterableType.new(@type) : nil
523
- else
524
- nil
525
- end
526
- end
527
-
528
- def eql?(o)
529
- self.class == o.class && @type == o.type
530
- end
531
-
532
- DEFAULT = PTypeType.new(nil)
533
-
534
- protected
535
-
536
- # @api private
537
- def _assignable?(o, guard)
538
- return false unless o.is_a?(PTypeType)
539
- return true if @type.nil? # wide enough to handle all types
540
- return false if o.type.nil? # wider than t
541
- @type.assignable?(o.type, guard)
542
- end
543
- end
544
-
545
- # For backward compatibility
546
- PType = PTypeType
547
-
548
- class PNotUndefType < PTypeWithContainedType
549
- def self.register_ptype(loader, ir)
550
- create_ptype(loader, ir, 'AnyType',
551
- 'type' => {
552
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
553
- KEY_VALUE => nil
554
- }
555
- )
556
- end
557
-
558
- def initialize(type = nil)
559
- super(type.class == PAnyType ? nil : type)
560
- end
561
-
562
- def instance?(o, guard = nil)
563
- !(o.nil? || o == :undef) && (@type.nil? || @type.instance?(o, guard))
564
- end
565
-
566
- def normalize(guard = nil)
567
- n = super
568
- if n.type.nil?
569
- n
570
- else
571
- if n.type.is_a?(POptionalType)
572
- # No point in having an optional in a NotUndef
573
- PNotUndefType.new(n.type.type).normalize
574
- elsif !n.type.assignable?(PUndefType::DEFAULT)
575
- # THe type is NotUndef anyway, so it can be stripped of
576
- n.type
577
- else
578
- n
579
- end
580
- end
581
- end
582
-
583
- def new_function
584
- # If only NotUndef, then use Unit's null converter
585
- if type.nil?
586
- PUnitType.new_function(self)
587
- else
588
- type.new_function
589
- end
590
- end
591
-
592
- DEFAULT = PNotUndefType.new
593
-
594
- protected
595
-
596
- # @api private
597
- def _assignable?(o, guard)
598
- o.is_a?(PAnyType) && !o.assignable?(PUndefType::DEFAULT, guard) && (@type.nil? || @type.assignable?(o, guard))
599
- end
600
- end
601
-
602
- # @api public
603
- #
604
- class PUndefType < PAnyType
605
- def self.register_ptype(loader, ir)
606
- create_ptype(loader, ir, 'AnyType')
607
- end
608
-
609
- def instance?(o, guard = nil)
610
- o.nil? || :undef == o
611
- end
612
-
613
- # @api private
614
- def callable_args?(callable_t, guard)
615
- # if callable_t is Optional (or indeed PUndefType), this means that 'missing callable' is accepted
616
- callable_t.assignable?(DEFAULT, guard)
617
- end
618
-
619
- DEFAULT = PUndefType.new
620
-
621
- protected
622
- # @api private
623
- def _assignable?(o, guard)
624
- o.is_a?(PUndefType)
625
- end
626
- end
627
-
628
- # A type private to the type system that describes "ignored type" - i.e. "I am what you are"
629
- # @api private
630
- #
631
- class PUnitType < PAnyType
632
- def self.register_ptype(loader, ir)
633
- create_ptype(loader, ir, 'AnyType')
634
- end
635
-
636
- def instance?(o, guard = nil)
637
- true
638
- end
639
-
640
- # A "null" implementation - that simply returns the given argument
641
- def self.new_function(type)
642
- @new_function ||= Puppet::Functions.create_loaded_function(:new_unit, type.loader) do
643
- dispatch :from_args do
644
- param 'Any', :from
645
- end
646
-
647
- def from_args(from)
648
- from
649
- end
650
- end
651
- end
652
-
653
- DEFAULT = PUnitType.new
654
-
655
- def assignable?(o, guard=nil)
656
- true
657
- end
658
-
659
- protected
660
-
661
- # @api private
662
- def _assignable?(o, guard)
663
- true
664
- end
665
- end
666
-
667
- # @api public
668
- #
669
- class PDefaultType < PAnyType
670
- def self.register_ptype(loader, ir)
671
- create_ptype(loader, ir, 'AnyType')
672
- end
673
-
674
- def instance?(o, guard = nil)
675
- # Ensure that Symbol.== is called here instead of something unknown
676
- # that is implemented on o
677
- :default == o
678
- end
679
-
680
- DEFAULT = PDefaultType.new
681
-
682
- protected
683
- # @api private
684
- def _assignable?(o, guard)
685
- o.is_a?(PDefaultType)
686
- end
687
- end
688
-
689
- # Type that is a Scalar
690
- # @api public
691
- #
692
- class PScalarType < PAnyType
693
- def self.register_ptype(loader, ir)
694
- create_ptype(loader, ir, 'AnyType')
695
- end
696
-
697
- def instance?(o, guard = nil)
698
- if o.is_a?(String) || o.is_a?(Numeric) || o.is_a?(TrueClass) || o.is_a?(FalseClass) || o.is_a?(Regexp)
699
- true
700
- elsif o.instance_of?(Array) || o.instance_of?(Hash) || o.is_a?(PAnyType) || o.is_a?(NilClass)
701
- false
702
- else
703
- assignable?(TypeCalculator.infer(o))
704
- end
705
- end
706
-
707
- def roundtrip_with_string?
708
- true
709
- end
710
-
711
- DEFAULT = PScalarType.new
712
-
713
- protected
714
-
715
- # @api private
716
- def _assignable?(o, guard)
717
- o.is_a?(PScalarType) ||
718
- PStringType::DEFAULT.assignable?(o, guard) ||
719
- PIntegerType::DEFAULT.assignable?(o, guard) ||
720
- PFloatType::DEFAULT.assignable?(o, guard) ||
721
- PBooleanType::DEFAULT.assignable?(o, guard) ||
722
- PRegexpType::DEFAULT.assignable?(o, guard) ||
723
- PSemVerType::DEFAULT.assignable?(o, guard) ||
724
- PSemVerRangeType::DEFAULT.assignable?(o, guard) ||
725
- PTimespanType::DEFAULT.assignable?(o, guard) ||
726
- PTimestampType::DEFAULT.assignable?(o, guard)
727
- end
728
- end
729
-
730
- # Like Scalar but limited to Json Data.
731
- # @api public
732
- #
733
- class PScalarDataType < PScalarType
734
- def self.register_ptype(loader, ir)
735
- create_ptype(loader, ir, 'ScalarType')
736
- end
737
-
738
- def instance?(o, guard = nil)
739
- return o.is_a?(String) || o.is_a?(Integer) || o.is_a?(Float) || o.is_a?(TrueClass) || o.is_a?(FalseClass)
740
- end
741
-
742
- DEFAULT = PScalarDataType.new
743
-
744
- protected
745
-
746
- # @api private
747
- def _assignable?(o, guard)
748
- o.is_a?(PScalarDataType) ||
749
- PStringType::DEFAULT.assignable?(o, guard) ||
750
- PIntegerType::DEFAULT.assignable?(o, guard) ||
751
- PFloatType::DEFAULT.assignable?(o, guard) ||
752
- PBooleanType::DEFAULT.assignable?(o, guard)
753
- end
754
- end
755
-
756
- # A string type describing the set of strings having one of the given values
757
- # @api public
758
- #
759
- class PEnumType < PScalarDataType
760
- def self.register_ptype(loader, ir)
761
- create_ptype(loader, ir, 'ScalarDataType',
762
- 'values' => PArrayType.new(PStringType::NON_EMPTY),
763
- 'case_insensitive' => { 'type' => PBooleanType::DEFAULT, 'value' => false })
764
- end
765
-
766
- attr_reader :values, :case_insensitive
767
-
768
- def initialize(values, case_insensitive = false)
769
- @values = values.uniq.sort.freeze
770
- @case_insensitive = case_insensitive
771
- end
772
-
773
- def case_insensitive?
774
- @case_insensitive
775
- end
776
-
777
- # Returns Enumerator if no block is given, otherwise, calls the given
778
- # block with each of the strings for this enum
779
- def each(&block)
780
- r = Iterable.on(self)
781
- block_given? ? r.each(&block) : r
782
- end
783
-
784
- def generalize
785
- # General form of an Enum is a String
786
- if @values.empty?
787
- PStringType::DEFAULT
788
- else
789
- range = @values.map(&:size).minmax
790
- PStringType.new(PIntegerType.new(range.min, range.max))
791
- end
792
- end
793
-
794
- def iterable?(guard = nil)
795
- true
796
- end
797
-
798
- def iterable_type(guard = nil)
799
- # An instance of an Enum is a String
800
- PStringType::ITERABLE_TYPE
801
- end
802
-
803
- def hash
804
- @values.hash ^ @case_insensitive.hash
805
- end
806
-
807
- def eql?(o)
808
- self.class == o.class && @values == o.values && @case_insensitive == o.case_insensitive?
809
- end
810
-
811
- def instance?(o, guard = nil)
812
- if o.is_a?(String)
813
- @case_insensitive ? @values.any? { |p| p.casecmp(o) == 0 } : @values.any? { |p| p == o }
814
- else
815
- false
816
- end
817
- end
818
-
819
- DEFAULT = PEnumType.new(EMPTY_ARRAY)
820
-
821
- protected
822
-
823
- # @api private
824
- def _assignable?(o, guard)
825
- return true if self == o
826
- svalues = values
827
- if svalues.empty?
828
- return true if o.is_a?(PStringType) || o.is_a?(PEnumType) || o.is_a?(PPatternType)
829
- end
830
- case o
831
- when PStringType
832
- # if the contained string is found in the set of enums
833
- instance?(o.value, guard)
834
- when PEnumType
835
- !o.values.empty? && (case_insensitive? || !o.case_insensitive?) && o.values.all? { |s| instance?(s, guard) }
836
- else
837
- false
838
- end
839
- end
840
- end
841
-
842
- INTEGER_HEX = '(?:0[xX][0-9A-Fa-f]+)'
843
- INTEGER_OCT = '(?:0[0-7]+)'
844
- INTEGER_BIN = '(?:0[bB][01]+)'
845
- INTEGER_DEC = '(?:0|[1-9]\d*)'
846
- SIGN_PREFIX = '[+-]?\s*'
847
-
848
- OPTIONAL_FRACTION = '(?:\.\d+)?'
849
- OPTIONAL_EXPONENT = '(?:[eE]-?\d+)?'
850
- FLOAT_DEC = '(?:' + INTEGER_DEC + OPTIONAL_FRACTION + OPTIONAL_EXPONENT + ')'
851
-
852
- INTEGER_PATTERN = '\A' + SIGN_PREFIX + '(?:' + INTEGER_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
853
- FLOAT_PATTERN = '\A' + SIGN_PREFIX + '(?:' + FLOAT_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
854
-
855
- # @api public
856
- #
857
- class PNumericType < PScalarDataType
858
- def self.register_ptype(loader, ir)
859
- create_ptype(loader, ir, 'ScalarDataType',
860
- 'from' => { KEY_TYPE => POptionalType.new(PNumericType::DEFAULT), KEY_VALUE => nil },
861
- 'to' => { KEY_TYPE => POptionalType.new(PNumericType::DEFAULT), KEY_VALUE => nil }
862
- )
863
- end
864
-
865
- def self.new_function(type)
866
- @new_function ||= Puppet::Functions.create_loaded_function(:new_numeric, type.loader) do
867
- local_types do
868
- type "Convertible = Variant[Integer, Float, Boolean, Pattern[/#{FLOAT_PATTERN}/], Timespan, Timestamp]"
869
- type 'NamedArgs = Struct[{from => Convertible, Optional[abs] => Boolean}]'
870
- end
871
-
872
- dispatch :from_args do
873
- param 'Convertible', :from
874
- optional_param 'Boolean', :abs
875
- end
876
-
877
- dispatch :from_hash do
878
- param 'NamedArgs', :hash_args
879
- end
880
-
881
- argument_mismatch :on_error do
882
- param 'Any', :from
883
- optional_param 'Boolean', :abs
884
- end
885
-
886
- def from_args(from, abs = false)
887
- result = from_convertible(from)
888
- abs ? result.abs : result
889
- end
890
-
891
- def from_hash(args_hash)
892
- from_args(args_hash['from'], args_hash['abs'] || false)
893
- end
894
-
895
- def from_convertible(from)
896
- case from
897
- when Float
898
- from
899
- when Integer
900
- from
901
- when Time::TimeData
902
- from.to_f
903
- when TrueClass
904
- 1
905
- when FalseClass
906
- 0
907
- else
908
- begin
909
- if from[0] == '0'
910
- second_char = (from[1] || '').downcase
911
- if second_char == 'b' || second_char == 'x'
912
- # use built in conversion
913
- return Integer(from)
914
- end
915
- end
916
-
917
- Puppet::Pops::Utils.to_n(from)
918
- rescue TypeError => e
919
- raise TypeConversionError.new(e.message)
920
- rescue ArgumentError => e
921
- raise TypeConversionError.new(e.message)
922
- end
923
- end
924
- end
925
-
926
- def on_error(from, abs = false)
927
- if from.is_a?(String)
928
- _("The string '%{str}' cannot be converted to Numeric") % { str: from }
929
- else
930
- t = TypeCalculator.singleton.infer(from).generalize
931
- _("Value of type %{type} cannot be converted to Numeric") % { type: t }
932
- end
933
- end
934
- end
935
- end
936
-
937
- def initialize(from, to = Float::INFINITY)
938
- from = -Float::INFINITY if from.nil? || from == :default
939
- to = Float::INFINITY if to.nil? || to == :default
940
- raise ArgumentError, "'from' must be less or equal to 'to'. Got (#{from}, #{to}" if from > to
941
- @from = from
942
- @to = to
943
- end
944
-
945
- # Checks if this numeric range intersects with another
946
- #
947
- # @param o [PNumericType] the range to compare with
948
- # @return [Boolean] `true` if this range intersects with the other range
949
- # @api public
950
- def intersect?(o)
951
- self.class == o.class && !(@to < o.numeric_from || o.numeric_to < @from)
952
- end
953
-
954
- # Returns the lower bound of the numeric range or `nil` if no lower bound is set.
955
- # @return [Float,Integer]
956
- def from
957
- @from == -Float::INFINITY ? nil : @from
958
- end
959
-
960
- # Returns the upper bound of the numeric range or `nil` if no upper bound is set.
961
- # @return [Float,Integer]
962
- def to
963
- @to == Float::INFINITY ? nil : @to
964
- end
965
-
966
- # Same as #from but will return `-Float::Infinity` instead of `nil` if no lower bound is set.
967
- # @return [Float,Integer]
968
- def numeric_from
969
- @from
970
- end
971
-
972
- # Same as #to but will return `Float::Infinity` instead of `nil` if no lower bound is set.
973
- # @return [Float,Integer]
974
- def numeric_to
975
- @to
976
- end
977
-
978
- def hash
979
- @from.hash ^ @to.hash
980
- end
981
-
982
- def eql?(o)
983
- self.class == o.class && @from == o.numeric_from && @to == o.numeric_to
984
- end
985
-
986
- def instance?(o, guard = nil)
987
- (o.is_a?(Float) || o.is_a?(Integer)) && o >= @from && o <= @to
988
- end
989
-
990
- def unbounded?
991
- @from == -Float::INFINITY && @to == Float::INFINITY
992
- end
993
-
994
- protected
995
-
996
- # @api_private
997
- def _assignable?(o, guard)
998
- return false unless o.is_a?(self.class)
999
- # If o min and max are within the range of t
1000
- @from <= o.numeric_from && @to >= o.numeric_to
1001
- end
1002
-
1003
- DEFAULT = PNumericType.new(-Float::INFINITY)
1004
- end
1005
-
1006
- # @api public
1007
- #
1008
- class PIntegerType < PNumericType
1009
- def self.register_ptype(loader, ir)
1010
- create_ptype(loader, ir, 'NumericType')
1011
- end
1012
-
1013
- # Will respond `true` for any range that is bounded at both ends.
1014
- #
1015
- # @return [Boolean] `true` if the type describes a finite range.
1016
- def finite_range?
1017
- @from != -Float::INFINITY && @to != Float::INFINITY
1018
- end
1019
-
1020
- def generalize
1021
- DEFAULT
1022
- end
1023
-
1024
- def instance?(o, guard = nil)
1025
- o.is_a?(Integer) && o >= numeric_from && o <= numeric_to
1026
- end
1027
-
1028
- # Checks if this range is adjacent to the given range
1029
- #
1030
- # @param o [PIntegerType] the range to compare with
1031
- # @return [Boolean] `true` if this range is adjacent to the other range
1032
- # @api public
1033
- def adjacent?(o)
1034
- o.is_a?(PIntegerType) && (@to + 1 == o.from || o.to + 1 == @from)
1035
- end
1036
-
1037
- # Concatenates this range with another range provided that the ranges intersect or
1038
- # are adjacent. When that's not the case, this method will return `nil`
1039
- #
1040
- # @param o [PIntegerType] the range to concatenate with this range
1041
- # @return [PIntegerType,nil] the concatenated range or `nil` when the ranges were apart
1042
- # @api public
1043
- def merge(o)
1044
- if intersect?(o) || adjacent?(o)
1045
- min = @from <= o.numeric_from ? @from : o.numeric_from
1046
- max = @to >= o.numeric_to ? @to : o.numeric_to
1047
- PIntegerType.new(min, max)
1048
- else
1049
- nil
1050
- end
1051
- end
1052
-
1053
- def iterable?(guard = nil)
1054
- true
1055
- end
1056
-
1057
- def iterable_type(guard = nil)
1058
- # It's unknown if the iterable will be a range (min, max) or a "times" (0, max)
1059
- PIterableType.new(PIntegerType::DEFAULT)
1060
- end
1061
-
1062
- # Returns Float.Infinity if one end of the range is unbound
1063
- def size
1064
- return Float::INFINITY if @from == -Float::INFINITY || @to == Float::INFINITY
1065
- 1+(to-from).abs
1066
- end
1067
-
1068
- # Returns the range as an array ordered so the smaller number is always first.
1069
- # The number may be Infinity or -Infinity.
1070
- def range
1071
- [@from, @to]
1072
- end
1073
-
1074
- # Returns Enumerator if no block is given
1075
- # Returns nil if size is infinity (does not yield)
1076
- def each(&block)
1077
- r = Iterable.on(self)
1078
- block_given? ? r.each(&block) : r
1079
- end
1080
-
1081
- # Returns a range where both to and from are positive numbers. Negative
1082
- # numbers are converted to zero
1083
- # @return [PIntegerType] a positive range
1084
- def to_size
1085
- @from >= 0 ? self : PIntegerType.new(0, @to < 0 ? 0 : @to)
1086
- end
1087
-
1088
- def new_function
1089
- @@new_function ||= Puppet::Functions.create_loaded_function(:new, loader) do
1090
- local_types do
1091
- type 'Radix = Variant[Default, Integer[2,2], Integer[8,8], Integer[10,10], Integer[16,16]]'
1092
- type "Convertible = Variant[Numeric, Boolean, Pattern[/#{INTEGER_PATTERN}/], Timespan, Timestamp]"
1093
- type 'NamedArgs = Struct[{from => Convertible, Optional[radix] => Radix, Optional[abs] => Boolean}]'
1094
- end
1095
-
1096
- dispatch :from_args do
1097
- param 'Convertible', :from
1098
- optional_param 'Radix', :radix
1099
- optional_param 'Boolean', :abs
1100
- end
1101
-
1102
- dispatch :from_hash do
1103
- param 'NamedArgs', :hash_args
1104
- end
1105
-
1106
- argument_mismatch :on_error_hash do
1107
- param 'Hash', :hash_args
1108
- end
1109
-
1110
- argument_mismatch :on_error do
1111
- param 'Any', :from
1112
- optional_param 'Integer', :radix
1113
- optional_param 'Boolean', :abs
1114
- end
1115
-
1116
- def from_args(from, radix = :default, abs = false)
1117
- result = from_convertible(from, radix)
1118
- abs ? result.abs : result
1119
- end
1120
-
1121
- def from_hash(args_hash)
1122
- from_args(args_hash['from'], args_hash['radix'] || :default, args_hash['abs'] || false)
1123
- end
1124
-
1125
- def from_convertible(from, radix)
1126
- case from
1127
- when Float, Time::TimeData
1128
- from.to_i
1129
- when Integer
1130
- from
1131
- when TrueClass
1132
- 1
1133
- when FalseClass
1134
- 0
1135
- else
1136
- begin
1137
- radix == :default ? Integer(from) : Integer(from, radix)
1138
- rescue TypeError => e
1139
- raise TypeConversionError.new(e.message)
1140
- rescue ArgumentError => e
1141
- # Test for special case where there is whitespace between sign and number
1142
- match = Patterns::WS_BETWEEN_SIGN_AND_NUMBER.match(from)
1143
- if match
1144
- begin
1145
- # Try again, this time with whitespace removed
1146
- return from_args(match[1] + match[2], radix)
1147
- rescue TypeConversionError
1148
- # Ignored to retain original error
1149
- end
1150
- end
1151
- raise TypeConversionError.new(e.message)
1152
- end
1153
- end
1154
- end
1155
-
1156
- def on_error_hash(args_hash)
1157
- if args_hash.include?('from')
1158
- from = args_hash['from']
1159
- return on_error(from) unless loader.load(:type, 'convertible').instance?(from)
1160
- end
1161
- radix = args_hash['radix']
1162
- assert_radix(radix) unless radix.nil? || radix == :default
1163
- TypeAsserter.assert_instance_of('Integer.new', loader.load(:type, 'namedargs'), args_hash)
1164
- end
1165
-
1166
- def on_error(from, radix = :default, abs = nil)
1167
- assert_radix(radix) unless radix == :default
1168
- if from.is_a?(String)
1169
- _("The string '%{str}' cannot be converted to Integer") % { str: from }
1170
- else
1171
- t = TypeCalculator.singleton.infer(from).generalize
1172
- _("Value of type %{type} cannot be converted to Integer") % { type: t }
1173
- end
1174
- end
1175
-
1176
- def assert_radix(radix)
1177
- case radix
1178
- when 2, 8, 10, 16
1179
- else
1180
- raise ArgumentError.new(_("Illegal radix: %{radix}, expected 2, 8, 10, 16, or default") % { radix: radix })
1181
- end
1182
- radix
1183
- end
1184
-
1185
- end
1186
- end
1187
-
1188
- DEFAULT = PIntegerType.new(-Float::INFINITY)
1189
- end
1190
-
1191
- # @api public
1192
- #
1193
- class PFloatType < PNumericType
1194
- def self.register_ptype(loader, ir)
1195
- create_ptype(loader, ir, 'NumericType')
1196
- end
1197
-
1198
- def generalize
1199
- DEFAULT
1200
- end
1201
-
1202
- def instance?(o, guard = nil)
1203
- o.is_a?(Float) && o >= numeric_from && o <= numeric_to
1204
- end
1205
-
1206
- # Concatenates this range with another range provided that the ranges intersect. When that's not the case, this
1207
- # method will return `nil`
1208
- #
1209
- # @param o [PFloatType] the range to concatenate with this range
1210
- # @return [PFloatType,nil] the concatenated range or `nil` when the ranges were apart
1211
- # @api public
1212
- def merge(o)
1213
- if intersect?(o)
1214
- min = @from <= o.from ? @from : o.from
1215
- max = @to >= o.to ? @to : o.to
1216
- PFloatType.new(min, max)
1217
- else
1218
- nil
1219
- end
1220
- end
1221
-
1222
- # Returns a new function that produces a Float value
1223
- #
1224
- def self.new_function(type)
1225
- @new_function ||= Puppet::Functions.create_loaded_function(:new_float, type.loader) do
1226
- local_types do
1227
- type "Convertible = Variant[Numeric, Boolean, Pattern[/#{FLOAT_PATTERN}/], Timespan, Timestamp]"
1228
- type 'NamedArgs = Struct[{from => Convertible, Optional[abs] => Boolean}]'
1229
- end
1230
-
1231
- dispatch :from_args do
1232
- param 'Convertible', :from
1233
- optional_param 'Boolean', :abs
1234
- end
1235
-
1236
- dispatch :from_hash do
1237
- param 'NamedArgs', :hash_args
1238
- end
1239
-
1240
- argument_mismatch :on_error do
1241
- param 'Any', :from
1242
- optional_param 'Boolean', :abs
1243
- end
1244
-
1245
- def from_args(from, abs = false)
1246
- result = from_convertible(from)
1247
- abs ? result.abs : result
1248
- end
1249
-
1250
- def from_hash(args_hash)
1251
- from_args(args_hash['from'], args_hash['abs'] || false)
1252
- end
1253
-
1254
- def from_convertible(from)
1255
- case from
1256
- when Float
1257
- from
1258
- when Integer
1259
- Float(from)
1260
- when Time::TimeData
1261
- from.to_f
1262
- when TrueClass
1263
- 1.0
1264
- when FalseClass
1265
- 0.0
1266
- else
1267
- begin
1268
- # support a binary as float
1269
- if from[0] == '0' && from[1].downcase == 'b'
1270
- from = Integer(from)
1271
- end
1272
- Float(from)
1273
- rescue TypeError => e
1274
- raise TypeConversionError.new(e.message)
1275
- rescue ArgumentError => e
1276
- # Test for special case where there is whitespace between sign and number
1277
- match = Patterns::WS_BETWEEN_SIGN_AND_NUMBER.match(from)
1278
- if match
1279
- begin
1280
- # Try again, this time with whitespace removed
1281
- return from_args(match[1] + match[2])
1282
- rescue TypeConversionError
1283
- # Ignored to retain original error
1284
- end
1285
- end
1286
- raise TypeConversionError.new(e.message)
1287
- end
1288
- end
1289
- end
1290
-
1291
- def on_error(from, _ = false)
1292
- if from.is_a?(String)
1293
- _("The string '%{str}' cannot be converted to Float") % { str: from }
1294
- else
1295
- t = TypeCalculator.singleton.infer(from).generalize
1296
- _("Value of type %{type} cannot be converted to Float") % { type: t }
1297
- end
1298
- end
1299
- end
1300
- end
1301
-
1302
- DEFAULT = PFloatType.new(-Float::INFINITY)
1303
- end
1304
-
1305
- # @api public
1306
- #
1307
- class PCollectionType < PAnyType
1308
- def self.register_ptype(loader, ir)
1309
- create_ptype(loader, ir, 'AnyType',
1310
- 'size_type' => {
1311
- KEY_TYPE => POptionalType.new(PTypeType.new(PIntegerType::DEFAULT)),
1312
- KEY_VALUE => nil
1313
- }
1314
- )
1315
- end
1316
-
1317
- attr_reader :size_type
1318
-
1319
- def initialize(size_type)
1320
- @size_type = size_type.nil? ? nil : size_type.to_size
1321
- end
1322
-
1323
- def accept(visitor, guard)
1324
- super
1325
- @size_type.accept(visitor, guard) unless @size_type.nil?
1326
- end
1327
-
1328
- def generalize
1329
- DEFAULT
1330
- end
1331
-
1332
- def normalize(guard = nil)
1333
- DEFAULT
1334
- end
1335
-
1336
- def instance?(o, guard = nil)
1337
- # The inferred type of a class derived from Array or Hash is either Runtime or Object. It's not assignable to the Collection type.
1338
- if o.instance_of?(Array) || o.instance_of?(Hash)
1339
- @size_type.nil? || @size_type.instance?(o.size)
1340
- else
1341
- false
1342
- end
1343
- end
1344
-
1345
- # Returns an array with from (min) size to (max) size
1346
- def size_range
1347
- (@size_type || DEFAULT_SIZE).range
1348
- end
1349
-
1350
- def has_empty_range?
1351
- from, to = size_range
1352
- from == 0 && to == 0
1353
- end
1354
-
1355
- def hash
1356
- @size_type.hash
1357
- end
1358
-
1359
- def iterable?(guard = nil)
1360
- true
1361
- end
1362
-
1363
- def eql?(o)
1364
- self.class == o.class && @size_type == o.size_type
1365
- end
1366
-
1367
-
1368
- DEFAULT_SIZE = PIntegerType.new(0)
1369
- ZERO_SIZE = PIntegerType.new(0, 0)
1370
- NOT_EMPTY_SIZE = PIntegerType.new(1)
1371
- DEFAULT = PCollectionType.new(nil)
1372
-
1373
- protected
1374
-
1375
- # @api private
1376
- #
1377
- def _assignable?(o, guard)
1378
- case o
1379
- when PCollectionType
1380
- (@size_type || DEFAULT_SIZE).assignable?(o.size_type || DEFAULT_SIZE, guard)
1381
- when PTupleType
1382
- # compute the tuple's min/max size, and check if that size matches
1383
- size_s = size_type || DEFAULT_SIZE
1384
- size_o = o.size_type
1385
- if size_o.nil?
1386
- type_count = o.types.size
1387
- size_o = PIntegerType.new(type_count, type_count)
1388
- end
1389
- size_s.assignable?(size_o)
1390
- when PStructType
1391
- from = to = o.elements.size
1392
- (@size_type || DEFAULT_SIZE).assignable?(PIntegerType.new(from, to), guard)
1393
- else
1394
- false
1395
- end
1396
- end
1397
- end
1398
-
1399
- class PIterableType < PTypeWithContainedType
1400
- def self.register_ptype(loader, ir)
1401
- create_ptype(loader, ir, 'AnyType',
1402
- 'type' => {
1403
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
1404
- KEY_VALUE => nil
1405
- }
1406
- )
1407
- end
1408
-
1409
- def element_type
1410
- @type
1411
- end
1412
-
1413
- def instance?(o, guard = nil)
1414
- if @type.nil? || @type.assignable?(PAnyType::DEFAULT, guard)
1415
- # Any element_type will do
1416
- case o
1417
- when Iterable, String, Hash, Array, Range, PEnumType
1418
- true
1419
- when Integer
1420
- o >= 0
1421
- when PIntegerType
1422
- o.finite_range?
1423
- when PTypeAliasType
1424
- instance?(o.resolved_type, guard)
1425
- else
1426
- false
1427
- end
1428
- else
1429
- assignable?(TypeCalculator.infer(o), guard)
1430
- end
1431
- end
1432
-
1433
- def iterable?(guard = nil)
1434
- true
1435
- end
1436
-
1437
- def iterable_type(guard = nil)
1438
- self
1439
- end
1440
-
1441
- DEFAULT = PIterableType.new(nil)
1442
-
1443
- protected
1444
-
1445
- # @api private
1446
- def _assignable?(o, guard)
1447
- if @type.nil? || @type.assignable?(PAnyType::DEFAULT, guard)
1448
- # Don't request the iterable_type. Since this Iterable accepts Any element, it is enough that o is iterable.
1449
- o.iterable?
1450
- else
1451
- o = o.iterable_type
1452
- o.nil? || o.element_type.nil? ? false : @type.assignable?(o.element_type, guard)
1453
- end
1454
- end
1455
- end
1456
-
1457
- # @api public
1458
- #
1459
- class PIteratorType < PTypeWithContainedType
1460
- def self.register_ptype(loader, ir)
1461
- create_ptype(loader, ir, 'AnyType',
1462
- 'type' => {
1463
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
1464
- KEY_VALUE => nil
1465
- }
1466
- )
1467
- end
1468
-
1469
- def element_type
1470
- @type
1471
- end
1472
-
1473
- def instance?(o, guard = nil)
1474
- o.is_a?(Iterable) && (@type.nil? || @type.assignable?(o.element_type, guard))
1475
- end
1476
-
1477
- def iterable?(guard = nil)
1478
- true
1479
- end
1480
-
1481
- def iterable_type(guard = nil)
1482
- @type.nil? ? PIterableType::DEFAULT : PIterableType.new(@type)
1483
- end
1484
-
1485
- DEFAULT = PIteratorType.new(nil)
1486
-
1487
- protected
1488
-
1489
- # @api private
1490
- def _assignable?(o, guard)
1491
- o.is_a?(PIteratorType) && (@type.nil? || @type.assignable?(o.element_type, guard))
1492
- end
1493
- end
1494
-
1495
- # @api public
1496
- #
1497
- class PStringType < PScalarDataType
1498
- def self.register_ptype(loader, ir)
1499
- create_ptype(loader, ir, 'ScalarDataType',
1500
- 'size_type_or_value' => {
1501
- KEY_TYPE => POptionalType.new(PVariantType.new([PStringType::DEFAULT, PTypeType.new(PIntegerType::DEFAULT)])),
1502
- KEY_VALUE => nil
1503
- })
1504
- end
1505
-
1506
- attr_reader :size_type_or_value
1507
-
1508
- def initialize(size_type_or_value, deprecated_multi_args = EMPTY_ARRAY)
1509
- unless deprecated_multi_args.empty?
1510
- if Puppet[:strict] != :off
1511
- #TRANSLATORS 'PStringType#initialize' is a class and method name and should not be translated
1512
- Puppet.warn_once('deprecations', "PStringType#initialize_multi_args",
1513
- _("Passing more than one argument to PStringType#initialize is deprecated"))
1514
- end
1515
- size_type_or_value = deprecated_multi_args[0]
1516
- end
1517
- @size_type_or_value = size_type_or_value.is_a?(PIntegerType) ? size_type_or_value.to_size : size_type_or_value
1518
- end
1519
-
1520
- def accept(visitor, guard)
1521
- super
1522
- @size_type_or_value.accept(visitor, guard) if @size_type_or_value.is_a?(PIntegerType)
1523
- end
1524
-
1525
- def generalize
1526
- DEFAULT
1527
- end
1528
-
1529
- def hash
1530
- @size_type_or_value.hash
1531
- end
1532
-
1533
- def iterable?(guard = nil)
1534
- true
1535
- end
1536
-
1537
- def iterable_type(guard = nil)
1538
- ITERABLE_TYPE
1539
- end
1540
-
1541
- def eql?(o)
1542
- self.class == o.class && @size_type_or_value == o.size_type_or_value
1543
- end
1544
-
1545
- def instance?(o, guard = nil)
1546
- # true if size compliant
1547
- if o.is_a?(String)
1548
- if @size_type_or_value.is_a?(PIntegerType)
1549
- @size_type_or_value.instance?(o.size, guard)
1550
- else
1551
- @size_type_or_value.nil? ? true : o == value
1552
- end
1553
- else
1554
- false
1555
- end
1556
- end
1557
-
1558
- def value
1559
- @size_type_or_value.is_a?(PIntegerType) ? nil : @size_type_or_value
1560
- end
1561
-
1562
- # @deprecated
1563
- # @api private
1564
- def values
1565
- if Puppet[:strict] != :off
1566
- #TRANSLATORS 'PStringType#values' and '#value' are classes and method names and should not be translated
1567
- Puppet.warn_once('deprecations', "PStringType#values", _("Method PStringType#values is deprecated. Use #value instead"))
1568
- end
1569
- @value.is_a?(String) ? [@value] : EMPTY_ARRAY
1570
- end
1571
-
1572
- def size_type
1573
- @size_type_or_value.is_a?(PIntegerType) ? @size_type_or_value : nil
1574
- end
1575
-
1576
- def derived_size_type
1577
- if @size_type_or_value.is_a?(PIntegerType)
1578
- @size_type_or_value
1579
- elsif @size_type_or_value.is_a?(String)
1580
- sz = @size_type_or_value.size
1581
- PIntegerType.new(sz, sz)
1582
- else
1583
- PCollectionType::DEFAULT_SIZE
1584
- end
1585
- end
1586
-
1587
- def self.new_function(type)
1588
- @new_function ||= Puppet::Functions.create_loaded_function(:new_string, type.loader) do
1589
- local_types do
1590
- type "Format = Pattern[/#{StringConverter::Format::FMT_PATTERN_STR}/]"
1591
- type 'ContainerFormat = Struct[{
1592
- Optional[format] => Format,
1593
- Optional[separator] => String,
1594
- Optional[separator2] => String,
1595
- Optional[string_formats] => Hash[Type, Format]
1596
- }]'
1597
- type 'TypeMap = Hash[Type, Variant[Format, ContainerFormat]]'
1598
- type 'Convertible = Any'
1599
- type 'Formats = Variant[Default, String[1], TypeMap]'
1600
- end
1601
-
1602
- dispatch :from_args do
1603
- param 'Convertible', :from
1604
- optional_param 'Formats', :string_formats
1605
- end
1606
-
1607
- def from_args(from, formats = :default)
1608
- StringConverter.singleton.convert(from, formats)
1609
- end
1610
- end
1611
- end
1612
-
1613
- DEFAULT = PStringType.new(nil)
1614
- NON_EMPTY = PStringType.new(PCollectionType::NOT_EMPTY_SIZE)
1615
-
1616
- # Iterates over each character of the string
1617
- ITERABLE_TYPE = PIterableType.new(PStringType.new(PIntegerType.new(1,1)))
1618
-
1619
- protected
1620
-
1621
- # @api private
1622
- def _assignable?(o, guard)
1623
- if @size_type_or_value.is_a?(PIntegerType)
1624
- # A general string is assignable by any other string or pattern restricted string
1625
- # if the string has a size constraint it does not match since there is no reasonable way
1626
- # to compute the min/max length a pattern will match. For enum, it is possible to test that
1627
- # each enumerator value is within range
1628
- case o
1629
- when PStringType
1630
- @size_type_or_value.assignable?(o.derived_size_type, guard)
1631
-
1632
- when PEnumType
1633
- if o.values.empty?
1634
- # enum represents all enums, and thus all strings, a sized constrained string can thus not
1635
- # be assigned any enum (unless it is max size).
1636
- @size_type_or_value.assignable?(PCollectionType::DEFAULT_SIZE, guard)
1637
- else
1638
- # true if all enum values are within range
1639
- orange = o.values.map(&:size).minmax
1640
- srange = @size_type_or_value.range
1641
- # If o min and max are within the range of t
1642
- srange[0] <= orange[0] && srange[1] >= orange[1]
1643
- end
1644
-
1645
- when PPatternType
1646
- # true if size constraint is at least 0 to +Infinity (which is the same as the default)
1647
- @size_type_or_value.assignable?(PCollectionType::DEFAULT_SIZE, guard)
1648
- else
1649
- # no other type matches string
1650
- false
1651
- end
1652
- else
1653
- case o
1654
- when PStringType
1655
- # Must match exactly when value is a string
1656
- @size_type_or_value.nil? || @size_type_or_value == o.size_type_or_value
1657
- when PEnumType
1658
- @size_type_or_value.nil? ? true : o.values.size == 1 && !o.case_insensitive? && o.values[0]
1659
- when PPatternType
1660
- @size_type_or_value.nil?
1661
- else
1662
- # All others are false, since no other type describes the same set of specific strings
1663
- false
1664
- end
1665
- end
1666
- end
1667
- end
1668
-
1669
- # @api public
1670
- #
1671
- class PRegexpType < PScalarType
1672
- def self.register_ptype(loader, ir)
1673
- create_ptype(loader, ir, 'ScalarType',
1674
- 'pattern' => {
1675
- KEY_TYPE => PVariantType.new([PUndefType::DEFAULT, PStringType::DEFAULT, PRegexpType::DEFAULT]),
1676
- KEY_VALUE => nil
1677
- })
1678
- end
1679
-
1680
-
1681
- # Returns a new function that produces a Regexp instance
1682
- #
1683
- def self.new_function(type)
1684
- @new_function ||= Puppet::Functions.create_loaded_function(:new_float, type.loader) do
1685
- dispatch :from_string do
1686
- param 'String', :pattern
1687
- end
1688
-
1689
- def from_string(pattern)
1690
- Regexp.new(pattern)
1691
- end
1692
- end
1693
- end
1694
-
1695
- attr_reader :pattern
1696
-
1697
- # @param regexp [Regexp] the regular expression
1698
- # @return [String] the Regexp as a slash delimited string with slashes escaped
1699
- def self.regexp_to_s_with_delimiters(regexp)
1700
- regexp.options == 0 ? regexp.inspect : "/#{regexp.to_s}/"
1701
- end
1702
-
1703
- # @param regexp [Regexp] the regular expression
1704
- # @return [String] the Regexp as a string without escaped slash
1705
- def self.regexp_to_s(regexp)
1706
- append_flags_group(regexp.source, regexp.options)
1707
- end
1708
-
1709
- def self.append_flags_group(rx_string, options)
1710
- if options == 0
1711
- rx_string
1712
- else
1713
- bld = '(?'
1714
- bld << 'i' if (options & Regexp::IGNORECASE) != 0
1715
- bld << 'm' if (options & Regexp::MULTILINE) != 0
1716
- bld << 'x' if (options & Regexp::EXTENDED) != 0
1717
- unless options == (Regexp::IGNORECASE | Regexp::MULTILINE | Regexp::EXTENDED)
1718
- bld << '-'
1719
- bld << 'i' if (options & Regexp::IGNORECASE) == 0
1720
- bld << 'm' if (options & Regexp::MULTILINE) == 0
1721
- bld << 'x' if (options & Regexp::EXTENDED) == 0
1722
- end
1723
- bld << ':' << rx_string << ')'
1724
- bld.freeze
1725
- end
1726
- end
1727
-
1728
- def initialize(pattern)
1729
- if pattern.is_a?(Regexp)
1730
- @regexp = pattern
1731
- @pattern = PRegexpType.regexp_to_s(pattern)
1732
- else
1733
- @pattern = pattern
1734
- end
1735
- end
1736
-
1737
- def regexp
1738
- @regexp ||= Regexp.new(@pattern || '')
1739
- end
1740
-
1741
- def hash
1742
- @pattern.hash
1743
- end
1744
-
1745
- def eql?(o)
1746
- self.class == o.class && @pattern == o.pattern
1747
- end
1748
-
1749
- def instance?(o, guard=nil)
1750
- o.is_a?(Regexp) && @pattern.nil? || regexp == o
1751
- end
1752
-
1753
- DEFAULT = PRegexpType.new(nil)
1754
-
1755
- protected
1756
-
1757
- # @api private
1758
- #
1759
- def _assignable?(o, guard)
1760
- o.is_a?(PRegexpType) && (@pattern.nil? || @pattern == o.pattern)
1761
- end
1762
- end
1763
-
1764
- # Represents a subtype of String that narrows the string to those matching the patterns
1765
- # If specified without a pattern it is basically the same as the String type.
1766
- #
1767
- # @api public
1768
- #
1769
- class PPatternType < PScalarDataType
1770
- def self.register_ptype(loader, ir)
1771
- create_ptype(loader, ir, 'ScalarDataType', 'patterns' => PArrayType.new(PRegexpType::DEFAULT))
1772
- end
1773
-
1774
- attr_reader :patterns
1775
-
1776
- def initialize(patterns)
1777
- @patterns = patterns.freeze
1778
- end
1779
-
1780
- def accept(visitor, guard)
1781
- super
1782
- @patterns.each { |p| p.accept(visitor, guard) }
1783
- end
1784
-
1785
- def hash
1786
- @patterns.hash
1787
- end
1788
-
1789
- def eql?(o)
1790
- self.class == o.class && @patterns.size == o.patterns.size && (@patterns - o.patterns).empty?
1791
- end
1792
-
1793
- def instance?(o, guard = nil)
1794
- o.is_a?(String) && (@patterns.empty? || @patterns.any? { |p| p.regexp.match(o) })
1795
- end
1796
-
1797
- DEFAULT = PPatternType.new(EMPTY_ARRAY)
1798
-
1799
- protected
1800
-
1801
- # @api private
1802
- #
1803
- def _assignable?(o, guard)
1804
- return true if self == o
1805
- case o
1806
- when PStringType
1807
- v = o.value
1808
- if v.nil?
1809
- # Strings cannot all match a pattern, but if there is no pattern it is ok
1810
- # (There should really always be a pattern, but better safe than sorry).
1811
- @patterns.empty?
1812
- else
1813
- # the string in String type must match one of the patterns in Pattern type,
1814
- # or Pattern represents all Patterns == all Strings
1815
- regexps = @patterns.map { |p| p.regexp }
1816
- regexps.empty? || regexps.any? { |re| re.match(v) }
1817
- end
1818
- when PEnumType
1819
- if o.values.empty?
1820
- # Enums (unknown which ones) cannot all match a pattern, but if there is no pattern it is ok
1821
- # (There should really always be a pattern, but better safe than sorry).
1822
- @patterns.empty?
1823
- else
1824
- # all strings in String/Enum type must match one of the patterns in Pattern type,
1825
- # or Pattern represents all Patterns == all Strings
1826
- regexps = @patterns.map { |p| p.regexp }
1827
- regexps.empty? || o.values.all? { |s| regexps.any? {|re| re.match(s) } }
1828
- end
1829
- when PPatternType
1830
- @patterns.empty?
1831
- else
1832
- false
1833
- end
1834
- end
1835
- end
1836
-
1837
- # @api public
1838
- #
1839
- class PBooleanType < PScalarDataType
1840
- def self.register_ptype(loader, ir)
1841
- create_ptype(loader, ir, 'ScalarDataType')
1842
- end
1843
-
1844
- attr_reader :value
1845
-
1846
- def initialize(value = nil)
1847
- @value = value
1848
- end
1849
-
1850
- def eql?(o)
1851
- o.is_a?(PBooleanType) && @value == o.value
1852
- end
1853
-
1854
- def generalize
1855
- PBooleanType::DEFAULT
1856
- end
1857
-
1858
- def hash
1859
- 31 ^ @value.hash
1860
- end
1861
-
1862
- def instance?(o, guard = nil)
1863
- (o == true || o == false) && (@value.nil? || value == o)
1864
- end
1865
-
1866
- def self.new_function(type)
1867
- @new_function ||= Puppet::Functions.create_loaded_function(:new_boolean, type.loader) do
1868
- dispatch :from_args do
1869
- param "Variant[Integer, Float, Boolean, Enum['false','true','yes','no','y','n',true]]", :from
1870
- end
1871
-
1872
- argument_mismatch :on_error do
1873
- param 'Any', :from
1874
- end
1875
-
1876
- def from_args(from)
1877
- from = from.downcase if from.is_a?(String)
1878
- case from
1879
- when Float
1880
- from != 0.0
1881
- when Integer
1882
- from != 0
1883
- when false, 'false', 'no', 'n'
1884
- false
1885
- else
1886
- true
1887
- end
1888
- end
1889
-
1890
- def on_error(from)
1891
- if from.is_a?(String)
1892
- _("The string '%{str}' cannot be converted to Boolean") % { str: from }
1893
- else
1894
- t = TypeCalculator.singleton.infer(from).generalize
1895
- _("Value of type %{type} cannot be converted to Boolean") % { type: t }
1896
- end
1897
- end
1898
- end
1899
- end
1900
-
1901
- DEFAULT = PBooleanType.new
1902
- TRUE = PBooleanType.new(true)
1903
- FALSE = PBooleanType.new(false)
1904
-
1905
- protected
1906
-
1907
- # @api private
1908
- #
1909
- def _assignable?(o, guard)
1910
- o.is_a?(PBooleanType) && (@value.nil? || @value == o.value)
1911
- end
1912
- end
1913
-
1914
- # @api public
1915
- #
1916
- # @api public
1917
- #
1918
- class PStructElement < TypedModelObject
1919
- def self.register_ptype(loader, ir)
1920
- @type = Pcore::create_object_type(loader, ir, self, 'Pcore::StructElement'.freeze, nil,
1921
- 'key_type' => PTypeType::DEFAULT,
1922
- 'value_type' => PTypeType::DEFAULT)
1923
- end
1924
-
1925
- attr_accessor :key_type, :value_type
1926
-
1927
- def accept(visitor, guard)
1928
- @key_type.accept(visitor, guard)
1929
- @value_type.accept(visitor, guard)
1930
- end
1931
-
1932
- def hash
1933
- value_type.hash ^ key_type.hash
1934
- end
1935
-
1936
- def name
1937
- k = key_type
1938
- k = k.optional_type if k.is_a?(POptionalType)
1939
- k.value
1940
- end
1941
-
1942
- def initialize(key_type, value_type)
1943
- @key_type = key_type
1944
- @value_type = value_type
1945
- end
1946
-
1947
- def generalize
1948
- gv_type = @value_type.generalize
1949
- @value_type.equal?(gv_type) ? self : PStructElement.new(@key_type, gv_type)
1950
- end
1951
-
1952
- def normalize(guard = nil)
1953
- nv_type = @value_type.normalize(guard)
1954
- @value_type.equal?(nv_type) ? self : PStructElement.new(@key_type, nv_type)
1955
- end
1956
-
1957
- def resolve(loader)
1958
- rkey_type = @key_type.resolve(loader)
1959
- rvalue_type = @value_type.resolve(loader)
1960
- rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type)
1961
- end
1962
-
1963
- def <=>(o)
1964
- self.name <=> o.name
1965
- end
1966
-
1967
- def eql?(o)
1968
- self == o
1969
- end
1970
-
1971
- def ==(o)
1972
- self.class == o.class && value_type == o.value_type && key_type == o.key_type
1973
- end
1974
-
1975
- # Special boostrap method to overcome the hen and egg problem with the Object initializer that contains
1976
- # types that are derived from Object (such as Annotation)
1977
- #
1978
- # @api private
1979
- def replace_value_type(new_type)
1980
- @value_type = new_type
1981
- end
1982
- end
1983
-
1984
- # @api public
1985
- #
1986
- class PStructType < PAnyType
1987
- include Enumerable
1988
-
1989
- def self.register_ptype(loader, ir)
1990
- create_ptype(loader, ir, 'AnyType', 'elements' => PArrayType.new(PTypeReferenceType.new('Pcore::StructElement')))
1991
- end
1992
-
1993
- def initialize(elements)
1994
- @elements = elements.freeze
1995
- end
1996
-
1997
- def accept(visitor, guard)
1998
- super
1999
- @elements.each { |elem| elem.accept(visitor, guard) }
2000
- end
2001
-
2002
- def each
2003
- if block_given?
2004
- elements.each { |elem| yield elem }
2005
- else
2006
- elements.to_enum
2007
- end
2008
- end
2009
-
2010
- def generalize
2011
- if @elements.empty?
2012
- DEFAULT
2013
- else
2014
- alter_type_array(@elements, :generalize) { |altered| PStructType.new(altered) }
2015
- end
2016
- end
2017
-
2018
- def normalize(guard = nil)
2019
- if @elements.empty?
2020
- DEFAULT
2021
- else
2022
- alter_type_array(@elements, :normalize, guard) { |altered| PStructType.new(altered) }
2023
- end
2024
- end
2025
-
2026
- def hashed_elements
2027
- @hashed ||= @elements.reduce({}) {|memo, e| memo[e.name] = e; memo }
2028
- end
2029
-
2030
- def hash
2031
- @elements.hash
2032
- end
2033
-
2034
- def iterable?(guard = nil)
2035
- true
2036
- end
2037
-
2038
- def iterable_type(guard = nil)
2039
- if self == DEFAULT
2040
- PIterableType.new(PHashType::DEFAULT_KEY_PAIR_TUPLE)
2041
- else
2042
- PIterableType.new(
2043
- PTupleType.new([
2044
- PVariantType.maybe_create(@elements.map {|se| se.key_type }),
2045
- PVariantType.maybe_create(@elements.map {|se| se.value_type })],
2046
- PHashType::KEY_PAIR_TUPLE_SIZE))
2047
- end
2048
- end
2049
-
2050
- def resolve(loader)
2051
- changed = false
2052
- relements = @elements.map do |elem|
2053
- relem = elem.resolve(loader)
2054
- changed ||= !relem.equal?(elem)
2055
- relem
2056
- end
2057
- changed ? self.class.new(relements) : self
2058
- end
2059
-
2060
- def eql?(o)
2061
- self.class == o.class && @elements == o.elements
2062
- end
2063
-
2064
- def elements
2065
- @elements
2066
- end
2067
-
2068
- def instance?(o, guard = nil)
2069
- # The inferred type of a class derived from Hash is either Runtime or Object. It's not assignable to the Struct type.
2070
- return false unless o.instance_of?(Hash)
2071
- matched = 0
2072
- @elements.all? do |e|
2073
- key = e.name
2074
- v = o[key]
2075
- if v.nil? && !o.include?(key)
2076
- # Entry is missing. Only OK when key is optional
2077
- e.key_type.assignable?(PUndefType::DEFAULT, guard)
2078
- else
2079
- matched += 1
2080
- e.value_type.instance?(v, guard)
2081
- end
2082
- end && matched == o.size
2083
- end
2084
-
2085
- def new_function
2086
- # Simply delegate to Hash type and let the higher level assertion deal with
2087
- # compliance with the Struct type regarding the produced result.
2088
- PHashType.new_function(self)
2089
- end
2090
-
2091
- DEFAULT = PStructType.new(EMPTY_ARRAY)
2092
-
2093
- protected
2094
-
2095
- # @api private
2096
- def _assignable?(o, guard)
2097
- if o.is_a?(Types::PStructType)
2098
- h2 = o.hashed_elements
2099
- matched = 0
2100
- elements.all? do |e1|
2101
- e2 = h2[e1.name]
2102
- if e2.nil?
2103
- e1.key_type.assignable?(PUndefType::DEFAULT, guard)
2104
- else
2105
- matched += 1
2106
- e1.key_type.assignable?(e2.key_type, guard) && e1.value_type.assignable?(e2.value_type, guard)
2107
- end
2108
- end && matched == h2.size
2109
- elsif o.is_a?(Types::PHashType)
2110
- required = 0
2111
- required_elements_assignable = elements.all? do |e|
2112
- key_type = e.key_type
2113
- if key_type.assignable?(PUndefType::DEFAULT)
2114
- # Element is optional so Hash does not need to provide it
2115
- true
2116
- else
2117
- required += 1
2118
- if e.value_type.assignable?(o.value_type, guard)
2119
- # Hash must have something that is assignable. We don't care about the name or size of the key though
2120
- # because we have no instance of a hash to compare against.
2121
- key_type.generalize.assignable?(o.key_type)
2122
- else
2123
- false
2124
- end
2125
- end
2126
- end
2127
- if required_elements_assignable
2128
- size_o = o.size_type || PCollectionType::DEFAULT_SIZE
2129
- PIntegerType.new(required, elements.size).assignable?(size_o, guard)
2130
- else
2131
- false
2132
- end
2133
- else
2134
- false
2135
- end
2136
- end
2137
- end
2138
-
2139
- # @api public
2140
- #
2141
- class PTupleType < PAnyType
2142
- include Enumerable
2143
-
2144
- def self.register_ptype(loader, ir)
2145
- create_ptype(loader, ir, 'AnyType',
2146
- 'types' => PArrayType.new(PTypeType::DEFAULT),
2147
- 'size_type' => {
2148
- KEY_TYPE => POptionalType.new(PTypeType.new(PIntegerType::DEFAULT)),
2149
- KEY_VALUE => nil
2150
- }
2151
- )
2152
- end
2153
-
2154
- # If set, describes min and max required of the given types - if max > size of
2155
- # types, the last type entry repeats
2156
- #
2157
- attr_reader :size_type
2158
-
2159
- attr_reader :types
2160
-
2161
- def accept(visitor, guard)
2162
- super
2163
- @size_type.accept(visitor, guard) unless @size_type.nil?
2164
- @types.each { |elem| elem.accept(visitor, guard) }
2165
- end
2166
-
2167
- # @api private
2168
- def callable_args?(callable_t, guard)
2169
- unless size_type.nil?
2170
- raise ArgumentError, 'Callable tuple may not have a size constraint when used as args'
2171
- end
2172
-
2173
- params_tuple = callable_t.param_types
2174
- param_block_t = callable_t.block_type
2175
- arg_types = @types
2176
- arg_block_t = arg_types.last
2177
- if arg_block_t.kind_of_callable?(true, guard)
2178
- # Can't pass a block to a callable that doesn't accept one
2179
- return false if param_block_t.nil?
2180
-
2181
- # Check that the block is of the right tyṕe
2182
- return false unless param_block_t.assignable?(arg_block_t, guard)
2183
-
2184
- # Check other arguments
2185
- arg_count = arg_types.size - 1
2186
- params_size_t = params_tuple.size_type || PIntegerType.new(*params_tuple.size_range)
2187
- return false unless params_size_t.assignable?(PIntegerType.new(arg_count, arg_count), guard)
2188
-
2189
- ctypes = params_tuple.types
2190
- arg_count.times do |index|
2191
- return false unless (ctypes[index] || ctypes[-1]).assignable?(arg_types[index], guard)
2192
- end
2193
- return true
2194
- end
2195
-
2196
- # Check that tuple is assignable and that the block (if declared) is optional
2197
- params_tuple.assignable?(self, guard) && (param_block_t.nil? || param_block_t.assignable?(PUndefType::DEFAULT, guard))
2198
- end
2199
-
2200
- def initialize(types, size_type = nil)
2201
- @types = types
2202
- @size_type = size_type.nil? ? nil : size_type.to_size
2203
- end
2204
-
2205
- # Returns Enumerator for the types if no block is given, otherwise, calls the given
2206
- # block with each of the types in this tuple
2207
- def each
2208
- if block_given?
2209
- types.each { |x| yield x }
2210
- else
2211
- types.to_enum
2212
- end
2213
- end
2214
-
2215
- def generalize
2216
- if self == DEFAULT
2217
- DEFAULT
2218
- else
2219
- alter_type_array(@types, :generalize) { |altered_types| PTupleType.new(altered_types, @size_type) }
2220
- end
2221
- end
2222
-
2223
- def normalize(guard = nil)
2224
- if self == DEFAULT
2225
- DEFAULT
2226
- else
2227
- alter_type_array(@types, :normalize, guard) { |altered_types| PTupleType.new(altered_types, @size_type) }
2228
- end
2229
- end
2230
-
2231
- def resolve(loader)
2232
- changed = false
2233
- rtypes = @types.map do |type|
2234
- rtype = type.resolve(loader)
2235
- changed ||= !rtype.equal?(type)
2236
- rtype
2237
- end
2238
- changed ? self.class.new(rtypes, @size_type) : self
2239
- end
2240
-
2241
- def instance?(o, guard = nil)
2242
- # The inferred type of a class derived from Array is either Runtime or Object. It's not assignable to the Tuple type.
2243
- return false unless o.instance_of?(Array)
2244
- if @size_type
2245
- return false unless @size_type.instance?(o.size, guard)
2246
- else
2247
- return false unless @types.empty? || @types.size == o.size
2248
- end
2249
- index = -1
2250
- @types.empty? || o.all? do |element|
2251
- @types.fetch(index += 1) { @types.last }.instance?(element, guard)
2252
- end
2253
- end
2254
-
2255
- def iterable?(guard = nil)
2256
- true
2257
- end
2258
-
2259
- def iterable_type(guard = nil)
2260
- PIterableType.new(PVariantType.maybe_create(types))
2261
- end
2262
-
2263
- # Returns the number of elements accepted [min, max] in the tuple
2264
- def size_range
2265
- if @size_type.nil?
2266
- types_size = @types.size
2267
- types_size == 0 ? [0, Float::INFINITY] : [types_size, types_size]
2268
- else
2269
- @size_type.range
2270
- end
2271
- end
2272
-
2273
- # Returns the number of accepted occurrences [min, max] of the last type in the tuple
2274
- # The defaults is [1,1]
2275
- #
2276
- def repeat_last_range
2277
- if @size_type.nil?
2278
- return [1, 1]
2279
- end
2280
- types_size = @types.size
2281
- from, to = @size_type.range
2282
- min = from - (types_size-1)
2283
- min = min <= 0 ? 0 : min
2284
- max = to - (types_size-1)
2285
- [min, max]
2286
- end
2287
-
2288
- def hash
2289
- @size_type.hash ^ @types.hash
2290
- end
2291
-
2292
- def eql?(o)
2293
- self.class == o.class && @types == o.types && @size_type == o.size_type
2294
- end
2295
-
2296
- def new_function
2297
- # Simply delegate to Array type and let the higher level assertion deal with
2298
- # compliance with the Tuple type regarding the produced result.
2299
- PArrayType.new_function(self)
2300
- end
2301
-
2302
- DEFAULT = PTupleType.new(EMPTY_ARRAY)
2303
-
2304
- protected
2305
-
2306
- # @api private
2307
- def _assignable?(o, guard)
2308
- return true if self == o
2309
- return false unless o.is_a?(PTupleType) || o.is_a?(PArrayType)
2310
- s_types = types
2311
- size_s = size_type || PIntegerType.new(*size_range)
2312
-
2313
- if o.is_a?(PTupleType)
2314
- size_o = o.size_type || PIntegerType.new(*o.size_range)
2315
- return false unless size_s.assignable?(size_o, guard)
2316
- unless s_types.empty?
2317
- o_types = o.types
2318
- return size_s.numeric_from == 0 if o_types.empty?
2319
- o_types.size.times do |index|
2320
- return false unless (s_types[index] || s_types[-1]).assignable?(o_types[index], guard)
2321
- end
2322
- end
2323
- else
2324
- size_o = o.size_type || PCollectionType::DEFAULT_SIZE
2325
- return false unless size_s.assignable?(size_o, guard)
2326
- unless s_types.empty?
2327
- o_entry = o.element_type
2328
- # Array of anything can not be assigned (unless tuple is tuple of anything) - this case
2329
- # was handled at the top of this method.
2330
- #
2331
- return false if o_entry.nil?
2332
- [s_types.size, size_o.range[1]].min.times { |index| return false unless (s_types[index] || s_types[-1]).assignable?(o_entry, guard) }
2333
- end
2334
- end
2335
- true
2336
- end
2337
- end
2338
-
2339
- # @api public
2340
- #
2341
- class PCallableType < PAnyType
2342
- def self.register_ptype(loader, ir)
2343
- create_ptype(loader, ir, 'AnyType',
2344
- 'param_types' => {
2345
- KEY_TYPE => POptionalType.new(PTypeType.new(PTupleType::DEFAULT)),
2346
- KEY_VALUE => nil
2347
- },
2348
- 'block_type' => {
2349
- KEY_TYPE => POptionalType.new(PTypeType.new(PCallableType::DEFAULT)),
2350
- KEY_VALUE => nil
2351
- },
2352
- 'return_type' => {
2353
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
2354
- KEY_VALUE => PAnyType::DEFAULT
2355
- }
2356
- )
2357
- end
2358
-
2359
- # @return [PAnyType] The type for the values returned by this callable. Returns `nil` if return value is unconstrained
2360
- attr_reader :return_type
2361
-
2362
- # Types of parameters as a Tuple with required/optional count, or an Integer with min (required), max count
2363
- # @return [PTupleType] the tuple representing the parameter types
2364
- attr_reader :param_types
2365
-
2366
- # Although being an abstract type reference, only Callable, or all Callables wrapped in
2367
- # Optional or Variant are supported
2368
- # If not set, the meaning is that block is not supported.
2369
- # @return [PAnyType|nil] the block type
2370
- attr_reader :block_type
2371
-
2372
- # @param param_types [PTupleType]
2373
- # @param block_type [PAnyType]
2374
- # @param return_type [PAnyType]
2375
- def initialize(param_types, block_type = nil, return_type = nil)
2376
- @param_types = param_types
2377
- @block_type = block_type
2378
- @return_type = return_type == PAnyType::DEFAULT ? nil : return_type
2379
- end
2380
-
2381
- def accept(visitor, guard)
2382
- super
2383
- @param_types.accept(visitor, guard) unless @param_types.nil?
2384
- @block_type.accept(visitor, guard) unless @block_type.nil?
2385
- @return_type.accept(visitor, guard) unless @return_type.nil?
2386
- end
2387
-
2388
- def generalize
2389
- if self == DEFAULT
2390
- DEFAULT
2391
- else
2392
- params_t = @param_types.nil? ? nil : @param_types.generalize
2393
- block_t = @block_type.nil? ? nil : @block_type.generalize
2394
- return_t = @return_type.nil? ? nil : @return_type.generalize
2395
- @param_types.equal?(params_t) && @block_type.equal?(block_t) && @return_type.equal?(return_t) ? self : PCallableType.new(params_t, block_t, return_t)
2396
- end
2397
- end
2398
-
2399
- def normalize(guard = nil)
2400
- if self == DEFAULT
2401
- DEFAULT
2402
- else
2403
- params_t = @param_types.nil? ? nil : @param_types.normalize(guard)
2404
- block_t = @block_type.nil? ? nil : @block_type.normalize(guard)
2405
- return_t = @return_type.nil? ? nil : @return_type.normalize(guard)
2406
- @param_types.equal?(params_t) && @block_type.equal?(block_t) && @return_type.equal?(return_t) ? self : PCallableType.new(params_t, block_t, return_t)
2407
- end
2408
- end
2409
-
2410
- def instance?(o, guard = nil)
2411
- (o.is_a?(Proc) || o.is_a?(Evaluator::Closure) || o.is_a?(Functions::Function)) && assignable?(TypeCalculator.infer(o), guard)
2412
- end
2413
-
2414
- # Returns `true` if this instance is a callable that accepts the given _args_
2415
- #
2416
- # @param args [Array] the arguments to test
2417
- # @return [Boolean] `true` if this instance is a callable that accepts the given _args_
2418
- def callable_with?(args, block = nil)
2419
- # nil param_types and compatible return type means other Callable is assignable
2420
- return true if @param_types.nil?
2421
- return false unless @param_types.instance?(args)
2422
- if @block_type.nil?
2423
- block == nil
2424
- else
2425
- @block_type.instance?(block)
2426
- end
2427
- end
2428
-
2429
- # @api private
2430
- def callable_args?(required_callable_t, guard)
2431
- # If the required callable is equal or more specific than self, self is acceptable arguments
2432
- required_callable_t.assignable?(self, guard)
2433
- end
2434
-
2435
- def kind_of_callable?(optional=true, guard = nil)
2436
- true
2437
- end
2438
-
2439
- # Returns the number of accepted arguments [min, max]
2440
- def size_range
2441
- @param_types.nil? ? nil : @param_types.size_range
2442
- end
2443
-
2444
- # Returns the number of accepted arguments for the last parameter type [min, max]
2445
- #
2446
- def last_range
2447
- @param_types.nil? ? nil : @param_types.repeat_last_range
2448
- end
2449
-
2450
- # Range [0,0], [0,1], or [1,1] for the block
2451
- #
2452
- def block_range
2453
- case block_type
2454
- when POptionalType
2455
- [0,1]
2456
- when PVariantType, PCallableType
2457
- [1,1]
2458
- else
2459
- [0,0]
2460
- end
2461
- end
2462
-
2463
- def hash
2464
- [@param_types, @block_type, @return_type].hash
2465
- end
2466
-
2467
- def eql?(o)
2468
- self.class == o.class && @param_types == o.param_types && @block_type == o.block_type && @return_type == o.return_type
2469
- end
2470
-
2471
- def resolve(loader)
2472
- params_t = @param_types.nil? ? nil : @param_types.resolve(loader)
2473
- block_t = @block_type.nil? ? nil : @block_type.resolve(loader)
2474
- return_t = @return_type.nil? ? nil : @return_type.resolve(loader)
2475
- @param_types.equal?(params_t) && @block_type.equal?(block_t) && @return_type.equal?(return_t) ? self : self.class.new(params_t, block_t, return_t)
2476
- end
2477
-
2478
- DEFAULT = PCallableType.new(nil, nil, nil)
2479
-
2480
- protected
2481
-
2482
- # @api private
2483
- def _assignable?(o, guard)
2484
- return false unless o.is_a?(PCallableType)
2485
- return false unless @return_type.nil? || @return_type.assignable?(o.return_type || PAnyType::DEFAULT, guard)
2486
-
2487
- # nil param_types and compatible return type means other Callable is assignable
2488
- return true if @param_types.nil?
2489
-
2490
- # NOTE: these tests are made in reverse as it is calling the callable that is constrained
2491
- # (it's lower bound), not its upper bound
2492
- other_param_types = o.param_types
2493
-
2494
- return false if other_param_types.nil? || !other_param_types.assignable?(@param_types, guard)
2495
- # names are ignored, they are just information
2496
- # Blocks must be compatible
2497
- this_block_t = @block_type || PUndefType::DEFAULT
2498
- that_block_t = o.block_type || PUndefType::DEFAULT
2499
- that_block_t.assignable?(this_block_t, guard)
2500
- end
2501
- end
2502
-
2503
- # @api public
2504
- #
2505
- class PArrayType < PCollectionType
2506
-
2507
- def self.register_ptype(loader, ir)
2508
- create_ptype(loader, ir, 'CollectionType',
2509
- 'element_type' => {
2510
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
2511
- KEY_VALUE => PAnyType::DEFAULT
2512
- }
2513
- )
2514
- end
2515
-
2516
- attr_reader :element_type
2517
-
2518
- def initialize(element_type, size_type = nil)
2519
- super(size_type)
2520
- if !size_type.nil? && size_type.from == 0 && size_type.to == 0
2521
- @element_type = PUnitType::DEFAULT
2522
- else
2523
- @element_type = element_type.nil? ? PAnyType::DEFAULT : element_type
2524
- end
2525
- end
2526
-
2527
- def accept(visitor, guard)
2528
- super
2529
- @element_type.accept(visitor, guard)
2530
- end
2531
-
2532
- # @api private
2533
- def callable_args?(callable, guard = nil)
2534
- param_t = callable.param_types
2535
- block_t = callable.block_type
2536
- # does not support calling with a block, but have to check that callable is ok with missing block
2537
- (param_t.nil? || param_t.assignable?(self, guard)) && (block_t.nil? || block_t.assignable?(PUndefType::DEFAULT, guard))
2538
- end
2539
-
2540
- def generalize
2541
- if PAnyType::DEFAULT.eql?(@element_type)
2542
- DEFAULT
2543
- else
2544
- ge_type = @element_type.generalize
2545
- @size_type.nil? && @element_type.equal?(ge_type) ? self : self.class.new(ge_type, nil)
2546
- end
2547
- end
2548
-
2549
- def eql?(o)
2550
- super && @element_type == o.element_type
2551
- end
2552
-
2553
- def hash
2554
- super ^ @element_type.hash
2555
- end
2556
-
2557
- def normalize(guard = nil)
2558
- if PAnyType::DEFAULT.eql?(@element_type)
2559
- DEFAULT
2560
- else
2561
- ne_type = @element_type.normalize(guard)
2562
- @element_type.equal?(ne_type) ? self : self.class.new(ne_type, @size_type)
2563
- end
2564
- end
2565
-
2566
- def resolve(loader)
2567
- relement_type = @element_type.resolve(loader)
2568
- relement_type.equal?(@element_type) ? self : self.class.new(relement_type, @size_type)
2569
- end
2570
-
2571
- def instance?(o, guard = nil)
2572
- # The inferred type of a class derived from Array is either Runtime or Object. It's not assignable to the Array type.
2573
- return false unless o.instance_of?(Array)
2574
- return false unless o.all? {|element| @element_type.instance?(element, guard) }
2575
- size_t = size_type
2576
- size_t.nil? || size_t.instance?(o.size, guard)
2577
- end
2578
-
2579
- def iterable_type(guard = nil)
2580
- PAnyType::DEFAULT.eql?(@element_type) ? PIterableType::DEFAULT : PIterableType.new(@element_type)
2581
- end
2582
-
2583
- # Returns a new function that produces an Array
2584
- #
2585
- def self.new_function(type)
2586
- @new_function ||= Puppet::Functions.create_loaded_function(:new_array, type.loader) do
2587
-
2588
- dispatch :to_array do
2589
- param 'Variant[Array,Hash,Binary,Iterable]', :from
2590
- optional_param 'Boolean[false]', :wrap
2591
- end
2592
-
2593
- dispatch :wrapped do
2594
- param 'Any', :from
2595
- param 'Boolean[true]', :wrap
2596
- end
2597
-
2598
- argument_mismatch :on_error do
2599
- param 'Any', :from
2600
- optional_param 'Boolean', :wrap
2601
- end
2602
-
2603
- def wrapped(from, _)
2604
- from.is_a?(Array) ? from : [from]
2605
- end
2606
-
2607
- def to_array(from, _ = false)
2608
- case from
2609
- when Array
2610
- from
2611
- when Hash
2612
- from.to_a
2613
- when PBinaryType::Binary
2614
- # For older rubies, the #bytes method returns an Enumerator that must be rolled out
2615
- from.binary_buffer.bytes.to_a
2616
- else
2617
- Iterable.on(from).to_a
2618
- end
2619
- end
2620
-
2621
- def on_error(from, _ = false)
2622
- t = TypeCalculator.singleton.infer(from).generalize
2623
- _("Value of type %{type} cannot be converted to Array") % { type: t }
2624
- end
2625
- end
2626
- end
2627
-
2628
- DEFAULT = PArrayType.new(nil)
2629
- EMPTY = PArrayType.new(PUnitType::DEFAULT, ZERO_SIZE)
2630
-
2631
- protected
2632
-
2633
- # Array is assignable if o is an Array and o's element type is assignable, or if o is a Tuple
2634
- # @api private
2635
- def _assignable?(o, guard)
2636
- if o.is_a?(PTupleType)
2637
- o_types = o.types
2638
- size_s = size_type || DEFAULT_SIZE
2639
- size_o = o.size_type
2640
- if size_o.nil?
2641
- type_count = o_types.size
2642
- size_o = PIntegerType.new(type_count, type_count)
2643
- end
2644
- size_s.assignable?(size_o) && o_types.all? { |ot| @element_type.assignable?(ot, guard) }
2645
- elsif o.is_a?(PArrayType)
2646
- super && @element_type.assignable?(o.element_type, guard)
2647
- else
2648
- false
2649
- end
2650
- end
2651
- end
2652
-
2653
- # @api public
2654
- #
2655
- class PHashType < PCollectionType
2656
-
2657
- def self.register_ptype(loader, ir)
2658
- create_ptype(loader, ir, 'CollectionType',
2659
- 'key_type' => {
2660
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
2661
- KEY_VALUE => PAnyType::DEFAULT
2662
- },
2663
- 'value_type' => {
2664
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
2665
- KEY_VALUE => PAnyType::DEFAULT
2666
- }
2667
- )
2668
- end
2669
-
2670
- attr_accessor :key_type, :value_type
2671
-
2672
- def initialize(key_type, value_type, size_type = nil)
2673
- super(size_type)
2674
- if !size_type.nil? && size_type.from == 0 && size_type.to == 0
2675
- @key_type = PUnitType::DEFAULT
2676
- @value_type = PUnitType::DEFAULT
2677
- else
2678
- @key_type = key_type.nil? ? PAnyType::DEFAULT : key_type
2679
- @value_type = value_type.nil? ? PAnyType::DEFAULT : value_type
2680
- end
2681
- end
2682
-
2683
- def accept(visitor, guard)
2684
- super
2685
- @key_type.accept(visitor, guard)
2686
- @value_type.accept(visitor, guard)
2687
- end
2688
-
2689
- def element_type
2690
- if Puppet[:strict] != :off
2691
- #TRANSLATOR 'Puppet::Pops::Types::PHashType#element_type' and '#value_type' are class and method names and should not be translated
2692
- Puppet.warn_once('deprecations', 'Puppet::Pops::Types::PHashType#element_type',
2693
- _('Puppet::Pops::Types::PHashType#element_type is deprecated, use #value_type instead'))
2694
- end
2695
- @value_type
2696
- end
2697
-
2698
- def generalize
2699
- if self == DEFAULT || self == EMPTY
2700
- self
2701
- else
2702
- key_t = @key_type
2703
- key_t = key_t.generalize
2704
- value_t = @value_type
2705
- value_t = value_t.generalize
2706
- @size_type.nil? && @key_type.equal?(key_t) && @value_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, nil)
2707
- end
2708
- end
2709
-
2710
- def normalize(guard = nil)
2711
- if self == DEFAULT || self == EMPTY
2712
- self
2713
- else
2714
- key_t = @key_type.normalize(guard)
2715
- value_t = @value_type.normalize(guard)
2716
- @size_type.nil? && @key_type.equal?(key_t) && @value_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, @size_type)
2717
- end
2718
- end
2719
-
2720
- def hash
2721
- super ^ @key_type.hash ^ @value_type.hash
2722
- end
2723
-
2724
- def instance?(o, guard = nil)
2725
- # The inferred type of a class derived from Hash is either Runtime or Object. It's not assignable to the Hash type.
2726
- return false unless o.instance_of?(Hash)
2727
- if o.keys.all? {|key| @key_type.instance?(key, guard) } && o.values.all? {|value| @value_type.instance?(value, guard) }
2728
- size_t = size_type
2729
- size_t.nil? || size_t.instance?(o.size, guard)
2730
- else
2731
- false
2732
- end
2733
- end
2734
-
2735
- def iterable?(guard = nil)
2736
- true
2737
- end
2738
-
2739
- def iterable_type(guard = nil)
2740
- if self == DEFAULT || self == EMPTY
2741
- PIterableType.new(DEFAULT_KEY_PAIR_TUPLE)
2742
- else
2743
- PIterableType.new(PTupleType.new([@key_type, @value_type], KEY_PAIR_TUPLE_SIZE))
2744
- end
2745
- end
2746
-
2747
- def eql?(o)
2748
- super && @key_type == o.key_type && @value_type == o.value_type
2749
- end
2750
-
2751
- def is_the_empty_hash?
2752
- self == EMPTY
2753
- end
2754
-
2755
- def resolve(loader)
2756
- rkey_type = @key_type.resolve(loader)
2757
- rvalue_type = @value_type.resolve(loader)
2758
- rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type, @size_type)
2759
- end
2760
-
2761
- def self.array_as_hash(value)
2762
- return value unless value.is_a?(Array)
2763
- result = {}
2764
- value.each_with_index {|v, idx| result[idx] = array_as_hash(v) }
2765
- result
2766
- end
2767
-
2768
- # Returns a new function that produces a Hash
2769
- #
2770
- def self.new_function(type)
2771
- @new_function ||= Puppet::Functions.create_loaded_function(:new_hash, type.loader) do
2772
- local_types do
2773
- type 'KeyValueArray = Array[Tuple[Any,Any],1]'
2774
- type 'TreeArray = Array[Tuple[Array,Any],1]'
2775
- type 'NewHashOption = Enum[tree, hash_tree]'
2776
- end
2777
-
2778
- dispatch :from_tree do
2779
- param 'TreeArray', :from
2780
- optional_param 'NewHashOption', :build_option
2781
- end
2782
-
2783
- dispatch :from_tuples do
2784
- param 'KeyValueArray', :from
2785
- end
2786
-
2787
- dispatch :from_array do
2788
- param 'Any', :from
2789
- end
2790
-
2791
- def from_tuples(tuple_array)
2792
- Hash[tuple_array]
2793
- end
2794
-
2795
- def from_tree(tuple_array, build_option = nil)
2796
- if build_option.nil?
2797
- return from_tuples(tuple_array)
2798
- end
2799
- # only remaining possible options is 'tree' or 'hash_tree'
2800
-
2801
- all_hashes = build_option == 'hash_tree'
2802
- result = {}
2803
- tuple_array.each do |entry|
2804
- path = entry[0]
2805
- value = entry[1]
2806
- if path.empty?
2807
- # root node (index [] was included - values merge into the result)
2808
- # An array must be changed to a hash first as this is the root
2809
- # (Cannot return an array from a Hash.new)
2810
- if value.is_a?(Array)
2811
- value.each_with_index {|v, idx| result[idx] = v }
2812
- else
2813
- result.merge!(value)
2814
- end
2815
- else
2816
- r = path[0..-2].reduce(result) {|memo, idx| (memo.is_a?(Array) || memo.has_key?(idx)) ? memo[idx] : memo[idx] = {}}
2817
- r[path[-1]]= (all_hashes ? PHashType.array_as_hash(value) : value)
2818
- end
2819
- end
2820
- result
2821
- end
2822
-
2823
- def from_array(from)
2824
- case from
2825
- when Array
2826
- if from.size == 0
2827
- {}
2828
- else
2829
- unless from.size % 2 == 0
2830
- raise TypeConversionError.new(_('odd number of arguments for Hash'))
2831
- end
2832
- Hash[*from]
2833
- end
2834
- when Hash
2835
- from
2836
- else
2837
- if PIterableType::DEFAULT.instance?(from)
2838
- Hash[*Iterable.on(from).to_a]
2839
- else
2840
- t = TypeCalculator.singleton.infer(from).generalize
2841
- raise TypeConversionError.new(_("Value of type %{type} cannot be converted to Hash") % { type: t })
2842
- end
2843
- end
2844
- end
2845
- end
2846
- end
2847
-
2848
- DEFAULT = PHashType.new(nil, nil)
2849
- KEY_PAIR_TUPLE_SIZE = PIntegerType.new(2,2)
2850
- DEFAULT_KEY_PAIR_TUPLE = PTupleType.new([PUnitType::DEFAULT, PUnitType::DEFAULT], KEY_PAIR_TUPLE_SIZE)
2851
- EMPTY = PHashType.new(PUnitType::DEFAULT, PUnitType::DEFAULT, PIntegerType.new(0, 0))
2852
-
2853
- protected
2854
-
2855
- # Hash is assignable if o is a Hash and o's key and element types are assignable
2856
- # @api private
2857
- def _assignable?(o, guard)
2858
- case o
2859
- when PHashType
2860
- size_s = size_type
2861
- return true if (size_s.nil? || size_s.from == 0) && o.is_the_empty_hash?
2862
- return false unless @key_type.assignable?(o.key_type, guard) && @value_type.assignable?(o.value_type, guard)
2863
- super
2864
- when PStructType
2865
- # hash must accept String as key type
2866
- # hash must accept all value types
2867
- # hash must accept the size of the struct
2868
- o_elements = o.elements
2869
- (size_type || DEFAULT_SIZE).instance?(o_elements.size, guard) &&
2870
- o_elements.all? {|e| @key_type.instance?(e.name, guard) && @value_type.assignable?(e.value_type, guard) }
2871
- else
2872
- false
2873
- end
2874
- end
2875
- end
2876
-
2877
- # A flexible type describing an any? of other types
2878
- # @api public
2879
- #
2880
- class PVariantType < PAnyType
2881
- include Enumerable
2882
-
2883
- def self.register_ptype(loader, ir)
2884
- create_ptype(loader, ir, 'AnyType', 'types' => PArrayType.new(PTypeType::DEFAULT))
2885
- end
2886
-
2887
- attr_reader :types
2888
-
2889
- # Checks if the number of unique types in the given array is greater than one, and if so
2890
- # creates a Variant with those types and returns it. If only one unique type is found,
2891
- # that type is instead returned.
2892
- #
2893
- # @param types [Array<PAnyType>] the variants
2894
- # @return [PAnyType] the resulting type
2895
- # @api public
2896
- def self.maybe_create(types)
2897
- types = flatten_variants(types).uniq
2898
- types.size == 1 ? types[0] : new(types)
2899
- end
2900
-
2901
- # @param types [Array[PAnyType]] the variants
2902
- def initialize(types)
2903
- @types = types.freeze
2904
- end
2905
-
2906
- def accept(visitor, guard)
2907
- super
2908
- @types.each { |t| t.accept(visitor, guard) }
2909
- end
2910
-
2911
- def each
2912
- if block_given?
2913
- types.each { |t| yield t }
2914
- else
2915
- types.to_enum
2916
- end
2917
- end
2918
-
2919
- def generalize
2920
- if self == DEFAULT
2921
- self
2922
- else
2923
- alter_type_array(@types, :generalize) { |altered| PVariantType.maybe_create(altered) }
2924
- end
2925
- end
2926
-
2927
- def normalize(guard = nil)
2928
- if self == DEFAULT || @types.empty?
2929
- self
2930
- else
2931
- # Normalize all contained types
2932
- modified = false
2933
- types = alter_type_array(@types, :normalize, guard)
2934
- if types == self
2935
- types = @types
2936
- else
2937
- modified = true
2938
- end
2939
-
2940
- if types.size == 1
2941
- types[0]
2942
- elsif types.any? { |t| t.is_a?(PUndefType) || t.is_a?(POptionalType) }
2943
- # Undef entry present. Use an OptionalType with a normalized Variant without Undefs and Optional wrappers
2944
- POptionalType.new(PVariantType.maybe_create(types.reject { |t| t.is_a?(PUndefType) }.map { |t| t.is_a?(POptionalType) ? t.type : t })).normalize
2945
- else
2946
- # Merge all variants into this one
2947
- types = PVariantType.flatten_variants(types)
2948
- size_before_merge = types.size
2949
-
2950
- types = swap_not_undefs(types)
2951
- types = merge_enums(types)
2952
- types = merge_patterns(types)
2953
- types = merge_version_ranges(types)
2954
- types = merge_numbers(PIntegerType, types)
2955
- types = merge_numbers(PFloatType, types)
2956
- types = merge_numbers(PTimespanType, types)
2957
- types = merge_numbers(PTimestampType, types)
2958
-
2959
- if types.size == 1
2960
- types[0]
2961
- else
2962
- modified || types.size != size_before_merge ? PVariantType.maybe_create(types) : self
2963
- end
2964
- end
2965
- end
2966
- end
2967
-
2968
- def self.flatten_variants(types)
2969
- modified = false
2970
- types = types.map do |t|
2971
- if t.is_a?(PVariantType)
2972
- modified = true
2973
- t.types
2974
- else
2975
- t
2976
- end
2977
- end
2978
- types.flatten! if modified
2979
- types
2980
- end
2981
-
2982
- def hash
2983
- @types.hash
2984
- end
2985
-
2986
- def instance?(o, guard = nil)
2987
- # instance of variant if o is instance? of any of variant's types
2988
- @types.any? { |type| type.instance?(o, guard) }
2989
- end
2990
-
2991
- def really_instance?(o, guard = nil)
2992
- @types.reduce(-1) do |memo, type|
2993
- ri = type.really_instance?(o, guard)
2994
- break ri if ri > 0
2995
- ri > memo ? ri : memo
2996
- end
2997
- end
2998
-
2999
- def kind_of_callable?(optional = true, guard = nil)
3000
- @types.all? { |type| type.kind_of_callable?(optional, guard) }
3001
- end
3002
-
3003
- def eql?(o)
3004
- self.class == o.class && @types.size == o.types.size && (@types - o.types).empty?
3005
- end
3006
-
3007
- DEFAULT = PVariantType.new(EMPTY_ARRAY)
3008
-
3009
- def assignable?(o, guard = nil)
3010
- # an empty Variant does not match Undef (it is void - not even undef)
3011
- if o.is_a?(PUndefType) && types.empty?
3012
- return false
3013
- end
3014
-
3015
- return super unless o.is_a?(PVariantType)
3016
- # If empty, all Variant types match irrespective of the types they hold (including being empty)
3017
- return true if types.empty?
3018
- # Since this variant is not empty, an empty Variant cannot match, because it matches nothing
3019
- # otherwise all types in o must be assignable to this
3020
- !o.types.empty? && o.types.all? { |vt| super(vt, guard) }
3021
- end
3022
-
3023
- protected
3024
-
3025
- # @api private
3026
- def _assignable?(o, guard)
3027
- # A variant is assignable if o is assignable to any of its types
3028
- types.any? { |option_t| option_t.assignable?(o, guard) }
3029
- end
3030
-
3031
- # @api private
3032
- def swap_not_undefs(array)
3033
- if array.size > 1
3034
- parts = array.partition {|t| t.is_a?(PNotUndefType) }
3035
- not_undefs = parts[0]
3036
- if not_undefs.size > 1
3037
- others = parts[1]
3038
- others << PNotUndefType.new(PVariantType.maybe_create(not_undefs.map { |not_undef| not_undef.type }).normalize)
3039
- array = others
3040
- end
3041
- end
3042
- array
3043
- end
3044
-
3045
- # @api private
3046
- def merge_enums(array)
3047
- # Merge case sensitive enums and strings
3048
- if array.size > 1
3049
- parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? && !t.case_insensitive? || t.is_a?(PStringType) && !t.value.nil? }
3050
- enums = parts[0]
3051
- if enums.size > 1
3052
- others = parts[1]
3053
- others << PEnumType.new(enums.map { |enum| enum.is_a?(PStringType) ? enum.value : enum.values }.flatten.uniq)
3054
- array = others
3055
- end
3056
- end
3057
-
3058
- # Merge case insensitive enums
3059
- if array.size > 1
3060
- parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? && t.case_insensitive? }
3061
- enums = parts[0]
3062
- if enums.size > 1
3063
- others = parts[1]
3064
- values = []
3065
- enums.each { |enum| enum.values.each { |value| values << value.downcase }}
3066
- values.uniq!
3067
- others << PEnumType.new(values, true)
3068
- array = others
3069
- end
3070
- end
3071
- array
3072
- end
3073
-
3074
- # @api private
3075
- def merge_patterns(array)
3076
- if array.size > 1
3077
- parts = array.partition {|t| t.is_a?(PPatternType) }
3078
- patterns = parts[0]
3079
- if patterns.size > 1
3080
- others = parts[1]
3081
- others << PPatternType.new(patterns.map { |pattern| pattern.patterns }.flatten.uniq)
3082
- array = others
3083
- end
3084
- end
3085
- array
3086
- end
3087
-
3088
- # @api private
3089
- def merge_numbers(clazz, array)
3090
- if array.size > 1
3091
- parts = array.partition {|t| t.is_a?(clazz) }
3092
- ranges = parts[0]
3093
- array = merge_ranges(ranges) + parts[1] if ranges.size > 1
3094
- end
3095
- array
3096
- end
3097
-
3098
- def merge_version_ranges(array)
3099
- if array.size > 1
3100
- parts = array.partition {|t| t.is_a?(PSemVerType) }
3101
- ranges = parts[0]
3102
- array = [PSemVerType.new(ranges.map(&:ranges).flatten)] + parts[1] if ranges.size > 1
3103
- end
3104
- array
3105
- end
3106
-
3107
- # @api private
3108
- def merge_ranges(ranges)
3109
- result = []
3110
- until ranges.empty?
3111
- unmerged = []
3112
- x = ranges.pop
3113
- result << ranges.inject(x) do |memo, y|
3114
- merged = memo.merge(y)
3115
- if merged.nil?
3116
- unmerged << y
3117
- else
3118
- memo = merged
3119
- end
3120
- memo
3121
- end
3122
- ranges = unmerged
3123
- end
3124
- result
3125
- end
3126
- end
3127
-
3128
- # Abstract representation of a type that can be placed in a Catalog.
3129
- # @api public
3130
- #
3131
- class PCatalogEntryType < PAnyType
3132
- def self.register_ptype(loader, ir)
3133
- create_ptype(loader, ir, 'AnyType')
3134
- end
3135
-
3136
- DEFAULT = PCatalogEntryType.new
3137
-
3138
- def instance?(o, guard = nil)
3139
- assignable?(TypeCalculator.infer(o), guard)
3140
- end
3141
-
3142
- protected
3143
- # @api private
3144
- def _assignable?(o, guard)
3145
- o.is_a?(PCatalogEntryType)
3146
- end
3147
- end
3148
-
3149
- # Represents a (host-) class in the Puppet Language.
3150
- # @api public
3151
- #
3152
- class PClassType < PCatalogEntryType
3153
- attr_reader :class_name
3154
-
3155
- def self.register_ptype(loader, ir)
3156
- create_ptype(loader, ir, 'CatalogEntryType',
3157
- 'class_name' => {
3158
- KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
3159
- KEY_VALUE => nil
3160
- }
3161
- )
3162
- end
3163
-
3164
- def initialize(class_name)
3165
- @class_name = class_name
3166
- end
3167
-
3168
- def hash
3169
- 11 ^ @class_name.hash
3170
- end
3171
- def eql?(o)
3172
- self.class == o.class && @class_name == o.class_name
3173
- end
3174
-
3175
- DEFAULT = PClassType.new(nil)
3176
-
3177
- protected
3178
-
3179
- # @api private
3180
- def _assignable?(o, guard)
3181
- return false unless o.is_a?(PClassType)
3182
- # Class = Class[name}, Class[name] != Class
3183
- return true if @class_name.nil?
3184
- # Class[name] = Class[name]
3185
- @class_name == o.class_name
3186
- end
3187
- end
3188
-
3189
- # For backward compatibility
3190
- PHostClassType = PClassType
3191
-
3192
-
3193
- # Represents a Resource Type in the Puppet Language
3194
- # @api public
3195
- #
3196
- class PResourceType < PCatalogEntryType
3197
-
3198
- def self.register_ptype(loader, ir)
3199
- create_ptype(loader, ir, 'CatalogEntryType',
3200
- 'type_name' => {
3201
- KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
3202
- KEY_VALUE => nil
3203
- },
3204
- 'title' => {
3205
- KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
3206
- KEY_VALUE => nil
3207
- }
3208
- )
3209
- end
3210
-
3211
- attr_reader :type_name, :title, :downcased_name
3212
-
3213
- def initialize(type_name, title = nil)
3214
- @type_name = type_name.freeze
3215
- @title = title.freeze
3216
- @downcased_name = type_name.nil? ? nil : @type_name.downcase.freeze
3217
- end
3218
-
3219
- def eql?(o)
3220
- self.class == o.class && @downcased_name == o.downcased_name && @title == o.title
3221
- end
3222
-
3223
- def hash
3224
- @downcased_name.hash ^ @title.hash
3225
- end
3226
-
3227
- DEFAULT = PResourceType.new(nil)
3228
-
3229
- protected
3230
-
3231
- # @api private
3232
- def _assignable?(o, guard)
3233
- o.is_a?(PResourceType) && (@downcased_name.nil? || @downcased_name == o.downcased_name && (@title.nil? || @title == o.title))
3234
- end
3235
- end
3236
-
3237
- # Represents a type that accept PUndefType instead of the type parameter
3238
- # required_type - is a short hand for Variant[T, Undef]
3239
- # @api public
3240
- #
3241
- class POptionalType < PTypeWithContainedType
3242
-
3243
- def self.register_ptype(loader, ir)
3244
- create_ptype(loader, ir, 'AnyType',
3245
- 'type' => {
3246
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
3247
- KEY_VALUE => nil
3248
- }
3249
- )
3250
- end
3251
-
3252
- def optional_type
3253
- @type
3254
- end
3255
-
3256
- def kind_of_callable?(optional=true, guard = nil)
3257
- optional && !@type.nil? && @type.kind_of_callable?(optional, guard)
3258
- end
3259
-
3260
- def instance?(o, guard = nil)
3261
- PUndefType::DEFAULT.instance?(o, guard) || (!@type.nil? && @type.instance?(o, guard))
3262
- end
3263
-
3264
- def normalize(guard = nil)
3265
- n = super
3266
- if n.type.nil?
3267
- n
3268
- else
3269
- if n.type.is_a?(PNotUndefType)
3270
- # No point in having an NotUndef in an Optional
3271
- POptionalType.new(n.type.type).normalize
3272
- elsif n.type.assignable?(PUndefType::DEFAULT)
3273
- # THe type is Optional anyway, so it can be stripped of
3274
- n.type
3275
- else
3276
- n
3277
- end
3278
- end
3279
- end
3280
-
3281
- def new_function
3282
- optional_type.new_function
3283
- end
3284
-
3285
- DEFAULT = POptionalType.new(nil)
3286
-
3287
- protected
3288
-
3289
- # @api private
3290
- def _assignable?(o, guard)
3291
- return true if o.is_a?(PUndefType)
3292
- return true if @type.nil?
3293
- if o.is_a?(POptionalType)
3294
- @type.assignable?(o.optional_type, guard)
3295
- else
3296
- @type.assignable?(o, guard)
3297
- end
3298
- end
3299
- end
3300
-
3301
- class PTypeReferenceType < PAnyType
3302
-
3303
- def self.register_ptype(loader, ir)
3304
- create_ptype(loader, ir, 'AnyType', 'type_string' => PStringType::NON_EMPTY)
3305
- end
3306
-
3307
- attr_reader :type_string
3308
-
3309
- def initialize(type_string)
3310
- @type_string = type_string
3311
- end
3312
-
3313
- def callable?(args)
3314
- false
3315
- end
3316
-
3317
- def instance?(o, guard = nil)
3318
- false
3319
- end
3320
-
3321
- def hash
3322
- @type_string.hash
3323
- end
3324
-
3325
- def eql?(o)
3326
- super && o.type_string == @type_string
3327
- end
3328
-
3329
- def resolve(loader)
3330
- TypeParser.singleton.parse(@type_string, loader)
3331
- end
3332
-
3333
- protected
3334
-
3335
- def _assignable?(o, guard)
3336
- # A type must be assignable to itself or a lot of unit tests will break
3337
- o == self
3338
- end
3339
-
3340
- DEFAULT = PTypeReferenceType.new('UnresolvedReference')
3341
- end
3342
-
3343
- # Describes a named alias for another Type.
3344
- # The alias is created with a name and an unresolved type expression. The type expression may
3345
- # in turn contain other aliases (including the alias that contains it) which means that an alias
3346
- # might contain self recursion. Whether or not that is the case is computed and remembered when the alias
3347
- # is resolved since guarding against self recursive constructs is relatively expensive.
3348
- #
3349
- # @api public
3350
- class PTypeAliasType < PAnyType
3351
-
3352
- def self.register_ptype(loader, ir)
3353
- create_ptype(loader, ir, 'AnyType',
3354
- 'name' => PStringType::NON_EMPTY,
3355
- 'type_expr' => PAnyType::DEFAULT,
3356
- 'resolved_type' => {
3357
- KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
3358
- KEY_VALUE => nil
3359
- }
3360
- )
3361
- end
3362
-
3363
- attr_reader :loader, :name
3364
-
3365
- # @param name [String] The name of the type
3366
- # @param type_expr [Model::PopsObject] The expression that describes the aliased type
3367
- # @param resolved_type [PAnyType] the resolve type (only used for the DEFAULT initialization)
3368
- def initialize(name, type_expr, resolved_type = nil)
3369
- @name = name
3370
- @type_expr = type_expr
3371
- @resolved_type = resolved_type
3372
- @self_recursion = false
3373
- end
3374
-
3375
- def assignable?(o, guard = nil)
3376
- if @self_recursion
3377
- guard ||= RecursionGuard.new
3378
- guard.with_this(self) { |state| state == RecursionGuard::SELF_RECURSION_IN_BOTH ? true : super(o, guard) }
3379
- else
3380
- super(o, guard)
3381
- end
3382
- end
3383
-
3384
- # Returns the resolved type. The type must have been resolved by a call prior to calls to this
3385
- # method or an error will be raised.
3386
- #
3387
- # @return [PAnyType] The resolved type of this alias.
3388
- # @raise [Puppet::Error] unless the type has been resolved prior to calling this method
3389
- def resolved_type
3390
- raise Puppet::Error, "Reference to unresolved type #{@name}" unless @resolved_type
3391
- @resolved_type
3392
- end
3393
-
3394
- def callable_args?(callable, guard)
3395
- guarded_recursion(guard, false) { |g| resolved_type.callable_args?(callable, g) }
3396
- end
3397
-
3398
- def check_self_recursion(originator)
3399
- resolved_type.check_self_recursion(originator) unless originator.equal?(self)
3400
- end
3401
-
3402
- def kind_of_callable?(optional=true, guard = nil)
3403
- guarded_recursion(guard, false) { |g| resolved_type.kind_of_callable?(optional, g) }
3404
- end
3405
-
3406
- def instance?(o, guard = nil)
3407
- really_instance?(o, guard) == 1
3408
- end
3409
-
3410
- def iterable?(guard = nil)
3411
- guarded_recursion(guard, false) { |g| resolved_type.iterable?(g) }
3412
- end
3413
-
3414
- def iterable_type(guard = nil)
3415
- guarded_recursion(guard, nil) { |g| resolved_type.iterable_type(g) }
3416
- end
3417
-
3418
- def hash
3419
- @name.hash
3420
- end
3421
-
3422
- # Acceptor used when checking for self recursion and that a type contains
3423
- # something other than aliases or type references
3424
- #
3425
- # @api private
3426
- class AssertOtherTypeAcceptor
3427
- def initialize
3428
- @other_type_detected = false
3429
- end
3430
-
3431
- def visit(type, _)
3432
- unless type.is_a?(PTypeAliasType) || type.is_a?(PVariantType)
3433
- @other_type_detected = true
3434
- end
3435
- end
3436
-
3437
- def other_type_detected?
3438
- @other_type_detected
3439
- end
3440
- end
3441
-
3442
- # Acceptor used when re-checking for self recursion after a self recursion has been detected
3443
- #
3444
- # @api private
3445
- class AssertSelfRecursionStatusAcceptor
3446
- def visit(type, _)
3447
- type.set_self_recursion_status if type.is_a?(PTypeAliasType)
3448
- end
3449
- end
3450
-
3451
- def set_self_recursion_status
3452
- return if @self_recursion || @resolved_type.is_a?(PTypeReferenceType)
3453
- @self_recursion = true
3454
- guard = RecursionGuard.new
3455
- accept(NoopTypeAcceptor::INSTANCE, guard)
3456
- @self_recursion = guard.recursive_this?(self)
3457
- when_self_recursion_detected if @self_recursion # no difference
3458
- end
3459
-
3460
- # Called from the TypeParser once it has found a type using the Loader. The TypeParser will
3461
- # interpret the contained expression and the resolved type is remembered. This method also
3462
- # checks and remembers if the resolve type contains self recursion.
3463
- #
3464
- # @param type_parser [TypeParser] type parser that will interpret the type expression
3465
- # @param loader [Loader::Loader] loader to use when loading type aliases
3466
- # @return [PTypeAliasType] the receiver of the call, i.e. `self`
3467
- # @api private
3468
- def resolve(loader)
3469
- @loader = loader
3470
- if @resolved_type.nil?
3471
- # resolved to PTypeReferenceType::DEFAULT during resolve to avoid endless recursion
3472
- @resolved_type = PTypeReferenceType::DEFAULT
3473
- @self_recursion = true # assumed while it being found out below
3474
- begin
3475
- if @type_expr.is_a?(PTypeReferenceType)
3476
- @resolved_type = @type_expr.resolve(loader)
3477
- else
3478
- @resolved_type = TypeParser.singleton.interpret(@type_expr, loader).normalize
3479
- end
3480
-
3481
- # Find out if this type is recursive. A recursive type has performance implications
3482
- # on several methods and this knowledge is used to avoid that for non-recursive
3483
- # types.
3484
- guard = RecursionGuard.new
3485
- real_type_asserter = AssertOtherTypeAcceptor.new
3486
- accept(real_type_asserter, guard)
3487
- unless real_type_asserter.other_type_detected?
3488
- raise ArgumentError, "Type alias '#{name}' cannot be resolved to a real type"
3489
- end
3490
- @self_recursion = guard.recursive_this?(self)
3491
- # All aliases involved must re-check status since this alias is now resolved
3492
- if @self_recursion
3493
- accept(AssertSelfRecursionStatusAcceptor.new, RecursionGuard.new)
3494
- when_self_recursion_detected
3495
- end
3496
- rescue
3497
- @resolved_type = nil
3498
- raise
3499
- end
3500
- else
3501
- # An alias may appoint an Object type that isn't resolved yet. The default type
3502
- # reference is used to prevent endless recursion and should not be resolved here.
3503
- @resolved_type.resolve(loader) unless @resolved_type.equal?(PTypeReferenceType::DEFAULT)
3504
- end
3505
- self
3506
- end
3507
-
3508
- def eql?(o)
3509
- super && o.name == @name
3510
- end
3511
-
3512
- def accept(visitor, guard)
3513
- guarded_recursion(guard, nil) do |g|
3514
- super(visitor, g)
3515
- @resolved_type.accept(visitor, g) unless @resolved_type.nil?
3516
- end
3517
- end
3518
-
3519
- def self_recursion?
3520
- @self_recursion
3521
- end
3522
-
3523
- # Returns the expanded string the form of the alias, e.g. <alias name> = <resolved type>
3524
- #
3525
- # @return [String] the expanded form of this alias
3526
- # @api public
3527
- def to_s
3528
- TypeFormatter.singleton.alias_expanded_string(self)
3529
- end
3530
-
3531
- # Delegates to resolved type
3532
- def respond_to_missing?(name, include_private)
3533
- resolved_type.respond_to?(name, include_private)
3534
- end
3535
-
3536
- # Delegates to resolved type
3537
- def method_missing(name, *arguments, &block)
3538
- super if @resolved_type.equal?(PTypeReferenceType::DEFAULT)
3539
- resolved_type.send(name, *arguments, &block)
3540
- end
3541
-
3542
- # @api private
3543
- def really_instance?(o, guard = nil)
3544
- if @self_recursion
3545
- guard ||= RecursionGuard.new
3546
- guard.with_that(o) do
3547
- guard.with_this(self) { |state| state == RecursionGuard::SELF_RECURSION_IN_BOTH ? 0 : resolved_type.really_instance?(o, guard) }
3548
- end
3549
- else
3550
- resolved_type.really_instance?(o, guard)
3551
- end
3552
- end
3553
-
3554
- # @return `nil` to prevent serialization of the type_expr used when first initializing this instance
3555
- # @api private
3556
- def type_expr
3557
- nil
3558
- end
3559
-
3560
- protected
3561
-
3562
- def _assignable?(o, guard)
3563
- resolved_type.assignable?(o, guard)
3564
- end
3565
-
3566
- def new_function
3567
- resolved_type.new_function
3568
- end
3569
-
3570
- private
3571
-
3572
- def guarded_recursion(guard, dflt)
3573
- if @self_recursion
3574
- guard ||= RecursionGuard.new
3575
- guard.with_this(self) { |state| (state & RecursionGuard::SELF_RECURSION_IN_THIS) == 0 ? yield(guard) : dflt }
3576
- else
3577
- yield(guard)
3578
- end
3579
- end
3580
-
3581
- def when_self_recursion_detected
3582
- if @resolved_type.is_a?(PVariantType)
3583
- # Drop variants that are not real types
3584
- resolved_types = @resolved_type.types
3585
- real_types = resolved_types.select do |type|
3586
- next false if type == self
3587
- real_type_asserter = AssertOtherTypeAcceptor.new
3588
- type.accept(real_type_asserter, RecursionGuard.new)
3589
- real_type_asserter.other_type_detected?
3590
- end
3591
- if real_types.size != resolved_types.size
3592
- if real_types.size == 1
3593
- @resolved_type = real_types[0]
3594
- else
3595
- @resolved_type = PVariantType.maybe_create(real_types)
3596
- end
3597
- # Drop self recursion status in case it's not self recursive anymore
3598
- guard = RecursionGuard.new
3599
- accept(NoopTypeAcceptor::INSTANCE, guard)
3600
- @self_recursion = guard.recursive_this?(self)
3601
- end
3602
- end
3603
- @resolved_type.check_self_recursion(self) if @self_recursion
3604
- end
3605
-
3606
- DEFAULT = PTypeAliasType.new('UnresolvedAlias', nil, PTypeReferenceType::DEFAULT)
3607
- end
3608
- end
3609
- end
3610
-
3611
- require 'puppet/pops/pcore'
3612
-
3613
- require_relative 'annotatable'
3614
- require_relative 'p_meta_type'
3615
- require_relative 'p_object_type'
3616
- require_relative 'annotation'
3617
- require_relative 'ruby_method'
3618
- require_relative 'p_runtime_type'
3619
- require_relative 'p_sem_ver_type'
3620
- require_relative 'p_sem_ver_range_type'
3621
- require_relative 'p_sensitive_type'
3622
- require_relative 'p_type_set_type'
3623
- require_relative 'p_timespan_type'
3624
- require_relative 'p_timestamp_type'
3625
- require_relative 'p_binary_type'
3626
- require_relative 'p_init_type'
3627
- require_relative 'p_object_type_extension'
3628
- require_relative 'p_uri_type'
3629
- require_relative 'type_set_reference'
3630
- require_relative 'implementation_registry'
3631
- require_relative 'tree_iterators'