nucleon 0.2.2 → 0.2.3

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 (400) hide show
  1. checksums.yaml +7 -7
  2. data/.gitignore +50 -0
  3. data/ARCHITECTURE.rdoc +12 -11
  4. data/Gemfile +7 -11
  5. data/Gemfile.lock +47 -70
  6. data/Rakefile +22 -20
  7. data/TODO.rdoc +1 -1
  8. data/VERSION +1 -1
  9. data/bin/nucleon +16 -15
  10. data/lib/core/codes.rb +65 -38
  11. data/lib/core/config.rb +774 -153
  12. data/lib/core/config/collection.rb +134 -25
  13. data/lib/core/config/options.rb +160 -36
  14. data/lib/core/core.rb +207 -45
  15. data/lib/core/environment.rb +626 -206
  16. data/lib/core/facade.rb +211 -185
  17. data/lib/core/gems.rb +60 -44
  18. data/lib/core/manager.rb +587 -237
  19. data/lib/core/mixin/colors.rb +66 -36
  20. data/lib/core/mixin/config/collection.rb +58 -23
  21. data/lib/core/mixin/config/options.rb +67 -24
  22. data/lib/core/mixin/macro/object_interface.rb +129 -135
  23. data/lib/core/mixin/macro/plugin_interface.rb +118 -124
  24. data/lib/core/mixin/settings.rb +7 -13
  25. data/lib/core/mixin/sub_config.rb +37 -43
  26. data/lib/core/mod/hash.rb +31 -10
  27. data/lib/core/plugin/action.rb +274 -238
  28. data/lib/core/plugin/base.rb +140 -132
  29. data/lib/core/plugin/project.rb +316 -311
  30. data/lib/core/util/cli.rb +146 -146
  31. data/lib/core/util/console.rb +567 -124
  32. data/lib/core/util/data.rb +654 -139
  33. data/lib/core/util/logger.rb +255 -66
  34. data/lib/nucleon.rb +6 -8
  35. data/lib/nucleon_base.rb +364 -106
  36. data/nucleon.gemspec +40 -389
  37. data/spec/core/codes_spec.rb +209 -0
  38. data/spec/core/config_spec.rb +810 -0
  39. data/spec/core/core_spec.rb +185 -0
  40. data/spec/core/environment_spec.rb +148 -0
  41. data/spec/core/util/console_spec.rb +254 -446
  42. data/spec/nucleon/test.rb +59 -0
  43. data/spec/nucleon/test/first.rb +28 -0
  44. data/spec/nucleon/test/second.rb +28 -0
  45. data/spec/nucleon_codes.rb +98 -0
  46. data/spec/nucleon_config.rb +523 -0
  47. data/spec/nucleon_plugin.rb +439 -0
  48. data/spec/nucleon_test.rb +34 -0
  49. data/spec/spec_helper.rb +6 -4
  50. metadata +157 -615
  51. data/.document +0 -5
  52. data/rdoc/site/0.1.19/ARCHITECTURE_rdoc.html +0 -634
  53. data/rdoc/site/0.1.19/Hash.html +0 -347
  54. data/rdoc/site/0.1.19/Kernel.html +0 -413
  55. data/rdoc/site/0.1.19/Nucleon.html +0 -570
  56. data/rdoc/site/0.1.19/Nucleon/Action.html +0 -280
  57. data/rdoc/site/0.1.19/Nucleon/Action/Add.html +0 -458
  58. data/rdoc/site/0.1.19/Nucleon/Action/Create.html +0 -415
  59. data/rdoc/site/0.1.19/Nucleon/Action/Extract.html +0 -413
  60. data/rdoc/site/0.1.19/Nucleon/Action/Remove.html +0 -461
  61. data/rdoc/site/0.1.19/Nucleon/Action/Save.html +0 -434
  62. data/rdoc/site/0.1.19/Nucleon/Action/Update.html +0 -381
  63. data/rdoc/site/0.1.19/Nucleon/Codes.html +0 -563
  64. data/rdoc/site/0.1.19/Nucleon/Command.html +0 -275
  65. data/rdoc/site/0.1.19/Nucleon/Command/Bash.html +0 -544
  66. data/rdoc/site/0.1.19/Nucleon/Config.html +0 -1623
  67. data/rdoc/site/0.1.19/Nucleon/Config/Collection.html +0 -509
  68. data/rdoc/site/0.1.19/Nucleon/Config/Options.html +0 -489
  69. data/rdoc/site/0.1.19/Nucleon/Core.html +0 -635
  70. data/rdoc/site/0.1.19/Nucleon/Errors.html +0 -275
  71. data/rdoc/site/0.1.19/Nucleon/Errors/BatchError.html +0 -281
  72. data/rdoc/site/0.1.19/Nucleon/Errors/NucleonError.html +0 -657
  73. data/rdoc/site/0.1.19/Nucleon/Errors/SSHUnavailable.html +0 -281
  74. data/rdoc/site/0.1.19/Nucleon/Event.html +0 -275
  75. data/rdoc/site/0.1.19/Nucleon/Event/Regex.html +0 -467
  76. data/rdoc/site/0.1.19/Nucleon/Facade.html +0 -2336
  77. data/rdoc/site/0.1.19/Nucleon/Gems.html +0 -635
  78. data/rdoc/site/0.1.19/Nucleon/Manager.html +0 -1828
  79. data/rdoc/site/0.1.19/Nucleon/Mixin.html +0 -284
  80. data/rdoc/site/0.1.19/Nucleon/Mixin/Action.html +0 -277
  81. data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Commit.html +0 -381
  82. data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Project.html +0 -395
  83. data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Push.html +0 -371
  84. data/rdoc/site/0.1.19/Nucleon/Mixin/Colors.html +0 -545
  85. data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigCollection.html +0 -481
  86. data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigOptions.html +0 -449
  87. data/rdoc/site/0.1.19/Nucleon/Mixin/Macro.html +0 -276
  88. data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/ObjectInterface.html +0 -695
  89. data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/PluginInterface.html +0 -682
  90. data/rdoc/site/0.1.19/Nucleon/Mixin/Settings.html +0 -481
  91. data/rdoc/site/0.1.19/Nucleon/Mixin/SubConfig.html +0 -887
  92. data/rdoc/site/0.1.19/Nucleon/Parallel.html +0 -325
  93. data/rdoc/site/0.1.19/Nucleon/Parallel/ClassMethods.html +0 -325
  94. data/rdoc/site/0.1.19/Nucleon/Parallel/InstanceMethods.html +0 -334
  95. data/rdoc/site/0.1.19/Nucleon/Plugin.html +0 -282
  96. data/rdoc/site/0.1.19/Nucleon/Plugin/Action.html +0 -1368
  97. data/rdoc/site/0.1.19/Nucleon/Plugin/Action/Option.html +0 -459
  98. data/rdoc/site/0.1.19/Nucleon/Plugin/Base.html +0 -1737
  99. data/rdoc/site/0.1.19/Nucleon/Plugin/Command.html +0 -721
  100. data/rdoc/site/0.1.19/Nucleon/Plugin/Event.html +0 -442
  101. data/rdoc/site/0.1.19/Nucleon/Plugin/Extension.html +0 -281
  102. data/rdoc/site/0.1.19/Nucleon/Plugin/Project.html +0 -2864
  103. data/rdoc/site/0.1.19/Nucleon/Plugin/Template.html +0 -476
  104. data/rdoc/site/0.1.19/Nucleon/Plugin/Translator.html +0 -371
  105. data/rdoc/site/0.1.19/Nucleon/Project.html +0 -276
  106. data/rdoc/site/0.1.19/Nucleon/Project/Git.html +0 -1801
  107. data/rdoc/site/0.1.19/Nucleon/Project/Github.html +0 -549
  108. data/rdoc/site/0.1.19/Nucleon/Template.html +0 -277
  109. data/rdoc/site/0.1.19/Nucleon/Template/Json.html +0 -329
  110. data/rdoc/site/0.1.19/Nucleon/Template/Wrapper.html +0 -329
  111. data/rdoc/site/0.1.19/Nucleon/Template/Yaml.html +0 -329
  112. data/rdoc/site/0.1.19/Nucleon/Translator.html +0 -276
  113. data/rdoc/site/0.1.19/Nucleon/Translator/Json.html +0 -366
  114. data/rdoc/site/0.1.19/Nucleon/Translator/Yaml.html +0 -366
  115. data/rdoc/site/0.1.19/Nucleon/Util.html +0 -285
  116. data/rdoc/site/0.1.19/Nucleon/Util/CLI.html +0 -388
  117. data/rdoc/site/0.1.19/Nucleon/Util/CLI/Parser.html +0 -1183
  118. data/rdoc/site/0.1.19/Nucleon/Util/Cache.html +0 -780
  119. data/rdoc/site/0.1.19/Nucleon/Util/Console.html +0 -1294
  120. data/rdoc/site/0.1.19/Nucleon/Util/Data.html +0 -1399
  121. data/rdoc/site/0.1.19/Nucleon/Util/Disk.html +0 -522
  122. data/rdoc/site/0.1.19/Nucleon/Util/Git.html +0 -361
  123. data/rdoc/site/0.1.19/Nucleon/Util/Liquid.html +0 -365
  124. data/rdoc/site/0.1.19/Nucleon/Util/Logger.html +0 -806
  125. data/rdoc/site/0.1.19/Nucleon/Util/Package.html +0 -558
  126. data/rdoc/site/0.1.19/Nucleon/Util/SSH.html +0 -910
  127. data/rdoc/site/0.1.19/Nucleon/Util/SSH/Keypair.html +0 -453
  128. data/rdoc/site/0.1.19/Nucleon/Util/Shell.html +0 -686
  129. data/rdoc/site/0.1.19/Nucleon/Util/Shell/Result.html +0 -497
  130. data/rdoc/site/0.1.19/README_rdoc.html +0 -312
  131. data/rdoc/site/0.1.19/TODO_rdoc.html +0 -267
  132. data/rdoc/site/0.1.19/created.rid +0 -60
  133. data/rdoc/site/0.1.19/images/add.png +0 -0
  134. data/rdoc/site/0.1.19/images/brick.png +0 -0
  135. data/rdoc/site/0.1.19/images/brick_link.png +0 -0
  136. data/rdoc/site/0.1.19/images/bug.png +0 -0
  137. data/rdoc/site/0.1.19/images/bullet_black.png +0 -0
  138. data/rdoc/site/0.1.19/images/bullet_toggle_minus.png +0 -0
  139. data/rdoc/site/0.1.19/images/bullet_toggle_plus.png +0 -0
  140. data/rdoc/site/0.1.19/images/date.png +0 -0
  141. data/rdoc/site/0.1.19/images/delete.png +0 -0
  142. data/rdoc/site/0.1.19/images/find.png +0 -0
  143. data/rdoc/site/0.1.19/images/loadingAnimation.gif +0 -0
  144. data/rdoc/site/0.1.19/images/macFFBgHack.png +0 -0
  145. data/rdoc/site/0.1.19/images/package.png +0 -0
  146. data/rdoc/site/0.1.19/images/page_green.png +0 -0
  147. data/rdoc/site/0.1.19/images/page_white_text.png +0 -0
  148. data/rdoc/site/0.1.19/images/page_white_width.png +0 -0
  149. data/rdoc/site/0.1.19/images/plugin.png +0 -0
  150. data/rdoc/site/0.1.19/images/ruby.png +0 -0
  151. data/rdoc/site/0.1.19/images/tag_blue.png +0 -0
  152. data/rdoc/site/0.1.19/images/tag_green.png +0 -0
  153. data/rdoc/site/0.1.19/images/transparent.png +0 -0
  154. data/rdoc/site/0.1.19/images/wrench.png +0 -0
  155. data/rdoc/site/0.1.19/images/wrench_orange.png +0 -0
  156. data/rdoc/site/0.1.19/images/zoom.png +0 -0
  157. data/rdoc/site/0.1.19/index.html +0 -311
  158. data/rdoc/site/0.1.19/js/darkfish.js +0 -155
  159. data/rdoc/site/0.1.19/js/jquery.js +0 -18
  160. data/rdoc/site/0.1.19/js/navigation.js +0 -142
  161. data/rdoc/site/0.1.19/js/search.js +0 -94
  162. data/rdoc/site/0.1.19/js/search_index.js +0 -1
  163. data/rdoc/site/0.1.19/js/searcher.js +0 -228
  164. data/rdoc/site/0.1.19/rdoc.css +0 -543
  165. data/rdoc/site/0.1.19/table_of_contents.html +0 -1541
  166. data/rdoc/site/0.2.0/ARCHITECTURE_rdoc.html +0 -638
  167. data/rdoc/site/0.2.0/Hash.html +0 -351
  168. data/rdoc/site/0.2.0/Kernel.html +0 -416
  169. data/rdoc/site/0.2.0/Nucleon.html +0 -607
  170. data/rdoc/site/0.2.0/Nucleon/Action.html +0 -284
  171. data/rdoc/site/0.2.0/Nucleon/Action/Extract.html +0 -455
  172. data/rdoc/site/0.2.0/Nucleon/Action/Project.html +0 -283
  173. data/rdoc/site/0.2.0/Nucleon/Action/Project/Add.html +0 -500
  174. data/rdoc/site/0.2.0/Nucleon/Action/Project/Create.html +0 -457
  175. data/rdoc/site/0.2.0/Nucleon/Action/Project/Remove.html +0 -503
  176. data/rdoc/site/0.2.0/Nucleon/Action/Project/Save.html +0 -476
  177. data/rdoc/site/0.2.0/Nucleon/Action/Project/Update.html +0 -423
  178. data/rdoc/site/0.2.0/Nucleon/Codes.html +0 -567
  179. data/rdoc/site/0.2.0/Nucleon/Command.html +0 -279
  180. data/rdoc/site/0.2.0/Nucleon/Command/Bash.html +0 -548
  181. data/rdoc/site/0.2.0/Nucleon/Config.html +0 -1631
  182. data/rdoc/site/0.2.0/Nucleon/Config/Collection.html +0 -513
  183. data/rdoc/site/0.2.0/Nucleon/Config/Options.html +0 -493
  184. data/rdoc/site/0.2.0/Nucleon/Core.html +0 -639
  185. data/rdoc/site/0.2.0/Nucleon/Environment.html +0 -1208
  186. data/rdoc/site/0.2.0/Nucleon/Errors.html +0 -279
  187. data/rdoc/site/0.2.0/Nucleon/Errors/BatchError.html +0 -285
  188. data/rdoc/site/0.2.0/Nucleon/Errors/NucleonError.html +0 -661
  189. data/rdoc/site/0.2.0/Nucleon/Errors/SSHUnavailable.html +0 -285
  190. data/rdoc/site/0.2.0/Nucleon/Event.html +0 -279
  191. data/rdoc/site/0.2.0/Nucleon/Event/Regex.html +0 -471
  192. data/rdoc/site/0.2.0/Nucleon/Facade.html +0 -2409
  193. data/rdoc/site/0.2.0/Nucleon/Gems.html +0 -639
  194. data/rdoc/site/0.2.0/Nucleon/Manager.html +0 -1860
  195. data/rdoc/site/0.2.0/Nucleon/Mixin.html +0 -288
  196. data/rdoc/site/0.2.0/Nucleon/Mixin/Action.html +0 -281
  197. data/rdoc/site/0.2.0/Nucleon/Mixin/Action/Commit.html +0 -385
  198. data/rdoc/site/0.2.0/Nucleon/Mixin/Action/Project.html +0 -399
  199. data/rdoc/site/0.2.0/Nucleon/Mixin/Action/Push.html +0 -375
  200. data/rdoc/site/0.2.0/Nucleon/Mixin/Colors.html +0 -549
  201. data/rdoc/site/0.2.0/Nucleon/Mixin/ConfigCollection.html +0 -485
  202. data/rdoc/site/0.2.0/Nucleon/Mixin/ConfigOptions.html +0 -453
  203. data/rdoc/site/0.2.0/Nucleon/Mixin/Macro.html +0 -280
  204. data/rdoc/site/0.2.0/Nucleon/Mixin/Macro/ObjectInterface.html +0 -699
  205. data/rdoc/site/0.2.0/Nucleon/Mixin/Macro/PluginInterface.html +0 -686
  206. data/rdoc/site/0.2.0/Nucleon/Mixin/Settings.html +0 -485
  207. data/rdoc/site/0.2.0/Nucleon/Mixin/SubConfig.html +0 -891
  208. data/rdoc/site/0.2.0/Nucleon/Parallel.html +0 -330
  209. data/rdoc/site/0.2.0/Nucleon/Parallel/ClassMethods.html +0 -329
  210. data/rdoc/site/0.2.0/Nucleon/Parallel/InstanceMethods.html +0 -456
  211. data/rdoc/site/0.2.0/Nucleon/Plugin.html +0 -286
  212. data/rdoc/site/0.2.0/Nucleon/Plugin/Action.html +0 -1829
  213. data/rdoc/site/0.2.0/Nucleon/Plugin/Action/Option.html +0 -463
  214. data/rdoc/site/0.2.0/Nucleon/Plugin/Base.html +0 -1803
  215. data/rdoc/site/0.2.0/Nucleon/Plugin/Command.html +0 -725
  216. data/rdoc/site/0.2.0/Nucleon/Plugin/Event.html +0 -446
  217. data/rdoc/site/0.2.0/Nucleon/Plugin/Extension.html +0 -285
  218. data/rdoc/site/0.2.0/Nucleon/Plugin/Project.html +0 -2898
  219. data/rdoc/site/0.2.0/Nucleon/Plugin/Template.html +0 -480
  220. data/rdoc/site/0.2.0/Nucleon/Plugin/Translator.html +0 -375
  221. data/rdoc/site/0.2.0/Nucleon/Project.html +0 -280
  222. data/rdoc/site/0.2.0/Nucleon/Project/Git.html +0 -1805
  223. data/rdoc/site/0.2.0/Nucleon/Project/Github.html +0 -553
  224. data/rdoc/site/0.2.0/Nucleon/Template.html +0 -281
  225. data/rdoc/site/0.2.0/Nucleon/Template/JSON.html +0 -333
  226. data/rdoc/site/0.2.0/Nucleon/Template/Wrapper.html +0 -333
  227. data/rdoc/site/0.2.0/Nucleon/Template/YAML.html +0 -333
  228. data/rdoc/site/0.2.0/Nucleon/Translator.html +0 -280
  229. data/rdoc/site/0.2.0/Nucleon/Translator/JSON.html +0 -370
  230. data/rdoc/site/0.2.0/Nucleon/Translator/YAML.html +0 -370
  231. data/rdoc/site/0.2.0/Nucleon/Util.html +0 -289
  232. data/rdoc/site/0.2.0/Nucleon/Util/CLI.html +0 -392
  233. data/rdoc/site/0.2.0/Nucleon/Util/CLI/Parser.html +0 -1250
  234. data/rdoc/site/0.2.0/Nucleon/Util/Cache.html +0 -784
  235. data/rdoc/site/0.2.0/Nucleon/Util/Console.html +0 -1318
  236. data/rdoc/site/0.2.0/Nucleon/Util/Data.html +0 -1411
  237. data/rdoc/site/0.2.0/Nucleon/Util/Disk.html +0 -526
  238. data/rdoc/site/0.2.0/Nucleon/Util/Git.html +0 -365
  239. data/rdoc/site/0.2.0/Nucleon/Util/Liquid.html +0 -369
  240. data/rdoc/site/0.2.0/Nucleon/Util/Logger.html +0 -810
  241. data/rdoc/site/0.2.0/Nucleon/Util/Package.html +0 -562
  242. data/rdoc/site/0.2.0/Nucleon/Util/SSH.html +0 -1033
  243. data/rdoc/site/0.2.0/Nucleon/Util/SSH/Keypair.html +0 -605
  244. data/rdoc/site/0.2.0/Nucleon/Util/Shell.html +0 -693
  245. data/rdoc/site/0.2.0/Nucleon/Util/Shell/Result.html +0 -501
  246. data/rdoc/site/0.2.0/README_rdoc.html +0 -316
  247. data/rdoc/site/0.2.0/TODO_rdoc.html +0 -265
  248. data/rdoc/site/0.2.0/created.rid +0 -61
  249. data/rdoc/site/0.2.0/images/add.png +0 -0
  250. data/rdoc/site/0.2.0/images/brick.png +0 -0
  251. data/rdoc/site/0.2.0/images/brick_link.png +0 -0
  252. data/rdoc/site/0.2.0/images/bug.png +0 -0
  253. data/rdoc/site/0.2.0/images/bullet_black.png +0 -0
  254. data/rdoc/site/0.2.0/images/bullet_toggle_minus.png +0 -0
  255. data/rdoc/site/0.2.0/images/bullet_toggle_plus.png +0 -0
  256. data/rdoc/site/0.2.0/images/date.png +0 -0
  257. data/rdoc/site/0.2.0/images/delete.png +0 -0
  258. data/rdoc/site/0.2.0/images/find.png +0 -0
  259. data/rdoc/site/0.2.0/images/loadingAnimation.gif +0 -0
  260. data/rdoc/site/0.2.0/images/macFFBgHack.png +0 -0
  261. data/rdoc/site/0.2.0/images/package.png +0 -0
  262. data/rdoc/site/0.2.0/images/page_green.png +0 -0
  263. data/rdoc/site/0.2.0/images/page_white_text.png +0 -0
  264. data/rdoc/site/0.2.0/images/page_white_width.png +0 -0
  265. data/rdoc/site/0.2.0/images/plugin.png +0 -0
  266. data/rdoc/site/0.2.0/images/ruby.png +0 -0
  267. data/rdoc/site/0.2.0/images/tag_blue.png +0 -0
  268. data/rdoc/site/0.2.0/images/tag_green.png +0 -0
  269. data/rdoc/site/0.2.0/images/transparent.png +0 -0
  270. data/rdoc/site/0.2.0/images/wrench.png +0 -0
  271. data/rdoc/site/0.2.0/images/wrench_orange.png +0 -0
  272. data/rdoc/site/0.2.0/images/zoom.png +0 -0
  273. data/rdoc/site/0.2.0/index.html +0 -315
  274. data/rdoc/site/0.2.0/js/darkfish.js +0 -155
  275. data/rdoc/site/0.2.0/js/jquery.js +0 -18
  276. data/rdoc/site/0.2.0/js/navigation.js +0 -142
  277. data/rdoc/site/0.2.0/js/search.js +0 -94
  278. data/rdoc/site/0.2.0/js/search_index.js +0 -1
  279. data/rdoc/site/0.2.0/js/searcher.js +0 -228
  280. data/rdoc/site/0.2.0/rdoc.css +0 -543
  281. data/rdoc/site/0.2.0/table_of_contents.html +0 -1657
  282. data/rdoc/site/0.2.1/ARCHITECTURE_rdoc.html +0 -640
  283. data/rdoc/site/0.2.1/Hash.html +0 -353
  284. data/rdoc/site/0.2.1/Kernel.html +0 -420
  285. data/rdoc/site/0.2.1/Nucleon.html +0 -674
  286. data/rdoc/site/0.2.1/Nucleon/Action.html +0 -286
  287. data/rdoc/site/0.2.1/Nucleon/Action/Extract.html +0 -457
  288. data/rdoc/site/0.2.1/Nucleon/Action/Project.html +0 -285
  289. data/rdoc/site/0.2.1/Nucleon/Action/Project/Add.html +0 -502
  290. data/rdoc/site/0.2.1/Nucleon/Action/Project/Create.html +0 -459
  291. data/rdoc/site/0.2.1/Nucleon/Action/Project/Remove.html +0 -505
  292. data/rdoc/site/0.2.1/Nucleon/Action/Project/Save.html +0 -478
  293. data/rdoc/site/0.2.1/Nucleon/Action/Project/Update.html +0 -425
  294. data/rdoc/site/0.2.1/Nucleon/Codes.html +0 -569
  295. data/rdoc/site/0.2.1/Nucleon/Command.html +0 -281
  296. data/rdoc/site/0.2.1/Nucleon/Command/Bash.html +0 -550
  297. data/rdoc/site/0.2.1/Nucleon/Config.html +0 -1634
  298. data/rdoc/site/0.2.1/Nucleon/Config/Collection.html +0 -515
  299. data/rdoc/site/0.2.1/Nucleon/Config/Options.html +0 -495
  300. data/rdoc/site/0.2.1/Nucleon/Core.html +0 -641
  301. data/rdoc/site/0.2.1/Nucleon/Environment.html +0 -1210
  302. data/rdoc/site/0.2.1/Nucleon/Errors.html +0 -281
  303. data/rdoc/site/0.2.1/Nucleon/Errors/BatchError.html +0 -287
  304. data/rdoc/site/0.2.1/Nucleon/Errors/NucleonError.html +0 -663
  305. data/rdoc/site/0.2.1/Nucleon/Errors/SSHUnavailable.html +0 -287
  306. data/rdoc/site/0.2.1/Nucleon/Event.html +0 -281
  307. data/rdoc/site/0.2.1/Nucleon/Event/Regex.html +0 -473
  308. data/rdoc/site/0.2.1/Nucleon/Facade.html +0 -2452
  309. data/rdoc/site/0.2.1/Nucleon/Gems.html +0 -641
  310. data/rdoc/site/0.2.1/Nucleon/Manager.html +0 -1862
  311. data/rdoc/site/0.2.1/Nucleon/Mixin.html +0 -291
  312. data/rdoc/site/0.2.1/Nucleon/Mixin/Action.html +0 -284
  313. data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Commit.html +0 -387
  314. data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Project.html +0 -401
  315. data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Push.html +0 -377
  316. data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Registration.html +0 -575
  317. data/rdoc/site/0.2.1/Nucleon/Mixin/Colors.html +0 -551
  318. data/rdoc/site/0.2.1/Nucleon/Mixin/ConfigCollection.html +0 -487
  319. data/rdoc/site/0.2.1/Nucleon/Mixin/ConfigOptions.html +0 -455
  320. data/rdoc/site/0.2.1/Nucleon/Mixin/Macro.html +0 -282
  321. data/rdoc/site/0.2.1/Nucleon/Mixin/Macro/ObjectInterface.html +0 -701
  322. data/rdoc/site/0.2.1/Nucleon/Mixin/Macro/PluginInterface.html +0 -688
  323. data/rdoc/site/0.2.1/Nucleon/Mixin/Settings.html +0 -487
  324. data/rdoc/site/0.2.1/Nucleon/Mixin/SubConfig.html +0 -893
  325. data/rdoc/site/0.2.1/Nucleon/Parallel.html +0 -332
  326. data/rdoc/site/0.2.1/Nucleon/Parallel/ClassMethods.html +0 -331
  327. data/rdoc/site/0.2.1/Nucleon/Parallel/InstanceMethods.html +0 -458
  328. data/rdoc/site/0.2.1/Nucleon/Plugin.html +0 -288
  329. data/rdoc/site/0.2.1/Nucleon/Plugin/Action.html +0 -2133
  330. data/rdoc/site/0.2.1/Nucleon/Plugin/Action/Option.html +0 -465
  331. data/rdoc/site/0.2.1/Nucleon/Plugin/Base.html +0 -1988
  332. data/rdoc/site/0.2.1/Nucleon/Plugin/Command.html +0 -765
  333. data/rdoc/site/0.2.1/Nucleon/Plugin/Event.html +0 -448
  334. data/rdoc/site/0.2.1/Nucleon/Plugin/Extension.html +0 -287
  335. data/rdoc/site/0.2.1/Nucleon/Plugin/Project.html +0 -2900
  336. data/rdoc/site/0.2.1/Nucleon/Plugin/Template.html +0 -482
  337. data/rdoc/site/0.2.1/Nucleon/Plugin/Translator.html +0 -377
  338. data/rdoc/site/0.2.1/Nucleon/Project.html +0 -282
  339. data/rdoc/site/0.2.1/Nucleon/Project/Git.html +0 -1807
  340. data/rdoc/site/0.2.1/Nucleon/Project/Github.html +0 -555
  341. data/rdoc/site/0.2.1/Nucleon/Template.html +0 -283
  342. data/rdoc/site/0.2.1/Nucleon/Template/JSON.html +0 -335
  343. data/rdoc/site/0.2.1/Nucleon/Template/Wrapper.html +0 -335
  344. data/rdoc/site/0.2.1/Nucleon/Template/YAML.html +0 -335
  345. data/rdoc/site/0.2.1/Nucleon/Translator.html +0 -282
  346. data/rdoc/site/0.2.1/Nucleon/Translator/JSON.html +0 -372
  347. data/rdoc/site/0.2.1/Nucleon/Translator/YAML.html +0 -372
  348. data/rdoc/site/0.2.1/Nucleon/Util.html +0 -291
  349. data/rdoc/site/0.2.1/Nucleon/Util/CLI.html +0 -394
  350. data/rdoc/site/0.2.1/Nucleon/Util/CLI/Parser.html +0 -1404
  351. data/rdoc/site/0.2.1/Nucleon/Util/Cache.html +0 -824
  352. data/rdoc/site/0.2.1/Nucleon/Util/Console.html +0 -1330
  353. data/rdoc/site/0.2.1/Nucleon/Util/Data.html +0 -1423
  354. data/rdoc/site/0.2.1/Nucleon/Util/Disk.html +0 -528
  355. data/rdoc/site/0.2.1/Nucleon/Util/Git.html +0 -367
  356. data/rdoc/site/0.2.1/Nucleon/Util/Liquid.html +0 -371
  357. data/rdoc/site/0.2.1/Nucleon/Util/Logger.html +0 -822
  358. data/rdoc/site/0.2.1/Nucleon/Util/Package.html +0 -564
  359. data/rdoc/site/0.2.1/Nucleon/Util/SSH.html +0 -1036
  360. data/rdoc/site/0.2.1/Nucleon/Util/SSH/Keypair.html +0 -607
  361. data/rdoc/site/0.2.1/Nucleon/Util/Shell.html +0 -697
  362. data/rdoc/site/0.2.1/Nucleon/Util/Shell/Result.html +0 -503
  363. data/rdoc/site/0.2.1/README_rdoc.html +0 -318
  364. data/rdoc/site/0.2.1/TODO_rdoc.html +0 -267
  365. data/rdoc/site/0.2.1/created.rid +0 -62
  366. data/rdoc/site/0.2.1/images/add.png +0 -0
  367. data/rdoc/site/0.2.1/images/brick.png +0 -0
  368. data/rdoc/site/0.2.1/images/brick_link.png +0 -0
  369. data/rdoc/site/0.2.1/images/bug.png +0 -0
  370. data/rdoc/site/0.2.1/images/bullet_black.png +0 -0
  371. data/rdoc/site/0.2.1/images/bullet_toggle_minus.png +0 -0
  372. data/rdoc/site/0.2.1/images/bullet_toggle_plus.png +0 -0
  373. data/rdoc/site/0.2.1/images/date.png +0 -0
  374. data/rdoc/site/0.2.1/images/delete.png +0 -0
  375. data/rdoc/site/0.2.1/images/find.png +0 -0
  376. data/rdoc/site/0.2.1/images/loadingAnimation.gif +0 -0
  377. data/rdoc/site/0.2.1/images/macFFBgHack.png +0 -0
  378. data/rdoc/site/0.2.1/images/package.png +0 -0
  379. data/rdoc/site/0.2.1/images/page_green.png +0 -0
  380. data/rdoc/site/0.2.1/images/page_white_text.png +0 -0
  381. data/rdoc/site/0.2.1/images/page_white_width.png +0 -0
  382. data/rdoc/site/0.2.1/images/plugin.png +0 -0
  383. data/rdoc/site/0.2.1/images/ruby.png +0 -0
  384. data/rdoc/site/0.2.1/images/tag_blue.png +0 -0
  385. data/rdoc/site/0.2.1/images/tag_green.png +0 -0
  386. data/rdoc/site/0.2.1/images/transparent.png +0 -0
  387. data/rdoc/site/0.2.1/images/wrench.png +0 -0
  388. data/rdoc/site/0.2.1/images/wrench_orange.png +0 -0
  389. data/rdoc/site/0.2.1/images/zoom.png +0 -0
  390. data/rdoc/site/0.2.1/index.html +0 -317
  391. data/rdoc/site/0.2.1/js/darkfish.js +0 -155
  392. data/rdoc/site/0.2.1/js/jquery.js +0 -18
  393. data/rdoc/site/0.2.1/js/navigation.js +0 -142
  394. data/rdoc/site/0.2.1/js/search.js +0 -94
  395. data/rdoc/site/0.2.1/js/search_index.js +0 -1
  396. data/rdoc/site/0.2.1/js/searcher.js +0 -228
  397. data/rdoc/site/0.2.1/rdoc.css +0 -543
  398. data/rdoc/site/0.2.1/table_of_contents.html +0 -1718
  399. data/spec/coral_mock_input.rb +0 -29
  400. data/spec/coral_test_kernel.rb +0 -22
