vagrant-unbundled 1.9.7.1 → 1.9.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/Gemfile.lock +10 -6
  4. data/contrib/bash/completion.sh +1 -1
  5. data/contrib/sudoers/linux-ubuntu +3 -4
  6. data/lib/vagrant/errors.rb +8 -0
  7. data/lib/vagrant/machine.rb +2 -0
  8. data/lib/vagrant/util/platform.rb +1 -1
  9. data/lib/vagrant/util/powershell.rb +42 -13
  10. data/lib/vagrant/util/safe_exec.rb +13 -2
  11. data/lib/vagrant/util/ssh.rb +11 -1
  12. data/plugins/commands/box/command/update.rb +12 -7
  13. data/plugins/commands/login/client.rb +15 -6
  14. data/plugins/commands/login/command.rb +13 -3
  15. data/plugins/commands/up/command.rb +9 -0
  16. data/plugins/commands/validate/command.rb +4 -4
  17. data/plugins/guests/darwin/cap/shell_expand_guest_path.rb +2 -2
  18. data/plugins/guests/freebsd/cap/configure_networks.rb +1 -1
  19. data/plugins/guests/freebsd/cap/shell_expand_guest_path.rb +2 -2
  20. data/plugins/guests/linux/cap/shell_expand_guest_path.rb +2 -2
  21. data/plugins/guests/netbsd/cap/shell_expand_guest_path.rb +2 -2
  22. data/plugins/guests/openbsd/cap/shell_expand_guest_path.rb +2 -2
  23. data/plugins/guests/windows/cap/public_key.rb +21 -45
  24. data/plugins/kernel_v2/config/ssh_connect.rb +3 -0
  25. data/plugins/providers/docker/config.rb +4 -0
  26. data/plugins/providers/docker/driver/compose.rb +11 -4
  27. data/plugins/providers/hyperv/action/wait_for_ip_address.rb +15 -11
  28. data/plugins/providers/hyperv/scripts/get_network_config.ps1 +24 -9
  29. data/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +18 -0
  30. data/plugins/provisioners/ansible/provisioner/host.rb +1 -1
  31. data/plugins/provisioners/chef/cap/debian/chef_install.rb +2 -2
  32. data/plugins/provisioners/chef/cap/freebsd/chef_install.rb +2 -2
  33. data/plugins/provisioners/chef/cap/omnios/chef_install.rb +2 -2
  34. data/plugins/provisioners/chef/cap/redhat/chef_install.rb +2 -2
  35. data/plugins/provisioners/chef/cap/suse/chef_install.rb +2 -2
  36. data/plugins/provisioners/chef/cap/windows/chef_install.rb +2 -2
  37. data/plugins/provisioners/chef/config/base.rb +17 -0
  38. data/plugins/provisioners/chef/config/chef_zero.rb +7 -0
  39. data/plugins/provisioners/chef/installer.rb +8 -7
  40. data/plugins/provisioners/chef/omnibus.rb +4 -6
  41. data/plugins/provisioners/chef/provisioner/base.rb +1 -0
  42. data/plugins/provisioners/chef/provisioner/chef_solo.rb +2 -1
  43. data/plugins/provisioners/file/provisioner.rb +18 -2
  44. data/plugins/provisioners/puppet/provisioner/puppet.rb +0 -2
  45. data/plugins/provisioners/salt/bootstrap-salt.sh +9 -5
  46. data/plugins/provisioners/shell/provisioner.rb +1 -1
  47. data/plugins/synced_folders/rsync/command/rsync_auto.rb +6 -1
  48. data/plugins/synced_folders/rsync/helper.rb +10 -0
  49. data/templates/locales/en.yml +27 -1
  50. data/templates/locales/providers_docker.yml +2 -0
  51. data/test/unit/base.rb +1 -3
  52. data/test/unit/plugins/commands/box/command/add_test.rb +3 -3
  53. data/test/unit/plugins/commands/box/command/remove_test.rb +6 -6
  54. data/test/unit/plugins/commands/box/command/repackage_test.rb +2 -4
  55. data/test/unit/plugins/commands/box/command/update_test.rb +36 -14
  56. data/test/unit/plugins/commands/init/command_test.rb +1 -1
  57. data/test/unit/plugins/commands/list-commands/command_test.rb +2 -2
  58. data/test/unit/plugins/commands/login/client_test.rb +5 -1
  59. data/test/unit/plugins/commands/package/command_test.rb +1 -1
  60. data/test/unit/plugins/commands/plugin/action/expunge_plugins_test.rb +1 -1
  61. data/test/unit/plugins/commands/plugin/action/install_gem_test.rb +3 -3
  62. data/test/unit/plugins/commands/plugin/action/plugin_exists_check_test.rb +3 -3
  63. data/test/unit/plugins/commands/plugin/action/uninstall_plugin_test.rb +1 -1
  64. data/test/unit/plugins/commands/plugin/action/update_gems_test.rb +2 -2
  65. data/test/unit/plugins/commands/port/command_test.rb +3 -3
  66. data/test/unit/plugins/commands/push/command_test.rb +1 -1
  67. data/test/unit/plugins/commands/snapshot/command/list_test.rb +2 -3
  68. data/test/unit/plugins/commands/ssh_config/command_test.rb +1 -1
  69. data/test/unit/plugins/commands/up/command_test.rb +69 -2
  70. data/test/unit/plugins/commands/validate/command_test.rb +47 -1
  71. data/test/unit/plugins/communicators/ssh/communicator_test.rb +5 -5
  72. data/test/unit/plugins/communicators/winrm/communicator_test.rb +6 -6
  73. data/test/unit/plugins/communicators/winrm/helper_test.rb +24 -23
  74. data/test/unit/plugins/communicators/winssh/communicator_test.rb +5 -5
  75. data/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb +43 -0
  76. data/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb +1 -1
  77. data/test/unit/plugins/guests/freebsd/cap/shell_expand_guest_path_test.rb +44 -0
  78. data/test/unit/plugins/guests/linux/cap/shell_expand_guest_path_test.rb +43 -0
  79. data/test/unit/plugins/guests/netbsd/cap/shell_expand_guest_path_test.rb +43 -0
  80. data/test/unit/plugins/guests/omnios/cap/mount_nfs_folder_test.rb +1 -3
  81. data/test/unit/plugins/guests/openbsd/cap/shell_expand_guest_path_test.rb +43 -0
  82. data/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb +2 -2
  83. data/test/unit/plugins/guests/smartos/cap/configure_networks_test.rb +2 -2
  84. data/test/unit/plugins/guests/smartos/cap/halt_test.rb +2 -2
  85. data/test/unit/plugins/guests/smartos/cap/insert_public_key_test.rb +1 -1
  86. data/test/unit/plugins/guests/smartos/cap/mount_nfs_test.rb +2 -2
  87. data/test/unit/plugins/guests/smartos/cap/rsync_test.rb +2 -2
  88. data/test/unit/plugins/guests/windows/cap/insert_public_key_test.rb +2 -2
  89. data/test/unit/plugins/guests/windows/cap/remove_public_key_test.rb +4 -3
  90. data/test/unit/plugins/guests/windows/config_test.rb +1 -1
  91. data/test/unit/plugins/guests/windows/guest_network_test.rb +2 -2
  92. data/test/unit/plugins/hosts/linux/cap/nfs_test.rb +2 -0
  93. data/test/unit/plugins/kernel_v2/config/push_test.rb +1 -1
  94. data/test/unit/plugins/kernel_v2/config/vm_test.rb +7 -7
  95. data/test/unit/plugins/providers/docker/action/create_test.rb +1 -1
  96. data/test/unit/plugins/providers/docker/command/exec_test.rb +1 -1
  97. data/test/unit/plugins/providers/docker/config_test.rb +23 -4
  98. data/test/unit/plugins/providers/docker/driver_compose_test.rb +60 -30
  99. data/test/unit/plugins/providers/docker/driver_test.rb +31 -31
  100. data/test/unit/plugins/providers/docker/synced_folder_test.rb +3 -3
  101. data/test/unit/plugins/providers/hyperv/provider_test.rb +19 -19
  102. data/test/unit/plugins/providers/virtualbox/action/network_fix_ipv6_test.rb +2 -2
  103. data/test/unit/plugins/providers/virtualbox/action/network_test.rb +1 -1
  104. data/test/unit/plugins/providers/virtualbox/action/prepare_nfs_settings_test.rb +34 -8
  105. data/test/unit/plugins/providers/virtualbox/action/prepare_nfs_valid_ids_test.rb +3 -3
  106. data/test/unit/plugins/providers/virtualbox/cap_test.rb +2 -2
  107. data/test/unit/plugins/providers/virtualbox/config_test.rb +6 -6
  108. data/test/unit/plugins/providers/virtualbox/synced_folder_test.rb +6 -8
  109. data/test/unit/plugins/provisioners/ansible/config/guest_test.rb +1 -1
  110. data/test/unit/plugins/provisioners/ansible/config/host_test.rb +4 -4
  111. data/test/unit/plugins/provisioners/ansible/config/shared.rb +2 -2
  112. data/test/unit/plugins/provisioners/ansible/provisioner_test.rb +165 -157
  113. data/test/unit/plugins/provisioners/chef/command_builder_test.rb +2 -2
  114. data/test/unit/plugins/provisioners/chef/config/base_test.rb +13 -0
  115. data/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb +11 -0
  116. data/test/unit/plugins/provisioners/chef/omnibus_test.rb +17 -7
  117. data/test/unit/plugins/provisioners/docker/config_test.rb +2 -1
  118. data/test/unit/plugins/provisioners/docker/provisioner_test.rb +13 -13
  119. data/test/unit/plugins/provisioners/file/provisioner_test.rb +32 -14
  120. data/test/unit/plugins/provisioners/puppet/provisioner/puppet_test.rb +51 -0
  121. data/test/unit/plugins/provisioners/salt/provisioner_test.rb +5 -5
  122. data/test/unit/plugins/provisioners/shell/provisioner_test.rb +35 -4
  123. data/test/unit/plugins/pushes/ftp/adapter_test.rb +1 -0
  124. data/test/unit/plugins/synced_folders/nfs/action_cleanup_test.rb +1 -1
  125. data/test/unit/plugins/synced_folders/nfs/config_test.rb +1 -1
  126. data/test/unit/plugins/synced_folders/rsync/command/rsync_auto_test.rb +44 -12
  127. data/test/unit/plugins/synced_folders/rsync/command/rsync_test.rb +5 -5
  128. data/test/unit/plugins/synced_folders/rsync/helper_test.rb +47 -29
  129. data/test/unit/plugins/synced_folders/rsync/synced_folder_test.rb +5 -5
  130. data/test/unit/vagrant/action/builtin/box_add_test.rb +27 -27
  131. data/test/unit/vagrant/action/builtin/box_check_outdated_test.rb +10 -10
  132. data/test/unit/vagrant/action/builtin/box_remove_test.rb +15 -15
  133. data/test/unit/vagrant/action/builtin/confirm_test.rb +1 -1
  134. data/test/unit/vagrant/action/builtin/graceful_halt_test.rb +2 -2
  135. data/test/unit/vagrant/action/builtin/handle_box_test.rb +8 -8
  136. data/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb +1 -1
  137. data/test/unit/vagrant/action/builtin/is_env_set_test.rb +2 -2
  138. data/test/unit/vagrant/action/builtin/is_state_test.rb +6 -6
  139. data/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb +6 -6
  140. data/test/unit/vagrant/action/builtin/provision_test.rb +1 -1
  141. data/test/unit/vagrant/action/builtin/provisioner_cleanup_test.rb +1 -1
  142. data/test/unit/vagrant/action/builtin/synced_folder_cleanup_test.rb +6 -6
  143. data/test/unit/vagrant/action/builtin/synced_folders_test.rb +3 -3
  144. data/test/unit/vagrant/batch_action_test.rb +2 -2
  145. data/test/unit/vagrant/box_collection_test.rb +1 -1
  146. data/test/unit/vagrant/box_test.rb +6 -6
  147. data/test/unit/vagrant/capability_host_test.rb +3 -3
  148. data/test/unit/vagrant/cli_test.rb +3 -3
  149. data/test/unit/vagrant/environment_test.rb +21 -20
  150. data/test/unit/vagrant/guest_test.rb +7 -7
  151. data/test/unit/vagrant/machine_index_test.rb +4 -4
  152. data/test/unit/vagrant/machine_test.rb +28 -17
  153. data/test/unit/vagrant/plugin/manager_test.rb +12 -12
  154. data/test/unit/vagrant/plugin/state_file_test.rb +2 -2
  155. data/test/unit/vagrant/plugin/v1/command_test.rb +9 -8
  156. data/test/unit/vagrant/plugin/v2/command_test.rb +54 -43
  157. data/test/unit/vagrant/plugin/v2/plugin_test.rb +4 -3
  158. data/test/unit/vagrant/plugin/v2/provider_test.rb +3 -3
  159. data/test/unit/vagrant/shared_helpers_test.rb +6 -6
  160. data/test/unit/vagrant/ui_test.rb +21 -21
  161. data/test/unit/vagrant/util/downloader_test.rb +7 -7
  162. data/test/unit/vagrant/util/ssh_test.rb +41 -5
  163. data/test/unit/vagrant/util/subprocess_test.rb +7 -7
  164. data/test/unit/vagrant_test.rb +9 -9
  165. data/vagrant.gemspec +3 -2
  166. data/vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-af86757912f7/vagrant-spec.gemspec +1 -1
  167. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/.gitignore +7 -0
  168. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/.rspec +2 -0
  169. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/.travis.yml +5 -0
  170. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/CONTRIBUTORS.md +19 -0
  171. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/Gemfile +12 -0
  172. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/Gemfile.lock +44 -0
  173. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/Guardfile +10 -0
  174. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/README.md +134 -0
  175. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/Rakefile +10 -0
  176. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/fake_ftp.gemspec +22 -0
  177. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/lib/fake_ftp.rb +5 -0
  178. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/lib/fake_ftp/file.rb +34 -0
  179. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/lib/fake_ftp/server.rb +340 -0
  180. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/lib/fake_ftp/version.rb +3 -0
  181. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/spec/fixtures/invisible_bike.jpg +0 -0
  182. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/spec/fixtures/text_file.txt +1 -0
  183. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/spec/functional/server_spec.rb +468 -0
  184. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/spec/integration/server_spec.rb +81 -0
  185. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/spec/models/fake_ftp/file_spec.rb +102 -0
  186. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/spec/models/fake_ftp/server_spec.rb +76 -0
  187. data/vendor/bundle/ruby/2.4.0/gems/fake_ftp-0.1.1/spec/spec_helper.rb +18 -0
  188. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/.gitignore +14 -0
  189. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/.rubocop.yml +57 -0
  190. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/.travis.yml +21 -0
  191. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/CONTRIBUTING.rdoc +36 -0
  192. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/Gemfile +3 -0
  193. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/History.rdoc +2247 -0
  194. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/MIT-LICENSE +21 -0
  195. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/README.rdoc +156 -0
  196. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/Rakefile +38 -0
  197. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/appveyor.yml +21 -0
  198. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/bin/console +7 -0
  199. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/bin/setup +6 -0
  200. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/command_line_usage.rdoc +158 -0
  201. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/example/Rakefile1 +38 -0
  202. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/example/Rakefile2 +35 -0
  203. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/example/a.c +6 -0
  204. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/example/b.c +6 -0
  205. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/example/main.c +11 -0
  206. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/glossary.rdoc +42 -0
  207. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/jamis.rb +591 -0
  208. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/proto_rake.rdoc +127 -0
  209. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/rake.1 +156 -0
  210. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/rakefile.rdoc +622 -0
  211. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/doc/rational.rdoc +151 -0
  212. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake +27 -0
  213. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake.rb +70 -0
  214. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb +785 -0
  215. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/backtrace.rb +23 -0
  216. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/clean.rb +77 -0
  217. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/cloneable.rb +16 -0
  218. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/cpu_counter.rb +106 -0
  219. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/default_loader.rb +14 -0
  220. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/dsl_definition.rb +194 -0
  221. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/early_time.rb +21 -0
  222. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/ext/core.rb +25 -0
  223. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/ext/string.rb +175 -0
  224. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_creation_task.rb +24 -0
  225. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_list.rb +434 -0
  226. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_task.rb +46 -0
  227. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_utils.rb +136 -0
  228. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_utils_ext.rb +144 -0
  229. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/invocation_chain.rb +56 -0
  230. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/invocation_exception_mixin.rb +16 -0
  231. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/late_time.rb +17 -0
  232. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/linked_list.rb +111 -0
  233. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/loaders/makefile.rb +53 -0
  234. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/multi_task.rb +49 -0
  235. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/name_space.rb +37 -0
  236. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/packagetask.rb +210 -0
  237. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/phony.rb +15 -0
  238. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/private_reader.rb +20 -0
  239. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/promise.rb +99 -0
  240. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/pseudo_status.rb +29 -0
  241. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/rake_module.rb +38 -0
  242. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb +21 -0
  243. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/rule_recursion_overflow_error.rb +19 -0
  244. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/scope.rb +42 -0
  245. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task.rb +390 -0
  246. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task_argument_error.rb +7 -0
  247. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task_arguments.rb +108 -0
  248. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task_manager.rb +303 -0
  249. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/tasklib.rb +11 -0
  250. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/testtask.rb +222 -0
  251. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/thread_history_display.rb +48 -0
  252. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/thread_pool.rb +162 -0
  253. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/trace_output.rb +22 -0
  254. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/version.rb +9 -0
  255. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/win32.rb +50 -0
  256. data/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/rake.gemspec +39 -0
  257. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/.gitignore +19 -0
  258. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/.rspec +3 -0
  259. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/.travis.yml +24 -0
  260. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/Changelog.md +49 -0
  261. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/Gemfile +26 -0
  262. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/LICENSE.txt +27 -0
  263. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/README.md +72 -0
  264. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/Rakefile +16 -0
  265. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/cucumber.yml +2 -0
  266. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/features/its.feature +125 -0
  267. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/features/step_definitions/additional_cli_steps.rb +21 -0
  268. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/features/support/env.rb +23 -0
  269. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/lib/rspec/its.rb +149 -0
  270. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/lib/rspec/its/version.rb +5 -0
  271. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/rspec-its.gemspec +28 -0
  272. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/script/test_all +20 -0
  273. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/spec/rspec/its_spec.rb +237 -0
  274. data/vendor/bundle/ruby/2.4.0/gems/rspec-its-1.2.0/spec/spec_helper.rb +15 -0
  275. data/vendor/bundle/ruby/2.4.0/specifications/fake_ftp-0.1.1.gemspec +20 -0
  276. data/vendor/bundle/ruby/2.4.0/specifications/rake-12.0.0.gemspec +43 -0
  277. data/vendor/bundle/ruby/2.4.0/specifications/rspec-its-1.2.0.gemspec +47 -0
  278. data/version.txt +1 -1
  279. metadata +137 -7
  280. data/2.14.0 +0 -5
