chef 16.10.17-universal-mingw32 → 17.1.35-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (694) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -21
  3. data/README.md +1 -1
  4. data/Rakefile +13 -2
  5. data/chef-universal-mingw32.gemspec +1 -1
  6. data/chef.gemspec +11 -24
  7. data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll +0 -0
  8. data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
  9. data/distro/ruby_bin_folder/AMD64/Newtonsoft.Json.dll +0 -0
  10. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
  11. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
  12. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
  13. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
  14. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
  15. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
  16. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
  17. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
  18. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
  19. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
  20. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
  21. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
  22. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
  23. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
  24. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
  25. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
  26. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
  27. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
  28. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
  29. data/distro/ruby_bin_folder/x86/Chef.PowerShell.dll +0 -0
  30. data/distro/ruby_bin_folder/x86/Chef.Powershell.Wrapper.dll +0 -0
  31. data/distro/ruby_bin_folder/x86/Newtonsoft.Json.dll +0 -0
  32. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
  33. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
  34. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
  35. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
  36. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
  37. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
  38. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
  39. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
  40. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
  41. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
  42. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
  43. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
  44. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
  45. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
  46. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
  47. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
  48. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
  49. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
  50. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
  51. data/lib/chef/application/base.rb +1 -1
  52. data/lib/chef/applications.rb +0 -1
  53. data/lib/chef/chef_fs/command_line.rb +5 -2
  54. data/lib/chef/chef_fs/file_pattern.rb +2 -2
  55. data/lib/chef/chef_fs/file_system.rb +9 -10
  56. data/lib/chef/client.rb +2 -2
  57. data/lib/chef/compliance/default_attributes.rb +11 -6
  58. data/lib/chef/compliance/fetcher/automate.rb +0 -7
  59. data/lib/chef/compliance/reporter/automate.rb +17 -7
  60. data/lib/chef/compliance/reporter/chef_server_automate.rb +11 -6
  61. data/lib/chef/compliance/reporter/cli.rb +77 -0
  62. data/lib/chef/compliance/reporter/compliance_enforcer.rb +4 -0
  63. data/lib/chef/compliance/reporter/json_file.rb +8 -1
  64. data/lib/chef/compliance/runner.rb +71 -28
  65. data/lib/chef/cookbook/cookbook_version_loader.rb +3 -3
  66. data/lib/chef/cookbook/gem_installer.rb +5 -1
  67. data/lib/chef/cookbook/synchronizer.rb +3 -5
  68. data/lib/chef/cookbook_loader.rb +2 -4
  69. data/lib/chef/cookbook_uploader.rb +0 -1
  70. data/lib/chef/data_bag_item.rb +11 -2
  71. data/lib/chef/delayed_evaluator.rb +4 -0
  72. data/lib/chef/deprecated.rb +4 -0
  73. data/lib/chef/dsl/chef_vault.rb +6 -6
  74. data/lib/chef/dsl/declare_resource.rb +5 -10
  75. data/lib/chef/dsl/reboot_pending.rb +1 -2
  76. data/lib/chef/formatters/doc.rb +2 -1
  77. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +20 -22
  78. data/lib/chef/group.rb +75 -0
  79. data/lib/chef/mixin/get_source_from_package.rb +1 -1
  80. data/lib/chef/node.rb +1 -1
  81. data/lib/chef/node/attribute.rb +6 -4
  82. data/lib/chef/node/immutable_collections.rb +13 -0
  83. data/lib/chef/node/mixin/deep_merge_cache.rb +11 -7
  84. data/lib/chef/org.rb +3 -2
  85. data/lib/chef/property.rb +18 -0
  86. data/lib/chef/provider.rb +1 -1
  87. data/lib/chef/provider/cron.rb +1 -1
  88. data/lib/chef/provider/directory.rb +6 -6
  89. data/lib/chef/provider/execute.rb +2 -1
  90. data/lib/chef/provider/file.rb +2 -2
  91. data/lib/chef/provider/git.rb +5 -7
  92. data/lib/chef/provider/group/groupadd.rb +3 -3
  93. data/lib/chef/provider/group/groupmod.rb +3 -3
  94. data/lib/chef/provider/group/pw.rb +3 -3
  95. data/lib/chef/provider/ifconfig.rb +2 -2
  96. data/lib/chef/provider/link.rb +3 -3
  97. data/lib/chef/provider/mount.rb +12 -7
  98. data/lib/chef/provider/mount/aix.rb +3 -3
  99. data/lib/chef/provider/mount/mount.rb +5 -5
  100. data/lib/chef/provider/mount/windows.rb +1 -1
  101. data/lib/chef/provider/package.rb +17 -21
  102. data/lib/chef/provider/package/apt.rb +27 -1
  103. data/lib/chef/provider/package/deb.rb +3 -3
  104. data/lib/chef/provider/package/dnf/dnf_helper.py +16 -11
  105. data/lib/chef/provider/package/dnf/python_helper.rb +9 -8
  106. data/lib/chef/provider/package/portage.rb +2 -2
  107. data/lib/chef/provider/package/rubygems.rb +11 -17
  108. data/lib/chef/provider/package/windows.rb +2 -4
  109. data/lib/chef/provider/package/yum.rb +1 -4
  110. data/lib/chef/provider/package/yum/python_helper.rb +15 -10
  111. data/lib/chef/provider/package/yum/yum_helper.py +51 -63
  112. data/lib/chef/provider/registry_key.rb +1 -1
  113. data/lib/chef/provider/route.rb +2 -2
  114. data/lib/chef/provider/service.rb +6 -6
  115. data/lib/chef/provider/service/aixinit.rb +1 -1
  116. data/lib/chef/provider/service/debian.rb +1 -1
  117. data/lib/chef/provider/service/freebsd.rb +15 -21
  118. data/lib/chef/provider/service/macosx.rb +7 -7
  119. data/lib/chef/provider/service/systemd.rb +43 -14
  120. data/lib/chef/provider/service/upstart.rb +2 -13
  121. data/lib/chef/provider/service/windows.rb +12 -12
  122. data/lib/chef/provider/subversion.rb +10 -12
  123. data/lib/chef/provider/systemd_unit.rb +36 -10
  124. data/lib/chef/provider/template/content.rb +3 -7
  125. data/lib/chef/provider/user.rb +2 -2
  126. data/lib/chef/provider/user/dscl.rb +1 -1
  127. data/lib/chef/provider/user/mac.rb +17 -20
  128. data/lib/chef/provider/user/pw.rb +1 -1
  129. data/lib/chef/provider/user/windows.rb +1 -1
  130. data/lib/chef/provider/windows_script.rb +1 -1
  131. data/lib/chef/provider/zypper_repository.rb +2 -2
  132. data/lib/chef/providers.rb +0 -1
  133. data/lib/chef/resource.rb +6 -7
  134. data/lib/chef/resource/alternatives.rb +6 -6
  135. data/lib/chef/resource/apt_package.rb +1 -1
  136. data/lib/chef/resource/apt_preference.rb +2 -2
  137. data/lib/chef/resource/apt_repository.rb +6 -6
  138. data/lib/chef/resource/apt_update.rb +3 -2
  139. data/lib/chef/resource/archive_file.rb +2 -3
  140. data/lib/chef/resource/breakpoint.rb +1 -1
  141. data/lib/chef/resource/build_essential.rb +2 -6
  142. data/lib/chef/resource/chef_client_config.rb +2 -2
  143. data/lib/chef/resource/chef_client_cron.rb +5 -5
  144. data/lib/chef/resource/chef_client_launchd.rb +4 -4
  145. data/lib/chef/resource/chef_client_scheduled_task.rb +1 -1
  146. data/lib/chef/resource/chef_client_systemd_timer.rb +2 -2
  147. data/lib/chef/resource/chef_handler.rb +3 -7
  148. data/lib/chef/resource/chef_sleep.rb +1 -1
  149. data/lib/chef/resource/chef_vault_secret.rb +3 -8
  150. data/lib/chef/resource/chocolatey_config.rb +2 -6
  151. data/lib/chef/resource/chocolatey_feature.rb +2 -6
  152. data/lib/chef/resource/chocolatey_source.rb +4 -10
  153. data/lib/chef/resource/cron/_cron_shared.rb +2 -2
  154. data/lib/chef/resource/cron_access.rb +2 -4
  155. data/lib/chef/resource/dmg_package.rb +6 -10
  156. data/lib/chef/resource/dpkg_package.rb +1 -1
  157. data/lib/chef/resource/execute.rb +8 -3
  158. data/lib/chef/resource/file.rb +1 -1
  159. data/lib/chef/resource/group.rb +2 -2
  160. data/lib/chef/resource/homebrew_cask.rb +2 -6
  161. data/lib/chef/resource/homebrew_tap.rb +2 -6
  162. data/lib/chef/resource/hostname.rb +21 -17
  163. data/lib/chef/resource/http_request.rb +1 -1
  164. data/lib/chef/resource/inspec_waiver_file_entry.rb +155 -0
  165. data/lib/chef/resource/kernel_module.rb +6 -17
  166. data/lib/chef/resource/locale.rb +2 -3
  167. data/lib/chef/resource/lwrp_base.rb +19 -0
  168. data/lib/chef/resource/macos_userdefaults.rb +10 -14
  169. data/lib/chef/resource/mdadm.rb +53 -7
  170. data/lib/chef/resource/mount.rb +2 -1
  171. data/lib/chef/resource/openssl_ec_private_key.rb +2 -2
  172. data/lib/chef/resource/openssl_rsa_private_key.rb +1 -1
  173. data/lib/chef/resource/openssl_x509_certificate.rb +2 -2
  174. data/lib/chef/resource/plist.rb +7 -7
  175. data/lib/chef/resource/powershell_script.rb +1 -1
  176. data/lib/chef/resource/remote_file.rb +3 -3
  177. data/lib/chef/resource/rhsm_errata.rb +16 -1
  178. data/lib/chef/resource/rhsm_errata_level.rb +10 -1
  179. data/lib/chef/resource/rhsm_register.rb +12 -6
  180. data/lib/chef/resource/rhsm_repo.rb +2 -6
  181. data/lib/chef/resource/rhsm_subscription.rb +2 -6
  182. data/lib/chef/resource/scm/git.rb +1 -1
  183. data/lib/chef/resource/sudo.rb +6 -6
  184. data/lib/chef/resource/sysctl.rb +2 -6
  185. data/lib/chef/resource/systemd_unit.rb +2 -2
  186. data/lib/chef/resource/template.rb +1 -1
  187. data/lib/chef/resource/timezone.rb +1 -3
  188. data/lib/chef/resource/user/mac_user.rb +1 -1
  189. data/lib/chef/resource/user_ulimit.rb +2 -2
  190. data/lib/chef/resource/windows_ad_join.rb +2 -6
  191. data/lib/chef/resource/windows_audit_policy.rb +1 -1
  192. data/lib/chef/resource/windows_auto_run.rb +2 -5
  193. data/lib/chef/resource/windows_certificate.rb +207 -73
  194. data/lib/chef/resource/windows_dfs_folder.rb +2 -6
  195. data/lib/chef/resource/windows_dfs_namespace.rb +2 -6
  196. data/lib/chef/resource/windows_dfs_server.rb +1 -3
  197. data/lib/chef/resource/windows_dns_record.rb +2 -6
  198. data/lib/chef/resource/windows_dns_zone.rb +2 -6
  199. data/lib/chef/resource/windows_env.rb +6 -5
  200. data/lib/chef/resource/windows_feature.rb +3 -9
  201. data/lib/chef/resource/windows_feature_dism.rb +2 -6
  202. data/lib/chef/resource/windows_feature_powershell.rb +3 -3
  203. data/lib/chef/resource/windows_firewall_profile.rb +4 -4
  204. data/lib/chef/resource/windows_firewall_rule.rb +2 -5
  205. data/lib/chef/resource/windows_font.rb +3 -5
  206. data/lib/chef/resource/windows_pagefile.rb +4 -8
  207. data/lib/chef/resource/windows_path.rb +4 -4
  208. data/lib/chef/resource/windows_printer.rb +4 -4
  209. data/lib/chef/resource/windows_printer_port.rb +6 -6
  210. data/lib/chef/resource/windows_security_policy.rb +56 -40
  211. data/lib/chef/resource/windows_share.rb +14 -21
  212. data/lib/chef/resource/windows_shortcut.rb +4 -6
  213. data/lib/chef/resource/windows_task.rb +18 -6
  214. data/lib/chef/resource/windows_uac.rb +1 -1
  215. data/lib/chef/resource/windows_user_privilege.rb +4 -4
  216. data/lib/chef/resource/windows_workgroup.rb +1 -2
  217. data/lib/chef/resource_builder.rb +8 -2
  218. data/lib/chef/resources.rb +1 -1
  219. data/lib/chef/run_lock.rb +1 -1
  220. data/lib/chef/runner.rb +1 -1
  221. data/lib/chef/shell/ext.rb +3 -3
  222. data/lib/chef/user.rb +0 -1
  223. data/lib/chef/user_v1.rb +3 -4
  224. data/lib/chef/util/dsc/configuration_generator.rb +1 -0
  225. data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
  226. data/lib/chef/version.rb +1 -1
  227. data/lib/chef/win32/api.rb +9 -2
  228. data/lib/chef/win32/registry.rb +4 -2
  229. data/spec/data/cookbooks/openldap/libraries/openldap.rb +1 -1
  230. data/spec/data/lwrp/resources/bar.rb +2 -0
  231. data/spec/data/lwrp/resources/buck_passer.rb +1 -0
  232. data/spec/data/lwrp/resources/buck_passer_2.rb +1 -0
  233. data/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb +1 -0
  234. data/spec/data/lwrp/resources/foo.rb +2 -0
  235. data/spec/data/lwrp/resources/inline_compiler.rb +1 -0
  236. data/spec/data/lwrp/resources/monkey_name_printer.rb +1 -0
  237. data/spec/data/lwrp/resources/paint_drying_watcher.rb +1 -0
  238. data/spec/data/lwrp/resources/thumb_twiddler.rb +1 -0
  239. data/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb +2 -0
  240. data/spec/data/lwrp_const_scoping/resources/conflict.rb +1 -0
  241. data/spec/data/lwrp_override/resources/foo.rb +1 -0
  242. data/spec/data/rubygems.org/nonexistent_gem-info +1 -0
  243. data/spec/data/rubygems.org/sexp_processor-info +49 -0
  244. data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
  245. data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
  246. data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
  247. data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
  248. data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
  249. data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +2 -0
  250. data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
  251. data/spec/data/run_context/cookbooks/test/resources/resource.rb +2 -0
  252. data/spec/functional/dsl/registry_helper_spec.rb +1 -1
  253. data/spec/functional/resource/aixinit_service_spec.rb +7 -7
  254. data/spec/functional/resource/apt_package_spec.rb +1 -1
  255. data/spec/functional/resource/chocolatey_package_spec.rb +13 -0
  256. data/spec/functional/resource/cron_spec.rb +1 -1
  257. data/spec/functional/resource/dnf_package_spec.rb +857 -534
  258. data/spec/functional/resource/group_spec.rb +1 -1
  259. data/spec/functional/resource/link_spec.rb +1 -1
  260. data/spec/functional/resource/registry_spec.rb +8 -8
  261. data/spec/functional/resource/remote_file_spec.rb +1 -1
  262. data/spec/functional/resource/user/mac_user_spec.rb +2 -2
  263. data/spec/functional/resource/windows_certificate_spec.rb +92 -35
  264. data/spec/functional/resource/windows_env_spec.rb +2 -2
  265. data/spec/functional/resource/yum_package_spec.rb +495 -428
  266. data/spec/functional/version_spec.rb +1 -1
  267. data/spec/functional/win32/registry_spec.rb +1 -1
  268. data/spec/integration/client/client_spec.rb +5 -22
  269. data/spec/integration/client/exit_code_spec.rb +1 -1
  270. data/spec/integration/client/ipv6_spec.rb +1 -1
  271. data/spec/integration/compliance/compliance_spec.rb +3 -2
  272. data/spec/integration/ohai/ohai_spec.rb +7 -6
  273. data/spec/integration/recipes/accumulator_spec.rb +13 -1
  274. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +5 -1
  275. data/spec/integration/recipes/lwrp_spec.rb +3 -1
  276. data/spec/integration/recipes/notifies_spec.rb +15 -1
  277. data/spec/integration/recipes/notifying_block_spec.rb +2 -1
  278. data/spec/integration/recipes/recipe_dsl_spec.rb +9 -9
  279. data/spec/integration/recipes/unified_mode_spec.rb +71 -1
  280. data/spec/integration/recipes/use_partial_spec.rb +4 -1
  281. data/spec/spec_helper.rb +14 -13
  282. data/spec/support/chef_helpers.rb +1 -17
  283. data/spec/support/lib/chef/resource/with_state.rb +0 -1
  284. data/spec/support/lib/chef/resource/zen_follower.rb +0 -1
  285. data/spec/support/lib/chef/resource/zen_master.rb +0 -1
  286. data/spec/support/matchers/leak.rb +7 -9
  287. data/spec/support/platform_helpers.rb +5 -8
  288. data/spec/support/shared/functional/execute_resource.rb +1 -1
  289. data/spec/support/shared/integration/integration_helper.rb +0 -1
  290. data/spec/support/shared/unit/provider/file.rb +15 -1
  291. data/spec/support/shared/unit/script_resource.rb +2 -2
  292. data/spec/unit/application/solo_spec.rb +2 -2
  293. data/spec/unit/chef_fs/diff_spec.rb +1 -1
  294. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +1 -1
  295. data/spec/unit/chef_fs/file_system_spec.rb +1 -1
  296. data/spec/unit/compliance/fetcher/automate_spec.rb +0 -16
  297. data/spec/unit/compliance/reporter/automate_spec.rb +26 -2
  298. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +20 -0
  299. data/spec/unit/compliance/reporter/compliance_enforcer_spec.rb +1 -0
  300. data/spec/unit/compliance/runner_spec.rb +85 -10
  301. data/spec/unit/data_bag_item_spec.rb +1 -6
  302. data/spec/unit/dsl/reboot_pending_spec.rb +2 -2
  303. data/spec/unit/dsl/registry_helper_spec.rb +1 -1
  304. data/spec/unit/lwrp_spec.rb +1 -1
  305. data/spec/unit/mixin/params_validate_spec.rb +4 -3
  306. data/spec/unit/node/attribute_spec.rb +1 -1
  307. data/spec/unit/node_spec.rb +78 -0
  308. data/spec/unit/org_group_spec.rb +45 -0
  309. data/spec/unit/property_spec.rb +23 -22
  310. data/spec/unit/provider/cron_spec.rb +1 -1
  311. data/spec/unit/provider/group/gpasswd_spec.rb +2 -2
  312. data/spec/unit/provider/group/groupmod_spec.rb +2 -2
  313. data/spec/unit/provider/group/pw_spec.rb +2 -2
  314. data/spec/unit/provider/group_spec.rb +1 -1
  315. data/spec/unit/provider/link_spec.rb +1 -1
  316. data/spec/unit/provider/mount/mount_spec.rb +51 -0
  317. data/spec/unit/provider/package/apt_spec.rb +84 -18
  318. data/spec/unit/provider/package/deb_spec.rb +3 -3
  319. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -0
  320. data/spec/unit/provider/package/rubygems_spec.rb +21 -33
  321. data/spec/unit/provider/package/yum/python_helper_spec.rb +1 -0
  322. data/spec/unit/provider/service/arch_service_spec.rb +1 -0
  323. data/spec/unit/provider/service/debian_service_spec.rb +1 -0
  324. data/spec/unit/provider/service/macosx_spec.rb +5 -5
  325. data/spec/unit/provider/service/systemd_service_spec.rb +138 -23
  326. data/spec/unit/provider/service/upstart_service_spec.rb +0 -29
  327. data/spec/unit/provider/service/windows_spec.rb +2 -2
  328. data/spec/unit/provider/subversion_spec.rb +2 -2
  329. data/spec/unit/provider/systemd_unit_spec.rb +79 -60
  330. data/spec/unit/provider/zypper_repository_spec.rb +2 -2
  331. data/spec/unit/provider_spec.rb +0 -8
  332. data/spec/unit/resource/chef_client_cron_spec.rb +8 -8
  333. data/spec/unit/resource/inspec_waiver_file_entry_spec.rb +80 -0
  334. data/spec/unit/resource/powershell_script_spec.rb +2 -2
  335. data/spec/unit/resource/windows_task_spec.rb +1 -1
  336. data/spec/unit/user_spec.rb +1 -1
  337. data/spec/unit/user_v1_spec.rb +6 -4
  338. data/tasks/rspec.rb +9 -6
  339. metadata +23 -528
  340. data/bin/knife +0 -24
  341. data/lib/chef/application/knife.rb +0 -234
  342. data/lib/chef/application/windows_service.rb +0 -338
  343. data/lib/chef/application/windows_service_manager.rb +0 -205
  344. data/lib/chef/chef_fs/knife.rb +0 -160
  345. data/lib/chef/chef_fs/parallelizer.rb +0 -102
  346. data/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb +0 -35
  347. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +0 -278
  348. data/lib/chef/cookbook_site_streaming_uploader.rb +0 -244
  349. data/lib/chef/knife.rb +0 -665
  350. data/lib/chef/knife/acl_add.rb +0 -57
  351. data/lib/chef/knife/acl_base.rb +0 -183
  352. data/lib/chef/knife/acl_bulk_add.rb +0 -78
  353. data/lib/chef/knife/acl_bulk_remove.rb +0 -83
  354. data/lib/chef/knife/acl_remove.rb +0 -62
  355. data/lib/chef/knife/acl_show.rb +0 -56
  356. data/lib/chef/knife/bootstrap.rb +0 -1192
  357. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +0 -162
  358. data/lib/chef/knife/bootstrap/client_builder.rb +0 -212
  359. data/lib/chef/knife/bootstrap/templates/README.md +0 -11
  360. data/lib/chef/knife/bootstrap/templates/chef-full.erb +0 -242
  361. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +0 -278
  362. data/lib/chef/knife/bootstrap/train_connector.rb +0 -336
  363. data/lib/chef/knife/client_bulk_delete.rb +0 -104
  364. data/lib/chef/knife/client_create.rb +0 -101
  365. data/lib/chef/knife/client_delete.rb +0 -62
  366. data/lib/chef/knife/client_edit.rb +0 -52
  367. data/lib/chef/knife/client_key_create.rb +0 -73
  368. data/lib/chef/knife/client_key_delete.rb +0 -80
  369. data/lib/chef/knife/client_key_edit.rb +0 -83
  370. data/lib/chef/knife/client_key_list.rb +0 -73
  371. data/lib/chef/knife/client_key_show.rb +0 -80
  372. data/lib/chef/knife/client_list.rb +0 -41
  373. data/lib/chef/knife/client_reregister.rb +0 -58
  374. data/lib/chef/knife/client_show.rb +0 -48
  375. data/lib/chef/knife/config_get.rb +0 -39
  376. data/lib/chef/knife/config_get_profile.rb +0 -37
  377. data/lib/chef/knife/config_list.rb +0 -139
  378. data/lib/chef/knife/config_list_profiles.rb +0 -37
  379. data/lib/chef/knife/config_show.rb +0 -127
  380. data/lib/chef/knife/config_use.rb +0 -61
  381. data/lib/chef/knife/config_use_profile.rb +0 -47
  382. data/lib/chef/knife/configure.rb +0 -150
  383. data/lib/chef/knife/configure_client.rb +0 -48
  384. data/lib/chef/knife/cookbook_bulk_delete.rb +0 -71
  385. data/lib/chef/knife/cookbook_delete.rb +0 -151
  386. data/lib/chef/knife/cookbook_download.rb +0 -142
  387. data/lib/chef/knife/cookbook_list.rb +0 -47
  388. data/lib/chef/knife/cookbook_metadata.rb +0 -106
  389. data/lib/chef/knife/cookbook_metadata_from_file.rb +0 -49
  390. data/lib/chef/knife/cookbook_show.rb +0 -98
  391. data/lib/chef/knife/cookbook_upload.rb +0 -292
  392. data/lib/chef/knife/core/bootstrap_context.rb +0 -264
  393. data/lib/chef/knife/core/cookbook_scm_repo.rb +0 -159
  394. data/lib/chef/knife/core/formatting_options.rb +0 -49
  395. data/lib/chef/knife/core/gem_glob_loader.rb +0 -138
  396. data/lib/chef/knife/core/generic_presenter.rb +0 -232
  397. data/lib/chef/knife/core/hashed_command_loader.rb +0 -100
  398. data/lib/chef/knife/core/node_editor.rb +0 -130
  399. data/lib/chef/knife/core/node_presenter.rb +0 -133
  400. data/lib/chef/knife/core/object_loader.rb +0 -115
  401. data/lib/chef/knife/core/status_presenter.rb +0 -147
  402. data/lib/chef/knife/core/subcommand_loader.rb +0 -203
  403. data/lib/chef/knife/core/text_formatter.rb +0 -85
  404. data/lib/chef/knife/core/ui.rb +0 -338
  405. data/lib/chef/knife/core/windows_bootstrap_context.rb +0 -406
  406. data/lib/chef/knife/data_bag_create.rb +0 -81
  407. data/lib/chef/knife/data_bag_delete.rb +0 -49
  408. data/lib/chef/knife/data_bag_edit.rb +0 -74
  409. data/lib/chef/knife/data_bag_from_file.rb +0 -113
  410. data/lib/chef/knife/data_bag_list.rb +0 -42
  411. data/lib/chef/knife/data_bag_secret_options.rb +0 -122
  412. data/lib/chef/knife/data_bag_show.rb +0 -69
  413. data/lib/chef/knife/delete.rb +0 -125
  414. data/lib/chef/knife/deps.rb +0 -156
  415. data/lib/chef/knife/diff.rb +0 -83
  416. data/lib/chef/knife/download.rb +0 -84
  417. data/lib/chef/knife/edit.rb +0 -88
  418. data/lib/chef/knife/environment_compare.rb +0 -128
  419. data/lib/chef/knife/environment_create.rb +0 -52
  420. data/lib/chef/knife/environment_delete.rb +0 -44
  421. data/lib/chef/knife/environment_edit.rb +0 -44
  422. data/lib/chef/knife/environment_from_file.rb +0 -84
  423. data/lib/chef/knife/environment_list.rb +0 -41
  424. data/lib/chef/knife/environment_show.rb +0 -47
  425. data/lib/chef/knife/exec.rb +0 -99
  426. data/lib/chef/knife/group_add.rb +0 -55
  427. data/lib/chef/knife/group_create.rb +0 -49
  428. data/lib/chef/knife/group_destroy.rb +0 -53
  429. data/lib/chef/knife/group_list.rb +0 -43
  430. data/lib/chef/knife/group_remove.rb +0 -56
  431. data/lib/chef/knife/group_show.rb +0 -49
  432. data/lib/chef/knife/key_create.rb +0 -112
  433. data/lib/chef/knife/key_create_base.rb +0 -50
  434. data/lib/chef/knife/key_delete.rb +0 -55
  435. data/lib/chef/knife/key_edit.rb +0 -118
  436. data/lib/chef/knife/key_edit_base.rb +0 -55
  437. data/lib/chef/knife/key_list.rb +0 -90
  438. data/lib/chef/knife/key_list_base.rb +0 -45
  439. data/lib/chef/knife/key_show.rb +0 -53
  440. data/lib/chef/knife/list.rb +0 -177
  441. data/lib/chef/knife/node_bulk_delete.rb +0 -75
  442. data/lib/chef/knife/node_create.rb +0 -47
  443. data/lib/chef/knife/node_delete.rb +0 -46
  444. data/lib/chef/knife/node_edit.rb +0 -70
  445. data/lib/chef/knife/node_environment_set.rb +0 -53
  446. data/lib/chef/knife/node_from_file.rb +0 -51
  447. data/lib/chef/knife/node_list.rb +0 -44
  448. data/lib/chef/knife/node_policy_set.rb +0 -79
  449. data/lib/chef/knife/node_run_list_add.rb +0 -104
  450. data/lib/chef/knife/node_run_list_remove.rb +0 -67
  451. data/lib/chef/knife/node_run_list_set.rb +0 -66
  452. data/lib/chef/knife/node_show.rb +0 -63
  453. data/lib/chef/knife/null.rb +0 -12
  454. data/lib/chef/knife/raw.rb +0 -123
  455. data/lib/chef/knife/recipe_list.rb +0 -32
  456. data/lib/chef/knife/rehash.rb +0 -50
  457. data/lib/chef/knife/role_bulk_delete.rb +0 -66
  458. data/lib/chef/knife/role_create.rb +0 -53
  459. data/lib/chef/knife/role_delete.rb +0 -46
  460. data/lib/chef/knife/role_edit.rb +0 -45
  461. data/lib/chef/knife/role_env_run_list_add.rb +0 -87
  462. data/lib/chef/knife/role_env_run_list_clear.rb +0 -55
  463. data/lib/chef/knife/role_env_run_list_remove.rb +0 -57
  464. data/lib/chef/knife/role_env_run_list_replace.rb +0 -60
  465. data/lib/chef/knife/role_env_run_list_set.rb +0 -70
  466. data/lib/chef/knife/role_from_file.rb +0 -51
  467. data/lib/chef/knife/role_list.rb +0 -42
  468. data/lib/chef/knife/role_run_list_add.rb +0 -87
  469. data/lib/chef/knife/role_run_list_clear.rb +0 -55
  470. data/lib/chef/knife/role_run_list_remove.rb +0 -56
  471. data/lib/chef/knife/role_run_list_replace.rb +0 -60
  472. data/lib/chef/knife/role_run_list_set.rb +0 -69
  473. data/lib/chef/knife/role_show.rb +0 -48
  474. data/lib/chef/knife/search.rb +0 -194
  475. data/lib/chef/knife/serve.rb +0 -65
  476. data/lib/chef/knife/show.rb +0 -72
  477. data/lib/chef/knife/ssh.rb +0 -645
  478. data/lib/chef/knife/ssl_check.rb +0 -284
  479. data/lib/chef/knife/ssl_fetch.rb +0 -161
  480. data/lib/chef/knife/status.rb +0 -95
  481. data/lib/chef/knife/supermarket_download.rb +0 -121
  482. data/lib/chef/knife/supermarket_install.rb +0 -192
  483. data/lib/chef/knife/supermarket_list.rb +0 -76
  484. data/lib/chef/knife/supermarket_search.rb +0 -53
  485. data/lib/chef/knife/supermarket_share.rb +0 -166
  486. data/lib/chef/knife/supermarket_show.rb +0 -66
  487. data/lib/chef/knife/supermarket_unshare.rb +0 -61
  488. data/lib/chef/knife/tag_create.rb +0 -52
  489. data/lib/chef/knife/tag_delete.rb +0 -60
  490. data/lib/chef/knife/tag_list.rb +0 -47
  491. data/lib/chef/knife/upload.rb +0 -86
  492. data/lib/chef/knife/user_create.rb +0 -107
  493. data/lib/chef/knife/user_delete.rb +0 -44
  494. data/lib/chef/knife/user_dissociate.rb +0 -42
  495. data/lib/chef/knife/user_edit.rb +0 -52
  496. data/lib/chef/knife/user_invite_add.rb +0 -43
  497. data/lib/chef/knife/user_invite_list.rb +0 -34
  498. data/lib/chef/knife/user_invite_rescind.rb +0 -63
  499. data/lib/chef/knife/user_key_create.rb +0 -73
  500. data/lib/chef/knife/user_key_delete.rb +0 -80
  501. data/lib/chef/knife/user_key_edit.rb +0 -83
  502. data/lib/chef/knife/user_key_list.rb +0 -73
  503. data/lib/chef/knife/user_key_show.rb +0 -80
  504. data/lib/chef/knife/user_list.rb +0 -42
  505. data/lib/chef/knife/user_reregister.rb +0 -59
  506. data/lib/chef/knife/user_show.rb +0 -48
  507. data/lib/chef/knife/xargs.rb +0 -282
  508. data/lib/chef/knife/yaml_convert.rb +0 -91
  509. data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +0 -79
  510. data/lib/chef/provider/package/yum/simplejson/__init__.py +0 -318
  511. data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
  512. data/lib/chef/provider/package/yum/simplejson/decoder.py +0 -354
  513. data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
  514. data/lib/chef/provider/package/yum/simplejson/encoder.py +0 -440
  515. data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
  516. data/lib/chef/provider/package/yum/simplejson/scanner.py +0 -65
  517. data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
  518. data/lib/chef/provider/package/yum/simplejson/tool.py +0 -37
  519. data/lib/chef/resource/user/dscl_user.rb +0 -35
  520. data/spec/functional/knife/configure_spec.rb +0 -33
  521. data/spec/functional/knife/cookbook_delete_spec.rb +0 -156
  522. data/spec/functional/knife/exec_spec.rb +0 -55
  523. data/spec/functional/knife/rehash_spec.rb +0 -39
  524. data/spec/functional/knife/smoke_test.rb +0 -42
  525. data/spec/functional/knife/ssh_spec.rb +0 -352
  526. data/spec/functional/resource/user/dscl_spec.rb +0 -188
  527. data/spec/functional/resource/windows_service_spec.rb +0 -105
  528. data/spec/functional/win32/service_manager_spec.rb +0 -220
  529. data/spec/integration/knife/chef_fs_data_store_spec.rb +0 -557
  530. data/spec/integration/knife/chef_repo_path_spec.rb +0 -962
  531. data/spec/integration/knife/chef_repository_file_system_spec.rb +0 -200
  532. data/spec/integration/knife/chefignore_spec.rb +0 -301
  533. data/spec/integration/knife/client_bulk_delete_spec.rb +0 -131
  534. data/spec/integration/knife/client_create_spec.rb +0 -70
  535. data/spec/integration/knife/client_delete_spec.rb +0 -64
  536. data/spec/integration/knife/client_key_create_spec.rb +0 -66
  537. data/spec/integration/knife/client_key_delete_spec.rb +0 -43
  538. data/spec/integration/knife/client_key_list_spec.rb +0 -61
  539. data/spec/integration/knife/client_key_show_spec.rb +0 -45
  540. data/spec/integration/knife/client_list_spec.rb +0 -49
  541. data/spec/integration/knife/client_show_spec.rb +0 -37
  542. data/spec/integration/knife/common_options_spec.rb +0 -174
  543. data/spec/integration/knife/config_list_spec.rb +0 -220
  544. data/spec/integration/knife/config_show_spec.rb +0 -192
  545. data/spec/integration/knife/config_use_spec.rb +0 -198
  546. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +0 -113
  547. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +0 -65
  548. data/spec/integration/knife/cookbook_download_spec.rb +0 -72
  549. data/spec/integration/knife/cookbook_list_spec.rb +0 -55
  550. data/spec/integration/knife/cookbook_show_spec.rb +0 -149
  551. data/spec/integration/knife/cookbook_upload_spec.rb +0 -128
  552. data/spec/integration/knife/data_bag_create_spec.rb +0 -125
  553. data/spec/integration/knife/data_bag_delete_spec.rb +0 -59
  554. data/spec/integration/knife/data_bag_edit_spec.rb +0 -105
  555. data/spec/integration/knife/data_bag_from_file_spec.rb +0 -116
  556. data/spec/integration/knife/data_bag_list_spec.rb +0 -44
  557. data/spec/integration/knife/data_bag_show_spec.rb +0 -95
  558. data/spec/integration/knife/delete_spec.rb +0 -1018
  559. data/spec/integration/knife/deps_spec.rb +0 -703
  560. data/spec/integration/knife/diff_spec.rb +0 -605
  561. data/spec/integration/knife/download_spec.rb +0 -1336
  562. data/spec/integration/knife/environment_compare_spec.rb +0 -75
  563. data/spec/integration/knife/environment_create_spec.rb +0 -41
  564. data/spec/integration/knife/environment_delete_spec.rb +0 -37
  565. data/spec/integration/knife/environment_from_file_spec.rb +0 -116
  566. data/spec/integration/knife/environment_list_spec.rb +0 -42
  567. data/spec/integration/knife/environment_show_spec.rb +0 -77
  568. data/spec/integration/knife/list_spec.rb +0 -1060
  569. data/spec/integration/knife/node_bulk_delete_spec.rb +0 -52
  570. data/spec/integration/knife/node_create_spec.rb +0 -47
  571. data/spec/integration/knife/node_delete_spec.rb +0 -48
  572. data/spec/integration/knife/node_environment_set_spec.rb +0 -46
  573. data/spec/integration/knife/node_from_file_spec.rb +0 -59
  574. data/spec/integration/knife/node_list_spec.rb +0 -45
  575. data/spec/integration/knife/node_run_list_add_spec.rb +0 -54
  576. data/spec/integration/knife/node_run_list_remove_spec.rb +0 -36
  577. data/spec/integration/knife/node_run_list_set_spec.rb +0 -41
  578. data/spec/integration/knife/node_show_spec.rb +0 -36
  579. data/spec/integration/knife/raw_spec.rb +0 -297
  580. data/spec/integration/knife/redirection_spec.rb +0 -64
  581. data/spec/integration/knife/role_bulk_delete_spec.rb +0 -52
  582. data/spec/integration/knife/role_create_spec.rb +0 -41
  583. data/spec/integration/knife/role_delete_spec.rb +0 -48
  584. data/spec/integration/knife/role_from_file_spec.rb +0 -96
  585. data/spec/integration/knife/role_list_spec.rb +0 -45
  586. data/spec/integration/knife/role_show_spec.rb +0 -51
  587. data/spec/integration/knife/search_node_spec.rb +0 -40
  588. data/spec/integration/knife/serve_spec.rb +0 -92
  589. data/spec/integration/knife/show_spec.rb +0 -197
  590. data/spec/integration/knife/upload_spec.rb +0 -1617
  591. data/spec/support/shared/functional/win32_service.rb +0 -57
  592. data/spec/unit/application/knife_spec.rb +0 -241
  593. data/spec/unit/chef_fs/parallelizer_spec.rb +0 -479
  594. data/spec/unit/cookbook_site_streaming_uploader_spec.rb +0 -198
  595. data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +0 -152
  596. data/spec/unit/knife/bootstrap/client_builder_spec.rb +0 -207
  597. data/spec/unit/knife/bootstrap/train_connector_spec.rb +0 -244
  598. data/spec/unit/knife/bootstrap_spec.rb +0 -2220
  599. data/spec/unit/knife/client_bulk_delete_spec.rb +0 -166
  600. data/spec/unit/knife/client_create_spec.rb +0 -169
  601. data/spec/unit/knife/client_delete_spec.rb +0 -99
  602. data/spec/unit/knife/client_edit_spec.rb +0 -53
  603. data/spec/unit/knife/client_list_spec.rb +0 -34
  604. data/spec/unit/knife/client_reregister_spec.rb +0 -62
  605. data/spec/unit/knife/client_show_spec.rb +0 -52
  606. data/spec/unit/knife/configure_client_spec.rb +0 -81
  607. data/spec/unit/knife/configure_spec.rb +0 -190
  608. data/spec/unit/knife/cookbook_bulk_delete_spec.rb +0 -87
  609. data/spec/unit/knife/cookbook_delete_spec.rb +0 -239
  610. data/spec/unit/knife/cookbook_download_spec.rb +0 -255
  611. data/spec/unit/knife/cookbook_list_spec.rb +0 -88
  612. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +0 -72
  613. data/spec/unit/knife/cookbook_metadata_spec.rb +0 -182
  614. data/spec/unit/knife/cookbook_show_spec.rb +0 -253
  615. data/spec/unit/knife/cookbook_upload_spec.rb +0 -364
  616. data/spec/unit/knife/core/bootstrap_context_spec.rb +0 -287
  617. data/spec/unit/knife/core/cookbook_scm_repo_spec.rb +0 -187
  618. data/spec/unit/knife/core/gem_glob_loader_spec.rb +0 -209
  619. data/spec/unit/knife/core/hashed_command_loader_spec.rb +0 -112
  620. data/spec/unit/knife/core/node_editor_spec.rb +0 -211
  621. data/spec/unit/knife/core/object_loader_spec.rb +0 -81
  622. data/spec/unit/knife/core/status_presenter_spec.rb +0 -54
  623. data/spec/unit/knife/core/subcommand_loader_spec.rb +0 -64
  624. data/spec/unit/knife/core/ui_spec.rb +0 -656
  625. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +0 -238
  626. data/spec/unit/knife/data_bag_create_spec.rb +0 -175
  627. data/spec/unit/knife/data_bag_edit_spec.rb +0 -126
  628. data/spec/unit/knife/data_bag_from_file_spec.rb +0 -174
  629. data/spec/unit/knife/data_bag_secret_options_spec.rb +0 -173
  630. data/spec/unit/knife/data_bag_show_spec.rb +0 -139
  631. data/spec/unit/knife/environment_compare_spec.rb +0 -112
  632. data/spec/unit/knife/environment_create_spec.rb +0 -91
  633. data/spec/unit/knife/environment_delete_spec.rb +0 -71
  634. data/spec/unit/knife/environment_edit_spec.rb +0 -79
  635. data/spec/unit/knife/environment_from_file_spec.rb +0 -90
  636. data/spec/unit/knife/environment_list_spec.rb +0 -54
  637. data/spec/unit/knife/environment_show_spec.rb +0 -52
  638. data/spec/unit/knife/key_create_spec.rb +0 -223
  639. data/spec/unit/knife/key_delete_spec.rb +0 -133
  640. data/spec/unit/knife/key_edit_spec.rb +0 -264
  641. data/spec/unit/knife/key_helper.rb +0 -74
  642. data/spec/unit/knife/key_list_spec.rb +0 -216
  643. data/spec/unit/knife/key_show_spec.rb +0 -126
  644. data/spec/unit/knife/node_bulk_delete_spec.rb +0 -94
  645. data/spec/unit/knife/node_delete_spec.rb +0 -77
  646. data/spec/unit/knife/node_edit_spec.rb +0 -116
  647. data/spec/unit/knife/node_environment_set_spec.rb +0 -61
  648. data/spec/unit/knife/node_from_file_spec.rb +0 -59
  649. data/spec/unit/knife/node_list_spec.rb +0 -62
  650. data/spec/unit/knife/node_policy_set_spec.rb +0 -122
  651. data/spec/unit/knife/node_run_list_add_spec.rb +0 -145
  652. data/spec/unit/knife/node_run_list_remove_spec.rb +0 -106
  653. data/spec/unit/knife/node_run_list_set_spec.rb +0 -115
  654. data/spec/unit/knife/node_show_spec.rb +0 -65
  655. data/spec/unit/knife/raw_spec.rb +0 -43
  656. data/spec/unit/knife/role_bulk_delete_spec.rb +0 -80
  657. data/spec/unit/knife/role_create_spec.rb +0 -80
  658. data/spec/unit/knife/role_delete_spec.rb +0 -67
  659. data/spec/unit/knife/role_edit_spec.rb +0 -77
  660. data/spec/unit/knife/role_env_run_list_add_spec.rb +0 -217
  661. data/spec/unit/knife/role_env_run_list_clear_spec.rb +0 -94
  662. data/spec/unit/knife/role_env_run_list_remove_spec.rb +0 -102
  663. data/spec/unit/knife/role_env_run_list_replace_spec.rb +0 -105
  664. data/spec/unit/knife/role_env_run_list_set_spec.rb +0 -99
  665. data/spec/unit/knife/role_from_file_spec.rb +0 -69
  666. data/spec/unit/knife/role_list_spec.rb +0 -54
  667. data/spec/unit/knife/role_run_list_add_spec.rb +0 -179
  668. data/spec/unit/knife/role_run_list_clear_spec.rb +0 -84
  669. data/spec/unit/knife/role_run_list_remove_spec.rb +0 -92
  670. data/spec/unit/knife/role_run_list_replace_spec.rb +0 -98
  671. data/spec/unit/knife/role_run_list_set_spec.rb +0 -89
  672. data/spec/unit/knife/role_show_spec.rb +0 -59
  673. data/spec/unit/knife/ssh_spec.rb +0 -403
  674. data/spec/unit/knife/ssl_check_spec.rb +0 -256
  675. data/spec/unit/knife/ssl_fetch_spec.rb +0 -222
  676. data/spec/unit/knife/status_spec.rb +0 -112
  677. data/spec/unit/knife/supermarket_download_spec.rb +0 -152
  678. data/spec/unit/knife/supermarket_install_spec.rb +0 -202
  679. data/spec/unit/knife/supermarket_list_spec.rb +0 -70
  680. data/spec/unit/knife/supermarket_search_spec.rb +0 -85
  681. data/spec/unit/knife/supermarket_share_spec.rb +0 -208
  682. data/spec/unit/knife/supermarket_unshare_spec.rb +0 -78
  683. data/spec/unit/knife/tag_create_spec.rb +0 -23
  684. data/spec/unit/knife/tag_delete_spec.rb +0 -25
  685. data/spec/unit/knife/tag_list_spec.rb +0 -23
  686. data/spec/unit/knife/user_create_spec.rb +0 -184
  687. data/spec/unit/knife/user_delete_spec.rb +0 -46
  688. data/spec/unit/knife/user_edit_spec.rb +0 -48
  689. data/spec/unit/knife/user_list_spec.rb +0 -36
  690. data/spec/unit/knife/user_reregister_spec.rb +0 -56
  691. data/spec/unit/knife/user_show_spec.rb +0 -46
  692. data/spec/unit/knife_spec.rb +0 -634
  693. data/spec/unit/provider/user/dscl_spec.rb +0 -699
  694. data/spec/unit/windows_service_spec.rb +0 -118