@@ -1,19 +1,53 @@
1
-
2
1
  module Nucleon
3
2
  module Util
3
+ #
4
+ # == Console
5
+ #
6
+ # The Nucleon::Util::Console class defines a console interface that the Nucleon
7
+ # framework uses to collect and display information to stdin, stdout, and stderr.
8
+ #
9
+ # This console interface is inspired by Vagrant's UI system but has some
10
+ # important differences.
11
+ #
12
+ # === Important rule
13
+ #
14
+ # We split all outbound message traffic between stdout and stderr by routing all
15
+ # data dumps to stderr and all other text based messages to stdout (even errors).
16
+ #
17
+ # TODO: This system will break if other libraries write to stderr. Eventually
18
+ # build multiple messaging systems on top of basic connection.
19
+ #
20
+ # TODO: Figure out some way to switch to a color profile method instead of current
21
+ # color methods.
22
+ #
23
+ # Remember:
24
+ # * *stderr* Serialized data objects ONLY
25
+ # * *stdout* ALL text messages (debug, info, warnings, and errors)
26
+ #
27
+ # If you are using this class, you don't have to think about this but it still
28
+ # helps to remember.
29
+ #
30
+ # Primary functions:
31
+ #
32
+ # 1. Render and transmit messages to various output channels
33
+ # 2. Dump data to isolated output channels
34
+ # 3. Collect public and private (hidden) information from input channels
35
+ # 4. Provide a color format library for composing potentially nested colored strings
36
+ #
37
+ # See also:
38
+ # - Nucleon::Core (base UI capable object)
39
+ #
4
40
  class Console
