cliutils 1.0.0

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 (96) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +48 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +288 -0
  8. data/README.rdoc +19 -0
  9. data/Rakefile +45 -0
  10. data/bin/cliutils +38 -0
  11. data/cliutils.gemspec +28 -0
  12. data/features/cli_manager.feature +13 -0
  13. data/features/step_definitions/cli_manager_steps.rb +1 -0
  14. data/features/support/env.rb +16 -0
  15. data/html/CLIUtils/Configuration.html +271 -0
  16. data/html/CLIUtils/Configurator.html +504 -0
  17. data/html/CLIUtils/LoggerDelegator.html +344 -0
  18. data/html/CLIUtils/Messenging.html +284 -0
  19. data/html/CLIUtils/Prefs.html +330 -0
  20. data/html/CLIUtils/PrettyIO.html +799 -0
  21. data/html/CLIUtils.html +112 -0
  22. data/html/Hash.html +453 -0
  23. data/html/Logger.html +183 -0
  24. data/html/Object.html +120 -0
  25. data/html/README_md.html +454 -0
  26. data/html/String.html +413 -0
  27. data/html/created.rid +13 -0
  28. data/html/fonts/Lato-Light.ttf +0 -0
  29. data/html/fonts/Lato-LightItalic.ttf +0 -0
  30. data/html/fonts/Lato-Regular.ttf +0 -0
  31. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  32. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  33. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  34. data/html/fonts.css +167 -0
  35. data/html/images/add.png +0 -0
  36. data/html/images/arrow_up.png +0 -0
  37. data/html/images/brick.png +0 -0
  38. data/html/images/brick_link.png +0 -0
  39. data/html/images/bug.png +0 -0
  40. data/html/images/bullet_black.png +0 -0
  41. data/html/images/bullet_toggle_minus.png +0 -0
  42. data/html/images/bullet_toggle_plus.png +0 -0
  43. data/html/images/date.png +0 -0
  44. data/html/images/delete.png +0 -0
  45. data/html/images/find.png +0 -0
  46. data/html/images/loadingAnimation.gif +0 -0
  47. data/html/images/macFFBgHack.png +0 -0
  48. data/html/images/package.png +0 -0
  49. data/html/images/page_green.png +0 -0
  50. data/html/images/page_white_text.png +0 -0
  51. data/html/images/page_white_width.png +0 -0
  52. data/html/images/plugin.png +0 -0
  53. data/html/images/ruby.png +0 -0
  54. data/html/images/tag_blue.png +0 -0
  55. data/html/images/tag_green.png +0 -0
  56. data/html/images/transparent.png +0 -0
  57. data/html/images/wrench.png +0 -0
  58. data/html/images/wrench_orange.png +0 -0
  59. data/html/images/zoom.png +0 -0
  60. data/html/index.html +455 -0
  61. data/html/js/darkfish.js +140 -0
  62. data/html/js/jquery.js +18 -0
  63. data/html/js/navigation.js +142 -0
  64. data/html/js/search.js +109 -0
  65. data/html/js/search_index.js +1 -0
  66. data/html/js/searcher.js +228 -0
  67. data/html/rdoc.css +580 -0
  68. data/html/table_of_contents.html +399 -0
  69. data/lib/.DS_Store +0 -0
  70. data/lib/cliutils/configuration.rb +48 -0
  71. data/lib/cliutils/configurator.rb +119 -0
  72. data/lib/cliutils/ext/Hash+Extensions.rb +145 -0
  73. data/lib/cliutils/ext/Logger+Extensions.rb +27 -0
  74. data/lib/cliutils/ext/String+Extensions.rb +26 -0
  75. data/lib/cliutils/logger-delegator.rb +66 -0
  76. data/lib/cliutils/messenging.rb +51 -0
  77. data/lib/cliutils/prefs.rb +116 -0
  78. data/lib/cliutils/pretty-io.rb +255 -0
  79. data/lib/cliutils/version.rb +3 -0
  80. data/lib/cliutils.rb +15 -0
  81. data/res/readme-images/messenger-types-1.png +0 -0
  82. data/res/readme-images/messenger-warn.png +0 -0
  83. data/res/readme-images/multi-logger.png +0 -0
  84. data/res/readme-images/prettyio-color-chart.png +0 -0
  85. data/res/readme-images/prettyio-gnarly-text.png +0 -0
  86. data/res/readme-images/prettyio-red-text.png +0 -0
  87. data/res/readme-images/prompting.png +0 -0
  88. data/res/readme-images/wrapping.png +0 -0
  89. data/test/configurator_test.rb +50 -0
  90. data/test/hash_extensions_test.rb +50 -0
  91. data/test/logger_extensions_test.rb +16 -0
  92. data/test/messenging_test.rb +53 -0
  93. data/test/prefs_test.rb +29 -0
  94. data/test/string_extesions_test.rb +14 -0
  95. data/test/test_files/prefstest.yaml +33 -0
  96. metadata +199 -0
