qo 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yardopts +3 -0
- data/README.md +35 -2
- data/Rakefile +65 -13
- data/docs/Qo.html +165 -0
- data/docs/Qo/Exceptions.html +160 -0
- data/docs/Qo/Exceptions/MultipleMatchersProvided.html +257 -0
- data/docs/Qo/Exceptions/NoMatchersProvided.html +257 -0
- data/docs/Qo/Exceptions/NotAllGuardMatchersProvided.html +260 -0
- data/docs/Qo/Helpers.html +382 -0
- data/docs/Qo/Matchers.html +169 -0
- data/docs/Qo/Matchers/ArrayMatcher.html +459 -0
- data/docs/Qo/Matchers/BaseMatcher.html +493 -0
- data/docs/Qo/Matchers/GuardBlockMatcher.html +471 -0
- data/docs/Qo/Matchers/HashMatcher.html +445 -0
- data/docs/Qo/Matchers/PatternMatch.html +551 -0
- data/docs/Qo/PublicApi.html +867 -0
- data/docs/_index.html +258 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +499 -0
- data/docs/file.README.html +701 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/img/qo_logo.png +0 -0
- data/docs/index.html +701 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +227 -0
- data/docs/top-level-namespace.html +110 -0
- data/img/whoa_lemur.png +0 -0
- data/lib/qo/exceptions.rb +8 -4
- data/lib/qo/matchers/array_matcher.rb +34 -12
- data/lib/qo/matchers/base_matcher.rb +26 -11
- data/lib/qo/matchers/guard_block_matcher.rb +17 -3
- data/lib/qo/matchers/hash_matcher.rb +32 -23
- data/lib/qo/matchers/pattern_match.rb +2 -1
- data/lib/qo/public_api.rb +6 -5
- data/lib/qo/version.rb +1 -1
- data/performance_report.txt +73 -24
- data/qo.gemspec +2 -0
- metadata +61 -3
@@ -0,0 +1,471 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Qo::Matchers::GuardBlockMatcher
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.12
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Qo::Matchers::GuardBlockMatcher";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (G)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span> » <span class='title'><span class='object_link'><a href="../Matchers.html" title="Qo::Matchers (module)">Matchers</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">GuardBlockMatcher</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Qo::Matchers::GuardBlockMatcher
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span></li>
|
78
|
+
|
79
|
+
<li class="next">Qo::Matchers::GuardBlockMatcher</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/qo/matchers/guard_block_matcher.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
<p>A GuardBlockMatcher is like a regular matcher, except in that if it
|
107
|
+
"matches" it will provide its match target to its associated block.</p>
|
108
|
+
|
109
|
+
<p>It returns tuples of (status, result) in order to prevent masking of
|
110
|
+
legitimate falsy or nil values returned.</p>
|
111
|
+
|
112
|
+
<p>Guard Block Matchers are best used with a PatternMatch, and chances are
|
113
|
+
you're going to want to read that documentation first.</p>
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
<div class="tags">
|
119
|
+
|
120
|
+
<div class="examples">
|
121
|
+
<p class="tag_title">Examples:</p>
|
122
|
+
|
123
|
+
|
124
|
+
<pre class="example code"><code>Qo::Matchers::GuardBlockMatcher == Qo.matcher == Qo.m
|
125
|
+
|
126
|
+
guard_matcher = Qo.m(Integer) { |v| v * 2 }
|
127
|
+
guard_matcher.call(1) # => [true, 2]
|
128
|
+
guard_matcher.call(:x) # => [false, false]</code></pre>
|
129
|
+
|
130
|
+
</div>
|
131
|
+
|
132
|
+
|
133
|
+
<p class="tag_title">See Also:</p>
|
134
|
+
<ul class="see">
|
135
|
+
|
136
|
+
<li><span class='object_link'><a href="PatternMatch.html" title="Qo::Matchers::PatternMatch (class)">Pattern Match using GuardBlockMatchers</a></span></li>
|
137
|
+
|
138
|
+
</ul>
|
139
|
+
<p class="tag_title">Author:</p>
|
140
|
+
<ul class="author">
|
141
|
+
|
142
|
+
<li>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<div class='inline'><p>baweaver</p>
|
149
|
+
</div>
|
150
|
+
|
151
|
+
</li>
|
152
|
+
|
153
|
+
</ul>
|
154
|
+
<p class="tag_title">Since:</p>
|
155
|
+
<ul class="since">
|
156
|
+
|
157
|
+
<li>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<div class='inline'><p>0.1.5</p>
|
164
|
+
</div>
|
165
|
+
|
166
|
+
</li>
|
167
|
+
|
168
|
+
</ul>
|
169
|
+
|
170
|
+
</div>
|
171
|
+
<h2>Constant Summary</h2>
|
172
|
+
<dl class="constants">
|
173
|
+
|
174
|
+
<dt id="IDENTITY-constant" class="">IDENTITY =
|
175
|
+
<div class="docstring">
|
176
|
+
<div class="discussion">
|
177
|
+
<p>Identity function that returns its argument directly</p>
|
178
|
+
|
179
|
+
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
<div class="tags">
|
183
|
+
|
184
|
+
<p class="tag_title">Since:</p>
|
185
|
+
<ul class="since">
|
186
|
+
|
187
|
+
<li>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<div class='inline'><p>0.1.5</p>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
</li>
|
197
|
+
|
198
|
+
</ul>
|
199
|
+
|
200
|
+
</div>
|
201
|
+
</dt>
|
202
|
+
<dd><pre class="code"><span class='tlambda'>-></span> <span class='id identifier rubyid_v'>v</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_v'>v</span> <span class='rbrace'>}</span></pre></dd>
|
203
|
+
|
204
|
+
<dt id="NON_MATCH-constant" class="">NON_MATCH =
|
205
|
+
<div class="docstring">
|
206
|
+
<div class="discussion">
|
207
|
+
<p>Definition of a non-match</p>
|
208
|
+
|
209
|
+
|
210
|
+
</div>
|
211
|
+
</div>
|
212
|
+
<div class="tags">
|
213
|
+
|
214
|
+
<p class="tag_title">Since:</p>
|
215
|
+
<ul class="since">
|
216
|
+
|
217
|
+
<li>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<div class='inline'><p>0.1.5</p>
|
224
|
+
</div>
|
225
|
+
|
226
|
+
</li>
|
227
|
+
|
228
|
+
</ul>
|
229
|
+
|
230
|
+
</div>
|
231
|
+
</dt>
|
232
|
+
<dd><pre class="code"><span class='lbracket'>[</span><span class='kw'>false</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rbracket'>]</span></pre></dd>
|
233
|
+
|
234
|
+
</dl>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
<h2>
|
244
|
+
Instance Method Summary
|
245
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
246
|
+
</h2>
|
247
|
+
|
248
|
+
<ul class="summary">
|
249
|
+
|
250
|
+
<li class="public ">
|
251
|
+
<span class="summary_signature">
|
252
|
+
|
253
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(*array_matchers, **keyword_matchers, &fn) ⇒ GuardBlockMatcher </a>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
</span>
|
258
|
+
|
259
|
+
|
260
|
+
<span class="note title constructor">constructor</span>
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of GuardBlockMatcher.</p>
|
270
|
+
</div></span>
|
271
|
+
|
272
|
+
</li>
|
273
|
+
|
274
|
+
|
275
|
+
<li class="public ">
|
276
|
+
<span class="summary_signature">
|
277
|
+
|
278
|
+
<a href="#to_proc-instance_method" title="#to_proc (instance method)">#<strong>to_proc</strong> ⇒ Proc[Any] - (Bool, Any) </a>
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
</span>
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
<span class="summary_desc"><div class='inline'><p>Overrides the base matcher's #to_proc to wrap the value in a status and potentially call through to the associated block if a base matcher would have passed.</p>
|
293
|
+
</div></span>
|
294
|
+
|
295
|
+
</li>
|
296
|
+
|
297
|
+
|
298
|
+
</ul>
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span></h3>
|
311
|
+
<p class="inherited"><span class='object_link'><a href="BaseMatcher.html#call-instance_method" title="Qo::Matchers::BaseMatcher#call (method)">#call</a></span></p>
|
312
|
+
<div id="constructor_details" class="method_details_list">
|
313
|
+
<h2>Constructor Details</h2>
|
314
|
+
|
315
|
+
<div class="method_details first">
|
316
|
+
<h3 class="signature first" id="initialize-instance_method">
|
317
|
+
|
318
|
+
#<strong>initialize</strong>(*array_matchers, **keyword_matchers, &fn) ⇒ <tt><span class='object_link'><a href="" title="Qo::Matchers::GuardBlockMatcher (class)">GuardBlockMatcher</a></span></tt>
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
</h3><div class="docstring">
|
325
|
+
<div class="discussion">
|
326
|
+
<p>Returns a new instance of GuardBlockMatcher</p>
|
327
|
+
|
328
|
+
|
329
|
+
</div>
|
330
|
+
</div>
|
331
|
+
<div class="tags">
|
332
|
+
|
333
|
+
<p class="tag_title">Since:</p>
|
334
|
+
<ul class="since">
|
335
|
+
|
336
|
+
<li>
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
<div class='inline'><p>0.1.5</p>
|
343
|
+
</div>
|
344
|
+
|
345
|
+
</li>
|
346
|
+
|
347
|
+
</ul>
|
348
|
+
|
349
|
+
</div><table class="source_code">
|
350
|
+
<tr>
|
351
|
+
<td>
|
352
|
+
<pre class="lines">
|
353
|
+
|
354
|
+
|
355
|
+
32
|
356
|
+
33
|
357
|
+
34
|
358
|
+
35
|
359
|
+
36</pre>
|
360
|
+
</td>
|
361
|
+
<td>
|
362
|
+
<pre class="code"><span class="info file"># File 'lib/qo/matchers/guard_block_matcher.rb', line 32</span>
|
363
|
+
|
364
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_fn'>fn</span><span class='rparen'>)</span>
|
365
|
+
<span class='ivar'>@fn</span> <span class='op'>=</span> <span class='id identifier rubyid_fn'>fn</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="#IDENTITY-constant" title="Qo::Matchers::GuardBlockMatcher::IDENTITY (constant)">IDENTITY</a></span></span>
|
366
|
+
|
367
|
+
<span class='kw'>super</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>and</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
|
368
|
+
<span class='kw'>end</span></pre>
|
369
|
+
</td>
|
370
|
+
</tr>
|
371
|
+
</table>
|
372
|
+
</div>
|
373
|
+
|
374
|
+
</div>
|
375
|
+
|
376
|
+
|
377
|
+
<div id="instance_method_details" class="method_details_list">
|
378
|
+
<h2>Instance Method Details</h2>
|
379
|
+
|
380
|
+
|
381
|
+
<div class="method_details first">
|
382
|
+
<h3 class="signature first" id="to_proc-instance_method">
|
383
|
+
|
384
|
+
#<strong>to_proc</strong> ⇒ <tt>Proc[Any] - (Bool, Any)</tt>
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
</h3><div class="docstring">
|
391
|
+
<div class="discussion">
|
392
|
+
<p>Overrides the base matcher's #to_proc to wrap the value in a status
|
393
|
+
and potentially call through to the associated block if a base
|
394
|
+
matcher would have passed</p>
|
395
|
+
|
396
|
+
|
397
|
+
</div>
|
398
|
+
</div>
|
399
|
+
<div class="tags">
|
400
|
+
|
401
|
+
<p class="tag_title">Returns:</p>
|
402
|
+
<ul class="return">
|
403
|
+
|
404
|
+
<li>
|
405
|
+
|
406
|
+
|
407
|
+
<span class='type'>(<tt>Proc[Any] - (Bool, Any)</tt>)</span>
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
—
|
412
|
+
<div class='inline'><p>(status, result) tuple</p>
|
413
|
+
</div>
|
414
|
+
|
415
|
+
</li>
|
416
|
+
|
417
|
+
</ul>
|
418
|
+
<p class="tag_title">Since:</p>
|
419
|
+
<ul class="since">
|
420
|
+
|
421
|
+
<li>
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
<div class='inline'><p>0.1.5</p>
|
428
|
+
</div>
|
429
|
+
|
430
|
+
</li>
|
431
|
+
|
432
|
+
</ul>
|
433
|
+
|
434
|
+
</div><table class="source_code">
|
435
|
+
<tr>
|
436
|
+
<td>
|
437
|
+
<pre class="lines">
|
438
|
+
|
439
|
+
|
440
|
+
44
|
441
|
+
45
|
442
|
+
46
|
443
|
+
47
|
444
|
+
48</pre>
|
445
|
+
</td>
|
446
|
+
<td>
|
447
|
+
<pre class="code"><span class="info file"># File 'lib/qo/matchers/guard_block_matcher.rb', line 44</span>
|
448
|
+
|
449
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_proc'>to_proc</span>
|
450
|
+
<span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_target'>target</span><span class='op'>|</span>
|
451
|
+
<span class='kw'>super</span><span class='lbracket'>[</span><span class='id identifier rubyid_target'>target</span><span class='rbracket'>]</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='kw'>true</span><span class='comma'>,</span> <span class='ivar'>@fn</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='rparen'>)</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='const'><span class='object_link'><a href="#NON_MATCH-constant" title="Qo::Matchers::GuardBlockMatcher::NON_MATCH (constant)">NON_MATCH</a></span></span>
|
452
|
+
<span class='rbrace'>}</span>
|
453
|
+
<span class='kw'>end</span></pre>
|
454
|
+
</td>
|
455
|
+
</tr>
|
456
|
+
</table>
|
457
|
+
</div>
|
458
|
+
|
459
|
+
</div>
|
460
|
+
|
461
|
+
</div>
|
462
|
+
|
463
|
+
<div id="footer">
|
464
|
+
Generated on Sun Apr 15 20:29:44 2018 by
|
465
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
466
|
+
0.9.12 (ruby-2.4.4).
|
467
|
+
</div>
|
468
|
+
|
469
|
+
</div>
|
470
|
+
</body>
|
471
|
+
</html>
|