5
-
41
+
42
+ #
6
43
  # Flush output immediately.
44
+ #
7
45
  $stderr.sync = true
8
46
  $stdout.sync = true
9
-
10
- #---
11
-
12
- @@quiet = false
13
- @@use_colors = true
14
-
15
- #---
16
47
 
48
+ #
49
+ # Color formatter map
50
+ #
17
51
  @@colors = {
18
52
  :clear => "\e[0m",
19
53
  :black => "\e[30m",
@@ -26,126 +60,324 @@ class Console
26
60
  :grey => "\e[37m"
27
61
  }
28
62
 
63
+ #
64
+ # Colored message map
65
+ #
29
66
  @@color_map = {
30
67
  :warn => :yellow,
31
68
  :error => :red,
32
69
  :success => :green
33
70
  }
34
71
 
35
- #-----------------------------------------------------------------------------
72
+ #*****************************************************************************
36
73
  # Constructor
37
-
74
+
75
+ # Initialize a new console object
76
+ #
77
+ # TODO: Figure out some way to make the console system pluggable?
78
+ #
79
+ # * *Parameters*
80
+ # - [Hash] *options* Console options
81
+ # - [String] *:resource* Logger resource identifier (also serves as prefix)
82
+ # - [Boolean] *:color* Whether or not to render messages in color (overridden by global quiet)
83
+ # - [Symbol] *:printer* Printer method (default :puts)
84
+ # - [IO] *:input* Don't touch
85
+ # - [IO] *:output* Don't touch
86
+ # - [IO] *:error* Don't touch
87
+ # - [ANY] *:console_delegate* Delegate object that handles console operations (must implement logging interface)
88
+ #
89
+ # * *Returns*
90
+ # - [Void] This method does not return a value
91
+ #
92
+ # * *Errors*
93
+ #
94
+ # See also:
95
+ # - Nucleon::Config::ensure
96
+ #
38
97
  def initialize(options = {})
