bovem 1.2.6 → 2.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 (50) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +1 -1
  3. data/README.md +5 -2
  4. data/bovem.gemspec +11 -9
  5. data/doc/Bovem.html +7 -25
  6. data/doc/Bovem/Configuration.html +30 -43
  7. data/doc/Bovem/Console.html +225 -4360
  8. data/doc/Bovem/ConsoleMethods.html +125 -0
  9. data/doc/Bovem/ConsoleMethods/Interactions.html +575 -0
  10. data/doc/Bovem/ConsoleMethods/Interactions/ClassMethods.html +231 -0
  11. data/doc/Bovem/ConsoleMethods/Logging.html +2218 -0
  12. data/doc/Bovem/ConsoleMethods/Logging/ClassMethods.html +212 -0
  13. data/doc/Bovem/ConsoleMethods/Output.html +1213 -0
  14. data/doc/Bovem/ConsoleMethods/StyleHandling.html +274 -0
  15. data/doc/Bovem/ConsoleMethods/StyleHandling/ClassMethods.html +653 -0
  16. data/doc/Bovem/Errors.html +3 -3
  17. data/doc/Bovem/Errors/InvalidConfiguration.html +3 -3
  18. data/doc/Bovem/Errors/InvalidLogger.html +3 -3
  19. data/doc/Bovem/Logger.html +112 -12
  20. data/doc/Bovem/Shell.html +58 -1888
  21. data/doc/Bovem/ShellMethods.html +125 -0
  22. data/doc/Bovem/ShellMethods/Directories.html +484 -0
  23. data/doc/Bovem/ShellMethods/Execute.html +565 -0
  24. data/doc/Bovem/ShellMethods/General.html +450 -0
  25. data/doc/Bovem/ShellMethods/Read.html +451 -0
  26. data/doc/Bovem/ShellMethods/Write.html +676 -0
  27. data/doc/Bovem/Version.html +6 -6
  28. data/doc/_index.html +145 -4
  29. data/doc/class_list.html +1 -1
  30. data/doc/file.README.html +10 -7
  31. data/doc/frames.html +1 -1
  32. data/doc/index.html +10 -7
  33. data/doc/method_list.html +119 -79
  34. data/doc/top-level-namespace.html +3 -3
  35. data/lib/bovem.rb +1 -1
  36. data/lib/bovem/configuration.rb +24 -13
  37. data/lib/bovem/console.rb +566 -497
  38. data/lib/bovem/errors.rb +1 -1
  39. data/lib/bovem/logger.rb +4 -4
  40. data/lib/bovem/shell.rb +482 -305
  41. data/lib/bovem/version.rb +4 -4
  42. data/locales/en.yml +43 -0
  43. data/locales/it.yml +43 -0
  44. data/spec/bovem/configuration_spec.rb +3 -3
  45. data/spec/bovem/console_spec.rb +17 -10
  46. data/spec/bovem/logger_spec.rb +1 -1
  47. data/spec/bovem/shell_spec.rb +9 -5
  48. data/spec/coverage_helper.rb +1 -1
  49. data/spec/spec_helper.rb +1 -1
  50. metadata +32 -22
