cliutils 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/html/index.html ADDED
@@ -0,0 +1,455 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>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="file">
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
+
40
+ <div id="search-section" role="search" class="project-section initially-hidden">
41
+ <form action="#" method="get" accept-charset="utf-8">
42
+ <div id="search-field-wrapper">
43
+ <input id="search-field" role="combobox" aria-label="Search"
44
+ aria-autocomplete="list" aria-controls="search-results"
45
+ type="text" name="search" placeholder="Search" spellcheck="false"
46
+ title="Type to search, Up and Down to navigate, Enter to load">
47
+ </div>
48
+
49
+ <ul id="search-results" aria-label="Search Results"
50
+ aria-busy="false" aria-expanded="false"
51
+ aria-atomic="false" class="initially-hidden"></ul>
52
+ </form>
53
+ </div>
54
+
55
+ </div>
56
+
57
+ <div id="project-metadata">
58
+ <div id="fileindex-section" class="nav-section">
59
+ <h3>Pages</h3>
60
+
61
+ <ul class="link-list">
62
+
63
+ <li><a href="./README_md.html">README</a>
64
+
65
+ </ul>
66
+ </div>
67
+
68
+ <div id="classindex-section" class="nav-section">
69
+ <h3>Class and Module Index</h3>
70
+
71
+ <ul class="link-list">
72
+
73
+ <li><a href="./CLIUtils.html">CLIUtils</a>
74
+
75
+ <li><a href="./CLIUtils/Configuration.html">CLIUtils::Configuration</a>
76
+
77
+ <li><a href="./CLIUtils/Configurator.html">CLIUtils::Configurator</a>
78
+
79
+ <li><a href="./CLIUtils/LoggerDelegator.html">CLIUtils::LoggerDelegator</a>
80
+
81
+ <li><a href="./CLIUtils/Messenging.html">CLIUtils::Messenging</a>
82
+
83
+ <li><a href="./CLIUtils/Prefs.html">CLIUtils::Prefs</a>
84
+
85
+ <li><a href="./CLIUtils/PrettyIO.html">CLIUtils::PrettyIO</a>
86
+
87
+ <li><a href="./Hash.html">Hash</a>
88
+
89
+ <li><a href="./Logger.html">Logger</a>
90
+
91
+ <li><a href="./String.html">String</a>
92
+
93
+ </ul>
94
+ </div>
95
+
96
+ </div>
97
+ </nav>
98
+
99
+ <main role="main">
100
+
101
+
102
+ <h1 id="label-CLIUtils"><a href="CLIUtils.html">CLIUtils</a><span><a href="#label-CLIUtils">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
103
+
104
+ <p><a href="CLIUtils.html">CLIUtils</a> is a library of functionality designed
105
+ to alleviate common tasks and headaches when developing command-line (CLI)
106
+ apps in Ruby.</p>
107
+
108
+ <h1 id="label-Why%3F">Why?<span><a href="#label-Why%3F">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
109
+
110
+ <p>It&#39;s fairly simple:</p>
111
+ <ol><li>
112
+ <p>I love developing Ruby-based CLI apps.</p>
113
+ </li><li>
114
+ <p>I found myself copy/pasting common code from one to another.</p>
115
+ </li><li>
116
+ <p>I decided to do something about it.</p>
117
+ </li></ol>
118
+
119
+ <h1 id="label-Installation">Installation<span><a href="#label-Installation">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
120
+
121
+ <p>Add this line to your application&#39;s Gemfile:</p>
122
+
123
+ <pre>$ gem &#39;cliutils&#39;</pre>
124
+
125
+ <p>And then execute:</p>
126
+
127
+ <pre>$ bundle</pre>
128
+
129
+ <p>Or install it yourself:</p>
130
+
131
+ <pre>$ gem install cliutils</pre>
132
+
133
+ <h1 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
134
+
135
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;cliutils&#39;</span>
136
+ </pre>
137
+
138
+ <p>If you want to mix in everything that <a href="CLIUtils.html">CLIUtils</a>
139
+ has to offer:</p>
140
+
141
+ <pre>include CLIUtils</pre>
142
+
143
+ <p>Alternatively, as described below, mix in only the libraries that you want.</p>
144
+
145
+ <p>Note that although this <a href="README_md.html">README.md</a> is
146
+ extensive, it may not cover all methods. Check out the <a
147
+ href="https://github.com/bachya/cli-utils/tree/master/test">tests</a> to
148
+ see more examples.</p>
149
+
150
+ <h1 id="label-Libraries">Libraries<span><a href="#label-Libraries">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
151
+
152
+ <p><a href="CLIUtils.html">CLIUtils</a> offers:</p>
153
+ <ul><li>
154
+ <p><a href="https://github.com/bachya/cli-utils#prettyio">PrettyIO</a>:
155
+ nicer-looking CLI messages</p>
156
+ </li><li>
157
+ <p><a href="https://github.com/bachya/cli-utils#messenging">Messenging</a>: a
158
+ full-featured <a href="Logger.html">Logger</a></p>
159
+ </li><li>
160
+ <p><a
161
+ href="https://github.com/bachya/cli-utils#configuration">Configuration</a>:
162
+ a app configuration manager</p>
163
+ </li><li>
164
+ <p><a href="https://github.com/bachya/cli-utils#prefs">Prefs</a>: a
165
+ preferences prompter and manager</p>
166
+ </li></ul>
167
+
168
+ <h2 id="label-PrettyIO">PrettyIO<span><a href="#label-PrettyIO">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
169
+
170
+ <p>First stop on our journey is better client IO. To activate, simply mix into
171
+ your project:</p>
172
+
173
+ <pre class="ruby"><span class="ruby-identifier">include</span> <span class="ruby-constant">CLIUtils</span><span class="ruby-operator">::</span><span class="ruby-constant">PrettyIO</span>
174
+ </pre>
175
+
176
+ <p>PrettyIO affords you colorized strings:</p>
177
+
178
+ <pre class="ruby"><span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;A sample string&#39;</span>.<span class="ruby-identifier">red</span>
179
+ </pre>
180
+
181
+ <p><img
182
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-red-text.png"></p>
183
+
184
+ <p>PrettyIO gives you utility methods for the common ANSI color codes:</p>
185
+
186
+ <pre class="ruby"><span class="ruby-constant">String</span>.<span class="ruby-identifier">blue</span>
187
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">cyan</span>
188
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">green</span>
189
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">purple</span>
190
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">red</span>
191
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">white</span>
192
+ <span class="ruby-constant">String</span>.<span class="ruby-identifier">yellow</span>
193
+ </pre>
194
+
195
+ <p>You also get the <code>colorize</code> method, which allows you to define
196
+ more complex color combinations. For example, to get some nice purple text
197
+ on a gnarly green background:</p>
198
+
199
+ <pre class="ruby"><span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;A sample string&#39;</span>.<span class="ruby-identifier">colorize</span>(<span class="ruby-string">&#39;35;42&#39;</span>)
200
+ </pre>
201
+
202
+ <p><img
203
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-gnarly-text.png"></p>
204
+
205
+ <p>Naturally, memorizing the ANSI color scheme is a pain, so PrettyIO gives
206
+ you a convenient method to look up these color combinations:</p>
207
+
208
+ <pre class="ruby"><span class="ruby-identifier">color_chart</span>
209
+ </pre>
210
+
211
+ <p><img
212
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-color-chart.png"></p>
213
+
214
+ <h2 id="label-Messenging">Messenging<span><a href="#label-Messenging">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
215
+
216
+ <p>Throughout the life of your application, you will most likely want to send
217
+ several messages to your user (warnings, errors, info, etc.). Messenging
218
+ makes this a snap. It, too, is a mixin:</p>
219
+
220
+ <pre class="ruby"><span class="ruby-identifier">include</span> <span class="ruby-constant">CLIUtils</span><span class="ruby-operator">::</span><span class="ruby-constant">Messenging</span>
221
+ </pre>
222
+
223
+ <p>Once mixed in, you get access to <code>messenger</code>, a type of <a
224
+ href="Logger.html">Logger</a> that uses PrettyIO to send nicely-formatted
225
+ messages to your user. For example, if you&#39;d like to warn your user:</p>
226
+
227
+ <pre class="ruby"><span class="ruby-identifier">messenger</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-string">&#39;Hey pal, you need to be careful.&#39;</span>)
228
+ </pre>
229
+
230
+ <p><img
231
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/messenger-warn.png"></p>
232
+
233
+ <h3 id="label-Messenging+Methods">Messenging Methods<span><a href="#label-Messenging+Methods">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
234
+
235
+ <p><code>messenger</code> gives you access to several basic methods:</p>
236
+ <ul><li>
237
+ <p><code>messenger.error</code>: used to show a formatted-red error message.</p>
238
+ </li><li>
239
+ <p><code>messenger.info</code>: used to show a formatted-blue infomational
240
+ message.</p>
241
+ </li><li>
242
+ <p><code>messenger.section</code>: used to show a formatted-purple sectional
243
+ message.</p>
244
+ </li><li>
245
+ <p><code>messenger.success</code>: used to show a formatted-green success
246
+ message.</p>
247
+ </li><li>
248
+ <p><code>messenger.yellow</code>: used to show a formatted-yellow warning
249
+ message.</p>
250
+ </li></ul>
251
+
252
+ <p>Let&#39;s see an example that uses them all:</p>
253
+
254
+ <pre>messenger.section(&#39;STARTING ATTACK RUN...&#39;)
255
+ messenger.info(&#39;Beginning strafing run...&#39;)
256
+ messenger.warn(&#39;WARNING: Tie Fighters approaching!&#39;)
257
+ messenger.error(&#39;Porkins died :(&#39;)
258
+ messenger.success(&#39;But Luke still blew up the Death Star!&#39;)</pre>
259
+
260
+ <p><img
261
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/messenger-types-1.png"></p>
262
+
263
+ <p><code>messenger</code> also includes two “block” methods that allow you to
264
+ wrap program execution in messages that are “longer-term”.</p>
265
+
266
+ <pre>messenger.info_block(&#39;Starting up...&#39;, &#39;Done!&#39;, multiline = false) { # do stuff here }</pre>
267
+
268
+ <p><code>messenger</code> outputs &#39;Starting up…&#39;, runs the code in
269
+ <code># do stuff here</code>, and once complete, outputs &#39;Done!&#39; on
270
+ the same line. Note that <code>section_block</code> is the same exact
271
+ signature (except for the method name, of course!).</p>
272
+
273
+ <h3 id="label-Message+Wrapping">Message Wrapping<span><a href="#label-Message+Wrapping">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
274
+
275
+ <p>PrettyIO also gives <code>messenger</code> the ability to wrap your
276
+ messages so that they don&#39;t span off into infinity. You can even
277
+ control what the wrap limit (in characters) is:</p>
278
+
279
+ <pre>CLIUtils::PrettyIO::wrap_at(50)
280
+ messenger.info(&#39;This is a really long message, okay? It should wrap at some point. Seriously. Wrapping is nice.&#39;)
281
+ puts &#39;&#39;
282
+ CLIUtils::PrettyIO::wrap_at(20)
283
+ messenger.info(&#39;This is a really long message, okay? It should wrap at some point. Seriously. Wrapping is nice.&#39;)
284
+ puts &#39;&#39;
285
+ CLIUtils::PrettyIO::wrap(false)
286
+ messenger.info(&#39;This is a really long message, okay? It should wrap at some point. Seriously. Wrapping is nice.&#39;)</pre>
287
+
288
+ <p><img
289
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/wrapping.png"></p>
290
+
291
+ <h3 id="label-Prompting">Prompting<span><a href="#label-Prompting">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
292
+
293
+ <p><code>messenger</code> also carries a convenient method to prompt your
294
+ users to give input (including an optional default). It makes use of
295
+ <code>readline</code>, so you can do cool things like text expansion of
296
+ paths.</p>
297
+
298
+ <pre>p = messenger.prompt(&#39;Are you a fan of Battlestar Galactica?&#39;, default = &#39;Y&#39;)
299
+ messenger.info(&quot;You answered: #{ p }&quot;)</pre>
300
+
301
+ <p><img
302
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prompting.png"></p>
303
+
304
+ <h3 id="label-Logging">Logging<span><a href="#label-Logging">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
305
+
306
+ <p>Often, it&#39;s desirable to log messages as they appear to your user.
307
+ <code>messenging</code> makes this a breeze by allowing you to attach and
308
+ detach <a href="Logger.html">Logger</a> instances at will.</p>
309
+
310
+ <p>For instance, let&#39;s say you wanted to log a few messages to both your
311
+ user&#39;s STDOUT and to <code>file.txt</code>:</p>
312
+
313
+ <pre>file_logger = Logger.new(&#39;file.txt&#39;)
314
+
315
+ messenger.info(&#39;This should only appear in STDOUT.&#39;)
316
+
317
+ messenger.attach(file_logger)
318
+
319
+ messenger.warn(&#39;This warning should appear in STDOUT and file.txt&#39;)
320
+ messenger.error(&#39;This error should appear in STDOUT and file.txt&#39;)
321
+ messenger.debug(&#39;This debug message should only appear in file.txt&#39;)
322
+
323
+ messenger.detach(file_logger)
324
+
325
+ messenger.section(&#39;This section message should appear only in STDOUT&#39;)</pre>
326
+
327
+ <p>In STDOUT:</p>
328
+
329
+ <p><img
330
+ src="https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/multi-logger.png"></p>
331
+
332
+ <p>…and in <code>file.txt</code>:</p>
333
+
334
+ <pre>W, [2014-03-29T15:14:34.844406 #4497] WARN -- : This warning should appear in STDOUT and file.txt
335
+ E, [2014-03-29T15:14:34.844553 #4497] ERROR -- : This error should appear in STDOUT and file.txt
336
+ D, [2014-03-29T15:14:34.844609 #4497] DEBUG -- : This debug message should only appear in file.txt</pre>
337
+
338
+ <p>Since you can attach <a href="Logger.html">Logger</a> objects, each can
339
+ have it&#39;s own format and severity level. Cool!</p>
340
+
341
+ <h2 id="label-Configuration">Configuration<span><a href="#label-Configuration">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
342
+
343
+ <p><a href="CLIUtils.html">CLIUtils</a> offers two “things” – a
344
+ <code>Configurator</code> class and a <code>Configuration</code> module
345
+ that provides access to a shared instance of <code>Configurator</code> –
346
+ that make managing a user&#39;s configuration parameters easy. Mix it in!</p>
347
+
348
+ <pre>include CLIUtils::Configuration</pre>
349
+
350
+ <h3 id="label-Loading+a+Configuration+File">Loading a Configuration File<span><a href="#label-Loading+a+Configuration+File">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
351
+
352
+ <pre>load_configuration(&#39;~/.my-app-config&#39;)</pre>
353
+
354
+ <p>If there&#39;s data in there, it will be consumed into
355
+ <code>configuration</code>&#39;s <code>data</code> property.</p>
356
+
357
+ <h3 id="label-Adding%2FRemoving+Sections">Adding/Removing Sections<span><a href="#label-Adding%2FRemoving+Sections">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
358
+
359
+ <p>Sections are top levels of the configuration file and are managed via the
360
+ <code>configuration</code> object:</p>
361
+
362
+ <pre>configuration.add_section(:user_data)
363
+ configuration.add_section(:program_data)
364
+ configuration.delete_section(:program_data)</pre>
365
+
366
+ <h3 id="label-Adding+Data+to+Sections">Adding Data to Sections<span><a href="#label-Adding+Data+to+Sections">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
367
+
368
+ <p>There are two ways data can be managed in <code>configuration</code>: via
369
+ its <code>@data</code> property or via some magic methods; your call:</p>
370
+
371
+ <pre>configuration.data[:user_data].merge!(username: &#39;bob&#39;)
372
+ # OR
373
+ configuration.user_data.merge!(username: &#39;bob&#39;)</pre>
374
+
375
+ <h3 id="label-Saving+to+a+File">Saving to a File<span><a href="#label-Saving+to+a+File">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
376
+
377
+ <p>When you&#39;re ready to save your configuration data to a YAML file:</p>
378
+
379
+ <pre>configuration.save</pre>
380
+
381
+ <p>Note that all your keys are converted to strings before saving (and,
382
+ likewise, are converted to symbols, when loading). Assuming we used the
383
+ commands above, we could expect this to be the contents of
384
+ <code>~/.my-app-config</code>:</p>
385
+
386
+ <pre>---
387
+ user_data:
388
+ username: bob</pre>
389
+
390
+ <h1 id="label-Known+Issues">Known Issues<span><a href="#label-Known+Issues">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
391
+ <ul><li>
392
+ <p>LoggerDelegator doesn&#39;t currently know what to do with
393
+ <code>messenger.prompt</code>, so you&#39;ll have to manually log a
394
+ <code>debug</code> message if you want that information logged.</p>
395
+ </li></ul>
396
+
397
+ <h1 id="label-Bugs+and+Feature+Requests">Bugs and Feature Requests<span><a href="#label-Bugs+and+Feature+Requests">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
398
+
399
+ <p>To report bugs with or suggest features/changes for <a
400
+ href="CLIUtils.html">CLIUtils</a>, please use the <a
401
+ href="http://github.com/bachya/cli-utils/issues">Issues Page</a>.</p>
402
+
403
+ <h1 id="label-Contributing">Contributing<span><a href="#label-Contributing">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
404
+
405
+ <p>Contributions are welcome and encouraged. To contribute:</p>
406
+ <ol><li>
407
+ <p>Fork it ( <a
408
+ href="http://github.com/bachya/cliutils/fork">github.com/bachya/cliutils/fork</a>
409
+ )</p>
410
+ </li><li>
411
+ <p>Create your feature branch (<code>git checkout -b my-new-feature</code>)</p>
412
+ </li><li>
413
+ <p>Commit your changes (<code>git commit -am &#39;Add some
414
+ feature&#39;</code>)</p>
415
+ </li><li>
416
+ <p>Push to the branch (<code>git push origin my-new-feature</code>)</p>
417
+ </li><li>
418
+ <p>Create new Pull Request</p>
419
+ </li></ol>
420
+
421
+ <h1 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
422
+
423
+ <p>(The MIT License)</p>
424
+
425
+ <p>Copyright © 2014 Aaron Bach <a
426
+ href="mailto:bachya1208@gmail.com">bachya1208@gmail.com</a></p>
427
+
428
+ <p>Permission is hereby granted, free of charge, to any person obtaining a
429
+ copy of this software and associated documentation files (the
430
+ &#39;Software&#39;), to deal in the Software without restriction, including
431
+ without limitation the rights to use, copy, modify, merge, publish,
432
+ distribute, sublicense, and/or sell copies of the Software, and to permit
433
+ persons to whom the Software is furnished to do so, subject to the
434
+ following conditions:</p>
435
+
436
+ <p>The above copyright notice and this permission notice shall be included in
437
+ all copies or substantial portions of the Software.</p>
438
+
439
+ <p>THE SOFTWARE IS PROVIDED &#39;AS IS&#39;, WITHOUT WARRANTY OF ANY KIND,
440
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
441
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
442
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
443
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
444
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
445
+ USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
446
+ </main>
447
+
448
+
449
+
450
+ <footer id="validator-badges" role="contentinfo">
451
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
452
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
453
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
454
+ </footer>
455
+
@@ -0,0 +1,140 @@
1
+ /**
2
+ *
3
+ * Darkfish Page Functions
4
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
5
+ *
6
+ * Author: Michael Granger <mgranger@laika.com>
7
+ *
8
+ */
9
+
10
+ /* Provide console simulation for firebug-less environments */
11
+ if (!("console" in window) || !("firebug" in console)) {
12
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
13
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
14
+
15
+ window.console = {};
16
+ for (var i = 0; i < names.length; ++i)
17
+ window.console[names[i]] = function() {};
18
+ };
19
+
20
+
21
+ /**
22
+ * Unwrap the first element that matches the given @expr@ from the targets and return them.
23
+ */
24
+ $.fn.unwrap = function( expr ) {
25
+ return this.each( function() {
26
+ $(this).parents( expr ).eq( 0 ).after( this ).remove();
27
+ });
28
+ };
29
+
30
+
31
+ function showSource( e ) {
32
+ var target = e.target;
33
+ var codeSections = $(target).
34
+ parents('.method-detail').
35
+ find('.method-source-code');
36
+
37
+ $(target).
38
+ parents('.method-detail').
39
+ find('.method-source-code').
40
+ slideToggle();
41
+ };
42
+
43
+ function hookSourceViews() {
44
+ $('.method-heading').click( showSource );
45
+ };
46
+
47
+ function toggleDebuggingSection() {
48
+ $('.debugging-section').slideToggle();
49
+ };
50
+
51
+ function hookDebuggingToggle() {
52
+ $('#debugging-toggle img').click( toggleDebuggingSection );
53
+ };
54
+
55
+ function hookSearch() {
56
+ var input = $('#search-field').eq(0);
57
+ var result = $('#search-results').eq(0);
58
+ $(result).show();
59
+
60
+ var search_section = $('#search-section').get(0);
61
+ $(search_section).show();
62
+
63
+ var search = new Search(search_data, input, result);
64
+
65
+ search.renderItem = function(result) {
66
+ var li = document.createElement('li');
67
+ var html = '';
68
+
69
+ // TODO add relative path to <script> per-page
70
+ html += '<p class="search-match"><a href="' + rdoc_rel_prefix + result.path + '">' + this.hlt(result.title);
71
+ if (result.params)
72
+ html += '<span class="params">' + result.params + '</span>';
73
+ html += '</a>';
74
+
75
+
76
+ if (result.namespace)
77
+ html += '<p class="search-namespace">' + this.hlt(result.namespace);
78
+
79
+ if (result.snippet)
80
+ html += '<div class="search-snippet">' + result.snippet + '</div>';
81
+
82
+ li.innerHTML = html;
83
+
84
+ return li;
85
+ }
86
+
87
+ search.select = function(result) {
88
+ var result_element = result.get(0);
89
+ window.location.href = result_element.firstChild.firstChild.href;
90
+ }
91
+
92
+ search.scrollIntoView = search.scrollInWindow;
93
+ };
94
+
95
+ function highlightTarget( anchor ) {
96
+ console.debug( "Highlighting target '%s'.", anchor );
97
+
98
+ $("a[name]").each( function() {
99
+ if ( $(this).attr("name") == anchor ) {
100
+ if ( !$(this).parent().parent().hasClass('target-section') ) {
101
+ console.debug( "Wrapping the target-section" );
102
+ $('div.method-detail').unwrap( 'div.target-section' );
103
+ $(this).parent().wrap( '<div class="target-section"></div>' );
104
+ } else {
105
+ console.debug( "Already wrapped." );
106
+ }
107
+ }
108
+ });
109
+ };
110
+
111
+ function highlightLocationTarget() {
112
+ console.debug( "Location hash: %s", window.location.hash );
113
+ if ( ! window.location.hash || window.location.hash.length == 0 ) return;
114
+
115
+ var anchor = window.location.hash.substring(1);
116
+ console.debug( "Found anchor: %s; matching %s", anchor, "a[name=" + anchor + "]" );
117
+
118
+ highlightTarget( anchor );
119
+ };
120
+
121
+ function highlightClickTarget( event ) {
122
+ console.debug( "Highlighting click target for event %o", event.target );
123
+ try {
124
+ var anchor = $(event.target).attr( 'href' ).substring(1);
125
+ console.debug( "Found target anchor: %s", anchor );
126
+ highlightTarget( anchor );
127
+ } catch ( err ) {
128
+ console.error( "Exception while highlighting: %o", err );
129
+ };
130
+ };
131
+
132
+
133
+ $(document).ready( function() {
134
+ hookSourceViews();
135
+ hookDebuggingToggle();
136
+ hookSearch();
137
+ highlightLocationTarget();
138
+
139
+ $('ul.link-list a').bind( "click", highlightClickTarget );
140
+ });