39
98
  if options.is_a?(String)
40
99
  options = { :resource => options }
41
100
  end
42
101
  config = Config.ensure(options)
43
-
102
+
44
103
  @resource = config.get(:resource, '')
45
-
46
- @color = config.get(:color, true)
104
+
105
+ @color = config.get(:color, true)
47
106
  @printer = config.get(:printer, :puts)
48
-
107
+
49
108
  @input = config.get(:input, $stdin)
50
109
  @output = config.get(:output, $stdout)
51
110
  @error = config.get(:error, $stderr)
52
-
111
+
53
112
  @delegate = config.get(:console_delegate, nil)
54
113
  end
55
114
 
56
- #---
57
-
115
+ # Return a string reference that identifies this console object
116
+ #
117
+ # * *Parameters*
118
+ #
119
+ # * *Returns*
120
+ # - [String] Identification string
121
+ #
122
+ # * *Errors*
123
+ #
58
124
  def inspect
59
125
  "#<#{self.class}: #{@resource}>"
60
126
  end
61
-
62
- #-----------------------------------------------------------------------------
127
+
128
+ #*****************************************************************************
63
129
  # Accessors / Modifiers
64
-
65
- attr_accessor :resource, :color, :input, :output, :error, :delegate
66
-
67
- #---
68
-
130
+
131
+ #
132
+ # [String] Console resource name
133
+ #
134
+ # This is the string identifier and default console prefix used when rendering.
135
+ #
136
+ attr_accessor :resource
137
+ #
138
+ # [Boolean] Whether or not to use color markers when rendering text
139
+ #
140
+ # This can be overridden by the global quiet setting ::quiet, ::quiet=
141
+ #
142
+ attr_accessor :color
143
+ #
144
+ # [IO] Input IO object
145
+ #
146
+ # Don't touch unless you know what you are doing.
147
+ #
148
+ attr_accessor :input
149
+ #
150
+ # [IO] Output IO object (messages)
151
+ #
152
+ # Don't touch unless you know what you are doing.
153
+ #
154
+ attr_accessor :output
155
+ #
156
+ # [IO] Error IO object (data)
157
+ #
158
+ # Don't touch unless you know what you are doing.
159
+ #
160
+ attr_accessor :error
161
+ #
162
+ # [ANY] Any class that implements this console interface
163
+ #
164
+ attr_accessor :delegate
165
+
166
+ #
167
+ # Global quiet flag to disable all output
168
+ #
169
+ @@quiet = false
170
+
171
+ # Check current global quiet flag
172
+ #
173
+ # * *Parameters*
174
+ #
175
+ # * *Returns*
176
+ # - [Boolean] Whether or not console output is disabled at the global level
177
+ #
178
+ # * *Errors*
179
+ #
180
+ # See also:
181
+ # - ::quiet=
182
+ #
69
183
  def self.quiet