@@ -0,0 +1,151 @@
1
+ = Why rake?
2
+
3
+ Ok, let me state from the beginning that I never intended to write this
4
+ code. I'm not convinced it is useful, and I'm not convinced anyone
5
+ would even be interested in it. All I can say is that Why's onion truck
6
+ must by been passing through the Ohio valley.
7
+
8
+ What am I talking about? ... A Ruby version of Make.
9
+
10
+ See, I can sense you cringing already, and I agree. The world certainly
11
+ doesn't need yet another reworking of the "make" program. I mean, we
12
+ already have "ant". Isn't that enough?
13
+
14
+ It started yesterday. I was helping a coworker fix a problem in one of
15
+ the Makefiles we use in our project. Not a particularly tough problem,
16
+ but during the course of the conversation I began lamenting some of the
17
+ shortcomings of make. In particular, in one of my makefiles I wanted to
18
+ determine the name of a file dynamically and had to resort to some
19
+ simple scripting (in Ruby) to make it work. "Wouldn't it be nice if you
20
+ could just use Ruby inside a Makefile" I said.
21
+
22
+ My coworker (a recent convert to Ruby) agreed, but wondered what it
23
+ would look like. So I sketched the following on the whiteboard...
24
+
25
+ "What if you could specify the make tasks in Ruby, like this ..."
26
+
27
+ task "build" do
28
+ java_compile(...args, etc ...)
29
+ end
30
+
31
+ "The task function would register "build" as a target to be made,
32
+ and the block would be the action executed whenever the build
33
+ system determined that it was time to do the build target."
34
+
35
+ We agreed that would be cool, but writing make from scratch would be WAY
36
+ too much work. And that was the end of that!
37
+
38
+ ... Except I couldn't get the thought out of my head. What exactly
39
+ would be needed to make the about syntax work as a make file? Hmmm, you
40
+ would need to register the tasks, you need some way of specifying
41
+ dependencies between tasks, and some way of kicking off the process.
42
+ Hey! What if we did ... and fifteen minutes later I had a working
43
+ prototype of Ruby make, complete with dependencies and actions.
44
+
45
+ I showed the code to my coworker and we had a good laugh. It was just
46
+ about a page worth of code that reproduced an amazing amount of the
47
+ functionality of make. We were both truly stunned with the power of
48
+ Ruby.
49
+
50
+ But it didn't do everything make did. In particular, it didn't have
51
+ timestamp based file dependencies (where a file is rebuilt if any of its
52
+ prerequisite files have a later timestamp). Obviously THAT would be a
53
+ pain to add and so Ruby Make would remain an interesting experiment.
54
+
55
+ ... Except as I walked back to my desk, I started thinking about what
56
+ file based dependencies would really need. Rats! I was hooked again,
57
+ and by adding a new class and two new methods, file/timestamp
58
+ dependencies were implemented.
59
+
60
+ Ok, now I was really hooked. Last night (during CSI!) I massaged the
61
+ code and cleaned it up a bit. The result is a bare-bones replacement
62
+ for make in exactly 100 lines of code.
63
+
64
+ For the curious, you can see it at ...
65
+ * doc/proto_rake.rdoc
66
+
67
+ Oh, about the name. When I wrote the example Ruby Make task on my
68
+ whiteboard, my coworker exclaimed "Oh! I have the perfect name: Rake ...
69
+ Get it? Ruby-Make. Rake!" He said he envisioned the tasks as leaves
70
+ and Rake would clean them up ... or something like that. Anyways, the
71
+ name stuck.
72
+
73
+ Some quick examples ...
74
+
75
+ A simple task to delete backup files ...
76
+
77
+ task :clean do
78
+ Dir['*~'].each {|fn| rm fn rescue nil}
79
+ end
80
+
81
+ Note that task names are symbols (they are slightly easier to type
82
+ than quoted strings ... but you may use quoted string if you would
83
+ rather). Rake makes the methods of the FileUtils module directly
84
+ available, so we take advantage of the <tt>rm</tt> command. Also note
85
+ the use of "rescue nil" to trap and ignore errors in the <tt>rm</tt>
86
+ command.
87
+
88
+ To run it, just type "rake clean". Rake will automatically find a
89
+ Rakefile in the current directory (or above!) and will invoke the
90
+ targets named on the command line. If there are no targets explicitly
91
+ named, rake will invoke the task "default".
92
+
93
+ Here's another task with dependencies ...
94
+
95
+ task :clobber => [:clean] do
96
+ rm_r "tempdir"
97
+ end
98
+
99
+ Task :clobber depends upon task :clean, so :clean will be run before
100
+ :clobber is executed.
101
+
102
+ Files are specified by using the "file" command. It is similar to the
103
+ task command, except that the task name represents a file, and the task
104
+ will be run only if the file doesn't exist, or if its modification time
105
+ is earlier than any of its prerequisites.
106
+
107
+ Here is a file based dependency that will compile "hello.cc" to
108
+ "hello.o".
109
+
110
+ file "hello.cc"
111
+ file "hello.o" => ["hello.cc"] do |t|
112
+ srcfile = t.name.sub(/\.o$/, ".cc")
113
+ sh %{g++ #{srcfile} -c -o #{t.name}}
114
+ end
115
+
116
+ I normally specify file tasks with string (rather than symbols). Some
117
+ file names can't be represented by symbols. Plus it makes the
118
+ distinction between them more clear to the casual reader.
119
+
120
+ Currently writing a task for each and every file in the project would be
121
+ tedious at best. I envision a set of libraries to make this job
122
+ easier. For instance, perhaps something like this ...
123
+
124
+ require 'rake/ctools'
125
+ Dir['*.c'].each do |fn|
126
+ c_source_file(fn)
127
+ end
128
+
129
+ where "c_source_file" will create all the tasks need to compile all the
130
+ C source files in a directory. Any number of useful libraries could be
131
+ created for rake.
132
+
133
+ That's it. There's no documentation (other than whats in this
134
+ message). Does this sound interesting to anyone? If so, I'll continue
135
+ to clean it up and write it up and publish it on RAA. Otherwise, I'll
136
+ leave it as an interesting exercise and a tribute to the power of Ruby.
137
+
138
+ Why /might/ rake be interesting to Ruby programmers. I don't know,
139
+ perhaps ...
140
+
141
+ * No weird make syntax (only weird Ruby syntax :-)
142
+ * No need to edit or read XML (a la ant)
143
+ * Platform independent build scripts.
144
+ * Will run anywhere Ruby exists, so no need to have "make" installed.
145
+ If you stay away from the "sys" command and use things like
146
+ 'ftools', you can have a perfectly platform independent
147
+ build script. Also rake is only 100 lines of code, so it can
148
+ easily be packaged along with the rest of your code.
149
+
150
+ So ... Sorry for the long rambling message. Like I said, I never
151
+ intended to write this code at all.
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #--
4
+ # Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to
8
+ # deal in the Software without restriction, including without limitation the
9
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ # sell copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
+ # IN THE SOFTWARE.
23
+ #++
24
+
25
+ require "rake"
26
+
27
+ Rake.application.run
@@ -0,0 +1,70 @@
1
+ #--
2
+ # Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com)
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to
6
+ # deal in the Software without restriction, including without limitation the
7
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
+ # sell copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
+ # IN THE SOFTWARE.
21
+ #++
22
+
23
+ module Rake; end
24
+
25
+ require "rake/version"
26
+
27
+ require "rbconfig"
28
+ require "fileutils"
29
+ require "singleton"
30
+ require "monitor"
31
+ require "optparse"
32
+ require "ostruct"
33
+
34
+ require "rake/ext/string"
35
+
36
+ require "rake/win32"
37
+
38
+ require "rake/linked_list"
39
+ require "rake/cpu_counter"
40
+ require "rake/scope"
41
+ require "rake/task_argument_error"
42
+ require "rake/rule_recursion_overflow_error"
43
+ require "rake/rake_module"
44
+ require "rake/trace_output"
45
+ require "rake/pseudo_status"
46
+ require "rake/task_arguments"
47
+ require "rake/invocation_chain"
48
+ require "rake/task"
49
+ require "rake/file_task"
50
+ require "rake/file_creation_task"
51
+ require "rake/multi_task"
52
+ require "rake/dsl_definition"
53
+ require "rake/file_utils_ext"
54
+ require "rake/file_list"
55
+ require "rake/default_loader"
56
+ require "rake/early_time"
57
+ require "rake/late_time"
58
+ require "rake/name_space"
59
+ require "rake/task_manager"
60
+ require "rake/application"
61
+ require "rake/backtrace"
62
+
63
+ $trace = false
64
+
65
+ # :stopdoc:
66
+ #
67
+ # Some top level Constants.
68
+
69
+ FileList = Rake::FileList
70
+ RakeFileUtils = Rake::FileUtilsExt
@@ -0,0 +1,785 @@
1
+ require "optparse"
2
+
3
+ require "rake/task_manager"
4
+ require "rake/file_list"
5
+ require "rake/thread_pool"
6
+ require "rake/thread_history_display"
7
+ require "rake/trace_output"
8
+ require "rake/win32"
9
+
10
+ module Rake
11
+
12
+ CommandLineOptionError = Class.new(StandardError)
13
+
14
+ ##
15
+ # Rake main application object. When invoking +rake+ from the
16
+ # command line, a Rake::Application object is created and run.
17
+
18
+ class Application
19
+ include TaskManager
20
+ include TraceOutput
21
+
22
+ # The name of the application (typically 'rake')
23
+ attr_reader :name
24
+
25
+ # The original directory where rake was invoked.
26
+ attr_reader :original_dir
27
+
28
+ # Name of the actual rakefile used.
29
+ attr_reader :rakefile
30
+
31
+ # Number of columns on the terminal
32
+ attr_accessor :terminal_columns
33
+
34
+ # List of the top level task names (task names from the command line).
35
+ attr_reader :top_level_tasks
36
+
37
+ # Override the detected TTY output state (mostly for testing)
38
+ attr_writer :tty_output
39
+
40
+ DEFAULT_RAKEFILES = [
41
+ "rakefile",
42
+ "Rakefile",
43
+ "rakefile.rb",
44
+ "Rakefile.rb"
45
+ ].freeze
46
+
47
+ # Initialize a Rake::Application object.
48
+ def initialize
49
+ super
50
+ @name = "rake"
51
+ @rakefiles = DEFAULT_RAKEFILES.dup
52
+ @rakefile = nil
53
+ @pending_imports = []
54
+ @imported = []
55
+ @loaders = {}
56
+ @default_loader = Rake::DefaultLoader.new
57
+ @original_dir = Dir.pwd
58
+ @top_level_tasks = []
59
+ add_loader("rb", DefaultLoader.new)
60
+ add_loader("rf", DefaultLoader.new)
61
+ add_loader("rake", DefaultLoader.new)
62
+ @tty_output = STDOUT.tty?
63
+ @terminal_columns = ENV["RAKE_COLUMNS"].to_i
64
+ end
65
+
66
+ # Run the Rake application. The run method performs the following
67
+ # three steps:
68
+ #
69
+ # * Initialize the command line options (+init+).
70
+ # * Define the tasks (+load_rakefile+).
71
+ # * Run the top level tasks (+top_level+).
72
+ #
73
+ # If you wish to build a custom rake command, you should call
74
+ # +init+ on your application. Then define any tasks. Finally,
75
+ # call +top_level+ to run your top level tasks.
76
+ def run
77
+ standard_exception_handling do
78
+ init
79
+ load_rakefile
80
+ top_level
81
+ end
82
+ end
83
+
84
+ # Initialize the command line parameters and app name.
85
+ def init(app_name="rake")
86
+ standard_exception_handling do
87
+ @name = app_name
88
+ args = handle_options
89
+ collect_command_line_tasks(args)
90
+ end
91
+ end
92
+
93
+ # Find the rakefile and then load it and any pending imports.
94
+ def load_rakefile
95
+ standard_exception_handling do
96
+ raw_load_rakefile
97
+ end
98
+ end
99
+
100
+ # Run the top level tasks of a Rake application.
101
+ def top_level
102
+ run_with_threads do
103
+ if options.show_tasks
104
+ display_tasks_and_comments
105
+ elsif options.show_prereqs
106
+ display_prerequisites
107
+ else
108
+ top_level_tasks.each { |task_name| invoke_task(task_name) }
109
+ end
110
+ end
111
+ end
112
+
113
+ # Run the given block with the thread startup and shutdown.
114
+ def run_with_threads
115
+ thread_pool.gather_history if options.job_stats == :history
116
+
117
+ yield
118
+
119
+ thread_pool.join
120
+ if options.job_stats
121
+ stats = thread_pool.statistics
122
+ puts "Maximum active threads: #{stats[:max_active_threads]} + main"
123
+ puts "Total threads in play: #{stats[:total_threads_in_play]} + main"
124
+ end
125
+ ThreadHistoryDisplay.new(thread_pool.history).show if
126
+ options.job_stats == :history
127
+ end
128
+
129
+ # Add a loader to handle imported files ending in the extension
130
+ # +ext+.
131
+ def add_loader(ext, loader)
132
+ ext = ".#{ext}" unless ext =~ /^\./
133
+ @loaders[ext] = loader
134
+ end
135
+
136
+ # Application options from the command line
137
+ def options
138
+ @options ||= OpenStruct.new
139
+ end
140
+
141
+ # Return the thread pool used for multithreaded processing.
142
+ def thread_pool # :nodoc:
143
+ @thread_pool ||= ThreadPool.new(options.thread_pool_size || Rake.suggested_thread_count-1)
144
+ end
145
+
146
+ # internal ----------------------------------------------------------------
147
+
148
+ # Invokes a task with arguments that are extracted from +task_string+
149
+ def invoke_task(task_string) # :nodoc:
150
+ name, args = parse_task_string(task_string)
151
+ t = self[name]
152
+ t.invoke(*args)
153
+ end
154
+
155
+ def parse_task_string(string) # :nodoc:
156
+ /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s
157
+
158
+ name = $1
159
+ remaining_args = $2
160
+
161
+ return string, [] unless name
162
+ return name, [] if remaining_args.empty?
163
+
164
+ args = []
165
+
166
+ begin
167
+ /((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
168
+
169
+ remaining_args = $2
170
+ args << $1.gsub(/\\(.)/, '\1')
171
+ end while remaining_args
172
+
173
+ return name, args
174
+ end
175
+
176
+ # Provide standard exception handling for the given block.
177
+ def standard_exception_handling # :nodoc:
178
+ yield
179
+ rescue SystemExit
180
+ # Exit silently with current status
181
+ raise
182
+ rescue OptionParser::InvalidOption => ex
183
+ $stderr.puts ex.message
184
+ exit(false)
185
+ rescue Exception => ex
186
+ # Exit with error message
187
+ display_error_message(ex)
188
+ exit_because_of_exception(ex)
189
+ end
190
+
191
+ # Exit the program because of an unhandled exception.
192
+ # (may be overridden by subclasses)
193
+ def exit_because_of_exception(ex) # :nodoc:
194
+ exit(false)
195
+ end
196
+
197
+ # Display the error message that caused the exception.
198
+ def display_error_message(ex) # :nodoc:
199
+ trace "#{name} aborted!"
200
+ display_exception_details(ex)
201
+ trace "Tasks: #{ex.chain}" if has_chain?(ex)
202
+ trace "(See full trace by running task with --trace)" unless
203
+ options.backtrace
204
+ end
205
+
206
+ def display_exception_details(ex) # :nodoc:
207
+ seen = Thread.current[:rake_display_exception_details_seen] ||= []
208
+ return if seen.include? ex
209
+ seen << ex
210
+
211
+ display_exception_message_details(ex)
212
+ display_exception_backtrace(ex)
213
+ display_exception_details(ex.cause) if has_cause?(ex)
214
+ end
215
+
216
+ def has_cause?(ex) # :nodoc:
217
+ ex.respond_to?(:cause) && ex.cause
218
+ end
219
+
220
+ def display_exception_message_details(ex) # :nodoc:
221
+ if ex.instance_of?(RuntimeError)
222
+ trace ex.message
223
+ else
224
+ trace "#{ex.class.name}: #{ex.message}"
225
+ end
226
+ end
227
+
228
+ def display_exception_backtrace(ex) # :nodoc:
229
+ if options.backtrace
230
+ trace ex.backtrace.join("\n")
231
+ else
232
+ trace Backtrace.collapse(ex.backtrace).join("\n")
233
+ end
234
+ end
235
+
236
+ # Warn about deprecated usage.
237
+ #
238
+ # Example:
239
+ # Rake.application.deprecate("import", "Rake.import", caller.first)
240
+ #
241
+ def deprecate(old_usage, new_usage, call_site) # :nodoc:
242
+ unless options.ignore_deprecate
243
+ $stderr.puts "WARNING: '#{old_usage}' is deprecated. " +
244
+ "Please use '#{new_usage}' instead.\n" +
245
+ " at #{call_site}"
246
+ end
247
+ end
248
+
249
+ # Does the exception have a task invocation chain?
250
+ def has_chain?(exception) # :nodoc:
251
+ exception.respond_to?(:chain) && exception.chain
252
+ end
253
+ private :has_chain?
254
+
255
+ # True if one of the files in RAKEFILES is in the current directory.
256
+ # If a match is found, it is copied into @rakefile.
257
+ def have_rakefile # :nodoc:
258
+ @rakefiles.each do |fn|
259
+ if File.exist?(fn)
260
+ others = FileList.glob(fn, File::FNM_CASEFOLD)
261
+ return others.size == 1 ? others.first : fn
262
+ elsif fn == ""
263
+ return fn
264
+ end
265
+ end
266
+ return nil
267
+ end
268
+
269
+ # True if we are outputting to TTY, false otherwise
270
+ def tty_output? # :nodoc:
271
+ @tty_output
272
+ end
273
+
274
+ # We will truncate output if we are outputting to a TTY or if we've been
275
+ # given an explicit column width to honor
276
+ def truncate_output? # :nodoc:
277
+ tty_output? || @terminal_columns.nonzero?
278
+ end
279
+
280
+ # Display the tasks and comments.
281
+ def display_tasks_and_comments # :nodoc:
282
+ displayable_tasks = tasks.select { |t|
283
+ (options.show_all_tasks || t.comment) &&
284
+ t.name =~ options.show_task_pattern
285
+ }
286
+ case options.show_tasks
287
+ when :tasks
288
+ width = displayable_tasks.map { |t| t.name_with_args.length }.max || 10
289
+ if truncate_output?
290
+ max_column = terminal_width - name.size - width - 7
291
+ else
292
+ max_column = nil
293
+ end
294
+
295
+ displayable_tasks.each do |t|
296
+ printf("#{name} %-#{width}s # %s\n",
297
+ t.name_with_args,
298
+ max_column ? truncate(t.comment, max_column) : t.comment)
299
+ end
300
+ when :describe
301
+ displayable_tasks.each do |t|
302
+ puts "#{name} #{t.name_with_args}"
303
+ comment = t.full_comment || ""
304
+ comment.split("\n").each do |line|
305
+ puts " #{line}"
306
+ end
307
+ puts
308
+ end
309
+ when :lines
310
+ displayable_tasks.each do |t|
311
+ t.locations.each do |loc|
312
+ printf "#{name} %-30s %s\n", t.name_with_args, loc
313
+ end
314
+ end
315
+ else
316
+ fail "Unknown show task mode: '#{options.show_tasks}'"
317
+ end
318
+ end
319
+
320
+ def terminal_width # :nodoc:
321
+ if @terminal_columns.nonzero?
322
+ result = @terminal_columns
323
+ else
324
+ result = unix? ? dynamic_width : 80
325
+ end
326
+ (result < 10) ? 80 : result
327
+ rescue
328
+ 80
329
+ end
330
+
331
+ # Calculate the dynamic width of the
332
+ def dynamic_width # :nodoc:
333
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
334
+ end
335
+
336
+ def dynamic_width_stty # :nodoc:
337
+ %x{stty size 2>/dev/null}.split[1].to_i
338
+ end
339
+
340
+ def dynamic_width_tput # :nodoc:
341
+ %x{tput cols 2>/dev/null}.to_i
342
+ end
343
+
344
+ def unix? # :nodoc:
345
+ RbConfig::CONFIG["host_os"] =~
346
+ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
347
+ end
348
+
349
+ def windows? # :nodoc:
350
+ Win32.windows?
351
+ end
352
+
353
+ def truncate(string, width) # :nodoc:
354
+ if string.nil?
355
+ ""
356
+ elsif string.length <= width
357
+ string
358
+ else
359
+ (string[0, width - 3] || "") + "..."
360
+ end
361
+ end
362
+
363
+ # Display the tasks and prerequisites
364
+ def display_prerequisites # :nodoc:
365
+ tasks.each do |t|
366
+ puts "#{name} #{t.name}"
367
+ t.prerequisites.each { |pre| puts " #{pre}" }
368
+ end
369
+ end
370
+
371
+ def trace(*strings) # :nodoc:
372
+ options.trace_output ||= $stderr
373
+ trace_on(options.trace_output, *strings)
374
+ end
375
+
376
+ def sort_options(options) # :nodoc:
377
+ options.sort_by { |opt|
378
+ opt.select { |o| o =~ /^-/ }.map(&:downcase).sort.reverse
379
+ }
380
+ end
381
+ private :sort_options
382
+
383
+ # A list of all the standard options used in rake, suitable for
384
+ # passing to OptionParser.
385
+ def standard_rake_options # :nodoc:
386
+ sort_options(
387
+ [
388
+ ["--all", "-A",
389
+ "Show all tasks, even uncommented ones (in combination with -T or -D)",
390
+ lambda { |value|
391
+ options.show_all_tasks = value
392
+ }
393
+ ],
394
+ ["--backtrace=[OUT]",
395
+ "Enable full backtrace. OUT can be stderr (default) or stdout.",
396
+ lambda { |value|
397
+ options.backtrace = true
398
+ select_trace_output(options, "backtrace", value)
399
+ }
400
+ ],
401
+ ["--build-all", "-B",
402
+ "Build all prerequisites, including those which are up-to-date.",
403
+ lambda { |value|
404
+ options.build_all = true
405
+ }
406
+ ],
407
+ ["--comments",
408
+ "Show commented tasks only",
409
+ lambda { |value|
410
+ options.show_all_tasks = !value
411
+ }
412
+ ],
413
+ ["--describe", "-D [PATTERN]",
414
+ "Describe the tasks (matching optional PATTERN), then exit.",
415
+ lambda { |value|
416
+ select_tasks_to_show(options, :describe, value)
417
+ }
418
+ ],
419
+ ["--dry-run", "-n",
420
+ "Do a dry run without executing actions.",
421
+ lambda { |value|
422
+ Rake.verbose(true)
423
+ Rake.nowrite(true)
424
+ options.dryrun = true
425
+ options.trace = true
426
+ }
427
+ ],
428
+ ["--execute", "-e CODE",
429
+ "Execute some Ruby code and exit.",
430
+ lambda { |value|
431
+ eval(value)
432
+ exit
433
+ }
434
+ ],
435
+ ["--execute-print", "-p CODE",
436
+ "Execute some Ruby code, print the result, then exit.",
437
+ lambda { |value|
438
+ puts eval(value)
439
+ exit
440
+ }
441
+ ],
442
+ ["--execute-continue", "-E CODE",
443
+ "Execute some Ruby code, " +
444
+ "then continue with normal task processing.",
445
+ lambda { |value| eval(value) }
446
+ ],
447
+ ["--jobs", "-j [NUMBER]",
448
+ "Specifies the maximum number of tasks to execute in parallel. " +
449
+ "(default is number of CPU cores + 4)",
450
+ lambda { |value|
451
+ if value.nil? || value == ""
452
+ value = Float::INFINITY
453
+ elsif value =~ /^\d+$/
454
+ value = value.to_i
455
+ else
456
+ value = Rake.suggested_thread_count
457
+ end
458
+ value = 1 if value < 1
459
+ options.thread_pool_size = value - 1
460
+ }
461
+ ],
462
+ ["--job-stats [LEVEL]",
463
+ "Display job statistics. " +
464
+ "LEVEL=history displays a complete job list",
465
+ lambda { |value|
466
+ if value =~ /^history/i
467
+ options.job_stats = :history
468
+ else
469
+ options.job_stats = true
470
+ end
471
+ }
472
+ ],
473
+ ["--libdir", "-I LIBDIR",
474
+ "Include LIBDIR in the search path for required modules.",
475
+ lambda { |value| $:.push(value) }
476
+ ],
477
+ ["--multitask", "-m",
478
+ "Treat all tasks as multitasks.",
479
+ lambda { |value| options.always_multitask = true }
480
+ ],
481
+ ["--no-search", "--nosearch",
482
+ "-N", "Do not search parent directories for the Rakefile.",
483
+ lambda { |value| options.nosearch = true }
484
+ ],
485
+ ["--prereqs", "-P",
486
+ "Display the tasks and dependencies, then exit.",
487
+ lambda { |value| options.show_prereqs = true }
488
+ ],
489
+ ["--quiet", "-q",
490
+ "Do not log messages to standard output.",
491
+ lambda { |value| Rake.verbose(false) }
492
+ ],
493
+ ["--rakefile", "-f [FILENAME]",
494
+ "Use FILENAME as the rakefile to search for.",
495
+ lambda { |value|
496
+ value ||= ""
497
+ @rakefiles.clear
498
+ @rakefiles << value
499
+ }
500
+ ],
501
+ ["--rakelibdir", "--rakelib", "-R RAKELIBDIR",
502
+ "Auto-import any .rake files in RAKELIBDIR. " +
503
+ "(default is 'rakelib')",
504
+ lambda { |value|
505
+ options.rakelib = value.split(File::PATH_SEPARATOR)
506
+ }
507
+ ],
508
+ ["--require", "-r MODULE",
509
+ "Require MODULE before executing rakefile.",
510
+ lambda { |value|
511
+ begin
512
+ require value
513
+ rescue LoadError => ex
514
+ begin
515
+ rake_require value
516
+ rescue LoadError
517
+ raise ex
518
+ end
519
+ end
520
+ }
521
+ ],
522
+ ["--rules",
523
+ "Trace the rules resolution.",
524
+ lambda { |value| options.trace_rules = true }
525
+ ],
526
+ ["--silent", "-s",
527
+ "Like --quiet, but also suppresses the " +
528
+ "'in directory' announcement.",
529
+ lambda { |value|
530
+ Rake.verbose(false)
531
+ options.silent = true
532
+ }
533
+ ],
534
+ ["--suppress-backtrace PATTERN",
535
+ "Suppress backtrace lines matching regexp PATTERN. " +
536
+ "Ignored if --trace is on.",
537
+ lambda { |value|
538
+ options.suppress_backtrace_pattern = Regexp.new(value)
539
+ }
540
+ ],
541
+ ["--system", "-g",
542
+ "Using system wide (global) rakefiles " +
543
+ "(usually '~/.rake/*.rake').",
544
+ lambda { |value| options.load_system = true }
545
+ ],
546
+ ["--no-system", "--nosystem", "-G",
547
+ "Use standard project Rakefile search paths, " +
548
+ "ignore system wide rakefiles.",
549
+ lambda { |value| options.ignore_system = true }
550
+ ],
551
+ ["--tasks", "-T [PATTERN]",
552
+ "Display the tasks (matching optional PATTERN) " +
553
+ "with descriptions, then exit. " +
554
+ "-AT combination displays all of tasks contained no description.",
555
+ lambda { |value|
556
+ select_tasks_to_show(options, :tasks, value)
557
+ }
558
+ ],
559
+ ["--trace=[OUT]", "-t",
560
+ "Turn on invoke/execute tracing, enable full backtrace. " +
561
+ "OUT can be stderr (default) or stdout.",
562
+ lambda { |value|
563
+ options.trace = true
564
+ options.backtrace = true
565
+ select_trace_output(options, "trace", value)
566
+ Rake.verbose(true)
567
+ }
568
+ ],
569
+ ["--verbose", "-v",
570
+ "Log message to standard output.",
571
+ lambda { |value| Rake.verbose(true) }
572
+ ],
573
+ ["--version", "-V",
574
+ "Display the program version.",
575
+ lambda { |value|
576
+ puts "rake, version #{Rake::VERSION}"
577
+ exit
578
+ }
579
+ ],
580
+ ["--where", "-W [PATTERN]",
581
+ "Describe the tasks (matching optional PATTERN), then exit.",
582
+ lambda { |value|
583
+ select_tasks_to_show(options, :lines, value)
584
+ options.show_all_tasks = true
585
+ }
586
+ ],
587
+ ["--no-deprecation-warnings", "-X",
588
+ "Disable the deprecation warnings.",
589
+ lambda { |value|
590
+ options.ignore_deprecate = true
591
+ }
592
+ ],
593
+ ])
594
+ end
595
+
596
+ def select_tasks_to_show(options, show_tasks, value) # :nodoc:
597
+ options.show_tasks = show_tasks
598
+ options.show_task_pattern = Regexp.new(value || "")
599
+ Rake::TaskManager.record_task_metadata = true
600
+ end
601
+ private :select_tasks_to_show
602
+
603
+ def select_trace_output(options, trace_option, value) # :nodoc:
604
+ value = value.strip unless value.nil?
605
+ case value
606
+ when "stdout"
607
+ options.trace_output = $stdout
608
+ when "stderr", nil
609
+ options.trace_output = $stderr
610
+ else
611
+ fail CommandLineOptionError,
612
+ "Unrecognized --#{trace_option} option '#{value}'"
613
+ end
614
+ end
615
+ private :select_trace_output
616
+
617
+ # Read and handle the command line options. Returns the command line
618
+ # arguments that we didn't understand, which should (in theory) be just
619
+ # task names and env vars.
620
+ def handle_options # :nodoc:
621
+ options.rakelib = ["rakelib"]
622
+ options.trace_output = $stderr
623
+
624
+ OptionParser.new do |opts|
625
+ opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..."
626
+ opts.separator ""
627
+ opts.separator "Options are ..."
628
+
629
+ opts.on_tail("-h", "--help", "-H", "Display this help message.") do
630
+ puts opts
631
+ exit
632
+ end
633
+
634
+ standard_rake_options.each { |args| opts.on(*args) }
635
+ opts.environment("RAKEOPT")
636
+ end.parse(ARGV)
637
+ end
638
+
639
+ # Similar to the regular Ruby +require+ command, but will check
640
+ # for *.rake files in addition to *.rb files.
641
+ def rake_require(file_name, paths=$LOAD_PATH, loaded=$") # :nodoc:
642
+ fn = file_name + ".rake"
643
+ return false if loaded.include?(fn)
644
+ paths.each do |path|
645
+ full_path = File.join(path, fn)
646
+ if File.exist?(full_path)
647
+ Rake.load_rakefile(full_path)
648
+ loaded << fn
649
+ return true
650
+ end
651
+ end
652
+ fail LoadError, "Can't find #{file_name}"
653
+ end
654
+
655
+ def find_rakefile_location # :nodoc:
656
+ here = Dir.pwd
657
+ until (fn = have_rakefile)
658
+ Dir.chdir("..")
659
+ return nil if Dir.pwd == here || options.nosearch
660
+ here = Dir.pwd
661
+ end
662
+ [fn, here]
663
+ ensure
664
+ Dir.chdir(Rake.original_dir)
665
+ end
666
+
667
+ def print_rakefile_directory(location) # :nodoc:
668
+ $stderr.puts "(in #{Dir.pwd})" unless
669
+ options.silent or original_dir == location
670
+ end
671
+
672
+ def raw_load_rakefile # :nodoc:
673
+ rakefile, location = find_rakefile_location
674
+ if (! options.ignore_system) &&
675
+ (options.load_system || rakefile.nil?) &&
676
+ system_dir && File.directory?(system_dir)
677
+ print_rakefile_directory(location)
678
+ glob("#{system_dir}/*.rake") do |name|
679
+ add_import name
680
+ end
681
+ else
682
+ fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if
683
+ rakefile.nil?
684
+ @rakefile = rakefile
685
+ Dir.chdir(location)
686
+ print_rakefile_directory(location)
687
+ Rake.load_rakefile(File.expand_path(@rakefile)) if
688
+ @rakefile && @rakefile != ""
689
+ options.rakelib.each do |rlib|
690
+ glob("#{rlib}/*.rake") do |name|
691
+ add_import name
692
+ end
693
+ end
694
+ end
695
+ load_imports
696
+ end
697
+
698
+ def glob(path, &block) # :nodoc:
699
+ FileList.glob(path.tr("\\", "/")).each(&block)
700
+ end
701
+ private :glob
702
+
703
+ # The directory path containing the system wide rakefiles.
704
+ def system_dir # :nodoc:
705
+ @system_dir ||=
706
+ begin
707
+ if ENV["RAKE_SYSTEM"]
708
+ ENV["RAKE_SYSTEM"]
709
+ else
710
+ standard_system_dir
711
+ end
712
+ end
713
+ end
714
+
715
+ # The standard directory containing system wide rake files.
716
+ if Win32.windows?
717
+ def standard_system_dir #:nodoc:
718
+ Win32.win32_system_dir
719
+ end
720
+ else
721
+ def standard_system_dir #:nodoc:
722
+ File.join(File.expand_path("~"), ".rake")
723
+ end
724
+ end
725
+ private :standard_system_dir
726
+
727
+ # Collect the list of tasks on the command line. If no tasks are
728
+ # given, return a list containing only the default task.
729
+ # Environmental assignments are processed at this time as well.
730
+ #
731
+ # `args` is the list of arguments to peruse to get the list of tasks.
732
+ # It should be the command line that was given to rake, less any
733
+ # recognised command-line options, which OptionParser.parse will
734
+ # have taken care of already.
735
+ def collect_command_line_tasks(args) # :nodoc:
736
+ @top_level_tasks = []
737
+ args.each do |arg|
738
+ if arg =~ /^(\w+)=(.*)$/m
739
+ ENV[$1] = $2
740
+ else
741
+ @top_level_tasks << arg unless arg =~ /^-/
742
+ end
743
+ end
744
+ @top_level_tasks.push(default_task_name) if @top_level_tasks.empty?
745
+ end
746
+
747
+ # Default task name ("default").
748
+ # (May be overridden by subclasses)
749
+ def default_task_name # :nodoc:
750
+ "default"
751
+ end
752
+
753
+ # Add a file to the list of files to be imported.
754
+ def add_import(fn) # :nodoc:
755
+ @pending_imports << fn
756
+ end
757
+
758
+ # Load the pending list of imported files.
759
+ def load_imports # :nodoc:
760
+ while fn = @pending_imports.shift
761
+ next if @imported.member?(fn)
762
+ fn_task = lookup(fn) and fn_task.invoke
763
+ ext = File.extname(fn)
764
+ loader = @loaders[ext] || @default_loader
765
+ loader.load(fn)
766
+ if fn_task = lookup(fn) and fn_task.needed?
767
+ fn_task.reenable
768
+ fn_task.invoke
769
+ loader.load(fn)
770
+ end
771
+ @imported << fn
772
+ end
773
+ end
774
+
775
+ def rakefile_location(backtrace=caller) # :nodoc:
776
+ backtrace.map { |t| t[/([^:]+):/, 1] }
777
+
778
+ re = /^#{@rakefile}$/
779
+ re = /#{re.source}/i if windows?
780
+
781
+ backtrace.find { |str| str =~ re } || ""
782
+ end
783
+
784
+ end
785
+ end