marked-conductor 1.0.17 → 1.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +2 -0
  4. data/lib/conductor/config.rb +24 -24
  5. data/lib/conductor/filter.rb +49 -23
  6. data/lib/conductor/version.rb +1 -1
  7. data/src/_README.md +2 -0
  8. metadata +1 -62
  9. data/html/Array.html +0 -160
  10. data/html/Conductor/Command.html +0 -271
  11. data/html/Conductor/Condition.html +0 -791
  12. data/html/Conductor/Config.html +0 -170
  13. data/html/Conductor/Env.html +0 -220
  14. data/html/Conductor/Script.html +0 -288
  15. data/html/Conductor.html +0 -363
  16. data/html/FalseClass.html +0 -138
  17. data/html/Filter.html +0 -269
  18. data/html/Hash.html +0 -160
  19. data/html/Object.html +0 -138
  20. data/html/README_rdoc.html +0 -86
  21. data/html/String.html +0 -1409
  22. data/html/TrueClass.html +0 -138
  23. data/html/YuiCompressor/Yui.html +0 -447
  24. data/html/YuiCompressor.html +0 -93
  25. data/html/created.rid +0 -16
  26. data/html/css/fonts.css +0 -167
  27. data/html/css/rdoc.css +0 -687
  28. data/html/fonts/Lato-Light.ttf +0 -0
  29. data/html/fonts/Lato-LightItalic.ttf +0 -0
  30. data/html/fonts/Lato-Regular.ttf +0 -0
  31. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  32. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  33. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  34. data/html/images/add.png +0 -0
  35. data/html/images/arrow_up.png +0 -0
  36. data/html/images/brick.png +0 -0
  37. data/html/images/brick_link.png +0 -0
  38. data/html/images/bug.png +0 -0
  39. data/html/images/bullet_black.png +0 -0
  40. data/html/images/bullet_toggle_minus.png +0 -0
  41. data/html/images/bullet_toggle_plus.png +0 -0
  42. data/html/images/date.png +0 -0
  43. data/html/images/delete.png +0 -0
  44. data/html/images/find.png +0 -0
  45. data/html/images/loadingAnimation.gif +0 -0
  46. data/html/images/macFFBgHack.png +0 -0
  47. data/html/images/package.png +0 -0
  48. data/html/images/page_green.png +0 -0
  49. data/html/images/page_white_text.png +0 -0
  50. data/html/images/page_white_width.png +0 -0
  51. data/html/images/plugin.png +0 -0
  52. data/html/images/ruby.png +0 -0
  53. data/html/images/tag_blue.png +0 -0
  54. data/html/images/tag_green.png +0 -0
  55. data/html/images/transparent.png +0 -0
  56. data/html/images/wrench.png +0 -0
  57. data/html/images/wrench_orange.png +0 -0
  58. data/html/images/zoom.png +0 -0
  59. data/html/index.html +0 -110
  60. data/html/js/darkfish.js +0 -97
  61. data/html/js/navigation.js +0 -105
  62. data/html/js/navigation.js.gz +0 -0
  63. data/html/js/search.js +0 -110
  64. data/html/js/search_index.js +0 -1
  65. data/html/js/search_index.js.gz +0 -0
  66. data/html/js/searcher.js +0 -229
  67. data/html/js/searcher.js.gz +0 -0
  68. data/html/table_of_contents.html +0 -539
  69. data/test.md +0 -14