70
184
  @@quiet
71
185
  end
72
-
186
+
187
+ # Set current global quiet flag
188
+ #
189
+ # * *Parameters*
190
+ # - [Boolean] *quiet* Whether or not console output is disabled at the global level
191
+ #
192
+ # * *Returns*
193
+ # - [Void] This method does not return a value
194
+ #
195
+ # * *Errors*
196
+ #
197
+ # See also:
198
+ # - ::quiet
199
+ #
73
200
  def self.quiet=quiet
74
201
  @@quiet = quiet
75
202
  end
76
-
77
- #---
78
-
203
+ #
204
+ # Global flag to render console output in color (using color formatting)
205
+ #
206
+ @@use_colors = true
207
+
208
+ # Check current global use colors flag
209
+ #
210
+ # * *Parameters*
211
+ #
212
+ # * *Returns*
213
+ # - [Boolean] Whether or not console output coloring is allowed at the global level
214
+ #
215
+ # * *Errors*
216
+ #
217
+ # See also:
218
+ # - ::use_colors=
219
+ #
79
220
  def self.use_colors
80
- @@use_colors && ! ENV['NUCLEON_NO_COLOR']
221
+ @@use_colors && ! ENV['NUCLEON_NO_COLOR']
81
222
  end
82
-
223
+
224
+ # Set current global use colors flag
225
+ #
226
+ # * *Parameters*
227
+ # - [Boolean] *use_colors* Whether or not console output coloring is allowed at the global level
228
+ #
229
+ # * *Returns*
230
+ # - [Void] This method does not return a value
231
+ #
232
+ # * *Errors*
233
+ #
234
+ # See also:
235
+ # - ::use_colors
236
+ #
83
237
  def self.use_colors=use_colors
