marked-conductor 1.0.8 → 1.0.10

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