@@ -1,354 +0,0 @@
1
- """Implementation of JSONDecoder
2
- """
3
- import re
4
- import sys
5
- import struct
6
-
7
- from simplejson.scanner import make_scanner
8
- try:
9
- from simplejson._speedups import scanstring as c_scanstring
10
- except ImportError:
11
- c_scanstring = None
12
-
13
- __all__ = ['JSONDecoder']
14
-
15
- FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
16
-
17
- def _floatconstants():
18
- _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
19
- if sys.byteorder != 'big':
20
- _BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
21
- nan, inf = struct.unpack('dd', _BYTES)
22
- return nan, inf, -inf
23
-
24
- NaN, PosInf, NegInf = _floatconstants()
25
-
26
-
27
- def linecol(doc, pos):
28
- lineno = doc.count('\n', 0, pos) + 1
29
- if lineno == 1:
30
- colno = pos
31
- else:
32
- colno = pos - doc.rindex('\n', 0, pos)
33
- return lineno, colno
34
-
35
-
36
- def errmsg(msg, doc, pos, end=None):
37
- # Note that this function is called from _speedups
38
- lineno, colno = linecol(doc, pos)
39
- if end is None:
40
- #fmt = '{0}: line {1} column {2} (char {3})'
41
- #return fmt.format(msg, lineno, colno, pos)
42
- fmt = '%s: line %d column %d (char %d)'
43
- return fmt % (msg, lineno, colno, pos)
44
- endlineno, endcolno = linecol(doc, end)
45
- #fmt = '{0}: line {1} column {2} - line {3} column {4} (char {5} - {6})'
46
- #return fmt.format(msg, lineno, colno, endlineno, endcolno, pos, end)
47
- fmt = '%s: line %d column %d - line %d column %d (char %d - %d)'
48
- return fmt % (msg, lineno, colno, endlineno, endcolno, pos, end)
49
-
50
-
51
- _CONSTANTS = {
52
- '-Infinity': NegInf,
53
- 'Infinity': PosInf,
54
- 'NaN': NaN,
55
- }
56
-
57
- STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
58
- BACKSLASH = {
59
- '"': u'"', '\\': u'\\', '/': u'/',
60
- 'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
61
- }
62
-
63
- DEFAULT_ENCODING = "utf-8"
64
-
65
- def py_scanstring(s, end, encoding=None, strict=True, _b=BACKSLASH, _m=STRINGCHUNK.match):
66
- """Scan the string s for a JSON string. End is the index of the
67
- character in s after the quote that started the JSON string.
68
- Unescapes all valid JSON string escape sequences and raises ValueError
69
- on attempt to decode an invalid string. If strict is False then literal
70
- control characters are allowed in the string.
71
-
72
- Returns a tuple of the decoded string and the index of the character in s
73
- after the end quote."""
74
- if encoding is None:
75
- encoding = DEFAULT_ENCODING
76
- chunks = []
77
- _append = chunks.append
78
- begin = end - 1
79
- while 1:
80
- chunk = _m(s, end)
81
- if chunk is None:
82
- raise ValueError(
83
- errmsg("Unterminated string starting at", s, begin))
84
- end = chunk.end()
85
- content, terminator = chunk.groups()
86
- # Content is contains zero or more unescaped string characters
87
- if content:
88
- if not isinstance(content, unicode):
89
- content = unicode(content, encoding)
90
- _append(content)
91
- # Terminator is the end of string, a literal control character,
92
- # or a backslash denoting that an escape sequence follows
93
- if terminator == '"':
94
- break
95
- elif terminator != '\\':
96
- if strict:
97
- msg = "Invalid control character %r at" % (terminator,)
98
- #msg = "Invalid control character {0!r} at".format(terminator)
99
- raise ValueError(errmsg(msg, s, end))
100
- else:
101
- _append(terminator)
102
- continue
103
- try:
104
- esc = s[end]
105
- except IndexError:
106
- raise ValueError(
107
- errmsg("Unterminated string starting at", s, begin))
108
- # If not a unicode escape sequence, must be in the lookup table
109
- if esc != 'u':
110
- try:
111
- char = _b[esc]
112
- except KeyError:
113
- msg = "Invalid \\escape: " + repr(esc)
114
- raise ValueError(errmsg(msg, s, end))
115
- end += 1
116
- else:
117
- # Unicode escape sequence
118
- esc = s[end + 1:end + 5]
119
- next_end = end + 5
120
- if len(esc) != 4:
121
- msg = "Invalid \\uXXXX escape"
122
- raise ValueError(errmsg(msg, s, end))
123
- uni = int(esc, 16)
124
- # Check for surrogate pair on UCS-4 systems
125
- if 0xd800 <= uni <= 0xdbff and sys.maxunicode > 65535:
126
- msg = "Invalid \\uXXXX\\uXXXX surrogate pair"
127
- if not s[end + 5:end + 7] == '\\u':
128
- raise ValueError(errmsg(msg, s, end))
129
- esc2 = s[end + 7:end + 11]
130
- if len(esc2) != 4:
131
- raise ValueError(errmsg(msg, s, end))
132
- uni2 = int(esc2, 16)
133
- uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
134
- next_end += 6
135
- char = unichr(uni)
136
- end = next_end
137
- # Append the unescaped character
138
- _append(char)
139
- return u''.join(chunks), end
140
-
141
-
142
- # Use speedup if available
143
- scanstring = c_scanstring or py_scanstring
144
-
145
- WHITESPACE = re.compile(r'[ \t\n\r]*', FLAGS)
146
- WHITESPACE_STR = ' \t\n\r'
147
-
148
- def JSONObject((s, end), encoding, strict, scan_once, object_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
149
- pairs = {}
150
- # Use a slice to prevent IndexError from being raised, the following
151
- # check will raise a more specific ValueError if the string is empty
152
- nextchar = s[end:end + 1]
153
- # Normally we expect nextchar == '"'
154
- if nextchar != '"':
155
- if nextchar in _ws:
156
- end = _w(s, end).end()
157
- nextchar = s[end:end + 1]
158
- # Trivial empty object
159
- if nextchar == '}':
160
- return pairs, end + 1
161
- elif nextchar != '"':
162
- raise ValueError(errmsg("Expecting property name", s, end))
163
- end += 1
164
- while True:
165
- key, end = scanstring(s, end, encoding, strict)
166
-
167
- # To skip some function call overhead we optimize the fast paths where
168
- # the JSON key separator is ": " or just ":".
169
- if s[end:end + 1] != ':':
170
- end = _w(s, end).end()
171
- if s[end:end + 1] != ':':
172
- raise ValueError(errmsg("Expecting : delimiter", s, end))
173
-
174
- end += 1
175
-
176
- try:
177
- if s[end] in _ws:
178
- end += 1
179
- if s[end] in _ws:
180
- end = _w(s, end + 1).end()
181
- except IndexError:
182
- pass
183
-
184
- try:
185
- value, end = scan_once(s, end)
186
- except StopIteration:
187
- raise ValueError(errmsg("Expecting object", s, end))
188
- pairs[key] = value
189
-
190
- try:
191
- nextchar = s[end]
192
- if nextchar in _ws:
193
- end = _w(s, end + 1).end()
194
- nextchar = s[end]
195
- except IndexError:
196
- nextchar = ''
197
- end += 1
198
-
199
- if nextchar == '}':
200
- break
201
- elif nextchar != ',':
202
- raise ValueError(errmsg("Expecting , delimiter", s, end - 1))
203
-
204
- try:
205
- nextchar = s[end]
206
- if nextchar in _ws:
207
- end += 1
208
- nextchar = s[end]
209
- if nextchar in _ws:
210
- end = _w(s, end + 1).end()
211
- nextchar = s[end]
212
- except IndexError:
213
- nextchar = ''
214
-
215
- end += 1
216
- if nextchar != '"':
217
- raise ValueError(errmsg("Expecting property name", s, end - 1))
218
-
219
- if object_hook is not None:
220
- pairs = object_hook(pairs)
221
- return pairs, end
222
-
223
- def JSONArray((s, end), scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
224
- values = []
225
- nextchar = s[end:end + 1]
226
- if nextchar in _ws:
227
- end = _w(s, end + 1).end()
228
- nextchar = s[end:end + 1]
229
- # Look-ahead for trivial empty array
230
- if nextchar == ']':
231
- return values, end + 1
232
- _append = values.append
233
- while True:
234
- try:
235
- value, end = scan_once(s, end)
236
- except StopIteration:
237
- raise ValueError(errmsg("Expecting object", s, end))
238
- _append(value)
239
- nextchar = s[end:end + 1]
240
- if nextchar in _ws:
241
- end = _w(s, end + 1).end()
242
- nextchar = s[end:end + 1]
243
- end += 1
244
- if nextchar == ']':
245
- break
246
- elif nextchar != ',':
247
- raise ValueError(errmsg("Expecting , delimiter", s, end))
248
-
249
- try:
250
- if s[end] in _ws:
251
- end += 1
252
- if s[end] in _ws:
253
- end = _w(s, end + 1).end()
254
- except IndexError:
255
- pass
256
-
257
- return values, end
258
-
259
- class JSONDecoder(object):
260
- """Simple JSON <http://json.org> decoder
261
-
262
- Performs the following translations in decoding by default:
263
-
264
- +---------------+-------------------+
265
- | JSON | Python |
266
- +===============+===================+
267
- | object | dict |
268
- +---------------+-------------------+
269
- | array | list |
270
- +---------------+-------------------+
271
- | string | unicode |
272
- +---------------+-------------------+
273
- | number (int) | int, long |
274
- +---------------+-------------------+
275
- | number (real) | float |
276
- +---------------+-------------------+
277
- | true | True |
278
- +---------------+-------------------+
279
- | false | False |
280
- +---------------+-------------------+
281
- | null | None |
282
- +---------------+-------------------+
283
-
284
- It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
285
- their corresponding ``float`` values, which is outside the JSON spec.
286
-
287
- """
288
-
289
- def __init__(self, encoding=None, object_hook=None, parse_float=None,
290
- parse_int=None, parse_constant=None, strict=True):
291
- """``encoding`` determines the encoding used to interpret any ``str``
292
- objects decoded by this instance (utf-8 by default). It has no
293
- effect when decoding ``unicode`` objects.
294
-
295
- Note that currently only encodings that are a superset of ASCII work,
296
- strings of other encodings should be passed in as ``unicode``.
297
-
298
- ``object_hook``, if specified, will be called with the result
299
- of every JSON object decoded and its return value will be used in
300
- place of the given ``dict``. This can be used to provide custom
301
- deserializations (e.g. to support JSON-RPC class hinting).
302
-
303
- ``parse_float``, if specified, will be called with the string
304
- of every JSON float to be decoded. By default this is equivalent to
305
- float(num_str). This can be used to use another datatype or parser
306
- for JSON floats (e.g. decimal.Decimal).
307
-
308
- ``parse_int``, if specified, will be called with the string
309
- of every JSON int to be decoded. By default this is equivalent to
310
- int(num_str). This can be used to use another datatype or parser
311
- for JSON integers (e.g. float).
312
-
313
- ``parse_constant``, if specified, will be called with one of the
314
- following strings: -Infinity, Infinity, NaN.
315
- This can be used to raise an exception if invalid JSON numbers
316
- are encountered.
317
-
318
- """
319
- self.encoding = encoding
320
- self.object_hook = object_hook
321
- self.parse_float = parse_float or float
322
- self.parse_int = parse_int or int
323
- self.parse_constant = parse_constant or _CONSTANTS.__getitem__
324
- self.strict = strict
325
- self.parse_object = JSONObject
326
- self.parse_array = JSONArray
327
- self.parse_string = scanstring
328
- self.scan_once = make_scanner(self)
329
-
330
- def decode(self, s, _w=WHITESPACE.match):
331
- """Return the Python representation of ``s`` (a ``str`` or ``unicode``
332
- instance containing a JSON document)
333
-
334
- """
335
- obj, end = self.raw_decode(s, idx=_w(s, 0).end())
336
- end = _w(s, end).end()
337
- if end != len(s):
338
- raise ValueError(errmsg("Extra data", s, end, len(s)))
339
- return obj
340
-
341
- def raw_decode(self, s, idx=0):
342
- """Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
343
- with a JSON document) and return a 2-tuple of the Python
344
- representation and the index in ``s`` where the document ended.
345
-
346
- This can be used to decode a JSON document from a string that may
347
- have extraneous data at the end.
348
-
349
- """
350
- try:
351
- obj, end = self.scan_once(s, idx)
352
- except StopIteration:
353
- raise ValueError("No JSON object could be decoded")
354
- return obj, end
@@ -1,440 +0,0 @@
1
- """Implementation of JSONEncoder
2
- """
3
- import re
4
-
5
- try:
6
- from simplejson._speedups import encode_basestring_ascii as c_encode_basestring_ascii
7
- except ImportError:
8
- c_encode_basestring_ascii = None
9
- try:
10
- from simplejson._speedups import make_encoder as c_make_encoder
11
- except ImportError:
12
- c_make_encoder = None
13
-
14
- ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]')
15
- ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
16
- HAS_UTF8 = re.compile(r'[\x80-\xff]')
17
- ESCAPE_DCT = {
18
- '\\': '\\\\',
19
- '"': '\\"',
20
- '\b': '\\b',
21
- '\f': '\\f',
22
- '\n': '\\n',
23
- '\r': '\\r',
24
- '\t': '\\t',
25
- }
26
- for i in range(0x20):
27
- #ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))
28
- ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))
29
-
30
- # Assume this produces an infinity on all machines (probably not guaranteed)
31
- INFINITY = float('1e66666')
32
- FLOAT_REPR = repr
33
-
34
- def encode_basestring(s):
35
- """Return a JSON representation of a Python string
36
-
37
- """
38
- def replace(match):
39
- return ESCAPE_DCT[match.group(0)]
40
- return '"' + ESCAPE.sub(replace, s) + '"'
41
-
42
-
43
- def py_encode_basestring_ascii(s):
44
- """Return an ASCII-only JSON representation of a Python string
45
-
46
- """
47
- if isinstance(s, str) and HAS_UTF8.search(s) is not None:
48
- s = s.decode('utf-8')
49
- def replace(match):
50
- s = match.group(0)
51
- try:
52
- return ESCAPE_DCT[s]
53
- except KeyError:
54
- n = ord(s)
55
- if n < 0x10000:
56
- #return '\\u{0:04x}'.format(n)
57
- return '\\u%04x' % (n,)
58
- else:
59
- # surrogate pair
60
- n -= 0x10000
61
- s1 = 0xd800 | ((n >> 10) & 0x3ff)
62
- s2 = 0xdc00 | (n & 0x3ff)
63
- #return '\\u{0:04x}\\u{1:04x}'.format(s1, s2)
64
- return '\\u%04x\\u%04x' % (s1, s2)
65
- return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'
66
-
67
-
68
- encode_basestring_ascii = c_encode_basestring_ascii or py_encode_basestring_ascii
69
-
70
- class JSONEncoder(object):
71
- """Extensible JSON <http://json.org> encoder for Python data structures.
72
-
73
- Supports the following objects and types by default:
74
-
75
- +-------------------+---------------+
76
- | Python | JSON |
77
- +===================+===============+
78
- | dict | object |
79
- +-------------------+---------------+
80
- | list, tuple | array |
81
- +-------------------+---------------+
82
- | str, unicode | string |
83
- +-------------------+---------------+
84
- | int, long, float | number |
85
- +-------------------+---------------+
86
- | True | true |
87
- +-------------------+---------------+
88
- | False | false |
89
- +-------------------+---------------+
90
- | None | null |
91
- +-------------------+---------------+
92
-
93
- To extend this to recognize other objects, subclass and implement a
94
- ``.default()`` method with another method that returns a serializable
95
- object for ``o`` if possible, otherwise it should call the superclass
96
- implementation (to raise ``TypeError``).
97
-
98
- """
99
- item_separator = ', '
100
- key_separator = ': '
101
- def __init__(self, skipkeys=False, ensure_ascii=True,
102
- check_circular=True, allow_nan=True, sort_keys=False,
103
- indent=None, separators=None, encoding='utf-8', default=None):
104
- """Constructor for JSONEncoder, with sensible defaults.
105
-
106
- If skipkeys is false, then it is a TypeError to attempt
107
- encoding of keys that are not str, int, long, float or None. If
108
- skipkeys is True, such items are simply skipped.
109
-
110
- If ensure_ascii is true, the output is guaranteed to be str
111
- objects with all incoming unicode characters escaped. If
112
- ensure_ascii is false, the output will be unicode object.
113
-
114
- If check_circular is true, then lists, dicts, and custom encoded
115
- objects will be checked for circular references during encoding to
116
- prevent an infinite recursion (which would cause an OverflowError).
117
- Otherwise, no such check takes place.
118
-
119
- If allow_nan is true, then NaN, Infinity, and -Infinity will be
120
- encoded as such. This behavior is not JSON specification compliant,
121
- but is consistent with most JavaScript based encoders and decoders.
122
- Otherwise, it will be a ValueError to encode such floats.
123
-
124
- If sort_keys is true, then the output of dictionaries will be
125
- sorted by key; this is useful for regression tests to ensure
126
- that JSON serializations can be compared on a day-to-day basis.
127
-
128
- If indent is a non-negative integer, then JSON array
129
- elements and object members will be pretty-printed with that
130
- indent level. An indent level of 0 will only insert newlines.
131
- None is the most compact representation.
132
-
133
- If specified, separators should be a (item_separator, key_separator)
134
- tuple. The default is (', ', ': '). To get the most compact JSON
135
- representation you should specify (',', ':') to eliminate whitespace.
136
-
137
- If specified, default is a function that gets called for objects
138
- that can't otherwise be serialized. It should return a JSON encodable
139
- version of the object or raise a ``TypeError``.
140
-
141
- If encoding is not None, then all input strings will be
142
- transformed into unicode using that encoding prior to JSON-encoding.
143
- The default is UTF-8.
144
-
145
- """
146
-
147
- self.skipkeys = skipkeys
148
- self.ensure_ascii = ensure_ascii
149
- self.check_circular = check_circular
150
- self.allow_nan = allow_nan
151
- self.sort_keys = sort_keys
152
- self.indent = indent
153
- if separators is not None:
154
- self.item_separator, self.key_separator = separators
155
- if default is not None:
156
- self.default = default
157
- self.encoding = encoding
158
-
159
- def default(self, o):
160
- """Implement this method in a subclass such that it returns
161
- a serializable object for ``o``, or calls the base implementation
162
- (to raise a ``TypeError``).
163
-
164
- For example, to support arbitrary iterators, you could
165
- implement default like this::
166
-
167
- def default(self, o):
168
- try:
169
- iterable = iter(o)
170
- except TypeError:
171
- pass
172
- else:
173
- return list(iterable)
174
- return JSONEncoder.default(self, o)
175
-
176
- """
177
- raise TypeError(repr(o) + " is not JSON serializable")
178
-
179
- def encode(self, o):
180
- """Return a JSON string representation of a Python data structure.
181
-
182
- >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
183
- '{"foo": ["bar", "baz"]}'
184
-
185
- """
186
- # This is for extremely simple cases and benchmarks.
187
- if isinstance(o, basestring):
188
- if isinstance(o, str):
189
- _encoding = self.encoding
190
- if (_encoding is not None
191
- and not (_encoding == 'utf-8')):
192
- o = o.decode(_encoding)
193
- if self.ensure_ascii:
194
- return encode_basestring_ascii(o)
195
- else:
196
- return encode_basestring(o)
197
- # This doesn't pass the iterator directly to ''.join() because the
198
- # exceptions aren't as detailed. The list call should be roughly
199
- # equivalent to the PySequence_Fast that ''.join() would do.
200
- chunks = self.iterencode(o, _one_shot=True)
201
- if not isinstance(chunks, (list, tuple)):
202
- chunks = list(chunks)
203
- return ''.join(chunks)
204
-
205
- def iterencode(self, o, _one_shot=False):
206
- """Encode the given object and yield each string
207
- representation as available.
208
-
209
- For example::
210
-
211
- for chunk in JSONEncoder().iterencode(bigobject):
212
- mysocket.write(chunk)
213
-
214
- """
215
- if self.check_circular:
216
- markers = {}
217
- else:
218
- markers = None
219
- if self.ensure_ascii:
220
- _encoder = encode_basestring_ascii
221
- else:
222
- _encoder = encode_basestring
223
- if self.encoding != 'utf-8':
224
- def _encoder(o, _orig_encoder=_encoder, _encoding=self.encoding):
225
- if isinstance(o, str):
226
- o = o.decode(_encoding)
227
- return _orig_encoder(o)
228
-
229
- def floatstr(o, allow_nan=self.allow_nan, _repr=FLOAT_REPR, _inf=INFINITY, _neginf=-INFINITY):
230
- # Check for specials. Note that this type of test is processor- and/or
231
- # platform-specific, so do tests which don't depend on the internals.
232
-
233
- if o != o:
234
- text = 'NaN'
235
- elif o == _inf:
236
- text = 'Infinity'
237
- elif o == _neginf:
238
- text = '-Infinity'
239
- else:
240
- return _repr(o)
241
-
242
- if not allow_nan:
243
- raise ValueError(
244
- "Out of range float values are not JSON compliant: " +
245
- repr(o))
246
-
247
- return text
248
-
249
-
250
- if _one_shot and c_make_encoder is not None and not self.indent and not self.sort_keys:
251
- _iterencode = c_make_encoder(
252
- markers, self.default, _encoder, self.indent,
253
- self.key_separator, self.item_separator, self.sort_keys,
254
- self.skipkeys, self.allow_nan)
255
- else:
256
- _iterencode = _make_iterencode(
257
- markers, self.default, _encoder, self.indent, floatstr,
258
- self.key_separator, self.item_separator, self.sort_keys,
259
- self.skipkeys, _one_shot)
260
- return _iterencode(o, 0)
261
-
262
- def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, _key_separator, _item_separator, _sort_keys, _skipkeys, _one_shot,
263
- ## HACK: hand-optimized bytecode; turn globals into locals
264
- False=False,
265
- True=True,
266
- ValueError=ValueError,
267
- basestring=basestring,
268
- dict=dict,
269
- float=float,
270
- id=id,
271
- int=int,
272
- isinstance=isinstance,
273
- list=list,
274
- long=long,
275
- str=str,
276
- tuple=tuple,
277
- ):
278
-
279
- def _iterencode_list(lst, _current_indent_level):
280
- if not lst:
281
- yield '[]'
282
- return
283
- if markers is not None:
284
- markerid = id(lst)
285
- if markerid in markers:
286
- raise ValueError("Circular reference detected")
287
- markers[markerid] = lst
288
- buf = '['
289
- if _indent is not None:
290
- _current_indent_level += 1
291
- newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
292
- separator = _item_separator + newline_indent
293
- buf += newline_indent
294
- else:
295
- newline_indent = None
296
- separator = _item_separator
297
- first = True
298
- for value in lst:
299
- if first:
300
- first = False
301
- else:
302
- buf = separator
303
- if isinstance(value, basestring):
304
- yield buf + _encoder(value)
305
- elif value is None:
306
- yield buf + 'null'
307
- elif value is True:
308
- yield buf + 'true'
309
- elif value is False:
310
- yield buf + 'false'
311
- elif isinstance(value, (int, long)):
312
- yield buf + str(value)
313
- elif isinstance(value, float):
314
- yield buf + _floatstr(value)
315
- else:
316
- yield buf
317
- if isinstance(value, (list, tuple)):
318
- chunks = _iterencode_list(value, _current_indent_level)
319
- elif isinstance(value, dict):
320
- chunks = _iterencode_dict(value, _current_indent_level)
321
- else:
322
- chunks = _iterencode(value, _current_indent_level)
323
- for chunk in chunks:
324
- yield chunk
325
- if newline_indent is not None:
326
- _current_indent_level -= 1
327
- yield '\n' + (' ' * (_indent * _current_indent_level))
328
- yield ']'
329
- if markers is not None:
330
- del markers[markerid]
331
-
332
- def _iterencode_dict(dct, _current_indent_level):
333
- if not dct:
334
- yield '{}'
335
- return
336
- if markers is not None:
337
- markerid = id(dct)
338
- if markerid in markers:
339
- raise ValueError("Circular reference detected")
340
- markers[markerid] = dct
341
- yield '{'
342
- if _indent is not None:
343
- _current_indent_level += 1
344
- newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
345
- item_separator = _item_separator + newline_indent
346
- yield newline_indent
347
- else:
348
- newline_indent = None
349
- item_separator = _item_separator
350
- first = True
351
- if _sort_keys:
352
- items = dct.items()
353
- items.sort(key=lambda kv: kv[0])
354
- else:
355
- items = dct.iteritems()
356
- for key, value in items:
357
- if isinstance(key, basestring):
358
- pass
359
- # JavaScript is weakly typed for these, so it makes sense to
360
- # also allow them. Many encoders seem to do something like this.
361
- elif isinstance(key, float):
362
- key = _floatstr(key)
363
- elif key is True:
364
- key = 'true'
365
- elif key is False:
366
- key = 'false'
367
- elif key is None:
368
- key = 'null'
369
- elif isinstance(key, (int, long)):
370
- key = str(key)
371
- elif _skipkeys:
372
- continue
373
- else:
374
- raise TypeError("key " + repr(key) + " is not a string")
375
- if first:
376
- first = False
377
- else:
378
- yield item_separator
379
- yield _encoder(key)
380
- yield _key_separator
381
- if isinstance(value, basestring):
382
- yield _encoder(value)
383
- elif value is None:
384
- yield 'null'
385
- elif value is True:
386
- yield 'true'
387
- elif value is False:
388
- yield 'false'
389
- elif isinstance(value, (int, long)):
390
- yield str(value)
391
- elif isinstance(value, float):
392
- yield _floatstr(value)
393
- else:
394
- if isinstance(value, (list, tuple)):
395
- chunks = _iterencode_list(value, _current_indent_level)
396
- elif isinstance(value, dict):
397
- chunks = _iterencode_dict(value, _current_indent_level)
398
- else:
399
- chunks = _iterencode(value, _current_indent_level)
400
- for chunk in chunks:
401
- yield chunk
402
- if newline_indent is not None:
403
- _current_indent_level -= 1
404
- yield '\n' + (' ' * (_indent * _current_indent_level))
405
- yield '}'
406
- if markers is not None:
407
- del markers[markerid]
408
-
409
- def _iterencode(o, _current_indent_level):
410
- if isinstance(o, basestring):
411
- yield _encoder(o)
412
- elif o is None:
413
- yield 'null'
414
- elif o is True:
415
- yield 'true'
416
- elif o is False:
417
- yield 'false'
418
- elif isinstance(o, (int, long)):
419
- yield str(o)
420
- elif isinstance(o, float):
421
- yield _floatstr(o)
422
- elif isinstance(o, (list, tuple)):
423
- for chunk in _iterencode_list(o, _current_indent_level):
424
- yield chunk
425
- elif isinstance(o, dict):
426
- for chunk in _iterencode_dict(o, _current_indent_level):
427
- yield chunk
428
- else:
429
- if markers is not None:
430
- markerid = id(o)
431
- if markerid in markers:
432
- raise ValueError("Circular reference detected")
433
- markers[markerid] = o
434
- o = _default(o)
435
- for chunk in _iterencode(o, _current_indent_level):
436
- yield chunk
437
- if markers is not None:
438
- del markers[markerid]
439
-
440
- return _iterencode