84
238
  @@use_colors = use_colors
85
239
  end
86
-
87
- #-----------------------------------------------------------------------------
240
+
241
+ #*****************************************************************************
88
242
  # UI functionality
89
243
 
244
+ # Output via a printer method to an output channel unless quiet specified
245
+ #
246
+ # * *Parameters*
247
+ # - [Symbol] *type* Message type; *:warn*, *:error*, *:success*
248
+ # - [String] *message* Message to render to output channel
249
+ # - [Hash] *options* Output options
250
+ # - [Boolean] *:quiet_override* Whether or not to override global quiet flag
251
+ # - [Boolean] *:new_line* Append new line to end of message
252
+ # - [Boolean] *:prefix* Render prefix before message (console resource)
253
+ # - [Symbol] *:channel* IO channel to send output to (don't touch)
254
+ # - #format_message options
255
+ #
256
+ # * *Returns*
257
+ # - [Void] This method does not return a value
258
+ #
259
+ # * *Errors*
260
+ #
261
+ # See also:
262
+ # - #check_delegate
263
+ # - #format_message
264
+ # - #safe_puts
265
+ #
90
266
  def say(type, message, options = {})
91
267
  return if @@quiet && ! options[:quiet_override]
92
268
  return @delegate.say(type, message, options) if check_delegate('say')
93
-
269
+
94
270
  defaults = { :new_line => true, :prefix => true }
95
271
  options = defaults.merge(options)
96
272
  printer = options[:new_line] ? :puts : :print
97
-
273
+
98
274
  puts_options = { :printer => printer }
99
275
  puts_options[:channel] = options[:channel] if options.has_key?(:channel)
100
-
276
+
101
277
  safe_puts(format_message(type, message, options), puts_options)
102
278
  end
103
-
104
- #---
105
-
279
+
280
+ # Dump an object to an output channel even if quiet specified
281
+ #
282
+ # Data dumps can not be silenced.
283
+ #
284
+ # * *Parameters*
285
+ # - [String] *data* Serialized data object or text string
286
+ # - [Hash] *options* Dump options
287
+ # - [Symbol] *:channel* IO channel to send output to (don't touch)
288
+ # - #safe_puts options
289
+ #
290
+ # * *Returns*
291
+ # - [Void] This method does not return a value
292
+ #
293
+ # * *Errors*
294
+ #
295
+ # See also:
296
+ # - #check_delegate
297
+ # - #safe_puts
298
+ #
106
299
  def dump(data, options = {})
107
300
  return @delegate.dump(data, options) if check_delegate('dump')
108
-
301
+
109
302
  options[:channel] = options.has_key?(:channel) ? options[:channel] : @error
110
- safe_puts(data.to_s, options)
303
+ safe_puts(data.to_s, options)
111
304
  end
112
-
113
- #---
114
305
 
306
+ # Ask terminal user for an input value
307
+ #
308
+ # Input text can be freely displayed or hidden as typed.
309
+ #
310
+ # * *Parameters*
311
+ # - [String] *message* Message to display to the user
312
+ # - [Hash] *options* Input options
313
+ # - [Boolean] *:new_line* Append new line to end of message
314
+ # - [Boolean] *:prefix* Render prefix before message (console resource)
315
+ # - [Boolean] *:echo* Whether or not to echo the input back to the screen
316
+ # - #say options (minus :quiet_override)
317
+ #
318
+ # * *Returns*
319
+ # - [Void] This method does not return a value
320
+ #
321
+ # * *Errors*
322
+ #
323
+ # See also:
324
+ # - #check_delegate
325
+ # - #say
326
+ # - Nucleon::Config::ensure
327
+ # - Nucleon::Config#import
328
+ # - Nucleon::Config#export
329
+ #
115
330
  def ask(message, options = {})
116
331
  return @delegate.ask(message, options) if check_delegate('ask')
117
332
 
118
333
  options[:new_line] = false if ! options.has_key?(:new_line)
119
334
  options[:prefix] = false if ! options.has_key?(:prefix)
120
335
  options[:echo] = true if ! options.has_key?(:echo)
121
-
336
+
122
337
  user_input = nil
123
-
338
+
124
339
  say(:info, message, Config.ensure(options).import({ :quiet_override => true }).export)
