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,41 +1,35 @@
1
-
2
- # Should be included via include
3
- #
4
- # include Mixin::Settings
5
- #
6
-
7
1
  module Nucleon
8
2
  module Mixin
9
3
  module Settings
10
-
4
+
11
5
  def settings(name)
12
6
  return get_hash([ :settings, name ])
13
7
  end
14
-
8
+
15
9
  #---
16
10
 
17
11
  def set_settings(name, settings = {})
18
12
  return set([ :settings, name ], settings)
19
13
  end
20
-
14
+
21
15
  #---
22
16
 
23
17
  def delete_settings(name)
24
18
  return delete([ :settings, name ])
25
19
  end
26
-
20
+
27
21
  #---
28
-
22
+
29
23
  def setting(name, key, default = '', format = false)
30
24
  return get([ :settings, name, key ], default, format)
31
25
  end
32
-
26
+
33
27
  #---
34
28
 
35
29
  def set_setting(name, key, value = '')
36
30
  return set([ :settings, name, key ], value)
37
31
  end
38
-
32
+
39
33
  #---
40
34
 
41
35
  def delete_setting(name, key)
@@ -1,144 +1,138 @@
1
-
2
- # Should be included via include
3
- #
4
- # include Mixin::SubConfig
5
- #
6
-
7
1
  module Nucleon
8
2
  module Mixin
9
3
  module SubConfig
10
-
4
+
11
5
  #-----------------------------------------------------------------------------
12
6
  # Initialization
13
-
7
+
14
8
  def init_subconfig(reset = false)
15
9
  return if @subconfig_initialized && ! reset
16
-
10
+
17
11
  unless @config
18
12
  @config = Config.new({}, {}, true, false)
19
13
  end
20
-
14
+
21
15
  @subconfig_initialized = true
22
16
  end
23
17
  protected :init_subconfig
24
-
18
+
25
19
  #-----------------------------------------------------------------------------
26
20
  # Propety accessors / modifiers
27
-
21
+
28
22
  def config
29
23
  return @config
30
24
  end
31
-
25
+
32
26
  #---
33
-
27
+
34
28
  def config=config
35
29
  @config = config
36
30
  end
37
-
31
+
38
32
  #-----------------------------------------------------------------------------
39
33
 
40
34
  def _get(keys, default = nil, format = false)
41
35
  return fetch(@properties, array(keys).flatten, default, format)
42
36
  end
43
37
  protected :_get
44
-
38
+
45
39
  #---
46
-
40
+
47
41
  def get(keys, default = nil, format = false)
48
42
  init_subconfig
49
43
  return config.get(keys, default, format)
50
44
  end
51
-
45
+
52
46
  #---
53
-
47
+
54
48
  def _init(keys, default = nil)
55
49
  return _set(keys, _get(keys, default))
56
50
  end
57
51
  protected :_init
58
52
 
59
53
  #---
60
-
54
+
61
55
  def _set(keys, value = '', delete_nil = false)
62
56
  modify(@properties, array(keys).flatten, value, delete_nil)
63
57
  end
64
58
  protected :_set
65
-
59
+
66
60
  #---
67
-
61
+
68
62
  def set(keys, value = '', delete_nil = false)
69
63
  init_subconfig
70
64
  config.set(keys, value, delete_nil)
71
65
  end
72
-
66
+
73
67
  #---
74
-
68
+
75
69
  def _delete(keys, default = nil)
76
70
  existing = modify(@properties, array(keys).flatten, nil, true)
77
71
  return existing[:value] if existing[:value]
78
- return default
72
+ return default
79
73
  end
80
74
  protected :_delete
81
-
75
+
82
76
  #---
83
-
77
+
84
78
  def delete(keys, default = nil)
85
79
  init_subconfig
86
80
  config.delete(keys, default)
87
81
  end
88
-
82
+
89
83
  #---
90
-
84
+
91
85
  def _clear
92
86
  @properties = {}
93
87
  end
94
88
  protected :_clear
95
-
89
+
96
90
  #---
97
-
91
+
98
92
  def clear
99
93
  init_subconfig
100
94
  config.clear
101
95
  end
102
-
96
+
103
97
  #-----------------------------------------------------------------------------
104
98
  # Import / Export
105
-
99
+
106
100
  def _import(properties, options = {})
107
101
  return import_base(properties, options)
108
102
  end
109
103
  protected :_import
110
-
104
+
111
105
  #---
