puppet 3.3.2 → 3.4.0.rc1

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

Potentially problematic release.


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

Files changed (589) hide show
  1. data/CONTRIBUTING.md +22 -0
  2. data/Gemfile +11 -2
  3. data/README.md +13 -17
  4. data/README_DEVELOPER.md +1 -1
  5. data/Rakefile +1 -1
  6. data/examples/hiera/README.md +4 -4
  7. data/ext/debian/puppetmaster.init +1 -0
  8. data/ext/debian/rules +2 -5
  9. data/ext/nagios/check_puppet.rb +7 -7
  10. data/ext/osx/file_mapping.yaml +1 -1
  11. data/ext/osx/preflight.erb +34 -19
  12. data/ext/rack/{files/config.ru → config.ru} +0 -0
  13. data/ext/rack/{files/apache2.conf → example-passenger-vhost.conf} +6 -0
  14. data/ext/redhat/puppet.spec.erb +20 -2
  15. data/ext/systemd/{puppetagent.service → puppet.service} +0 -0
  16. data/lib/hiera_puppet.rb +2 -2
  17. data/lib/puppet/agent.rb +1 -6
  18. data/lib/puppet/application.rb +15 -2
  19. data/lib/puppet/application/agent.rb +2 -7
  20. data/lib/puppet/application/apply.rb +8 -13
  21. data/lib/puppet/application/cert.rb +47 -7
  22. data/lib/puppet/application/device.rb +1 -6
  23. data/lib/puppet/application/face_base.rb +1 -1
  24. data/lib/puppet/application/filebucket.rb +1 -1
  25. data/lib/puppet/application/inspect.rb +3 -12
  26. data/lib/puppet/application/master.rb +1 -6
  27. data/lib/puppet/application/queue.rb +1 -6
  28. data/lib/puppet/application/resource.rb +2 -6
  29. data/lib/puppet/coercion.rb +11 -0
  30. data/lib/puppet/configurer.rb +5 -3
  31. data/lib/puppet/configurer/downloader.rb +3 -1
  32. data/lib/puppet/configurer/plugin_handler.rb +10 -0
  33. data/lib/puppet/confine.rb +80 -0
  34. data/lib/puppet/{provider/confine → confine}/exists.rb +3 -3
  35. data/lib/puppet/{provider/confine → confine}/false.rb +2 -2
  36. data/lib/puppet/{provider/confine → confine}/feature.rb +2 -2
  37. data/lib/puppet/{provider/confine → confine}/true.rb +2 -2
  38. data/lib/puppet/{provider/confine → confine}/variable.rb +2 -2
  39. data/lib/puppet/{provider/confine_collection.rb → confine_collection.rb} +4 -4
  40. data/lib/puppet/{provider/confiner.rb → confiner.rb} +4 -4
  41. data/lib/puppet/daemon.rb +2 -6
  42. data/lib/puppet/data_binding.rb +2 -30
  43. data/lib/puppet/defaults.rb +283 -174
  44. data/lib/puppet/error.rb +1 -0
  45. data/lib/puppet/external/nagios.rb +0 -2
  46. data/lib/puppet/external/nagios/base.rb +4 -3
  47. data/lib/puppet/external/nagios/grammar.ry +173 -112
  48. data/lib/puppet/external/nagios/parser.rb +233 -184
  49. data/lib/puppet/face/file/store.rb +1 -1
  50. data/lib/puppet/face/module/generate.rb +5 -7
  51. data/lib/puppet/face/parser.rb +12 -2
  52. data/lib/puppet/face/plugin.rb +6 -0
  53. data/lib/puppet/feature/base.rb +16 -0
  54. data/lib/puppet/feature/external_facts.rb +5 -0
  55. data/lib/puppet/feature/libuser.rb +1 -1
  56. data/lib/puppet/feature/msgpack.rb +1 -0
  57. data/lib/puppet/feature/rails.rb +2 -2
  58. data/lib/puppet/file_bucket/dipper.rb +8 -6
  59. data/lib/puppet/file_bucket/file.rb +17 -1
  60. data/lib/puppet/file_serving/base.rb +21 -10
  61. data/lib/puppet/file_serving/configuration.rb +5 -7
  62. data/lib/puppet/file_serving/configuration/parser.rb +1 -1
  63. data/lib/puppet/file_serving/content.rb +1 -1
  64. data/lib/puppet/file_serving/fileset.rb +3 -3
  65. data/lib/puppet/file_serving/metadata.rb +22 -18
  66. data/lib/puppet/file_serving/mount/file.rb +1 -1
  67. data/lib/puppet/file_serving/mount/pluginfacts.rb +35 -0
  68. data/lib/puppet/file_system.rb +3 -0
  69. data/lib/puppet/file_system/file.rb +261 -0
  70. data/lib/puppet/file_system/file18.rb +5 -0
  71. data/lib/puppet/file_system/file19.rb +5 -0
  72. data/lib/puppet/file_system/file19windows.rb +113 -0
  73. data/lib/puppet/file_system/memory_file.rb +31 -0
  74. data/lib/puppet/file_system/tempfile.rb +20 -0
  75. data/lib/puppet/indirector/active_record.rb +1 -0
  76. data/lib/puppet/indirector/catalog/compiler.rb +28 -0
  77. data/lib/puppet/indirector/certificate_request/memory.rb +6 -0
  78. data/lib/puppet/indirector/data_binding/hiera.rb +46 -2
  79. data/lib/puppet/indirector/direct_file_server.rb +2 -2
  80. data/lib/puppet/indirector/facts/facter.rb +25 -0
  81. data/lib/puppet/indirector/file_bucket_file/file.rb +60 -74
  82. data/lib/puppet/indirector/indirection.rb +5 -1
  83. data/lib/puppet/indirector/json.rb +1 -1
  84. data/lib/puppet/indirector/key/ca.rb +4 -0
  85. data/lib/puppet/indirector/key/file.rb +7 -3
  86. data/lib/puppet/indirector/key/memory.rb +6 -0
  87. data/lib/puppet/indirector/node/write_only_yaml.rb +2 -2
  88. data/lib/puppet/indirector/request.rb +17 -11
  89. data/lib/puppet/indirector/resource/ral.rb +5 -0
  90. data/lib/puppet/indirector/resource/rest.rb +1 -0
  91. data/lib/puppet/indirector/resource/store_configs.rb +4 -0
  92. data/lib/puppet/indirector/rest.rb +2 -1
  93. data/lib/puppet/indirector/ssl_file.rb +7 -7
  94. data/lib/puppet/indirector/terminus.rb +4 -0
  95. data/lib/puppet/indirector/yaml.rb +3 -3
  96. data/lib/puppet/interface/documentation.rb +4 -11
  97. data/lib/puppet/module.rb +19 -6
  98. data/lib/puppet/module_tool/applications/builder.rb +1 -1
  99. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  100. data/lib/puppet/module_tool/checksums.rb +1 -1
  101. data/lib/puppet/module_tool/dependency.rb +7 -3
  102. data/lib/puppet/module_tool/metadata.rb +6 -2
  103. data/lib/puppet/module_tool/tar.rb +2 -1
  104. data/lib/puppet/module_tool/tar/gnu.rb +6 -2
  105. data/lib/puppet/module_tool/tar/mini.rb +2 -0
  106. data/lib/puppet/module_tool/tar/solaris.rb +2 -5
  107. data/lib/puppet/network/authconfig.rb +0 -2
  108. data/lib/puppet/network/authentication.rb +1 -1
  109. data/lib/puppet/network/authstore.rb +6 -7
  110. data/lib/puppet/network/format.rb +2 -3
  111. data/lib/puppet/network/format_handler.rb +16 -11
  112. data/lib/puppet/network/format_support.rb +14 -0
  113. data/lib/puppet/network/formats.rb +26 -0
  114. data/lib/puppet/network/http/connection.rb +8 -41
  115. data/lib/puppet/network/http/handler.rb +28 -32
  116. data/lib/puppet/network/http/webrick.rb +15 -22
  117. data/lib/puppet/network/http_pool.rb +43 -9
  118. data/lib/puppet/network/rights.rb +0 -0
  119. data/lib/puppet/node.rb +24 -8
  120. data/lib/puppet/node/environment.rb +18 -20
  121. data/lib/puppet/node/facts.rb +23 -6
  122. data/lib/puppet/parameter.rb +15 -2
  123. data/lib/puppet/parameter/boolean.rb +5 -0
  124. data/lib/puppet/parameter/value_collection.rb +6 -4
  125. data/lib/puppet/parser/ast/resourceparam.rb +2 -1
  126. data/lib/puppet/parser/compiler.rb +25 -9
  127. data/lib/puppet/parser/files.rb +1 -1
  128. data/lib/puppet/parser/functions.rb +12 -21
  129. data/lib/puppet/parser/functions/collect.rb +6 -35
  130. data/lib/puppet/parser/functions/contain.rb +26 -0
  131. data/lib/puppet/parser/functions/create_resources.rb +5 -0
  132. data/lib/puppet/parser/functions/extlookup.rb +2 -2
  133. data/lib/puppet/parser/functions/file.rb +1 -1
  134. data/lib/puppet/parser/functions/{reject.rb → filter.rb} +13 -12
  135. data/lib/puppet/parser/functions/fqdn_rand.rb +13 -5
  136. data/lib/puppet/parser/functions/include.rb +18 -1
  137. data/lib/puppet/parser/functions/map.rb +44 -0
  138. data/lib/puppet/parser/functions/select.rb +6 -38
  139. data/lib/puppet/parser/lexer.rb +1 -1
  140. data/lib/puppet/parser/parser_support.rb +1 -1
  141. data/lib/puppet/parser/resource.rb +6 -45
  142. data/lib/puppet/parser/scope.rb +33 -2
  143. data/lib/puppet/parser/type_loader.rb +4 -60
  144. data/lib/puppet/pops/binder/bindings_loader.rb +1 -1
  145. data/lib/puppet/pops/binder/config/binder_config.rb +3 -3
  146. data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +1 -1
  147. data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +1 -1
  148. data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +2 -2
  149. data/lib/puppet/pops/issues.rb +4 -0
  150. data/lib/puppet/pops/model/ast_transformer.rb +4 -1
  151. data/lib/puppet/pops/model/model_label_provider.rb +1 -1
  152. data/lib/puppet/pops/parser/egrammar.ra +5 -24
  153. data/lib/puppet/pops/parser/eparser.rb +859 -902
  154. data/lib/puppet/pops/parser/lexer.rb +48 -30
  155. data/lib/puppet/pops/parser/parser_support.rb +1 -1
  156. data/lib/puppet/pops/patterns.rb +4 -4
  157. data/lib/puppet/pops/utils.rb +1 -1
  158. data/lib/puppet/pops/validation/checker3_1.rb +25 -20
  159. data/lib/puppet/provider.rb +23 -6
  160. data/lib/puppet/provider/aixobject.rb +0 -0
  161. data/lib/puppet/provider/augeas/augeas.rb +21 -5
  162. data/lib/puppet/provider/confine.rb +5 -79
  163. data/lib/puppet/provider/cron/crontab.rb +0 -0
  164. data/lib/puppet/provider/exec.rb +9 -7
  165. data/lib/puppet/provider/exec/posix.rb +10 -1
  166. data/lib/puppet/provider/exec/windows.rb +1 -1
  167. data/lib/puppet/provider/file/posix.rb +1 -0
  168. data/lib/puppet/provider/file/windows.rb +16 -5
  169. data/lib/puppet/provider/group/aix.rb +0 -0
  170. data/lib/puppet/provider/group/windows_adsi.rb +33 -1
  171. data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
  172. data/lib/puppet/provider/mailalias/aliases.rb +0 -0
  173. data/lib/puppet/provider/maillist/mailman.rb +0 -0
  174. data/lib/puppet/provider/mount/parsed.rb +0 -0
  175. data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
  176. data/lib/puppet/provider/package/appdmg.rb +1 -1
  177. data/lib/puppet/provider/package/apple.rb +1 -1
  178. data/lib/puppet/provider/package/apt.rb +1 -1
  179. data/lib/puppet/provider/package/aptitude.rb +0 -0
  180. data/lib/puppet/provider/package/blastwave.rb +1 -1
  181. data/lib/puppet/provider/package/dpkg.rb +1 -1
  182. data/lib/puppet/provider/package/fink.rb +1 -1
  183. data/lib/puppet/provider/package/freebsd.rb +0 -0
  184. data/lib/puppet/provider/package/gem.rb +0 -0
  185. data/lib/puppet/provider/package/macports.rb +0 -0
  186. data/lib/puppet/provider/package/msi.rb +4 -10
  187. data/lib/puppet/provider/package/nim.rb +8 -8
  188. data/lib/puppet/provider/package/openbsd.rb +1 -1
  189. data/lib/puppet/provider/package/opkg.rb +0 -0
  190. data/lib/puppet/provider/package/pacman.rb +2 -2
  191. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  192. data/lib/puppet/provider/package/pkgutil.rb +1 -1
  193. data/lib/puppet/provider/package/ports.rb +0 -0
  194. data/lib/puppet/provider/package/rpm.rb +39 -3
  195. data/lib/puppet/provider/package/sun.rb +3 -3
  196. data/lib/puppet/provider/package/sunfreeware.rb +0 -0
  197. data/lib/puppet/provider/package/windows.rb +12 -19
  198. data/lib/puppet/provider/package/windows/package.rb +1 -1
  199. data/lib/puppet/provider/package/yum.rb +2 -2
  200. data/lib/puppet/provider/parsedfile.rb +0 -0
  201. data/lib/puppet/provider/port/parsed.rb +0 -0
  202. data/lib/puppet/provider/service/base.rb +0 -0
  203. data/lib/puppet/provider/service/bsd.rb +3 -3
  204. data/lib/puppet/provider/service/daemontools.rb +8 -8
  205. data/lib/puppet/provider/service/debian.rb +0 -0
  206. data/lib/puppet/provider/service/freebsd.rb +3 -3
  207. data/lib/puppet/provider/service/init.rb +5 -4
  208. data/lib/puppet/provider/service/launchd.rb +35 -24
  209. data/lib/puppet/provider/service/openbsd.rb +23 -0
  210. data/lib/puppet/provider/service/redhat.rb +0 -0
  211. data/lib/puppet/provider/service/runit.rb +3 -3
  212. data/lib/puppet/provider/service/smf.rb +0 -0
  213. data/lib/puppet/provider/service/src.rb +0 -0
  214. data/lib/puppet/provider/service/systemd.rb +0 -0
  215. data/lib/puppet/provider/service/upstart.rb +3 -3
  216. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -2
  217. data/lib/puppet/provider/sshkey/parsed.rb +0 -0
  218. data/lib/puppet/provider/user/aix.rb +0 -0
  219. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  220. data/lib/puppet/provider/user/useradd.rb +1 -1
  221. data/lib/puppet/provider/zone/solaris.rb +1 -1
  222. data/lib/puppet/rails/benchmark.rb +1 -1
  223. data/lib/puppet/reference/configuration.rb +1 -2
  224. data/lib/puppet/reference/indirection.rb +12 -14
  225. data/lib/puppet/relationship.rb +7 -4
  226. data/lib/puppet/reports.rb +2 -2
  227. data/lib/puppet/reports/rrdgraph.rb +1 -1
  228. data/lib/puppet/reports/store.rb +3 -3
  229. data/lib/puppet/reports/tagmail.rb +2 -2
  230. data/lib/puppet/resource.rb +66 -8
  231. data/lib/puppet/resource/catalog.rb +18 -25
  232. data/lib/puppet/resource/status.rb +10 -4
  233. data/lib/puppet/run.rb +6 -2
  234. data/lib/puppet/settings.rb +39 -119
  235. data/lib/puppet/settings/base_setting.rb +8 -9
  236. data/lib/puppet/settings/directory_setting.rb +8 -0
  237. data/lib/puppet/settings/file_setting.rb +35 -1
  238. data/lib/puppet/settings/priority_setting.rb +42 -0
  239. data/lib/puppet/ssl.rb +4 -0
  240. data/lib/puppet/ssl/certificate.rb +18 -0
  241. data/lib/puppet/ssl/certificate_authority.rb +101 -72
  242. data/lib/puppet/ssl/certificate_authority/autosign_command.rb +44 -0
  243. data/lib/puppet/ssl/certificate_authority/interface.rb +21 -17
  244. data/lib/puppet/ssl/certificate_factory.rb +38 -12
  245. data/lib/puppet/ssl/certificate_request.rb +201 -47
  246. data/lib/puppet/ssl/certificate_request_attributes.rb +34 -0
  247. data/lib/puppet/ssl/certificate_revocation_list.rb +2 -2
  248. data/lib/puppet/ssl/host.rb +21 -10
  249. data/lib/puppet/ssl/inventory.rb +6 -10
  250. data/lib/puppet/ssl/key.rb +1 -1
  251. data/lib/puppet/ssl/oids.rb +78 -0
  252. data/lib/puppet/ssl/validator.rb +41 -97
  253. data/lib/puppet/ssl/validator/default_validator.rb +153 -0
  254. data/lib/puppet/ssl/validator/no_validator.rb +17 -0
  255. data/lib/puppet/status.rb +4 -0
  256. data/lib/puppet/test/test_helper.rb +5 -0
  257. data/lib/puppet/transaction.rb +13 -0
  258. data/lib/puppet/transaction/event.rb +8 -3
  259. data/lib/puppet/transaction/report.rb +6 -2
  260. data/lib/puppet/transaction/resource_harness.rb +173 -115
  261. data/lib/puppet/type.rb +30 -13
  262. data/lib/puppet/type/augeas.rb +12 -46
  263. data/lib/puppet/type/component.rb +1 -7
  264. data/lib/puppet/type/cron.rb +0 -0
  265. data/lib/puppet/type/exec.rb +13 -1
  266. data/lib/puppet/type/file.rb +19 -10
  267. data/lib/puppet/type/file/checksum.rb +0 -0
  268. data/lib/puppet/type/file/content.rb +3 -0
  269. data/lib/puppet/type/file/ensure.rb +33 -15
  270. data/lib/puppet/type/file/group.rb +0 -0
  271. data/lib/puppet/type/file/mode.rb +6 -2
  272. data/lib/puppet/type/file/owner.rb +0 -0
  273. data/lib/puppet/type/file/source.rb +65 -14
  274. data/lib/puppet/type/file/target.rb +6 -6
  275. data/lib/puppet/type/file/type.rb +0 -0
  276. data/lib/puppet/type/filebucket.rb +0 -0
  277. data/lib/puppet/type/group.rb +18 -0
  278. data/lib/puppet/type/host.rb +0 -0
  279. data/lib/puppet/type/k5login.rb +4 -4
  280. data/lib/puppet/type/mailalias.rb +0 -0
  281. data/lib/puppet/type/maillist.rb +0 -0
  282. data/lib/puppet/type/mount.rb +15 -1
  283. data/lib/puppet/type/package.rb +7 -1
  284. data/lib/puppet/type/port.rb +0 -0
  285. data/lib/puppet/type/schedule.rb +9 -4
  286. data/lib/puppet/type/service.rb +1 -1
  287. data/lib/puppet/type/sshkey.rb +0 -0
  288. data/lib/puppet/type/tidy.rb +1 -1
  289. data/lib/puppet/type/user.rb +3 -0
  290. data/lib/puppet/type/yumrepo.rb +8 -6
  291. data/lib/puppet/type/zpool.rb +0 -0
  292. data/lib/puppet/util.rb +4 -31
  293. data/lib/puppet/util/adsi.rb +73 -17
  294. data/lib/puppet/util/autoload.rb +3 -3
  295. data/lib/puppet/util/backups.rb +4 -4
  296. data/lib/puppet/util/cacher.rb +7 -13
  297. data/lib/puppet/util/checksums.rb +2 -2
  298. data/lib/puppet/util/classgen.rb +3 -1
  299. data/lib/puppet/util/colors.rb +1 -0
  300. data/lib/puppet/util/command_line.rb +5 -0
  301. data/lib/puppet/util/docs.rb +33 -27
  302. data/lib/puppet/util/execution.rb +42 -18
  303. data/lib/puppet/util/filetype.rb +3 -3
  304. data/lib/puppet/util/instance_loader.rb +2 -2
  305. data/lib/puppet/util/instrumentation.rb +23 -42
  306. data/lib/puppet/util/instrumentation/data.rb +11 -4
  307. data/lib/puppet/util/instrumentation/indirection_probe.rb +11 -4
  308. data/lib/puppet/util/instrumentation/instrumentable.rb +7 -14
  309. data/lib/puppet/util/instrumentation/listener.rb +15 -8
  310. data/lib/puppet/util/instrumentation/listeners/log.rb +4 -10
  311. data/lib/puppet/util/instrumentation/listeners/performance.rb +8 -14
  312. data/lib/puppet/util/limits.rb +12 -0
  313. data/lib/puppet/util/lockfile.rb +2 -2
  314. data/lib/puppet/util/log.rb +14 -6
  315. data/lib/puppet/util/log/destinations.rb +23 -1
  316. data/lib/puppet/util/metric.rb +9 -3
  317. data/lib/puppet/util/monkey_patches.rb +7 -2
  318. data/lib/puppet/util/network_device/config.rb +1 -1
  319. data/lib/puppet/util/plugins.rb +1 -1
  320. data/lib/puppet/util/posix.rb +0 -0
  321. data/lib/puppet/util/profiler.rb +7 -2
  322. data/lib/puppet/util/provider_features.rb +2 -2
  323. data/lib/puppet/util/rdoc.rb +28 -30
  324. data/lib/puppet/util/rdoc/code_objects.rb +75 -25
  325. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  326. data/lib/puppet/util/rdoc/parser.rb +12 -487
  327. data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +477 -0
  328. data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc1.rb +19 -0
  329. data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +14 -0
  330. data/lib/puppet/util/reference.rb +1 -1
  331. data/lib/puppet/util/resource_template.rb +1 -1
  332. data/lib/puppet/util/selinux.rb +1 -1
  333. data/lib/puppet/util/storage.rb +2 -2
  334. data/lib/puppet/util/suidmanager.rb +1 -1
  335. data/lib/puppet/util/tag_set.rb +29 -0
  336. data/lib/puppet/util/tagging.rb +8 -24
  337. data/lib/puppet/util/watched_file.rb +1 -1
  338. data/lib/puppet/util/watcher.rb +1 -1
  339. data/lib/puppet/util/windows.rb +3 -0
  340. data/lib/puppet/util/windows/access_control_entry.rb +84 -0
  341. data/lib/puppet/util/windows/access_control_list.rb +106 -0
  342. data/lib/puppet/util/windows/file.rb +213 -0
  343. data/lib/puppet/util/windows/process.rb +199 -0
  344. data/lib/puppet/util/windows/root_certs.rb +52 -37
  345. data/lib/puppet/util/windows/security.rb +270 -245
  346. data/lib/puppet/util/windows/security_descriptor.rb +62 -0
  347. data/lib/puppet/util/windows/sid.rb +26 -4
  348. data/lib/puppet/version.rb +2 -2
  349. data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +1 -1
  350. data/spec/fixtures/unit/indirector/{hiera → data_binding/hiera}/global.yaml +0 -0
  351. data/spec/fixtures/unit/indirector/data_binding/hiera/invalid.yaml +1 -0
  352. data/spec/fixtures/unit/module/trailing-comma.json +24 -0
  353. data/spec/fixtures/unit/util/monkey_patches/x509.pem +32 -0
  354. data/spec/integration/application/apply_spec.rb +1 -1
  355. data/spec/integration/application/doc_spec.rb +1 -1
  356. data/spec/integration/configurer_spec.rb +4 -2
  357. data/spec/integration/data_binding.rb +100 -0
  358. data/spec/integration/indirector/catalog/compiler_spec.rb +16 -13
  359. data/spec/integration/indirector/direct_file_server_spec.rb +3 -5
  360. data/spec/integration/indirector/file_content/file_server_spec.rb +2 -2
  361. data/spec/integration/node/facts_spec.rb +1 -1
  362. data/spec/integration/node_spec.rb +1 -1
  363. data/spec/integration/parser/compiler_spec.rb +90 -0
  364. data/spec/integration/parser/parser_spec.rb +2 -2
  365. data/spec/integration/provider/cron/crontab_spec.rb +3 -5
  366. data/spec/integration/resource/catalog_spec.rb +1 -1
  367. data/spec/integration/ssl/autosign_spec.rb +90 -0
  368. data/spec/integration/ssl/certificate_authority_spec.rb +62 -69
  369. data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -1
  370. data/spec/integration/ssl/host_spec.rb +1 -1
  371. data/spec/integration/transaction_spec.rb +13 -13
  372. data/spec/integration/type/exec_spec.rb +2 -2
  373. data/spec/integration/type/file_spec.rb +287 -45
  374. data/spec/integration/type/tidy_spec.rb +3 -3
  375. data/spec/integration/util/rdoc/parser_spec.rb +236 -35
  376. data/spec/integration/util/settings_spec.rb +1 -1
  377. data/spec/integration/util/windows/process_spec.rb +22 -0
  378. data/spec/integration/util/windows/security_spec.rb +316 -106
  379. data/spec/lib/matchers/containment_matchers.rb +52 -0
  380. data/spec/lib/puppet_spec/compiler.rb +6 -0
  381. data/spec/lib/puppet_spec/files.rb +20 -21
  382. data/spec/shared_behaviours/documentation_on_faces.rb +3 -3
  383. data/spec/shared_behaviours/file_server_terminus.rb +2 -2
  384. data/spec/shared_contexts/platform.rb +1 -0
  385. data/spec/spec_helper.rb +13 -1
  386. data/spec/unit/agent_spec.rb +0 -12
  387. data/spec/unit/application/agent_spec.rb +4 -4
  388. data/spec/unit/application/apply_spec.rb +18 -2
  389. data/spec/unit/application/cert_spec.rb +8 -6
  390. data/spec/unit/application/device_spec.rb +1 -1
  391. data/spec/unit/application/filebucket_spec.rb +1 -1
  392. data/spec/unit/application/inspect_spec.rb +1 -1
  393. data/spec/unit/application_spec.rb +24 -0
  394. data/spec/unit/configurer/downloader_spec.rb +8 -7
  395. data/spec/unit/configurer/fact_handler_spec.rb +23 -0
  396. data/spec/unit/configurer/plugin_handler_spec.rb +7 -2
  397. data/spec/unit/configurer_spec.rb +15 -5
  398. data/spec/unit/{provider/confine → confine}/exists_spec.rb +12 -12
  399. data/spec/unit/{provider/confine → confine}/false_spec.rb +9 -9
  400. data/spec/unit/{provider/confine → confine}/feature_spec.rb +10 -10
  401. data/spec/unit/{provider/confine → confine}/true_spec.rb +7 -7
  402. data/spec/unit/{provider/confine → confine}/variable_spec.rb +16 -16
  403. data/spec/unit/{provider/confine_collection_spec.rb → confine_collection_spec.rb} +30 -30
  404. data/spec/unit/{provider/confine_spec.rb → confine_spec.rb} +11 -11
  405. data/spec/unit/{provider/confiner_spec.rb → confiner_spec.rb} +4 -4
  406. data/spec/unit/face/parser_spec.rb +54 -0
  407. data/spec/unit/file_bucket/dipper_spec.rb +2 -2
  408. data/spec/unit/file_serving/base_spec.rb +32 -9
  409. data/spec/unit/file_serving/configuration_spec.rb +7 -7
  410. data/spec/unit/file_serving/content_spec.rb +12 -7
  411. data/spec/unit/file_serving/fileset_spec.rb +57 -27
  412. data/spec/unit/file_serving/metadata_spec.rb +74 -12
  413. data/spec/unit/file_serving/mount/file_spec.rb +10 -10
  414. data/spec/unit/file_serving/mount/pluginfacts_spec.rb +73 -0
  415. data/spec/unit/file_system/file_spec.rb +486 -0
  416. data/spec/unit/file_system/tempfile_spec.rb +48 -0
  417. data/spec/unit/graph/relationship_graph_spec.rb +0 -6
  418. data/spec/unit/hiera_puppet_spec.rb +2 -2
  419. data/spec/unit/indirector/catalog/compiler_spec.rb +15 -19
  420. data/spec/unit/indirector/certificate_status/file_spec.rb +30 -40
  421. data/spec/unit/indirector/data_binding/hiera_spec.rb +95 -2
  422. data/spec/unit/indirector/direct_file_server_spec.rb +6 -6
  423. data/spec/unit/indirector/facts/facter_spec.rb +33 -0
  424. data/spec/unit/indirector/file_bucket_file/file_spec.rb +61 -52
  425. data/spec/unit/indirector/file_metadata/file_spec.rb +2 -2
  426. data/spec/unit/indirector/file_server_spec.rb +4 -4
  427. data/spec/unit/indirector/json_spec.rb +4 -4
  428. data/spec/unit/indirector/key/file_spec.rb +13 -14
  429. data/spec/unit/indirector/resource/ral_spec.rb +7 -0
  430. data/spec/unit/indirector/resource/store_configs_spec.rb +11 -0
  431. data/spec/unit/indirector/rest_spec.rb +7 -3
  432. data/spec/unit/indirector/ssl_file_spec.rb +14 -17
  433. data/spec/unit/indirector/yaml_spec.rb +4 -4
  434. data/spec/unit/module_spec.rb +43 -15
  435. data/spec/unit/module_tool/tar/gnu_spec.rb +2 -2
  436. data/spec/unit/module_tool/tar/solaris_spec.rb +2 -2
  437. data/spec/unit/module_tool/tar_spec.rb +45 -0
  438. data/spec/unit/network/authconfig_spec.rb +2 -1
  439. data/spec/unit/network/authentication_spec.rb +2 -2
  440. data/spec/unit/network/format_handler_spec.rb +2 -2
  441. data/spec/unit/network/formats_spec.rb +24 -0
  442. data/spec/unit/network/http/connection_spec.rb +76 -199
  443. data/spec/unit/network/http/handler_spec.rb +33 -34
  444. data/spec/unit/network/http_pool_spec.rb +8 -5
  445. data/spec/unit/node/environment_spec.rb +76 -90
  446. data/spec/unit/node/facts_spec.rb +20 -3
  447. data/spec/unit/node_spec.rb +43 -0
  448. data/spec/unit/parameter/boolean_spec.rb +22 -12
  449. data/spec/unit/parser/ast/resourceparam_spec.rb +51 -0
  450. data/spec/unit/parser/compiler_spec.rb +103 -35
  451. data/spec/unit/parser/eparser_adapter_spec.rb +12 -12
  452. data/spec/unit/parser/files_spec.rb +11 -11
  453. data/spec/unit/parser/functions/contain_spec.rb +185 -0
  454. data/spec/unit/parser/functions/create_resources_spec.rb +13 -5
  455. data/spec/unit/parser/functions/generate_spec.rb +1 -1
  456. data/spec/unit/parser/functions_spec.rb +2 -2
  457. data/spec/unit/parser/lexer_spec.rb +1 -1
  458. data/spec/unit/parser/methods/each_spec.rb +1 -1
  459. data/spec/unit/parser/methods/{select_spec.rb → filter_spec.rb} +11 -11
  460. data/spec/unit/parser/methods/map_spec.rb +95 -0
  461. data/spec/unit/parser/methods/reduce_spec.rb +12 -11
  462. data/spec/unit/parser/methods/shared.rb +5 -5
  463. data/spec/unit/parser/methods/slice_spec.rb +13 -13
  464. data/spec/unit/parser/parser_spec.rb +1 -1
  465. data/spec/unit/parser/resource/param_spec.rb +44 -0
  466. data/spec/unit/parser/resource_spec.rb +16 -15
  467. data/spec/unit/pops/model/ast_transformer_spec.rb +18 -4
  468. data/spec/unit/pops/parser/lexer_spec.rb +22 -5
  469. data/spec/unit/pops/parser/parse_calls_spec.rb +5 -5
  470. data/spec/unit/pops/transformer/transform_calls_spec.rb +6 -6
  471. data/spec/unit/pops/transformer/transform_containers_spec.rb +2 -2
  472. data/spec/unit/pops/validator/validator_spec.rb +31 -0
  473. data/spec/unit/provider/augeas/augeas_spec.rb +57 -2
  474. data/spec/unit/provider/exec/posix_spec.rb +8 -3
  475. data/spec/unit/provider/file/posix_spec.rb +2 -2
  476. data/spec/unit/provider/group/windows_adsi_spec.rb +70 -3
  477. data/spec/unit/provider/nameservice/directoryservice_spec.rb +3 -3
  478. data/spec/unit/provider/package/apt_spec.rb +1 -1
  479. data/spec/unit/provider/package/msi_spec.rb +15 -42
  480. data/spec/unit/provider/package/openbsd_spec.rb +3 -3
  481. data/spec/unit/provider/package/rpm_spec.rb +56 -13
  482. data/spec/unit/provider/package/windows_spec.rb +15 -19
  483. data/spec/unit/provider/service/base_spec.rb +1 -1
  484. data/spec/unit/provider/service/daemontools_spec.rb +18 -8
  485. data/spec/unit/provider/service/freebsd_spec.rb +3 -3
  486. data/spec/unit/provider/service/gentoo_spec.rb +5 -2
  487. data/spec/unit/provider/service/init_spec.rb +17 -17
  488. data/spec/unit/provider/service/launchd_spec.rb +76 -23
  489. data/spec/unit/provider/service/openbsd_spec.rb +125 -0
  490. data/spec/unit/provider/service/openwrt_spec.rb +1 -1
  491. data/spec/unit/provider/service/runit_spec.rb +12 -5
  492. data/spec/unit/provider/service/upstart_spec.rb +4 -4
  493. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -5
  494. data/spec/unit/provider/user/directoryservice_spec.rb +4 -4
  495. data/spec/unit/provider/zone/solaris_spec.rb +1 -1
  496. data/spec/unit/provider_spec.rb +2 -2
  497. data/spec/unit/reports/http_spec.rb +19 -34
  498. data/spec/unit/reports/store_spec.rb +2 -2
  499. data/spec/unit/resource/catalog_spec.rb +81 -11
  500. data/spec/unit/resource/status_spec.rb +11 -1
  501. data/spec/unit/resource/type_spec.rb +30 -1
  502. data/spec/unit/resource_spec.rb +40 -4
  503. data/spec/unit/settings/file_setting_spec.rb +2 -2
  504. data/spec/unit/settings/path_setting_spec.rb +2 -2
  505. data/spec/unit/settings/priority_setting_spec.rb +66 -0
  506. data/spec/unit/settings_spec.rb +16 -31
  507. data/spec/unit/ssl/certificate_authority/autosign_command_spec.rb +30 -0
  508. data/spec/unit/ssl/certificate_authority_spec.rb +129 -134
  509. data/spec/unit/ssl/certificate_factory_spec.rb +18 -0
  510. data/spec/unit/ssl/certificate_request_attributes_spec.rb +61 -0
  511. data/spec/unit/ssl/certificate_request_spec.rb +103 -0
  512. data/spec/unit/ssl/certificate_spec.rb +31 -18
  513. data/spec/unit/ssl/host_spec.rb +34 -8
  514. data/spec/unit/ssl/inventory_spec.rb +27 -62
  515. data/spec/unit/ssl/key_spec.rb +4 -4
  516. data/spec/unit/ssl/oids_spec.rb +48 -0
  517. data/spec/unit/ssl/validator_spec.rb +49 -6
  518. data/spec/unit/status_spec.rb +9 -0
  519. data/spec/unit/transaction/event_spec.rb +1 -9
  520. data/spec/unit/transaction/report_spec.rb +20 -1
  521. data/spec/unit/transaction/resource_harness_spec.rb +60 -210
  522. data/spec/unit/transaction_spec.rb +54 -8
  523. data/spec/unit/type/component_spec.rb +2 -2
  524. data/spec/unit/type/exec_spec.rb +14 -7
  525. data/spec/unit/type/file/content_spec.rb +13 -2
  526. data/spec/unit/type/file/ctime_spec.rb +1 -1
  527. data/spec/unit/type/file/mode_spec.rb +48 -2
  528. data/spec/unit/type/file/mtime_spec.rb +1 -1
  529. data/spec/unit/type/file/source_spec.rb +177 -7
  530. data/spec/unit/type/file_spec.rb +63 -71
  531. data/spec/unit/type/group_spec.rb +20 -0
  532. data/spec/unit/type/k5login_spec.rb +3 -3
  533. data/spec/unit/type/mount_spec.rb +53 -0
  534. data/spec/unit/type/nagios_spec.rb +216 -0
  535. data/spec/unit/type/package_spec.rb +7 -1
  536. data/spec/unit/type/schedule_spec.rb +6 -0
  537. data/spec/unit/type/service_spec.rb +3 -3
  538. data/spec/unit/type/tidy_spec.rb +14 -14
  539. data/spec/unit/type/user_spec.rb +9 -0
  540. data/spec/unit/type_spec.rb +86 -4
  541. data/spec/unit/util/adsi_spec.rb +120 -12
  542. data/spec/unit/util/autoload_spec.rb +14 -14
  543. data/spec/unit/util/backups_spec.rb +29 -21
  544. data/spec/unit/util/checksums_spec.rb +2 -1
  545. data/spec/unit/util/command_line_spec.rb +41 -0
  546. data/spec/unit/util/docs_spec.rb +91 -0
  547. data/spec/unit/util/execution_spec.rb +26 -2
  548. data/spec/unit/util/filetype_spec.rb +7 -7
  549. data/spec/unit/util/lockfile_spec.rb +2 -2
  550. data/spec/unit/util/log/destinations_spec.rb +32 -0
  551. data/spec/unit/util/monkey_patches_spec.rb +41 -0
  552. data/spec/unit/util/pidlock_spec.rb +6 -6
  553. data/spec/unit/util/rdoc/parser_spec.rb +15 -13
  554. data/spec/unit/util/rdoc_spec.rb +18 -24
  555. data/spec/unit/util/resource_template_spec.rb +3 -3
  556. data/spec/unit/util/selinux_spec.rb +4 -2
  557. data/spec/unit/util/storage_spec.rb +4 -4
  558. data/spec/unit/util/suidmanager_spec.rb +7 -0
  559. data/spec/unit/util/tag_set_spec.rb +46 -0
  560. data/spec/unit/util/tagging_spec.rb +82 -45
  561. data/spec/unit/util/watcher_spec.rb +4 -1
  562. data/spec/unit/util/windows/access_control_entry_spec.rb +67 -0
  563. data/spec/unit/util/windows/access_control_list_spec.rb +133 -0
  564. data/spec/unit/util/windows/root_certs_spec.rb +10 -8
  565. data/spec/unit/util/windows/security_descriptor_spec.rb +117 -0
  566. data/spec/unit/util/windows/sid_spec.rb +69 -0
  567. data/spec/unit/util_spec.rb +7 -7
  568. data/tasks/ci.rake +17 -36
  569. metadata +2811 -2746
  570. checksums.yaml +0 -7
  571. data/examples/mac_automount.pp +0 -16
  572. data/examples/mcx_dock_absent.pp +0 -4
  573. data/examples/mcx_dock_default.pp +0 -118
  574. data/examples/mcx_dock_full.pp +0 -125
  575. data/examples/mcx_dock_invalid.pp +0 -9
  576. data/examples/mcx_nogroup.pp +0 -118
  577. data/examples/mcx_notexists_absent.pp +0 -4
  578. data/ext/rack/README +0 -58
  579. data/ext/rack/manifest.pp +0 -59
  580. data/lib/puppet/external/lock.rb +0 -63
  581. data/lib/puppet/indirector/hiera.rb +0 -39
  582. data/lib/puppet/parser/functions/foreach.rb +0 -95
  583. data/spec/integration/network/server/webrick_spec.rb +0 -76
  584. data/spec/integration/parser/functions_spec.rb +0 -16
  585. data/spec/unit/indirector/hiera_spec.rb +0 -154
  586. data/spec/unit/parser/methods/collect_spec.rb +0 -153
  587. data/spec/unit/parser/methods/foreach_spec.rb +0 -91
  588. data/spec/unit/parser/methods/reject_spec.rb +0 -73
  589. data/spec/unit/resource/resource_type.json +0 -34