125
-
340
+
126
341
  if options[:echo]
127
342
  user_input = @input.gets.chomp
128
343
  else
129
- require 'io/console'
344
+ require 'io/console'
130
345
  user_input = @input.noecho(&:gets).chomp
131
346
  end
132
347
  safe_puts("\n")
133
348
  user_input
134
349
  end
135
-
136
- #---
137
-
350
+
351
+ # Ask terminal user for a password
352
+ #
353
+ # Keeps requesting until two password inputs match or user cancels the input.
354
+ #
355
+ # TODO: Needs I18n treatment.
356
+ #
357
+ # * *Parameters*
358
+ # - [String, Symbol] *type* Type of password being requested (in prompt)
359
+ # - [Hash] *options* Input options
360
+ #
361
+ # * *Returns*
362
+ # - [String] Returns password with whitespace stripped
363
+ #
364
+ # * *Errors*
365
+ #
366
+ # See also:
367
+ # - #check_delegate
368
+ # - #ask
369
+ #
138
370
  def password(type, options = {})
139
371
  return @delegate.password(type, options) if check_delegate('password')
140
-
372
+
141
373
  try_again = true
142
374
  password = nil
143
-
375
+
144
376
  while try_again
145
377
  # Get and check a password from the keyboard
146
378
  password = ask("Enter #{type} password: ", { :echo => false })
147
379
  confirmation_password = ask("Confirm #{type} password: ", { :echo => false })
148
-
380
+
149
381
  if password != confirmation_password
150
382
  choice = ask('Passwords do not match! Try again? (Y|N): ')
151
383
  try_again = choice.upcase == "Y"
@@ -156,67 +388,151 @@ class Console
156
388
  end
157
389
  password.strip
158
390
  end
159
-
160
- #-----------------------------------------------------------------------------
161
-
391
+
392
+ #*****************************************************************************
393
+
394
+ # Output information to an output channel unless quiet specified
395
+ #
396
+ # * *Parameters*
397
+ # - [String] *message* Message to render to output channel
398
+ # - [Hash] *options* Output options
399
+ # - #say options
400
+ #
401
+ # * *Returns*
402
+ # - [Void] This method does not return a value
403
+ #
404
+ # * *Errors*
405
+ #
406
+ # See also:
407
+ # - #check_delegate
408
+ # - #say
409
+ #
162
410
  def info(message, *args)
163
411
  return @delegate.info(message, *args) if check_delegate('info')
164
412
  say(:info, message, *args)
165
413
  end
166
-
167
- #---
168
-
414
+
415
+ # Output warning to an output channel unless quiet specified
416
+ #
417
+ # * *Parameters*
418
+ # - [String] *message* Message to render to output channel
419
+ # - [Hash] *options* Output options
420
+ # - #say options
421
+ #
422
+ # * *Returns*
423
+ # - [Void] This method does not return a value
424
+ #
425
+ # * *Errors*
426
+ #
427
+ # See also:
428
+ # - #check_delegate
429
+ # - #say
430
+ #
169
431
  def warn(message, *args)
170
432
  return @delegate.warn(message, *args) if check_delegate('warn')
171
433
  say(:warn, message, *args)
172
434
  end
173
-
174
- #---
175
-
435
+
436
+ # Output error to an output channel unless quiet specified
437
+ #
438
+ # * *Parameters*
439
+ # - [String] *message* Message to render to output channel
440
+ # - [Hash] *options* Output options
441
+ # - #say options
442
+ #
443
+ # * *Returns*
444
+ # - [Void] This method does not return a value
445
+ #
446
+ # * *Errors*
447
+ #
448
+ # See also:
449
+ # - #check_delegate
450
+ # - #say
451
+ #
176
452
  def error(message, *args)
177
453
  return @delegate.error(message, *args) if check_delegate('error')
178
454
  say(:error, message, *args)
179
455
  end
180
-
181
- #---
182
-
456
+
457
+ # Output success message to an output channel unless quiet specified
458
+ #
459
+ # * *Parameters*
460
+ # - [String] *message* Message to render to output channel
461
+ # - [Hash] *options* Output options
462
+ # - #say options
463
+ #
464
+ # * *Returns*
465
+ # - [Void] This method does not return a value
466
+ #
467
+ # * *Errors*
468
+ #
469
+ # See also:
470
+ # - #check_delegate
471
+ # - #say
472
+ #
183
473
  def success(message, *args)
184
474
  return @delegate.success(message, *args) if check_delegate('success')
185
475
  say(:success, message, *args)
186
476
  end
187
-
188
- #-----------------------------------------------------------------------------
477
+
478
+ #*****************************************************************************
189
479
  # Utilities
190
480
 
481
+ # Format a message for display.
482
+ #
483
+ # Primary functions:
484
+ #
485
+ # 1. Add prefix to each line if requested (:prefix)
486
+ # 2. Add colors to each line if requested (global and instance color enabled)
487
+ #
488
+ # * *Parameters*
489
+ # - [Symbol] *type* Message type; *:warn*, *:error*, *:success*
490
+ # - [String] *message* Message to render
491
+ # - [Hash] *options* Format options
492
+ # - [Boolean] *:color* Color to use; *:black*, *:red*, *:green*, *:yellow*, *:blue*, *:purple*, *:cyan*, *:grey*
493
+ # - [Boolean] *:prefix* Render prefix before message
494
+ # - [String] *:prefix_text* Text to render within brackets [{prefix_text}] (default console resource)
495
+ #
496
+ # * *Returns*
497
+ # - [String] Formatted string ready for output
498
+ #
499
+ # * *Errors*
500
+ #
501
+ # See also:
502
+ # - ::use_colors
503
+ # - ::colorize
504
+ # - #check_delegate
505
+ # - #say
506
+ #
191
507
  def format_message(type, message, options = {})
192
- return @delegate.format_message(type, message, options) if check_delegate('format_message')
508
+ return @delegate.format_message(type, message, options) if check_delegate('format_message')
193
509
  return '' if message.to_s.strip.empty?
194
-
510
+
195
511
  if options[:prefix]
196
512
  if prefix_text = options[:prefix_text]
197
513
  prefix = "[#{prefix_text}]"
198
-
514
+
199
515
  elsif @resource && ! @resource.empty?
200
516
  prefix = "[#{@resource}]"
201
517
  end
202
518
  end
203
-
519
+
204
520
  lines = []
205
521
  prev_color = nil
206
522
  escaped_clear = Regexp.escape(@@colors[:clear])
207
-
523
+
208
524
  message.split("\n").each do |line|
209
525
  line = prev_color + line if self.class.use_colors && @color && prev_color
210
-
526
+
211
527
  lines << "#{prefix} #{line}".sub(/^ /, '')
212
-
528
+
213
529
  if self.class.use_colors && @color
214
530
  # Set next previous color
215
531
  if line =~ /#{escaped_clear}$/
216
- prev_color = nil
532
+ prev_color = nil
217
533
  else
