qb 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -1
  3. data/README.md +42 -26
  4. data/ansible.cfg +7 -0
  5. data/doc/common_issues/qb_run/slow_gather_facts.md +51 -0
  6. data/doc/getting_started.md +84 -0
  7. data/doc/intro.md +67 -0
  8. data/doc/notes/2018.01.06.ansible_devel_submodule.md +29 -0
  9. data/doc/qb_roles.md +155 -0
  10. data/doc/qb_roles/metadata/default_dir.md +116 -0
  11. data/exe/qb +16 -14
  12. data/lib/qb.rb +5 -20
  13. data/lib/qb/ansible/cmds/playbook.rb +3 -4
  14. data/lib/qb/ansible/env.rb +22 -2
  15. data/lib/qb/ansible/env/devel.rb +49 -0
  16. data/lib/qb/cli.rb +3 -1
  17. data/lib/qb/cli/help.rb +1 -1
  18. data/lib/qb/cli/list.rb +47 -0
  19. data/lib/qb/cli/run.rb +41 -15
  20. data/lib/qb/cli/setup.rb +35 -2
  21. data/lib/qb/options.rb +57 -30
  22. data/lib/qb/role.rb +32 -170
  23. data/lib/qb/role/default_dir.rb +231 -0
  24. data/lib/qb/role/errors.rb +18 -10
  25. data/lib/qb/role/name.rb +139 -0
  26. data/lib/qb/util/logging.rb +0 -7
  27. data/lib/qb/version.rb +1 -1
  28. data/library/stream +5 -0
  29. data/plugins/filter_plugins/string_plugins.py +2 -3
  30. data/plugins/filter_plugins/version_plugins.py +11 -0
  31. data/qb.gemspec +158 -62
  32. data/roles/nrser.blockinfile/library/blockinfile.py +14 -0
  33. data/roles/qb.git_repo/tasks/main.yml +3 -3
  34. data/roles/qb.npm_package/meta/main.yml +2 -2
  35. data/roles/qb.npm_package/meta/qb.yml +3 -3
  36. data/roles/qb.vars/meta/qb.yml +8 -7
  37. data/roles/qb.vars/tasks/main.yml +10 -1
  38. data/roles/qb/call/defaults/main.yml +2 -0
  39. data/roles/qb/call/meta/main.yml +8 -0
  40. data/roles/qb/call/meta/qb.yml +68 -0
  41. data/roles/qb/call/tasks/main.yml +92 -0
  42. data/roles/qb/gem/new/meta/qb.yml +1 -1
  43. data/roles/qb/gem/new/tasks/main.yml +3 -3
  44. data/roles/qb/gem/release/tasks/main.yml +3 -5
  45. data/roles/{qb.gitignore → qb/git/ignore}/defaults/main.yml +1 -1
  46. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  47. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Actionscript.gitignore +2 -3
  48. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Ada.gitignore +0 -0
  49. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Agda.gitignore +0 -0
  50. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Android.gitignore +3 -2
  51. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/AppEngine.gitignore +0 -0
  52. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/AppceleratorTitanium.gitignore +0 -0
  53. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ArchLinuxPackages.gitignore +0 -0
  54. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Autotools.gitignore +9 -0
  55. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/C++.gitignore +0 -0
  56. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/C.gitignore +0 -0
  57. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CFWheels.gitignore +0 -0
  58. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CMake.gitignore +0 -0
  59. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CONTRIBUTING.md +0 -0
  60. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CUDA.gitignore +0 -0
  61. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CakePHP.gitignore +0 -0
  62. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ChefCookbook.gitignore +0 -0
  63. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Clojure.gitignore +0 -0
  64. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CodeIgniter.gitignore +0 -0
  65. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CommonLisp.gitignore +0 -0
  66. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Composer.gitignore +1 -1
  67. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Concrete5.gitignore +0 -0
  68. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Coq.gitignore +0 -0
  69. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CraftCMS.gitignore +0 -0
  70. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/D.gitignore +0 -0
  71. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/DM.gitignore +0 -0
  72. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Dart.gitignore +0 -0
  73. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Delphi.gitignore +0 -0
  74. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Drupal.gitignore +3 -0
  75. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/EPiServer.gitignore +0 -0
  76. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Eagle.gitignore +0 -0
  77. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Elisp.gitignore +0 -0
  78. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Elixir.gitignore +2 -0
  79. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Elm.gitignore +0 -0
  80. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Erlang.gitignore +0 -0
  81. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ExpressionEngine.gitignore +0 -0
  82. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ExtJs.gitignore +2 -0
  83. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Fancy.gitignore +0 -0
  84. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Finale.gitignore +0 -0
  85. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ForceDotCom.gitignore +0 -0
  86. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Fortran.gitignore +0 -0
  87. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/FuelPHP.gitignore +0 -0
  88. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/GWT.gitignore +0 -0
  89. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Gcov.gitignore +0 -0
  90. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Gem.gitignore +0 -0
  91. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/GitBook.gitignore +0 -0
  92. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Anjuta.gitignore +0 -0
  93. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Ansible.gitignore +0 -0
  94. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Archives.gitignore +2 -2
  95. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Bazaar.gitignore +0 -0
  96. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/BricxCC.gitignore +0 -0
  97. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/CVS.gitignore +0 -0
  98. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Calabash.gitignore +0 -0
  99. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Cloud9.gitignore +0 -0
  100. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/CodeKit.gitignore +0 -0
  101. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/DartEditor.gitignore +0 -0
  102. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Dreamweaver.gitignore +0 -0
  103. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Dropbox.gitignore +0 -0
  104. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Eclipse.gitignore +0 -0
  105. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/EiffelStudio.gitignore +0 -0
  106. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Emacs.gitignore +0 -0
  107. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Ensime.gitignore +0 -0
  108. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Espresso.gitignore +0 -0
  109. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/FlexBuilder.gitignore +0 -0
  110. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/GPG.gitignore +0 -0
  111. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/JDeveloper.gitignore +0 -0
  112. data/roles/qb/git/ignore/files/gitignore/Global/JEnv.gitignore +5 -0
  113. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/JetBrains.gitignore +2 -1
  114. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/KDevelop4.gitignore +0 -0
  115. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Kate.gitignore +0 -0
  116. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Lazarus.gitignore +0 -0
  117. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/LibreOffice.gitignore +0 -0
  118. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Linux.gitignore +0 -0
  119. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/LyX.gitignore +0 -0
  120. data/roles/qb/git/ignore/files/gitignore/Global/Matlab.gitignore +25 -0
  121. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Mercurial.gitignore +0 -0
  122. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/MicrosoftOffice.gitignore +0 -0
  123. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/ModelSim.gitignore +0 -0
  124. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Momentics.gitignore +0 -0
  125. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/MonoDevelop.gitignore +0 -0
  126. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/NetBeans.gitignore +0 -0
  127. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Ninja.gitignore +0 -0
  128. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/NotepadPP.gitignore +0 -0
  129. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Otto.gitignore +0 -0
  130. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/README.md +0 -0
  131. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Redcar.gitignore +0 -0
  132. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Redis.gitignore +0 -0
  133. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SBT.gitignore +0 -0
  134. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SVN.gitignore +0 -0
  135. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SlickEdit.gitignore +0 -0
  136. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Stata.gitignore +0 -0
  137. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SublimeText.gitignore +5 -5
  138. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SynopsysVCS.gitignore +0 -0
  139. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Tags.gitignore +0 -0
  140. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/TextMate.gitignore +0 -0
  141. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/TortoiseGit.gitignore +0 -0
  142. data/roles/qb/git/ignore/files/gitignore/Global/Vagrant.gitignore +5 -0
  143. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Vim.gitignore +6 -4
  144. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/VirtualEnv.gitignore +0 -0
  145. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/VisualStudioCode.gitignore +0 -0
  146. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/WebMethods.gitignore +0 -0
  147. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Windows.gitignore +4 -1
  148. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Xcode.gitignore +9 -9
  149. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/XilinxISE.gitignore +0 -0
  150. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/macOS.gitignore +2 -1
  151. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Go.gitignore +0 -3
  152. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Gradle.gitignore +0 -0
  153. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Grails.gitignore +0 -0
  154. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Haskell.gitignore +2 -0
  155. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/IGORPro.gitignore +0 -0
  156. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Idris.gitignore +0 -0
  157. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Java.gitignore +0 -0
  158. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Jboss.gitignore +0 -0
  159. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Jekyll.gitignore +1 -0
  160. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Joomla.gitignore +1 -1
  161. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Julia.gitignore +0 -0
  162. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/KiCad.gitignore +0 -0
  163. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Kohana.gitignore +0 -0
  164. data/roles/qb/git/ignore/files/gitignore/Kotlin.gitignore +1 -0
  165. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/LICENSE +0 -0
  166. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/LabVIEW.gitignore +0 -0
  167. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Laravel.gitignore +0 -0
  168. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Leiningen.gitignore +0 -0
  169. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/LemonStand.gitignore +0 -0
  170. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Lilypond.gitignore +0 -0
  171. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Lithium.gitignore +0 -0
  172. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Lua.gitignore +0 -0
  173. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Magento.gitignore +0 -0
  174. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Maven.gitignore +0 -0
  175. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Mercury.gitignore +0 -0
  176. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/MetaProgrammingSystem.gitignore +0 -0
  177. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Nanoc.gitignore +1 -1
  178. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Nim.gitignore +0 -0
  179. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Node.gitignore +1 -1
  180. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/OCaml.gitignore +3 -0
  181. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Objective-C.gitignore +0 -0
  182. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Opa.gitignore +0 -0
  183. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/OpenCart.gitignore +0 -0
  184. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/OracleForms.gitignore +0 -0
  185. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Packer.gitignore +0 -0
  186. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Perl.gitignore +1 -1
  187. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Phalcon.gitignore +0 -0
  188. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/PlayFramework.gitignore +0 -0
  189. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Plone.gitignore +0 -0
  190. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Prestashop.gitignore +3 -1
  191. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Processing.gitignore +0 -0
  192. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/PureScript.gitignore +0 -0
  193. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Python.gitignore +11 -5
  194. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/QB.gitignore +0 -0
  195. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Qooxdoo.gitignore +0 -0
  196. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Qt.gitignore +8 -0
  197. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/R.gitignore +0 -0
  198. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/README.md +2 -2
  199. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ROS.gitignore +2 -0
  200. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Rails.gitignore +4 -0
  201. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/RhodesRhomobile.gitignore +0 -0
  202. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Ruby.gitignore +0 -16
  203. data/roles/qb/git/ignore/files/gitignore/RubyMotion.gitignore +30 -0
  204. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Rust.gitignore +0 -0
  205. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SCons.gitignore +0 -0
  206. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Sass.gitignore +0 -0
  207. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Scala.gitignore +0 -0
  208. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Scheme.gitignore +0 -0
  209. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Scrivener.gitignore +0 -0
  210. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Sdcc.gitignore +0 -0
  211. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SeamGen.gitignore +0 -0
  212. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SketchUp.gitignore +0 -0
  213. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Smalltalk.gitignore +4 -0
  214. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Stella.gitignore +0 -0
  215. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SugarCRM.gitignore +2 -2
  216. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Swift.gitignore +1 -0
  217. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Symfony.gitignore +7 -0
  218. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SymphonyCMS.gitignore +0 -0
  219. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/TeX.gitignore +6 -1
  220. data/roles/qb/git/ignore/files/gitignore/Terraform.gitignore +9 -0
  221. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Textpattern.gitignore +0 -0
  222. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/TurboGears2.gitignore +0 -0
  223. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Typo3.gitignore +0 -0
  224. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Umbraco.gitignore +7 -0
  225. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Unity.gitignore +7 -6
  226. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/UnrealEngine.gitignore +2 -0
  227. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/VVVV.gitignore +0 -0
  228. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/VisualStudio.gitignore +37 -6
  229. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Waf.gitignore +0 -0
  230. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/WordPress.gitignore +1 -0
  231. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Xojo.gitignore +0 -0
  232. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Yeoman.gitignore +0 -0
  233. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Yii.gitignore +0 -0
  234. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ZendFramework.gitignore +0 -1
  235. data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Zephir.gitignore +0 -0
  236. data/roles/{qb.gitignore → qb/git/ignore}/meta/main.yml +1 -1
  237. data/roles/{qb.gitignore → qb/git/ignore}/meta/qb +5 -0
  238. data/roles/{qb.gitignore → qb/git/ignore}/tasks/main.yml +9 -1
  239. data/roles/qb/github/pages/setup/defaults/main.yml +2 -0
  240. data/roles/qb/github/pages/setup/meta/main.yml +8 -0
  241. data/roles/qb/github/pages/setup/meta/qb.yml +68 -0
  242. data/roles/qb/github/pages/setup/tasks/main.yml +10 -0
  243. data/roles/{qb.project → qb/project}/.qb-options.yml +1 -1
  244. data/roles/{qb.project → qb/project}/defaults/main.yml +1 -1
  245. data/roles/{qb.project → qb/project}/files/ansible.cfg +0 -0
  246. data/roles/{qb.project → qb/project}/files/hosts +0 -0
  247. data/roles/qb/project/meta/main.yml +6 -0
  248. data/roles/{qb.project → qb/project}/meta/qb.yml +4 -2
  249. data/roles/{qb.project → qb/project}/qb/get_dir +0 -0
  250. data/roles/qb/project/tasks/dev.yml +53 -0
  251. data/roles/{qb.project → qb/project}/tasks/main.yml +3 -2
  252. data/roles/{qb.project → qb/project}/templates/.gitkeep +0 -0
  253. data/roles/qb/project/templates/README.md.j2 +4 -0
  254. data/roles/qb/project/templates/setup.qb.yml.j2 +52 -0
  255. data/roles/{qb.project → qb/project}/templates/setup.yml.j2 +0 -0
  256. data/roles/{qb.role → qb/role}/.qb-options.yml +0 -0
  257. data/roles/{qb.role → qb/role}/defaults/main.yml +4 -1
  258. data/roles/{qb.role → qb/role}/meta/main.yml +1 -1
  259. data/roles/{qb.role → qb/role}/meta/qb.yml +2 -2
  260. data/roles/qb/role/qb/meta/main.yml +1 -1
  261. data/roles/qb/role/qb/meta/qb.yml +1 -1
  262. data/roles/qb/role/qb/tasks/main.yml +4 -2
  263. data/roles/qb/role/qb/templates/qb.yml.j2 +1 -1
  264. data/roles/{qb.role → qb/role}/tasks/main.yml +3 -2
  265. data/roles/{qb.role → qb/role}/tasks/module.yml +0 -0
  266. data/roles/{qb.role → qb/role}/tasks/plugins/_filter_plugin.yml +0 -0
  267. data/roles/{qb.role → qb/role}/tasks/plugins/filter_plugins.yml +5 -5
  268. data/roles/{qb.role → qb/role}/templates/.gitkeep +0 -0
  269. data/roles/{qb.role → qb/role}/templates/README.md.j2 +0 -0
  270. data/roles/{qb.role → qb/role}/templates/defaults/main.yml.j2 +0 -0
  271. data/roles/{qb.role → qb/role}/templates/filter_plugins/filters.py.j2 +0 -0
  272. data/roles/{qb.role → qb/role}/templates/handlers/main.yml.j2 +0 -0
  273. data/roles/{qb.role → qb/role}/templates/library/module.rb.j2 +0 -0
  274. data/roles/{qb.role → qb/role}/templates/meta/main.yml.j2 +0 -0
  275. data/roles/{qb.role → qb/role}/templates/tasks/main.yml.j2 +0 -0
  276. data/roles/{qb.role → qb/role}/templates/vars/main.yml.j2 +0 -0
  277. data/roles/{qb.role → qb/role}/vars/main.yml +1 -1
  278. data/roles/qb/ruby/bundler/.qb-options.yml +4 -0
  279. data/roles/qb/ruby/bundler/defaults/main.yml +7 -0
  280. data/roles/qb/ruby/bundler/filter_plugins/bundler_filters.py +157 -0
  281. data/roles/qb/ruby/bundler/meta/main.yml +8 -0
  282. data/roles/qb/ruby/bundler/meta/qb.yml +69 -0
  283. data/roles/qb/ruby/bundler/tasks/gems.yml +12 -0
  284. data/roles/qb/ruby/bundler/tasks/main.yml +12 -0
  285. data/roles/qb/ruby/bundler/tasks/setup.yml +13 -0
  286. data/roles/qb/ruby/yard/defaults/args.yml +2 -0
  287. data/roles/qb/ruby/yard/defaults/main.yml +9 -0
  288. data/roles/qb/ruby/yard/meta/main.yml +8 -0
  289. data/roles/qb/ruby/yard/meta/qb.yml +71 -0
  290. data/roles/qb/ruby/yard/tasks/main.yml +28 -0
  291. metadata +290 -297
  292. data/roles/nrser.blockinfile/tests/.gitignore +0 -1
  293. data/roles/nrser.blockinfile/tests/expected/test-basic/create.txt +0 -5
  294. data/roles/nrser.blockinfile/tests/expected/test-basic/insert.txt +0 -6
  295. data/roles/nrser.blockinfile/tests/expected/test-basic/marker.txt +0 -5
  296. data/roles/nrser.blockinfile/tests/expected/test-basic/remove.txt +0 -2
  297. data/roles/nrser.blockinfile/tests/expected/test-basic/update.txt +0 -6
  298. data/roles/nrser.blockinfile/tests/expected/test-block/block.txt +0 -4
  299. data/roles/nrser.blockinfile/tests/expected/test-block/content.txt +0 -4
  300. data/roles/nrser.blockinfile/tests/expected/test-follow/link0.txt +0 -6
  301. data/roles/nrser.blockinfile/tests/expected/test-follow/link1.txt +0 -6
  302. data/roles/nrser.blockinfile/tests/expected/test-follow/link2.txt +0 -1
  303. data/roles/nrser.blockinfile/tests/expected/test-follow/real0.txt +0 -2
  304. data/roles/nrser.blockinfile/tests/expected/test-follow/real1.txt +0 -2
  305. data/roles/nrser.blockinfile/tests/expected/test-follow/real2.txt +0 -6
  306. data/roles/nrser.blockinfile/tests/expected/test-insertab/insertafter.txt +0 -8
  307. data/roles/nrser.blockinfile/tests/expected/test-insertab/insertbefore.txt +0 -8
  308. data/roles/nrser.blockinfile/tests/expected/test-insertab/insertbof.txt +0 -8
  309. data/roles/nrser.blockinfile/tests/expected/test-insertab/inserteof.txt +0 -8
  310. data/roles/nrser.blockinfile/tests/expected/test-insertab/insertunmatched.txt +0 -8
  311. data/roles/nrser.blockinfile/tests/expected/test-insertab/updateafter.txt +0 -8
  312. data/roles/nrser.blockinfile/tests/expected/test-insertab/updatebefore.txt +0 -8
  313. data/roles/nrser.blockinfile/tests/expected/test-multiline/insert.txt +0 -11
  314. data/roles/nrser.blockinfile/tests/expected/test-multiline/remove.txt +0 -2
  315. data/roles/nrser.blockinfile/tests/expected/test-multiline/update.txt +0 -12
  316. data/roles/nrser.blockinfile/tests/expected/test-replace/index.html +0 -6
  317. data/roles/nrser.blockinfile/tests/expected/test-state/insert-present.txt +0 -5
  318. data/roles/nrser.blockinfile/tests/expected/test-state/insert.txt +0 -5
  319. data/roles/nrser.blockinfile/tests/expected/test-state/remove-absent.txt +0 -2
  320. data/roles/nrser.blockinfile/tests/expected/test-state/remove-present.txt +0 -2
  321. data/roles/nrser.blockinfile/tests/expected/test-state/remove.txt +0 -2
  322. data/roles/nrser.blockinfile/tests/fixtures/test-basic/insert.txt +0 -2
  323. data/roles/nrser.blockinfile/tests/fixtures/test-basic/marker.txt +0 -1
  324. data/roles/nrser.blockinfile/tests/fixtures/test-basic/remove.txt +0 -6
  325. data/roles/nrser.blockinfile/tests/fixtures/test-basic/update.txt +0 -6
  326. data/roles/nrser.blockinfile/tests/fixtures/test-block/block.txt +0 -1
  327. data/roles/nrser.blockinfile/tests/fixtures/test-block/content.txt +0 -1
  328. data/roles/nrser.blockinfile/tests/fixtures/test-follow/link0.txt +0 -1
  329. data/roles/nrser.blockinfile/tests/fixtures/test-follow/link1.txt +0 -1
  330. data/roles/nrser.blockinfile/tests/fixtures/test-follow/link2.txt +0 -1
  331. data/roles/nrser.blockinfile/tests/fixtures/test-follow/real0.txt +0 -2
  332. data/roles/nrser.blockinfile/tests/fixtures/test-follow/real1.txt +0 -2
  333. data/roles/nrser.blockinfile/tests/fixtures/test-follow/real2.txt +0 -2
  334. data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertafter.txt +0 -4
  335. data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertbefore.txt +0 -4
  336. data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertbof.txt +0 -4
  337. data/roles/nrser.blockinfile/tests/fixtures/test-insertab/inserteof.txt +0 -4
  338. data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertunmatched.txt +0 -4
  339. data/roles/nrser.blockinfile/tests/fixtures/test-insertab/updateafter.txt +0 -8
  340. data/roles/nrser.blockinfile/tests/fixtures/test-insertab/updatebefore.txt +0 -8
  341. data/roles/nrser.blockinfile/tests/fixtures/test-multiline/insert.txt +0 -2
  342. data/roles/nrser.blockinfile/tests/fixtures/test-multiline/remove.txt +0 -11
  343. data/roles/nrser.blockinfile/tests/fixtures/test-multiline/update.txt +0 -12
  344. data/roles/nrser.blockinfile/tests/fixtures/test-replace/index.html +0 -1
  345. data/roles/nrser.blockinfile/tests/fixtures/test-state/insert-present.txt +0 -2
  346. data/roles/nrser.blockinfile/tests/fixtures/test-state/insert.txt +0 -2
  347. data/roles/nrser.blockinfile/tests/fixtures/test-state/remove-absent.txt +0 -6
  348. data/roles/nrser.blockinfile/tests/fixtures/test-state/remove-present.txt +0 -6
  349. data/roles/nrser.blockinfile/tests/fixtures/test-state/remove.txt +0 -6
  350. data/roles/nrser.blockinfile/tests/hosts +0 -1
  351. data/roles/nrser.blockinfile/tests/roles/yaegashi.blockinfile +0 -1
  352. data/roles/nrser.blockinfile/tests/run.sh +0 -64
  353. data/roles/nrser.blockinfile/tests/test-basic.yml +0 -31
  354. data/roles/nrser.blockinfile/tests/test-block.yml +0 -16
  355. data/roles/nrser.blockinfile/tests/test-follow.yml +0 -21
  356. data/roles/nrser.blockinfile/tests/test-insertab.yml +0 -34
  357. data/roles/nrser.blockinfile/tests/test-multiline.yml +0 -51
  358. data/roles/nrser.blockinfile/tests/test-replace.yml +0 -21
  359. data/roles/nrser.blockinfile/tests/test-state.yml +0 -32
  360. data/roles/qb.gitignore/files/gitignore/Global/Matlab.gitignore +0 -22
  361. data/roles/qb.gitignore/files/gitignore/Global/Vagrant.gitignore +0 -1
  362. data/roles/qb.gitignore/files/gitignore/Terraform.gitignore +0 -6
  363. data/roles/qb.project/meta/main.yml +0 -6
  364. data/roles/qb.project/tasks/dev.yml +0 -36
  365. data/roles/qb.project/tasks/setup.yml +0 -42
  366. data/roles/qb.project/templates/README.md.j2 +0 -2
  367. data/roles/qb.project/templates/bootstrap.yml.j2 +0 -20