112
-
106
+
113
107
  def import(properties, options = {})
114
108
  init_subconfig
115
109
  config.import(properties, options)
116
110
  end
117
-
111
+
118
112
  #---
119
-
113
+
120
114
  def _defaults(defaults, options = {})
121
115
  config = new(options).set(:import_type, :default)
122
116
  return import_base(defaults, config)
123
117
  end
124
118
  protected :_defaults
125
-
119
+
126
120
  #---
127
-
121
+
128
122
  def defaults(defaults, options = {})
129
123
  init_subconfig
130
124
  config.defaults(defaults, options)
131
125
  end
132
-
126
+
133
127
  #---
134
-
128
+
135
129
  def _export
136
130
  return @properties
137
131
  end
138
132
  protected :_export
139
-
133
+
140
134
  #---
141
-
135
+
142
136
  def export
143
137
  init_subconfig
144
138
  return config.export
@@ -1,24 +1,45 @@
1
-
2
- #-------------------------------------------------------------------------------
3
- # Hash data type alterations
4
-
1
+ #
2
+ # Hash class additions
3
+ #
4
+ # Over time these may get depreciated in favor of other solutions.
5
+ #
5
6
  class Hash
7
+
8
+ # Search for a key (potentially recursively) in a given hash.
9
+ #
10
+ # This method uses strict matching between string and symbol key types. They
11
+ # must be the same type or they will not match.
12
+ #
13
+ # * *Parameters*
14
+ # - [String, Symbol] *search_key* Key to search for in hash
15
+ # - [Hash<String, Symbol|ANY>] *options* Search options
16
+ # - [Boolean] *:recurse* Whether to recurse through sub hashes to find key value
17
+ # - [Integer] *:recurse_level* Maximum level to recurse into nested hashes or -1 for all
18
+ #
19
+ # * *Returns*
20
+ # - [ANY] Return value for search key if value found, nil otherwise
21
+ #
22
+ # * *Errors*
23
+ #
24
+ # See also:
25
+ # - Nucleon::Util::Data::interpolate
26
+ #
6
27
  def search(search_key, options = {})
7
28
  config = Nucleon::Config.ensure(options)
8
29
  value = nil
9
-
30
+
10
31
  recurse = config.get(:recurse, false)
11
32
  recurse_level = config.get(:recurse_level, -1)
12
-
33
+
13
34
  self.each do |key, data|
14
35
  if key == search_key
15
36
  value = data
16
-
17
- elsif data.is_a?(Hash) &&
37
+
38
+ elsif data.is_a?(Hash) &&
18
39
  recurse && (recurse_level == -1 || recurse_level > 0)
19
-
40
+
20
41
  recurse_level -= 1 unless recurse_level == -1
