cliutils 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +22 -0
- data/README.md +288 -0
- data/README.rdoc +19 -0
- data/Rakefile +45 -0
- data/bin/cliutils +38 -0
- data/cliutils.gemspec +28 -0
- data/features/cli_manager.feature +13 -0
- data/features/step_definitions/cli_manager_steps.rb +1 -0
- data/features/support/env.rb +16 -0
- data/html/CLIUtils/Configuration.html +271 -0
- data/html/CLIUtils/Configurator.html +504 -0
- data/html/CLIUtils/LoggerDelegator.html +344 -0
- data/html/CLIUtils/Messenging.html +284 -0
- data/html/CLIUtils/Prefs.html +330 -0
- data/html/CLIUtils/PrettyIO.html +799 -0
- data/html/CLIUtils.html +112 -0
- data/html/Hash.html +453 -0
- data/html/Logger.html +183 -0
- data/html/Object.html +120 -0
- data/html/README_md.html +454 -0
- data/html/String.html +413 -0
- data/html/created.rid +13 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/fonts.css +167 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +455 -0
- data/html/js/darkfish.js +140 -0
- data/html/js/jquery.js +18 -0
- data/html/js/navigation.js +142 -0
- data/html/js/search.js +109 -0
- data/html/js/search_index.js +1 -0
- data/html/js/searcher.js +228 -0
- data/html/rdoc.css +580 -0
- data/html/table_of_contents.html +399 -0
- data/lib/.DS_Store +0 -0
- data/lib/cliutils/configuration.rb +48 -0
- data/lib/cliutils/configurator.rb +119 -0
- data/lib/cliutils/ext/Hash+Extensions.rb +145 -0
- data/lib/cliutils/ext/Logger+Extensions.rb +27 -0
- data/lib/cliutils/ext/String+Extensions.rb +26 -0
- data/lib/cliutils/logger-delegator.rb +66 -0
- data/lib/cliutils/messenging.rb +51 -0
- data/lib/cliutils/prefs.rb +116 -0
- data/lib/cliutils/pretty-io.rb +255 -0
- data/lib/cliutils/version.rb +3 -0
- data/lib/cliutils.rb +15 -0
- data/res/readme-images/messenger-types-1.png +0 -0
- data/res/readme-images/messenger-warn.png +0 -0
- data/res/readme-images/multi-logger.png +0 -0
- data/res/readme-images/prettyio-color-chart.png +0 -0
- data/res/readme-images/prettyio-gnarly-text.png +0 -0
- data/res/readme-images/prettyio-red-text.png +0 -0
- data/res/readme-images/prompting.png +0 -0
- data/res/readme-images/wrapping.png +0 -0
- data/test/configurator_test.rb +50 -0
- data/test/hash_extensions_test.rb +50 -0
- data/test/logger_extensions_test.rb +16 -0
- data/test/messenging_test.rb +53 -0
- data/test/prefs_test.rb +29 -0
- data/test/string_extesions_test.rb +14 -0
- data/test/test_files/prefstest.yaml +33 -0
- metadata +199 -0
@@ -0,0 +1,799 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module CLIUtils::PrettyIO - 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="module">
|
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="#module-CLIUtils::PrettyIO-label-"></a>
|
62
|
+
<li><a href="#module-CLIUtils::PrettyIO-label-"></a>
|
63
|
+
</ul>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
|
67
|
+
<div id="class-metadata">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
<!-- Method Quickref -->
|
73
|
+
<div id="method-list-section" class="nav-section">
|
74
|
+
<h3>Methods</h3>
|
75
|
+
|
76
|
+
<ul class="link-list" role="directory">
|
77
|
+
|
78
|
+
<li ><a href="#method-c-included">::included</a>
|
79
|
+
|
80
|
+
<li ><a href="#method-c-wrap">::wrap</a>
|
81
|
+
|
82
|
+
<li ><a href="#method-c-wrap_at">::wrap_at</a>
|
83
|
+
|
84
|
+
<li ><a href="#method-c-wrap_limit">::wrap_limit</a>
|
85
|
+
|
86
|
+
<li ><a href="#method-i-color_chart">#color_chart</a>
|
87
|
+
|
88
|
+
<li ><a href="#method-i-debug">#debug</a>
|
89
|
+
|
90
|
+
<li ><a href="#method-i-error">#error</a>
|
91
|
+
|
92
|
+
<li ><a href="#method-i-info">#info</a>
|
93
|
+
|
94
|
+
<li ><a href="#method-i-info_block">#info_block</a>
|
95
|
+
|
96
|
+
<li ><a href="#method-i-log">#log</a>
|
97
|
+
|
98
|
+
<li ><a href="#method-i-prompt">#prompt</a>
|
99
|
+
|
100
|
+
<li ><a href="#method-i-section">#section</a>
|
101
|
+
|
102
|
+
<li ><a href="#method-i-section_block">#section_block</a>
|
103
|
+
|
104
|
+
<li ><a href="#method-i-success">#success</a>
|
105
|
+
|
106
|
+
<li ><a href="#method-i-warn">#warn</a>
|
107
|
+
|
108
|
+
</ul>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
</div>
|
112
|
+
</nav>
|
113
|
+
|
114
|
+
<main role="main" aria-labelledby="module-CLIUtils::PrettyIO">
|
115
|
+
<h1 id="module-CLIUtils::PrettyIO" class="module">
|
116
|
+
module CLIUtils::PrettyIO
|
117
|
+
</h1>
|
118
|
+
|
119
|
+
<section class="description">
|
120
|
+
|
121
|
+
<h6 id="module-CLIUtils::PrettyIO-label-"><span><a href="#module-CLIUtils::PrettyIO-label-">¶</a> <a href="#documentation">↑</a></span></h6>
|
122
|
+
|
123
|
+
<p>CLIMessenger Module Outputs color-coordinated messages to a CLI</p>
|
124
|
+
|
125
|
+
<h6 id="module-CLIUtils::PrettyIO-label-"><span><a href="#module-CLIUtils::PrettyIO-label-">¶</a> <a href="#documentation">↑</a></span></h6>
|
126
|
+
|
127
|
+
</section>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
143
|
+
<header>
|
144
|
+
<h3>Public Class Methods</h3>
|
145
|
+
</header>
|
146
|
+
|
147
|
+
|
148
|
+
<div id="method-c-included" class="method-detail ">
|
149
|
+
|
150
|
+
<div class="method-heading">
|
151
|
+
<span class="method-name">included</span><span
|
152
|
+
class="method-args">(k)</span>
|
153
|
+
|
154
|
+
<span class="method-click-advice">click to toggle source</span>
|
155
|
+
|
156
|
+
</div>
|
157
|
+
|
158
|
+
|
159
|
+
<div class="method-description">
|
160
|
+
|
161
|
+
<h6 id="method-c-included-label-"><span><a href="#method-c-included-label-">¶</a> <a href="#documentation">↑</a></span></h6>
|
162
|
+
|
163
|
+
<p>Methods</p>
|
164
|
+
|
165
|
+
<h6 id="method-c-included-label-----------------------------------------------------">—————————————————-<span><a href="#method-c-included-label-----------------------------------------------------">¶</a> <a href="#documentation">↑</a></span></h6>
|
166
|
+
|
167
|
+
<p>included method</p>
|
168
|
+
|
169
|
+
<p>Hook called when this module gets mixed in; extends the includer with the
|
170
|
+
methods defined here. @param k The includer @return Void</p>
|
171
|
+
<hr>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
<div class="method-source-code" id="included-source">
|
177
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 29</span>
|
178
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">included</span>(<span class="ruby-identifier">k</span>)
|
179
|
+
<span class="ruby-identifier">k</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-keyword">self</span>)
|
180
|
+
<span class="ruby-keyword">end</span></pre>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
</div>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
</div>
|
189
|
+
|
190
|
+
|
191
|
+
<div id="method-c-wrap" class="method-detail ">
|
192
|
+
|
193
|
+
<div class="method-heading">
|
194
|
+
<span class="method-name">wrap</span><span
|
195
|
+
class="method-args">(on)</span>
|
196
|
+
|
197
|
+
<span class="method-click-advice">click to toggle source</span>
|
198
|
+
|
199
|
+
</div>
|
200
|
+
|
201
|
+
|
202
|
+
<div class="method-description">
|
203
|
+
|
204
|
+
<hr>
|
205
|
+
|
206
|
+
<p>wrap method</p>
|
207
|
+
|
208
|
+
<p>Toggles wrapping on or off @return Integer</p>
|
209
|
+
<hr>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
<div class="method-source-code" id="wrap-source">
|
215
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 210</span>
|
216
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">wrap</span>(<span class="ruby-identifier">on</span>)
|
217
|
+
<span class="ruby-identifier">@@wrap</span> = <span class="ruby-identifier">on</span>
|
218
|
+
<span class="ruby-keyword">end</span></pre>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
</div>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
</div>
|
227
|
+
|
228
|
+
|
229
|
+
<div id="method-c-wrap_at" class="method-detail ">
|
230
|
+
|
231
|
+
<div class="method-heading">
|
232
|
+
<span class="method-name">wrap_at</span><span
|
233
|
+
class="method-args">(chars)</span>
|
234
|
+
|
235
|
+
<span class="method-click-advice">click to toggle source</span>
|
236
|
+
|
237
|
+
</div>
|
238
|
+
|
239
|
+
|
240
|
+
<div class="method-description">
|
241
|
+
|
242
|
+
<hr>
|
243
|
+
|
244
|
+
<p><a href="PrettyIO.html#method-c-wrap_at">::wrap_at</a> method</p>
|
245
|
+
|
246
|
+
<p>Sets the number of characters at which to wrap @return Integer</p>
|
247
|
+
<hr>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
<div class="method-source-code" id="wrap_at-source">
|
253
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 230</span>
|
254
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">wrap_at</span>(<span class="ruby-identifier">chars</span>)
|
255
|
+
<span class="ruby-identifier">@@wrap_char_limit</span> = <span class="ruby-identifier">chars</span>
|
256
|
+
<span class="ruby-keyword">end</span></pre>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
</div>
|
265
|
+
|
266
|
+
|
267
|
+
<div id="method-c-wrap_limit" class="method-detail ">
|
268
|
+
|
269
|
+
<div class="method-heading">
|
270
|
+
<span class="method-name">wrap_limit</span><span
|
271
|
+
class="method-args">()</span>
|
272
|
+
|
273
|
+
<span class="method-click-advice">click to toggle source</span>
|
274
|
+
|
275
|
+
</div>
|
276
|
+
|
277
|
+
|
278
|
+
<div class="method-description">
|
279
|
+
|
280
|
+
<hr>
|
281
|
+
|
282
|
+
<p><a href="PrettyIO.html#method-c-wrap_limit">::wrap_limit</a> method</p>
|
283
|
+
|
284
|
+
<p>Returns the current character wrap amount @return Integer</p>
|
285
|
+
<hr>
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
<div class="method-source-code" id="wrap_limit-source">
|
291
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 220</span>
|
292
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">wrap_limit</span>
|
293
|
+
<span class="ruby-identifier">@@wrap_char_limit</span>
|
294
|
+
<span class="ruby-keyword">end</span></pre>
|
295
|
+
</div>
|
296
|
+
|
297
|
+
</div>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
</div>
|
303
|
+
|
304
|
+
|
305
|
+
</section>
|
306
|
+
|
307
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
308
|
+
<header>
|
309
|
+
<h3>Public Instance Methods</h3>
|
310
|
+
</header>
|
311
|
+
|
312
|
+
|
313
|
+
<div id="method-i-color_chart" class="method-detail ">
|
314
|
+
|
315
|
+
<div class="method-heading">
|
316
|
+
<span class="method-name">color_chart</span><span
|
317
|
+
class="method-args">()</span>
|
318
|
+
|
319
|
+
<span class="method-click-advice">click to toggle source</span>
|
320
|
+
|
321
|
+
</div>
|
322
|
+
|
323
|
+
|
324
|
+
<div class="method-description">
|
325
|
+
|
326
|
+
<hr>
|
327
|
+
|
328
|
+
<p><a href="PrettyIO.html#method-i-color_chart">#color_chart</a> method</p>
|
329
|
+
|
330
|
+
<p>Displays a chart of all the possible ANSI foreground and background color
|
331
|
+
combinations. @return Void</p>
|
332
|
+
<hr>
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
<div class="method-source-code" id="color_chart-source">
|
338
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 40</span>
|
339
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">color_chart</span>
|
340
|
+
[<span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">4</span>, <span class="ruby-value">5</span>, <span class="ruby-value">7</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attr</span><span class="ruby-operator">|</span>
|
341
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'----------------------------------------------------------------'</span>
|
342
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"ESC[#{attr};Foreground;Background"</span>
|
343
|
+
<span class="ruby-value">30</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-value">37</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fg</span><span class="ruby-operator">|</span>
|
344
|
+
<span class="ruby-value">40</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-value">47</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">bg</span><span class="ruby-operator">|</span>
|
345
|
+
<span class="ruby-identifier">print</span> <span class="ruby-node">"\033[#{attr};#{fg};#{bg}m #{fg};#{bg} "</span>
|
346
|
+
<span class="ruby-keyword">end</span>
|
347
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"\033[0m"</span>
|
348
|
+
<span class="ruby-keyword">end</span>
|
349
|
+
<span class="ruby-keyword">end</span>
|
350
|
+
<span class="ruby-keyword">end</span></pre>
|
351
|
+
</div>
|
352
|
+
|
353
|
+
</div>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
</div>
|
359
|
+
|
360
|
+
|
361
|
+
<div id="method-i-debug" class="method-detail ">
|
362
|
+
|
363
|
+
<div class="method-heading">
|
364
|
+
<span class="method-name">debug</span><span
|
365
|
+
class="method-args">(m)</span>
|
366
|
+
|
367
|
+
<span class="method-click-advice">click to toggle source</span>
|
368
|
+
|
369
|
+
</div>
|
370
|
+
|
371
|
+
|
372
|
+
<div class="method-description">
|
373
|
+
|
374
|
+
<hr>
|
375
|
+
|
376
|
+
<p>debug method</p>
|
377
|
+
|
378
|
+
<p>Empty method so that <a href="Messenging.html">Messenging</a> doesn't
|
379
|
+
freak out when passed a debug message. @return Void</p>
|
380
|
+
<hr>
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
<div class="method-source-code" id="debug-source">
|
386
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 60</span>
|
387
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">m</span>); <span class="ruby-keyword">end</span></pre>
|
388
|
+
</div>
|
389
|
+
|
390
|
+
</div>
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
</div>
|
396
|
+
|
397
|
+
|
398
|
+
<div id="method-i-error" class="method-detail ">
|
399
|
+
|
400
|
+
<div class="method-heading">
|
401
|
+
<span class="method-name">error</span><span
|
402
|
+
class="method-args">(m)</span>
|
403
|
+
|
404
|
+
<span class="method-click-advice">click to toggle source</span>
|
405
|
+
|
406
|
+
</div>
|
407
|
+
|
408
|
+
|
409
|
+
<div class="method-description">
|
410
|
+
|
411
|
+
<hr>
|
412
|
+
|
413
|
+
<p>error method</p>
|
414
|
+
|
415
|
+
<p>Outputs a formatted-red error message. @param m The message to output
|
416
|
+
@return Void</p>
|
417
|
+
<hr>
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
<div class="method-source-code" id="error-source">
|
423
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 69</span>
|
424
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">error</span>(<span class="ruby-identifier">m</span>)
|
425
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m</span>, <span class="ruby-string">'# '</span>).<span class="ruby-identifier">red</span>
|
426
|
+
<span class="ruby-keyword">end</span></pre>
|
427
|
+
</div>
|
428
|
+
|
429
|
+
</div>
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
</div>
|
435
|
+
|
436
|
+
|
437
|
+
<div id="method-i-info" class="method-detail ">
|
438
|
+
|
439
|
+
<div class="method-heading">
|
440
|
+
<span class="method-name">info</span><span
|
441
|
+
class="method-args">(m)</span>
|
442
|
+
|
443
|
+
<span class="method-click-advice">click to toggle source</span>
|
444
|
+
|
445
|
+
</div>
|
446
|
+
|
447
|
+
|
448
|
+
<div class="method-description">
|
449
|
+
|
450
|
+
<hr>
|
451
|
+
|
452
|
+
<p>info method</p>
|
453
|
+
|
454
|
+
<p>Outputs a formatted-blue informational message. @param m The message to
|
455
|
+
output @return Void</p>
|
456
|
+
<hr>
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
<div class="method-source-code" id="info-source">
|
462
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 80</span>
|
463
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">info</span>(<span class="ruby-identifier">m</span>)
|
464
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m</span>, <span class="ruby-string">'# '</span>).<span class="ruby-identifier">blue</span>
|
465
|
+
<span class="ruby-keyword">end</span></pre>
|
466
|
+
</div>
|
467
|
+
|
468
|
+
</div>
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
</div>
|
474
|
+
|
475
|
+
|
476
|
+
<div id="method-i-info_block" class="method-detail ">
|
477
|
+
|
478
|
+
<div class="method-heading">
|
479
|
+
<span class="method-name">info_block</span><span
|
480
|
+
class="method-args">(m1, m2 = 'Done.', multiline = false) { || ... }</span>
|
481
|
+
|
482
|
+
<span class="method-click-advice">click to toggle source</span>
|
483
|
+
|
484
|
+
</div>
|
485
|
+
|
486
|
+
|
487
|
+
<div class="method-description">
|
488
|
+
|
489
|
+
<hr>
|
490
|
+
|
491
|
+
<p><a href="PrettyIO.html#method-i-info_block">#info_block</a> method</p>
|
492
|
+
|
493
|
+
<p>Wraps a block in an opening and closing info message. @param m1 The opening
|
494
|
+
message to output @param m2 The closing message to output @param multiline
|
495
|
+
Whether the message should be multiline @return Void</p>
|
496
|
+
<hr>
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
<div class="method-source-code" id="info_block-source">
|
502
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 93</span>
|
503
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">info_block</span>(<span class="ruby-identifier">m1</span>, <span class="ruby-identifier">m2</span> = <span class="ruby-string">'Done.'</span>, <span class="ruby-identifier">multiline</span> = <span class="ruby-keyword">false</span>)
|
504
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
|
505
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">multiline</span>
|
506
|
+
<span class="ruby-identifier">info</span>(<span class="ruby-identifier">m1</span>)
|
507
|
+
<span class="ruby-keyword">else</span>
|
508
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m1</span>, <span class="ruby-string">'# '</span>).<span class="ruby-identifier">blue</span>
|
509
|
+
<span class="ruby-keyword">end</span>
|
510
|
+
|
511
|
+
<span class="ruby-keyword">yield</span>
|
512
|
+
|
513
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">multiline</span>
|
514
|
+
<span class="ruby-identifier">info</span>(<span class="ruby-identifier">m2</span>)
|
515
|
+
<span class="ruby-keyword">else</span>
|
516
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m2</span>, <span class="ruby-string">'# '</span>).<span class="ruby-identifier">blue</span>
|
517
|
+
<span class="ruby-keyword">end</span>
|
518
|
+
<span class="ruby-keyword">else</span>
|
519
|
+
<span class="ruby-identifier">fail</span> <span class="ruby-string">'Did not specify a valid block'</span>
|
520
|
+
<span class="ruby-keyword">end</span>
|
521
|
+
<span class="ruby-keyword">end</span></pre>
|
522
|
+
</div>
|
523
|
+
|
524
|
+
</div>
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
</div>
|
530
|
+
|
531
|
+
|
532
|
+
<div id="method-i-log" class="method-detail ">
|
533
|
+
|
534
|
+
<div class="method-heading">
|
535
|
+
<span class="method-name">log</span><span
|
536
|
+
class="method-args">(m)</span>
|
537
|
+
|
538
|
+
<span class="method-click-advice">click to toggle source</span>
|
539
|
+
|
540
|
+
</div>
|
541
|
+
|
542
|
+
|
543
|
+
<div class="method-description">
|
544
|
+
|
545
|
+
<hr>
|
546
|
+
|
547
|
+
<p>log method</p>
|
548
|
+
|
549
|
+
<p>Empty method so that <a href="Messenging.html">Messenging</a> doesn't
|
550
|
+
freak out when passed a debug message. @return Void</p>
|
551
|
+
<hr>
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
<div class="method-source-code" id="log-source">
|
557
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 120</span>
|
558
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">log</span>(<span class="ruby-identifier">m</span>); <span class="ruby-keyword">end</span></pre>
|
559
|
+
</div>
|
560
|
+
|
561
|
+
</div>
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
</div>
|
567
|
+
|
568
|
+
|
569
|
+
<div id="method-i-prompt" class="method-detail ">
|
570
|
+
|
571
|
+
<div class="method-heading">
|
572
|
+
<span class="method-name">prompt</span><span
|
573
|
+
class="method-args">(prompt, default = nil, start_dir = '')</span>
|
574
|
+
|
575
|
+
<span class="method-click-advice">click to toggle source</span>
|
576
|
+
|
577
|
+
</div>
|
578
|
+
|
579
|
+
|
580
|
+
<div class="method-description">
|
581
|
+
|
582
|
+
<hr>
|
583
|
+
|
584
|
+
<p>prompt method</p>
|
585
|
+
|
586
|
+
<p>Outputs a prompt, collects the user's response, and returns it. @param
|
587
|
+
prompt The prompt to output @param default The default option @return <a
|
588
|
+
href="../String.html">String</a></p>
|
589
|
+
<hr>
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
|
594
|
+
<div class="method-source-code" id="prompt-source">
|
595
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 131</span>
|
596
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">prompt</span>(<span class="ruby-identifier">prompt</span>, <span class="ruby-identifier">default</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">start_dir</span> = <span class="ruby-string">''</span>)
|
597
|
+
<span class="ruby-constant">Readline</span>.<span class="ruby-identifier">completion_append_character</span> = <span class="ruby-keyword">nil</span>
|
598
|
+
<span class="ruby-constant">Readline</span>.<span class="ruby-identifier">completion_proc</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">prefix</span><span class="ruby-operator">|</span>
|
599
|
+
<span class="ruby-identifier">files</span> = <span class="ruby-constant">Dir</span>[<span class="ruby-node">"#{start_dir}#{prefix}*"</span>]
|
600
|
+
<span class="ruby-identifier">files</span>.
|
601
|
+
<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">f</span>) }.
|
602
|
+
<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">+</span> <span class="ruby-string">"/"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">f</span> }
|
603
|
+
<span class="ruby-keyword">end</span>
|
604
|
+
<span class="ruby-identifier">choice</span> = <span class="ruby-constant">Readline</span>.<span class="ruby-identifier">readline</span>(<span class="ruby-node">"# #{ prompt }#{ default.nil? ? ':' : " [default: #{ default }]:" } "</span>.<span class="ruby-identifier">cyan</span>)
|
605
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">choice</span>.<span class="ruby-identifier">empty?</span>
|
606
|
+
<span class="ruby-identifier">default</span>
|
607
|
+
<span class="ruby-keyword">else</span>
|
608
|
+
<span class="ruby-identifier">choice</span>
|
609
|
+
<span class="ruby-keyword">end</span>
|
610
|
+
<span class="ruby-keyword">end</span></pre>
|
611
|
+
</div>
|
612
|
+
|
613
|
+
</div>
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
</div>
|
619
|
+
|
620
|
+
|
621
|
+
<div id="method-i-section" class="method-detail ">
|
622
|
+
|
623
|
+
<div class="method-heading">
|
624
|
+
<span class="method-name">section</span><span
|
625
|
+
class="method-args">(m)</span>
|
626
|
+
|
627
|
+
<span class="method-click-advice">click to toggle source</span>
|
628
|
+
|
629
|
+
</div>
|
630
|
+
|
631
|
+
|
632
|
+
<div class="method-description">
|
633
|
+
|
634
|
+
<hr>
|
635
|
+
|
636
|
+
<p>section method</p>
|
637
|
+
|
638
|
+
<p>Outputs a formatted-purple section message. @param m The message to output
|
639
|
+
@return Void</p>
|
640
|
+
<hr>
|
641
|
+
|
642
|
+
|
643
|
+
|
644
|
+
|
645
|
+
<div class="method-source-code" id="section-source">
|
646
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 154</span>
|
647
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">section</span>(<span class="ruby-identifier">m</span>)
|
648
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m</span>, <span class="ruby-string">'---> '</span>).<span class="ruby-identifier">purple</span>
|
649
|
+
<span class="ruby-keyword">end</span></pre>
|
650
|
+
</div>
|
651
|
+
|
652
|
+
</div>
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
</div>
|
658
|
+
|
659
|
+
|
660
|
+
<div id="method-i-section_block" class="method-detail ">
|
661
|
+
|
662
|
+
<div class="method-heading">
|
663
|
+
<span class="method-name">section_block</span><span
|
664
|
+
class="method-args">(m, multiline = true) { || ... }</span>
|
665
|
+
|
666
|
+
<span class="method-click-advice">click to toggle source</span>
|
667
|
+
|
668
|
+
</div>
|
669
|
+
|
670
|
+
|
671
|
+
<div class="method-description">
|
672
|
+
|
673
|
+
<hr>
|
674
|
+
|
675
|
+
<p><a href="PrettyIO.html#method-i-section_block">#section_block</a> method</p>
|
676
|
+
|
677
|
+
<p>Wraps a block in an opening and closing section message. @param m1 The
|
678
|
+
opening message to output @param m2 The closing message to output @param
|
679
|
+
multiline A multiline message or not @return Void</p>
|
680
|
+
<hr>
|
681
|
+
|
682
|
+
|
683
|
+
|
684
|
+
|
685
|
+
<div class="method-source-code" id="section_block-source">
|
686
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 168</span>
|
687
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">section_block</span>(<span class="ruby-identifier">m</span>, <span class="ruby-identifier">multiline</span> = <span class="ruby-keyword">true</span>)
|
688
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
|
689
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">multiline</span>
|
690
|
+
<span class="ruby-identifier">section</span>(<span class="ruby-identifier">m</span>)
|
691
|
+
<span class="ruby-keyword">else</span>
|
692
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m</span>, <span class="ruby-string">'---> '</span>).<span class="ruby-identifier">purple</span>
|
693
|
+
<span class="ruby-keyword">end</span>
|
694
|
+
|
695
|
+
<span class="ruby-keyword">yield</span>
|
696
|
+
<span class="ruby-keyword">else</span>
|
697
|
+
<span class="ruby-identifier">fail</span> <span class="ruby-string">'Did not specify a valid block'</span>
|
698
|
+
<span class="ruby-keyword">end</span>
|
699
|
+
<span class="ruby-keyword">end</span></pre>
|
700
|
+
</div>
|
701
|
+
|
702
|
+
</div>
|
703
|
+
|
704
|
+
|
705
|
+
|
706
|
+
|
707
|
+
</div>
|
708
|
+
|
709
|
+
|
710
|
+
<div id="method-i-success" class="method-detail ">
|
711
|
+
|
712
|
+
<div class="method-heading">
|
713
|
+
<span class="method-name">success</span><span
|
714
|
+
class="method-args">(m)</span>
|
715
|
+
|
716
|
+
<span class="method-click-advice">click to toggle source</span>
|
717
|
+
|
718
|
+
</div>
|
719
|
+
|
720
|
+
|
721
|
+
<div class="method-description">
|
722
|
+
|
723
|
+
<hr>
|
724
|
+
|
725
|
+
<p>success method</p>
|
726
|
+
|
727
|
+
<p>Outputs a formatted-green success message. @param m The message to output
|
728
|
+
@return Void</p>
|
729
|
+
<hr>
|
730
|
+
|
731
|
+
|
732
|
+
|
733
|
+
|
734
|
+
<div class="method-source-code" id="success-source">
|
735
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 189</span>
|
736
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">success</span>(<span class="ruby-identifier">m</span>)
|
737
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m</span>, <span class="ruby-string">'# '</span>).<span class="ruby-identifier">green</span>
|
738
|
+
<span class="ruby-keyword">end</span></pre>
|
739
|
+
</div>
|
740
|
+
|
741
|
+
</div>
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
</div>
|
747
|
+
|
748
|
+
|
749
|
+
<div id="method-i-warn" class="method-detail ">
|
750
|
+
|
751
|
+
<div class="method-heading">
|
752
|
+
<span class="method-name">warn</span><span
|
753
|
+
class="method-args">(m)</span>
|
754
|
+
|
755
|
+
<span class="method-click-advice">click to toggle source</span>
|
756
|
+
|
757
|
+
</div>
|
758
|
+
|
759
|
+
|
760
|
+
<div class="method-description">
|
761
|
+
|
762
|
+
<hr>
|
763
|
+
|
764
|
+
<p>warning method</p>
|
765
|
+
|
766
|
+
<p>Outputs a formatted-yellow warning message. @param m The message to output
|
767
|
+
@return Void</p>
|
768
|
+
<hr>
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
<div class="method-source-code" id="warn-source">
|
774
|
+
<pre><span class="ruby-comment"># File lib/cliutils/pretty-io.rb, line 200</span>
|
775
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">warn</span>(<span class="ruby-identifier">m</span>)
|
776
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">_word_wrap</span>(<span class="ruby-identifier">m</span>, <span class="ruby-string">'# '</span>).<span class="ruby-identifier">yellow</span>
|
777
|
+
<span class="ruby-keyword">end</span></pre>
|
778
|
+
</div>
|
779
|
+
|
780
|
+
</div>
|
781
|
+
|
782
|
+
|
783
|
+
|
784
|
+
|
785
|
+
</div>
|
786
|
+
|
787
|
+
|
788
|
+
</section>
|
789
|
+
|
790
|
+
</section>
|
791
|
+
</main>
|
792
|
+
|
793
|
+
|
794
|
+
<footer id="validator-badges" role="contentinfo">
|
795
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
796
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
797
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
798
|
+
</footer>
|
799
|
+
|