@@ -1,10 +1,20 @@
1
1
  # Requirements
2
2
  # =====================================================================
3
3
 
4
+ # StdLib
5
+ require 'pathname'
6
+
4
7
  # package
5
8
  require 'qb/ansible/cmds/playbook'
6
9
 
7
10
 
11
+ # Refinements
12
+ # =======================================================================
13
+
14
+ require 'nrser/refinements'
15
+ using NRSER
16
+
17
+
8
18
  # Declarations
9
19
  # =======================================================================
10
20
 
@@ -25,8 +35,31 @@ module QB::CLI
25
35
  # The `ansible-playbook` command exit code.
26
36
  #
27
37
  def self.setup args = []
28
- project_root = NRSER.git_root '.'
29
- playbook_path = project_root / 'dev' / 'setup.qb.yml'
38
+ # Figure out project root and setup playbook path
39
+ case args[0]
40
+ when String, Pathname
41
+ # The playbook path has been provided, use that to find the project root
42
+ playbook_path = QB::Util.resolve args[0]
43
+ project_root = NRSER.git_root playbook_path
44
+
45
+ when nil
46
+ # Figure the project root out from the current directory, then
47
+ # form the playbook path from that
48
+ project_root = NRSER.git_root '.'
49
+ playbook_path = project_root / 'dev' / 'setup.qb.yml'
50
+
51
+ else
52
+ raise TypeError.new binding.erb <<-END
53
+ First entry of `args` must be nil, String or Pathname, found:
54
+
55
+ <%= args[0].pretty_inspect %>
56
+
57
+ args:
58
+
59
+ <%= args.pretty_inspect %>
60
+
61
+ END
62
+ end
30
63
 