@@ -0,0 +1,330 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class CLIUtils::Prefs - CLIUtils</title>
8
+
9
+ <link href="../fonts.css" rel="stylesheet">
10
+ <link href="../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../";
14
+ </script>
15
+
16
+ <script src="../js/jquery.js"></script>
17
+ <script src="../js/navigation.js"></script>
18
+ <script src="../js/search_index.js"></script>
19
+ <script src="../js/search.js"></script>
20
+ <script src="../js/searcher.js"></script>
21
+ <script src="../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../table_of_contents.html#pages">Pages</a>
34
+ <a href="../table_of_contents.html#classes">Classes</a>
35
+ <a href="../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+ <div class="nav-section">
58
+ <h3>Table of Contents</h3>
59
+
60
+ <ul class="link-list" role="directory">
61
+ <li><a href="#class-CLIUtils::Prefs-label-"></a>
62
+ <li><a href="#class-CLIUtils::Prefs-label-"></a>
63
+ </ul>
64
+ </div>
65
+
66
+
67
+ <div id="class-metadata">
68
+
69
+ <div id="parent-class-section" class="nav-section">
70
+ <h3>Parent</h3>
71
+
72
+
73
+ <p class="link">Object
74
+
75
+ </div>
76
+
77
+ <div id="includes-section" class="nav-section">
78
+ <h3>Included Modules</h3>
79
+
80
+ <ul class="link-list">
81
+
82
+
83
+ <li><a class="include" href="PrettyIO.html">CLIUtils::PrettyIO</a>
84
+
85
+
86
+ </ul>
87
+ </div>
88
+
89
+
90
+ <!-- Method Quickref -->
91
+ <div id="method-list-section" class="nav-section">
92
+ <h3>Methods</h3>
93
+
94
+ <ul class="link-list" role="directory">
95
+
96
+ <li ><a href="#method-c-new">::new</a>
97
+
98
+ <li ><a href="#method-i-ask">#ask</a>
99
+
100
+ </ul>
101
+ </div>
102
+
103
+ </div>
104
+ </nav>
105
+
106
+ <main role="main" aria-labelledby="class-CLIUtils::Prefs">
107
+ <h1 id="class-CLIUtils::Prefs" class="class">
108
+ class CLIUtils::Prefs
109
+ </h1>
110
+
111
+ <section class="description">
112
+
113
+ <h6 id="class-CLIUtils::Prefs-label-"><span><a href="#class-CLIUtils::Prefs-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
114
+
115
+ <p>PrefManager Class</p>
116
+
117
+ <p>Engine to derive preferences from a YAML file, deliver those to a user via
118
+ a prompt, and collect the results.</p>
119
+
120
+ <h6 id="class-CLIUtils::Prefs-label-"><span><a href="#class-CLIUtils::Prefs-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
121
+
122
+ </section>
123
+
124
+
125
+
126
+
127
+ <section id="5Buntitled-5D" class="documentation-section">
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+ <section class="attribute-method-details" class="method-section">
136
+ <header>
137
+ <h3>Attributes</h3>
138
+ </header>
139
+
140
+
141
+ <div id="attribute-i-answers" class="method-detail">
142
+ <div class="method-heading attribute-method-heading">
143
+ <span class="method-name">answers</span><span
144
+ class="attribute-access-type">[R]</span>
145
+ </div>
146
+
147
+ <div class="method-description">
148
+
149
+ <h6 id="attribute-i-answers-label-"><span><a href="#attribute-i-answers-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
150
+
151
+ <p>Attributes</p>
152
+
153
+ <h6 id="attribute-i-answers-label-"><span><a href="#attribute-i-answers-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
154
+
155
+ </div>
156
+ </div>
157
+
158
+ <div id="attribute-i-config_path" class="method-detail">
159
+ <div class="method-heading attribute-method-heading">
160
+ <span class="method-name">config_path</span><span
161
+ class="attribute-access-type">[R]</span>
162
+ </div>
163
+
164
+ <div class="method-description">
165
+
166
+ <h6 id="attribute-i-config_path-label-"><span><a href="#attribute-i-config_path-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
167
+
168
+ <p>Attributes</p>
169
+
170
+ <h6 id="attribute-i-config_path-label-"><span><a href="#attribute-i-config_path-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
171
+
172
+ </div>
173
+ </div>
174
+
175
+ <div id="attribute-i-prompts" class="method-detail">
176
+ <div class="method-heading attribute-method-heading">
177
+ <span class="method-name">prompts</span><span
178
+ class="attribute-access-type">[R]</span>
179
+ </div>
180
+
181
+ <div class="method-description">
182
+
183
+ <h6 id="attribute-i-prompts-label-"><span><a href="#attribute-i-prompts-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
184
+
185
+ <p>Attributes</p>
186
+
187
+ <h6 id="attribute-i-prompts-label-"><span><a href="#attribute-i-prompts-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
188
+
189
+ </div>
190
+ </div>
191
+
192
+ </section>
193
+
194
+
195
+
196
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
197
+ <header>
198
+ <h3>Public Class Methods</h3>
199
+ </header>
200
+
201
+
202
+ <div id="method-c-new" class="method-detail ">
203
+
204
+ <div class="method-heading">
205
+ <span class="method-name">new</span><span
206
+ class="method-args">(data)</span>
207
+
208
+ <span class="method-click-advice">click to toggle source</span>
209
+
210
+ </div>
211
+
212
+
213
+ <div class="method-description">
214
+
215
+ <h6 id="method-c-new-label-"><span><a href="#method-c-new-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
216
+
217
+ <p>Methods</p>
218
+
219
+ <h6 id="method-c-new-label-"><span><a href="#method-c-new-label-">&para;</a> <a href="#documentation">&uarr;</a></span></h6>
220
+ <hr>
221
+
222
+ <p>initialize method</p>
223
+
224
+ <p>Reads prompt data from YAML file. @return Void</p>
225
+ <hr>
226
+
227
+
228
+
229
+
230
+ <div class="method-source-code" id="new-source">
231
+ <pre><span class="ruby-comment"># File lib/cliutils/prefs.rb, line 24</span>
232
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">data</span>)
233
+ <span class="ruby-ivar">@answers</span> = []
234
+ <span class="ruby-ivar">@prompts</span> = {}
235
+
236
+ <span class="ruby-keyword">case</span> <span class="ruby-identifier">data</span>
237
+ <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
238
+ <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">data</span>)
239
+ <span class="ruby-ivar">@config_path</span> = <span class="ruby-identifier">data</span>
240
+
241
+ <span class="ruby-identifier">prompts</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">data</span>)
242
+ <span class="ruby-ivar">@prompts</span>.<span class="ruby-identifier">deep_merge!</span>(<span class="ruby-identifier">prompts</span>).<span class="ruby-identifier">deep_symbolize_keys!</span>
243
+ <span class="ruby-keyword">else</span>
244
+ <span class="ruby-identifier">fail</span> <span class="ruby-node">&quot;Invalid configuration file: #{ yaml_path }&quot;</span>
245
+ <span class="ruby-keyword">end</span>
246
+ <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
247
+ <span class="ruby-ivar">@config_path</span> = <span class="ruby-keyword">nil</span>
248
+
249
+ <span class="ruby-identifier">prompts</span> = {<span class="ruby-value">:prompts</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">data</span>}
250
+ <span class="ruby-ivar">@prompts</span>.<span class="ruby-identifier">deep_merge!</span>(<span class="ruby-identifier">prompts</span>).<span class="ruby-identifier">deep_symbolize_keys!</span>
251
+ <span class="ruby-keyword">else</span>
252
+ <span class="ruby-identifier">fail</span> <span class="ruby-string">&#39;Invalid configuration data&#39;</span>
253
+ <span class="ruby-keyword">end</span>
254
+ <span class="ruby-keyword">end</span></pre>
255
+ </div>
256
+
257
+ </div>
258
+
259
+
260
+
261
+
262
+ </div>
263
+
264
+
265
+ </section>
266
+
267
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
268
+ <header>
269
+ <h3>Public Instance Methods</h3>
270
+ </header>
271
+
272
+
273
+ <div id="method-i-ask" class="method-detail ">
274
+
275
+ <div class="method-heading">
276
+ <span class="method-name">ask</span><span
277
+ class="method-args">()</span>
278
+
279
+ <span class="method-click-advice">click to toggle source</span>
280
+
281
+ </div>
282
+
283
+
284
+ <div class="method-description">
285
+
286
+ <hr>
287
+
288
+ <p>ask method</p>
289
+
290
+ <p>Runs through all of the prompt questions and collects answers from the
291
+ user. Note that all questions w/o requirements are examined first; once
292
+ those are complete, questions w/ requirements are examined. @return Void</p>
293
+ <hr>
294
+
295
+
296
+
297
+
298
+ <div class="method-source-code" id="ask-source">
299
+ <pre><span class="ruby-comment"># File lib/cliutils/prefs.rb, line 57</span>
300
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">ask</span>
301
+ <span class="ruby-ivar">@prompts</span>[<span class="ruby-value">:prompts</span>].<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:requirements</span>] }.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
302
+ <span class="ruby-identifier">_deliver_prompt</span>(<span class="ruby-identifier">p</span>)
303
+ <span class="ruby-keyword">end</span>
304
+
305
+ <span class="ruby-ivar">@prompts</span>[<span class="ruby-value">:prompts</span>].<span class="ruby-identifier">find_all</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>[<span class="ruby-value">:requirements</span>] }.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
306
+ <span class="ruby-identifier">_deliver_prompt</span>(<span class="ruby-identifier">p</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">_requirements_fulfilled?</span>(<span class="ruby-identifier">p</span>)
307
+ <span class="ruby-keyword">end</span>
308
+ <span class="ruby-keyword">end</span></pre>
309
+ </div>
310
+
311
+ </div>
312
+
313
+
314
+
315
+
316
+ </div>
317
+
318
+
319
+ </section>
320
+
321
+ </section>
322
+ </main>
323
+
324
+
325
+ <footer id="validator-badges" role="contentinfo">
326
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
327
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
328
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
329
+ </footer>
330
+