@@ -1,791 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class Conductor::Condition - Marked Conductor</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "../";
11
- var index_rel_prefix = "../";
12
- </script>
13
-
14
- <script src="../js/navigation.js" defer></script>
15
- <script src="../js/search.js" defer></script>
16
- <script src="../js/search_index.js" defer></script>
17
- <script src="../js/searcher.js" defer></script>
18
- <script src="../js/darkfish.js" defer></script>
19
-
20
- <link href="../css/fonts.css" rel="stylesheet">
21
- <link href="../css/rdoc.css" rel="stylesheet">
22
-
23
-
24
- <body id="top" role="document" class="class">
25
- <nav role="navigation">
26
- <div id="project-navigation">
27
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
- <h2>
29
- <a href="../index.html" rel="home">Home</a>
30
- </h2>
31
-
32
- <div id="table-of-contents-navigation">
33
- <a href="../table_of_contents.html#pages">Pages</a>
34
- <a href="../table_of_contents.html#classes">Classes</a>
35
- <a href="../table_of_contents.html#methods">Methods</a>
36
- </div>
37
- </div>
38
-
39
- <div id="search-section" role="search" class="project-section initially-hidden">
40
- <form action="#" method="get" accept-charset="utf-8">
41
- <div id="search-field-wrapper">
42
- <input id="search-field" role="combobox" aria-label="Search"
43
- aria-autocomplete="list" aria-controls="search-results"
44
- type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
45
- title="Type to search, Up and Down to navigate, Enter to load">
46
- </div>
47
-
48
- <ul id="search-results" aria-label="Search Results"
49
- aria-busy="false" aria-expanded="false"
50
- aria-atomic="false" class="initially-hidden"></ul>
51
- </form>
52
- </div>
53
-
54
- </div>
55
-
56
-
57
-
58
- <div id="class-metadata">
59
-
60
-
61
- <div id="parent-class-section" class="nav-section">
62
- <h3>Parent</h3>
63
-
64
- <p class="link"><a href="../Object.html">Object</a>
65
- </div>
66
-
67
-
68
-
69
-
70
- <!-- Method Quickref -->
71
- <div id="method-list-section" class="nav-section">
72
- <h3>Methods</h3>
73
-
74
- <ul class="link-list" role="directory">
75
- <li ><a href="#method-c-new">::new</a>
76
- <li ><a href="#method-i-operator_to_symbol">#operator_to_symbol</a>
77
- <li ><a href="#method-i-parse_condition">#parse_condition</a>
78
- <li ><a href="#method-i-split_booleans">#split_booleans</a>
79
- <li ><a href="#method-i-split_condition">#split_condition</a>
80
- <li ><a href="#method-i-test_condition">#test_condition</a>
81
- <li ><a href="#method-i-test_meta">#test_meta</a>
82
- <li ><a href="#method-i-test_operator">#test_operator</a>
83
- <li ><a href="#method-i-test_pandoc">#test_pandoc</a>
84
- <li ><a href="#method-i-test_string">#test_string</a>
85
- <li ><a href="#method-i-test_tree">#test_tree</a>
86
- <li ><a href="#method-i-test_truthy">#test_truthy</a>
87
- <li ><a href="#method-i-test_type">#test_type</a>
88
- <li ><a href="#method-i-test_yaml">#test_yaml</a>
89
- <li ><a href="#method-i-true-3F">#true?</a>
90
- </ul>
91
- </div>
92
-
93
- </div>
94
- </nav>
95
-
96
- <main role="main" aria-labelledby="class-Conductor::Condition">
97
- <h1 id="class-Conductor::Condition" class="class">
98
- class Conductor::Condition
99
- </h1>
100
-
101
- <section class="description">
102
-
103
- </section>
104
-
105
- <section id="5Buntitled-5D" class="documentation-section">
106
-
107
-
108
-
109
-
110
-
111
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
112
- <header>
113
- <h3>Public Class Methods</h3>
114
- </header>
115
-
116
- <div id="method-c-new" class="method-detail ">
117
- <div class="method-header">
118
- <div class="method-heading">
119
- <span class="method-name">new</span><span
120
- class="method-args">(condition)</span>
121
- <span class="method-click-advice">click to toggle source</span>
122
- </div>
123
- </div>
124
-
125
- <div class="method-description">
126
- <p>Initializes the given condition.</p>
127
-
128
- <p>@param condition The condition</p>
129
-
130
- <div class="method-source-code" id="new-source">
131
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 11</span>
132
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">condition</span>)
133
- <span class="ruby-ivar">@condition</span> = <span class="ruby-identifier">condition</span>
134
- <span class="ruby-ivar">@env</span> = <span class="ruby-constant">Conductor</span><span class="ruby-operator">::</span><span class="ruby-constant">Env</span>.<span class="ruby-identifier">env</span>
135
- <span class="ruby-keyword">end</span></pre>
136
- </div>
137
- </div>
138
-
139
-
140
- </div>
141
-
142
- </section>
143
-
144
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
145
- <header>
146
- <h3>Public Instance Methods</h3>
147
- </header>
148
-
149
- <div id="method-i-operator_to_symbol" class="method-detail ">
150
- <div class="method-header">
151
- <div class="method-heading">
152
- <span class="method-name">operator_to_symbol</span><span
153
- class="method-args">(operator)</span>
154
- <span class="method-click-advice">click to toggle source</span>
155
- </div>
156
- </div>
157
-
158
- <div class="method-description">
159
-
160
-
161
- <div class="method-source-code" id="operator_to_symbol-source">
162
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 381</span>
163
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">operator_to_symbol</span>(<span class="ruby-identifier">operator</span>)
164
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">operator</span>.<span class="ruby-identifier">nil?</span>
165
-
166
- <span class="ruby-keyword">case</span> <span class="ruby-identifier">operator</span>
167
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(gt|greater( than)?|&gt;|(?:is )?after)/i</span>
168
- <span class="ruby-value">:gt</span>
169
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(lt|less( than)?|&lt;|(?:is )?before)/i</span>
170
- <span class="ruby-value">:lt</span>
171
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/not (ha(?:s|ve)|contains|includes|match(es)?)/i</span>
172
- <span class="ruby-value">:not_contains</span>
173
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(ha(?:s|ve)|contains|includes|match(es)?|\*=)/i</span>
174
- <span class="ruby-value">:contains</span>
175
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/not (suffix|ends? with)/i</span>
176
- <span class="ruby-value">:not_ends_with</span>
177
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/not (prefix|(starts?|begins?) with)/i</span>
178
- <span class="ruby-value">:not_starts_with</span>
179
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(suffix|ends with|\$=)/i</span>
180
- <span class="ruby-value">:ends_with</span>
181
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(prefix|(starts?|begins?) with|\^=)/i</span>
182
- <span class="ruby-value">:starts_with</span>
183
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/is not (an?|type( of)?)/i</span>
184
- <span class="ruby-value">:not_type_of</span>
185
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/is (an?|type( of)?)/i</span>
186
- <span class="ruby-value">:type_of</span>
187
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/((?:(?:is|does) )?not(?: equals?)?|!==?)/i</span>
188
- <span class="ruby-value">:not_equal</span>
189
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(is|==?|equals?)/i</span>
190
- <span class="ruby-value">:equal</span>
191
- <span class="ruby-keyword">end</span>
192
- <span class="ruby-keyword">end</span></pre>
193
- </div>
194
- </div>
195
-
196
-
197
- </div>
198
-
199
- <div id="method-i-parse_condition" class="method-detail ">
200
- <div class="method-header">
201
- <div class="method-heading">
202
- <span class="method-name">parse_condition</span><span
203
- class="method-args">()</span>
204
- <span class="method-click-advice">click to toggle source</span>
205
- </div>
206
- </div>
207
-
208
- <div class="method-description">
209
-
210
-
211
- <div class="method-source-code" id="parse_condition-source">
212
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 412</span>
213
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_condition</span>
214
- <span class="ruby-identifier">cond</span> = <span class="ruby-ivar">@condition</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\((.*?)\)/</span>) <span class="ruby-keyword">do</span>
215
- <span class="ruby-identifier">condition</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>(<span class="ruby-value">1</span>)
216
- <span class="ruby-identifier">split_booleans</span>(<span class="ruby-identifier">condition</span>)
217
- <span class="ruby-keyword">end</span>
218
-
219
- <span class="ruby-identifier">split_booleans</span>(<span class="ruby-identifier">cond</span>)
220
- <span class="ruby-keyword">end</span></pre>
221
- </div>
222
- </div>
223
-
224
-
225
- </div>
226
-
227
- <div id="method-i-split_booleans" class="method-detail ">
228
- <div class="method-header">
229
- <div class="method-heading">
230
- <span class="method-name">split_booleans</span><span
231
- class="method-args">(condition)</span>
232
- <span class="method-click-advice">click to toggle source</span>
233
- </div>
234
- </div>
235
-
236
- <div class="method-description">
237
- <p>Splits booleans and tests components.</p>
238
-
239
- <p>@param condition The condition to test</p>
240
-
241
- <p>@return [Boolean] test result</p>
242
-
243
- <div class="method-source-code" id="split_booleans-source">
244
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 32</span>
245
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">split_booleans</span>(<span class="ruby-identifier">condition</span>)
246
- <span class="ruby-identifier">split</span> = <span class="ruby-identifier">condition</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/ ((?:AND )?NOT|AND|OR) /</span>)
247
-
248
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">split</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
249
- <span class="ruby-identifier">test_condition</span>(<span class="ruby-identifier">split</span>[<span class="ruby-value">0</span>])
250
- <span class="ruby-keyword">else</span>
251
- <span class="ruby-identifier">res</span> = <span class="ruby-keyword">nil</span>
252
- <span class="ruby-identifier">bool</span> = <span class="ruby-keyword">nil</span>
253
- <span class="ruby-identifier">prev</span> = <span class="ruby-keyword">false</span>
254
- <span class="ruby-identifier">split</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cond</span><span class="ruby-operator">|</span>
255
- <span class="ruby-keyword">if</span> <span class="ruby-regexp">/((?:AND )?NOT|AND|OR|&amp;&amp;|\|\||!!)/</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">cond</span>)
256
- <span class="ruby-identifier">bool</span> = <span class="ruby-identifier">cond</span>.<span class="ruby-identifier">bool_to_symbol</span>
257
- <span class="ruby-keyword">next</span>
258
- <span class="ruby-keyword">end</span>
259
-
260
- <span class="ruby-identifier">r</span> = <span class="ruby-identifier">split_booleans</span>(<span class="ruby-identifier">cond</span>)
261
-
262
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">bool</span> <span class="ruby-operator">==</span> <span class="ruby-value">:and</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">r</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-identifier">prev</span>)
263
- <span class="ruby-identifier">res</span> = <span class="ruby-keyword">false</span>
264
- <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">bool</span> <span class="ruby-operator">==</span> <span class="ruby-value">:or</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">r</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">prev</span>)
265
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
266
- <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">bool</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">r</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">prev</span>)
267
- <span class="ruby-identifier">res</span> = <span class="ruby-keyword">false</span>
268
- <span class="ruby-keyword">else</span>
269
- <span class="ruby-identifier">res</span> = <span class="ruby-identifier">r</span>
270
- <span class="ruby-keyword">end</span>
271
-
272
- <span class="ruby-identifier">prev</span> = <span class="ruby-identifier">res</span>
273
- <span class="ruby-keyword">end</span>
274
- <span class="ruby-identifier">res</span>
275
- <span class="ruby-keyword">end</span>
276
- <span class="ruby-keyword">end</span></pre>
277
- </div>
278
- </div>
279
-
280
-
281
- </div>
282
-
283
- <div id="method-i-split_condition" class="method-detail ">
284
- <div class="method-header">
285
- <div class="method-heading">
286
- <span class="method-name">split_condition</span><span
287
- class="method-args">(condition)</span>
288
- <span class="method-click-advice">click to toggle source</span>
289
- </div>
290
- </div>
291
-
292
- <div class="method-description">
293
- <p>Splits a natural language condition.</p>
294
-
295
- <p>@param condition The condition @return [Array] Value, value to compare, operator</p>
296
-
297
- <div class="method-source-code" id="split_condition-source">
298
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 99</span>
299
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">split_condition</span>(<span class="ruby-identifier">condition</span>)
300
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">condition</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/(?:((?:does )?not)?(?:ha(?:s|ve)|contains?|includes?) +)?(yaml|headers|frontmatter|mmd|meta(?:data)?|pandoc)(:\S+)?/i</span>)
301
- <span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
302
- <span class="ruby-identifier">op</span> = <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-value">:contains</span> <span class="ruby-operator">:</span> <span class="ruby-value">:not_contains</span>
303
- <span class="ruby-identifier">type</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>]
304
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^m/i</span>
305
- <span class="ruby-string">&quot;mmd&quot;</span>
306
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^p/i</span>
307
- <span class="ruby-string">&quot;pandoc&quot;</span>
308
- <span class="ruby-keyword">else</span>
309
- <span class="ruby-string">&quot;yaml&quot;</span>
310
- <span class="ruby-keyword">end</span>
311
- <span class="ruby-keyword">return</span> [<span class="ruby-node">&quot;#{type}#{m[3]}&quot;</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">op</span>]
312
- <span class="ruby-keyword">end</span>
313
-
314
- <span class="ruby-identifier">res</span> = <span class="ruby-identifier">condition</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^(?&lt;val1&gt;.*?)(?:(?: +(?&lt;op&gt;(?:is|does)(?: not)?(?: an?|type(?: of)?|equals?(?: to))?|!?==?|[gl]t|(?:greater|less)(?: than)?|&lt;|&gt;|(?:starts|ends) with|(?:ha(?:s|ve) )?(?:prefix|suffix)|has|contains?|includes?) +)(?&lt;val2&gt;.*?))?$/i</span>)
315
- [<span class="ruby-identifier">res</span>[<span class="ruby-string">&quot;val1&quot;</span>], <span class="ruby-identifier">res</span>[<span class="ruby-string">&quot;val2&quot;</span>], <span class="ruby-identifier">operator_to_symbol</span>(<span class="ruby-identifier">res</span>[<span class="ruby-string">&quot;op&quot;</span>])]
316
- <span class="ruby-keyword">end</span></pre>
317
- </div>
318
- </div>
319
-
320
-
321
- </div>
322
-
323
- <div id="method-i-test_condition" class="method-detail ">
324
- <div class="method-header">
325
- <div class="method-heading">
326
- <span class="method-name">test_condition</span><span
327
- class="method-args">(condition)</span>
328
- <span class="method-click-advice">click to toggle source</span>
329
- </div>
330
- </div>
331
-
332
- <div class="method-description">
333
-
334
-
335
- <div class="method-source-code" id="test_condition-source">
336
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 343</span>
337
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_condition</span>(<span class="ruby-identifier">condition</span>)
338
- <span class="ruby-identifier">type</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span> = <span class="ruby-identifier">split_condition</span>(<span class="ruby-identifier">condition</span>)
339
-
340
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">operator</span>.<span class="ruby-identifier">nil?</span>
341
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
342
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^(true|any|all|else|\*+|catch(all)?)$/i</span>
343
- <span class="ruby-keyword">true</span>
344
- <span class="ruby-keyword">else</span>
345
- <span class="ruby-keyword">false</span>
346
- <span class="ruby-keyword">end</span>
347
- <span class="ruby-keyword">end</span>
348
-
349
- <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
350
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^ext/i</span>
351
- <span class="ruby-identifier">test_string</span>(<span class="ruby-ivar">@env</span>[<span class="ruby-value">:ext</span>], <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
352
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^tree/i</span>
353
- <span class="ruby-identifier">test_tree</span>(<span class="ruby-ivar">@env</span>[<span class="ruby-value">:origin</span>], <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
354
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^(path|dir)/i</span>
355
- <span class="ruby-identifier">test_string</span>(<span class="ruby-ivar">@env</span>[<span class="ruby-value">:filepath</span>], <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
356
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^(file)?name/i</span>
357
- <span class="ruby-identifier">test_string</span>(<span class="ruby-ivar">@env</span>[<span class="ruby-value">:filename</span>], <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
358
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^phase/i</span>
359
- <span class="ruby-identifier">test_string</span>(<span class="ruby-ivar">@env</span>[<span class="ruby-value">:phase</span>], <span class="ruby-identifier">value</span>, <span class="ruby-value">:starts_with</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
360
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^text/i</span>
361
- <span class="ruby-identifier">test_string</span>(<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
362
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^(?:yaml|headers|frontmatter)(?::(.*?))?$/i</span>
363
- <span class="ruby-identifier">key</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>(<span class="ruby-value">1</span>) <span class="ruby-operator">||</span> <span class="ruby-keyword">nil</span>
364
- <span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>.<span class="ruby-identifier">yaml?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">test_yaml</span>(<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">operator</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
365
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^(?:mmd|meta(?:data)?)(?::(.*?))?$/i</span>
366
- <span class="ruby-identifier">key</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>(<span class="ruby-value">1</span>) <span class="ruby-operator">||</span> <span class="ruby-keyword">nil</span>
367
- <span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>.<span class="ruby-identifier">meta?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">test_meta</span>(<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">operator</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
368
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^pandoc/</span>
369
- <span class="ruby-identifier">test_pandoc</span>(<span class="ruby-constant">Conductor</span>.<span class="ruby-identifier">stdin</span>, <span class="ruby-identifier">operator</span>)
370
- <span class="ruby-keyword">else</span>
371
- <span class="ruby-keyword">false</span>
372
- <span class="ruby-keyword">end</span>
373
- <span class="ruby-keyword">end</span></pre>
374
- </div>
375
- </div>
376
-
377
-
378
- </div>
379
-
380
- <div id="method-i-test_meta" class="method-detail ">
381
- <div class="method-header">
382
- <div class="method-heading">
383
- <span class="method-name">test_meta</span><span
384
- class="method-args">(content, value, key, operator)</span>
385
- <span class="method-click-advice">click to toggle source</span>
386
- </div>
387
- </div>
388
-
389
- <div class="method-description">
390
- <p>Test for MultiMarkdown metadata,</p>
391
-
392
- <pre class="ruby"><span class="ruby-identifier">optionally</span> <span class="ruby-identifier">key</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">value</span>
393
- </pre>
394
-
395
- <p>@param content [String] The text content @param value [String] The value to test for @param key [String] The key to test for @param operator [Symbol] The operator</p>
396
-
397
- <p>@return [Boolean] test result</p>
398
-
399
- <div class="method-source-code" id="test_meta-source">
400
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 310</span>
401
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_meta</span>(<span class="ruby-identifier">content</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">operator</span>)
402
- <span class="ruby-identifier">headers</span> = []
403
- <span class="ruby-identifier">content</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;\n&quot;</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>
404
- <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">==</span> <span class="ruby-regexp">/^ *\n$/</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/\w+: *\S/</span>
405
-
406
- <span class="ruby-identifier">headers</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
407
- <span class="ruby-keyword">end</span>
408
-
409
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">empty?</span>
410
-
411
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-operator">!=</span> <span class="ruby-value">:not_equal</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span>
412
-
413
- <span class="ruby-identifier">meta</span> = {}
414
- <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
415
- <span class="ruby-identifier">parts</span> = <span class="ruby-identifier">h</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/ *: */</span>)
416
- <span class="ruby-identifier">k</span> = <span class="ruby-identifier">parts</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/ +/</span>, <span class="ruby-string">&quot;&quot;</span>)
417
- <span class="ruby-identifier">v</span> = <span class="ruby-identifier">parts</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;:&quot;</span>).<span class="ruby-identifier">strip</span>
418
- <span class="ruby-identifier">meta</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
419
- <span class="ruby-keyword">end</span>
420
-
421
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span>
422
- <span class="ruby-identifier">test_string</span>(<span class="ruby-identifier">meta</span>[<span class="ruby-identifier">key</span>], <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
423
- <span class="ruby-keyword">else</span>
424
- <span class="ruby-identifier">res</span> = <span class="ruby-identifier">value</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">meta</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">value</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>
425
- <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-operator">?</span> <span class="ruby-operator">!</span><span class="ruby-identifier">res</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">res</span>
426
- <span class="ruby-keyword">end</span>
427
- <span class="ruby-keyword">end</span></pre>
428
- </div>
429
- </div>
430
-
431
-
432
- </div>
433
-
434
- <div id="method-i-test_operator" class="method-detail ">
435
- <div class="method-header">
436
- <div class="method-heading">
437
- <span class="method-name">test_operator</span><span
438
- class="method-args">(value1, value2, operator)</span>
439
- <span class="method-click-advice">click to toggle source</span>
440
- </div>
441
- </div>
442
-
443
- <div class="method-description">
444
- <p>Test operators</p>
445
-
446
- <p>@param value1 Value @param value2 Value to test @param operator The operator</p>
447
-
448
- <p>@return [Boolean] test result</p>
449
-
450
- <div class="method-source-code" id="test_operator-source">
451
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 74</span>
452
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_operator</span>(<span class="ruby-identifier">value1</span>, <span class="ruby-identifier">value2</span>, <span class="ruby-identifier">operator</span>)
453
- <span class="ruby-keyword">case</span> <span class="ruby-identifier">operator</span>
454
- <span class="ruby-keyword">when</span> <span class="ruby-value">:gt</span>
455
- <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">value2</span>.<span class="ruby-identifier">to_f</span>
456
- <span class="ruby-keyword">when</span> <span class="ruby-value">:lt</span>
457
- <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">value2</span>.<span class="ruby-identifier">to_f</span>
458
- <span class="ruby-keyword">when</span> <span class="ruby-value">:contains</span>
459
- <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/#{value2}/i</span>
460
- <span class="ruby-keyword">when</span> <span class="ruby-value">:starts_with</span>
461
- <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^#{value2}/i</span>
462
- <span class="ruby-keyword">when</span> <span class="ruby-value">:ends_with</span>
463
- <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/#{value2}$/i</span>
464
- <span class="ruby-keyword">when</span> <span class="ruby-value">:not_equal</span>
465
- <span class="ruby-identifier">value1</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">value2</span>
466
- <span class="ruby-keyword">when</span> <span class="ruby-value">:equal</span>
467
- <span class="ruby-identifier">value1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">value2</span>
468
- <span class="ruby-keyword">end</span>
469
- <span class="ruby-keyword">end</span></pre>
470
- </div>
471
- </div>
472
-
473
-
474
- </div>
475
-
476
- <div id="method-i-test_pandoc" class="method-detail ">
477
- <div class="method-header">
478
- <div class="method-heading">
479
- <span class="method-name">test_pandoc</span><span
480
- class="method-args">(content, operator)</span>
481
- <span class="method-click-advice">click to toggle source</span>
482
- </div>
483
- </div>
484
-
485
- <div class="method-description">
486
-
487
-
488
- <div class="method-source-code" id="test_pandoc-source">
489
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 338</span>
490
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_pandoc</span>(<span class="ruby-identifier">content</span>, <span class="ruby-identifier">operator</span>)
491
- <span class="ruby-identifier">res</span> = <span class="ruby-identifier">content</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/^%% /</span>)
492
- <span class="ruby-node">%i[not_contains not_equal]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">operator</span>) <span class="ruby-operator">?</span> <span class="ruby-operator">!</span><span class="ruby-identifier">res</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">nil?</span>
493
- <span class="ruby-keyword">end</span></pre>
494
- </div>
495
- </div>
496
-
497
-
498
- </div>
499
-
500
- <div id="method-i-test_string" class="method-detail ">
501
- <div class="method-header">
502
- <div class="method-heading">
503
- <span class="method-name">test_string</span><span
504
- class="method-args">(val1, val2, operator)</span>
505
- <span class="method-click-advice">click to toggle source</span>
506
- </div>
507
- </div>
508
-
509
- <div class="method-description">
510
- <p>Compare a string based on operator</p>
511
-
512
- <p>@param val1 The string to test against @param val2 The value to test @param operator The operator</p>
513
-
514
- <p>@return [Boolean] test result</p>
515
-
516
- <div class="method-source-code" id="test_string-source">
517
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 152</span>
518
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_string</span>(<span class="ruby-identifier">val1</span>, <span class="ruby-identifier">val2</span>, <span class="ruby-identifier">operator</span>)
519
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">:</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val1</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">val2</span>.<span class="ruby-identifier">nil?</span>
520
-
521
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">nil?</span>
522
-
523
- <span class="ruby-identifier">val2</span> = <span class="ruby-identifier">val2</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">&quot;utf-8&quot;</span>)
524
-
525
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">date?</span>
526
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">val2</span>.<span class="ruby-identifier">time?</span>
527
- <span class="ruby-identifier">date1</span> = <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">to_date</span>
528
- <span class="ruby-identifier">date2</span> = <span class="ruby-identifier">val2</span>.<span class="ruby-identifier">to_date</span>
529
- <span class="ruby-keyword">else</span>
530
- <span class="ruby-identifier">date1</span> = <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:gt</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">to_day</span>(<span class="ruby-value">:end</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">to_day</span>
531
- <span class="ruby-identifier">date2</span> = <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:gt</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">val2</span>.<span class="ruby-identifier">to_day</span>(<span class="ruby-value">:end</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">to_day</span>
532
- <span class="ruby-keyword">end</span>
533
-
534
- <span class="ruby-identifier">res</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">operator</span>
535
- <span class="ruby-keyword">when</span> <span class="ruby-value">:gt</span>
536
- <span class="ruby-identifier">date1</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">date2</span>
537
- <span class="ruby-keyword">when</span> <span class="ruby-value">:lt</span>
538
- <span class="ruby-identifier">date1</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">date2</span>
539
- <span class="ruby-keyword">when</span> <span class="ruby-value">:equal</span>
540
- <span class="ruby-identifier">date1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">date2</span>
541
- <span class="ruby-keyword">when</span> <span class="ruby-value">:not_equal</span>
542
- <span class="ruby-identifier">date1</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">date2</span>
543
- <span class="ruby-keyword">end</span>
544
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">res</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">nil?</span>
545
- <span class="ruby-keyword">end</span>
546
-
547
- <span class="ruby-identifier">val2</span> = <span class="ruby-keyword">if</span> <span class="ruby-regexp">%r{^/.*?/$}</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">val2</span>.<span class="ruby-identifier">strip</span>)
548
- <span class="ruby-identifier">val2</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">%r{(^/|/$)}</span>, <span class="ruby-string">&quot;&quot;</span>)
549
- <span class="ruby-keyword">else</span>
550
- <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">val2</span>)
551
- <span class="ruby-keyword">end</span>
552
- <span class="ruby-identifier">val1</span> = <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">&quot;utf-8&quot;</span>)
553
- <span class="ruby-keyword">case</span> <span class="ruby-identifier">operator</span>
554
- <span class="ruby-keyword">when</span> <span class="ruby-value">:contains</span>
555
- <span class="ruby-identifier">val1</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/#{val2}/i</span>
556
- <span class="ruby-keyword">when</span> <span class="ruby-value">:not_starts_with</span>
557
- <span class="ruby-identifier">val1</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/^#{val2}/i</span>
558
- <span class="ruby-keyword">when</span> <span class="ruby-value">:not_ends_with</span>
559
- <span class="ruby-identifier">val1</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/#{val2}$/i</span>
560
- <span class="ruby-keyword">when</span> <span class="ruby-value">:starts_with</span>
561
- <span class="ruby-identifier">val1</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^#{val2}/i</span>
562
- <span class="ruby-keyword">when</span> <span class="ruby-value">:ends_with</span>
563
- <span class="ruby-identifier">val1</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/#{val2}$/i</span>
564
- <span class="ruby-keyword">when</span> <span class="ruby-value">:equal</span>
565
- <span class="ruby-identifier">val1</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^#{val2}$/i</span>
566
- <span class="ruby-keyword">when</span> <span class="ruby-value">:not_equal</span>
567
- <span class="ruby-identifier">val1</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/^#{val2}$/i</span>
568
- <span class="ruby-keyword">else</span>
569
- <span class="ruby-keyword">false</span>
570
- <span class="ruby-keyword">end</span>
571
- <span class="ruby-keyword">end</span></pre>
572
- </div>
573
- </div>
574
-
575
-
576
- </div>
577
-
578
- <div id="method-i-test_tree" class="method-detail ">
579
- <div class="method-header">
580
- <div class="method-heading">
581
- <span class="method-name">test_tree</span><span
582
- class="method-args">(origin, value, operator)</span>
583
- <span class="method-click-advice">click to toggle source</span>
584
- </div>
585
- </div>
586
-
587
- <div class="method-description">
588
- <p>Test for the existince of a</p>
589
-
590
- <pre>file/directory in the parent tree</pre>
591
-
592
- <p>@param origin Starting directory @param value The file/directory to search</p>
593
-
594
- <pre>for</pre>
595
-
596
- <p>@param operator The operator</p>
597
-
598
- <p>@return [Boolean] test result</p>
599
-
600
- <div class="method-source-code" id="test_tree-source">
601
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 218</span>
602
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_tree</span>(<span class="ruby-identifier">origin</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
603
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">origin</span>, <span class="ruby-identifier">value</span>))
604
-
605
- <span class="ruby-identifier">dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">origin</span>)
606
-
607
- <span class="ruby-keyword">if</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">value</span>))
608
- <span class="ruby-keyword">true</span>
609
- <span class="ruby-keyword">elsif</span> [<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">home</span>, <span class="ruby-string">&quot;/&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">dir</span>)
610
- <span class="ruby-keyword">false</span>
611
- <span class="ruby-keyword">else</span>
612
- <span class="ruby-identifier">test_tree</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
613
- <span class="ruby-keyword">end</span>
614
- <span class="ruby-keyword">end</span></pre>
615
- </div>
616
- </div>
617
-
618
-
619
- </div>
620
-
621
- <div id="method-i-test_truthy" class="method-detail ">
622
- <div class="method-header">
623
- <div class="method-heading">
624
- <span class="method-name">test_truthy</span><span
625
- class="method-args">(value1, value2, operator)</span>
626
- <span class="method-click-advice">click to toggle source</span>
627
- </div>
628
- </div>
629
-
630
- <div class="method-description">
631
- <p>Test “truthiness”</p>
632
-
633
- <p>@param value1 Value to test against @param value2 Value to test @param operator The operator</p>
634
-
635
- <p>@return [Boolean] test result</p>
636
-
637
- <div class="method-source-code" id="test_truthy-source">
638
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 241</span>
639
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_truthy</span>(<span class="ruby-identifier">value1</span>, <span class="ruby-identifier">value2</span>, <span class="ruby-identifier">operator</span>)
640
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">value2</span>&amp;.<span class="ruby-identifier">bool?</span>
641
-
642
- <span class="ruby-identifier">value2</span> = <span class="ruby-identifier">value2</span>.<span class="ruby-identifier">to_bool</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value2</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
643
-
644
- <span class="ruby-identifier">res</span> = <span class="ruby-identifier">value1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">value2</span>
645
-
646
- <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-operator">?</span> <span class="ruby-operator">!</span><span class="ruby-identifier">res</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">res</span>
647
- <span class="ruby-keyword">end</span></pre>
648
- </div>
649
- </div>
650
-
651
-
652
- </div>
653
-
654
- <div id="method-i-test_type" class="method-detail ">
655
- <div class="method-header">
656
- <div class="method-heading">
657
- <span class="method-name">test_type</span><span
658
- class="method-args">(val1, val2, operator)</span>
659
- <span class="method-click-advice">click to toggle source</span>
660
- </div>
661
- </div>
662
-
663
- <div class="method-description">
664
- <p>Test for type of value</p>
665
-
666
- <p>@param val1 value @param val2 value to test against @param operator The operator</p>
667
-
668
- <div class="method-source-code" id="test_type-source">
669
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 125</span>
670
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_type</span>(<span class="ruby-identifier">val1</span>, <span class="ruby-identifier">val2</span>, <span class="ruby-identifier">operator</span>)
671
- <span class="ruby-identifier">res</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">val2</span>
672
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/number/</span>
673
- <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Numeric</span>)
674
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/int(eger)?/</span>
675
- <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>)
676
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(float|decimal)/</span>
677
- <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Float</span>)
678
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/array/i</span>
679
- <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
680
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/(string|text)/i</span>
681
- <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
682
- <span class="ruby-keyword">when</span> <span class="ruby-regexp">/date/i</span>
683
- <span class="ruby-identifier">val1</span>.<span class="ruby-identifier">date?</span>
684
- <span class="ruby-keyword">end</span>
685
- <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:type_of</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">res</span> <span class="ruby-operator">:</span> <span class="ruby-operator">!</span><span class="ruby-identifier">res</span>
686
- <span class="ruby-keyword">end</span></pre>
687
- </div>
688
- </div>
689
-
690
-
691
- </div>
692
-
693
- <div id="method-i-test_yaml" class="method-detail ">
694
- <div class="method-header">
695
- <div class="method-heading">
696
- <span class="method-name">test_yaml</span><span
697
- class="method-args">(content, value, key, operator)</span>
698
- <span class="method-click-advice">click to toggle source</span>
699
- </div>
700
- </div>
701
-
702
- <div class="method-description">
703
- <p>Test for presence of yaml, optionall for</p>
704
-
705
- <pre>a key, optionally for a key&#39;s value</pre>
706
-
707
- <p>@param content Text content containing YAML @param value The value to test for @param key The key to test for @param operator The operator</p>
708
-
709
- <p>@return [Boolean] test result</p>
710
-
711
- <div class="method-source-code" id="test_yaml-source">
712
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 262</span>
713
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_yaml</span>(<span class="ruby-identifier">content</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">operator</span>)
714
- <span class="ruby-keyword">begin</span>
715
- <span class="ruby-identifier">yaml</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">content</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/^(?:---|\.\.\.)/</span>)[<span class="ruby-value">1</span>])
716
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span>
717
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
718
- <span class="ruby-keyword">end</span>
719
-
720
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">yaml</span>
721
-
722
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span>
723
- <span class="ruby-identifier">value1</span> = <span class="ruby-identifier">yaml</span>[<span class="ruby-identifier">key</span>]
724
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">nil?</span>
725
-
726
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span>
727
- <span class="ruby-identifier">has_key</span> = <span class="ruby-operator">!</span><span class="ruby-identifier">value1</span>.<span class="ruby-identifier">nil?</span>
728
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span> <span class="ruby-operator">?</span> <span class="ruby-operator">!</span><span class="ruby-identifier">has_key</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">has_key</span>
729
- <span class="ruby-keyword">end</span>
730
-
731
- <span class="ruby-keyword">if</span> <span class="ruby-node">%i[type_of not_type_of]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">operator</span>)
732
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">test_type</span>(<span class="ruby-identifier">value1</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
733
- <span class="ruby-keyword">end</span>
734
-
735
- <span class="ruby-identifier">value1</span> = <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;,&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
736
-
737
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">bool?</span>
738
- <span class="ruby-identifier">test_truthy</span>(<span class="ruby-identifier">value1</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
739
- <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">value1</span>.<span class="ruby-identifier">number?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">number?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-node">%i[gt lt equal not_equal]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">operator</span>)
740
- <span class="ruby-identifier">test_operator</span>(<span class="ruby-identifier">value1</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
741
- <span class="ruby-keyword">else</span>
742
- <span class="ruby-identifier">test_string</span>(<span class="ruby-identifier">value1</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">operator</span>)
743
- <span class="ruby-keyword">end</span>
744
- <span class="ruby-keyword">else</span>
745
- <span class="ruby-identifier">res</span> = <span class="ruby-identifier">value</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">yaml</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">value</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>
746
- (<span class="ruby-identifier">operator</span> <span class="ruby-operator">==</span> <span class="ruby-value">:not_equal</span>) <span class="ruby-operator">?</span> <span class="ruby-operator">!</span><span class="ruby-identifier">res</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">res</span>
747
- <span class="ruby-keyword">end</span>
748
- <span class="ruby-keyword">end</span></pre>
749
- </div>
750
- </div>
751
-
752
-
753
- </div>
754
-
755
- <div id="method-i-true-3F" class="method-detail ">
756
- <div class="method-header">
757
- <div class="method-heading">
758
- <span class="method-name">true?</span><span
759
- class="method-args">()</span>
760
- <span class="method-click-advice">click to toggle source</span>
761
- </div>
762
- </div>
763
-
764
- <div class="method-description">
765
- <p>Tests condition</p>
766
-
767
- <p>@return [Boolean] test result</p>
768
-
769
- <div class="method-source-code" id="true-3F-source">
770
- <pre><span class="ruby-comment"># File lib/conductor/condition.rb, line 21</span>
771
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">true?</span>
772
- <span class="ruby-identifier">parse_condition</span>
773
- <span class="ruby-keyword">end</span></pre>
774
- </div>
775
- </div>
776
-
777
-
778
- </div>
779
-
780
- </section>
781
-
782
- </section>
783
- </main>
784
-
785
-
786
- <footer id="validator-badges" role="contentinfo">
787
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
788
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
789
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
790
- </footer>
791
-