218
534
  line_section = line.split(/#{escaped_clear}/).pop
219
-
535
+
220
536
  if line_section
221
537
  prev_colors = line_section.scan(/\e\[[0-9][0-9]?m/)
222
538
  prev_color = prev_colors.pop unless prev_colors.empty?
@@ -224,12 +540,12 @@ class Console
224
540
  end
225
541
  end
226
542
  end
227
-
543
+
228
544
  message = lines.join("\n")
229
-
545
+
230
546
  if self.class.use_colors && @color
231
547
  if options.has_key?(:color)
232
- message = self.class.colorize(message, options[:color])
548
+ message = self.class.colorize(message, options[:color])
233
549
  else
234
550
  message = self.class.colorize(message, @@color_map[type]) if @@color_map[type]
235
551
  end
@@ -237,11 +553,26 @@ class Console
237
553
  return message
238
554
  end
239
555
 
240
- #---
241
-
556
+ # Safely output via a printer method to an output channel unless quiet specified
557
+ #
558
+ # * *Parameters*
559
+ # - [String] *message* Message to render to output channel
560
+ # - [Hash] *options* Output options
561
+ # - [Symbol] *:channel* IO channel to send output to (don't touch)
562
+ # - [Symbol] *:printer* Printer method to use; *:puts*, *:print*
563
+ #
564
+ # * *Returns*
565
+ # - [Void] This method does not return a value
566
+ #
567
+ # * *Errors*
568
+ # - [Errno::EPIPE] Error if sending of output to communication channel fails
569
+ #
570
+ # See also:
571
+ # - #check_delegate
572
+ #
242
573
  def safe_puts(message = nil, options = {})
243
574
  return @delegate.safe_puts(message, options) if check_delegate('safe_puts')
244
-
575
+
245
576
  message ||= ""
246
577
  options = {
247
578
  :channel => @output,
@@ -254,82 +585,194 @@ class Console
254
585
  return
255
586
  end
256
587
  end
257
-
258
- #-----------------------------------------------------------------------------
259
-
588
+
589
+ #*****************************************************************************
590
+
591
+ # Check if a registered delegate exists and responds to a specified method.
592
+ #
593
+ # * *Parameters*
594
+ # - [String, Symbol] *method* Method to check in delegate if registered
595
+ #
596
+ # * *Returns*
597
+ # - [Boolean] Whether a delegate that responds to method exists
598
+ #
599
+ # * *Errors*
600
+ #
260
601
  def check_delegate(method)
261
- return ( @delegate && @delegate.respond_to?(method.to_s) )
602
+ return Util::Data.test(@delegate && @delegate.respond_to?(method.to_s))
262
603
  end
263
-
264
- #-----------------------------------------------------------------------------
604
+
605
+ #*****************************************************************************
265
606
  # Color translation
266
-
607
+
608
+ # Colorize a given string if global colors enabled, else return input string.
609
+ #
610
+ # * *Parameters*
611
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
612
+ # - [String, Symbol] *color* Color to use; *:black*, *:red*, *:green*, *:yellow*, *:blue*, *:purple*, *:cyan*, *:grey*
613
+ #
614
+ # * *Returns*
615
+ # - [String] Colorized or input string depending on global color flag
616
+ #
617
+ # * *Errors*
618
+ #
619
+ # See also:
620
+ # - ::use_colors
621
+ #
267
622
  def self.colorize(string, color)
268
623
  return '' unless string
269
624
  return string.to_s unless use_colors
270
-
625
+
271
626
  color = color.to_sym
272
627
  string = string.to_s
273
628
  color_string = string
274
-
629
+
275
630
  if @@colors[color]
276
631
  color = @@colors[color]
277
632
  clear_color = @@colors[:clear]
278
633
  escaped_clear = Regexp.escape(clear_color)
279
-
634
+
280
635
  color_string = "#{color}"
281
636
  color_string << string.gsub(/#{escaped_clear}(?!\e\[)/, "#{clear_color}#{color}")
282
637
  color_string << "#{clear_color}"
283
638
  end
284
639
  color_string
285
640
  end
286
-
287
- #---
288
-
641
+
642
+ # Color a given string black if global colors enabled, else return input string.
643
+ #
644
+ # * *Parameters*
645
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
646
+ #
647
+ # * *Returns*
648
+ # - [String] Black or uncolored input string depending on global color flag
649
+ #
650
+ # * *Errors*
651
+ #
652
+ # See:
653
+ # - ::colorize
654
+ #
289
655
  def self.black(string)
290
- colorize(string, :black)
656
+ colorize(string, :black)
291
657
  end
292
-
293
- #---
294
-
658
+
659
+ # Color a given string red if global colors enabled, else return input string.
660
+ #
661
+ # * *Parameters*
662
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
663
+ #
664
+ # * *Returns*
665
+ # - [String] Red or uncolored input string depending on global color flag
666
+ #
667
+ # * *Errors*
668
+ #
669
+ # See:
670
+ # - ::colorize
671
+ #
295
672
  def self.red(string)
296
- colorize(string, :red)
673
+ colorize(string, :red)
297
674
  end
298
-
299
- #---
300
-
675
+
676
+ # Color a given string green if global colors enabled, else return input string.
677
+ #
678
+ # * *Parameters*
679
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
680
+ #
681
+ # * *Returns*
682
+ # - [String] Green or uncolored input string depending on global color flag
683
+ #
684
+ # * *Errors*
685
+ #
686
+ # See:
687
+ # - ::colorize
688
+ #
301
689
  def self.green(string)
302
- colorize(string, :green)
690
+ colorize(string, :green)
303
691
  end
304
-
305
- #---
306
-
692
+
693
+ # Color a given string yellow if global colors enabled, else return input string.
694
+ #
695
+ # * *Parameters*
696
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
697
+ #
698
+ # * *Returns*
699
+ # - [String] Yellow or uncolored input string depending on global color flag
700
+ #
701
+ # * *Errors*
702
+ #
703
+ # See:
704
+ # - ::colorize
705
+ #
307
706
  def self.yellow(string)
308
- colorize(string, :yellow)
707
+ colorize(string, :yellow)
309
708
  end
310
-
311
- #---
312
-
709
+
710
+ # Color a given string blue if global colors enabled, else return input string.
711
+ #
712
+ # * *Parameters*
713
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
714
+ #
715
+ # * *Returns*
716
+ # - [String] Blue or uncolored input string depending on global color flag
717
+ #
718
+ # * *Errors*
719
+ #
720
+ # See:
721
+ # - ::colorize
722
+ #
313
723
  def self.blue(string)
314
- colorize(string, :blue)
724
+ colorize(string, :blue)
315
725
  end
316
-
317
- #---
318
-
726
+
727
+ # Color a given string purple if global colors enabled, else return input string.
728
+ #
729
+ # * *Parameters*
730
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
731
+ #
732
+ # * *Returns*
733
+ # - [String] Purple or uncolored input string depending on global color flag
734
+ #
735
+ # * *Errors*
736
+ #
737
+ # See:
738
+ # - ::colorize
739
+ #
319
740
  def self.purple(string)
320
- colorize(string, :purple)
741
+ colorize(string, :purple)
321
742
  end
322
-
323
- #---
324
-
743
+
744
+ # Color a given string cyan if global colors enabled, else return input string.
745
+ #
746
+ # * *Parameters*
747
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
748
+ #
749
+ # * *Returns*
750
+ # - [String] Cyan or uncolored input string depending on global color flag
751
+ #
752
+ # * *Errors*
753
+ #
754
+ # See:
755
+ # - ::colorize
756
+ #
325
757
  def self.cyan(string)
326
- colorize(string, :cyan)
758
+ colorize(string, :cyan)
327
759
  end
328
-
329
- #---
330
-
760
+
761
+ # Color a given string grey if global colors enabled, else return input string.
762
+ #
763
+ # * *Parameters*
764
+ # - [String, Symbol] *string* String to colorize (if colors allowed globally)
765
+ #
766
+ # * *Returns*
767
+ # - [String] Grey or uncolored input string depending on global color flag
768
+ #
769
+ # * *Errors*
770
+ #
771
+ # See:
772
+ # - ::colorize
773
+ #
331
774
  def self.grey(string)
332
- colorize(string, :grey)
775
+ colorize(string, :grey)
333
776
  end
334
777
  end
335
778
  end