31
64
  unless playbook_path.file?
32
65
  raise "Can't find QB setup playbook at `#{ playbook_path.to_s }`"
@@ -10,7 +10,13 @@ using NRSER
10
10
 
11
11
  module QB
12
12
  class Options
13
- # constants
13
+ # Mixins
14
+ # ========================================================================
15
+
16
+ include SemanticLogger::Loggable
17
+
18
+
19
+ # Constants
14
20
  # =======================================================================
15
21
 
16
22
  QB_DEFAULTS = {
@@ -103,6 +109,8 @@ module QB
103
109
 
104
110
  QB.debug "including #{ role.name } as #{ new_include_path.join('-') }"
105
111
 
112
+ opts.separator "Options for included #{ role.name } role:"
113
+
106
114
  add opts, options, role, new_include_path
107
115
  end
108
116
 
@@ -353,6 +361,8 @@ module QB
353
361
 
354
362
  opts.banner = @role.banner
355
363
 
364
+ opts.separator "Common options:"
365
+
356
366
  opts.on(
357
367
  '-H',
358
368
  '--HOSTS=HOSTS',
@@ -457,6 +467,8 @@ module QB
457
467
  @qb['ask'] = value
458
468
  end
459
469
 
470
+ opts.separator "Role options:"
471
+
460
472
  self.class.add opts, @role_options, @role
461
473
 
462
474
  opts.on_tail("-h", "--help", "Show this message") do
@@ -471,37 +483,52 @@ module QB
471
483
  opt_parser.parse! @argv
472
484
  end # parse!
473
485
 
474
- # pull options that start with
475
- #
476
- # 1. `--ANSIBLE_`
477
- # 1. `--ANSIBLE-`
478
- # 2. `---`
479
- #
480
- # out of `@argv` and stick them in `@ansible`.
481
- def parse_ansible!
482
- @ansible = @role.default_ansible_options.clone
483
-
484
- reg_exs = [
485
- /\A\-\-ANSIBLE[\-\_]/,
486
- /\A\-\-\-/,
487
- ]
486
+
487
+ protected
488
+ # ========================================================================
488
489
 
489
- @argv.reject! {|shellword|
490
- if re = reg_exs.find {|re| re =~ shellword}
491
- name = shellword.sub re, ''
492
-
493
- value = true
494
-
495
- if name.include? '='
496
- name, value = name.split('=', 2)
490
+ # Pull options that start with
491
+ #
492
+ # 1. `--ANSIBLE_`
493
+ # 1. `--ANSIBLE-`
494
+ # 2. `---`
495
+ #
496
+ # out of `@argv` and stick them in `@ansible`.
497
+ #
498
+ # @return [nil]
499
+ # **Mutates** `@argv`.
500
+ #
501
+ def parse_ansible!
502
+ logger.debug "Parsing Ansible options...",
503
+ argv: @argv.dup
504
+
505
+ @ansible = @role.default_ansible_options.clone
506
+
507
+ reg_exs = [
508
+ /\A\-\-ANSIBLE[\-\_]/,
509
+ /\A\-\-\-/,
510
+ ]
511
+
512
+ @argv.reject! {|shellword|
513
+ if re = reg_exs.find {|re| re =~ shellword}
514
+ name = shellword.sub re, ''
515
+
516
+ value = true
517
+
518
+ if name.include? '='
519
+ name, value = name.split('=', 2)
520
+ end
521
+
522
+ @ansible[name] = value
523
+
524
+ true
497
525
  end
498
-
499
- @ansible[name] = value
500
-
501
- true
502
- end
503
- }
504
- end # #parse_ansible!
526
+ }
527
+
528
+ nil
529
+ end # #parse_ansible!
530
+
531
+ # end protected
505
532
 
506
533
  end # Options
507
534
  end # QB
@@ -1,15 +1,24 @@
1
-
2
1
  # Requirements
3
2
  # =======================================================================
4
3
 
5
4
  # stdlib
5
+ # ----------------------------------------------------------------------------
6
+
6
7
  require 'yaml'
7
8
  require 'cmds'
8
9
 
10
+
9
11
  # deps
12
+ # ----------------------------------------------------------------------------
13
+
10
14
 
11
15
  # package
12
- require_relative './role/errors'
16
+ # ----------------------------------------------------------------------------
17
+
18
+ # Breakouts
19
+ require 'qb/role/errors'
20
+ require 'qb/role/name'
21
+ require 'qb/role/default_dir'
13
22
 
14
23
 
15
24
  # Refinements
@@ -29,6 +38,12 @@ module QB; end
29
38
  #
30
39
  class QB::Role
31
40
 
41
+ # Mixins
42
+ # ============================================================================
43
+
44
+ include SemanticLogger::Loggable
45
+
46
+
32
47
  # Constants
33
48
  # =====================================================================
34
49
 
@@ -219,10 +234,12 @@ class QB::Role
219
234
  search_dir.directory?
220
235
  }.
221
236
  map {|search_dir|
222
- Pathname.glob(search_dir.join '**', 'meta', 'qb.yml').
223
- map {|meta_path|
224
- [meta_path.dirname.dirname, search_dir: search_dir]
225
- }
237
+ ['', '.yml', '.yaml'].flat_map { |ext|
238
+ Pathname.glob(search_dir.join '**', 'meta', "qb#{ ext }").
239
+ map {|meta_path|
240
+ [meta_path.dirname.dirname, search_dir: search_dir]
241
+ }
242
+ }
226
243
  }.
227
244
  flatten(1).
228
245
  map {|args|
@@ -403,58 +420,6 @@ class QB::Role
403
420
  end
404
421
 
405
422
 
406
- # Do our best to figure out a role name from a path (that might not exist).
407
- #
408
- # We needs this for when we're creating a role.
409
- #
410
- # @param [String | Pathname] path
411
- #
412
- #
413
- # @return [String]
414
- #
415
- def self.default_role_name path
416
- resolved_path = QB::Util.resolve path
417
-
418
- # Find the first directory in the search path that contains the path,
419
- # if any do.
420
- #
421
- # It *could* be in more than one in funky situations like overlapping
422
- # search paths or link silliness, but that doesn't matter - we consider
423
- # the first place we find it to be the relevant once, since the search
424
- # path is most-important-first.
425
- #
426
- search_dir = search_path.find { |pathname|
427
- resolved_path.fnmatch? ( pathname / '**' ).to_s
428
- }
429
-
430
- if search_dir.nil?
431
- # It's not in any of the search directories
432
- #
433
- # If it has 'roles' as a segment than use what's after the last occurrence
434
- # of that (unless there isn't anything).
435
- #
436
- segments = resolved_path.to_s.split File::SEPARATOR
437
-
438
- if index = segments.rindex( 'roles' )
439
- name_segs = segments[( index + 1 )..( -1 )]
440
-
441
- unless name_segs.empty?
442
- return File.join name_segs
443
- end
444
- end
445
-
446
- # Ok, that didn't work... just return the basename I guess...
447
- return File.basename resolved_path
448
-
449
- end
450
-
451
- # it's in the search path, return the relative path from the containing
452
- # search dir to the resolved path (string version of it).
453
- resolved_path.relative_path_from( search_dir ).to_s
454
-
455
- end # #default_role_name
456
-
457
-
458
423
  # Instance Attributes
459
424
  # =======================================================================
460
425
 
@@ -534,22 +499,6 @@ class QB::Role
534
499
  # Instance Methods
535
500
  # =====================================================================
536
501
 
537
- def namespace
538
- *namespace_segments, last = @name.split File::Separator
539
-
540
- namespace_segments << last.split('.').first if last.include?('.')
541
-
542
- if namespace_segments.empty?
543
- nil
544
- else
545
- File.join *namespace_segments
546
- end
547
- end
548
-
549
- def namespaceless
550
- File.basename(@name).split('.', 2).last
551
- end
552
-
553
502
  def options_key
554
503
  @display_path.to_s
555
504
  end
@@ -695,7 +644,7 @@ class QB::Role
695
644
  parts << '[OPTIONS]'
696
645
  end
697
646
 
698
- if uses_default_dir?
647
+ if has_dir_arg?
699
648
  parts << 'DIRECTORY'
700
649
  end
701
650
 
@@ -715,10 +664,11 @@ class QB::Role
715
664
  lines << meta['description']
716
665
  lines << ''
717
666
  end
718
- lines << 'usage:'
667
+ lines << 'Usage:'
668
+ lines << ''
719
669
  lines << " #{ usage }"
720
670
  lines << ''
721
- lines << 'options:'
671
+ lines << ''
722
672
 
723
673
  lines.join("\n")
724
674
  end
@@ -776,102 +726,14 @@ class QB::Role
776
726
  end
777
727
 
778
728
 
729
+ # Test if the {QB::Role} uses a directory argument (that gets assigned to
730
+ # the `qb_dir` variable in Ansible).
731
+ #
779
732
  # @return [Boolean]
780
- # @todo Document return value.
781
733
  #
782
- def uses_default_dir?
734
+ def has_dir_arg?
783
735
  meta['default_dir'] != false
784
- end # #uses_default_dir?
785
-
786
-
787
- # gets the default `qb_dir` value, raising an error if the role doesn't
788
- # define how to get one or there is a problem getting it.
789
- #
790
- #
791
- def default_dir cwd, options
792
- QB.debug "get_default_dir",
793
- role: self,
794
- meta: self.meta,
795
- cwd: cwd,
796
- options: options
797
-
798
- key = 'default_dir'
799
- value = self.meta[key]
800
- case value
801
- when nil
802
- # there is no get_dir info in meta/qb.yml, can't get the dir
803
- raise QB::UserInputError.dedented <<-END
804
- unable to infer default directory: no '#{ key }' key in 'meta/qb.yml'
805
- for role #{ self }
806
- END
807
-
808
- when false
809
- # this method should not get called when the value is false (an entire
810
- # section is skipped in exe/qb when `default_dir = false`)
811
- raise QB::StateError.squished <<-END
812
- role does not use default directory (meta/qb.yml:default_dir = false)
813
- END
814
-
815
- when 'git_root'
816
- QB.debug "returning the git root relative to cwd"
817
- NRSER.git_root cwd
818
-
819
- when 'cwd'
820
- QB.debug "returning current working directory"
821
- cwd
822
-
823
- when Hash
824
- QB.debug "qb meta option is a Hash"
825
-
826
- unless value.length == 1
827
- raise "#{ meta_path.to_s }:default_dir invalid: #{ value.inspect }"
828
- end
829
-
830
- hash_key, hash_value = value.first
831
-
832
- case hash_key
833
- when 'exe'
834
- exe_path = hash_value
835
-
836
- # supply the options to the exe so it can make work off those values
837
- # if it wants.
838
- exe_input_data = Hash[
839
- options.map {|option|
840
- [option.cli_option_name, option.value]
841
- }
842
- ]
843
-
844
- unless exe_path.start_with?('~') || exe_path.start_with?('/')
845
- exe_path = File.join(self.path, exe_path)
846
- debug 'exe path is relative, basing off role dir', exe_path: exe_path
847
- end
848
-
849
- debug "found 'exe' key, calling", exe_path: exe_path,
850
- exe_input_data: exe_input_data
851
-
852
- Cmds.chomp! exe_path do
853
- JSON.dump exe_input_data
854
- end
855
-
856
- when 'find_up'
857
- filename = hash_value
858
-
859
- unless filename.is_a? String
860
- raise "find_up filename must be string, found #{ filename.inspect }"
861
- end
862
-
863
- QB.debug "found 'find_up', looking for file named #{ filename }"
864
-
865
- QB::Util.find_up filename
866
-
867
- else
868
- raise QB::Role::MetadataError.squised <<-END
869
- bad key: #{ hash_key } in #{ self.meta_path.to_s }:default_dir
870
- END
871
-
872
- end
873
- end
874
- end # default_dir
736
+ end # #has_dir_arg?
875
737
 
876
738
 
877
739
  # @return [Hash<String, *>]
@@ -0,0 +1,231 @@
1
+ ##
2
+ # {QB::Role} methods for finding the default directory for
3
+ # running a role when one is not provided in the CLI.
4
+ #
5
+ # Broken out from the main `//lib/qb/role.rb` file because it was starting to
6
+ # get long and unwieldy.
7
+ #
8
+ ##
9
+
10
+
11
+ # Requirements
12
+ # =======================================================================
13
+
14
+ # Stdlib
15
+ # -----------------------------------------------------------------------
16
+ require 'pathname'
17
+
18
+ # Deps
19
+ # -----------------------------------------------------------------------
20
+
21
+ # Project / Package
22
+ # -----------------------------------------------------------------------
23
+
24
+
25
+ # Refinements
26
+ # =======================================================================
27
+
28
+ require 'nrser/refinements'
29
+ using NRSER
30
+
31
+
32
+ # Declarations
33
+ # =======================================================================
34
+
35
+ module QB; end
36
+
37
+
38
+ # Definitions
39
+ # =======================================================================
40
+
41
+ class QB::Role
42
+
43
+ # Instance Methods
44
+ # ======================================================================
45
+
46
+ # Gets the default `qb_dir` value, raising an error if the role doesn't
47
+ # define how to get one or there is a problem getting it.
48
+ #
49
+ # It uses a "strategy" value found at the 'default_dir' key in the role's
50
+ # QB metadata (in `<role_path>/meta/qb.yml` or returned by a
51
+ # `<role_path>/meta/qb` executable).
52
+ #
53
+ # See the {file:doc/qb_roles/metadata/default_dir.md default_dir}
54
+ # documentation for details on the accepted strategy values.
55
+ #
56
+ # @param [String | Pathname] cwd:
57
+ # The working directory the CLI command was run in.
58
+ #
59
+ # @param [Hash<String, QB::Options::Option>] options:
60
+ # The role options (from {QB::Options#role_options}).
61
+ #
62
+ # TODO rename this.
63
+ #
64
+ # @return [Pathname]
65
+ # The directory to target.
66
+ #
67
+ # @raise
68
+ # When we can't determine a directory due to role meta settings or target
69
+ # system state.
70
+ #
71
+ def default_dir cwd, options
72
+ logger.debug "CALLING default_dir",
73
+ role: self.instance_variables.map_values { |k, v|
74
+ self.instance_variable_get k
75
+ },
76
+ cwd: cwd,
77
+ options: options
78
+
79
+ default_dir_for(
80
+ value: self.meta['default_dir'],
81
+ cwd: cwd,
82
+ options: options
83
+ ).to_pn
84
+ end # default_dir
85
+
86
+
87
+ protected
88
+ # ========================================================================
89
+
90
+ # Internal, possibly recursive method that actually does the work of
91
+ # figuring out the directory value.
92
+ #
93
+ # Recurs when the meta value is an array, trying each of the entries in
94
+ # sequence, returning the first to succeed, and raising if they all fail.
95
+ #
96
+ # @param [nil | false | String | Hash | Array] strategy
97
+ # Instruction for how to determine the directory value.
98
+ #
99
+ # See the {file:doc/qb_roles.md#default_dir default_dir} for a details
100
+ # on recognized values.
101
+ #
102
+ # @return [return_type]
103
+ # @todo Document return value.
104
+ #
105
+ def default_dir_for value:, cwd:, options:
106
+ case value
107
+ when nil
108
+ # there is no get_dir info in meta/qb.yml, can't get the dir
109
+ raise QB::UserInputError.new binding.erb <<-END
110
+ No default directory for role <%= self.name %>
111
+
112
+ Role <%= self.name %> does not provide a default target directory
113
+ (used to populate the `qb_dir` Ansible variable).
114
+
115
+ You must provide one via the CLI like
116
+
117
+ qb run <%= self.name %> DIRECTORY
118
+
119
+ or, if you are the developer of the <%= self.name %> role, set a
120
+ non-null value for the 'default_dir' key in
121
+
122
+ <%= self.meta_path %>
123
+
124
+ END
125
+
126
+ when false
127
+ # this method should not get called when the value is false (an entire
128
+ # section is skipped in exe/qb when `default_dir = false`)
129
+ raise QB::StateError.squished <<-END
130
+ role does not use default directory (meta/qb.yml:default_dir = false)
131
+ END
132
+
133
+ when 'git_root'
134
+ logger.debug "returning the git root relative to cwd"
135
+ NRSER.git_root cwd
136
+
137
+ when 'cwd'
138
+ logger.debug "returning current working directory"
139
+ cwd
140
+
141
+ when Hash
142
+ logger.debug "qb meta option is a Hash"
143
+
144
+ unless value.length == 1
145
+ raise "#{ meta_path.to_s }:default_dir invalid: #{ value.inspect }"
146
+ end
147
+
148
+ hash_key, hash_value = value.first
149
+
150
+ case hash_key
151
+ when 'exe'
152
+ exe_path = hash_value
153
+
154
+ # supply the options to the exe so it can make work off those values
155
+ # if it wants.
156
+ exe_input_data = Hash[
157
+ options.map {|option|
158
+ [option.cli_option_name, option.value]
159
+ }
160
+ ]
161
+
162
+ unless exe_path.start_with?('~') || exe_path.start_with?('/')
163
+ exe_path = File.join(self.path, exe_path)
164
+ debug 'exe path is relative, basing off role dir', exe_path: exe_path
165
+ end
166
+
167
+ debug "found 'exe' key, calling", exe_path: exe_path,
168
+ exe_input_data: exe_input_data
169
+
170
+ Cmds.chomp! exe_path do
171
+ JSON.dump exe_input_data
172
+ end
173
+
174
+ when 'find_up'
175
+ filename = hash_value
176
+
177
+ unless filename.is_a? String
178
+ raise "find_up filename must be string, found #{ filename.inspect }"
179
+ end
180
+
181
+ QB.debug "found 'find_up', looking for file named #{ filename }"
182
+
183
+ QB::Util.find_up filename
184
+
185
+ when 'from_role'
186
+ # Get the value from another role, presumably one this role includes
187
+
188
+ default_dir_for \
189
+ value: QB::Role.require( hash_value ).meta['default_dir'],
190
+ cwd: cwd,
191
+ options: options
192
+
193
+ else
194
+ raise QB::Role::MetadataError.new binding.erb <<-END
195
+ Bad key <%= hash_key.inspect %> in 'default_dir' value
196
+
197
+ Metadata for role <%= name %> read from
198
+
199
+ <%= self.meta_path.to_s %>
200
+
201
+ contains an invalid default directory strategy
202
+
203
+ <%= value.pretty_inspect %>
204
+
205
+ The key <%= hash_key.inspect %> does not correspond to a recognized
206
+ form.
207
+
208
+ Valid forms are:
209
+
210
+ 1. {exe: FILEPATH}
211
+ 2. {file_up: FILEPATH}
212
+ 3. {from_role: ROLE}
213
+
214
+ END
215
+ end
216
+
217
+ when Array
218
+ value.try_find do |candidate|
219
+ default_dir_for value: candidate, cwd: cwd, options: options
220
+ end
221
+
222
+ else
223
+ raise QB::Role::MetadataError.new binding.erb <<-END
224
+ bad default_dir value: <%= value %>
225
+ END
226
+ end # case value
227
+ end # .default_dir_for
228
+
229
+ # end protected
230
+
231
+ end # class QB::Role