@@ -0,0 +1,450 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Bovem::ShellMethods::General
8
+
9
+ &mdash; Documentation by YARD 0.8.3
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (G)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ShellMethods.html" title="Bovem::ShellMethods (module)">ShellMethods</a></span></span>
36
+ &raquo;
37
+ <span class="title">General</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Bovem::ShellMethods::General
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+ <dt class="r1">Included in:</dt>
81
+ <dd class="r1"><span class='object_link'><a href="../Shell.html" title="Bovem::Shell (class)">Bovem::Shell</a></span></dd>
82
+
83
+
84
+
85
+ <dt class="r2 last">Defined in:</dt>
86
+ <dd class="r2 last">lib/bovem/shell.rb</dd>
87
+
88
+ </dl>
89
+ <div class="clear"></div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+ <p>General methods.</p>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+
101
+ </div>
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <h2>
110
+ Instance Method Summary
111
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
112
+ </h2>
113
+
114
+ <ul class="summary">
115
+
116
+ <li class="public ">
117
+ <span class="summary_signature">
118
+
119
+ <a href="#handle_failure-instance_method" title="#handle_failure (instance method)">- (Object) <strong>handle_failure</strong>(e, access_error, not_found_error, general_error, entries, fatal, show_errors) </a>
120
+
121
+
122
+
123
+ </span>
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'><p>Handles general failure of a file/directory method.</p>
134
+ </div></span>
135
+
136
+ </li>
137
+
138
+
139
+ <li class="public ">
140
+ <span class="summary_signature">
141
+
142
+ <a href="#show_general_failure-instance_method" title="#show_general_failure (instance method)">- (Object) <strong>show_general_failure</strong>(e, general_error, entries, fatal) </a>
143
+
144
+
145
+
146
+ </span>
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+ <span class="summary_desc"><div class='inline'><p>Shows errors when a directory creation failed.</p>
157
+ </div></span>
158
+
159
+ </li>
160
+
161
+
162
+ </ul>
163
+
164
+
165
+
166
+
167
+ <div id="instance_method_details" class="method_details_list">
168
+ <h2>Instance Method Details</h2>
169
+
170
+
171
+ <div class="method_details first">
172
+ <h3 class="signature first" id="handle_failure-instance_method">
173
+
174
+ - (<tt>Object</tt>) <strong>handle_failure</strong>(e, access_error, not_found_error, general_error, entries, fatal, show_errors)
175
+
176
+
177
+
178
+
179
+
180
+ </h3><div class="docstring">
181
+ <div class="discussion">
182
+ <p>Handles general failure of a file/directory method.</p>
183
+
184
+
185
+ </div>
186
+ </div>
187
+ <div class="tags">
188
+ <p class="tag_title">Parameters:</p>
189
+ <ul class="param">
190
+
191
+ <li>
192
+
193
+ <span class='name'>e</span>
194
+
195
+
196
+ <span class='type'>(<tt>Exception</tt>)</span>
197
+
198
+
199
+
200
+ &mdash;
201
+ <div class='inline'><p>The occurred exception.</p>
202
+ </div>
203
+
204
+ </li>
205
+
206
+ <li>
207
+
208
+ <span class='name'>access_error</span>
209
+
210
+
211
+ <span class='type'>(<tt>String|Symbol</tt>)</span>
212
+
213
+
214
+
215
+ &mdash;
216
+ <div class='inline'><p>The message to show in case of access errors.</p>
217
+ </div>
218
+
219
+ </li>
220
+
221
+ <li>
222
+
223
+ <span class='name'>not_found_error</span>
224
+
225
+
226
+ <span class='type'>(<tt>String|Symbol</tt>)</span>
227
+
228
+
229
+
230
+ &mdash;
231
+ <div class='inline'><p>The message to show in case of a not found entry.</p>
232
+ </div>
233
+
234
+ </li>
235
+
236
+ <li>
237
+
238
+ <span class='name'>general_error</span>
239
+
240
+
241
+ <span class='type'>(<tt>String|Symbol</tt>)</span>
242
+
243
+
244
+
245
+ &mdash;
246
+ <div class='inline'><p>The message to show in case of other errors.</p>
247
+ </div>
248
+
249
+ </li>
250
+
251
+ <li>
252
+
253
+ <span class='name'>entries</span>
254
+
255
+
256
+ <span class='type'>(<tt>Array</tt>)</span>
257
+
258
+
259
+
260
+ &mdash;
261
+ <div class='inline'><p>The list of entries which failed.</p>
262
+ </div>
263
+
264
+ </li>
265
+
266
+ <li>
267
+
268
+ <span class='name'>fatal</span>
269
+
270
+
271
+ <span class='type'>(<tt>Boolean</tt>)</span>
272
+
273
+
274
+
275
+ &mdash;
276
+ <div class='inline'><p>If quit in case of fatal errors.</p>
277
+ </div>
278
+
279
+ </li>
280
+
281
+ <li>
282
+
283
+ <span class='name'>show_errors</span>
284
+
285
+
286
+ <span class='type'>(<tt>Boolean</tt>)</span>
287
+
288
+
289
+
290
+ &mdash;
291
+ <div class='inline'><p>Whether to show errors.</p>
292
+ </div>
293
+
294
+ </li>
295
+
296
+ </ul>
297
+
298
+
299
+ </div><table class="source_code">
300
+ <tr>
301
+ <td>
302
+ <pre class="lines">
303
+
304
+
305
+ 21
306
+ 22
307
+ 23
308
+ 24
309
+ 25
310
+ 26
311
+ 27
312
+ 28
313
+ 29
314
+ 30
315
+ 31</pre>
316
+ </td>
317
+ <td>
318
+ <pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 21</span>
319
+
320
+ <span class='kw'>def</span> <span class='id identifier rubyid_handle_failure'>handle_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='comma'>,</span> <span class='id identifier rubyid_access_error'>access_error</span><span class='comma'>,</span> <span class='id identifier rubyid_not_found_error'>not_found_error</span><span class='comma'>,</span> <span class='id identifier rubyid_general_error'>general_error</span><span class='comma'>,</span> <span class='id identifier rubyid_entries'>entries</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span><span class='rparen'>)</span>
321
+ <span class='id identifier rubyid_error_type'>error_type</span> <span class='op'>=</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>?</span> <span class='symbol'>:fatal</span> <span class='op'>:</span> <span class='symbol'>:error</span>
322
+ <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>.+ - (.+)</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\1</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
323
+ <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_shell'>shell</span>
324
+
325
+ <span class='kw'>case</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
326
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Errno::EACCES</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='ivar'>@console</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_error_type'>error_type</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_access_error'>access_error</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span><span class='rparen'>)</span>
327
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Errno::ENOENT</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='ivar'>@console</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_error_type'>error_type</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_not_found_error'>not_found_error</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span><span class='rparen'>)</span>
328
+ <span class='kw'>else</span> <span class='id identifier rubyid_show_general_failure'>show_general_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='comma'>,</span> <span class='id identifier rubyid_general_error'>general_error</span><span class='comma'>,</span> <span class='id identifier rubyid_entries'>entries</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_show_errors'>show_errors</span>
329
+ <span class='kw'>end</span>
330
+ <span class='kw'>end</span></pre>
331
+ </td>
332
+ </tr>
333
+ </table>
334
+ </div>
335
+
336
+ <div class="method_details ">
337
+ <h3 class="signature " id="show_general_failure-instance_method">
338
+
339
+ - (<tt>Object</tt>) <strong>show_general_failure</strong>(e, general_error, entries, fatal)
340
+
341
+
342
+
343
+
344
+
345
+ </h3><div class="docstring">
346
+ <div class="discussion">
347
+ <p>Shows errors when a directory creation failed.</p>
348
+
349
+
350
+ </div>
351
+ </div>
352
+ <div class="tags">
353
+ <p class="tag_title">Parameters:</p>
354
+ <ul class="param">
355
+
356
+ <li>
357
+
358
+ <span class='name'>e</span>
359
+
360
+
361
+ <span class='type'>(<tt>Exception</tt>)</span>
362
+
363
+
364
+
365
+ &mdash;
366
+ <div class='inline'><p>The occurred exception.</p>
367
+ </div>
368
+
369
+ </li>
370
+
371
+ <li>
372
+
373
+ <span class='name'>entries</span>
374
+
375
+
376
+ <span class='type'>(<tt>Array</tt>)</span>
377
+
378
+
379
+
380
+ &mdash;
381
+ <div class='inline'><p>The list of entries which failed.</p>
382
+ </div>
383
+
384
+ </li>
385
+
386
+ <li>
387
+
388
+ <span class='name'>fatal</span>
389
+
390
+
391
+ <span class='type'>(<tt>Boolean</tt>)</span>
392
+
393
+
394
+
395
+ &mdash;
396
+ <div class='inline'><p>If quit in case of fatal errors.</p>
397
+ </div>
398
+
399
+ </li>
400
+
401
+ </ul>
402
+
403
+
404
+ </div><table class="source_code">
405
+ <tr>
406
+ <td>
407
+ <pre class="lines">
408
+
409
+
410
+ 38
411
+ 39
412
+ 40
413
+ 41
414
+ 42
415
+ 43
416
+ 44
417
+ 45
418
+ 46
419
+ 47</pre>
420
+ </td>
421
+ <td>
422
+ <pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 38</span>
423
+
424
+ <span class='kw'>def</span> <span class='id identifier rubyid_show_general_failure'>show_general_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='comma'>,</span> <span class='id identifier rubyid_general_error'>general_error</span><span class='comma'>,</span> <span class='id identifier rubyid_entries'>entries</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
425
+ <span class='id identifier rubyid_locale'>locale</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_shell'>shell</span>
426
+
427
+ <span class='ivar'>@console</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_general_error'>general_error</span><span class='rparen'>)</span><span class='rparen'>)</span>
428
+ <span class='ivar'>@console</span><span class='period'>.</span><span class='id identifier rubyid_with_indentation'>with_indentation</span><span class='lparen'>(</span><span class='int'>11</span><span class='rparen'>)</span> <span class='kw'>do</span>
429
+ <span class='id identifier rubyid_entries'>entries</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span> <span class='ivar'>@console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='rparen'>)</span> <span class='kw'>end</span>
430
+ <span class='kw'>end</span>
431
+ <span class='ivar'>@console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='int'>5</span><span class='rparen'>)</span>
432
+ <span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_fatal'>fatal</span>
433
+ <span class='kw'>end</span></pre>
434
+ </td>
435
+ </tr>
436
+ </table>
437
+ </div>
438
+
439
+ </div>
440
+
441
+ </div>
442
+
443
+ <div id="footer">
444
+ Generated on Fri Feb 1 23:40:17 2013 by
445
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
446
+ 0.8.3 (ruby-1.9.3).
447
+ </div>
448
+
449
+ </body>
450
+ </html>
@@ -0,0 +1,451 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Bovem::ShellMethods::Read
8
+
9
+ &mdash; Documentation by YARD 0.8.3
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (R)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ShellMethods.html" title="Bovem::ShellMethods (module)">ShellMethods</a></span></span>
36
+ &raquo;
37
+ <span class="title">Read</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Bovem::ShellMethods::Read
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+ <dt class="r1">Included in:</dt>
81
+ <dd class="r1"><span class='object_link'><a href="../Shell.html" title="Bovem::Shell (class)">Bovem::Shell</a></span></dd>
82
+
83
+
84
+
85
+ <dt class="r2 last">Defined in:</dt>
86
+ <dd class="r2 last">lib/bovem/shell.rb</dd>
87
+
88
+ </dl>
89
+ <div class="clear"></div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+ <p>Methods to find or check entries.</p>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+
101
+ </div>
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <h2>
110
+ Instance Method Summary
111
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
112
+ </h2>
113
+
114
+ <ul class="summary">
115
+
116
+ <li class="public ">
117
+ <span class="summary_signature">
118
+
119
+ <a href="#check-instance_method" title="#check (instance method)">- (Object) <strong>check</strong>(path, tests) </a>
120
+
121
+
122
+
123
+ </span>
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'><p>Tests a path against a list of test.</p>
134
+ </div></span>
135
+
136
+ </li>
137
+
138
+
139
+ <li class="public ">
140
+ <span class="summary_signature">
141
+
142
+ <a href="#find-instance_method" title="#find (instance method)">- (Object) <strong>find</strong>(directories, patterns = [], by_extension = false, case_sensitive = false, &amp;block) </a>
143
+
144
+
145
+
146
+ </span>
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+ <span class="summary_desc"><div class='inline'><p>Find a list of files in directories matching given regexps or patterns.</p>
157
+ </div></span>
158
+
159
+ </li>
160
+
161
+
162
+ </ul>
163
+
164
+
165
+
166
+
167
+ <div id="instance_method_details" class="method_details_list">
168
+ <h2>Instance Method Details</h2>
169
+
170
+
171
+ <div class="method_details first">
172
+ <h3 class="signature first" id="check-instance_method">
173
+
174
+ - (<tt>Object</tt>) <strong>check</strong>(path, tests)
175
+
176
+
177
+
178
+
179
+
180
+ </h3><div class="docstring">
181
+ <div class="discussion">
182
+ <p>Tests a path against a list of test.</p>
183
+
184
+ <p>Valid tests are every method available in <a href="http://www.ruby-doc.org/core-1.9.3/FileTest.html">http://www.ruby-doc.org/core-1.9.3/FileTest.html</a> (plus <code>read</code>, <code>write</code>, <code>execute</code>, <code>exec</code>, <code>dir</code>). Trailing question mark can be omitted.</p>
185
+
186
+
187
+ </div>
188
+ </div>
189
+ <div class="tags">
190
+ <p class="tag_title">Parameters:</p>
191
+ <ul class="param">
192
+
193
+ <li>
194
+
195
+ <span class='name'>path</span>
196
+
197
+
198
+ <span class='type'>(<tt>String</tt>)</span>
199
+
200
+
201
+
202
+ &mdash;
203
+ <div class='inline'><p>The path to test.</p>
204
+ </div>
205
+
206
+ </li>
207
+
208
+ <li>
209
+
210
+ <span class='name'>tests</span>
211
+
212
+
213
+ <span class='type'>(<tt>Array</tt>)</span>
214
+
215
+
216
+
217
+ &mdash;
218
+ <div class='inline'><p>The list of tests to perform.</p>
219
+ </div>
220
+
221
+ </li>
222
+
223
+ </ul>
224
+
225
+
226
+ </div><table class="source_code">
227
+ <tr>
228
+ <td>
229
+ <pre class="lines">
230
+
231
+
232
+ 58
233
+ 59
234
+ 60
235
+ 61
236
+ 62
237
+ 63
238
+ 64
239
+ 65
240
+ 66
241
+ 67
242
+ 68
243
+ 69
244
+ 70
245
+ 71
246
+ 72
247
+ 73
248
+ 74
249
+ 75
250
+ 76
251
+ 77</pre>
252
+ </td>
253
+ <td>
254
+ <pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 58</span>
255
+
256
+ <span class='kw'>def</span> <span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_tests'>tests</span><span class='rparen'>)</span>
257
+ <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
258
+
259
+ <span class='id identifier rubyid_tests'>tests</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_test'>test</span><span class='op'>|</span>
260
+ <span class='comment'># Adjust test name
261
+ </span> <span class='id identifier rubyid_test'>test</span> <span class='op'>=</span> <span class='id identifier rubyid_test'>test</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
262
+
263
+ <span class='id identifier rubyid_test'>test</span> <span class='op'>=</span> <span class='kw'>case</span> <span class='id identifier rubyid_test'>test</span>
264
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>read</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>readable</span><span class='tstring_end'>&quot;</span></span>
265
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>write</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>writable</span><span class='tstring_end'>&quot;</span></span>
266
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>execute</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>exec</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>executable</span><span class='tstring_end'>&quot;</span></span>
267
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>dir</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>directory</span><span class='tstring_end'>&quot;</span></span>
268
+ <span class='kw'>else</span> <span class='id identifier rubyid_test'>test</span>
269
+ <span class='kw'>end</span>
270
+
271
+ <span class='comment'># Execute test
272
+ </span> <span class='id identifier rubyid_test'>test</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>?</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_test'>test</span> <span class='op'>!~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\?$</span><span class='regexp_end'>/</span></span>
273
+ <span class='const'>FileTest</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_test'>test</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='const'>FileTest</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_test'>test</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
274
+ <span class='rbrace'>}</span>
275
+ <span class='kw'>end</span></pre>
276
+ </td>
277
+ </tr>
278
+ </table>
279
+ </div>
280
+
281
+ <div class="method_details ">
282
+ <h3 class="signature " id="find-instance_method">
283
+
284
+ - (<tt>Object</tt>) <strong>find</strong>(directories, patterns = [], by_extension = false, case_sensitive = false, &amp;block)
285
+
286
+
287
+
288
+
289
+
290
+ </h3><div class="docstring">
291
+ <div class="discussion">
292
+ <p>Find a list of files in directories matching given regexps or patterns.</p>
293
+
294
+ <p>You can also pass a block to perform matching. The block will receive a single argument and the path will be considered matched if the blocks not evaluates to <code>nil</code> or <code>false</code>.</p>
295
+
296
+ <p>Inside the block, you can call <code>Find.prune</code> to stop searching in the current directory.</p>
297
+
298
+
299
+ </div>
300
+ </div>
301
+ <div class="tags">
302
+ <p class="tag_title">Parameters:</p>
303
+ <ul class="param">
304
+
305
+ <li>
306
+
307
+ <span class='name'>directories</span>
308
+
309
+
310
+ <span class='type'>(<tt>String</tt>)</span>
311
+
312
+
313
+
314
+ &mdash;
315
+ <div class='inline'><p>A list of directories where to search files.</p>
316
+ </div>
317
+
318
+ </li>
319
+
320
+ <li>
321
+
322
+ <span class='name'>patterns</span>
323
+
324
+
325
+ <span class='type'>(<tt>Array</tt>)</span>
326
+
327
+
328
+ <em class="default">(defaults to: <tt>[]</tt>)</em>
329
+
330
+
331
+ &mdash;
332
+ <div class='inline'><p>A list of regexps or patterns to match files. If empty, every file is returned. Ignored if a block is provided.</p>
333
+ </div>
334
+
335
+ </li>
336
+
337
+ <li>
338
+
339
+ <span class='name'>by_extension</span>
340
+
341
+
342
+ <span class='type'>(<tt>Boolean</tt>)</span>
343
+
344
+
345
+ <em class="default">(defaults to: <tt>false</tt>)</em>
346
+
347
+
348
+ &mdash;
349
+ <div class='inline'><p>If to only search in extensions. Ignored if a block is provided.</p>
350
+ </div>
351
+
352
+ </li>
353
+
354
+ <li>
355
+
356
+ <span class='name'>case_sensitive</span>
357
+
358
+
359
+ <span class='type'>(<tt>Boolean</tt>)</span>
360
+
361
+
362
+ <em class="default">(defaults to: <tt>false</tt>)</em>
363
+
364
+
365
+ &mdash;
366
+ <div class='inline'><p>If the search is case sensitive. Only meaningful for string patterns.</p>
367
+ </div>
368
+
369
+ </li>
370
+
371
+ <li>
372
+
373
+ <span class='name'>block</span>
374
+
375
+
376
+ <span class='type'>(<tt>Proc</tt>)</span>
377
+
378
+
379
+
380
+ &mdash;
381
+ <div class='inline'><p>An optional block to perform matching instead of pattern matching.</p>
382
+ </div>
383
+
384
+ </li>
385
+
386
+ </ul>
387
+
388
+
389
+ </div><table class="source_code">
390
+ <tr>
391
+ <td>
392
+ <pre class="lines">
393
+
394
+
395
+ 90
396
+ 91
397
+ 92
398
+ 93
399
+ 94
400
+ 95
401
+ 96
402
+ 97
403
+ 98
404
+ 99
405
+ 100
406
+ 101
407
+ 102
408
+ 103
409
+ 104
410
+ 105
411
+ 106
412
+ 107</pre>
413
+ </td>
414
+ <td>
415
+ <pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 90</span>
416
+
417
+ <span class='kw'>def</span> <span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_directories'>directories</span><span class='comma'>,</span> <span class='id identifier rubyid_patterns'>patterns</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_by_extension'>by_extension</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_case_sensitive'>case_sensitive</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
418
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
419
+
420
+ <span class='id identifier rubyid_directories'>directories</span> <span class='op'>=</span> <span class='id identifier rubyid_directories'>directories</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_d'>d</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='id identifier rubyid_d'>d</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
421
+ <span class='id identifier rubyid_patterns'>patterns</span> <span class='op'>=</span> <span class='id identifier rubyid_normalize_patterns'>normalize_patterns</span><span class='lparen'>(</span><span class='id identifier rubyid_patterns'>patterns</span><span class='comma'>,</span> <span class='id identifier rubyid_by_extension'>by_extension</span><span class='comma'>,</span> <span class='id identifier rubyid_case_sensitive'>case_sensitive</span><span class='rparen'>)</span>
422
+
423
+ <span class='id identifier rubyid_directories'>directories</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_directory'>directory</span><span class='op'>|</span>
424
+ <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:directory</span><span class='comma'>,</span> <span class='symbol'>:readable</span><span class='comma'>,</span> <span class='symbol'>:executable</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>then</span>
425
+ <span class='const'>Find</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span>
426
+ <span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='id identifier rubyid_patterns'>patterns</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>?</span> <span class='kw'>true</span> <span class='op'>:</span> <span class='id identifier rubyid_match_pattern'>match_pattern</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='comma'>,</span> <span class='id identifier rubyid_patterns'>patterns</span><span class='comma'>,</span> <span class='id identifier rubyid_by_extension'>by_extension</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
427
+
428
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_entry'>entry</span> <span class='kw'>if</span> <span class='id identifier rubyid_found'>found</span>
429
+ <span class='kw'>end</span>
430
+ <span class='kw'>end</span>
431
+ <span class='kw'>end</span>
432
+
433
+ <span class='id identifier rubyid_rv'>rv</span>
434
+ <span class='kw'>end</span></pre>
435
+ </td>
436
+ </tr>
437
+ </table>
438
+ </div>
439
+
440
+ </div>
441
+
442
+ </div>
443
+
444
+ <div id="footer">
445
+ Generated on Fri Feb 1 23:40:17 2013 by
446
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
447
+ 0.8.3 (ruby-1.9.3).
448
+ </div>
449
+
450
+ </body>
451
+ </html>