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
@@ -0,0 +1,209 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ module Nucleon
5
+
6
+ describe Codes do
7
+
8
+ include_context "nucleon_test"
9
+ include_context "nucleon_codes"
10
+
11
+ #***************************************************************************
12
+
13
+ def codes(*args, &code)
14
+ test_object(Codes, *args, &code)
15
+ end
16
+
17
+
18
+ #***************************************************************************
19
+ # Global collections
20
+
21
+ # Return the codes registry object
22
+ #
23
+ describe "#registry" do
24
+
25
+ it "returns the global code registry hash" do
26
+ test_eq Codes.registry, codes_registry_custom
27
+ end
28
+ end
29
+
30
+ # Return the codes status index object
31
+ #
32
+ describe "#status_index" do
33
+
34
+ it "returns the global status index hash" do
35
+ test_eq Codes.status_index, codes_status_index_custom
36
+ end
37
+ end
38
+
39
+
40
+ #***************************************************************************
41
+ # Global collections
42
+
43
+ # Return status index information for specified codes
44
+ #
45
+ describe "#index" do
46
+
47
+ it "returns the global status index if no code requested" do
48
+ test_eq Codes.index, codes_status_index_custom
49
+ test_eq Codes.index(nil), codes_status_index_custom
50
+ end
51
+
52
+ it "returns the appropriate code label if it exists" do
53
+ test_eq Codes.index(0), "success"
54
+ test_eq Codes.index(1), "help_wanted"
55
+ test_eq Codes.index(2), "unknown_status"
56
+ test_eq Codes.index(3), "action_unprocessed"
57
+ test_eq Codes.index(4), "batch_error"
58
+ test_eq Codes.index(5), "validation_failed"
59
+ test_eq Codes.index(6), "access_denied"
60
+ test_eq Codes.index(7), "good"
61
+ test_eq Codes.index(8), "bad"
62
+ test_eq Codes.index(9), "ok"
63
+ test_eq Codes.index(10), "wow"
64
+ test_eq Codes.index(11), "whew"
65
+ end
66
+
67
+ it "returns the unknown status label if the code does not exist" do
68
+ test_eq Codes.index(100), "unknown_status"
69
+ end
70
+ end
71
+
72
+ # Return status display information for specified codes
73
+ #
74
+ describe "#render_status" do
75
+
76
+ it "renders known status name with selected code if specified" do
77
+ for status_code in 0 .. 11
78
+ test_eq Codes.render_status(status_code), codes_rendered_status(status_code)
79
+ end
80
+ end
81
+
82
+ it "renders unknown status name code if unknown status code specified" do
83
+ test_eq Codes.render_status(100), codes_rendered_status(100)
84
+ end
85
+ end
86
+
87
+ # Return status index information for specified codes
88
+ #
89
+ describe "#render_index" do
90
+
91
+ it "renders known status code information with selected code if specified" do
92
+ for status_code in 0 .. 11
93
+ test_eq Codes.render_index(status_code), codes_rendered_index(status_code)
94
+ end
95
+ end
96
+
97
+ it "renders status index without selected code if unknown status code specified" do
98
+ test_eq Codes.render_index(100), codes_rendered_index(100)
99
+ end
100
+ end
101
+
102
+ #***************************************************************************
103
+ # Code construction
104
+
105
+ # Add a status code name to the global collection to receive unique status code
106
+ #
107
+ describe "#code" do
108
+
109
+ it "adds a non existing status code identifier to the global collection" do
110
+ Codes.code("my_code")
111
+
112
+ test_eq codes["my_code"], 12
113
+ test_eq codes[:my_code], 12
114
+ end
115
+
116
+ it "leaves an existing status code identifier in the global collection" do
117
+ Codes.code(:unknown_status)
118
+
119
+ test_eq codes["unknown_status"], 2
120
+ test_eq codes[:unknown_status], 2
121
+ end
122
+ end
123
+
124
+ # Add multiple status code names to the global collection to receive unique status codes
125
+ #
126
+ describe "#codes" do
127
+
128
+ it "adds non existing status code identifiers to the global collection" do
129
+ Codes.codes("my_code1", :batch_error, :my_code2, "success", "yay")
130
+
131
+ test_eq codes["my_code1"], 12
132
+ test_eq codes[:my_code1], 12
133
+ test_eq codes["batch_error"], 4
134
+ test_eq codes[:batch_error], 4
135
+ test_eq codes["my_code2"], 13
136
+ test_eq codes[:my_code2], 13
137
+ test_eq codes["success"], 0
138
+ test_eq codes[:success], 0
139
+ test_eq codes["yay"], 14
140
+ test_eq codes[:yay], 14
141
+ end
142
+ end
143
+
144
+ # Reset all status codes back to default in the global collection
145
+ #
146
+ describe "#reset" do
147
+
148
+ it "clears all custom codes and reverts registry to default state" do
149
+ Codes.codes("my_code1", :batch_error, :my_code2, "success", "yay")
150
+ Codes.reset
151
+
152
+ test_eq Codes.registry, codes_registry_clean
153
+ test_eq Codes.status_index, codes_status_index_clean
154
+ end
155
+ end
156
+
157
+
158
+ #***************************************************************************
159
+ # Code access
160
+
161
+ # Return the code for a specified code identifier
162
+ #
163
+ describe "#[]" do
164
+
165
+ it "returns an status code for an existing identifier" do
166
+ test_eq codes["ok"], 9
167
+ test_eq codes[:ok], 9
168
+ test_eq codes["batch_error"], 4
169
+ test_eq codes[:batch_error], 4
170
+ test_eq codes["whew"], 11
171
+ test_eq codes[:whew], 11
172
+ test_eq codes["success"], 0
173
+ test_eq codes[:success], 0
174
+ end
175
+
176
+ it "returns the unknown status code if no existing identifier" do
177
+ test_eq codes["not_ok"], 2
178
+ test_eq codes[:not_ok], 2
179
+ test_eq codes["batchy_error"], 2
180
+ test_eq codes[:batchy_error], 2
181
+ end
182
+ end
183
+
184
+ # Return the code for a specified code identifier
185
+ #
186
+ describe "#method_missing" do
187
+
188
+ it "returns the proper status code for existing identifier methods" do
189
+ test_eq codes.success, 0
190
+ test_eq codes.help_wanted, 1
191
+ test_eq codes.unknown_status, 2
192
+ test_eq codes.action_unprocessed, 3
193
+ test_eq codes.batch_error, 4
194
+ test_eq codes.validation_failed, 5
195
+ test_eq codes.access_denied, 6
196
+ test_eq codes.good, 7
197
+ test_eq codes.bad, 8
198
+ test_eq codes.ok, 9
199
+ test_eq codes.wow, 10
200
+ test_eq codes.whew, 11
201
+ end
202
+
203
+ it "returns the unknown status code for non existing identifier methods" do
204
+ test_eq codes.doesnt_exist, 2
205
+ test_eq codes.so_sorry, 2
206
+ end
207
+ end
208
+ end
209
+ end
@@ -0,0 +1,810 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ module Nucleon
5
+
6
+ describe Config do
7
+
8
+ include_context "nucleon_test"
9
+ include_context "nucleon_config"
10
+
11
+
12
+ #***************************************************************************
13
+
14
+ def config(*args, &code)
15
+ test_object(Config, *args, &code)
16
+ end
17
+
18
+
19
+ #***************************************************************************
20
+
21
+ let(:config_object) { config(config_hash2) }
22
+
23
+
24
+ #***************************************************************************
25
+ # Instance generators
26
+
27
+ # Ensure the return of a Nucleon::Config object based on different inputs.
28
+ #
29
+ describe "#ensure" do
30
+
31
+ it "creates with default values if nil given as the primary data source" do
32
+ test_config Config.ensure(nil, config_hash1, true, true), config_hash1
33
+ test_config Config.ensure(nil, config_hash1, true, false), config_hash1
34
+ test_config Config.ensure(nil, config_hash1, false, true), config_hash1
35
+ test_config Config.ensure(nil, config_hash1, false, false), config_hash1
36
+ end
37
+
38
+ it "creates via a basic merge of hash with forced overwrites" do
39
+ test_config Config.ensure(config_hash2, config_hash1, true, true), config_hash_force_basic_merge
40
+ end
41
+ it "creates via a deep merge of hash with forced overwrites" do
42
+ test_config Config.ensure(config_hash2, config_hash1, true, false), config_hash_force_deep_merge
43
+ end
44
+ it "creates via a basic merge of hash with no forced overwrites" do
45
+ test_config Config.ensure(config_hash2, config_hash1, false, true), config_hash_no_force_basic_merge
46
+ end
47
+ it "creates via a deep merge of hash with no forced overwrites" do
48
+ test_config Config.ensure(config_hash2, config_hash1, false, false), config_hash_no_force_deep_merge
49
+ end
50
+
51
+ it "creates via a basic merge of Config object with forced overwrites" do
52
+ config = Config.ensure(config_object, config_hash1, true, true)
53
+
54
+ test_config config, config_hash_force_basic_merge
55
+ test_eq config == config_object, true
56
+ end
57
+ it "creates via a deep merge of Config object with forced overwrites" do
58
+ config = Config.ensure(config_object, config_hash1, true, false)
59
+
60
+ test_config config, config_hash_force_deep_merge
61
+ test_eq config == config_object, true
62
+ end
63
+ it "creates via a basic merge of Config object with no forced overwrites" do
64
+ config = Config.ensure(config_object, config_hash1, false, true)
65
+
66
+ test_config config, config_hash_no_force_basic_merge
67
+ test_eq config == config_object, true
68
+ end
69
+ it "creates via a deep merge of Config object with no forced overwrites" do
70
+ config = Config.ensure(config_object, config_hash1, false, false)
71
+
72
+ test_config config, config_hash_no_force_deep_merge
73
+ test_eq config == config_object, true
74
+ end
75
+ end
76
+
77
+ # Initialize a new configuration object with contextualized defaults from the global configuration option collection.
78
+ #
79
+ describe "#init" do
80
+
81
+ it "creates with global contextual options only (multiple contexts, single hierarchy)" do
82
+ test_config Config.init(nil, config_contexts1, config_context_hierarchy1, {}, true, true), config_context_options1
83
+ end
84
+ it "creates with global contextual options only (multiple contexts, multiple hierarchies)" do
85
+ test_config Config.init(nil, config_contexts2, config_context_hierarchy2, {}, true, true), config_context_options2
86
+ end
87
+ it "creates with global contextual options only (single context, multiple hierarchies)" do
88
+ test_config Config.init(nil, config_contexts3, config_context_hierarchy3, {}, true, true), config_context_options3
89
+ end
90
+
91
+ it "creates via a basic merge of hash with forced overwrites (multiple contexts, single hierarchy)" do
92
+ test_config Config.init(config_hash1, config_contexts1, config_context_hierarchy1, config_context_default_data, true, true), config_hash_context1_force_basic_merge
93
+ end
94
+ it "creates via a deep merge of hash with forced overwrites (multiple contexts, single hierarchy)" do
95
+ test_config Config.init(config_hash1, config_contexts1, config_context_hierarchy1, config_context_default_data, true, false), config_hash_context1_force_deep_merge
96
+ end
97
+ it "creates via a basic merge of hash with no forced overwrites (multiple contexts, single hierarchy)" do
98
+ test_config Config.init(config_hash1, config_contexts1, config_context_hierarchy1, config_context_default_data, false, true), config_hash_context1_no_force_basic_merge
99
+ end
100
+ it "creates via a deep merge of hash with no forced overwrites (multiple contexts, single hierarchy)" do
101
+ test_config Config.init(config_hash1, config_contexts1, config_context_hierarchy1, config_context_default_data, false, false), config_hash_context1_no_force_deep_merge
102
+ end
103
+
104
+ it "creates via a basic merge of hash with forced overwrites (multiple contexts, multiple hierarchies)" do
105
+ test_config Config.init(config_hash1, config_contexts2, config_context_hierarchy2, config_context_default_data, true, true), config_hash_context2_force_basic_merge
106
+ end
107
+ it "creates via a deep merge of hash with forced overwrites (multiple contexts, multiple hierarchies)" do
108
+ test_config Config.init(config_hash1, config_contexts2, config_context_hierarchy2, config_context_default_data, true, false), config_hash_context2_force_deep_merge
109
+ end
110
+ it "creates via a basic merge of hash with no forced overwrites (multiple contexts, multiple hierarchies)" do
111
+ test_config Config.init(config_hash1, config_contexts2, config_context_hierarchy2, config_context_default_data, false, true), config_hash_context2_no_force_basic_merge
112
+ end
113
+ it "creates via a deep merge of hash with no forced overwrites (multiple contexts, multiple hierarchies)" do
114
+ test_config Config.init(config_hash1, config_contexts2, config_context_hierarchy2, config_context_default_data, false, false), config_hash_context2_no_force_deep_merge
115
+ end
116
+
117
+ it "creates via a basic merge of hash with forced overwrites (single context, multiple hierarchies)" do
118
+ test_config Config.init(config_hash1, config_contexts3, config_context_hierarchy3, config_context_default_data, true, true), config_hash_context3_force_basic_merge
119
+ end
120
+ it "creates via a deep merge of hash with forced overwrites (single context, multiple hierarchies)" do
121
+ test_config Config.init(config_hash1, config_contexts3, config_context_hierarchy3, config_context_default_data, true, false), config_hash_context3_force_deep_merge
122
+ end
123
+ it "creates via a basic merge of hash with no forced overwrites (single context, multiple hierarchies)" do
124
+ test_config Config.init(config_hash1, config_contexts3, config_context_hierarchy3, config_context_default_data, false, true), config_hash_context3_no_force_basic_merge
125
+ end
126
+ it "creates via a deep merge of hash with no forced overwrites (single contexts, multiple hierarchies)" do
127
+ test_config Config.init(config_hash1, config_contexts3, config_context_hierarchy3, config_context_default_data, false, false), config_hash_context3_no_force_deep_merge
128
+ end
129
+ end
130
+
131
+ # Initialize a new configuration object with contextualized defaults from the
132
+ # global configuration option collection (no hierarchical support).
133
+ #
134
+ describe "#init_flat" do
135
+
136
+ it "creates with global contextual options only (multiple contexts)" do
137
+ test_config Config.init_flat(nil, config_flat_contexts1, {}, true, true), config_flat_context_options1
138
+ end
139
+ it "creates with global contextual options only (single context)" do
140
+ test_config Config.init_flat(nil, config_flat_contexts2, {}, true, true), config_flat_context_options2
141
+ end
142
+ end
143
+
144
+
145
+ #***************************************************************************
146
+ # Constructor / Destructor
147
+
148
+ # Initialize a new Nucleon core object
149
+ #
150
+ describe "#initialize" do
151
+
152
+ it "creates with default values if nil given as the primary data source" do
153
+ test_config config(nil, config_hash1, true, true), config_hash1
154
+ test_config config(nil, config_hash1, true, false), config_hash1
155
+ test_config config(nil, config_hash1, false, true), config_hash1
156
+ test_config config(nil, config_hash1, false, false), config_hash1
157
+ end
158
+
159
+ it "creates via a basic merge of hash with forced overwrites" do
160
+ test_config config(config_hash2, config_hash1, true, true), config_hash_force_basic_merge
161
+ end
162
+ it "creates via a deep merge of hash with forced overwrites" do
163
+ test_config config(config_hash2, config_hash1, true, false), config_hash_force_deep_merge
164
+ end
165
+ it "creates via a basic merge of hash with no forced overwrites" do
166
+ test_config config(config_hash2, config_hash1, false, true), config_hash_no_force_basic_merge
167
+ end
168
+ it "creates via a deep merge of hash with no forced overwrites" do
169
+ test_config config(config_hash2, config_hash1, false, false), config_hash_no_force_deep_merge
170
+ end
171
+
172
+ it "creates via a basic merge of Config object with forced overwrites" do
173
+ test_config config(config_object, config_hash1, true, true), config_hash_force_basic_merge
174
+ end
175
+ it "creates via a deep merge of Config object with forced overwrites" do
176
+ test_config config(config_object, config_hash1, true, false), config_hash_force_deep_merge
177
+ end
178
+ it "creates via a basic merge of Config object with no forced overwrites" do
179
+ test_config config(config_object, config_hash1, false, true), config_hash_no_force_basic_merge
180
+ end
181
+ it "creates via a deep merge of Config object with no forced overwrites" do
182
+ test_config config(config_object, config_hash1, false, false), config_hash_no_force_deep_merge
183
+ end
184
+ end
185
+
186
+
187
+ #***************************************************************************
188
+ # Checks
189
+
190
+ # Check whether or not this configuration object is empty.
191
+ #
192
+ describe "#empty?" do
193
+
194
+ it "returns false if properties are in the configuration object" do
195
+ test_eq config(config_hash1, {}, true, true).empty?, false
196
+ end
197
+
198
+ it "returns true if the configuration object is empty" do
199
+ test_eq config(nil, {}, true, true).empty?, true
200
+ end
201
+ end
202
+
203
+ # Check whether or not this configuration object has a specific key.
204
+ #
205
+ describe "#has_key?" do
206
+
207
+ it "is true if a top level key exists in the configuration object" do
208
+ config(config_hash1, {}, true, true) do |config|
209
+ test_eq config.has_key?("testkey"), true
210
+ test_eq config.has_key?(:testkey), true
211
+ end
212
+ end
213
+ it "is true if a nested key exists in the configuration object" do
214
+ config(config_hash1, {}, true, true) do |config|
215
+ test_eq config.has_key?([ "nestedkey", "a", "test1" ]), true
216
+ test_eq config.has_key?([ :nestedkey, :a, :test1 ]), true
217
+ test_eq config.has_key?([ "nestedkey", "a", :test1 ]), true
218
+ test_eq config.has_key?([ :nestedkey, nil, :a, nil, :test1, nil ]), true
219
+ end
220
+ end
221
+
222
+ it "is false if a top level key does not exist in the configuration object" do
223
+ config(config_hash1, {}, true, true) do |config|
224
+ test_eq config.has_key?("some_non_existent_key"), false
225
+ test_eq config.has_key?(:some_non_existent_key), false
226
+ end
227
+ end
228
+ it "is false if a nested key does not exist in the configuration object" do
229
+ config(config_hash1, {}, true, true) do |config|
230
+ test_eq config.has_key?([ "nestedkey", "test5" ]), false
231
+ test_eq config.has_key?([ :nestedkey, :test5 ]), false
232
+ test_eq config.has_key?([ "nestedkey", :test5 ]), false
233
+ test_eq config.has_key?([ :nestedkey, nil, :test5, nil ]), false
234
+ end
235
+ end
236
+ end
237
+
238
+
239
+ #***************************************************************************
240
+ # Property accessors / modifiers
241
+
242
+ # Return all of the keys for the configuration properties hash.
243
+ #
244
+ describe "#keys" do
245
+
246
+ it "returns the top level property keys in the configuration object" do
247
+ test_eq config(config_hash1, {}, true, true).keys, [ :testkey, :nestedkey, :other, :array ]
248
+ test_eq config(config_hash2, {}, true, true).keys, [ :testkey1, :nestedkey, :other, :array ]
249
+ end
250
+ end
251
+
252
+ # Fetch value for key path in the configuration object.
253
+ #
254
+ describe "#get" do
255
+
256
+ it "returns an existing value for a top level property from the configuration object if it exists" do
257
+ test_eq config(config_hash1, {}, true, true).get(:testkey, nil, false), 'testval'
258
+ test_eq config(config_hash2, {}, true, true).get(:testkey1, nil, false), 'testval1'
259
+ end
260
+ it "returns an existing value for a nested property from the configuration object if it exists" do
261
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, :test2 ], nil, false), [ 'no' ]
262
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, nil, :y, nil ], nil, false), 'again'
263
+ test_eq config(config_hash2, {}, true, true).get([ :nestedkey, :a, :test1 ], nil, false), 'oh'
264
+ test_eq config(config_hash2, {}, true, true).get([ :nestedkey, :a, nil, :test3, nil ], nil, false), true
265
+ end
266
+
267
+ it "returns a default value for a top level property from the configuration object if it does not exist" do
268
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, false, false), false
269
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, 'string', false), 'string'
270
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, :symbol, false), :symbol
271
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, [ :a, :b, :c ], false), [ :a, :b, :c ]
272
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, { :a => :b }, false), { :a => :b }
273
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, false, :test), false
274
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, '42', :test), true
275
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, 'string', :string), 'string'
276
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, :string, :string), 'string'
277
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, :symbol, :symbol), :symbol
278
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, 'symbol', :symbol), :symbol
279
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, [ :a, :b, :c ], :array), [ :a, :b, :c ]
280
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, :a, :array), [ :a ]
281
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, { :a => :b }, :hash), { :a => :b }
282
+ test_eq config(config_hash1, {}, true, true).get(:testkey15, nil, :hash), {}
283
+ end
284
+ it "returns a default value for a nested property from the configuration object if it does not exist" do
285
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], false, false), false
286
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], 'string', false), 'string'
287
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], :symbol, false), :symbol
288
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], [ :a, :b, :c ], false), [ :a, :b, :c ]
289
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], { :a => :b }, false), { :a => :b }
290
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], false, :test), false
291
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], '42', :test), true
292
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], 'string', :string), 'string'
293
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], :string, :string), 'string'
294
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], :symbol, :symbol), :symbol
295
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], 'symbol', :symbol), :symbol
296
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], [ :a, :b, :c ], :array), [ :a, :b, :c ]
297
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], :a, :array), [ :a ]
298
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], { :a => :b }, :hash), { :a => :b }
299
+ test_eq config(config_hash1, {}, true, true).get([ :nestedkey, :a, nil, :unknown ], nil, :hash), {}
300
+ end
301
+ end
302
+
303
+ # Fetch value for key path in the configuration object.
304
+ #
305
+ describe "#[]" do
306
+
307
+ it "returns an existing value for a top level property from the configuration object if it exists" do
308
+ test_eq config(config_hash1, {}, true, true)[:testkey, nil, false], 'testval'
309
+ test_eq config(config_hash2, {}, true, true)[:testkey1, nil, false], 'testval1'
310
+ end
311
+
312
+ it "returns a default value for a top level property from the configuration object if it does not exist" do
313
+ test_eq config(config_hash1, {}, true, true)[:testkey15, false, false], false
314
+ test_eq config(config_hash1, {}, true, true)[:testkey15, 'string', false], 'string'
315
+ test_eq config(config_hash1, {}, true, true)[:testkey15, :symbol, false], :symbol
316
+ test_eq config(config_hash1, {}, true, true)[:testkey15, [ :a, :b, :c ], false], [ :a, :b, :c ]
317
+ test_eq config(config_hash1, {}, true, true)[:testkey15, { :a => :b }, false], { :a => :b }
318
+ test_eq config(config_hash1, {}, true, true)[:testkey15, false, :test], false
319
+ test_eq config(config_hash1, {}, true, true)[:testkey15, '42', :test], true
320
+ test_eq config(config_hash1, {}, true, true)[:testkey15, 'string', :string], 'string'
321
+ test_eq config(config_hash1, {}, true, true)[:testkey15, :string, :string], 'string'
322
+ test_eq config(config_hash1, {}, true, true)[:testkey15, :symbol, :symbol], :symbol
323
+ test_eq config(config_hash1, {}, true, true)[:testkey15, 'symbol', :symbol], :symbol
324
+ test_eq config(config_hash1, {}, true, true)[:testkey15, [ :a, :b, :c ], :array], [ :a, :b, :c ]
325
+ test_eq config(config_hash1, {}, true, true)[:testkey15, :a, :array], [ :a ]
326
+ test_eq config(config_hash1, {}, true, true)[:testkey15, { :a => :b }, :hash], { :a => :b }
327
+ test_eq config(config_hash1, {}, true, true)[:testkey15, nil, :hash], {}
328
+ end
329
+ end
330
+
331
+ # Fetch filtered array value for key path in the configuration object.
332
+ #
333
+ describe "#get_array" do
334
+
335
+ it "returns an existing array for a top level property from the configuration object if it exists" do
336
+ test_eq config(config_hash1, {}, true, true).get_array(:testkey, []), [ 'testval' ]
337
+ test_eq config(config_hash2, {}, true, true).get_array(:testkey1, []), [ 'testval1' ]
338
+ end
339
+ it "returns an existing array for a nested property from the configuration object if it exists" do
340
+ test_eq config(config_hash1, {}, true, true).get_array([ :nestedkey, :a, :test2 ], []), [ 'no' ]
341
+ test_eq config(config_hash1, {}, true, true).get_array([ :nestedkey, nil, :y, nil ], []), [ 'again' ]
342
+ test_eq config(config_hash2, {}, true, true).get_array([ :nestedkey, :a, :test1 ], []), [ 'oh' ]
343
+ test_eq config(config_hash2, {}, true, true).get_array([ :nestedkey, :a, nil, :test3, nil ], []), [ true ]
344
+ end
345
+
346
+ it "returns a default array for a top level property from the configuration object if it does not exist" do
347
+ test_eq config(config_hash1, {}, true, true).get_array(:testkey15, [ :a, :b, :c ]), [ :a, :b, :c ]
348
+ test_eq config(config_hash1, {}, true, true).get_array(:testkey15, :a), [ :a ]
349
+ end
350
+ it "returns a default array for a nested property from the configuration object if it does not exist" do
351
+ test_eq config(config_hash1, {}, true, true).get_array([ :nestedkey, :a, nil, :unknown ], [ :a, :b, :c ]), [ :a, :b, :c ]
352
+ test_eq config(config_hash1, {}, true, true).get_array([ :nestedkey, :a, nil, :unknown ], :a), [ :a ]
353
+ end
354
+ end
355
+
356
+ # Fetch filtered hash value for key path in the configuration object.
357
+ #
358
+ describe "#get_hash" do
359
+
360
+ it "returns an existing hash for a top level property from the configuration object if it exists" do
361
+ test_eq config(config_hash1, {}, true, true).get_hash(:nestedkey, {}), {
362
+ :a => {
363
+ :test1 => 'oh',
364
+ :test2 => [ 'no' ]
365
+ },
366
+ :x => 'hello',
367
+ :y => 'again',
368
+ :z => 'im done now'
369
+ }
370
+ test_eq config(config_hash2, {}, true, true).get_hash(:nestedkey, {}), {
371
+ :a => {
372
+ :test1 => 'oh',
373
+ :test2 => [ 'yes' ],
374
+ :test3 => true
375
+ },
376
+ :z => 'whew'
377
+ }
378
+ end
379
+ it "returns an existing hash for a nested property from the configuration object if it exists" do
380
+ test_eq config(config_hash1, {}, true, true).get_hash([ :nestedkey, :a ], {}), { :test1 => 'oh', :test2 => [ 'no' ] }
381
+ test_eq config(config_hash1, {}, true, true).get_hash([ :nestedkey, nil, :y, nil ], {}), {}
382
+ test_eq config(config_hash2, {}, true, true).get_hash([ :nestedkey, :a ], {}), { :test1 => 'oh', :test2 => [ 'yes' ], :test3 => true }
383
+ test_eq config(config_hash2, {}, true, true).get_hash([ :nestedkey, :a, nil, :test3, nil ], {}), {}
384
+ end
385
+
386
+ it "returns a default hash for a top level property from the configuration object if it does not exist" do
387
+ test_eq config(config_hash1, {}, true, true).get_hash(:testkey15, { :a => :b }), { :a => :b }
388
+ test_eq config(config_hash1, {}, true, true).get_hash(:testkey15, nil), {}
389
+ end
390
+ it "returns a default hash for a nested property from the configuration object if it does not exist" do
391
+ test_eq config(config_hash1, {}, true, true).get_hash([ :nestedkey, :a, nil, :unknown ], { :a => :b }), { :a => :b }
392
+ test_eq config(config_hash1, {}, true, true).get_hash([ :nestedkey, :a, nil, :unknown ], nil), {}
393
+ end
394
+ end
395
+
396
+ # Initialize value for key path in the configuration object if one does not
397
+ # exist yet.
398
+ #
399
+ describe "#init" do
400
+
401
+ it "sets a top level configuration property that does not exist yet" do
402
+ test_eq config(config_hash1, {}, true, true).init(:other_property, 'testing').get(:other_property), 'testing'
403
+ test_eq config(config_hash2, {}, true, true).init(:new_property, 'testing2').get(:new_property), 'testing2'
404
+ end
405
+ it "sets a nested configuration property that does not exist yet" do
406
+ test_eq config(config_hash1, {}, true, true).init([ :nested_property, :abc ], [ 1, 2, 3 ]).get([ :nested_property, :abc ]), [ 1, 2, 3 ]
407
+ test_eq config(config_hash2, {}, true, true).init([ :nested_property, :abc ], [ 1, 2, 3 ]).get([ :nested_property, :abc ]), [ 1, 2, 3 ]
408
+ end
409
+
410
+ it "leaves a top level configuration property untouched if it already exists" do
411
+ test_eq config(config_hash1, {}, true, true).init(:other, 'testing').get(:other), [ 1, 2, 3, 4 ]
412
+ test_eq config(config_hash2, {}, true, true).init(:other, 'testing').get(:other), 56
413
+ end
414
+ it "leaves a nested configuration property untouched if it already exists" do
415
+ test_eq config(config_hash1, {}, true, true).init([ :nestedkey, :a ], { :a => :b }).get([ :nestedkey, :a ]), { :test1 => 'oh', :test2 => [ 'no' ] }
416
+ test_eq config(config_hash2, {}, true, true).init([ :nestedkey, :a ], { :a => :b }).get([ :nestedkey, :a ]), { :test1 => 'oh', :test2 => [ 'yes' ], :test3 => true }
417
+ end
418
+ end
419
+
420
+ # Set value for key path in the configuration object.
421
+ #
422
+ describe "#set" do
423
+
424
+ it "creates a configuration property with a specified value" do
425
+ test_eq config(config_hash1, {}, true, true).set("other_property", "onething", false).get(:other_property), 'onething'
426
+ test_eq config(config_hash2, {}, true, true).set(:other_property, { "a" => :b }, false).get([ :other_property, :a ]), :b
427
+ end
428
+
429
+ it "updates a configuration property with a specified value" do
430
+ test_eq config(config_hash1, {}, true, true).set("other", "onething", false).get(:other), 'onething'
431
+ test_eq config(config_hash2, {}, true, true).set(:nestedkey, { "a" => :b }, false).get([ :nestedkey, :a ]), :b
432
+ end
433
+
434
+ it "removes a configuration property containing a nil value" do
435
+ test_eq config(config_hash1, {}, true, true).set(:array, nil, true).keys, [ :testkey, :nestedkey, :other ]
436
+ test_eq config(config_hash2, {}, true, true).set(:array, nil, true).keys, [ :testkey1, :nestedkey, :other ]
437
+ end
438
+ end
439
+
440
+ # Append a value for key path in the configuration object.
441
+ #
442
+ describe "#append" do
443
+
444
+ it "appends values to a configuration property" do
445
+ config do |config|
446
+ config.append([ :my, :sequence ], 1)
447
+ config.append([ :my, :sequence ], 3)
448
+ config.append([ :my, :sequence ], 5)
449
+ config.append([ :my, :sequence ], 7)
450
+ test_eq config.get([ :my, :sequence]), [ 1, 3, 5, 7 ]
451
+ end
452
+
453
+ config do |config|
454
+ config.append([ "my", :sequence ], [ 1, 2 ])
455
+ config.append([ :my, :sequence ], 3)
456
+ config.append([ :my, :sequence ], [ 5, 5.5, 18 ])
457
+ config.append([ :my, "sequence" ], 7)
458
+ test_eq config.get([ :my, "sequence" ]), [ 1, 2, 3, 5, 5.5, 18, 7 ]
459
+ end
460
+ end
461
+ end
462
+
463
+ # Prepend a value for key path in the configuration object.
464
+ #
465
+ describe "#prepend" do
466
+
467
+ it "prepends values to a configuration property" do
468
+ config do |config|
469
+ config.prepend([ :my, :sequence ], 1)
470
+ config.prepend([ :my, :sequence ], 3)
471
+ config.prepend([ :my, :sequence ], 5)
472
+ config.prepend([ :my, :sequence ], 7)
473
+ test_eq config.get([ :my, :sequence]), [ 7, 5, 3, 1 ]
474
+ end
475
+
476
+ config do |config|
477
+ config.prepend([ "my", :sequence ], [ 1, 2 ])
478
+ config.prepend([ :my, :sequence, nil ], 3)
479
+ config.prepend([ :my, :sequence ], [ 5, 5.5, 18 ])
480
+ config.prepend([ :my, "sequence" ], 7)
481
+ test_eq config.get([ :my, "sequence" ]), [ 7, 5, 5.5, 18, 3, 1, 2 ]
482
+ end
483
+ end
484
+
485
+ it "prepends values to a configuration property with reversed arrays" do
486
+ config do |config|
487
+ config.prepend([ "my", :sequence ], [ 1, 2 ], true)
488
+ config.prepend([ :my, :sequence ], 3)
489
+ config.prepend([ :my, :sequence ], [ 5, 5.5, 18 ], true)
490
+ config.prepend([ :my, "sequence" ], 7)
491
+ test_eq config.get([ :my, "sequence" ]), [ 7, 18, 5.5, 5, 3, 2, 1 ]
492
+ end
493
+
494
+ config do |config|
495
+ config.prepend([ "my", :sequence ], [ 1, 2 ], true)
496
+ config.prepend([ :my, nil, :sequence ], 3)
497
+ config.prepend([ :my, :sequence ], [ 5, 5.5, 18 ], false)
498
+ config.prepend([ :my, "sequence" ], 7)
499
+ test_eq config.get([ :my, "sequence" ]), [ 7, 5, 5.5, 18, 3, 2, 1 ]
500
+ end
501
+ end
502
+ end
503
+
504
+ # Set value for key in the configuration object.
505
+ #
506
+ describe "#[]=" do
507
+
508
+ it "creates a configuration property with a specified value" do
509
+ config(config_hash1, {}, true, true) do |config|
510
+ config["other_property"] = "onething"
511
+ test_eq config.get(:other_property), 'onething'
512
+ end
513
+
514
+ config(config_hash2, {}, true, true) do |config|
515
+ config[:other_property] = { "a" => :b }
516
+ test_eq config.get([ :other_property, :a ]), :b
517
+ end
518
+ end
519
+
520
+ it "updates a configuration property with a specified value" do
521
+ config(config_hash1, {}, true, true) do |config|
522
+ config["other"] = "onething"
523
+ test_eq config.get(:other), 'onething'
524
+ end
525
+
526
+ config(config_hash2, {}, true, true) do |config|
527
+ config[:nestedkey] = { "a" => :b }
528
+ test_eq config.get([ :nestedkey, :a ]), :b
529
+ end
530
+ end
531
+ end
532
+
533
+ # Delete key path from the configuration object.
534
+ #
535
+ describe "#delete" do
536
+
537
+ it "removes a configuration property and returns existing value" do
538
+ config(config_hash1, {}, true, true) do |config|
539
+ test_eq config.delete(:other, nil), [ 1, 2, 3, 4 ]
540
+ test_eq config.keys, [ :testkey, :nestedkey, :array ]
541
+ end
542
+
543
+ config(config_hash2, {}, true, true) do |config|
544
+ test_eq config.delete(:array, nil), [ 12 ]
545
+ test_eq config.keys, [ :testkey1, :nestedkey, :other ]
546
+ end
547
+ end
548
+
549
+ it "returns a default value if configuration property doesn't exist" do
550
+ test_eq config(config_hash1, {}, true, true).delete(:test57, :yummy), :yummy
551
+ test_eq config(config_hash2, {}, true, true).delete(:test57, [ 1, 2, 3 ]), [ 1, 2, 3 ]
552
+ end
553
+ end
554
+
555
+ # Clear all properties from the configuration object.
556
+ #
557
+ describe "#clear" do
558
+
559
+ it "removes all the configuration properties from the object" do
560
+ test_config config(config_hash1, {}, true, true).clear, {}
561
+ test_config config(config_hash2, {}, true, true).clear, {}
562
+ end
563
+ end
564
+
565
+
566
+ #***************************************************************************
567
+ # Import / Export
568
+
569
+ # Import new property values into the configuration object. (override)
570
+ #
571
+ describe "#import" do
572
+
573
+ # TODO: String and symbol lookup conditions (used in CORL)
574
+
575
+ it "imports properties via a basic merge of hash with forced overwrites" do
576
+ test_config config({}, {}, true, true).import([ config_hash1, config_hash2 ]), config_hash_force_basic_merge
577
+ test_config config(config_hash1, {}, true, true).import(config_hash2), config_hash_force_basic_merge
578
+ test_config config(config_hash1, {}, false, false).import(config_hash2, { :force => true, :basic => true }), config_hash_force_basic_merge
579
+ end
580
+ it "imports properties via a deep merge of hash with forced overwrites" do
581
+ test_config config({}, {}, true, false).import([ config_hash1, config_hash2 ]), config_hash_force_deep_merge
582
+ test_config config(config_hash1, {}, true, false).import(config_hash2), config_hash_force_deep_merge
583
+ test_config config(config_hash1, {}, false, true).import(config_hash2, { :force => true, :basic => false }), config_hash_force_deep_merge
584
+ end
585
+ it "imports properties via a basic merge of hash with no forced overwrites" do
586
+ test_config config({}, {}, false, true).import([ config_hash1, config_hash2 ]), config_hash_no_force_basic_merge
587
+ test_config config(config_hash1, {}, false, true).import(config_hash2), config_hash_no_force_basic_merge
588
+ test_config config(config_hash1, {}, true, false).import(config_hash2, { :force => false, :basic => true }), config_hash_no_force_basic_merge
589
+ end
590
+ it "imports properties via a deep merge of hash with no forced overwrites" do
591
+ test_config config({}, {}, false, false).import([ config_hash1, config_hash2 ]), config_hash_no_force_deep_merge
592
+ test_config config(config_hash1, {}, false, false).import(config_hash2), config_hash_no_force_deep_merge
593
+ test_config config(config_hash1, {}, true, true).import(config_hash2, { :force => false, :basic => false }), config_hash_no_force_deep_merge
594
+ end
595
+
596
+ it "imports properties via a basic merge of Config object with forced overwrites" do
597
+ test_config config({}, {}, true, true).import([ config_hash1, config_object ]), config_hash_force_basic_merge
598
+ test_config config(config_hash1, {}, true, true).import(config_object), config_hash_force_basic_merge
599
+ test_config config(config_hash1, {}, false, false).import(config_object, { :force => true, :basic => true }), config_hash_force_basic_merge
600
+ end
601
+ it "imports properties via a deep merge of Config object with forced overwrites" do
602
+ test_config config({}, {}, true, false).import([ config_hash1, config_object ]), config_hash_force_deep_merge
603
+ test_config config(config_hash1, {}, true, false).import(config_object), config_hash_force_deep_merge
604
+ test_config config(config_hash1, {}, false, true).import(config_object, { :force => true, :basic => false }), config_hash_force_deep_merge
605
+ end
606
+ it "imports properties via a basic merge of Config object with no forced overwrites" do
607
+ test_config config({}, {}, false, true).import([ config_hash1, config_object ]), config_hash_no_force_basic_merge
608
+ test_config config(config_hash1, {}, false, true).import(config_object), config_hash_no_force_basic_merge
609
+ test_config config(config_hash1, {}, true, false).import(config_object, { :force => false, :basic => true }), config_hash_no_force_basic_merge
610
+ end
611
+ it "imports properties via a deep merge of Config object with no forced overwrites" do
612
+ test_config config({}, {}, false, false).import([ config_hash1, config_object ]), config_hash_no_force_deep_merge
613
+ test_config config(config_hash1, {}, false, false).import(config_object), config_hash_no_force_deep_merge
614
+ test_config config(config_hash1, {}, true, true).import(config_object, { :force => false, :basic => false }), config_hash_no_force_deep_merge
615
+ end
616
+ end
617
+
618
+ # Set default property values in the configuration object if they don't exist.
619
+ #
620
+ describe "#defaults" do
621
+
622
+ # TODO: String and symbol lookup conditions (used in CORL)
623
+
624
+ it "imports default properties via a basic merge of hash with forced overwrites" do
625
+ test_config config({}, {}, true, true).defaults([ config_hash2, config_hash1 ]), config_hash_force_basic_merge
626
+ test_config config(config_hash2, {}, true, true).defaults(config_hash1), config_hash_force_basic_merge
627
+ test_config config(config_hash2, {}, false, false).defaults(config_hash1, { :force => true, :basic => true }), config_hash_force_basic_merge
628
+ end
629
+ it "imports default properties via a deep merge of hash with forced overwrites" do
630
+ test_config config({}, {}, true, false).defaults([ config_hash2, config_hash1 ]), config_hash_force_deep_merge
631
+ test_config config(config_hash2, {}, true, false).defaults(config_hash1), config_hash_force_deep_merge
632
+ test_config config(config_hash2, {}, false, true).defaults(config_hash1, { :force => true, :basic => false }), config_hash_force_deep_merge
633
+ end
634
+ it "imports default properties via a basic merge of hash with no forced overwrites" do
635
+ test_config config({}, {}, false, true).defaults([ config_hash2, config_hash1 ]), config_hash_no_force_basic_merge
636
+ test_config config(config_hash2, {}, false, true).defaults(config_hash1), config_hash_no_force_basic_merge
637
+ test_config config(config_hash2, {}, true, false).defaults(config_hash1, { :force => false, :basic => true }), config_hash_no_force_basic_merge
638
+ end
639
+ it "imports default properties via a deep merge of hash with no forced overwrites" do
640
+ test_config config({}, {}, false, false).defaults([ config_hash2, config_hash1 ]), config_hash_no_force_deep_merge
641
+ test_config config(config_hash2, {}, false, false).defaults(config_hash1), config_hash_no_force_deep_merge
642
+ test_config config(config_hash2, {}, true, true).defaults(config_hash1, { :force => false, :basic => false }), config_hash_no_force_deep_merge
643
+ end
644
+
645
+ it "imports default properties via a basic merge of Config object with forced overwrites" do
646
+ test_config config({}, {}, true, true).defaults([ config_object, config_hash1 ]), config_hash_force_basic_merge
647
+ test_config config(config_object, {}, true, true).defaults(config_hash1), config_hash_force_basic_merge
648
+ test_config config(config_object, {}, false, false).defaults(config_hash1, { :force => true, :basic => true }), config_hash_force_basic_merge
649
+ end
650
+ it "imports default properties via a deep merge of Config object with forced overwrites" do
651
+ test_config config({}, {}, true, false).defaults([ config_object, config_hash1 ]), config_hash_force_deep_merge
652
+ test_config config(config_object, {}, true, false).defaults(config_hash1), config_hash_force_deep_merge
653
+ test_config config(config_object, {}, false, true).defaults(config_hash1, { :force => true, :basic => false }), config_hash_force_deep_merge
654
+ end
655
+ it "imports default properties via a basic merge of Config object with no forced overwrites" do
656
+ test_config config({}, {}, false, true).defaults([ config_object, config_hash1 ]), config_hash_no_force_basic_merge
657
+ test_config config(config_object, {}, false, true).defaults(config_hash1), config_hash_no_force_basic_merge
658
+ test_config config(config_object, {}, true, false).defaults(config_hash1, { :force => false, :basic => true }), config_hash_no_force_basic_merge
659
+ end
660
+ it "imports default properties via a deep merge of Config object with no forced overwrites" do
661
+ test_config config({}, {}, false, false).defaults([ config_object, config_hash1 ]), config_hash_no_force_deep_merge
662
+ test_config config(config_object, {}, false, false).defaults(config_hash1), config_hash_no_force_deep_merge
663
+ test_config config(config_object, {}, true, true).defaults(config_hash1, { :force => false, :basic => false }), config_hash_no_force_deep_merge
664
+ end
665
+ end
666
+
667
+ # Export properties into a regular hash object (cloned)
668
+ #
669
+ describe "#export" do
670
+
671
+ it "returns all configuration properties as a symbolized hash" do
672
+ test_config config(config_hash1, {}, true, true), config_hash1
673
+ test_config config(config_hash2, {}, true, true), config_hash2
674
+ end
675
+ end
676
+
677
+
678
+ #***************************************************************************
679
+ # Utilities
680
+
681
+ # Return hash as a symbol map.
682
+ #
683
+ describe "#symbol_map" do
684
+
685
+ it "returns a hash with recursively symbolized keys" do
686
+ test_eq Config.symbol_map(config_mixed_hash), config_symbolized_hash
687
+ end
688
+ end
689
+
690
+ # Return hash as a string map.
691
+ #
692
+ describe "#string_map" do
693
+
694
+ it "returns a hash with recursively stringified keys" do
695
+ test_eq Config.string_map(config_mixed_hash), config_stringified_hash
696
+ end
697
+ end
698
+
699
+
700
+ #***************************************************************************
701
+
702
+ # Run a defined filter on a data object.
703
+ #
704
+ describe "#filter" do
705
+
706
+ it "returns given value when not filtered" do
707
+ test_eq Config.filter(true, false), true
708
+ test_eq Config.filter("string", false), "string"
709
+ test_eq Config.filter(:symbol, false), :symbol
710
+ test_eq Config.filter([ "test", "array" ], false), [ "test", "array" ]
711
+ test_eq Config.filter({ :a => :b }, false), { :a => :b }
712
+ end
713
+ it "returns a boolean when filtered for a test condition" do
714
+ test_eq Config.filter(2 == 2, :test), true
715
+ test_eq Config.filter(2 == 5, :test), false
716
+ test_eq Config.filter("hello", :test), true
717
+ test_eq Config.filter([ '1' ], :test), true
718
+ test_eq Config.filter([], :test), false
719
+ test_eq Config.filter({ "a" => "b" }, :test), true
720
+ test_eq Config.filter({}, :test), false
721
+ end
722
+ it "returns a string when filtered for a string" do
723
+ test_eq Config.filter("string", :string), "string"
724
+ test_eq Config.filter(:symbol, :string), "symbol"
725
+ test_eq Config.filter(true, :string), "true"
726
+ test_eq Config.filter([ 1, 2, 3 ], :string), "[1, 2, 3]"
727
+ test_eq Config.filter({ :a => :b }, :string), "{:a=>:b}"
728
+ end
729
+ it "returns a symbol when filtered for a symbol" do
730
+ test_eq Config.filter("string", :symbol), :string
731
+ test_eq Config.filter(:symbol, :symbol), :symbol
732
+ test_eq Config.filter(true, :symbol), :true
733
+ end
734
+ it "returns an array when filtered for a array" do
735
+ test_eq Config.filter(nil, :array), []
736
+ test_eq Config.filter("test", :array), [ "test" ]
737
+ test_eq Config.filter([ "test", "array" ], :array), [ "test", "array" ]
738
+ end
739
+ it "returns a hash when filtered for a hash" do
740
+ test_eq Config.filter(nil, :hash), {}
741
+ test_eq Config.filter("test", :hash), {}
742
+ test_eq Config.filter({ :a => :b }, :hash), { :a => :b }
743
+ end
744
+ end
745
+
746
+
747
+ #***************************************************************************
748
+
749
+ # Ensure a data object is an array.
750
+ #
751
+ describe "#array" do
752
+
753
+ it "returns a filtered array" do
754
+ test_eq Config.filter(nil, :array), []
755
+ test_eq Config.filter("test", :array), [ "test" ]
756
+ test_eq Config.filter([ "test", "array" ], :array), [ "test", "array" ]
757
+ end
758
+ end
759
+
760
+ # Ensure a data object is a hash.
761
+ #
762
+ describe "#hash" do
763
+
764
+ it "returns a filtered hash" do
765
+ test_eq Config.filter(nil, :hash), {}
766
+ test_eq Config.filter("test", :hash), {}
767
+ test_eq Config.filter({ :a => :b }, :hash), { :a => :b }
768
+ end
769
+ end
770
+
771
+ # Ensure a data object is a string.
772
+ #
773
+ describe "#string" do
774
+
775
+ it "returns a filtered string" do
776
+ test_eq Config.filter("string", :string), "string"
777
+ test_eq Config.filter(:symbol, :string), "symbol"
778
+ test_eq Config.filter(true, :string), "true"
779
+ test_eq Config.filter([ 1, 2, 3 ], :string), "[1, 2, 3]"
780
+ test_eq Config.filter({ :a => :b }, :string), "{:a=>:b}"
781
+ end
782
+ end
783
+
784
+ # Ensure a data object is a symbol.
785
+ #
786
+ describe "#symbol" do
787
+
788
+ it "returns a filtered symbol" do
789
+ test_eq Config.filter("string", :symbol), :string
790
+ test_eq Config.filter(:symbol, :symbol), :symbol
791
+ test_eq Config.filter(true, :symbol), :true
792
+ end
793
+ end
794
+
795
+ # Test a data object for emptiness and return boolean result.
796
+ #
797
+ describe "#test" do
798
+
799
+ it "returns a filtered boolean" do
800
+ test_eq Config.filter(2 == 2, :test), true
801
+ test_eq Config.filter(2 == 5, :test), false
802
+ test_eq Config.filter("hello", :test), true
803
+ test_eq Config.filter([ '1' ], :test), true
804
+ test_eq Config.filter([], :test), false
805
+ test_eq Config.filter({ "a" => "b" }, :test), true
806
+ test_eq Config.filter({}, :test), false
807
+ end
808
+ end
809
+ end
810
+ end