@@ -56,5 +56,6 @@ module Puppet
56
56
  # An error class for when I don't know what happened. Automatically
57
57
  # prints a stack trace when in debug mode.
58
58
  class DevError < Puppet::Error
59
+ include ExternalFileError
59
60
  end
60
61
  end
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby -w
2
-
3
1
  #--------------------
4
2
  # A script to retrieve hosts from ldap and create an importable
5
3
  # cfservd file from them
@@ -297,12 +297,13 @@ class Nagios::Base
297
297
  def to_s
298
298
  str = "define #{self.type} {\n"
299
299
 
300
- self.each { |param,value|
300
+ @parameters.keys.sort.each { |param|
301
+ value = @parameters[param]
301
302
  str += %{\t%-30s %s\n} % [ param,
302
303
  if value.is_a? Array
303
- value.join(",")
304
+ value.join(",").sub(';', '\;')
304
305
  else
305
- value
306
+ value.sub(';', '\;')
306
307
  end
307
308
  ]
308
309
  }
@@ -1,7 +1,7 @@
1
1
  # vim: syntax=ruby
2
2
  class Nagios::Parser
3
3
 
4
- token DEFINE NAME STRING PARAM LCURLY RCURLY VALUE RETURN COMMENT INLINECOMMENT
4
+ token DEFINE NAME PARAM LCURLY RCURLY VALUE RETURN
5
5
 
6
6
  rule
7
7
  decls: decl { return val[0] if val[0] }
@@ -20,13 +20,9 @@ decls: decl { return val[0] if val[0] }
20
20
 
21
21
  decl: object { result = [val[0]] }
22
22
  | RETURN { result = nil }
23
- | comment
24
23
  ;
25
24
 
26
- comment: COMMENT RETURN { result = nil }
27
- ;
28
-
29
- object: DEFINE NAME LCURLY RETURN vars RCURLY {
25
+ object: DEFINE NAME LCURLY returns vars RCURLY {
30
26
  result = Nagios::Base.create(val[1],val[4])
31
27
  }
32
28
  ;
@@ -40,146 +36,211 @@ vars: var
40
36
  }
41
37
  ;
42
38
 
43
- var: PARAM VALUE icomment returns { result = {val[0] => val[1]} }
39
+ var: PARAM VALUE returns { result = {val[0] => val[1]} }
44
40
  ;
45
41
 
46
- returns: RETURN
47
- | returns RETURN
48
- ;
49
-
50
- icomment: # nothing
51
- | INLINECOMMENT
42
+ returns: RETURN
43
+ | RETURN returns
52
44
  ;
53
45
 
54
46
  end
55
47
 
56
48
  ----inner
49
+ require 'strscan'
57
50
 
58
51
  class ::Nagios::Parser::SyntaxError < RuntimeError; end
59
52
 
60
53
  def parse(src)
61
- @src = src
54
+ if src.respond_to?("force_encoding") then
55
+ src.force_encoding("ASCII-8BIT")
56
+ end
57
+ @ss = StringScanner.new(src)
62
58
 
63
- # state variables
64
- @invar = false
65
- @inobject = false
66
- @done = false
59
+ # state variables
60
+ @in_parameter_value = false
61
+ @in_object_definition = false
62
+ @done = false
67
63
 
68
- @line = 0
69
- @yydebug = true
64
+ @line = 1
65
+ @yydebug = true
70
66
 
71
- do_parse
67
+ do_parse
72
68
  end
73
69
 
74
- # The lexer. Very simple.
75
- def token
76
- @src.sub!(/\A\n/,'')
77
- if $&
78
- @line += 1
79
- return [ :RETURN, "\n" ]
80
- end
70
+ # This tokenizes the outside of object definitions,
71
+ # and detects when we start defining an object.
72
+ # We ignore whitespaces, comments and inline comments.
73
+ # We yield when finding newlines, the "define" keyword,
74
+ # the object name and the opening curly bracket.
75
+ def tokenize_outside_definitions
76
+ case
77
+ when (chars = @ss.skip(/[ \t]+/)) # ignore whitespace /\s+/
78
+ ;
81
79
 
82
- if @done
83
- return nil
84
- end
85
- yytext = String.new
80
+ when (text = @ss.scan(/\#.*$/)) # ignore comments
81
+ ;
86
82
 
83
+ when (text = @ss.scan(/;.*$/)) # ignore inline comments
84
+ ;
87
85
 
88
- # remove comments from this line
89
- @src.sub!(/\A[ \t]*;.*\n/,"\n")
90
- if $&
91
- return [:INLINECOMMENT, ""]
92
- end
86
+ when (text = @ss.scan(/\n/)) # newline
87
+ [:RETURN, text]
93
88
 
94
- @src.sub!(/\A#.*\n/,"\n")
95
- if $&
96
- return [:COMMENT, ""]
97
- end
89
+ when (text = @ss.scan(/\b(define)\b/)) # the "define" keyword
90
+ [:DEFINE, text]
98
91
 
99
- @src.sub!(/#.*/,'')
92
+ when (text = @ss.scan(/[^{ \t\n]+/)) # the name of the object being defined (everything not an opening curly bracket or a separator)
93
+ [:NAME, text]
100
94
 
101
- if @src.length == 0
102
- @done = true
103
- return [false, '$']
104
- end
95
+ when (text = @ss.scan(/\{/)) # the opening curly bracket - we enter object definition
96
+ @in_object_definition = true
97
+ [:LCURLY, text]
105
98
 
106
- if @invar
107
- @src.sub!(/\A[ \t]+/,'')
108
- @src.sub!(/\A([^;\n]+)(\n|;)/,'\2')
109
- if $1
110
- yytext += $1
111
- end
112
- @invar = false
113
- return [:VALUE, yytext]
114
- else
115
- @src.sub!(/\A[\t ]*(\S+)([\t ]*|$)/,'')
116
- if $1
117
- yytext = $1
118
- case yytext
119
- when 'define'
120
- #puts "got define"
121
- return [:DEFINE, yytext]
122
- when '{'
123
- #puts "got {"
124
- @inobject = true
125
- return [:LCURLY, yytext]
126
- else
127
- unless @inobject
128
- #puts "got type: #{yytext}"
129
- if yytext =~ /\W/
130
- giveback = yytext.dup
131
- giveback.sub!(/^\w+/,'')
132
- #puts "giveback " + giveback
133
- #puts "yytext " + yytext
134
- yytext.sub!(/\W.*$/,'')
135
- #puts "yytext " + yytext
136
- #puts "all [#{giveback} #{yytext} #{orig}]"
137
- @src = giveback + @src
138
- end
139
- return [:NAME, yytext]
140
- else
141
- if yytext == '}'
142
- #puts "got closure: #{yytext}"
143
- @inobject = false
144
- return [:RCURLY, '}']
145
- end
146
-
147
- unless @invar
148
- @invar = true
149
- return [:PARAM, $1]
150
- else
151
- end
152
- end
153
- end
154
- end
99
+ else
100
+ text = @ss.string[@ss.pos .. -1]
101
+ raise ScanError, "can not match: '#{text}'"
102
+ end # case
103
+ end
104
+
105
+ # This tokenizes until we find the parameter name.
106
+ def tokenize_parameter_name
107
+ case
108
+ when (chars = @ss.skip(/[ \t]+/)) # ignore whitespace /\s+/
109
+ ;
110
+
111
+ when (text = @ss.scan(/\#.*$/)) # ignore comments
112
+ ;
113
+
114
+ when (text = @ss.scan(/;.*$/)) # ignore inline comments
115
+ ;
116
+
117
+ when (text = @ss.scan(/\n/)) # newline
118
+ [:RETURN, text]
119
+
120
+ when (text = @ss.scan(/\}/)) # closing curly bracket : end of definition
121
+ @in_object_definition = false
122
+ [:RCURLY, text]
123
+
124
+ when (not @in_parameter_value and (text = @ss.scan(/\S+/))) # This is the name of the parameter
125
+ @in_parameter_value = true
126
+ [:PARAM, text]
127
+
128
+ else
129
+ text = @ss.string[@ss.pos .. -1]
130
+ raise ScanError, "can not match: '#{text}'"
131
+ end # case
132
+ end
133
+
134
+ # This tokenizes the parameter value.
135
+ # There is a special handling for lines containing semicolons :
136
+ # - unescaped semicolons are line comments (and should stop parsing of the line)
137
+ # - escaped (with backslash \) semicolons should be kept in the parameter value (without the backslash)
138
+ def tokenize_parameter_value
139
+ case
140
+ when (chars = @ss.skip(/[ \t]+/)) # ignore whitespace /\s+/
141
+ ;
142
+
143
+ when (text = @ss.scan(/\#.*$/)) # ignore comments
144
+ ;
145
+
146
+ when (text = @ss.scan(/\n/)) # newline
147
+ [:RETURN, text]
148
+
149
+ when (text = @ss.scan(/.+$/)) # Value of parameter
150
+ @in_parameter_value = false
151
+
152
+ # Special handling of inline comments (;) and escaped semicolons (\;)
153
+
154
+ # We split the string on escaped semicolons (\;),
155
+ # Then we rebuild it as long as there are no inline comments (;)
156
+ # We join the rebuilt string with unescaped semicolons (on purpose)
157
+ array = text.split('\;', 0)
158
+
159
+ text = ""
160
+
161
+ array.each do |elt|
162
+
163
+ # Now we split at inline comments. If we have more than 1 element in the array
164
+ # it means we have an inline comment, so we are able to stop parsing
165
+ # However we still want to reconstruct the string with its first part (before the comment)
166
+ linearray = elt.split(';', 0)
167
+
168
+ # Let's reconstruct the string with a (unescaped) semicolon
169
+ if text != "" then
170
+ text += ';'
171
+ end
172
+ text += linearray[0]
173
+
174
+ # Now we can stop
175
+ if linearray.length > 1 then
176
+ break
177
+ end
155
178
  end
179
+
180
+
181
+ # We strip the text to remove spaces between end of string and beginning of inline comment
182
+ [:VALUE, text.strip]
183
+
184
+ else
185
+ text = @ss.string[@ss.pos .. -1]
186
+ raise ScanError, "can not match: '#{text}'"
187
+ end # case
188
+ end
189
+
190
+ # This tokenizes inside an object definition.
191
+ # Two cases : parameter name and parameter value
192
+ def tokenize_inside_definitions
193
+ if @in_parameter_value
194
+ tokenize_parameter_value
195
+ else
196
+ tokenize_parameter_name
197
+ end
198
+ end
199
+
200
+ # The lexer. Very simple.
201
+ def token
202
+ text = @ss.peek(1)
203
+ @line += 1 if text == "\n"
204
+
205
+ token = if @in_object_definition
206
+ tokenize_inside_definitions
207
+ else
208
+ tokenize_outside_definitions
209
+ end
210
+ token
156
211
  end
157
212
 
158
213
  def next_token
159
- token
214
+ return if @ss.eos?
215
+
216
+ # skips empty actions
217
+ until _next_token = token or @ss.eos?; end
218
+ _next_token
160
219
  end
161
220
 
162
221
  def yydebug
163
- 1
222
+ 1
164
223
  end
165
224
 
166
225
  def yywrap
167
- 0
226
+ 0
168
227
  end
169
228
 
170
229
  def on_error(token, value, vstack )
171
- msg = ""
172
- unless value.nil?
173
- msg = "line #{@line}: syntax error at '#{value}'"
174
- else
175
- msg = "line #{@line}: syntax error at '#{token}'"
176
- end
177
- unless @src.size > 0
178
- msg = "line #{@line}: Unexpected end of file"
179
- end
180
- if token == '$end'.intern
181
- puts "okay, this is silly"
182
- else
183
- raise ::Nagios::Parser::SyntaxError, msg
184
- end
230
+ # text = @ss.string[@ss.pos .. -1]
231
+ text = @ss.peek(20)
232
+ msg = ""
233
+ unless value.nil?
234
+ msg = "line #{@line}: syntax error at value '#{value}' : #{text}"
235
+ else
236
+ msg = "line #{@line}: syntax error at token '#{token}' : #{text}"
237
+ end
238
+ if @ss.eos?
239
+ msg = "line #{@line}: Unexpected end of file"
240
+ end
241
+ if token == '$end'.intern
242
+ puts "okay, this is silly"
243
+ else
244
+ raise ::Nagios::Parser::SyntaxError, msg
245
+ end
185
246
  end
@@ -8,205 +8,269 @@ require 'racc/parser.rb'
8
8
  module Nagios
9
9
  class Parser < Racc::Parser
10
10
 
11
- module_eval(<<'...end grammar.ry/module_eval...', 'grammar.ry', 57)
11
+ module_eval(<<'...end grammar.ry/module_eval...', 'grammar.ry', 49)
12
+ require 'strscan'
12
13
 
13
14
  class ::Nagios::Parser::SyntaxError < RuntimeError; end
14
15
 
15
16
  def parse(src)
16
- @src = src
17
+ if src.respond_to?("force_encoding") then
18
+ src.force_encoding("ASCII-8BIT")
19
+ end
20
+ @ss = StringScanner.new(src)
17
21
 
18
- # state variables
19
- @invar = false
20
- @inobject = false
21
- @done = false
22
+ # state variables
23
+ @in_parameter_value = false
24
+ @in_object_definition = false
25
+ @done = false
22
26
 
23
- @line = 0
24
- @yydebug = true
27
+ @line = 1
28
+ @yydebug = true
25
29
 
26
- do_parse
30
+ do_parse
27
31
  end
28
32
 
29
- # The lexer. Very simple.
30
- def token
31
- @src.sub!(/\A\n/,'')
32
- if $&
33
- @line += 1
34
- return [ :RETURN, "\n" ]
35
- end
33
+ # This tokenizes the outside of object definitions,
34
+ # and detects when we start defining an object.
35
+ # We ignore whitespaces, comments and inline comments.
36
+ # We yield when finding newlines, the "define" keyword,
37
+ # the object name and the opening curly bracket.
38
+ def tokenize_outside_definitions
39
+ case
40
+ when (chars = @ss.skip(/[ \t]+/)) # ignore whitespace /\s+/
41
+ ;
36
42
 
37
- if @done
38
- return nil
39
- end
40
- yytext = String.new
43
+ when (text = @ss.scan(/\#.*$/)) # ignore comments
44
+ ;
41
45
 
46
+ when (text = @ss.scan(/;.*$/)) # ignore inline comments
47
+ ;
42
48
 
43
- # remove comments from this line
44
- @src.sub!(/\A[ \t]*;.*\n/,"\n")
45
- if $&
46
- return [:INLINECOMMENT, ""]
47
- end
49
+ when (text = @ss.scan(/\n/)) # newline
50
+ [:RETURN, text]
48
51
 
49
- @src.sub!(/\A#.*\n/,"\n")
50
- if $&
51
- return [:COMMENT, ""]
52
- end
52
+ when (text = @ss.scan(/\b(define)\b/)) # the "define" keyword
53
+ [:DEFINE, text]
53
54
 
54
- @src.sub!(/#.*/,'')
55
+ when (text = @ss.scan(/[^{ \t\n]+/)) # the name of the object being defined (everything not an opening curly bracket or a separator)
56
+ [:NAME, text]
55
57
 
56
- if @src.length == 0
57
- @done = true
58
- return [false, '$']
59
- end
58
+ when (text = @ss.scan(/\{/)) # the opening curly bracket - we enter object definition
59
+ @in_object_definition = true
60
+ [:LCURLY, text]
60
61
 
61
- if @invar
62
- @src.sub!(/\A[ \t]+/,'')
63
- @src.sub!(/\A([^;\n]+)(\n|;)/,'\2')
64
- if $1
65
- yytext += $1
66
- end
67
- @invar = false
68
- return [:VALUE, yytext]
69
- else
70
- @src.sub!(/\A[\t ]*(\S+)([\t ]*|$)/,'')
71
- if $1
72
- yytext = $1
73
- case yytext
74
- when 'define'
75
- #puts "got define"
76
- return [:DEFINE, yytext]
77
- when '{'
78
- #puts "got {"
79
- @inobject = true
80
- return [:LCURLY, yytext]
81
- else
82
- unless @inobject
83
- #puts "got type: #{yytext}"
84
- if yytext =~ /\W/
85
- giveback = yytext.dup
86
- giveback.sub!(/^\w+/,'')
87
- #puts "giveback " + giveback
88
- #puts "yytext " + yytext
89
- yytext.sub!(/\W.*$/,'')
90
- #puts "yytext " + yytext
91
- #puts "all [#{giveback} #{yytext} #{orig}]"
92
- @src = giveback + @src
93
- end
94
- return [:NAME, yytext]
95
- else
96
- if yytext == '}'
97
- #puts "got closure: #{yytext}"
98
- @inobject = false
99
- return [:RCURLY, '}']
100
- end
101
-
102
- unless @invar
103
- @invar = true
104
- return [:PARAM, $1]
105
- else
106
- end
107
- end
108
- end
109
- end
62
+ else
63
+ text = @ss.string[@ss.pos .. -1]
64
+ raise ScanError, "can not match: '#{text}'"
65
+ end # case
66
+ end
67
+
68
+ # This tokenizes until we find the parameter name.
69
+ def tokenize_parameter_name
70
+ case
71
+ when (chars = @ss.skip(/[ \t]+/)) # ignore whitespace /\s+/
72
+ ;
73
+
74
+ when (text = @ss.scan(/\#.*$/)) # ignore comments
75
+ ;
76
+
77
+ when (text = @ss.scan(/;.*$/)) # ignore inline comments
78
+ ;
79
+
80
+ when (text = @ss.scan(/\n/)) # newline
81
+ [:RETURN, text]
82
+
83
+ when (text = @ss.scan(/\}/)) # closing curly bracket : end of definition
84
+ @in_object_definition = false
85
+ [:RCURLY, text]
86
+
87
+ when (not @in_parameter_value and (text = @ss.scan(/\S+/))) # This is the name of the parameter
88
+ @in_parameter_value = true
89
+ [:PARAM, text]
90
+
91
+ else
92
+ text = @ss.string[@ss.pos .. -1]
93
+ raise ScanError, "can not match: '#{text}'"
94
+ end # case
95
+ end
96
+
97
+ # This tokenizes the parameter value.
98
+ # There is a special handling for lines containing semicolons :
99
+ # - unescaped semicolons are line comments (and should stop parsing of the line)
100
+ # - escaped (with backslash \) semicolons should be kept in the parameter value (without the backslash)
101
+ def tokenize_parameter_value
102
+ case
103
+ when (chars = @ss.skip(/[ \t]+/)) # ignore whitespace /\s+/
104
+ ;
105
+
106
+ when (text = @ss.scan(/\#.*$/)) # ignore comments
107
+ ;
108
+
109
+ when (text = @ss.scan(/\n/)) # newline
110
+ [:RETURN, text]
111
+
112
+ when (text = @ss.scan(/.+$/)) # Value of parameter
113
+ @in_parameter_value = false
114
+
115
+ # Special handling of inline comments (;) and escaped semicolons (\;)
116
+
117
+ # We split the string on escaped semicolons (\;),
118
+ # Then we rebuild it as long as there are no inline comments (;)
119
+ # We join the rebuilt string with unescaped semicolons (on purpose)
120
+ array = text.split('\;', 0)
121
+
122
+ text = ""
123
+
124
+ array.each do |elt|
125
+
126
+ # Now we split at inline comments. If we have more than 1 element in the array
127
+ # it means we have an inline comment, so we are able to stop parsing
128
+ # However we still want to reconstruct the string with its first part (before the comment)
129
+ linearray = elt.split(';', 0)
130
+
131
+ # Let's reconstruct the string with a (unescaped) semicolon
132
+ if text != "" then
133
+ text += ';'
134
+ end
135
+ text += linearray[0]
136
+
137
+ # Now we can stop
138
+ if linearray.length > 1 then
139
+ break
140
+ end
110
141
  end
142
+
143
+
144
+ # We strip the text to remove spaces between end of string and beginning of inline comment
145
+ [:VALUE, text.strip]
146
+
147
+ else
148
+ text = @ss.string[@ss.pos .. -1]
149
+ raise ScanError, "can not match: '#{text}'"
150
+ end # case
151
+ end
152
+
153
+ # This tokenizes inside an object definition.
154
+ # Two cases : parameter name and parameter value
155
+ def tokenize_inside_definitions
156
+ if @in_parameter_value
157
+ tokenize_parameter_value
158
+ else
159
+ tokenize_parameter_name
160
+ end
161
+ end
162
+
163
+ # The lexer. Very simple.
164
+ def token
165
+ text = @ss.peek(1)
166
+ @line += 1 if text == "\n"
167
+
168
+ token = if @in_object_definition
169
+ tokenize_inside_definitions
170
+ else
171
+ tokenize_outside_definitions
172
+ end
173
+ token
111
174
  end
112
175
 
113
176
  def next_token
114
- token
177
+ return if @ss.eos?
178
+
179
+ # skips empty actions
180
+ until _next_token = token or @ss.eos?; end
181
+ _next_token
115
182
  end
116
183
 
117
184
  def yydebug
118
- 1
185
+ 1
119
186
  end
120
187
 
121
188
  def yywrap
122
- 0
189
+ 0
123
190
  end
124
191
 
125
192
  def on_error(token, value, vstack )
126
- msg = ""
127
- unless value.nil?
128
- msg = "line #{@line}: syntax error at '#{value}'"
129
- else
130
- msg = "line #{@line}: syntax error at '#{token}'"
131
- end
132
- unless @src.size > 0
133
- msg = "line #{@line}: Unexpected end of file"
134
- end
135
- if token == '$end'.intern
136
- puts "okay, this is silly"
137
- else
138
- raise ::Nagios::Parser::SyntaxError, msg
139
- end
193
+ # text = @ss.string[@ss.pos .. -1]
194
+ text = @ss.peek(20)
195
+ msg = ""
196
+ unless value.nil?
197
+ msg = "line #{@line}: syntax error at value '#{value}' : #{text}"
198
+ else
199
+ msg = "line #{@line}: syntax error at token '#{token}' : #{text}"
200
+ end
201
+ if @ss.eos?
202
+ msg = "line #{@line}: Unexpected end of file"
203
+ end
204
+ if token == '$end'.intern
205
+ puts "okay, this is silly"
206
+ else
207
+ raise ::Nagios::Parser::SyntaxError, msg
208
+ end
140
209
  end
141
210
  ...end grammar.ry/module_eval...
142
211
  ##### State transition tables begin ###
143
212
 
144
213
  racc_action_table = [
145
- 8, 17, 7, 18, 7, 14, 12, 13, 11, 4,
146
- 6, 4, 6, 17, 10, 20, 22, 24, 25 ]
214
+ 8, 3, 3, 14, 12, 18, 10, 4, 4, 9,
215
+ 14, 12, 6, 19, 12 ]
147
216
 
148
217
  racc_action_check = [
149
- 1, 15, 1, 15, 0, 13, 8, 11, 7, 1,
150
- 1, 0, 0, 14, 6, 17, 20, 21, 23 ]
218
+ 5, 0, 5, 13, 9, 13, 8, 0, 5, 6,
219
+ 11, 12, 3, 14, 19 ]
151
220
 
152
221
  racc_action_pointer = [
153
- 2, 0, nil, nil, nil, nil, 5, 5, 6, nil,
154
- nil, 1, nil, -4, 8, -4, nil, 7, nil, nil,
155
- 5, 8, nil, 9, nil, nil ]
222
+ -1, nil, nil, 9, nil, 0, 4, nil, 6, -4,
223
+ nil, 6, 3, -1, 6, nil, nil, nil, nil, 6,
224
+ nil ]
156
225
 
157
226
  racc_action_default = [
158
- -15, -15, -1, -3, -4, -5, -15, -15, -15, -2,
159
- -6, -15, 26, -15, -15, -15, -8, -15, -7, -9,
160
- -13, -15, -14, -10, -11, -12 ]
227
+ -11, -1, -3, -11, -4, -11, -11, -2, -11, -11,
228
+ 21, -11, -9, -11, -11, -6, -10, -7, -5, -11,
229
+ -8 ]
161
230
 
162
231
  racc_goto_table = [
163
- 16, 19, 2, 9, 1, 15, 21, 23 ]
232
+ 11, 1, 15, 16, 17, 13, 7, 5, nil, nil,
233
+ 20 ]
164
234
 
165
235
  racc_goto_check = [
166
- 6, 6, 2, 2, 1, 5, 7, 8 ]
236
+ 4, 2, 6, 4, 6, 5, 2, 1, nil, nil,
237
+ 4 ]
167
238
 
168
239
  racc_goto_pointer = [
169
- nil, 4, 2, nil, nil, -9, -14, -14, -14 ]
240
+ nil, 7, 1, nil, -9, -6, -9 ]
170
241
 
171
242
  racc_goto_default = [
172
- nil, nil, nil, 3, 5, nil, nil, nil, nil ]
243
+ nil, nil, nil, 2, nil, nil, nil ]
173
244
 
174
245
  racc_reduce_table = [
175
246
  0, 0, :racc_error,
176
- 1, 13, :_reduce_1,
177
- 2, 13, :_reduce_2,
178
- 1, 14, :_reduce_3,
179
- 1, 14, :_reduce_4,
247
+ 1, 10, :_reduce_1,
248
+ 2, 10, :_reduce_2,
249
+ 1, 11, :_reduce_3,
250
+ 1, 11, :_reduce_4,
251
+ 6, 12, :_reduce_5,
180
252
  1, 14, :_reduce_none,
181
- 2, 16, :_reduce_6,
182
- 6, 15, :_reduce_7,
183
- 1, 17, :_reduce_none,
184
- 2, 17, :_reduce_9,
185
- 4, 18, :_reduce_10,
186
- 1, 20, :_reduce_none,
187
- 2, 20, :_reduce_none,
188
- 0, 19, :_reduce_none,
189
- 1, 19, :_reduce_none ]
253
+ 2, 14, :_reduce_7,
254
+ 3, 15, :_reduce_8,
255
+ 1, 13, :_reduce_none,
256
+ 2, 13, :_reduce_none ]
190
257
 
191
- racc_reduce_n = 15
258
+ racc_reduce_n = 11
192
259
 
193
- racc_shift_n = 26
260
+ racc_shift_n = 21
194
261
 
195
262
  racc_token_table = {
196
263
  false => 0,
197
264
  :error => 1,
198
265
  :DEFINE => 2,
199
266
  :NAME => 3,
200
- :STRING => 4,
201
- :PARAM => 5,
202
- :LCURLY => 6,
203
- :RCURLY => 7,
204
- :VALUE => 8,
205
- :RETURN => 9,
206
- :COMMENT => 10,
207
- :INLINECOMMENT => 11 }
267
+ :PARAM => 4,
268
+ :LCURLY => 5,
269
+ :RCURLY => 6,
270
+ :VALUE => 7,
271
+ :RETURN => 8 }
208
272
 
209
- racc_nt_base = 12
273
+ racc_nt_base = 9
210
274
 
211
275
  racc_use_result_var = true
212
276
 
@@ -231,23 +295,18 @@ Racc_token_to_s_table = [
231
295
  "error",
232
296
  "DEFINE",
233
297
  "NAME",
234
- "STRING",
235
298
  "PARAM",
236
299
  "LCURLY",
237
300
  "RCURLY",
238
301
  "VALUE",
239
302
  "RETURN",
240
- "COMMENT",
241
- "INLINECOMMENT",
242
303
  "$start",
243
304
  "decls",
244
305
  "decl",
245
306
  "object",
246
- "comment",
307
+ "returns",
247
308
  "vars",
248
- "var",
249
- "icomment",
250
- "returns" ]
309
+ "var" ]
251
310
 
252
311
  Racc_debug_parser = false
253
312
 
@@ -257,82 +316,72 @@ Racc_debug_parser = false
257
316
 
258
317
  module_eval(<<'.,.,', 'grammar.ry', 6)
259
318
  def _reduce_1(val, _values, result)
260
- return val[0] if val[0]
319
+ return val[0] if val[0]
261
320
  result
262
321
  end
263
322
  .,.,
264
323
 
265
324
  module_eval(<<'.,.,', 'grammar.ry', 8)
266
325
  def _reduce_2(val, _values, result)
267
- if val[1].nil?
268
- result = val[0]
269
- else
270
- if val[0].nil?
271
- result = val[1]
272
- else
273
- result = [ val[0], val[1] ].flatten
274
- end
275
- end
326
+ if val[1].nil?
327
+ result = val[0]
328
+ else
329
+ if val[0].nil?
330
+ result = val[1]
331
+ else
332
+ result = [ val[0], val[1] ].flatten
333
+ end
334
+ end
335
+
276
336
  result
277
337
  end
278
338
  .,.,
279
339
 
280
340
  module_eval(<<'.,.,', 'grammar.ry', 20)
281
341
  def _reduce_3(val, _values, result)
282
- result = [val[0]]
342
+ result = [val[0]]
283
343
  result
284
344
  end
285
345
  .,.,
286
346
 
287
347
  module_eval(<<'.,.,', 'grammar.ry', 21)
288
348
  def _reduce_4(val, _values, result)
289
- result = nil
349
+ result = nil
290
350
  result
291
351
  end
292
352
  .,.,
293
353
 
294
- # reduce 5 omitted
295
-
296
354
  module_eval(<<'.,.,', 'grammar.ry', 25)
297
- def _reduce_6(val, _values, result)
298
- result = nil
355
+ def _reduce_5(val, _values, result)
356
+ result = Nagios::Base.create(val[1],val[4])
357
+
299
358
  result
300
359
  end
301
360
  .,.,
302
361
 
303
- module_eval(<<'.,.,', 'grammar.ry', 29)
304
- def _reduce_7(val, _values, result)
305
- result = Nagios::Base.create(val[1],val[4])
306
- result
307
- end
308
- .,.,
362
+ # reduce 6 omitted
309
363
 
310
- # reduce 8 omitted
311
-
312
- module_eval(<<'.,.,', 'grammar.ry', 35)
313
- def _reduce_9(val, _values, result)
314
- val[1].each {|p,v|
315
- val[0][p] = v
316
- }
317
- result = val[0]
364
+ module_eval(<<'.,.,', 'grammar.ry', 31)
365
+ def _reduce_7(val, _values, result)
366
+ val[1].each {|p,v|
367
+ val[0][p] = v
368
+ }
369
+ result = val[0]
370
+
318
371
  result
319
372
  end
320
373
  .,.,
321
374
 
322
- module_eval(<<'.,.,', 'grammar.ry', 42)
323
- def _reduce_10(val, _values, result)
324
- result = {val[0] => val[1]}
375
+ module_eval(<<'.,.,', 'grammar.ry', 38)
376
+ def _reduce_8(val, _values, result)
377
+ result = {val[0] => val[1]}
325
378
  result
326
379
  end
327
380
  .,.,
328
381
 
329
- # reduce 11 omitted
330
-
331
- # reduce 12 omitted
332
-
333
- # reduce 13 omitted
382
+ # reduce 9 omitted
334
383
 
335
- # reduce 14 omitted
384
+ # reduce 10 omitted
336
385
 
337
386
  def _reduce_none(val, _values, result)
338
387
  val[0]