21
- value = value.search(search_key,
42
+ value = value.search(search_key,
22
43
  Nucleon::Config.new(config).set(:recurse_level, recurse_level)
23
44
  )
24
45
  end
@@ -2,23 +2,25 @@
2
2
  module Nucleon
3
3
  module Plugin
4
4
  class Action < Nucleon.plugin_class(:nucleon, :base)
5
-
5
+
6
6
  extend Mixin::Colors
7
-
7
+
8
8
  include Mixin::Action::Registration
9
-
9
+
10
+ codes :action_interrupted
11
+
10
12
  #-----------------------------------------------------------------------------
11
13
  # Info
12
-
14
+
13
15
  def self.describe(group = nil, action = 'unknown', weight = -1000, description = nil, help = nil)
14
16
  describe_base(group, action, weight, description, help)
15
17
  end
16
-
18
+
17
19
  def self.describe_base(group = nil, action = 'unknown', weight = -1000, description = nil, help = nil, provider_override = nil)
18
20
  if provider_override
19
21
  provider_override = provider_override.to_s.gsub('_', '.')
20
22
  description_id = "#{namespace}.action.#{provider_override}.description"
21
- help_id = "#{namespace}.action.#{provider_override}.help"
23
+ help_id = "#{namespace}.action.#{provider_override}.help"
22
24
  else
23
25
  if group
24
26
  group_name = Util::Data.array(group).join('.')
@@ -29,7 +31,7 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
29
31
  help_id = "#{namespace}.action.#{action}.help"
30
32
  end
31
33
  end
32
-
34
+
33
35
  {
34
36
  :namespace => namespace,
35
37
  :weight => weight,
@@ -39,16 +41,16 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
39
41
  :help => help ? help : I18n.t(help_id)
40
42
  }
41
43
  end
42
-
44
+
43
45
  #---
44
-
46
+
45
47
  def self.namespace
46
48
  :nucleon
47
49
  end
48
-
50
+
49
51
  #-----------------------------------------------------------------------------
50
52
  # Default option interface
51
-
53
+
52
54
  class Option
53
55
  def initialize(namespace, provider, name, type, default, locale = nil, &validator)
54
56
  @provider = provider
@@ -58,14 +60,14 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
58
60
  @locale = locale.nil? ? "#{namespace}.action.#{provider.to_s.gsub('_', '.')}.options.#{name}" : locale
59
61
  @validator = validator if validator
60
62
  end
61
-
63
+
62
64
  #---
63
-
65
+
64
66
  attr_reader :provider, :name, :type
65
67
  attr_accessor :default, :locale, :validator
66
-
68
+
67
69
  #---
68
-
70
+
69
71
  def validate(value, *args)
70
72
  success = true
71
73
  if @validator
@@ -75,92 +77,116 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
75
77
  end
76
78
  end
77
79
 
80
+ #-----------------------------------------------------------------------------
81
+ # Action execution state container
82
+
83
+ class State
84
+ def initialize(status = 0, result = nil, action = nil, error = nil)
85
+ @status = status
86
+ @result = result
87
+ @action = action
88
+ @error = error
89
+ end
90
+
91
+ #---
92
+
93
+ attr_accessor :status, :result, :action, :error
94
+ end
95
+
78
96
  #-----------------------------------------------------------------------------
79
97
  # Action plugin interface
80
-
81
- def self.exec_safe(provider, options)
82
- action_result = nil
83
-
98
+
99
+ def self.exec_safe(provider, options, display_errors = true, state = nil)
84
100
  begin
101
+ state = State.new(Nucleon.code.unknown_status) unless state
85
102
  logger = Nucleon.logger
86
-
87
- logger.debug("Running nucleon action #{provider} with #{options.inspect}")
88
- action = Nucleon.action(provider, options)
89
- exit_status = action.execute
90
- action_result = action.result
91
-
92
- rescue => error
93
- logger.error("Nucleon action #{provider} experienced an error:")
94
- logger.error(error.inspect)
95
- logger.error(error.message)
96
- logger.error(Nucleon::Util::Data.to_yaml(error.backtrace))
97
-
98
- Nucleon.ui.error(error.message, { :prefix => false }) if error.message
99
-
100
- exit_status = error.status_code if error.respond_to?(:status_code)
103
+
104
+ logger.info("Running nucleon action #{provider} with #{options.inspect}")
105
+
106
+ state.action = Nucleon.action(provider, options)
107
+ state.action.execute
108
+
109
+ state.status = state.action.status if state.action.status.is_a?(Integer)
110
+ state.result = state.action.result
111
+
112
+ rescue => error # This does NOT catch interrupts
113
+ state.error = error
114
+
115
+ if display_errors
116
+ logger.error("Nucleon action #{provider} experienced an error:")
117
+ logger.error(state.error.inspect)
118
+ logger.error(state.error.message)
119
+ logger.error(Nucleon::Util::Data.to_yaml(state.error.backtrace))
120
+
121
+ Nucleon.ui.error(state.error.message, { :prefix => false }) if state.error.message
122
+ end
123
+
124
+ state.action.finalize_execution(false) if state.action
101
125
  end
102
-
103
- exit_status = Nucleon.code.unknown_status unless exit_status.is_a?(Integer)
104
- { :status => exit_status, :result => action_result }
126
+ state
105
127
  end
106
-
107
- def self.exec(provider, options, quiet = true)
108
- exec_safe(provider, { :settings => Config.ensure(options), :quiet => quiet })
128
+
129
+ def self.exec(provider, options, quiet = true, display_errors = true, state = nil)
130
+ exec_safe(provider, { :settings => Config.ensure(options), :quiet => quiet }, display_errors, state)
109
131
  end
110
-
111
- def self.exec_cli(provider, args, quiet = false, name = :nucleon)
112
- results = exec_safe(provider, { :args => args, :quiet => quiet, :executable => name })
113
- results[:status]
132
+
133
+ def self.exec_cli(provider, args, quiet = false, name = :nucleon, display_errors = true, state = nil)
134
+ exec_safe(provider, { :args => args, :quiet => quiet, :executable => name }, display_errors, state)
114
135
  end
115
-
136
+
116
137
  #---
117
-
138
+
118
139
  def normalize(reload)
119
140
  args = array(delete(:args, []))
120
-
121
- @action_interface = Util::Liquid.new do |method, method_args|
122
- options = {}
123
- options = method_args[0] if method_args.length > 0
124
-
125
- quiet = true
126
- quiet = method_args[1] if method_args.length > 1
127
-
128
- myself.class.exec(method, options, quiet)
141
+ help = delete(:help, false)
142
+
143
+ unless reload
144
+ @action_interface = Util::Liquid.new do |method, method_args|
145
+ options = {}
146
+ options = method_args[0] if method_args.length > 0
147
+
148
+ quiet = true
149
+ quiet = method_args[1] if method_args.length > 1
150
+
151
+ myself.class.exec(method, options, quiet)
152
+ end
153
+
154
+ set(:config, Config.new)
155
+
156
+ if get(:settings, nil)
157
+ # Internal processing
158
+ configure
159
+ set(:processed, true)
160
+ set(:settings, Config.ensure(get(:settings)))
161
+
162
+ Nucleon.log_level = settings[:log_level] if settings.has_key?(:log_level)
163
+ else
164
+ # External processing
165
+ set(:settings, Config.new)
166
+ configure
167
+ parse_base(args)
168
+ end
169
+
170
+ yield if block_given? && ! help
129
171
  end
130
-
131
- set(:config, Config.new)
132
-
133
- if get(:settings, nil)
134
- # Internal processing
135
- configure
136
- set(:processed, true)
137
- set(:settings, Config.ensure(get(:settings)))
138
-
139
- Nucleon.log_level = settings[:log_level] if settings.has_key?(:log_level)
140
- else
141
- # External processing
142
- set(:settings, Config.new)
143
- configure
144
- parse_base(args)
145
- end
146
172
  end
147
-
173
+
148
174
  #-----------------------------------------------------------------------------
149
175
  # Checks
150
-
176
+
151
177
  def strict?
152
178
  true # Override in providers if needed (allow extra options if false)
153
179
  end
154
-
180
+
155
181
  #---
156
-
182
+
157
183
  def processed?
158
184
  get(:processed, false)
159
185
  end
160
-
186
+
161
187
  #-----------------------------------------------------------------------------
162
188
  # Property accessor / modifiers
163
-
189
+
164
190
  def index_config
165
191
  action_info = nil
166
192
  self.class.action_index(false).export.each do |action_id, info|
@@ -169,161 +195,165 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
169
195
  break
170
196
  end
171
197
  end
172
- Config.ensure(action_info)
198
+ Config.ensure(action_info)
173
199
  end
174
-
200
+
175
201
  #---
176
-
202
+
177
203
  def namespace
178
204
  self.class.namespace
179
205
  end
180
-
206
+
181
207
  #---
182
-
208
+
183
209
  def config
184
210
  get(:config)
185
211
  end
186
-
212
+
187
213
  #---
188
-
214
+
189
215
  def config_subset(names)
190
216
  Util::Data.subset(config, names)
191
217
  end
192
-
218
+
193
219
  #---
194
-
220
+
195
221
  def settings
196
222
  get(:settings)
197
223
  end
198
-
224
+
199
225
  #---
200
-
226
+
227
+ def registration_provider
228
+ plugin_provider
229
+ end
230
+
201
231
  def register(name, type, default = nil, locale = nil, &code)
202
232
  name = name.to_sym
203
-
233
+
204
234
  if code
205
- option = Option.new(namespace, plugin_provider, name, type, default, locale) do |value, success|
235
+ option = Option.new(namespace, registration_provider, name, type, default, locale) do |value, success|
206
236
  code.call(value, success)
207
237
  end
208
238
  else
209
- option = Option.new(namespace, plugin_provider, name, type, default, locale)
239
+ option = Option.new(namespace, registration_provider, name, type, default, locale)
210
240
  end
211
-
241
+
212
242
  config[name] = option
213
243
  settings[name] = option.default if settings[name].nil?
214
244
  end
215
-
245
+
216
246
  #---
217
-
247
+
218
248
  def remove(names)
219
249
  Util::Data.rm_keys(config, names)
220
250
  Util::Data.rm_keys(settings, names)
221
251
  end
222
-
252
+
223
253
  #---
224
-
254
+
225
255
  def ignore
226
256
  []
227
257
  end
228
-
258
+
229
259
  def options
230
260
  config.keys - arguments - ignore
231
261
  end
232
-
262
+
233
263
  def arguments
234
264
  []
235
265
  end
236
-
266
+
237
267
  #---
238
-
268
+
239
269
  def configure
240
270
  action_info = index_config
241
-
271
+
242
272
  yield(action_info) if block_given?
243
-
244
- group = array(action_info[:description][:group])
273
+
274
+ group = array(action_info[:description][:group])
245
275
  action = cyan(action_info[:description][:action])
246
-
276
+
247
277
  if ! group.empty?
248
278
  group = green(group.join(' ').strip)
249
279
  usage = "#{group} #{action} "
250
280
  else
251
281
  usage = "#{action} "
252
282
  end
253
-
283
+
254
284
  arguments.each do |arg|
255
285
  arg_config = config[arg.to_sym]
256
-
286
+
257
287
  arg_prefix = arg_config.default ? '[' : ''
258
288
  arg_suffix = arg_config.default ? ']' : ''
259
-
289
+
260
290
  if arg_config.type == :array
261
291
  usage << "#{arg_prefix}<#{arg}> ...#{arg_suffix}"
262
292
  else
263
- usage << "#{arg_prefix}<#{arg}>#{arg_suffix} "
264
- end
293
+ usage << "#{arg_prefix}<#{arg}>#{arg_suffix} "
294
+ end
265
295
  end
266
296
  myself.usage = yellow(usage)
267
297
  myself
268
298
  end
269
-
299
+
270
300
  #---
271
-
301
+
272
302
  def usage=usage
273
303
  set(:usage, usage)
274
304
  end
275
-
305
+
276
306
  def usage
277
307
  get(:usage, '')
278
308
  end
279
-
309
+
280
310
  #---
281
-
311
+
282
312
  def help
283
313
  return @parser.help if @parser
284
314
  usage
285
315
  end
286
-
316
+
287
317
  #---
288
-
318
+
289
319
  def result=result
290
320
  set(:result, result)
291
321
  end
292
-
322
+
293
323
  def result
294
324
  get(:result, nil)
295
325
  end
296
326
 
297
327
  #-----------------------------------------------------------------------------
298
328
  # Operations
299
-
300
- def parse_base(args)
329
+
330
+ def parse_base(args)
301
331
  logger.info("Parsing action #{plugin_provider} with: #{args.inspect}")
302
-
332
+
303
333
  action_info = index_config
304
-
334
+
305
335
  help_text = ''
306
336
  action_info[:description][:help].split("\n").each do |line|
307
337
  help_text << ' ' + green(line) + "\n"
308
338
  end
309
-
339
+
310
340
  @parser = Util::CLI::Parser.new(args, usage, "\n#{help_text}\n") do |parser|
311
341
  parser.strict = strict?
312
-
313
- parse(parser)
342
+
343
+ parse(parser)
314
344
  extension(:parse, { :parser => parser, :config => config })
315
345
  end
316
-
317
- if @parser
346
+
347
+ if @parser
318
348
  if @parser.processed
319
349
  set(:processed, true)
320
350
  settings.import(Util::Data.merge([ @parser.extra, @parser.options, @parser.arguments ], true))
321
351
  logger.debug("Parse successful")
322
-
352
+
323
353
  elsif @parser.options[:help] && ! quiet?
324
354
  executable = delete(:executable, '')
325
355
  puts I18n.t('nucleon.core.exec.help.usage') + ": " + executable.to_s + ' ' + help + "\n"
326
-
356
+
327
357
  else
328
358
  if @parser.options[:help]
329
359
  logger.debug("Help wanted but running in silent mode")
@@ -333,60 +363,60 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
333
363
  end
334
364
  end
335
365
  end
336
-
366
+
337
367
  #---
338
-
368
+
339
369
  def parse_types
340
- [ :bool, :int, :float, :str, :array ]
370
+ [ :bool, :int, :float, :str, :array ]
341
371
  end
342
-
372
+
343
373
  def parse(parser)
344
-
374
+
345
375
  generate = lambda do |format, name|
346
376
  formats = [ :option, :arg ]
347
377
  types = parse_types
348
378
  name = name.to_sym
349
-
379
+
350
380
  if config.export.has_key?(name) && formats.include?(format.to_sym)
351
381
  option_config = config[name]
352
382
  type = option_config.type
353
383
  default = option_config.default
354
- locale = option_config.locale
355
-
384
+ locale = option_config.locale
385
+
356
386
  if types.include?(type.to_sym)
357
387
  value_label = "#{type.to_s.upcase}"
358
-
388
+
359
389
  if type == :bool
360
- parser.send("option_#{type}", name, default, "--[no-]#{name}", locale)
390
+ parser.send("option_#{type}", name, default, "--[no-]#{name}", locale)
361
391
  elsif format == :arg
362
- parser.send("#{format}_#{type}", name, default, locale)
392
+ parser.send("#{format}_#{type}", name, default, locale)
363
393
  else
364
394
  if type == :array
365
- parser.send("option_#{type}", name, default, "--#{name} #{value_label},...", locale)
395
+ parser.send("option_#{type}", name, default, "--#{name} #{value_label},...", locale)
366
396
  else
367
397
  parser.send("option_#{type}", name, default, "--#{name} #{value_label}", locale)
368
398
  end
369
399
  end
370
- end
400
+ end
371
401
  end
372
402
  end
373
-
403
+
374
404
  #---
375
-
405
+
376
406
  options.each do |name|
377
- generate.call(:option, name)
407
+ generate.call(:option, name)
378
408
  end
379
-
409
+
380
410
  arguments.each do |name|
381
411
  generate.call(:arg, name)
382
- end
412
+ end
383
413
  end
384
-
414
+
385
415
  #---
386
-
416
+
387
417
  def validate(*args)
388
418
  # TODO: Add extension hooks and logging
389
-
419
+
390
420
  # Validate all of the configurations
391
421
  success = true
392
422
  config.export.each do |name, option|
@@ -396,7 +426,7 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
396
426
  end
397
427
  if success
398
428
  # Check for missing arguments (in case of internal execution mode)
399
- arguments.each do |name|
429
+ arguments.each do |name|
400
430
  if settings[name.to_sym].nil?
401
431
  warn('nucleon.core.exec.errors.missing_argument', { :name => name })
402
432
  success = false
@@ -405,100 +435,106 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
405
435
  end
406
436
  success
407
437
  end
408
-
438
+
409
439
  #---
410
-
440
+
411
441
  def execute(skip_validate = false, skip_hooks = false)
412
442
  logger.info("Executing action #{plugin_provider}")
413
-
443
+
414
444
  myself.status = code.success
415
445
  myself.result = nil
416
-
417
- if processed?
418
- begin
419
- if skip_validate || validate
420
- yield if block_given? && ( skip_hooks || extension_check(:exec_init) )
421
- myself.status = extension_set(:exec_exit, myself.status) unless skip_hooks
422
- else
423
- puts "\n" + I18n.t('nucleon.core.exec.help.usage') + ': ' + help + "\n" unless quiet?
424
- myself.status = code.validation_failed
425
- end
426
- ensure
427
- cleanup
446
+
447
+ if processed?
448
+ if skip_validate || validate
449
+ yield if block_given? && ( skip_hooks || extension_check(:exec_init) )
450
+ else
451
+ puts "\n" + I18n.t('nucleon.core.exec.help.usage') + ': ' + help + "\n" unless quiet?
452
+ myself.status = code.validation_failed
453
+ skip_hooks = true
428
454
  end
455
+ finalize_execution(skip_hooks)
429
456
  else
430
457
  if @parser.options[:help]
431
458
  myself.status = code.help_wanted
432
459
  else
433
460
  myself.status = code.action_unprocessed
434
461
  end
462
+ finalize_execution(true)
463
+ end
464
+ end
465
+
466
+ #---
467
+
468
+ def finalize_execution(skip_hooks = false)
469
+ begin
470
+ myself.status = extension_set(:exec_exit, status) unless skip_hooks
471
+ ensure
472
+ cleanup
435
473
  end
436
-
437
- myself.status = code.unknown_status unless status.is_a?(Integer)
438
-
439
- if processed? && status != code.success
474
+
475
+ myself.status = code.unknown_status unless myself.status.is_a?(Integer)
476
+
477
+ if processed? && myself.status != code.success
440
478
  logger.warn("Execution failed for #{plugin_provider} with status #{status}")
441
- warn(Codes.render_index(status), { :i18n => false })
442
- end
443
-
444
- status
479
+ warn(Codes.render_status(status), { :i18n => false })
480
+ end
445
481
  end
446
-
482
+
447
483
  #---
448
-
484
+
449
485
  def run
450
486
  @action_interface
451
487
  end
452
-
488
+
453
489
  #---
454
-
490
+
455
491
  def cleanup
456
492
  logger.info("Running cleanup for action #{plugin_provider}")
457
-
493
+
458
494
  yield if block_given?
459
-
495
+
460
496
  # Nothing to do right now
461
497
  extension(:cleanup)
462
498
  end
463
-
499
+
464
500
  #-----------------------------------------------------------------------------
465
501
  # Output
466
-
502
+
467
503
  def render_options
468
504
  options = super
469
505
  options.merge(settings.export)
470
506
  end
471
-
507
+
472
508
  #-----------------------------------------------------------------------------
473
509
  # Utilities
474
510
 
475
511
  def self.components(search)
476
512
  components = []
477
-
513
+
478
514
  array(search).each do |element|
479
515
  break if element.match(/^\-+/)
480
516
  components << element
481
517
  end
482
- components
518
+ components
483
519
  end
484
-
520
+
485
521
  #---
486
-
522
+
487
523
  def self.action_index(tree = true)
488
524
  action_config = Config.new
489
525
  action_index = Config.new
490
-
526
+
491
527
  generate_index = lambda do |info, parents = nil|
492
528
  groups = info.keys - [ :_weight, :_weights ]
493
- groups = groups.sort do |a, b|
529
+ groups = groups.sort do |a, b|
494
530
  info[b][:_weight] <=> info[a][:_weight]
495
531
  end
496
-
532
+
497
533
  groups.each do |group|
498
534
  data = info[group]
499
-
535
+
500
536
  if data.is_a?(Hash) && data.has_key?(:_weights)
501
- sub_parents = parents.nil? ? [ group ] : [ parents, group ].flatten
537
+ sub_parents = parents.nil? ? [ group ] : [ parents, group ].flatten
502
538
  generate_index.call(data, sub_parents)
503
539
  else
504
540
  keys = tree ? [ parents, group ] : [ parents, group ].flatten.join('::')
@@ -506,47 +542,47 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
506
542
  end
507
543
  end
508
544
  end
509
-
545
+
510
546
  Nucleon.loaded_plugins(:nucleon, :action).each do |provider, data|
511
547
  description = data[:class].describe
512
548
  data[:description] = description
513
549
  data[:_weight] = description[:weight]
514
-
550
+
515
551
  keys = [ description[:namespace], description[:group], description[:action] ].flatten.compact
516
552
  action_config.set(keys, data)
517
-
553
+
518
554
  keys.pop
519
-
555
+
520
556
  while ! keys.empty?
521
557
  group_config = action_config.get(keys)
522
-
558
+
523
559
  if group_config.has_key?(:_weights)
524
- group_config[:_weights].push(description[:weight])
560
+ group_config[:_weights].push(description[:weight])
525
561
  else
526
562
  action_config.set([ keys, :_weights ], [ description[:weight] ])
527
- end
563
+ end
528
564
  action_config.set([ keys, :_weight ], group_config[:_weights].inject(0.0) { |sum, el| sum + el } / group_config[:_weights].size)
529
565
  keys.pop
530
566
  end
531
567
  end
532
-
568
+
533
569
  generate_index.call(action_config.export)
534
570
  action_index
535
571
  end
536
-
572
+
537
573
  #---
538
-
574
+
539
575
  def self.search_actions(search_components)
540
576
  action_components = components(search_components)
541
577
  action_index = action_index(false).export
542
578
  actions_found = []
543
579
  final_components = []
544
-
580
+
545
581
  search_action = lambda do |components|
546
582
  unless components.empty?
547
583
  action_id = components.is_a?(Array) ? components.flatten.join('::') : components
548
584
  action_id_pattern = action_id.gsub('::', ':.*:')
549
-
585
+
550
586
  action_index.each do |loaded_action_id, loaded_action_info|
551
587
  if loaded_action_id.match(/(^|\:)#{action_id_pattern.gsub(/\-/, '\-')}(\:|$)/)
552
588
  loaded_action_info[:action_id] = loaded_action_id
@@ -560,113 +596,113 @@ class Action < Nucleon.plugin_class(:nucleon, :base)
560
596
  search_action.call(components)
561
597
  else
562
598
  final_components = components
563
- end
599
+ end
564
600
  end
565
-
601
+
566
602
  search_action.call(action_components) unless action_components.empty?
567
-
568
- { :actions => actions_found.size == 1 ? actions_found[0] : actions_found,
569
- :components => final_components
603
+
604
+ { :actions => actions_found.size == 1 ? actions_found[0] : actions_found,
605
+ :components => final_components
570
606
  }
571
607
  end
572
-
608
+
573
609
  #---
574
-
610
+
575
611
  def self.action_help(action = nil, extended_help = false)
576
612
  action_index = action_index(false).export
577
613
  provider_index = {}
578
614
  processed_actions = {}
579
-
615
+
580
616
  last_namespace = nil
581
- last_group = nil
617
+ last_group = nil
582
618
  multiple_found = false
583
-
619
+
584
620
  command_width = 0
585
621
  namespace_command_width = {}
586
-
622
+
587
623
  output = ''
588
-
624
+
589
625
  if action
590
626
  if action.empty?
591
627
  output << cyan(sprintf("\n%s\n", I18n.t('nucleon.core.exec.help.no_actions_found')))
592
628
  else
593
629
  multiple_found = true
594
630
  output << cyan(sprintf("\n%s\n", I18n.t('nucleon.core.exec.help.multiple_actions_found')))
595
-
631
+
596
632
  action.each do |info|
597
633
  provider_index[info[:provider]] = true
598
634
  end
599
635
  end
600
636
  end
601
-
637
+
602
638
  action_index.each do |action_id, info|
603
639
  if ! multiple_found || provider_index.has_key?(info[:provider])
604
- action = Nucleon.action(info[:provider], { :settings => {}, :quiet => true })
640
+ action = Nucleon.action(info[:provider], { :settings => {}, :quiet => true, :help => true })
605
641
  command_text = action.help
606
-
642
+
607
643
  command_size = command_text.gsub(/\e\[(\d+)m/, '').size
608
644
  command_width = [ command_width, command_size + 2 ].max
609
-
645
+
610
646
  namespace = info[:description][:namespace]
611
-
647
+
612
648
  namespace_command_width[namespace] = 0 unless namespace_command_width.has_key?(namespace)
613
649
  namespace_command_width[namespace] = [ namespace_command_width[namespace], command_size + 2 ].max
614
-
650
+
615
651
  if extended_help
616
652
  help_text = ''
617
653
  info[:description][:help].split("\n").each do |line|
618
654
  break if ! help_text.empty? && line.empty?
619
655
  help_text << ' ' + line + "\n"
620
- end
656
+ end
621
657
  else
622
658
  help_text = nil
623
659
  end
624
-
660
+
625
661
  processed_actions[action_id] = {
626
662
  :info => info,
627
663
  :command => command_text,
628
- :help => help_text
629
- }
630
- end
664
+ :help => help_text
665
+ }
666
+ end
631
667
  end
632
-
668
+
633
669
  processed_actions.each do |action_id, info|
634
670
  command_text = info[:command]
635
671
  help_text = info[:help]
636
672
  info = info[:info]
637
673
  namespace = info[:description][:namespace]
638
674
  group = info[:description][:group]
639
-
675
+
640
676
  group_id = group.is_a?(Array) ? group.flatten.join('::') : group.to_s
641
677
  group_id = '' unless group_id
642
-
678
+
643
679
  output << "\n" if group_id != last_group
644
-
680
+
645
681
  if namespace != last_namespace
646
682
  output << "\n----------------------------------------------------\n" if help_text
647
683
  output << sprintf("\n %s:\n\n", I18n.t('nucleon.core.exec.help.action_group', { :namespace => purple(namespace) }))
648
684
  end
649
-
685
+
650
686
  if help_text
651
687
  output << " " + render_colorized(command_text, namespace_command_width[namespace]) + " -- " + blue(info[:description][:description]) + "\n"
652
688
  output << "\n#{help_text}\n"
653
689
  else
654
690
  output << " " + render_colorized(command_text, command_width) + " -- " + blue(info[:description][:description]) + "\n"
655
- end
656
-
691
+ end
692
+
657
693
  last_namespace = namespace
658
694
  last_group = group_id
659
695
  end
660
- output
696
+ output
661
697
  end
662
-
698
+
663
699
  #---
664
700
 
665
701
  def self.render_colorized(text, length = 0)
666
702
  command_size = text.gsub(/\e\[(\d+)m/, '').size
667
703
  remaining = [ length - command_size, 0 ].max
668
- text + sprintf("%#{remaining}s", ' ')
669
- end
704
+ text + sprintf("%#{remaining}s", ' ')
705
+ end
670
706
  end
671
707
  end
672
708
  end