rvvm 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +159 -5
- data/Rakefile +0 -6
- data/doc/Crayons.html +1206 -0
- data/doc/Rvvm/Error.html +148 -0
- data/doc/Rvvm.html +2258 -0
- data/doc/Templates.html +227 -0
- data/doc/Utils.html +991 -0
- data/doc/_index.html +161 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +503 -0
- data/doc/file.README.html +444 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +22 -0
- data/doc/index.html +444 -0
- data/doc/js/app.js +344 -0
- data/doc/js/full_list.js +242 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +334 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/rvvm/crayons.rb +8 -3
- data/lib/rvvm/utils.rb +2 -2
- data/lib/rvvm/version.rb +1 -1
- data/lib/rvvm.rb +5 -2
- data/sig/rvvm/crayons.rbs +12 -6
- data/sig/rvvm/utils.rbs +5 -5
- data/sig/rvvm.rbs +31 -5
- metadata +20 -1
data/doc/Utils.html
ADDED
@@ -0,0 +1,991 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: Utils
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "Utils";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index (U)</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">Utils</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: Utils
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/rvvm/utils.rb</dd>
|
82
|
+
</dl>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<h2>Overview</h2><div class="docstring">
|
87
|
+
<div class="discussion">
|
88
|
+
<p>Utils module providing utilities and helper methods to rvvm.</p>
|
89
|
+
|
90
|
+
<p>Mainly used to generate files and templates.</p>
|
91
|
+
|
92
|
+
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
<div class="tags">
|
96
|
+
|
97
|
+
<p class="tag_title">Since:</p>
|
98
|
+
<ul class="since">
|
99
|
+
|
100
|
+
<li>
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
<div class='inline'><p>0.1.0</p>
|
107
|
+
</div>
|
108
|
+
|
109
|
+
</li>
|
110
|
+
|
111
|
+
</ul>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<h2>
|
122
|
+
Class Method Summary
|
123
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
124
|
+
</h2>
|
125
|
+
|
126
|
+
<ul class="summary">
|
127
|
+
|
128
|
+
<li class="public ">
|
129
|
+
<span class="summary_signature">
|
130
|
+
|
131
|
+
<a href="#all_nil%3F-class_method" title="all_nil? (class method)">.<strong>all_nil?</strong>(hash, array) ⇒ Bolean, Boolean </a>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</span>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<span class="summary_desc"><div class='inline'><p>Checks if hash contains keys provided from an array.</p>
|
146
|
+
</div></span>
|
147
|
+
|
148
|
+
</li>
|
149
|
+
|
150
|
+
|
151
|
+
<li class="public ">
|
152
|
+
<span class="summary_signature">
|
153
|
+
|
154
|
+
<a href="#find_file_dir-class_method" title="find_file_dir (class method)">.<strong>find_file_dir</strong>(filename, path) ⇒ String<sup>?</sup> </a>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
</span>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<span class="summary_desc"><div class='inline'><p>Recursively searches provided directory for a file.</p>
|
169
|
+
</div></span>
|
170
|
+
|
171
|
+
</li>
|
172
|
+
|
173
|
+
|
174
|
+
<li class="public ">
|
175
|
+
<span class="summary_signature">
|
176
|
+
|
177
|
+
<a href="#gen_file-class_method" title="gen_file (class method)">.<strong>gen_file</strong>(path, content) ⇒ void </a>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
</span>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
<span class="summary_desc"><div class='inline'><p>Generates a file with a provided content.</p>
|
192
|
+
</div></span>
|
193
|
+
|
194
|
+
</li>
|
195
|
+
|
196
|
+
|
197
|
+
<li class="public ">
|
198
|
+
<span class="summary_signature">
|
199
|
+
|
200
|
+
<a href="#gen_template-class_method" title="gen_template (class method)">.<strong>gen_template</strong>(template, name = nil, config = nil, path = nil) ⇒ void </a>
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
</span>
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
<span class="summary_desc"><div class='inline'><p>Generates a file based on a template.</p>
|
215
|
+
</div></span>
|
216
|
+
|
217
|
+
</li>
|
218
|
+
|
219
|
+
|
220
|
+
<li class="public ">
|
221
|
+
<span class="summary_signature">
|
222
|
+
|
223
|
+
<a href="#git_userame-class_method" title="git_userame (class method)">.<strong>git_userame</strong> ⇒ String </a>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
</span>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
<span class="summary_desc"><div class='inline'><p>Extracts git username using git config system call.</p>
|
238
|
+
</div></span>
|
239
|
+
|
240
|
+
</li>
|
241
|
+
|
242
|
+
|
243
|
+
<li class="public ">
|
244
|
+
<span class="summary_signature">
|
245
|
+
|
246
|
+
<a href="#interpolate-class_method" title="interpolate (class method)">.<strong>interpolate</strong>(string, hash) ⇒ string </a>
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
</span>
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
<span class="summary_desc"><div class='inline'><p>Interpolates string.</p>
|
261
|
+
</div></span>
|
262
|
+
|
263
|
+
</li>
|
264
|
+
|
265
|
+
|
266
|
+
</ul>
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
<div id="class_method_details" class="method_details_list">
|
272
|
+
<h2>Class Method Details</h2>
|
273
|
+
|
274
|
+
|
275
|
+
<div class="method_details first">
|
276
|
+
<h3 class="signature first" id="all_nil?-class_method">
|
277
|
+
|
278
|
+
.<strong>all_nil?</strong>(hash, array) ⇒ <tt>Bolean</tt>, <tt>Boolean</tt>
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
</h3><div class="docstring">
|
285
|
+
<div class="discussion">
|
286
|
+
<p>Checks if hash contains keys provided from an array.</p>
|
287
|
+
|
288
|
+
|
289
|
+
</div>
|
290
|
+
</div>
|
291
|
+
<div class="tags">
|
292
|
+
<p class="tag_title">Parameters:</p>
|
293
|
+
<ul class="param">
|
294
|
+
|
295
|
+
<li>
|
296
|
+
|
297
|
+
<span class='name'>hash</span>
|
298
|
+
|
299
|
+
|
300
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
—
|
305
|
+
<div class='inline'><p>to analyze</p>
|
306
|
+
</div>
|
307
|
+
|
308
|
+
</li>
|
309
|
+
|
310
|
+
<li>
|
311
|
+
|
312
|
+
<span class='name'>array</span>
|
313
|
+
|
314
|
+
|
315
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
—
|
320
|
+
<div class='inline'><p>of keys to look for in the hash</p>
|
321
|
+
</div>
|
322
|
+
|
323
|
+
</li>
|
324
|
+
|
325
|
+
</ul>
|
326
|
+
|
327
|
+
<p class="tag_title">Returns:</p>
|
328
|
+
<ul class="return">
|
329
|
+
|
330
|
+
<li>
|
331
|
+
|
332
|
+
|
333
|
+
<span class='type'>(<tt>Bolean</tt>)</span>
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
—
|
338
|
+
<div class='inline'><p>true if all provided keys from a hash return nil</p>
|
339
|
+
</div>
|
340
|
+
|
341
|
+
</li>
|
342
|
+
|
343
|
+
<li>
|
344
|
+
|
345
|
+
|
346
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
—
|
351
|
+
<div class='inline'><p>false if a provided key is found in the hash</p>
|
352
|
+
</div>
|
353
|
+
|
354
|
+
</li>
|
355
|
+
|
356
|
+
</ul>
|
357
|
+
<p class="tag_title">Since:</p>
|
358
|
+
<ul class="since">
|
359
|
+
|
360
|
+
<li>
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
<div class='inline'><p>0.9.0</p>
|
367
|
+
</div>
|
368
|
+
|
369
|
+
</li>
|
370
|
+
|
371
|
+
</ul>
|
372
|
+
|
373
|
+
</div><table class="source_code">
|
374
|
+
<tr>
|
375
|
+
<td>
|
376
|
+
<pre class="lines">
|
377
|
+
|
378
|
+
|
379
|
+
115
|
380
|
+
116
|
381
|
+
117
|
382
|
+
118
|
383
|
+
119
|
384
|
+
120</pre>
|
385
|
+
</td>
|
386
|
+
<td>
|
387
|
+
<pre class="code"><span class="info file"># File 'lib/rvvm/utils.rb', line 115</span>
|
388
|
+
|
389
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_all_nil?'>all_nil?</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_array'>array</span><span class='rparen'>)</span>
|
390
|
+
<span class='id identifier rubyid_array'>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_key'>key</span><span class='op'>|</span>
|
391
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span>
|
392
|
+
<span class='kw'>end</span>
|
393
|
+
<span class='kw'>true</span>
|
394
|
+
<span class='kw'>end</span></pre>
|
395
|
+
</td>
|
396
|
+
</tr>
|
397
|
+
</table>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
<div class="method_details ">
|
401
|
+
<h3 class="signature " id="find_file_dir-class_method">
|
402
|
+
|
403
|
+
.<strong>find_file_dir</strong>(filename, path) ⇒ <tt>String</tt><sup>?</sup>
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
</h3><div class="docstring">
|
410
|
+
<div class="discussion">
|
411
|
+
<p>Recursively searches provided directory for a file.</p>
|
412
|
+
|
413
|
+
<p>or</p>
|
414
|
+
|
415
|
+
|
416
|
+
</div>
|
417
|
+
</div>
|
418
|
+
<div class="tags">
|
419
|
+
<p class="tag_title">Parameters:</p>
|
420
|
+
<ul class="param">
|
421
|
+
|
422
|
+
<li>
|
423
|
+
|
424
|
+
<span class='name'>filename</span>
|
425
|
+
|
426
|
+
|
427
|
+
<span class='type'>(<tt>String</tt>)</span>
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
—
|
432
|
+
<div class='inline'><p>name of the file to look for</p>
|
433
|
+
</div>
|
434
|
+
|
435
|
+
</li>
|
436
|
+
|
437
|
+
<li>
|
438
|
+
|
439
|
+
<span class='name'>path</span>
|
440
|
+
|
441
|
+
|
442
|
+
<span class='type'>(<tt>String</tt>)</span>
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
—
|
447
|
+
<div class='inline'><p>path to start search on</p>
|
448
|
+
</div>
|
449
|
+
|
450
|
+
</li>
|
451
|
+
|
452
|
+
</ul>
|
453
|
+
|
454
|
+
<p class="tag_title">Returns:</p>
|
455
|
+
<ul class="return">
|
456
|
+
|
457
|
+
<li>
|
458
|
+
|
459
|
+
|
460
|
+
<span class='type'>(<tt>String</tt>)</span>
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
—
|
465
|
+
<div class='inline'><p>path of the first occurence of the file</p>
|
466
|
+
</div>
|
467
|
+
|
468
|
+
</li>
|
469
|
+
|
470
|
+
<li>
|
471
|
+
|
472
|
+
|
473
|
+
<span class='type'>(<tt>nil</tt>)</span>
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
—
|
478
|
+
<div class='inline'><p>if file not found</p>
|
479
|
+
</div>
|
480
|
+
|
481
|
+
</li>
|
482
|
+
|
483
|
+
</ul>
|
484
|
+
<p class="tag_title">Since:</p>
|
485
|
+
<ul class="since">
|
486
|
+
|
487
|
+
<li>
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
<div class='inline'><p>0.8.0</p>
|
494
|
+
</div>
|
495
|
+
|
496
|
+
</li>
|
497
|
+
|
498
|
+
</ul>
|
499
|
+
|
500
|
+
</div><table class="source_code">
|
501
|
+
<tr>
|
502
|
+
<td>
|
503
|
+
<pre class="lines">
|
504
|
+
|
505
|
+
|
506
|
+
74
|
507
|
+
75
|
508
|
+
76
|
509
|
+
77
|
510
|
+
78
|
511
|
+
79
|
512
|
+
80
|
513
|
+
81
|
514
|
+
82
|
515
|
+
83
|
516
|
+
84
|
517
|
+
85
|
518
|
+
86
|
519
|
+
87
|
520
|
+
88
|
521
|
+
89</pre>
|
522
|
+
</td>
|
523
|
+
<td>
|
524
|
+
<pre class="code"><span class="info file"># File 'lib/rvvm/utils.rb', line 74</span>
|
525
|
+
|
526
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_find_file_dir'>find_file_dir</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
|
527
|
+
<span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span>
|
528
|
+
<span class='kw'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_file'>file</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span>
|
529
|
+
<span class='kw'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_file'>file</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>..</span><span class='tstring_end'>"</span></span>
|
530
|
+
|
531
|
+
<span class='id identifier rubyid_full_path'>full_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
|
532
|
+
|
533
|
+
<span class='kw'>if</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_full_path'>full_path</span><span class='rparen'>)</span>
|
534
|
+
<span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='id identifier rubyid_find_file_dir'>find_file_dir</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
|
535
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_found'>found</span> <span class='kw'>if</span> <span class='id identifier rubyid_found'>found</span>
|
536
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_file'>file</span> <span class='op'>==</span> <span class='id identifier rubyid_filename'>filename</span>
|
537
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_path'>path</span>
|
538
|
+
<span class='kw'>end</span>
|
539
|
+
<span class='kw'>end</span>
|
540
|
+
<span class='kw'>nil</span>
|
541
|
+
<span class='kw'>end</span></pre>
|
542
|
+
</td>
|
543
|
+
</tr>
|
544
|
+
</table>
|
545
|
+
</div>
|
546
|
+
|
547
|
+
<div class="method_details ">
|
548
|
+
<h3 class="signature " id="gen_file-class_method">
|
549
|
+
|
550
|
+
.<strong>gen_file</strong>(path, content) ⇒ <tt>void</tt>
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
</h3><div class="docstring">
|
557
|
+
<div class="discussion">
|
558
|
+
<p class="note returns_void">This method returns an undefined value.</p><p>Generates a file with a provided content.</p>
|
559
|
+
|
560
|
+
|
561
|
+
</div>
|
562
|
+
</div>
|
563
|
+
<div class="tags">
|
564
|
+
<p class="tag_title">Parameters:</p>
|
565
|
+
<ul class="param">
|
566
|
+
|
567
|
+
<li>
|
568
|
+
|
569
|
+
<span class='name'>path</span>
|
570
|
+
|
571
|
+
|
572
|
+
<span class='type'>(<tt>String</tt>)</span>
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
—
|
577
|
+
<div class='inline'><p>path of the file to be generated</p>
|
578
|
+
</div>
|
579
|
+
|
580
|
+
</li>
|
581
|
+
|
582
|
+
<li>
|
583
|
+
|
584
|
+
<span class='name'>content</span>
|
585
|
+
|
586
|
+
|
587
|
+
<span class='type'>(<tt>String</tt>)</span>
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
—
|
592
|
+
<div class='inline'><p>content of the file to be generated</p>
|
593
|
+
</div>
|
594
|
+
|
595
|
+
</li>
|
596
|
+
|
597
|
+
</ul>
|
598
|
+
|
599
|
+
<p class="tag_title">Since:</p>
|
600
|
+
<ul class="since">
|
601
|
+
|
602
|
+
<li>
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
<div class='inline'><p>0.8.0</p>
|
609
|
+
</div>
|
610
|
+
|
611
|
+
</li>
|
612
|
+
|
613
|
+
</ul>
|
614
|
+
|
615
|
+
</div><table class="source_code">
|
616
|
+
<tr>
|
617
|
+
<td>
|
618
|
+
<pre class="lines">
|
619
|
+
|
620
|
+
|
621
|
+
35
|
622
|
+
36
|
623
|
+
37
|
624
|
+
38
|
625
|
+
39
|
626
|
+
40
|
627
|
+
41
|
628
|
+
42</pre>
|
629
|
+
</td>
|
630
|
+
<td>
|
631
|
+
<pre class="code"><span class="info file"># File 'lib/rvvm/utils.rb', line 35</span>
|
632
|
+
|
633
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_gen_file'>gen_file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span><span class='rparen'>)</span>
|
634
|
+
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>w</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span>
|
635
|
+
<span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='rparen'>)</span>
|
636
|
+
<span class='kw'>end</span>
|
637
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
638
|
+
<span class='const'><span class='object_link'><a href="Crayons.html" title="Crayons (module)">Crayons</a></span></span><span class='period'>.</span><span class='id identifier rubyid_spinner_stop'><span class='object_link'><a href="Crayons.html#spinner_stop-class_method" title="Crayons.spinner_stop (method)">spinner_stop</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Error!</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="Crayons.html" title="Crayons (module)">Crayons</a></span></span><span class='period'>.</span><span class='id identifier rubyid_spinner_running?'><span class='object_link'><a href="Crayons.html#spinner_running%3F-class_method" title="Crayons.spinner_running? (method)">spinner_running?</a></span></span>
|
639
|
+
<span class='const'><span class='object_link'><a href="Crayons.html" title="Crayons (module)">Crayons</a></span></span><span class='period'>.</span><span class='id identifier rubyid_log_error'><span class='object_link'><a href="Crayons.html#log_error-class_method" title="Crayons.log_error (method)">log_error</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\nFailed to create a file!\n </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='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
640
|
+
<span class='kw'>end</span></pre>
|
641
|
+
</td>
|
642
|
+
</tr>
|
643
|
+
</table>
|
644
|
+
</div>
|
645
|
+
|
646
|
+
<div class="method_details ">
|
647
|
+
<h3 class="signature " id="gen_template-class_method">
|
648
|
+
|
649
|
+
.<strong>gen_template</strong>(template, name = nil, config = nil, path = nil) ⇒ <tt>void</tt>
|
650
|
+
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
</h3><div class="docstring">
|
656
|
+
<div class="discussion">
|
657
|
+
<p class="note returns_void">This method returns an undefined value.</p><p>Generates a file based on a template.</p>
|
658
|
+
|
659
|
+
|
660
|
+
</div>
|
661
|
+
</div>
|
662
|
+
<div class="tags">
|
663
|
+
<p class="tag_title">Parameters:</p>
|
664
|
+
<ul class="param">
|
665
|
+
|
666
|
+
<li>
|
667
|
+
|
668
|
+
<span class='name'>template</span>
|
669
|
+
|
670
|
+
|
671
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
672
|
+
|
673
|
+
|
674
|
+
|
675
|
+
—
|
676
|
+
<div class='inline'><p>hash with the template content</p>
|
677
|
+
</div>
|
678
|
+
|
679
|
+
</li>
|
680
|
+
|
681
|
+
<li>
|
682
|
+
|
683
|
+
<span class='name'>name</span>
|
684
|
+
|
685
|
+
|
686
|
+
<span class='type'>(<tt>String</tt>)</span>
|
687
|
+
|
688
|
+
|
689
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
690
|
+
|
691
|
+
|
692
|
+
—
|
693
|
+
<div class='inline'><p>name of the file to be generated</p>
|
694
|
+
</div>
|
695
|
+
|
696
|
+
</li>
|
697
|
+
|
698
|
+
<li>
|
699
|
+
|
700
|
+
<span class='name'>config</span>
|
701
|
+
|
702
|
+
|
703
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
704
|
+
|
705
|
+
|
706
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
707
|
+
|
708
|
+
|
709
|
+
—
|
710
|
+
<div class='inline'><p>template config hash for content interpolation</p>
|
711
|
+
</div>
|
712
|
+
|
713
|
+
</li>
|
714
|
+
|
715
|
+
<li>
|
716
|
+
|
717
|
+
<span class='name'>path</span>
|
718
|
+
|
719
|
+
|
720
|
+
<span class='type'>(<tt>String</tt>)</span>
|
721
|
+
|
722
|
+
|
723
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
724
|
+
|
725
|
+
|
726
|
+
—
|
727
|
+
<div class='inline'><p>path of the template file to be generated (excluding file name)</p>
|
728
|
+
</div>
|
729
|
+
|
730
|
+
</li>
|
731
|
+
|
732
|
+
</ul>
|
733
|
+
|
734
|
+
<p class="tag_title">Since:</p>
|
735
|
+
<ul class="since">
|
736
|
+
|
737
|
+
<li>
|
738
|
+
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
|
743
|
+
<div class='inline'><p>0.8.0</p>
|
744
|
+
</div>
|
745
|
+
|
746
|
+
</li>
|
747
|
+
|
748
|
+
</ul>
|
749
|
+
|
750
|
+
</div><table class="source_code">
|
751
|
+
<tr>
|
752
|
+
<td>
|
753
|
+
<pre class="lines">
|
754
|
+
|
755
|
+
|
756
|
+
54
|
757
|
+
55
|
758
|
+
56
|
759
|
+
57
|
760
|
+
58
|
761
|
+
59
|
762
|
+
60
|
763
|
+
61
|
764
|
+
62</pre>
|
765
|
+
</td>
|
766
|
+
<td>
|
767
|
+
<pre class="code"><span class="info file"># File 'lib/rvvm/utils.rb', line 54</span>
|
768
|
+
|
769
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_gen_template'>gen_template</span><span class='lparen'>(</span><span class='id identifier rubyid_template'>template</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
770
|
+
<span class='id identifier rubyid_temp_config'>temp_config</span> <span class='op'>=</span> <span class='id identifier rubyid_config'>config</span> <span class='op'>||</span> <span class='id identifier rubyid_template'>template</span><span class='lbracket'>[</span><span class='symbol'>:config</span><span class='rbracket'>]</span>
|
771
|
+
<span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='id identifier rubyid_interpolate'>interpolate</span><span class='lparen'>(</span><span class='id identifier rubyid_template'>template</span><span class='lbracket'>[</span><span class='symbol'>:content</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_temp_config'>temp_config</span><span class='rparen'>)</span>
|
772
|
+
<span class='id identifier rubyid_filename'>filename</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>||</span> <span class='id identifier rubyid_template'>template</span><span class='lbracket'>[</span><span class='symbol'>:file</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span>
|
773
|
+
<span class='id identifier rubyid_filepath'>filepath</span> <span class='op'>=</span> <span class='id identifier rubyid_path'>path</span> <span class='op'>||</span> <span class='id identifier rubyid_template'>template</span><span class='lbracket'>[</span><span class='symbol'>:file</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:path</span><span class='rbracket'>]</span>
|
774
|
+
|
775
|
+
<span class='const'><span class='object_link'><a href="Crayons.html" title="Crayons (module)">Crayons</a></span></span><span class='period'>.</span><span class='id identifier rubyid_spinner_log'><span class='object_link'><a href="Crayons.html#spinner_log-class_method" title="Crayons.spinner_log (method)">spinner_log</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Generating: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filepath'>filepath</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filename'>filename</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
776
|
+
<span class='id identifier rubyid_gen_file'>gen_file</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filepath'>filepath</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filename'>filename</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span><span class='rparen'>)</span>
|
777
|
+
<span class='kw'>end</span></pre>
|
778
|
+
</td>
|
779
|
+
</tr>
|
780
|
+
</table>
|
781
|
+
</div>
|
782
|
+
|
783
|
+
<div class="method_details ">
|
784
|
+
<h3 class="signature " id="git_userame-class_method">
|
785
|
+
|
786
|
+
.<strong>git_userame</strong> ⇒ <tt>String</tt>
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
</h3><div class="docstring">
|
793
|
+
<div class="discussion">
|
794
|
+
<p>Extracts git username using git config system call.</p>
|
795
|
+
|
796
|
+
|
797
|
+
</div>
|
798
|
+
</div>
|
799
|
+
<div class="tags">
|
800
|
+
|
801
|
+
<p class="tag_title">Returns:</p>
|
802
|
+
<ul class="return">
|
803
|
+
|
804
|
+
<li>
|
805
|
+
|
806
|
+
|
807
|
+
<span class='type'>(<tt>String</tt>)</span>
|
808
|
+
|
809
|
+
|
810
|
+
|
811
|
+
—
|
812
|
+
<div class='inline'><p>git username</p>
|
813
|
+
</div>
|
814
|
+
|
815
|
+
</li>
|
816
|
+
|
817
|
+
</ul>
|
818
|
+
<p class="tag_title">Since:</p>
|
819
|
+
<ul class="since">
|
820
|
+
|
821
|
+
<li>
|
822
|
+
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
|
827
|
+
<div class='inline'><p>0.9.0</p>
|
828
|
+
</div>
|
829
|
+
|
830
|
+
</li>
|
831
|
+
|
832
|
+
</ul>
|
833
|
+
|
834
|
+
</div><table class="source_code">
|
835
|
+
<tr>
|
836
|
+
<td>
|
837
|
+
<pre class="lines">
|
838
|
+
|
839
|
+
|
840
|
+
96
|
841
|
+
97
|
842
|
+
98
|
843
|
+
99
|
844
|
+
100
|
845
|
+
101
|
846
|
+
102
|
847
|
+
103
|
848
|
+
104</pre>
|
849
|
+
</td>
|
850
|
+
<td>
|
851
|
+
<pre class="code"><span class="info file"># File 'lib/rvvm/utils.rb', line 96</span>
|
852
|
+
|
853
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_git_userame'>git_userame</span>
|
854
|
+
<span class='id identifier rubyid_username'>username</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
855
|
+
<span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_popen'>popen</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>git config --get user.name</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_handle'>handle</span><span class='op'>|</span>
|
856
|
+
<span class='id identifier rubyid_username'>username</span> <span class='op'>=</span> <span class='id identifier rubyid_handle'>handle</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span>
|
857
|
+
<span class='kw'>end</span>
|
858
|
+
|
859
|
+
<span class='id identifier rubyid_username'>username</span><span class='op'>&.</span><span class='id identifier rubyid_strip!'>strip!</span>
|
860
|
+
<span class='id identifier rubyid_username'>username</span>
|
861
|
+
<span class='kw'>end</span></pre>
|
862
|
+
</td>
|
863
|
+
</tr>
|
864
|
+
</table>
|
865
|
+
</div>
|
866
|
+
|
867
|
+
<div class="method_details ">
|
868
|
+
<h3 class="signature " id="interpolate-class_method">
|
869
|
+
|
870
|
+
.<strong>interpolate</strong>(string, hash) ⇒ <tt>string</tt>
|
871
|
+
|
872
|
+
|
873
|
+
|
874
|
+
|
875
|
+
|
876
|
+
</h3><div class="docstring">
|
877
|
+
<div class="discussion">
|
878
|
+
<p>Interpolates string.</p>
|
879
|
+
|
880
|
+
<p>Replaces named keys <code>${example_key}</code> with provided values based on a hash.</p>
|
881
|
+
|
882
|
+
|
883
|
+
</div>
|
884
|
+
</div>
|
885
|
+
<div class="tags">
|
886
|
+
<p class="tag_title">Parameters:</p>
|
887
|
+
<ul class="param">
|
888
|
+
|
889
|
+
<li>
|
890
|
+
|
891
|
+
<span class='name'>string</span>
|
892
|
+
|
893
|
+
|
894
|
+
<span class='type'>(<tt>String</tt>)</span>
|
895
|
+
|
896
|
+
|
897
|
+
|
898
|
+
—
|
899
|
+
<div class='inline'><p>string to be interpolated</p>
|
900
|
+
</div>
|
901
|
+
|
902
|
+
</li>
|
903
|
+
|
904
|
+
<li>
|
905
|
+
|
906
|
+
<span class='name'>hash</span>
|
907
|
+
|
908
|
+
|
909
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
910
|
+
|
911
|
+
|
912
|
+
|
913
|
+
—
|
914
|
+
<div class='inline'><p>Hash to provide values to replace instead of the named keys</p>
|
915
|
+
</div>
|
916
|
+
|
917
|
+
</li>
|
918
|
+
|
919
|
+
</ul>
|
920
|
+
|
921
|
+
<p class="tag_title">Returns:</p>
|
922
|
+
<ul class="return">
|
923
|
+
|
924
|
+
<li>
|
925
|
+
|
926
|
+
|
927
|
+
<span class='type'>(<tt>string</tt>)</span>
|
928
|
+
|
929
|
+
|
930
|
+
|
931
|
+
—
|
932
|
+
<div class='inline'><p>interpolated string</p>
|
933
|
+
</div>
|
934
|
+
|
935
|
+
</li>
|
936
|
+
|
937
|
+
</ul>
|
938
|
+
<p class="tag_title">Since:</p>
|
939
|
+
<ul class="since">
|
940
|
+
|
941
|
+
<li>
|
942
|
+
|
943
|
+
|
944
|
+
|
945
|
+
|
946
|
+
|
947
|
+
<div class='inline'><p>0.1.0</p>
|
948
|
+
</div>
|
949
|
+
|
950
|
+
</li>
|
951
|
+
|
952
|
+
</ul>
|
953
|
+
|
954
|
+
</div><table class="source_code">
|
955
|
+
<tr>
|
956
|
+
<td>
|
957
|
+
<pre class="lines">
|
958
|
+
|
959
|
+
|
960
|
+
21
|
961
|
+
22
|
962
|
+
23
|
963
|
+
24
|
964
|
+
25</pre>
|
965
|
+
</td>
|
966
|
+
<td>
|
967
|
+
<pre class="code"><span class="info file"># File 'lib/rvvm/utils.rb', line 21</span>
|
968
|
+
|
969
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_interpolate'>interpolate</span><span class='lparen'>(</span><span class='id identifier rubyid_string'>string</span><span class='comma'>,</span> <span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
970
|
+
<span class='id identifier rubyid_string'>string</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='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span>
|
971
|
+
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_last_match'>last_match</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_match'>match</span>
|
972
|
+
<span class='kw'>end</span>
|
973
|
+
<span class='kw'>end</span></pre>
|
974
|
+
</td>
|
975
|
+
</tr>
|
976
|
+
</table>
|
977
|
+
</div>
|
978
|
+
|
979
|
+
</div>
|
980
|
+
|
981
|
+
</div>
|
982
|
+
|
983
|
+
<div id="footer">
|
984
|
+
Generated on Thu Sep 19 20:26:42 2024 by
|
985
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
986
|
+
0.9.37 (ruby-3.2.5).
|
987
|
+
</div>
|
988
|
+
|
989
|
+
</div>
|
990
|
+
</body>
|
991
|
+
</html>
|