bovem 1.2.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/Gemfile +1 -1
- data/README.md +5 -2
- data/bovem.gemspec +11 -9
- data/doc/Bovem.html +7 -25
- data/doc/Bovem/Configuration.html +30 -43
- data/doc/Bovem/Console.html +225 -4360
- data/doc/Bovem/ConsoleMethods.html +125 -0
- data/doc/Bovem/ConsoleMethods/Interactions.html +575 -0
- data/doc/Bovem/ConsoleMethods/Interactions/ClassMethods.html +231 -0
- data/doc/Bovem/ConsoleMethods/Logging.html +2218 -0
- data/doc/Bovem/ConsoleMethods/Logging/ClassMethods.html +212 -0
- data/doc/Bovem/ConsoleMethods/Output.html +1213 -0
- data/doc/Bovem/ConsoleMethods/StyleHandling.html +274 -0
- data/doc/Bovem/ConsoleMethods/StyleHandling/ClassMethods.html +653 -0
- data/doc/Bovem/Errors.html +3 -3
- data/doc/Bovem/Errors/InvalidConfiguration.html +3 -3
- data/doc/Bovem/Errors/InvalidLogger.html +3 -3
- data/doc/Bovem/Logger.html +112 -12
- data/doc/Bovem/Shell.html +58 -1888
- data/doc/Bovem/ShellMethods.html +125 -0
- data/doc/Bovem/ShellMethods/Directories.html +484 -0
- data/doc/Bovem/ShellMethods/Execute.html +565 -0
- data/doc/Bovem/ShellMethods/General.html +450 -0
- data/doc/Bovem/ShellMethods/Read.html +451 -0
- data/doc/Bovem/ShellMethods/Write.html +676 -0
- data/doc/Bovem/Version.html +6 -6
- data/doc/_index.html +145 -4
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +10 -7
- data/doc/frames.html +1 -1
- data/doc/index.html +10 -7
- data/doc/method_list.html +119 -79
- data/doc/top-level-namespace.html +3 -3
- data/lib/bovem.rb +1 -1
- data/lib/bovem/configuration.rb +24 -13
- data/lib/bovem/console.rb +566 -497
- data/lib/bovem/errors.rb +1 -1
- data/lib/bovem/logger.rb +4 -4
- data/lib/bovem/shell.rb +482 -305
- data/lib/bovem/version.rb +4 -4
- data/locales/en.yml +43 -0
- data/locales/it.yml +43 -0
- data/spec/bovem/configuration_spec.rb +3 -3
- data/spec/bovem/console_spec.rb +17 -10
- data/spec/bovem/logger_spec.rb +1 -1
- data/spec/bovem/shell_spec.rb +9 -5
- data/spec/coverage_helper.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +32 -22
data/doc/Bovem/Errors.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Bovem::Errors
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -116,9 +116,9 @@
|
|
116
116
|
</div>
|
117
117
|
|
118
118
|
<div id="footer">
|
119
|
-
Generated on
|
119
|
+
Generated on Fri Feb 1 23:40:17 2013 by
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
|
-
0.8.
|
121
|
+
0.8.3 (ruby-1.9.3).
|
122
122
|
</div>
|
123
123
|
|
124
124
|
</body>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Exception: Bovem::Errors::InvalidConfiguration
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -124,9 +124,9 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Feb 1 23:40:18 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
|
-
0.8.
|
129
|
+
0.8.3 (ruby-1.9.3).
|
130
130
|
</div>
|
131
131
|
|
132
132
|
</body>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Exception: Bovem::Errors::InvalidLogger
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -124,9 +124,9 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Feb 1 23:40:18 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
|
-
0.8.
|
129
|
+
0.8.3 (ruby-1.9.3).
|
130
130
|
</div>
|
131
131
|
|
132
132
|
</body>
|
data/doc/Bovem/Logger.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Bovem::Logger
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -121,7 +121,7 @@
|
|
121
121
|
<li class="public ">
|
122
122
|
<span class="summary_signature">
|
123
123
|
|
124
|
-
<a href="#device-instance_method" title="#device (instance method)">- (
|
124
|
+
<a href="#device-instance_method" title="#device (instance method)">- (IO|String) <strong>device</strong> </a>
|
125
125
|
|
126
126
|
|
127
127
|
|
@@ -130,8 +130,6 @@
|
|
130
130
|
|
131
131
|
|
132
132
|
|
133
|
-
<span class="note title readonly">readonly</span>
|
134
|
-
|
135
133
|
|
136
134
|
|
137
135
|
|
@@ -143,6 +141,32 @@
|
|
143
141
|
<span class="summary_desc"><div class='inline'><p>The file or device to log messages to.</p>
|
144
142
|
</div></span>
|
145
143
|
|
144
|
+
</li>
|
145
|
+
|
146
|
+
|
147
|
+
<li class="public ">
|
148
|
+
<span class="summary_signature">
|
149
|
+
|
150
|
+
<a href="#start_time-instance_method" title="#start_time (instance method)">- (Time) <strong>start_time</strong> </a>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
</span>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<span class="summary_desc"><div class='inline'><p>The start time of first line.</p>
|
168
|
+
</div></span>
|
169
|
+
|
146
170
|
</li>
|
147
171
|
|
148
172
|
|
@@ -423,11 +447,11 @@
|
|
423
447
|
<h2>Instance Attribute Details</h2>
|
424
448
|
|
425
449
|
|
426
|
-
<span id=""></span>
|
450
|
+
<span id="device=-instance_method"></span>
|
427
451
|
<div class="method_details first">
|
428
452
|
<h3 class="signature first" id="device-instance_method">
|
429
453
|
|
430
|
-
- (<tt>
|
454
|
+
- (<tt>IO|String</tt>) <strong>device</strong>
|
431
455
|
|
432
456
|
|
433
457
|
|
@@ -442,6 +466,23 @@
|
|
442
466
|
</div>
|
443
467
|
<div class="tags">
|
444
468
|
|
469
|
+
<p class="tag_title">Returns:</p>
|
470
|
+
<ul class="return">
|
471
|
+
|
472
|
+
<li>
|
473
|
+
|
474
|
+
|
475
|
+
<span class='type'>(<tt>IO|String</tt>)</span>
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
—
|
480
|
+
<div class='inline'><p>the current value of device</p>
|
481
|
+
</div>
|
482
|
+
|
483
|
+
</li>
|
484
|
+
|
485
|
+
</ul>
|
445
486
|
|
446
487
|
</div><table class="source_code">
|
447
488
|
<tr>
|
@@ -449,12 +490,12 @@
|
|
449
490
|
<pre class="lines">
|
450
491
|
|
451
492
|
|
452
|
-
|
453
|
-
|
454
|
-
|
493
|
+
12
|
494
|
+
13
|
495
|
+
14</pre>
|
455
496
|
</td>
|
456
497
|
<td>
|
457
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line
|
498
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line 12</span>
|
458
499
|
|
459
500
|
<span class='kw'>def</span> <span class='id identifier rubyid_device'>device</span>
|
460
501
|
<span class='ivar'>@device</span>
|
@@ -464,6 +505,65 @@
|
|
464
505
|
</table>
|
465
506
|
</div>
|
466
507
|
|
508
|
+
|
509
|
+
<span id="start_time=-instance_method"></span>
|
510
|
+
<div class="method_details ">
|
511
|
+
<h3 class="signature " id="start_time-instance_method">
|
512
|
+
|
513
|
+
- (<tt>Time</tt>) <strong>start_time</strong>
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
</h3><div class="docstring">
|
520
|
+
<div class="discussion">
|
521
|
+
<p>The start time of first line. This allows to show a <code>T+0.1234</code> information into the log.</p>
|
522
|
+
|
523
|
+
|
524
|
+
</div>
|
525
|
+
</div>
|
526
|
+
<div class="tags">
|
527
|
+
|
528
|
+
<p class="tag_title">Returns:</p>
|
529
|
+
<ul class="return">
|
530
|
+
|
531
|
+
<li>
|
532
|
+
|
533
|
+
|
534
|
+
<span class='type'>(<tt>Time</tt>)</span>
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
—
|
539
|
+
<div class='inline'><p>the current value of start_time</p>
|
540
|
+
</div>
|
541
|
+
|
542
|
+
</li>
|
543
|
+
|
544
|
+
</ul>
|
545
|
+
|
546
|
+
</div><table class="source_code">
|
547
|
+
<tr>
|
548
|
+
<td>
|
549
|
+
<pre class="lines">
|
550
|
+
|
551
|
+
|
552
|
+
12
|
553
|
+
13
|
554
|
+
14</pre>
|
555
|
+
</td>
|
556
|
+
<td>
|
557
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/logger.rb', line 12</span>
|
558
|
+
|
559
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_start_time'>start_time</span>
|
560
|
+
<span class='ivar'>@start_time</span>
|
561
|
+
<span class='kw'>end</span></pre>
|
562
|
+
</td>
|
563
|
+
</tr>
|
564
|
+
</table>
|
565
|
+
</div>
|
566
|
+
|
467
567
|
</div>
|
468
568
|
|
469
569
|
|
@@ -887,9 +987,9 @@
|
|
887
987
|
</div>
|
888
988
|
|
889
989
|
<div id="footer">
|
890
|
-
Generated on
|
990
|
+
Generated on Fri Feb 1 23:40:18 2013 by
|
891
991
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
892
|
-
0.8.
|
992
|
+
0.8.3 (ruby-1.9.3).
|
893
993
|
</div>
|
894
994
|
|
895
995
|
</body>
|
data/doc/Bovem/Shell.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Bovem::Shell
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -90,11 +90,15 @@
|
|
90
90
|
|
91
91
|
|
92
92
|
|
93
|
+
<dt class="r2">Includes:</dt>
|
94
|
+
<dd class="r2"><span class='object_link'><a href="ShellMethods/Directories.html" title="Bovem::ShellMethods::Directories (module)">Bovem::ShellMethods::Directories</a></span>, <span class='object_link'><a href="ShellMethods/Execute.html" title="Bovem::ShellMethods::Execute (module)">Bovem::ShellMethods::Execute</a></span>, <span class='object_link'><a href="ShellMethods/General.html" title="Bovem::ShellMethods::General (module)">Bovem::ShellMethods::General</a></span>, <span class='object_link'><a href="ShellMethods/Read.html" title="Bovem::ShellMethods::Read (module)">Bovem::ShellMethods::Read</a></span>, <span class='object_link'><a href="ShellMethods/Write.html" title="Bovem::ShellMethods::Write (module)">Bovem::ShellMethods::Write</a></span>, Lazier::I18n</dd>
|
95
|
+
|
96
|
+
|
93
97
|
|
94
98
|
|
95
99
|
|
96
|
-
<dt class="
|
97
|
-
<dd class="
|
100
|
+
<dt class="r1 last">Defined in:</dt>
|
101
|
+
<dd class="r1 last">lib/bovem/shell.rb</dd>
|
98
102
|
|
99
103
|
</dl>
|
100
104
|
<div class="clear"></div>
|
@@ -119,7 +123,7 @@
|
|
119
123
|
<li class="public ">
|
120
124
|
<span class="summary_signature">
|
121
125
|
|
122
|
-
<a href="#console-instance_method" title="#console (instance method)">- (
|
126
|
+
<a href="#console-instance_method" title="#console (instance method)">- (Console) <strong>console</strong> </a>
|
123
127
|
|
124
128
|
|
125
129
|
|
@@ -136,7 +140,7 @@
|
|
136
140
|
|
137
141
|
|
138
142
|
|
139
|
-
<span class="summary_desc"><div class='inline'><
|
143
|
+
<span class="summary_desc"><div class='inline'><h1>A console instance.</h1>
|
140
144
|
</div></span>
|
141
145
|
|
142
146
|
</li>
|
@@ -190,81 +194,14 @@
|
|
190
194
|
<li class="public ">
|
191
195
|
<span class="summary_signature">
|
192
196
|
|
193
|
-
<a href="#
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
</span>
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
<span class="summary_desc"><div class='inline'><p>Tests a path against a list of test.</p>
|
208
|
-
</div></span>
|
209
|
-
|
210
|
-
</li>
|
211
|
-
|
212
|
-
|
213
|
-
<li class="public ">
|
214
|
-
<span class="summary_signature">
|
215
|
-
|
216
|
-
<a href="#copy-instance_method" title="#copy (instance method)">- (Boolean) <strong>copy</strong>(src, dst, run = true, show_errors = false, fatal = true) </a>
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
</span>
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
<span class="summary_desc"><div class='inline'><p>Copies a set of files or directory to another location.</p>
|
231
|
-
</div></span>
|
232
|
-
|
233
|
-
</li>
|
234
|
-
|
235
|
-
|
236
|
-
<li class="public ">
|
237
|
-
<span class="summary_signature">
|
238
|
-
|
239
|
-
<a href="#copy_or_move-instance_method" title="#copy_or_move (instance method)">- (Boolean) <strong>copy_or_move</strong>(src, dst, operation, run = true, show_errors = false, fatal = true) </a>
|
197
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Shell) <strong>initialize</strong> </a>
|
240
198
|
|
241
199
|
|
242
200
|
|
243
201
|
</span>
|
244
202
|
|
245
203
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
<span class="summary_desc"><div class='inline'><p>Copies or moves a set of files or directory to another location.</p>
|
254
|
-
</div></span>
|
255
|
-
|
256
|
-
</li>
|
257
|
-
|
258
|
-
|
259
|
-
<li class="public ">
|
260
|
-
<span class="summary_signature">
|
261
|
-
|
262
|
-
<a href="#create_directories-instance_method" title="#create_directories (instance method)">- (Boolean) <strong>create_directories</strong>(directories, mode = 0755, run = true, show_errors = false, fatal = true) </a>
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
</span>
|
267
|
-
|
204
|
+
<span class="note title constructor">constructor</span>
|
268
205
|
|
269
206
|
|
270
207
|
|
@@ -273,156 +210,72 @@
|
|
273
210
|
|
274
211
|
|
275
212
|
|
276
|
-
<span class="summary_desc"><div class='inline'><p>
|
213
|
+
<span class="summary_desc"><div class='inline'><p>Initializes a new Shell.</p>
|
277
214
|
</div></span>
|
278
215
|
|
279
216
|
</li>
|
280
217
|
|
281
218
|
|
282
|
-
|
283
|
-
<span class="summary_signature">
|
284
|
-
|
285
|
-
<a href="#delete-instance_method" title="#delete (instance method)">- (Boolean) <strong>delete</strong>(files, run = true, show_errors = false, fatal = true) </a>
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
</span>
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
<span class="summary_desc"><div class='inline'><p>Deletes a list of files.</p>
|
300
|
-
</div></span>
|
219
|
+
</ul>
|
301
220
|
|
302
|
-
</li>
|
303
221
|
|
304
|
-
|
305
|
-
<li class="public ">
|
306
|
-
<span class="summary_signature">
|
307
|
-
|
308
|
-
<a href="#find-instance_method" title="#find (instance method)">- (Object) <strong>find</strong>(directories, patterns = [], by_extension = false, case_sensitive = false) </a>
|
309
|
-
|
310
222
|
|
311
|
-
|
312
|
-
</span>
|
313
|
-
|
314
223
|
|
315
224
|
|
316
225
|
|
317
226
|
|
318
227
|
|
319
228
|
|
320
|
-
|
321
229
|
|
322
|
-
<span class="summary_desc"><div class='inline'><p>Find a list of files in directories matching given regexps or patterns.</p>
|
323
|
-
</div></span>
|
324
230
|
|
325
|
-
</
|
326
|
-
|
327
|
-
|
328
|
-
<li class="public ">
|
329
|
-
<span class="summary_signature">
|
330
|
-
|
331
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Shell) <strong>initialize</strong> </a>
|
332
|
-
|
231
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="ShellMethods/Directories.html" title="Bovem::ShellMethods::Directories (module)">Bovem::ShellMethods::Directories</a></span></h3>
|
232
|
+
<p class="inherited"><span class='object_link'><a href="ShellMethods/Directories.html#create_directories-instance_method" title="Bovem::ShellMethods::Directories#create_directories (method)">#create_directories</a></span>, <span class='object_link'><a href="ShellMethods/Directories.html#within_directory-instance_method" title="Bovem::ShellMethods::Directories#within_directory (method)">#within_directory</a></span></p>
|
333
233
|
|
334
|
-
|
335
|
-
</span>
|
336
|
-
|
337
|
-
|
338
|
-
<span class="note title constructor">constructor</span>
|
339
234
|
|
340
235
|
|
341
236
|
|
342
237
|
|
343
238
|
|
344
239
|
|
345
|
-
|
346
240
|
|
347
|
-
<span class="summary_desc"><div class='inline'><p>Initializes a new Shell.</p>
|
348
|
-
</div></span>
|
349
241
|
|
350
|
-
</
|
351
|
-
|
352
|
-
|
353
|
-
<li class="public ">
|
354
|
-
<span class="summary_signature">
|
355
|
-
|
356
|
-
<a href="#move-instance_method" title="#move (instance method)">- (Boolean) <strong>move</strong>(src, dst, run = true, show_errors = false, fatal = true) </a>
|
357
|
-
|
242
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="ShellMethods/Execute.html" title="Bovem::ShellMethods::Execute (module)">Bovem::ShellMethods::Execute</a></span></h3>
|
243
|
+
<p class="inherited"><span class='object_link'><a href="ShellMethods/Execute.html#delete-instance_method" title="Bovem::ShellMethods::Execute#delete (method)">#delete</a></span>, <span class='object_link'><a href="ShellMethods/Execute.html#run-instance_method" title="Bovem::ShellMethods::Execute#run (method)">#run</a></span></p>
|
358
244
|
|
359
|
-
|
360
|
-
</span>
|
361
|
-
|
362
245
|
|
363
246
|
|
364
247
|
|
365
248
|
|
366
249
|
|
367
250
|
|
368
|
-
|
369
251
|
|
370
|
-
<span class="summary_desc"><div class='inline'><p>Moves a set of files or directory to another location.</p>
|
371
|
-
</div></span>
|
372
252
|
|
373
|
-
</
|
374
|
-
|
375
|
-
|
376
|
-
<li class="public ">
|
377
|
-
<span class="summary_signature">
|
378
|
-
|
379
|
-
<a href="#run-instance_method" title="#run (instance method)">- (Hash) <strong>run</strong>(command, message = nil, run = true, show_exit = true, show_output = false, show_command = false, fatal = true) </a>
|
380
|
-
|
253
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="ShellMethods/Write.html" title="Bovem::ShellMethods::Write (module)">Bovem::ShellMethods::Write</a></span></h3>
|
254
|
+
<p class="inherited"><span class='object_link'><a href="ShellMethods/Write.html#copy-instance_method" title="Bovem::ShellMethods::Write#copy (method)">#copy</a></span>, <span class='object_link'><a href="ShellMethods/Write.html#copy_or_move-instance_method" title="Bovem::ShellMethods::Write#copy_or_move (method)">#copy_or_move</a></span>, <span class='object_link'><a href="ShellMethods/Write.html#move-instance_method" title="Bovem::ShellMethods::Write#move (method)">#move</a></span></p>
|
381
255
|
|
382
|
-
|
383
|
-
</span>
|
384
|
-
|
385
256
|
|
386
257
|
|
387
258
|
|
388
259
|
|
389
260
|
|
390
261
|
|
391
|
-
|
392
262
|
|
393
|
-
<span class="summary_desc"><div class='inline'><p>Runs a command into the shell.</p>
|
394
|
-
</div></span>
|
395
263
|
|
396
|
-
</
|
397
|
-
|
398
|
-
|
399
|
-
<li class="public ">
|
400
|
-
<span class="summary_signature">
|
401
|
-
|
402
|
-
<a href="#within_directory-instance_method" title="#within_directory (instance method)">- (Boolean) <strong>within_directory</strong>(directory, restore = true, show_messages = false) </a>
|
403
|
-
|
264
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="ShellMethods/Read.html" title="Bovem::ShellMethods::Read (module)">Bovem::ShellMethods::Read</a></span></h3>
|
265
|
+
<p class="inherited"><span class='object_link'><a href="ShellMethods/Read.html#check-instance_method" title="Bovem::ShellMethods::Read#check (method)">#check</a></span>, <span class='object_link'><a href="ShellMethods/Read.html#find-instance_method" title="Bovem::ShellMethods::Read#find (method)">#find</a></span></p>
|
404
266
|
|
405
|
-
|
406
|
-
</span>
|
407
|
-
|
408
267
|
|
409
268
|
|
410
269
|
|
411
270
|
|
412
271
|
|
413
272
|
|
414
|
-
|
415
|
-
|
416
|
-
<span class="summary_desc"><div class='inline'><p>Executes a block of code in another directory.</p>
|
417
|
-
</div></span>
|
418
273
|
|
419
|
-
</li>
|
420
|
-
|
421
|
-
|
422
|
-
</ul>
|
423
274
|
|
275
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="ShellMethods/General.html" title="Bovem::ShellMethods::General (module)">Bovem::ShellMethods::General</a></span></h3>
|
276
|
+
<p class="inherited"><span class='object_link'><a href="ShellMethods/General.html#handle_failure-instance_method" title="Bovem::ShellMethods::General#handle_failure (method)">#handle_failure</a></span>, <span class='object_link'><a href="ShellMethods/General.html#show_general_failure-instance_method" title="Bovem::ShellMethods::General#show_general_failure (method)">#show_general_failure</a></span></p>
|
424
277
|
|
425
|
-
<div id="constructor_details" class="method_details_list">
|
278
|
+
<div id="constructor_details" class="method_details_list">
|
426
279
|
<h2>Constructor Details</h2>
|
427
280
|
|
428
281
|
<div class="method_details first">
|
@@ -450,15 +303,17 @@
|
|
450
303
|
<pre class="lines">
|
451
304
|
|
452
305
|
|
453
|
-
|
454
|
-
|
455
|
-
|
306
|
+
559
|
307
|
+
560
|
308
|
+
561
|
309
|
+
562</pre>
|
456
310
|
</td>
|
457
311
|
<td>
|
458
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line
|
312
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 559</span>
|
459
313
|
|
460
314
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
461
315
|
<span class='ivar'>@console</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Console</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
|
316
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_i18n_setup'>i18n_setup</span><span class='lparen'>(</span><span class='symbol'>:bovem</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>/../../locales/</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
|
462
317
|
<span class='kw'>end</span></pre>
|
463
318
|
</td>
|
464
319
|
</tr>
|
@@ -475,54 +330,7 @@
|
|
475
330
|
<div class="method_details first">
|
476
331
|
<h3 class="signature first" id="console-instance_method">
|
477
332
|
|
478
|
-
- (<tt>
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
</h3><div class="docstring">
|
485
|
-
<div class="discussion">
|
486
|
-
<p>A <span class='object_link'><a href="Console.html" title="Bovem::Console (class)">Console</a></span> instance.</p>
|
487
|
-
|
488
|
-
|
489
|
-
</div>
|
490
|
-
</div>
|
491
|
-
<div class="tags">
|
492
|
-
|
493
|
-
|
494
|
-
</div><table class="source_code">
|
495
|
-
<tr>
|
496
|
-
<td>
|
497
|
-
<pre class="lines">
|
498
|
-
|
499
|
-
|
500
|
-
11
|
501
|
-
12
|
502
|
-
13</pre>
|
503
|
-
</td>
|
504
|
-
<td>
|
505
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 11</span>
|
506
|
-
|
507
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_console'>console</span>
|
508
|
-
<span class='ivar'>@console</span>
|
509
|
-
<span class='kw'>end</span></pre>
|
510
|
-
</td>
|
511
|
-
</tr>
|
512
|
-
</table>
|
513
|
-
</div>
|
514
|
-
|
515
|
-
</div>
|
516
|
-
|
517
|
-
|
518
|
-
<div id="class_method_details" class="method_details_list">
|
519
|
-
<h2>Class Method Details</h2>
|
520
|
-
|
521
|
-
|
522
|
-
<div class="method_details first">
|
523
|
-
<h3 class="signature first" id="instance-class_method">
|
524
|
-
|
525
|
-
+ (<tt><span class='object_link'><a href="" title="Bovem::Shell (class)">Shell</a></span></tt>) <strong>instance</strong>
|
333
|
+
- (<tt><span class='object_link'><a href="Console.html" title="Bovem::Console (class)">Console</a></span></tt>) <strong>console</strong>
|
526
334
|
|
527
335
|
|
528
336
|
|
@@ -530,7 +338,7 @@
|
|
530
338
|
|
531
339
|
</h3><div class="docstring">
|
532
340
|
<div class="discussion">
|
533
|
-
<
|
341
|
+
<h1>A console instance.</h1>
|
534
342
|
|
535
343
|
|
536
344
|
</div>
|
@@ -543,12 +351,12 @@
|
|
543
351
|
<li>
|
544
352
|
|
545
353
|
|
546
|
-
<span class='type'>(<tt><span class='object_link'><a href="" title="Bovem::
|
354
|
+
<span class='type'>(<tt><span class='object_link'><a href="Console.html" title="Bovem::Console (class)">Console</a></span></tt>)</span>
|
547
355
|
|
548
356
|
|
549
357
|
|
550
358
|
—
|
551
|
-
<div class='inline'><p>
|
359
|
+
<div class='inline'><p>the current value of console</p>
|
552
360
|
</div>
|
553
361
|
|
554
362
|
</li>
|
@@ -561,15 +369,15 @@
|
|
561
369
|
<pre class="lines">
|
562
370
|
|
563
371
|
|
564
|
-
|
565
|
-
|
566
|
-
|
372
|
+
541
|
373
|
+
542
|
374
|
+
543</pre>
|
567
375
|
</td>
|
568
376
|
<td>
|
569
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line
|
377
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 541</span>
|
570
378
|
|
571
|
-
<span class='kw'>def</span> <span class='
|
572
|
-
<span class='ivar'>@
|
379
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_console'>console</span>
|
380
|
+
<span class='ivar'>@console</span>
|
573
381
|
<span class='kw'>end</span></pre>
|
574
382
|
</td>
|
575
383
|
</tr>
|
@@ -578,14 +386,15 @@
|
|
578
386
|
|
579
387
|
</div>
|
580
388
|
|
581
|
-
|
582
|
-
|
389
|
+
|
390
|
+
<div id="class_method_details" class="method_details_list">
|
391
|
+
<h2>Class Method Details</h2>
|
583
392
|
|
584
393
|
|
585
394
|
<div class="method_details first">
|
586
|
-
<h3 class="signature first" id="
|
395
|
+
<h3 class="signature first" id="instance-class_method">
|
587
396
|
|
588
|
-
|
397
|
+
+ (<tt><span class='object_link'><a href="" title="Bovem::Shell (class)">Shell</a></span></tt>) <strong>instance</strong>
|
589
398
|
|
590
399
|
|
591
400
|
|
@@ -593,1685 +402,46 @@
|
|
593
402
|
|
594
403
|
</h3><div class="docstring">
|
595
404
|
<div class="discussion">
|
596
|
-
<p>
|
597
|
-
|
598
|
-
<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>
|
405
|
+
<p>Returns a unique instance for Shell.</p>
|
599
406
|
|
600
407
|
|
601
408
|
</div>
|
602
409
|
</div>
|
603
410
|
<div class="tags">
|
604
|
-
<p class="tag_title">Parameters:</p>
|
605
|
-
<ul class="param">
|
606
411
|
|
607
|
-
|
608
|
-
|
609
|
-
<span class='name'>path</span>
|
610
|
-
|
611
|
-
|
612
|
-
<span class='type'>(<tt>String</tt>)</span>
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
—
|
617
|
-
<div class='inline'><p>The path to test.</p>
|
618
|
-
</div>
|
619
|
-
|
620
|
-
</li>
|
412
|
+
<p class="tag_title">Returns:</p>
|
413
|
+
<ul class="return">
|
621
414
|
|
622
415
|
<li>
|
623
416
|
|
624
|
-
<span class='name'>tests</span>
|
625
417
|
|
626
|
-
|
627
|
-
<span class='type'>(<tt>Array</tt>)</span>
|
418
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Bovem::Shell (class)">Shell</a></span></tt>)</span>
|
628
419
|
|
629
420
|
|
630
421
|
|
631
422
|
—
|
632
|
-
<div class='inline'><p>
|
423
|
+
<div class='inline'><p>A new instance.</p>
|
633
424
|
</div>
|
634
425
|
|
635
426
|
</li>
|
636
427
|
|
637
428
|
</ul>
|
638
429
|
|
639
|
-
|
640
430
|
</div><table class="source_code">
|
641
431
|
<tr>
|
642
432
|
<td>
|
643
433
|
<pre class="lines">
|
644
434
|
|
645
435
|
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
76
|
650
|
-
77
|
651
|
-
78
|
652
|
-
79
|
653
|
-
80
|
654
|
-
81
|
655
|
-
82
|
656
|
-
83
|
657
|
-
84
|
658
|
-
85
|
659
|
-
86
|
660
|
-
87
|
661
|
-
88
|
662
|
-
89
|
663
|
-
90
|
664
|
-
91
|
665
|
-
92</pre>
|
436
|
+
554
|
437
|
+
555
|
438
|
+
556</pre>
|
666
439
|
</td>
|
667
440
|
<td>
|
668
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line
|
669
|
-
|
670
|
-
<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>
|
671
|
-
<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>
|
672
|
-
|
673
|
-
<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>
|
674
|
-
<span class='comment'># Adjust test name
|
675
|
-
</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>
|
676
|
-
|
677
|
-
<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>
|
678
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>read</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>readable</span><span class='tstring_end'>"</span></span>
|
679
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>write</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>writable</span><span class='tstring_end'>"</span></span>
|
680
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>execute</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>exec</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>executable</span><span class='tstring_end'>"</span></span>
|
681
|
-
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>dir</span><span class='tstring_end'>"</span></span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>directory</span><span class='tstring_end'>"</span></span>
|
682
|
-
<span class='kw'>else</span> <span class='id identifier rubyid_test'>test</span>
|
683
|
-
<span class='kw'>end</span>
|
684
|
-
|
685
|
-
<span class='comment'># Execute test
|
686
|
-
</span> <span class='id identifier rubyid_test'>test</span> <span class='op'>+=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>?</span><span class='tstring_end'>"</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>
|
687
|
-
<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>
|
688
|
-
<span class='rbrace'>}</span>
|
689
|
-
<span class='kw'>end</span></pre>
|
690
|
-
</td>
|
691
|
-
</tr>
|
692
|
-
</table>
|
693
|
-
</div>
|
694
|
-
|
695
|
-
<div class="method_details ">
|
696
|
-
<h3 class="signature " id="copy-instance_method">
|
697
|
-
|
698
|
-
- (<tt>Boolean</tt>) <strong>copy</strong>(src, dst, run = true, show_errors = false, fatal = true)
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
</h3><div class="docstring">
|
705
|
-
<div class="discussion">
|
706
|
-
<p>Copies a set of files or directory to another location.</p>
|
441
|
+
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 554</span>
|
707
442
|
|
708
|
-
|
709
|
-
</
|
710
|
-
</div>
|
711
|
-
<div class="tags">
|
712
|
-
<p class="tag_title">Parameters:</p>
|
713
|
-
<ul class="param">
|
714
|
-
|
715
|
-
<li>
|
716
|
-
|
717
|
-
<span class='name'>src</span>
|
718
|
-
|
719
|
-
|
720
|
-
<span class='type'>(<tt>String|Array</tt>)</span>
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
—
|
725
|
-
<div class='inline'><p>The entries to copy. If is an Array, <code>dst</code> is assumed to be a directory.</p>
|
726
|
-
</div>
|
727
|
-
|
728
|
-
</li>
|
729
|
-
|
730
|
-
<li>
|
731
|
-
|
732
|
-
<span class='name'>dst</span>
|
733
|
-
|
734
|
-
|
735
|
-
<span class='type'>(<tt>String</tt>)</span>
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
—
|
740
|
-
<div class='inline'><p>The destination. <strong>Any existing entries will be overwritten.</strong> Any required directory will be created.</p>
|
741
|
-
</div>
|
742
|
-
|
743
|
-
</li>
|
744
|
-
|
745
|
-
<li>
|
746
|
-
|
747
|
-
<span class='name'>run</span>
|
748
|
-
|
749
|
-
|
750
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
751
|
-
|
752
|
-
|
753
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
754
|
-
|
755
|
-
|
756
|
-
—
|
757
|
-
<div class='inline'><p>If <code>false</code>, it will just print a list of message that would be copied or moved.</p>
|
758
|
-
</div>
|
759
|
-
|
760
|
-
</li>
|
761
|
-
|
762
|
-
<li>
|
763
|
-
|
764
|
-
<span class='name'>show_errors</span>
|
765
|
-
|
766
|
-
|
767
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
768
|
-
|
769
|
-
|
770
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
771
|
-
|
772
|
-
|
773
|
-
—
|
774
|
-
<div class='inline'><p>If show errors.</p>
|
775
|
-
</div>
|
776
|
-
|
777
|
-
</li>
|
778
|
-
|
779
|
-
<li>
|
780
|
-
|
781
|
-
<span class='name'>fatal</span>
|
782
|
-
|
783
|
-
|
784
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
785
|
-
|
786
|
-
|
787
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
788
|
-
|
789
|
-
|
790
|
-
—
|
791
|
-
<div class='inline'><p>If quit in case of fatal errors.</p>
|
792
|
-
</div>
|
793
|
-
|
794
|
-
</li>
|
795
|
-
|
796
|
-
</ul>
|
797
|
-
|
798
|
-
<p class="tag_title">Returns:</p>
|
799
|
-
<ul class="return">
|
800
|
-
|
801
|
-
<li>
|
802
|
-
|
803
|
-
|
804
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
—
|
809
|
-
<div class='inline'><p><code>true</code> if operation succeeded, <code>false</code> otherwise.</p>
|
810
|
-
</div>
|
811
|
-
|
812
|
-
</li>
|
813
|
-
|
814
|
-
</ul>
|
815
|
-
|
816
|
-
</div><table class="source_code">
|
817
|
-
<tr>
|
818
|
-
<td>
|
819
|
-
<pre class="lines">
|
820
|
-
|
821
|
-
|
822
|
-
238
|
823
|
-
239
|
824
|
-
240</pre>
|
825
|
-
</td>
|
826
|
-
<td>
|
827
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 238</span>
|
828
|
-
|
829
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_copy'>copy</span><span class='lparen'>(</span><span class='id identifier rubyid_src'>src</span><span class='comma'>,</span> <span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
830
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_copy_or_move'>copy_or_move</span><span class='lparen'>(</span><span class='id identifier rubyid_src'>src</span><span class='comma'>,</span> <span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='symbol'>:copy</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
|
831
|
-
<span class='kw'>end</span></pre>
|
832
|
-
</td>
|
833
|
-
</tr>
|
834
|
-
</table>
|
835
|
-
</div>
|
836
|
-
|
837
|
-
<div class="method_details ">
|
838
|
-
<h3 class="signature " id="copy_or_move-instance_method">
|
839
|
-
|
840
|
-
- (<tt>Boolean</tt>) <strong>copy_or_move</strong>(src, dst, operation, run = true, show_errors = false, fatal = true)
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
</h3><div class="docstring">
|
847
|
-
<div class="discussion">
|
848
|
-
<p>Copies or moves a set of files or directory to another location.</p>
|
849
|
-
|
850
|
-
|
851
|
-
</div>
|
852
|
-
</div>
|
853
|
-
<div class="tags">
|
854
|
-
<p class="tag_title">Parameters:</p>
|
855
|
-
<ul class="param">
|
856
|
-
|
857
|
-
<li>
|
858
|
-
|
859
|
-
<span class='name'>src</span>
|
860
|
-
|
861
|
-
|
862
|
-
<span class='type'>(<tt>String|Array</tt>)</span>
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
—
|
867
|
-
<div class='inline'><p>The entries to copy or move. If is an Array, <code>dst</code> is assumed to be a directory.</p>
|
868
|
-
</div>
|
869
|
-
|
870
|
-
</li>
|
871
|
-
|
872
|
-
<li>
|
873
|
-
|
874
|
-
<span class='name'>dst</span>
|
875
|
-
|
876
|
-
|
877
|
-
<span class='type'>(<tt>String</tt>)</span>
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
—
|
882
|
-
<div class='inline'><p>The destination. <strong>Any existing entries will be overwritten.</strong> Any required directory will be created.</p>
|
883
|
-
</div>
|
884
|
-
|
885
|
-
</li>
|
886
|
-
|
887
|
-
<li>
|
888
|
-
|
889
|
-
<span class='name'>operation</span>
|
890
|
-
|
891
|
-
|
892
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
—
|
897
|
-
<div class='inline'><p>The operation to perform. Valid values are <code>:copy</code> or <code>:move</code>.</p>
|
898
|
-
</div>
|
899
|
-
|
900
|
-
</li>
|
901
|
-
|
902
|
-
<li>
|
903
|
-
|
904
|
-
<span class='name'>run</span>
|
905
|
-
|
906
|
-
|
907
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
908
|
-
|
909
|
-
|
910
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
911
|
-
|
912
|
-
|
913
|
-
—
|
914
|
-
<div class='inline'><p>If <code>false</code>, it will just print a list of message that would be copied or moved.</p>
|
915
|
-
</div>
|
916
|
-
|
917
|
-
</li>
|
918
|
-
|
919
|
-
<li>
|
920
|
-
|
921
|
-
<span class='name'>show_errors</span>
|
922
|
-
|
923
|
-
|
924
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
925
|
-
|
926
|
-
|
927
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
928
|
-
|
929
|
-
|
930
|
-
—
|
931
|
-
<div class='inline'><p>If show errors.</p>
|
932
|
-
</div>
|
933
|
-
|
934
|
-
</li>
|
935
|
-
|
936
|
-
<li>
|
937
|
-
|
938
|
-
<span class='name'>fatal</span>
|
939
|
-
|
940
|
-
|
941
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
942
|
-
|
943
|
-
|
944
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
945
|
-
|
946
|
-
|
947
|
-
—
|
948
|
-
<div class='inline'><p>If quit in case of fatal errors.</p>
|
949
|
-
</div>
|
950
|
-
|
951
|
-
</li>
|
952
|
-
|
953
|
-
</ul>
|
954
|
-
|
955
|
-
<p class="tag_title">Returns:</p>
|
956
|
-
<ul class="return">
|
957
|
-
|
958
|
-
<li>
|
959
|
-
|
960
|
-
|
961
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
—
|
966
|
-
<div class='inline'><p><code>true</code> if operation succeeded, <code>false</code> otherwise.</p>
|
967
|
-
</div>
|
968
|
-
|
969
|
-
</li>
|
970
|
-
|
971
|
-
</ul>
|
972
|
-
|
973
|
-
</div><table class="source_code">
|
974
|
-
<tr>
|
975
|
-
<td>
|
976
|
-
<pre class="lines">
|
977
|
-
|
978
|
-
|
979
|
-
146
|
980
|
-
147
|
981
|
-
148
|
982
|
-
149
|
983
|
-
150
|
984
|
-
151
|
985
|
-
152
|
986
|
-
153
|
987
|
-
154
|
988
|
-
155
|
989
|
-
156
|
990
|
-
157
|
991
|
-
158
|
992
|
-
159
|
993
|
-
160
|
994
|
-
161
|
995
|
-
162
|
996
|
-
163
|
997
|
-
164
|
998
|
-
165
|
999
|
-
166
|
1000
|
-
167
|
1001
|
-
168
|
1002
|
-
169
|
1003
|
-
170
|
1004
|
-
171
|
1005
|
-
172
|
1006
|
-
173
|
1007
|
-
174
|
1008
|
-
175
|
1009
|
-
176
|
1010
|
-
177
|
1011
|
-
178
|
1012
|
-
179
|
1013
|
-
180
|
1014
|
-
181
|
1015
|
-
182
|
1016
|
-
183
|
1017
|
-
184
|
1018
|
-
185
|
1019
|
-
186
|
1020
|
-
187
|
1021
|
-
188
|
1022
|
-
189
|
1023
|
-
190
|
1024
|
-
191
|
1025
|
-
192
|
1026
|
-
193
|
1027
|
-
194
|
1028
|
-
195
|
1029
|
-
196
|
1030
|
-
197
|
1031
|
-
198
|
1032
|
-
199
|
1033
|
-
200
|
1034
|
-
201
|
1035
|
-
202
|
1036
|
-
203
|
1037
|
-
204
|
1038
|
-
205
|
1039
|
-
206
|
1040
|
-
207
|
1041
|
-
208
|
1042
|
-
209
|
1043
|
-
210
|
1044
|
-
211
|
1045
|
-
212
|
1046
|
-
213
|
1047
|
-
214
|
1048
|
-
215
|
1049
|
-
216
|
1050
|
-
217
|
1051
|
-
218
|
1052
|
-
219
|
1053
|
-
220
|
1054
|
-
221
|
1055
|
-
222
|
1056
|
-
223
|
1057
|
-
224
|
1058
|
-
225
|
1059
|
-
226
|
1060
|
-
227
|
1061
|
-
228</pre>
|
1062
|
-
</td>
|
1063
|
-
<td>
|
1064
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 146</span>
|
1065
|
-
|
1066
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_copy_or_move'>copy_or_move</span><span class='lparen'>(</span><span class='id identifier rubyid_src'>src</span><span class='comma'>,</span> <span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='id identifier rubyid_operation'>operation</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
1067
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1068
|
-
<span class='id identifier rubyid_operation'>operation</span> <span class='op'>=</span> <span class='symbol'>:copy</span> <span class='kw'>if</span> <span class='id identifier rubyid_operation'>operation</span> <span class='op'>!=</span> <span class='symbol'>:move</span>
|
1069
|
-
<span class='id identifier rubyid_single'>single</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span>
|
1070
|
-
|
1071
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_single'>single</span> <span class='kw'>then</span>
|
1072
|
-
<span class='id identifier rubyid_src'>src</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_src'>src</span><span class='rparen'>)</span>
|
1073
|
-
<span class='kw'>else</span>
|
1074
|
-
<span class='id identifier rubyid_src'>src</span> <span class='op'>=</span> <span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_s'>s</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_s'>s</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1075
|
-
<span class='kw'>end</span>
|
1076
|
-
|
1077
|
-
<span class='id identifier rubyid_dst'>dst</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_dst'>dst</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
|
1078
|
-
|
1079
|
-
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_run'>run</span> <span class='kw'>then</span>
|
1080
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_single'>single</span> <span class='kw'>then</span>
|
1081
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Will </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> a file:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1082
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>From: {mark=bright}</span><span class='embexpr_beg'>#{</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_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>11</span><span class='rparen'>)</span>
|
1083
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>To: {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst'>dst</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>11</span><span class='rparen'>)</span>
|
1084
|
-
<span class='kw'>else</span>
|
1085
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Will </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> following entries:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1086
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>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>
|
1087
|
-
<span class='id identifier rubyid_src'>src</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_s'>s</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span> <span class='kw'>end</span>
|
1088
|
-
<span class='kw'>end</span>
|
1089
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>to directory: {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst'>dst</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>5</span><span class='rparen'>)</span>
|
1090
|
-
<span class='kw'>end</span>
|
1091
|
-
<span class='kw'>else</span>
|
1092
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1093
|
-
<span class='id identifier rubyid_dst_dir'>dst_dir</span> <span class='op'>=</span> <span class='id identifier rubyid_single'>single</span> <span class='op'>?</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='id identifier rubyid_dst'>dst</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_dst'>dst</span>
|
1094
|
-
<span class='id identifier rubyid_has_dir'>has_dir</span> <span class='op'>=</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_dst_dir'>dst_dir</span><span class='comma'>,</span> <span class='symbol'>:dir</span><span class='rparen'>)</span>
|
1095
|
-
|
1096
|
-
<span class='comment'># Create directory
|
1097
|
-
</span> <span class='id identifier rubyid_has_dir'>has_dir</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_directories'>create_directories</span><span class='lparen'>(</span><span class='id identifier rubyid_dst_dir'>dst_dir</span><span class='comma'>,</span> <span class='int'>0755</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_has_dir'>has_dir</span>
|
1098
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_has_dir'>has_dir</span>
|
1099
|
-
|
1100
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_single'>single</span> <span class='op'>&&</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_dst'>dst</span><span class='comma'>,</span> <span class='symbol'>:dir</span><span class='rparen'>)</span> <span class='kw'>then</span>
|
1101
|
-
<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_fatal'>fatal</span> <span class='op'>?</span> <span class='symbol'>:fatal</span> <span class='op'>:</span> <span class='symbol'>:error</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> file {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_src'>src</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} to {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst'>dst</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} because it is currently a directory.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1102
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1103
|
-
<span class='kw'>end</span>
|
1104
|
-
|
1105
|
-
<span class='comment'># Check that every file is existing
|
1106
|
-
</span> <span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</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_s'>s</span><span class='op'>|</span>
|
1107
|
-
<span class='kw'>if</span> <span class='op'>!</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_s'>s</span><span class='comma'>,</span> <span class='symbol'>:exists</span><span class='rparen'>)</span> <span class='kw'>then</span>
|
1108
|
-
<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_fatal'>fatal</span> <span class='op'>?</span> <span class='symbol'>:fatal</span> <span class='op'>:</span> <span class='symbol'>:error</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> non existent file {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_s'>s</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1109
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1110
|
-
<span class='kw'>end</span>
|
1111
|
-
<span class='kw'>end</span>
|
1112
|
-
|
1113
|
-
<span class='comment'># Do operation
|
1114
|
-
</span> <span class='kw'>begin</span>
|
1115
|
-
<span class='const'>FileUtils</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_operation'>operation</span> <span class='op'>==</span> <span class='symbol'>:move</span> <span class='op'>?</span> <span class='symbol'>:mv</span> <span class='op'>:</span> <span class='symbol'>:cp_r</span><span class='comma'>,</span> <span class='id identifier rubyid_src'>src</span><span class='comma'>,</span> <span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:noop</span> <span class='op'>=></span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:verbose</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1116
|
-
<span class='kw'>rescue</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>EACCES</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1117
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_single'>single</span> <span class='kw'>then</span>
|
1118
|
-
<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_fatal'>fatal</span> <span class='op'>?</span> <span class='symbol'>:fatal</span> <span class='op'>:</span> <span class='symbol'>:error</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> file {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_src'>src</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} to non writable directory {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst_dir'>dst_dir</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1119
|
-
<span class='kw'>else</span>
|
1120
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> following file(s) to non writable directory {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst'>dst</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1121
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>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>
|
1122
|
-
<span class='id identifier rubyid_src'>src</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_s'>s</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span> <span class='kw'>end</span>
|
1123
|
-
<span class='kw'>end</span>
|
1124
|
-
<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>
|
1125
|
-
<span class='kw'>end</span>
|
1126
|
-
|
1127
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1128
|
-
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1129
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_single'>single</span> <span class='kw'>then</span>
|
1130
|
-
<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_fatal'>fatal</span> <span class='op'>?</span> <span class='symbol'>:fatal</span> <span class='op'>:</span> <span class='symbol'>:error</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> file {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_src'>src</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} to directory {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst_dir'>dst_dir</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} due to this error: [</span><span class='embexpr_beg'>#{</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='rbrace'>}</span><span class='tstring_content'>] </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>5</span><span class='rparen'>)</span>
|
1131
|
-
<span class='kw'>else</span>
|
1132
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_operation'>operation</span><span class='rbrace'>}</span><span class='tstring_content'> following entries to {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst'>dst</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1133
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>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>
|
1134
|
-
<span class='id identifier rubyid_src'>src</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_s'>s</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span> <span class='kw'>end</span>
|
1135
|
-
<span class='kw'>end</span>
|
1136
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>due to this error: [</span><span class='embexpr_beg'>#{</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='rbrace'>}</span><span class='tstring_content'>] </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>5</span><span class='rparen'>)</span>
|
1137
|
-
<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>
|
1138
|
-
<span class='kw'>end</span>
|
1139
|
-
|
1140
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1141
|
-
<span class='kw'>end</span>
|
1142
|
-
|
1143
|
-
<span class='kw'>true</span>
|
1144
|
-
<span class='kw'>end</span>
|
1145
|
-
<span class='kw'>end</span>
|
1146
|
-
|
1147
|
-
<span class='id identifier rubyid_rv'>rv</span>
|
1148
|
-
<span class='kw'>end</span></pre>
|
1149
|
-
</td>
|
1150
|
-
</tr>
|
1151
|
-
</table>
|
1152
|
-
</div>
|
1153
|
-
|
1154
|
-
<div class="method_details ">
|
1155
|
-
<h3 class="signature " id="create_directories-instance_method">
|
1156
|
-
|
1157
|
-
- (<tt>Boolean</tt>) <strong>create_directories</strong>(directories, mode = 0755, run = true, show_errors = false, fatal = true)
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
</h3><div class="docstring">
|
1164
|
-
<div class="discussion">
|
1165
|
-
<p>Creates a list of directories, included missing parent directories.</p>
|
1166
|
-
|
1167
|
-
|
1168
|
-
</div>
|
1169
|
-
</div>
|
1170
|
-
<div class="tags">
|
1171
|
-
<p class="tag_title">Parameters:</p>
|
1172
|
-
<ul class="param">
|
1173
|
-
|
1174
|
-
<li>
|
1175
|
-
|
1176
|
-
<span class='name'>directories</span>
|
1177
|
-
|
1178
|
-
|
1179
|
-
<span class='type'>(<tt>Array</tt>)</span>
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
—
|
1184
|
-
<div class='inline'><p>The list of directories to create.</p>
|
1185
|
-
</div>
|
1186
|
-
|
1187
|
-
</li>
|
1188
|
-
|
1189
|
-
<li>
|
1190
|
-
|
1191
|
-
<span class='name'>mode</span>
|
1192
|
-
|
1193
|
-
|
1194
|
-
<span class='type'>(<tt>Fixnum</tt>)</span>
|
1195
|
-
|
1196
|
-
|
1197
|
-
<em class="default">(defaults to: <tt>0755</tt>)</em>
|
1198
|
-
|
1199
|
-
|
1200
|
-
—
|
1201
|
-
<div class='inline'><p>Initial permissions for the new directories.</p>
|
1202
|
-
</div>
|
1203
|
-
|
1204
|
-
</li>
|
1205
|
-
|
1206
|
-
<li>
|
1207
|
-
|
1208
|
-
<span class='name'>run</span>
|
1209
|
-
|
1210
|
-
|
1211
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1212
|
-
|
1213
|
-
|
1214
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1215
|
-
|
1216
|
-
|
1217
|
-
—
|
1218
|
-
<div class='inline'><p>If <code>false</code>, it will just print a list of directories that would be created.</p>
|
1219
|
-
</div>
|
1220
|
-
|
1221
|
-
</li>
|
1222
|
-
|
1223
|
-
<li>
|
1224
|
-
|
1225
|
-
<span class='name'>show_errors</span>
|
1226
|
-
|
1227
|
-
|
1228
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1229
|
-
|
1230
|
-
|
1231
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1232
|
-
|
1233
|
-
|
1234
|
-
—
|
1235
|
-
<div class='inline'><p>If show errors.</p>
|
1236
|
-
</div>
|
1237
|
-
|
1238
|
-
</li>
|
1239
|
-
|
1240
|
-
<li>
|
1241
|
-
|
1242
|
-
<span class='name'>fatal</span>
|
1243
|
-
|
1244
|
-
|
1245
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1246
|
-
|
1247
|
-
|
1248
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1249
|
-
|
1250
|
-
|
1251
|
-
—
|
1252
|
-
<div class='inline'><p>If quit in case of fatal errors.</p>
|
1253
|
-
</div>
|
1254
|
-
|
1255
|
-
</li>
|
1256
|
-
|
1257
|
-
</ul>
|
1258
|
-
|
1259
|
-
<p class="tag_title">Returns:</p>
|
1260
|
-
<ul class="return">
|
1261
|
-
|
1262
|
-
<li>
|
1263
|
-
|
1264
|
-
|
1265
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
—
|
1270
|
-
<div class='inline'><p><code>true</code> if operation succeeded, <code>false</code> otherwise.</p>
|
1271
|
-
</div>
|
1272
|
-
|
1273
|
-
</li>
|
1274
|
-
|
1275
|
-
</ul>
|
1276
|
-
|
1277
|
-
</div><table class="source_code">
|
1278
|
-
<tr>
|
1279
|
-
<td>
|
1280
|
-
<pre class="lines">
|
1281
|
-
|
1282
|
-
|
1283
|
-
296
|
1284
|
-
297
|
1285
|
-
298
|
1286
|
-
299
|
1287
|
-
300
|
1288
|
-
301
|
1289
|
-
302
|
1290
|
-
303
|
1291
|
-
304
|
1292
|
-
305
|
1293
|
-
306
|
1294
|
-
307
|
1295
|
-
308
|
1296
|
-
309
|
1297
|
-
310
|
1298
|
-
311
|
1299
|
-
312
|
1300
|
-
313
|
1301
|
-
314
|
1302
|
-
315
|
1303
|
-
316
|
1304
|
-
317
|
1305
|
-
318
|
1306
|
-
319
|
1307
|
-
320
|
1308
|
-
321
|
1309
|
-
322
|
1310
|
-
323
|
1311
|
-
324
|
1312
|
-
325
|
1313
|
-
326
|
1314
|
-
327
|
1315
|
-
328
|
1316
|
-
329
|
1317
|
-
330
|
1318
|
-
331
|
1319
|
-
332
|
1320
|
-
333
|
1321
|
-
334
|
1322
|
-
335
|
1323
|
-
336
|
1324
|
-
337
|
1325
|
-
338
|
1326
|
-
339
|
1327
|
-
340
|
1328
|
-
341</pre>
|
1329
|
-
</td>
|
1330
|
-
<td>
|
1331
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 296</span>
|
1332
|
-
|
1333
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_create_directories'>create_directories</span><span class='lparen'>(</span><span class='id identifier rubyid_directories'>directories</span><span class='comma'>,</span> <span class='id identifier rubyid_mode'>mode</span> <span class='op'>=</span> <span class='int'>0755</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
1334
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1335
|
-
|
1336
|
-
<span class='comment'># Adjust directory
|
1337
|
-
</span> <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>
|
1338
|
-
|
1339
|
-
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_run'>run</span> <span class='kw'>then</span> <span class='comment'># Just print
|
1340
|
-
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Will create directories:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1341
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>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>
|
1342
|
-
<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> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='rparen'>)</span> <span class='kw'>end</span>
|
1343
|
-
<span class='kw'>end</span>
|
1344
|
-
<span class='kw'>else</span>
|
1345
|
-
<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>
|
1346
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1347
|
-
<span class='comment'># Perform tests
|
1348
|
-
</span> <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='symbol'>:directory</span><span class='rparen'>)</span> <span class='kw'>then</span>
|
1349
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</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><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The directory {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_directory'>directory</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} already exists.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1350
|
-
<span class='kw'>elsif</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='symbol'>:exist</span><span class='rparen'>)</span> <span class='kw'>then</span>
|
1351
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</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><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Path {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_directory'>directory</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} is currently a file.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1352
|
-
<span class='kw'>else</span>
|
1353
|
-
<span class='kw'>begin</span> <span class='comment'># Create directory
|
1354
|
-
</span> <span class='const'>FileUtils</span><span class='period'>.</span><span class='id identifier rubyid_mkdir_p'>mkdir_p</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:mode</span> <span class='op'>=></span> <span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='symbol'>:noop</span> <span class='op'>=></span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:verbose</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1355
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
1356
|
-
<span class='kw'>rescue</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>EACCES</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1357
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</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><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot create following directory due to permission denied: {mark=bright}</span><span class='embexpr_beg'>#{</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'>"</span><span class='tstring_content'>\\1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1358
|
-
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1359
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_show_errors'>show_errors</span> <span class='kw'>then</span>
|
1360
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot create following directories:</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1361
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>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>
|
1362
|
-
<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> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='rparen'>)</span> <span class='kw'>end</span>
|
1363
|
-
<span class='kw'>end</span>
|
1364
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>due to this error: [</span><span class='embexpr_beg'>#{</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='rbrace'>}</span><span class='tstring_content'>] </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>5</span><span class='rparen'>)</span>
|
1365
|
-
<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>
|
1366
|
-
<span class='kw'>end</span>
|
1367
|
-
<span class='kw'>end</span>
|
1368
|
-
<span class='kw'>end</span>
|
1369
|
-
|
1370
|
-
<span class='kw'>false</span>
|
1371
|
-
<span class='kw'>end</span>
|
1372
|
-
|
1373
|
-
<span class='kw'>break</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_rv'>rv</span>
|
1374
|
-
<span class='kw'>end</span>
|
1375
|
-
<span class='kw'>end</span>
|
1376
|
-
|
1377
|
-
<span class='id identifier rubyid_rv'>rv</span>
|
1378
|
-
<span class='kw'>end</span></pre>
|
1379
|
-
</td>
|
1380
|
-
</tr>
|
1381
|
-
</table>
|
1382
|
-
</div>
|
1383
|
-
|
1384
|
-
<div class="method_details ">
|
1385
|
-
<h3 class="signature " id="delete-instance_method">
|
1386
|
-
|
1387
|
-
- (<tt>Boolean</tt>) <strong>delete</strong>(files, run = true, show_errors = false, fatal = true)
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
</h3><div class="docstring">
|
1394
|
-
<div class="discussion">
|
1395
|
-
<p>Deletes a list of files.</p>
|
1396
|
-
|
1397
|
-
|
1398
|
-
</div>
|
1399
|
-
</div>
|
1400
|
-
<div class="tags">
|
1401
|
-
<p class="tag_title">Parameters:</p>
|
1402
|
-
<ul class="param">
|
1403
|
-
|
1404
|
-
<li>
|
1405
|
-
|
1406
|
-
<span class='name'>files</span>
|
1407
|
-
|
1408
|
-
|
1409
|
-
<span class='type'>(<tt>Array</tt>)</span>
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
—
|
1414
|
-
<div class='inline'><p>The list of files to remove</p>
|
1415
|
-
</div>
|
1416
|
-
|
1417
|
-
</li>
|
1418
|
-
|
1419
|
-
<li>
|
1420
|
-
|
1421
|
-
<span class='name'>run</span>
|
1422
|
-
|
1423
|
-
|
1424
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1425
|
-
|
1426
|
-
|
1427
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1428
|
-
|
1429
|
-
|
1430
|
-
—
|
1431
|
-
<div class='inline'><p>If <code>false</code>, it will just print a list of message that would be deleted.</p>
|
1432
|
-
</div>
|
1433
|
-
|
1434
|
-
</li>
|
1435
|
-
|
1436
|
-
<li>
|
1437
|
-
|
1438
|
-
<span class='name'>show_errors</span>
|
1439
|
-
|
1440
|
-
|
1441
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1442
|
-
|
1443
|
-
|
1444
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1445
|
-
|
1446
|
-
|
1447
|
-
—
|
1448
|
-
<div class='inline'><p>If show errors.</p>
|
1449
|
-
</div>
|
1450
|
-
|
1451
|
-
</li>
|
1452
|
-
|
1453
|
-
<li>
|
1454
|
-
|
1455
|
-
<span class='name'>fatal</span>
|
1456
|
-
|
1457
|
-
|
1458
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1459
|
-
|
1460
|
-
|
1461
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1462
|
-
|
1463
|
-
|
1464
|
-
—
|
1465
|
-
<div class='inline'><p>If quit in case of fatal errors.</p>
|
1466
|
-
</div>
|
1467
|
-
|
1468
|
-
</li>
|
1469
|
-
|
1470
|
-
</ul>
|
1471
|
-
|
1472
|
-
<p class="tag_title">Returns:</p>
|
1473
|
-
<ul class="return">
|
1474
|
-
|
1475
|
-
<li>
|
1476
|
-
|
1477
|
-
|
1478
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
—
|
1483
|
-
<div class='inline'><p><code>true</code> if operation succeeded, <code>false</code> otherwise.</p>
|
1484
|
-
</div>
|
1485
|
-
|
1486
|
-
</li>
|
1487
|
-
|
1488
|
-
</ul>
|
1489
|
-
|
1490
|
-
</div><table class="source_code">
|
1491
|
-
<tr>
|
1492
|
-
<td>
|
1493
|
-
<pre class="lines">
|
1494
|
-
|
1495
|
-
|
1496
|
-
101
|
1497
|
-
102
|
1498
|
-
103
|
1499
|
-
104
|
1500
|
-
105
|
1501
|
-
106
|
1502
|
-
107
|
1503
|
-
108
|
1504
|
-
109
|
1505
|
-
110
|
1506
|
-
111
|
1507
|
-
112
|
1508
|
-
113
|
1509
|
-
114
|
1510
|
-
115
|
1511
|
-
116
|
1512
|
-
117
|
1513
|
-
118
|
1514
|
-
119
|
1515
|
-
120
|
1516
|
-
121
|
1517
|
-
122
|
1518
|
-
123
|
1519
|
-
124
|
1520
|
-
125
|
1521
|
-
126
|
1522
|
-
127
|
1523
|
-
128
|
1524
|
-
129
|
1525
|
-
130
|
1526
|
-
131
|
1527
|
-
132
|
1528
|
-
133
|
1529
|
-
134
|
1530
|
-
135</pre>
|
1531
|
-
</td>
|
1532
|
-
<td>
|
1533
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 101</span>
|
1534
|
-
|
1535
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_files'>files</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
1536
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1537
|
-
<span class='id identifier rubyid_files'>files</span> <span class='op'>=</span> <span class='id identifier rubyid_files'>files</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='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</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_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1538
|
-
|
1539
|
-
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_run'>run</span> <span class='kw'>then</span>
|
1540
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Will remove file(s):</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1541
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>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>
|
1542
|
-
<span class='id identifier rubyid_files'>files</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_file'>file</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span> <span class='kw'>end</span>
|
1543
|
-
<span class='kw'>end</span>
|
1544
|
-
<span class='kw'>else</span>
|
1545
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1546
|
-
<span class='kw'>begin</span>
|
1547
|
-
<span class='const'>FileUtils</span><span class='period'>.</span><span class='id identifier rubyid_rm_r'>rm_r</span><span class='lparen'>(</span><span class='id identifier rubyid_files'>files</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:noop</span> <span class='op'>=></span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:verbose</span> <span class='op'>=></span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:secure</span> <span class='op'>=></span> <span class='kw'>true</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1548
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:rv</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
1549
|
-
<span class='kw'>rescue</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>EACCES</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1550
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</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><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot remove following non writable file: {mark=bright}</span><span class='embexpr_beg'>#{</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'>"</span><span class='tstring_content'>\\1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1551
|
-
<span class='kw'>rescue</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>ENOENT</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1552
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</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><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot remove following non existent file: {mark=bright}</span><span class='embexpr_beg'>#{</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'>"</span><span class='tstring_content'>\\1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1553
|
-
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
1554
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_show_errors'>show_errors</span> <span class='kw'>then</span>
|
1555
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot remove following file(s):</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1556
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>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>
|
1557
|
-
<span class='id identifier rubyid_files'>files</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_file'>file</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span> <span class='kw'>end</span>
|
1558
|
-
<span class='kw'>end</span>
|
1559
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>due to this error: [</span><span class='embexpr_beg'>#{</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='rbrace'>}</span><span class='tstring_content'>] </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>5</span><span class='rparen'>)</span>
|
1560
|
-
<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>
|
1561
|
-
<span class='kw'>end</span>
|
1562
|
-
<span class='kw'>end</span>
|
1563
|
-
|
1564
|
-
<span class='kw'>false</span>
|
1565
|
-
<span class='kw'>end</span>
|
1566
|
-
<span class='kw'>end</span>
|
1567
|
-
|
1568
|
-
<span class='id identifier rubyid_rv'>rv</span>
|
1569
|
-
<span class='kw'>end</span></pre>
|
1570
|
-
</td>
|
1571
|
-
</tr>
|
1572
|
-
</table>
|
1573
|
-
</div>
|
1574
|
-
|
1575
|
-
<div class="method_details ">
|
1576
|
-
<h3 class="signature " id="find-instance_method">
|
1577
|
-
|
1578
|
-
- (<tt>Object</tt>) <strong>find</strong>(directories, patterns = [], by_extension = false, case_sensitive = false)
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
</h3><div class="docstring">
|
1585
|
-
<div class="discussion">
|
1586
|
-
<p>Find a list of files in directories matching given regexps or patterns.</p>
|
1587
|
-
|
1588
|
-
<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>
|
1589
|
-
|
1590
|
-
<p>Inside the block, you can call <code>Find.prune</code> to stop searching in the current directory.</p>
|
1591
|
-
|
1592
|
-
|
1593
|
-
</div>
|
1594
|
-
</div>
|
1595
|
-
<div class="tags">
|
1596
|
-
<p class="tag_title">Parameters:</p>
|
1597
|
-
<ul class="param">
|
1598
|
-
|
1599
|
-
<li>
|
1600
|
-
|
1601
|
-
<span class='name'>directories</span>
|
1602
|
-
|
1603
|
-
|
1604
|
-
<span class='type'>(<tt>String</tt>)</span>
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
—
|
1609
|
-
<div class='inline'><p>A list of directories where to search files.</p>
|
1610
|
-
</div>
|
1611
|
-
|
1612
|
-
</li>
|
1613
|
-
|
1614
|
-
<li>
|
1615
|
-
|
1616
|
-
<span class='name'>patterns</span>
|
1617
|
-
|
1618
|
-
|
1619
|
-
<span class='type'>(<tt>Array</tt>)</span>
|
1620
|
-
|
1621
|
-
|
1622
|
-
<em class="default">(defaults to: <tt>[]</tt>)</em>
|
1623
|
-
|
1624
|
-
|
1625
|
-
—
|
1626
|
-
<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>
|
1627
|
-
</div>
|
1628
|
-
|
1629
|
-
</li>
|
1630
|
-
|
1631
|
-
<li>
|
1632
|
-
|
1633
|
-
<span class='name'>by_extension</span>
|
1634
|
-
|
1635
|
-
|
1636
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1637
|
-
|
1638
|
-
|
1639
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1640
|
-
|
1641
|
-
|
1642
|
-
—
|
1643
|
-
<div class='inline'><p>If to only search in extensions. Ignored if a block is provided.</p>
|
1644
|
-
</div>
|
1645
|
-
|
1646
|
-
</li>
|
1647
|
-
|
1648
|
-
<li>
|
1649
|
-
|
1650
|
-
<span class='name'>case_sensitive</span>
|
1651
|
-
|
1652
|
-
|
1653
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1654
|
-
|
1655
|
-
|
1656
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1657
|
-
|
1658
|
-
|
1659
|
-
—
|
1660
|
-
<div class='inline'><p>If the search is case sensitive. Only meaningful for string patterns.</p>
|
1661
|
-
</div>
|
1662
|
-
|
1663
|
-
</li>
|
1664
|
-
|
1665
|
-
</ul>
|
1666
|
-
|
1667
|
-
|
1668
|
-
</div><table class="source_code">
|
1669
|
-
<tr>
|
1670
|
-
<td>
|
1671
|
-
<pre class="lines">
|
1672
|
-
|
1673
|
-
|
1674
|
-
353
|
1675
|
-
354
|
1676
|
-
355
|
1677
|
-
356
|
1678
|
-
357
|
1679
|
-
358
|
1680
|
-
359
|
1681
|
-
360
|
1682
|
-
361
|
1683
|
-
362
|
1684
|
-
363
|
1685
|
-
364
|
1686
|
-
365
|
1687
|
-
366
|
1688
|
-
367
|
1689
|
-
368
|
1690
|
-
369
|
1691
|
-
370
|
1692
|
-
371
|
1693
|
-
372
|
1694
|
-
373
|
1695
|
-
374
|
1696
|
-
375
|
1697
|
-
376
|
1698
|
-
377
|
1699
|
-
378
|
1700
|
-
379
|
1701
|
-
380
|
1702
|
-
381
|
1703
|
-
382
|
1704
|
-
383
|
1705
|
-
384
|
1706
|
-
385</pre>
|
1707
|
-
</td>
|
1708
|
-
<td>
|
1709
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 353</span>
|
1710
|
-
|
1711
|
-
<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='rparen'>)</span>
|
1712
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1713
|
-
|
1714
|
-
<span class='comment'># Adjust directory
|
1715
|
-
</span> <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>
|
1716
|
-
|
1717
|
-
<span class='comment'># Adjust patterns
|
1718
|
-
</span> <span class='id identifier rubyid_patterns'>patterns</span> <span class='op'>=</span> <span class='id identifier rubyid_patterns'>patterns</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='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Regexp</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_p'>p</span> <span class='op'>:</span> <span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_quote'>quote</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1719
|
-
<span class='id identifier rubyid_patterns'>patterns</span> <span class='op'>=</span> <span class='id identifier rubyid_patterns'>patterns</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='rbrace'>}</span><span class='tstring_content'>)$</span><span class='regexp_end'>/</span></span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_by_extension'>by_extension</span>
|
1720
|
-
<span class='id identifier rubyid_patterns'>patterns</span> <span class='op'>=</span> <span class='id identifier rubyid_patterns'>patterns</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='rbrace'>}</span><span class='regexp_end'>/i</span></span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_case_sensitive'>case_sensitive</span>
|
1721
|
-
|
1722
|
-
<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>
|
1723
|
-
<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>
|
1724
|
-
<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>
|
1725
|
-
<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_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:found</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1726
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span> <span class='kw'>then</span>
|
1727
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:found</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='rparen'>)</span>
|
1728
|
-
<span class='kw'>else</span>
|
1729
|
-
<span class='id identifier rubyid_patterns'>patterns</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_pattern'>pattern</span><span class='op'>|</span>
|
1730
|
-
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:found</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_pattern'>pattern</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_by_extension'>by_extension</span> <span class='op'>||</span> <span class='op'>!</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1731
|
-
<span class='kw'>end</span>
|
1732
|
-
<span class='kw'>end</span>
|
1733
|
-
|
1734
|
-
<span class='kw'>false</span>
|
1735
|
-
<span class='kw'>end</span>
|
1736
|
-
|
1737
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'><<</span> <span class='id identifier rubyid_entry'>entry</span> <span class='kw'>if</span> <span class='id identifier rubyid_found'>found</span>
|
1738
|
-
<span class='kw'>end</span>
|
1739
|
-
<span class='kw'>end</span>
|
1740
|
-
<span class='kw'>end</span>
|
1741
|
-
|
1742
|
-
<span class='id identifier rubyid_rv'>rv</span>
|
1743
|
-
<span class='kw'>end</span></pre>
|
1744
|
-
</td>
|
1745
|
-
</tr>
|
1746
|
-
</table>
|
1747
|
-
</div>
|
1748
|
-
|
1749
|
-
<div class="method_details ">
|
1750
|
-
<h3 class="signature " id="move-instance_method">
|
1751
|
-
|
1752
|
-
- (<tt>Boolean</tt>) <strong>move</strong>(src, dst, run = true, show_errors = false, fatal = true)
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
</h3><div class="docstring">
|
1759
|
-
<div class="discussion">
|
1760
|
-
<p>Moves a set of files or directory to another location.</p>
|
1761
|
-
|
1762
|
-
|
1763
|
-
</div>
|
1764
|
-
</div>
|
1765
|
-
<div class="tags">
|
1766
|
-
<p class="tag_title">Parameters:</p>
|
1767
|
-
<ul class="param">
|
1768
|
-
|
1769
|
-
<li>
|
1770
|
-
|
1771
|
-
<span class='name'>src</span>
|
1772
|
-
|
1773
|
-
|
1774
|
-
<span class='type'>(<tt>String|Array</tt>)</span>
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
—
|
1779
|
-
<div class='inline'><p>The entries to move. If is an Array, <code>dst</code> is assumed to be a directory.</p>
|
1780
|
-
</div>
|
1781
|
-
|
1782
|
-
</li>
|
1783
|
-
|
1784
|
-
<li>
|
1785
|
-
|
1786
|
-
<span class='name'>dst</span>
|
1787
|
-
|
1788
|
-
|
1789
|
-
<span class='type'>(<tt>String</tt>)</span>
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
—
|
1794
|
-
<div class='inline'><p>The destination. <strong>Any existing entries will be overwritten.</strong> Any required directory will be created.</p>
|
1795
|
-
</div>
|
1796
|
-
|
1797
|
-
</li>
|
1798
|
-
|
1799
|
-
<li>
|
1800
|
-
|
1801
|
-
<span class='name'>run</span>
|
1802
|
-
|
1803
|
-
|
1804
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1805
|
-
|
1806
|
-
|
1807
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1808
|
-
|
1809
|
-
|
1810
|
-
—
|
1811
|
-
<div class='inline'><p>If <code>false</code>, it will just print a list of message that would be deleted.</p>
|
1812
|
-
</div>
|
1813
|
-
|
1814
|
-
</li>
|
1815
|
-
|
1816
|
-
<li>
|
1817
|
-
|
1818
|
-
<span class='name'>show_errors</span>
|
1819
|
-
|
1820
|
-
|
1821
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1822
|
-
|
1823
|
-
|
1824
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1825
|
-
|
1826
|
-
|
1827
|
-
—
|
1828
|
-
<div class='inline'><p>If show errors.</p>
|
1829
|
-
</div>
|
1830
|
-
|
1831
|
-
</li>
|
1832
|
-
|
1833
|
-
<li>
|
1834
|
-
|
1835
|
-
<span class='name'>fatal</span>
|
1836
|
-
|
1837
|
-
|
1838
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1839
|
-
|
1840
|
-
|
1841
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1842
|
-
|
1843
|
-
|
1844
|
-
—
|
1845
|
-
<div class='inline'><p>If quit in case of fatal errors.</p>
|
1846
|
-
</div>
|
1847
|
-
|
1848
|
-
</li>
|
1849
|
-
|
1850
|
-
</ul>
|
1851
|
-
|
1852
|
-
<p class="tag_title">Returns:</p>
|
1853
|
-
<ul class="return">
|
1854
|
-
|
1855
|
-
<li>
|
1856
|
-
|
1857
|
-
|
1858
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
—
|
1863
|
-
<div class='inline'><p><code>true</code> if operation succeeded, <code>false</code> otherwise.</p>
|
1864
|
-
</div>
|
1865
|
-
|
1866
|
-
</li>
|
1867
|
-
|
1868
|
-
</ul>
|
1869
|
-
|
1870
|
-
</div><table class="source_code">
|
1871
|
-
<tr>
|
1872
|
-
<td>
|
1873
|
-
<pre class="lines">
|
1874
|
-
|
1875
|
-
|
1876
|
-
250
|
1877
|
-
251
|
1878
|
-
252</pre>
|
1879
|
-
</td>
|
1880
|
-
<td>
|
1881
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 250</span>
|
1882
|
-
|
1883
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_move'>move</span><span class='lparen'>(</span><span class='id identifier rubyid_src'>src</span><span class='comma'>,</span> <span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
1884
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_copy_or_move'>copy_or_move</span><span class='lparen'>(</span><span class='id identifier rubyid_src'>src</span><span class='comma'>,</span> <span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='symbol'>:move</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span><span class='rparen'>)</span>
|
1885
|
-
<span class='kw'>end</span></pre>
|
1886
|
-
</td>
|
1887
|
-
</tr>
|
1888
|
-
</table>
|
1889
|
-
</div>
|
1890
|
-
|
1891
|
-
<div class="method_details ">
|
1892
|
-
<h3 class="signature " id="run-instance_method">
|
1893
|
-
|
1894
|
-
- (<tt>Hash</tt>) <strong>run</strong>(command, message = nil, run = true, show_exit = true, show_output = false, show_command = false, fatal = true)
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
</h3><div class="docstring">
|
1901
|
-
<div class="discussion">
|
1902
|
-
<p>Runs a command into the shell.</p>
|
1903
|
-
|
1904
|
-
|
1905
|
-
</div>
|
1906
|
-
</div>
|
1907
|
-
<div class="tags">
|
1908
|
-
<p class="tag_title">Parameters:</p>
|
1909
|
-
<ul class="param">
|
1910
|
-
|
1911
|
-
<li>
|
1912
|
-
|
1913
|
-
<span class='name'>command</span>
|
1914
|
-
|
1915
|
-
|
1916
|
-
<span class='type'>(<tt>String</tt>)</span>
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
—
|
1921
|
-
<div class='inline'><p>The string to run.</p>
|
1922
|
-
</div>
|
1923
|
-
|
1924
|
-
</li>
|
1925
|
-
|
1926
|
-
<li>
|
1927
|
-
|
1928
|
-
<span class='name'>message</span>
|
1929
|
-
|
1930
|
-
|
1931
|
-
<span class='type'>(<tt>String</tt>)</span>
|
1932
|
-
|
1933
|
-
|
1934
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1935
|
-
|
1936
|
-
|
1937
|
-
—
|
1938
|
-
<div class='inline'><p>A message to show before running.</p>
|
1939
|
-
</div>
|
1940
|
-
|
1941
|
-
</li>
|
1942
|
-
|
1943
|
-
<li>
|
1944
|
-
|
1945
|
-
<span class='name'>run</span>
|
1946
|
-
|
1947
|
-
|
1948
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1949
|
-
|
1950
|
-
|
1951
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1952
|
-
|
1953
|
-
|
1954
|
-
—
|
1955
|
-
<div class='inline'><p>If <code>false</code>, it will just print a message with the full command that will be run.</p>
|
1956
|
-
</div>
|
1957
|
-
|
1958
|
-
</li>
|
1959
|
-
|
1960
|
-
<li>
|
1961
|
-
|
1962
|
-
<span class='name'>show_exit</span>
|
1963
|
-
|
1964
|
-
|
1965
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1966
|
-
|
1967
|
-
|
1968
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
1969
|
-
|
1970
|
-
|
1971
|
-
—
|
1972
|
-
<div class='inline'><p>If show the exit status.</p>
|
1973
|
-
</div>
|
1974
|
-
|
1975
|
-
</li>
|
1976
|
-
|
1977
|
-
<li>
|
1978
|
-
|
1979
|
-
<span class='name'>show_output</span>
|
1980
|
-
|
1981
|
-
|
1982
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1983
|
-
|
1984
|
-
|
1985
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1986
|
-
|
1987
|
-
|
1988
|
-
—
|
1989
|
-
<div class='inline'><p>If show command output.</p>
|
1990
|
-
</div>
|
1991
|
-
|
1992
|
-
</li>
|
1993
|
-
|
1994
|
-
<li>
|
1995
|
-
|
1996
|
-
<span class='name'>show_command</span>
|
1997
|
-
|
1998
|
-
|
1999
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
2000
|
-
|
2001
|
-
|
2002
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
2003
|
-
|
2004
|
-
|
2005
|
-
—
|
2006
|
-
<div class='inline'><p>If show the command that will be run.</p>
|
2007
|
-
</div>
|
2008
|
-
|
2009
|
-
</li>
|
2010
|
-
|
2011
|
-
<li>
|
2012
|
-
|
2013
|
-
<span class='name'>fatal</span>
|
2014
|
-
|
2015
|
-
|
2016
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
2017
|
-
|
2018
|
-
|
2019
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
2020
|
-
|
2021
|
-
|
2022
|
-
—
|
2023
|
-
<div class='inline'><p>If quit in case of fatal errors.</p>
|
2024
|
-
</div>
|
2025
|
-
|
2026
|
-
</li>
|
2027
|
-
|
2028
|
-
</ul>
|
2029
|
-
|
2030
|
-
<p class="tag_title">Returns:</p>
|
2031
|
-
<ul class="return">
|
2032
|
-
|
2033
|
-
<li>
|
2034
|
-
|
2035
|
-
|
2036
|
-
<span class='type'>(<tt>Hash</tt>)</span>
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
—
|
2041
|
-
<div class='inline'><p>An hash with <code>status</code> and <code>output</code> keys.</p>
|
2042
|
-
</div>
|
2043
|
-
|
2044
|
-
</li>
|
2045
|
-
|
2046
|
-
</ul>
|
2047
|
-
|
2048
|
-
</div><table class="source_code">
|
2049
|
-
<tr>
|
2050
|
-
<td>
|
2051
|
-
<pre class="lines">
|
2052
|
-
|
2053
|
-
|
2054
|
-
35
|
2055
|
-
36
|
2056
|
-
37
|
2057
|
-
38
|
2058
|
-
39
|
2059
|
-
40
|
2060
|
-
41
|
2061
|
-
42
|
2062
|
-
43
|
2063
|
-
44
|
2064
|
-
45
|
2065
|
-
46
|
2066
|
-
47
|
2067
|
-
48
|
2068
|
-
49
|
2069
|
-
50
|
2070
|
-
51
|
2071
|
-
52
|
2072
|
-
53
|
2073
|
-
54
|
2074
|
-
55
|
2075
|
-
56
|
2076
|
-
57
|
2077
|
-
58
|
2078
|
-
59
|
2079
|
-
60
|
2080
|
-
61
|
2081
|
-
62
|
2082
|
-
63
|
2083
|
-
64</pre>
|
2084
|
-
</td>
|
2085
|
-
<td>
|
2086
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 35</span>
|
2087
|
-
|
2088
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_run'>run</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_output'>show_output</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_show_command'>show_command</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
2089
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='symbol'>:status</span> <span class='op'>=></span> <span class='int'>0</span><span class='comma'>,</span> <span class='symbol'>:output</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span>
|
2090
|
-
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
|
2091
|
-
|
2092
|
-
<span class='comment'># Show the command
|
2093
|
-
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_begin'>begin</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
2094
|
-
|
2095
|
-
|
2096
|
-
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_run'>run</span> <span class='kw'>then</span> <span class='comment'># Print a message
|
2097
|
-
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Will run command: {mark=bright}\"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_command'>command</span><span class='rbrace'>}</span><span class='tstring_content'>\"{/mark}...</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
2098
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_status'>status</span><span class='lparen'>(</span><span class='symbol'>:ok</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_show_exit'>show_exit</span>
|
2099
|
-
<span class='kw'>else</span> <span class='comment'># Run
|
2100
|
-
</span> <span class='id identifier rubyid_output'>output</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span>
|
2101
|
-
|
2102
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Running command: {mark=bright}\"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_command'>command</span><span class='rbrace'>}</span><span class='tstring_content'>\"{/mark}...</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_show_command'>show_command</span>
|
2103
|
-
<span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='symbol'>:status</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Open4</span><span class='op'>::</span><span class='id identifier rubyid_popen4'>popen4</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> 2>&1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_pid'>pid</span><span class='comma'>,</span> <span class='id identifier rubyid_stdin'>stdin</span><span class='comma'>,</span> <span class='id identifier rubyid_stdout'>stdout</span><span class='comma'>,</span> <span class='id identifier rubyid_stderr'>stderr</span><span class='op'>|</span>
|
2104
|
-
<span class='id identifier rubyid_stdout'>stdout</span><span class='period'>.</span><span class='id identifier rubyid_each_line'>each_line</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
|
2105
|
-
<span class='id identifier rubyid_output'>output</span> <span class='op'><<</span> <span class='id identifier rubyid_line'>line</span>
|
2106
|
-
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_print'>print</span> <span class='id identifier rubyid_line'>line</span> <span class='kw'>if</span> <span class='id identifier rubyid_show_output'>show_output</span>
|
2107
|
-
<span class='kw'>end</span>
|
2108
|
-
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_exitstatus'>exitstatus</span>
|
2109
|
-
|
2110
|
-
<span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='symbol'>:output</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_output'>output</span>
|
2111
|
-
<span class='kw'>end</span>
|
2112
|
-
|
2113
|
-
<span class='comment'># Return
|
2114
|
-
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_status'>status</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='symbol'>:status</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='int'>0</span> <span class='op'>?</span> <span class='symbol'>:ok</span> <span class='op'>:</span> <span class='symbol'>:fail</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_show_exit'>show_exit</span>
|
2115
|
-
<span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='symbol'>:status</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_fatal'>fatal</span> <span class='op'>&&</span> <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='symbol'>:status</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='int'>0</span>
|
2116
|
-
<span class='id identifier rubyid_rv'>rv</span>
|
2117
|
-
<span class='kw'>end</span></pre>
|
2118
|
-
</td>
|
2119
|
-
</tr>
|
2120
|
-
</table>
|
2121
|
-
</div>
|
2122
|
-
|
2123
|
-
<div class="method_details ">
|
2124
|
-
<h3 class="signature " id="within_directory-instance_method">
|
2125
|
-
|
2126
|
-
- (<tt>Boolean</tt>) <strong>within_directory</strong>(directory, restore = true, show_messages = false)
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
</h3><div class="docstring">
|
2133
|
-
<div class="discussion">
|
2134
|
-
<p>Executes a block of code in another directory.</p>
|
2135
|
-
|
2136
|
-
|
2137
|
-
</div>
|
2138
|
-
</div>
|
2139
|
-
<div class="tags">
|
2140
|
-
<p class="tag_title">Parameters:</p>
|
2141
|
-
<ul class="param">
|
2142
|
-
|
2143
|
-
<li>
|
2144
|
-
|
2145
|
-
<span class='name'>directory</span>
|
2146
|
-
|
2147
|
-
|
2148
|
-
<span class='type'>(<tt>String</tt>)</span>
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
—
|
2153
|
-
<div class='inline'><p>The new working directory.</p>
|
2154
|
-
</div>
|
2155
|
-
|
2156
|
-
</li>
|
2157
|
-
|
2158
|
-
<li>
|
2159
|
-
|
2160
|
-
<span class='name'>restore</span>
|
2161
|
-
|
2162
|
-
|
2163
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
2164
|
-
|
2165
|
-
|
2166
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
2167
|
-
|
2168
|
-
|
2169
|
-
—
|
2170
|
-
<div class='inline'><p>If to restore the original working directory.</p>
|
2171
|
-
</div>
|
2172
|
-
|
2173
|
-
</li>
|
2174
|
-
|
2175
|
-
<li>
|
2176
|
-
|
2177
|
-
<span class='name'>show_messages</span>
|
2178
|
-
|
2179
|
-
|
2180
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
2181
|
-
|
2182
|
-
|
2183
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
2184
|
-
|
2185
|
-
|
2186
|
-
—
|
2187
|
-
<div class='inline'><p>Show informative messages about working directory changes.</p>
|
2188
|
-
</div>
|
2189
|
-
|
2190
|
-
</li>
|
2191
|
-
|
2192
|
-
</ul>
|
2193
|
-
|
2194
|
-
<p class="tag_title">Returns:</p>
|
2195
|
-
<ul class="return">
|
2196
|
-
|
2197
|
-
<li>
|
2198
|
-
|
2199
|
-
|
2200
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
—
|
2205
|
-
<div class='inline'><p><code>true</code> if the directory was valid and the code executed, <code>false</code> otherwise.</p>
|
2206
|
-
</div>
|
2207
|
-
|
2208
|
-
</li>
|
2209
|
-
|
2210
|
-
</ul>
|
2211
|
-
|
2212
|
-
</div><table class="source_code">
|
2213
|
-
<tr>
|
2214
|
-
<td>
|
2215
|
-
<pre class="lines">
|
2216
|
-
|
2217
|
-
|
2218
|
-
260
|
2219
|
-
261
|
2220
|
-
262
|
2221
|
-
263
|
2222
|
-
264
|
2223
|
-
265
|
2224
|
-
266
|
2225
|
-
267
|
2226
|
-
268
|
2227
|
-
269
|
2228
|
-
270
|
2229
|
-
271
|
2230
|
-
272
|
2231
|
-
273
|
2232
|
-
274
|
2233
|
-
275
|
2234
|
-
276
|
2235
|
-
277
|
2236
|
-
278
|
2237
|
-
279
|
2238
|
-
280
|
2239
|
-
281
|
2240
|
-
282
|
2241
|
-
283
|
2242
|
-
284
|
2243
|
-
285
|
2244
|
-
286</pre>
|
2245
|
-
</td>
|
2246
|
-
<td>
|
2247
|
-
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 260</span>
|
2248
|
-
|
2249
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_within_directory'>within_directory</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='comma'>,</span> <span class='id identifier rubyid_restore'>restore</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_show_messages'>show_messages</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
2250
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>false</span>
|
2251
|
-
<span class='id identifier rubyid_original'>original</span> <span class='op'>=</span> <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_pwd'>pwd</span>
|
2252
|
-
<span class='id identifier rubyid_directory'>directory</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_directory'>directory</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
|
2253
|
-
|
2254
|
-
<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'>:executable</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>then</span>
|
2255
|
-
<span class='kw'>begin</span>
|
2256
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Moving into directory {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_directory'>directory</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_show_messages'>show_messages</span>
|
2257
|
-
<span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_chdir'>chdir</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='rparen'>)</span>
|
2258
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>true</span>
|
2259
|
-
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
2260
|
-
<span class='kw'>end</span>
|
2261
|
-
<span class='kw'>end</span>
|
2262
|
-
|
2263
|
-
<span class='kw'>yield</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&&</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
2264
|
-
|
2265
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&&</span> <span class='id identifier rubyid_original'>original</span> <span class='kw'>then</span>
|
2266
|
-
<span class='kw'>begin</span>
|
2267
|
-
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Moving back into directory {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_original'>original</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_show_messages'>show_messages</span>
|
2268
|
-
<span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_chdir'>chdir</span><span class='lparen'>(</span><span class='id identifier rubyid_original'>original</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_restore'>restore</span>
|
2269
|
-
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
2270
|
-
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>false</span>
|
2271
|
-
<span class='kw'>end</span>
|
2272
|
-
<span class='kw'>end</span>
|
2273
|
-
|
2274
|
-
<span class='id identifier rubyid_rv'>rv</span>
|
443
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
|
444
|
+
<span class='ivar'>@instance</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Shell</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
2275
445
|
<span class='kw'>end</span></pre>
|
2276
446
|
</td>
|
2277
447
|
</tr>
|
@@ -2283,9 +453,9 @@
|
|
2283
453
|
</div>
|
2284
454
|
|
2285
455
|
<div id="footer">
|
2286
|
-
Generated on
|
456
|
+
Generated on Fri Feb 1 23:40:18 2013 by
|
2287
457
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2288
|
-
0.8.
|
458
|
+
0.8.3 (ruby-1.9.3).
|
2289
459
|
</div>
|
2290
460
|
|
2291
461
|
</body>
|