marked-conductor 1.0.13 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +41 -5
- data/html/Filter.html +262 -0
- data/html/String.html +428 -26
- data/html/created.rid +4 -4
- data/html/js/search_index.js +1 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/table_of_contents.html +79 -19
- data/lib/conductor/filter.rb +165 -3
- data/lib/conductor/string.rb +31 -0
- data/lib/conductor/version.rb +1 -1
- data/src/_README.md +41 -5
- data/test.md +14 -0
- data/test.sh +4 -7
- metadata +4 -2
data/html/String.html
CHANGED
@@ -75,17 +75,27 @@
|
|
75
75
|
<li ><a href="#method-i-add_comment">#add_comment</a>
|
76
76
|
<li ><a href="#method-i-add_mmd">#add_mmd</a>
|
77
77
|
<li ><a href="#method-i-add_yaml">#add_yaml</a>
|
78
|
+
<li ><a href="#method-i-append">#append</a>
|
78
79
|
<li ><a href="#method-i-bool-3F">#bool?</a>
|
79
80
|
<li ><a href="#method-i-bool_to_symbol">#bool_to_symbol</a>
|
80
81
|
<li ><a href="#method-i-date-3F">#date?</a>
|
81
82
|
<li ><a href="#method-i-delete_meta">#delete_meta</a>
|
82
83
|
<li ><a href="#method-i-delete_mmd">#delete_mmd</a>
|
83
84
|
<li ><a href="#method-i-delete_yaml">#delete_yaml</a>
|
85
|
+
<li ><a href="#method-i-first_h1">#first_h1</a>
|
86
|
+
<li ><a href="#method-i-first_h2">#first_h2</a>
|
87
|
+
<li ><a href="#method-i-get_title">#get_title</a>
|
84
88
|
<li ><a href="#method-i-has_comment-3F">#has_comment?</a>
|
89
|
+
<li ><a href="#method-i-insert_file">#insert_file</a>
|
90
|
+
<li ><a href="#method-i-insert_script">#insert_script</a>
|
91
|
+
<li ><a href="#method-i-insert_title">#insert_title</a>
|
92
|
+
<li ><a href="#method-i-insert_toc">#insert_toc</a>
|
85
93
|
<li ><a href="#method-i-meta-3F">#meta?</a>
|
86
94
|
<li ><a href="#method-i-meta_insert_point">#meta_insert_point</a>
|
87
95
|
<li ><a href="#method-i-meta_type">#meta_type</a>
|
88
96
|
<li ><a href="#method-i-normalize_filter">#normalize_filter</a>
|
97
|
+
<li ><a href="#method-i-normalize_include_type">#normalize_include_type</a>
|
98
|
+
<li ><a href="#method-i-normalize_position">#normalize_position</a>
|
89
99
|
<li ><a href="#method-i-number-3F">#number?</a>
|
90
100
|
<li ><a href="#method-i-replace">#replace</a>
|
91
101
|
<li ><a href="#method-i-replace_all">#replace_all</a>
|
@@ -93,6 +103,8 @@
|
|
93
103
|
<li ><a href="#method-i-strip_meta">#strip_meta</a>
|
94
104
|
<li ><a href="#method-i-strip_time">#strip_time</a>
|
95
105
|
<li ><a href="#method-i-time-3F">#time?</a>
|
106
|
+
<li ><a href="#method-i-title_from_slug">#title_from_slug</a>
|
107
|
+
<li ><a href="#method-i-titleize">#titleize</a>
|
96
108
|
<li ><a href="#method-i-to_bool">#to_bool</a>
|
97
109
|
<li ><a href="#method-i-to_bool-21">#to_bool!</a>
|
98
110
|
<li ><a href="#method-i-to_date">#to_date</a>
|
@@ -143,7 +155,7 @@
|
|
143
155
|
|
144
156
|
|
145
157
|
<div class="method-source-code" id="add_comment-source">
|
146
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
158
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 231</span>
|
147
159
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_comment</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
|
148
160
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">has_comment?</span>(<span class="ruby-identifier">key</span>)
|
149
161
|
<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/ *#{key}: .*?$/</span>, <span class="ruby-node">"#{key}: #{value}"</span>)
|
@@ -172,7 +184,7 @@
|
|
172
184
|
|
173
185
|
|
174
186
|
<div class="method-source-code" id="add_mmd-source">
|
175
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
187
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 213</span>
|
176
188
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_mmd</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
|
177
189
|
<span class="ruby-keyword">if</span> <span class="ruby-identifier">match</span>(<span class="ruby-regexp">/(\A|\n) *#{key}: *\S+/i</span>)
|
178
190
|
<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^ *#{key}:.*?\n/i</span>, <span class="ruby-node">"#{key}: #{value}\n"</span>)
|
@@ -201,7 +213,7 @@
|
|
201
213
|
|
202
214
|
|
203
215
|
<div class="method-source-code" id="add_yaml-source">
|
204
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
216
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 195</span>
|
205
217
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_yaml</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
|
206
218
|
<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^---.*?\n(---|\.\.\.)/m</span>) <span class="ruby-keyword">do</span>
|
207
219
|
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
@@ -214,6 +226,29 @@
|
|
214
226
|
</div>
|
215
227
|
|
216
228
|
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<div id="method-i-append" class="method-detail ">
|
232
|
+
<div class="method-header">
|
233
|
+
<div class="method-heading">
|
234
|
+
<span class="method-name">append</span><span
|
235
|
+
class="method-args">(string)</span>
|
236
|
+
<span class="method-click-advice">click to toggle source</span>
|
237
|
+
</div>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
<div class="method-description">
|
241
|
+
|
242
|
+
|
243
|
+
<div class="method-source-code" id="append-source">
|
244
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 117</span>
|
245
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">append</span>(<span class="ruby-identifier">string</span>)
|
246
|
+
<span class="ruby-node">"#{self}\n#{string}"</span>
|
247
|
+
<span class="ruby-keyword">end</span></pre>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
217
252
|
</div>
|
218
253
|
|
219
254
|
<div id="method-i-bool-3F" class="method-detail ">
|
@@ -231,7 +266,7 @@
|
|
231
266
|
<p>@return [Boolean] test result</p>
|
232
267
|
|
233
268
|
<div class="method-source-code" id="bool-3F-source">
|
234
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
269
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 108</span>
|
235
270
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bool?</span>
|
236
271
|
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">"utf-8"</span>).<span class="ruby-identifier">match?</span>(<span class="ruby-regexp">/^(?:y(?:es)?|no?|t(?:rue)?|f(?:alse)?)$/</span>)
|
237
272
|
<span class="ruby-keyword">end</span></pre>
|
@@ -256,7 +291,7 @@
|
|
256
291
|
<p>@return [Symbol] symbolized version</p>
|
257
292
|
|
258
293
|
<div class="method-source-code" id="bool_to_symbol-source">
|
259
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
294
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 41</span>
|
260
295
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bool_to_symbol</span>
|
261
296
|
<span class="ruby-keyword">case</span> <span class="ruby-keyword">self</span>
|
262
297
|
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/(NOT|!!)/</span>
|
@@ -288,7 +323,7 @@
|
|
288
323
|
<p>@return [Boolean] test result</p>
|
289
324
|
|
290
325
|
<div class="method-source-code" id="date-3F-source">
|
291
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
326
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 57</span>
|
292
327
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">date?</span>
|
293
328
|
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">"utf-8"</span>).<span class="ruby-identifier">match?</span>(<span class="ruby-regexp">/^\d{4}-\d{2}-\d{2}( \d\d:\d\d)?$/</span>)
|
294
329
|
<span class="ruby-keyword">end</span></pre>
|
@@ -311,7 +346,7 @@
|
|
311
346
|
|
312
347
|
|
313
348
|
<div class="method-source-code" id="delete_meta-source">
|
314
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
349
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 241</span>
|
315
350
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_meta</span>(<span class="ruby-identifier">key</span>)
|
316
351
|
<span class="ruby-keyword">case</span> <span class="ruby-identifier">meta_type</span>
|
317
352
|
<span class="ruby-keyword">when</span> <span class="ruby-value">:yaml</span>
|
@@ -339,7 +374,7 @@
|
|
339
374
|
|
340
375
|
|
341
376
|
<div class="method-source-code" id="delete_mmd-source">
|
342
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
377
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 223</span>
|
343
378
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_mmd</span>(<span class="ruby-identifier">key</span>)
|
344
379
|
<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^ *#{key}:.*?\n/i</span>, <span class="ruby-string">""</span>)
|
345
380
|
<span class="ruby-keyword">end</span></pre>
|
@@ -362,7 +397,7 @@
|
|
362
397
|
|
363
398
|
|
364
399
|
<div class="method-source-code" id="delete_yaml-source">
|
365
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
400
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 204</span>
|
366
401
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_yaml</span>(<span class="ruby-identifier">key</span>)
|
367
402
|
<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/^---.*?\n(---|\.\.\.)/m</span>) <span class="ruby-keyword">do</span>
|
368
403
|
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
@@ -375,6 +410,110 @@
|
|
375
410
|
</div>
|
376
411
|
|
377
412
|
|
413
|
+
</div>
|
414
|
+
|
415
|
+
<div id="method-i-first_h1" class="method-detail ">
|
416
|
+
<div class="method-header">
|
417
|
+
<div class="method-heading">
|
418
|
+
<span class="method-name">first_h1</span><span
|
419
|
+
class="method-args">()</span>
|
420
|
+
<span class="method-click-advice">click to toggle source</span>
|
421
|
+
</div>
|
422
|
+
</div>
|
423
|
+
|
424
|
+
<div class="method-description">
|
425
|
+
|
426
|
+
|
427
|
+
<div class="method-source-code" id="first_h1-source">
|
428
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 50</span>
|
429
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">first_h1</span>
|
430
|
+
<span class="ruby-identifier">first</span> = <span class="ruby-value">0</span>
|
431
|
+
<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n/</span>).<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">idx</span><span class="ruby-operator">|</span>
|
432
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(# *\S|={2,} *$)/</span>
|
433
|
+
<span class="ruby-identifier">first</span> = <span class="ruby-identifier">idx</span>
|
434
|
+
<span class="ruby-keyword">break</span>
|
435
|
+
<span class="ruby-keyword">end</span>
|
436
|
+
<span class="ruby-keyword">end</span>
|
437
|
+
<span class="ruby-identifier">first</span>
|
438
|
+
<span class="ruby-keyword">end</span></pre>
|
439
|
+
</div>
|
440
|
+
</div>
|
441
|
+
|
442
|
+
|
443
|
+
</div>
|
444
|
+
|
445
|
+
<div id="method-i-first_h2" class="method-detail ">
|
446
|
+
<div class="method-header">
|
447
|
+
<div class="method-heading">
|
448
|
+
<span class="method-name">first_h2</span><span
|
449
|
+
class="method-args">()</span>
|
450
|
+
<span class="method-click-advice">click to toggle source</span>
|
451
|
+
</div>
|
452
|
+
</div>
|
453
|
+
|
454
|
+
<div class="method-description">
|
455
|
+
|
456
|
+
|
457
|
+
<div class="method-source-code" id="first_h2-source">
|
458
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 61</span>
|
459
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">first_h2</span>
|
460
|
+
<span class="ruby-identifier">first</span> = <span class="ruby-value">0</span>
|
461
|
+
<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n/</span>).<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">idx</span><span class="ruby-operator">|</span>
|
462
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(## *\S|-{2,} *$)/</span>
|
463
|
+
<span class="ruby-identifier">first</span> = <span class="ruby-identifier">idx</span>
|
464
|
+
<span class="ruby-keyword">break</span>
|
465
|
+
<span class="ruby-keyword">end</span>
|
466
|
+
<span class="ruby-keyword">end</span>
|
467
|
+
<span class="ruby-identifier">first</span>
|
468
|
+
<span class="ruby-keyword">end</span></pre>
|
469
|
+
</div>
|
470
|
+
</div>
|
471
|
+
|
472
|
+
|
473
|
+
</div>
|
474
|
+
|
475
|
+
<div id="method-i-get_title" class="method-detail ">
|
476
|
+
<div class="method-header">
|
477
|
+
<div class="method-heading">
|
478
|
+
<span class="method-name">get_title</span><span
|
479
|
+
class="method-args">()</span>
|
480
|
+
<span class="method-click-advice">click to toggle source</span>
|
481
|
+
</div>
|
482
|
+
</div>
|
483
|
+
|
484
|
+
<div class="method-description">
|
485
|
+
|
486
|
+
|
487
|
+
<div class="method-source-code" id="get_title-source">
|
488
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 150</span>
|
489
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_title</span>
|
490
|
+
<span class="ruby-identifier">title</span> = <span class="ruby-keyword">nil</span>
|
491
|
+
|
492
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">meta_type</span>
|
493
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:yaml</span>
|
494
|
+
<span class="ruby-identifier">m</span> = <span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^---.*?\n(---|\.\.\.)/m</span>)
|
495
|
+
<span class="ruby-identifier">yaml</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>])
|
496
|
+
<span class="ruby-identifier">title</span> = <span class="ruby-identifier">yaml</span>[<span class="ruby-string">"title"</span>]
|
497
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:mmd</span>
|
498
|
+
<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
499
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^ *title: *(\S.*?)$/i</span>
|
500
|
+
<span class="ruby-identifier">title</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>(<span class="ruby-value">1</span>)
|
501
|
+
<span class="ruby-keyword">break</span>
|
502
|
+
<span class="ruby-keyword">end</span>
|
503
|
+
<span class="ruby-keyword">end</span>
|
504
|
+
<span class="ruby-keyword">else</span>
|
505
|
+
<span class="ruby-identifier">m</span> = <span class="ruby-identifier">match</span>(<span class="ruby-regexp">/title: (.*?)$/i</span>)
|
506
|
+
<span class="ruby-identifier">title</span> = <span class="ruby-identifier">m</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
|
507
|
+
<span class="ruby-keyword">end</span>
|
508
|
+
|
509
|
+
<span class="ruby-identifier">title</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">title_from_slug</span>.<span class="ruby-identifier">titleize</span>
|
510
|
+
|
511
|
+
<span class="ruby-identifier">title</span>
|
512
|
+
<span class="ruby-keyword">end</span></pre>
|
513
|
+
</div>
|
514
|
+
</div>
|
515
|
+
|
516
|
+
|
378
517
|
</div>
|
379
518
|
|
380
519
|
<div id="method-i-has_comment-3F" class="method-detail ">
|
@@ -390,7 +529,7 @@
|
|
390
529
|
|
391
530
|
|
392
531
|
<div class="method-source-code" id="has_comment-3F-source">
|
393
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
532
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 227</span>
|
394
533
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">has_comment?</span>(<span class="ruby-identifier">key</span>)
|
395
534
|
<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^<!--.*?#{key}: \S.*?-->/m</span>)
|
396
535
|
<span class="ruby-keyword">end</span></pre>
|
@@ -398,6 +537,157 @@
|
|
398
537
|
</div>
|
399
538
|
|
400
539
|
|
540
|
+
</div>
|
541
|
+
|
542
|
+
<div id="method-i-insert_file" class="method-detail ">
|
543
|
+
<div class="method-header">
|
544
|
+
<div class="method-heading">
|
545
|
+
<span class="method-name">insert_file</span><span
|
546
|
+
class="method-args">(path, type = :file, position = :end)</span>
|
547
|
+
<span class="method-click-advice">click to toggle source</span>
|
548
|
+
</div>
|
549
|
+
</div>
|
550
|
+
|
551
|
+
<div class="method-description">
|
552
|
+
|
553
|
+
|
554
|
+
<div class="method-source-code" id="insert_file-source">
|
555
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 87</span>
|
556
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">insert_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">type</span> = <span class="ruby-value">:file</span>, <span class="ruby-identifier">position</span> = <span class="ruby-value">:end</span>)
|
557
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">strip!</span>
|
558
|
+
|
559
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r{^[~/]}</span>
|
560
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
|
561
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">"~/.config/conductor/files"</span>))
|
562
|
+
<span class="ruby-identifier">new_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-node">"~/.config/conductor/files/#{path}"</span>)
|
563
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-identifier">new_path</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">new_path</span>)
|
564
|
+
<span class="ruby-keyword">end</span>
|
565
|
+
|
566
|
+
<span class="ruby-identifier">out</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
|
567
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:code</span>
|
568
|
+
<span class="ruby-node">"<<(#{path})"</span>
|
569
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:raw</span>
|
570
|
+
<span class="ruby-node">"<<{#{path}}"</span>
|
571
|
+
<span class="ruby-keyword">else</span>
|
572
|
+
<span class="ruby-node">"<<[#{path}]"</span>
|
573
|
+
<span class="ruby-keyword">end</span>
|
574
|
+
<span class="ruby-identifier">out</span> = <span class="ruby-node">"\n#{out}\n"</span>
|
575
|
+
|
576
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">position</span>
|
577
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:start</span>
|
578
|
+
<span class="ruby-node">"#{out}\n#{self}"</span>
|
579
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:h1</span>
|
580
|
+
<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n/</span>).<span class="ruby-identifier">insert</span>(<span class="ruby-identifier">first_h1</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">out</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">"\n"</span>)
|
581
|
+
<span class="ruby-keyword">else</span>
|
582
|
+
<span class="ruby-node">"#{self}\n#{out}"</span>
|
583
|
+
<span class="ruby-keyword">end</span>
|
584
|
+
<span class="ruby-keyword">end</span></pre>
|
585
|
+
</div>
|
586
|
+
</div>
|
587
|
+
|
588
|
+
|
589
|
+
</div>
|
590
|
+
|
591
|
+
<div id="method-i-insert_script" class="method-detail ">
|
592
|
+
<div class="method-header">
|
593
|
+
<div class="method-heading">
|
594
|
+
<span class="method-name">insert_script</span><span
|
595
|
+
class="method-args">(path)</span>
|
596
|
+
<span class="method-click-advice">click to toggle source</span>
|
597
|
+
</div>
|
598
|
+
</div>
|
599
|
+
|
600
|
+
<div class="method-description">
|
601
|
+
|
602
|
+
|
603
|
+
<div class="method-source-code" id="insert_script-source">
|
604
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 121</span>
|
605
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">insert_script</span>(<span class="ruby-identifier">path</span>)
|
606
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">strip!</span>
|
607
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-node">"#{path}.js"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\.js$/</span>
|
608
|
+
|
609
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r{^[~/]}</span>
|
610
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
|
611
|
+
<span class="ruby-keyword">else</span>
|
612
|
+
<span class="ruby-identifier">new_path</span> = <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">"~/.config/conductor/javascript"</span>))
|
613
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-node">"~/.config/conductor/javascript/#{path}"</span>)
|
614
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">"~/.config/conductor/javascripts"</span>))
|
615
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-node">"~/.config/conductor/javascripts/#{path}"</span>)
|
616
|
+
<span class="ruby-keyword">else</span>
|
617
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-node">"~/.config/conductor/scripts/#{path}"</span>)
|
618
|
+
<span class="ruby-keyword">end</span>
|
619
|
+
|
620
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-identifier">new_path</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">new_path</span>)
|
621
|
+
<span class="ruby-keyword">end</span>
|
622
|
+
|
623
|
+
<span class="ruby-node">%(#{self}\n<script type="javascript" src="#{path}"></script>\n)</span>
|
624
|
+
<span class="ruby-keyword">end</span></pre>
|
625
|
+
</div>
|
626
|
+
</div>
|
627
|
+
|
628
|
+
|
629
|
+
</div>
|
630
|
+
|
631
|
+
<div id="method-i-insert_title" class="method-detail ">
|
632
|
+
<div class="method-header">
|
633
|
+
<div class="method-heading">
|
634
|
+
<span class="method-name">insert_title</span><span
|
635
|
+
class="method-args">()</span>
|
636
|
+
<span class="method-click-advice">click to toggle source</span>
|
637
|
+
</div>
|
638
|
+
</div>
|
639
|
+
|
640
|
+
<div class="method-description">
|
641
|
+
|
642
|
+
|
643
|
+
<div class="method-source-code" id="insert_title-source">
|
644
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 175</span>
|
645
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">insert_title</span>
|
646
|
+
<span class="ruby-identifier">title</span> = <span class="ruby-identifier">get_title</span>
|
647
|
+
<span class="ruby-identifier">lines</span> = <span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n/</span>)
|
648
|
+
<span class="ruby-identifier">insert_point</span> = <span class="ruby-identifier">meta_insert_point</span>
|
649
|
+
<span class="ruby-identifier">insert_at</span> = <span class="ruby-identifier">insert_point</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">insert_point</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
|
650
|
+
<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-identifier">insert_at</span>, <span class="ruby-node">"# #{title}\n"</span>)
|
651
|
+
<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">"\n"</span>)
|
652
|
+
<span class="ruby-keyword">end</span></pre>
|
653
|
+
</div>
|
654
|
+
</div>
|
655
|
+
|
656
|
+
|
657
|
+
</div>
|
658
|
+
|
659
|
+
<div id="method-i-insert_toc" class="method-detail ">
|
660
|
+
<div class="method-header">
|
661
|
+
<div class="method-heading">
|
662
|
+
<span class="method-name">insert_toc</span><span
|
663
|
+
class="method-args">(max = nil, after = :h1)</span>
|
664
|
+
<span class="method-click-advice">click to toggle source</span>
|
665
|
+
</div>
|
666
|
+
</div>
|
667
|
+
|
668
|
+
<div class="method-description">
|
669
|
+
|
670
|
+
|
671
|
+
<div class="method-source-code" id="insert_toc-source">
|
672
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 72</span>
|
673
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">insert_toc</span>(<span class="ruby-identifier">max</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">after</span> = <span class="ruby-value">:h1</span>)
|
674
|
+
<span class="ruby-identifier">lines</span> = <span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n/</span>)
|
675
|
+
<span class="ruby-identifier">max</span> = <span class="ruby-identifier">max</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span>.<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-node">" max#{max}"</span> <span class="ruby-operator">:</span> <span class="ruby-string">""</span>
|
676
|
+
<span class="ruby-identifier">line</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">after</span>.<span class="ruby-identifier">to_sym</span>
|
677
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:h2</span>
|
678
|
+
<span class="ruby-identifier">first_h2</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">first_h2</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
|
679
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:h1</span>
|
680
|
+
<span class="ruby-identifier">first_h1</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">first_h1</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
|
681
|
+
<span class="ruby-keyword">else</span>
|
682
|
+
<span class="ruby-value">0</span>
|
683
|
+
<span class="ruby-keyword">end</span>
|
684
|
+
|
685
|
+
<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-identifier">line</span>, <span class="ruby-node">"\n<!--toc#{max}-->\n"</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">"\n"</span>)
|
686
|
+
<span class="ruby-keyword">end</span></pre>
|
687
|
+
</div>
|
688
|
+
</div>
|
689
|
+
|
690
|
+
|
401
691
|
</div>
|
402
692
|
|
403
693
|
<div id="method-i-meta-3F" class="method-detail ">
|
@@ -415,7 +705,7 @@
|
|
415
705
|
<p>@return [Boolean] test result</p>
|
416
706
|
|
417
707
|
<div class="method-source-code" id="meta-3F-source">
|
418
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
708
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 126</span>
|
419
709
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meta?</span>
|
420
710
|
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">'utf-8'</span>).<span class="ruby-identifier">match?</span>(<span class="ruby-regexp">/^\w+: +\S+/m</span>)
|
421
711
|
<span class="ruby-keyword">end</span></pre>
|
@@ -525,6 +815,66 @@
|
|
525
815
|
</div>
|
526
816
|
|
527
817
|
|
818
|
+
</div>
|
819
|
+
|
820
|
+
<div id="method-i-normalize_include_type" class="method-detail ">
|
821
|
+
<div class="method-header">
|
822
|
+
<div class="method-heading">
|
823
|
+
<span class="method-name">normalize_include_type</span><span
|
824
|
+
class="method-args">()</span>
|
825
|
+
<span class="method-click-advice">click to toggle source</span>
|
826
|
+
</div>
|
827
|
+
</div>
|
828
|
+
|
829
|
+
<div class="method-description">
|
830
|
+
|
831
|
+
|
832
|
+
<div class="method-source-code" id="normalize_include_type-source">
|
833
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 25</span>
|
834
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize_include_type</span>
|
835
|
+
<span class="ruby-keyword">case</span> <span class="ruby-keyword">self</span>
|
836
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^c/</span>
|
837
|
+
<span class="ruby-value">:code</span>
|
838
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^r/</span>
|
839
|
+
<span class="ruby-value">:raw</span>
|
840
|
+
<span class="ruby-keyword">else</span>
|
841
|
+
<span class="ruby-value">:file</span>
|
842
|
+
<span class="ruby-keyword">end</span>
|
843
|
+
<span class="ruby-keyword">end</span></pre>
|
844
|
+
</div>
|
845
|
+
</div>
|
846
|
+
|
847
|
+
|
848
|
+
</div>
|
849
|
+
|
850
|
+
<div id="method-i-normalize_position" class="method-detail ">
|
851
|
+
<div class="method-header">
|
852
|
+
<div class="method-heading">
|
853
|
+
<span class="method-name">normalize_position</span><span
|
854
|
+
class="method-args">()</span>
|
855
|
+
<span class="method-click-advice">click to toggle source</span>
|
856
|
+
</div>
|
857
|
+
</div>
|
858
|
+
|
859
|
+
<div class="method-description">
|
860
|
+
|
861
|
+
|
862
|
+
<div class="method-source-code" id="normalize_position-source">
|
863
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 14</span>
|
864
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize_position</span>
|
865
|
+
<span class="ruby-keyword">case</span> <span class="ruby-keyword">self</span>
|
866
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^(be|s|t)/</span>
|
867
|
+
<span class="ruby-value">:start</span>
|
868
|
+
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/h1/</span>
|
869
|
+
<span class="ruby-value">:h1</span>
|
870
|
+
<span class="ruby-keyword">else</span>
|
871
|
+
<span class="ruby-value">:end</span>
|
872
|
+
<span class="ruby-keyword">end</span>
|
873
|
+
<span class="ruby-keyword">end</span></pre>
|
874
|
+
</div>
|
875
|
+
</div>
|
876
|
+
|
877
|
+
|
528
878
|
</div>
|
529
879
|
|
530
880
|
<div id="method-i-number-3F" class="method-detail ">
|
@@ -542,7 +892,7 @@
|
|
542
892
|
<p>@return [Boolean] test result</p>
|
543
893
|
|
544
894
|
<div class="method-source-code" id="number-3F-source">
|
545
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
895
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 99</span>
|
546
896
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">number?</span>
|
547
897
|
<span class="ruby-identifier">to_f</span>.<span class="ruby-identifier">positive?</span>
|
548
898
|
<span class="ruby-keyword">end</span></pre>
|
@@ -565,7 +915,7 @@
|
|
565
915
|
|
566
916
|
|
567
917
|
<div class="method-source-code" id="replace-source">
|
568
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
918
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 264</span>
|
569
919
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">replace</span>(<span class="ruby-identifier">regex</span>, <span class="ruby-identifier">pattern</span>)
|
570
920
|
<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">regex</span>.<span class="ruby-identifier">to_rx</span>, <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">to_pattern</span>)
|
571
921
|
<span class="ruby-keyword">end</span></pre>
|
@@ -588,7 +938,7 @@
|
|
588
938
|
|
589
939
|
|
590
940
|
<div class="method-source-code" id="replace_all-source">
|
591
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
941
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 260</span>
|
592
942
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">replace_all</span>(<span class="ruby-identifier">regex</span>, <span class="ruby-identifier">pattern</span>)
|
593
943
|
<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">regex</span>.<span class="ruby-identifier">to_rx</span>, <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">to_pattern</span>)
|
594
944
|
<span class="ruby-keyword">end</span></pre>
|
@@ -611,7 +961,7 @@
|
|
611
961
|
|
612
962
|
|
613
963
|
<div class="method-source-code" id="set_meta-source">
|
614
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
964
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 184</span>
|
615
965
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_meta</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-value">style:</span> <span class="ruby-value">:comment</span>)
|
616
966
|
<span class="ruby-keyword">case</span> <span class="ruby-identifier">style</span>
|
617
967
|
<span class="ruby-keyword">when</span> <span class="ruby-value">:yaml</span>
|
@@ -641,7 +991,7 @@
|
|
641
991
|
|
642
992
|
|
643
993
|
<div class="method-source-code" id="strip_meta-source">
|
644
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
994
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 250</span>
|
645
995
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">strip_meta</span>
|
646
996
|
<span class="ruby-keyword">case</span> <span class="ruby-identifier">meta_type</span>
|
647
997
|
<span class="ruby-keyword">when</span> <span class="ruby-value">:yaml</span>
|
@@ -672,7 +1022,7 @@
|
|
672
1022
|
<p>@return [String] string with time removed</p>
|
673
1023
|
|
674
1024
|
<div class="method-source-code" id="strip_time-source">
|
675
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
1025
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 85</span>
|
676
1026
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">strip_time</span>
|
677
1027
|
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">"utf-8"</span>).<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/ \d{1,2}(:\d\d)? *([ap]m)?/i</span>, <span class="ruby-string">""</span>)
|
678
1028
|
<span class="ruby-keyword">end</span></pre>
|
@@ -697,7 +1047,7 @@
|
|
697
1047
|
<p>@return [Boolean] test result</p>
|
698
1048
|
|
699
1049
|
<div class="method-source-code" id="time-3F-source">
|
700
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
1050
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 66</span>
|
701
1051
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">time?</span>
|
702
1052
|
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">"utf-8"</span>).<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/ \d{1,2}(:\d\d)? *([ap]m)?/i</span>)
|
703
1053
|
<span class="ruby-keyword">end</span></pre>
|
@@ -705,6 +1055,58 @@
|
|
705
1055
|
</div>
|
706
1056
|
|
707
1057
|
|
1058
|
+
</div>
|
1059
|
+
|
1060
|
+
<div id="method-i-title_from_slug" class="method-detail ">
|
1061
|
+
<div class="method-header">
|
1062
|
+
<div class="method-heading">
|
1063
|
+
<span class="method-name">title_from_slug</span><span
|
1064
|
+
class="method-args">()</span>
|
1065
|
+
<span class="method-click-advice">click to toggle source</span>
|
1066
|
+
</div>
|
1067
|
+
</div>
|
1068
|
+
|
1069
|
+
<div class="method-description">
|
1070
|
+
|
1071
|
+
|
1072
|
+
<div class="method-source-code" id="title_from_slug-source">
|
1073
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 142</span>
|
1074
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">title_from_slug</span>
|
1075
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-constant">Conductor</span><span class="ruby-operator">::</span><span class="ruby-constant">Env</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value">:filepath</span>]).<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/\.[a-z]+$/i</span>, <span class="ruby-string">""</span>)
|
1076
|
+
<span class="ruby-identifier">filename</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/-?\d{4}-\d{2}-\d{2}-?/</span>, <span class="ruby-string">""</span>)
|
1077
|
+
<span class="ruby-identifier">filename</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/\bdot\b/</span>, <span class="ruby-string">"."</span>)
|
1078
|
+
<span class="ruby-identifier">filename</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/ dash /</span>, <span class="ruby-string">"-"</span>)
|
1079
|
+
<span class="ruby-identifier">filename</span>
|
1080
|
+
<span class="ruby-keyword">end</span></pre>
|
1081
|
+
</div>
|
1082
|
+
</div>
|
1083
|
+
|
1084
|
+
|
1085
|
+
</div>
|
1086
|
+
|
1087
|
+
<div id="method-i-titleize" class="method-detail ">
|
1088
|
+
<div class="method-header">
|
1089
|
+
<div class="method-heading">
|
1090
|
+
<span class="method-name">titleize</span><span
|
1091
|
+
class="method-args">()</span>
|
1092
|
+
<span class="method-click-advice">click to toggle source</span>
|
1093
|
+
</div>
|
1094
|
+
</div>
|
1095
|
+
|
1096
|
+
<div class="method-description">
|
1097
|
+
<p>Titlecase a string</p>
|
1098
|
+
|
1099
|
+
<p>@return Titleized string</p>
|
1100
|
+
|
1101
|
+
<div class="method-source-code" id="titleize-source">
|
1102
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 10</span>
|
1103
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">titleize</span>
|
1104
|
+
<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/(\W)/</span>).<span class="ruby-identifier">map</span>(<span class="ruby-operator">&</span><span class="ruby-value">:capitalize</span>).<span class="ruby-identifier">join</span>
|
1105
|
+
<span class="ruby-keyword">end</span></pre>
|
1106
|
+
</div>
|
1107
|
+
</div>
|
1108
|
+
|
1109
|
+
|
708
1110
|
</div>
|
709
1111
|
|
710
1112
|
<div id="method-i-to_bool" class="method-detail ">
|
@@ -722,7 +1124,7 @@
|
|
722
1124
|
<p>@return [Boolean] Bool representation of the object.</p>
|
723
1125
|
|
724
1126
|
<div class="method-source-code" id="to_bool-source">
|
725
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
1127
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 145</span>
|
726
1128
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_bool</span>
|
727
1129
|
<span class="ruby-keyword">case</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">'utf-8'</span>)
|
728
1130
|
<span class="ruby-keyword">when</span> <span class="ruby-regexp">/^[yt]/i</span>
|
@@ -752,7 +1154,7 @@
|
|
752
1154
|
<p>@see <a href="String.html#method-i-to_bool"><code>to_bool</code></a></p>
|
753
1155
|
|
754
1156
|
<div class="method-source-code" id="to_bool-21-source">
|
755
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
1157
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 136</span>
|
756
1158
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_bool!</span>
|
757
1159
|
<span class="ruby-identifier">replace</span> <span class="ruby-identifier">to_bool</span>
|
758
1160
|
<span class="ruby-keyword">end</span></pre>
|
@@ -780,7 +1182,7 @@
|
|
780
1182
|
<p>@return [Date] Resulting Date object</p>
|
781
1183
|
|
782
1184
|
<div class="method-source-code" id="to_date-source">
|
783
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
1185
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 76</span>
|
784
1186
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_date</span>
|
785
1187
|
<span class="ruby-constant">Chronic</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">"utf-8"</span>))
|
786
1188
|
<span class="ruby-keyword">end</span></pre>
|
@@ -803,7 +1205,7 @@
|
|
803
1205
|
|
804
1206
|
|
805
1207
|
<div class="method-source-code" id="to_day-source">
|
806
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
1208
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 89</span>
|
807
1209
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_day</span>(<span class="ruby-identifier">time</span> = <span class="ruby-value">:end</span>)
|
808
1210
|
<span class="ruby-identifier">t</span> = <span class="ruby-identifier">time</span> <span class="ruby-operator">==</span> <span class="ruby-value">:end</span> <span class="ruby-operator">?</span> <span class="ruby-string">"23:59"</span> <span class="ruby-operator">:</span> <span class="ruby-string">"00:00"</span>
|
809
1211
|
<span class="ruby-constant">Chronic</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">"#{strip_time} #{t}"</span>)
|
@@ -827,9 +1229,9 @@
|
|
827
1229
|
|
828
1230
|
|
829
1231
|
<div class="method-source-code" id="to_pattern-source">
|
830
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
1232
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 279</span>
|
831
1233
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_pattern</span>
|
832
|
-
<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\$(\d+)/</span>, <span class="ruby-string">'\\\\\1'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(^["']|["']$)/</span>, <span class="ruby-string"
|
1234
|
+
<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\$(\d+)/</span>, <span class="ruby-string">'\\\\\1'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(^["']|["']$)/</span>, <span class="ruby-string">""</span>)
|
833
1235
|
<span class="ruby-keyword">end</span></pre>
|
834
1236
|
</div>
|
835
1237
|
</div>
|
@@ -850,7 +1252,7 @@
|
|
850
1252
|
|
851
1253
|
|
852
1254
|
<div class="method-source-code" id="to_rx-source">
|
853
|
-
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line
|
1255
|
+
<pre><span class="ruby-comment"># File lib/conductor/filter.rb, line 268</span>
|
854
1256
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_rx</span>
|
855
1257
|
<span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r{^/(.*?)/([im]+)?$}</span>
|
856
1258
|
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
@@ -882,7 +1284,7 @@
|
|
882
1284
|
<p>@return [Boolean] test result</p>
|
883
1285
|
|
884
1286
|
<div class="method-source-code" id="yaml-3F-source">
|
885
|
-
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line
|
1287
|
+
<pre><span class="ruby-comment"># File lib/conductor/string.rb, line 117</span>
|
886
1288
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">yaml?</span>
|
887
1289
|
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">'utf-8'</span>).<span class="ruby-identifier">match?</span>(<span class="ruby-regexp">/^---/m</span>)
|
888
1290
|
<span class="ruby-keyword">end</span></pre>
|