ae_easy-test 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,1710 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Module: AeEasy::Test::Helper
8
-
9
- &mdash; Documentation by YARD 0.9.19
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 = "AeEasy::Test::Helper";
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 (H)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../AeEasy.html" title="AeEasy (module)">AeEasy</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Test.html" title="AeEasy::Test (module)">Test</a></span></span>
41
- &raquo;
42
- <span class="title">Helper</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="../../class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Module: AeEasy::Test::Helper
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- <dl>
80
- <dt>Defined in:</dt>
81
- <dd>lib/ae_easy/test/helper.rb</dd>
82
- </dl>
83
-
84
- </div>
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
- <h2>
95
- Class Method Summary
96
- <small><a href="#" class="summary_toggle">collapse</a></small>
97
- </h2>
98
-
99
- <ul class="summary">
100
-
101
- <li class="public ">
102
- <span class="summary_signature">
103
-
104
- <a href="#collection_diff-class_method" title="collection_diff (class method)">.<strong>collection_diff</strong>(items_a, items_b, opts = {}) &#x21d2; Hash </a>
105
-
106
-
107
-
108
- </span>
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
- <span class="summary_desc"><div class='inline'>
119
- <p>Generate a diff over 2 collections.</p>
120
- </div></span>
121
-
122
- </li>
123
-
124
-
125
- <li class="public ">
126
- <span class="summary_signature">
127
-
128
- <a href="#collection_match%3F-class_method" title="collection_match? (class method)">.<strong>collection_match?</strong>(fragment, universe, opts = {}) &#x21d2; Boolean </a>
129
-
130
-
131
-
132
- </span>
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
- <span class="summary_desc"><div class='inline'>
143
- <p>Validate when an item collection match universe item collection.</p>
144
- </div></span>
145
-
146
- </li>
147
-
148
-
149
- <li class="public ">
150
- <span class="summary_signature">
151
-
152
- <a href="#delete_keys_from!-class_method" title="delete_keys_from! (class method)">.<strong>delete_keys_from!</strong>(hash, keys) &#x21d2; Hash </a>
153
-
154
-
155
-
156
- </span>
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
- <span class="summary_desc"><div class='inline'>
167
- <p>Delete keys from a hash.</p>
168
- </div></span>
169
-
170
- </li>
171
-
172
-
173
- <li class="public ">
174
- <span class="summary_signature">
175
-
176
- <a href="#load_file-class_method" title="load_file (class method)">.<strong>load_file</strong>(file_path, should_exists = false) &#x21d2; String<sup>?</sup> </a>
177
-
178
-
179
-
180
- </span>
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
- <span class="summary_desc"><div class='inline'>
191
- <p>Load and return file contents when exists.</p>
192
- </div></span>
193
-
194
- </li>
195
-
196
-
197
- <li class="public ">
198
- <span class="summary_signature">
199
-
200
- <a href="#load_json_file-class_method" title="load_json_file (class method)">.<strong>load_json_file</strong>(file_path, should_exists = false) &#x21d2; Hash<sup>?</sup> </a>
201
-
202
-
203
-
204
- </span>
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
- <span class="summary_desc"><div class='inline'>
215
- <p>Load and return file contents as json when exists.</p>
216
- </div></span>
217
-
218
- </li>
219
-
220
-
221
- <li class="public ">
222
- <span class="summary_signature">
223
-
224
- <a href="#match%3F-class_method" title="match? (class method)">.<strong>match?</strong>(element, filter, opts = {}) &#x21d2; Boolean </a>
225
-
226
-
227
-
228
- </span>
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
- <span class="summary_desc"><div class='inline'>
239
- <p>Check if an hash element match the filter.</p>
240
- </div></span>
241
-
242
- </li>
243
-
244
-
245
- <li class="public ">
246
- <span class="summary_signature">
247
-
248
- <a href="#match_collections-class_method" title="match_collections (class method)">.<strong>match_collections</strong>(items_a, items_b, opts = {}) &#x21d2; Hash </a>
249
-
250
-
251
-
252
- </span>
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
- <span class="summary_desc"><div class='inline'>
263
- <p>Match two collections and calculate diff.</p>
264
- </div></span>
265
-
266
- </li>
267
-
268
-
269
- <li class="public ">
270
- <span class="summary_signature">
271
-
272
- <a href="#sanitize-class_method" title="sanitize (class method)">.<strong>sanitize</strong>(raw_hash, opts) &#x21d2; Hash </a>
273
-
274
-
275
-
276
- </span>
277
-
278
-
279
-
280
-
281
-
282
-
283
-
284
-
285
-
286
- <span class="summary_desc"><div class='inline'>
287
- <p>Sanitize a copy of the hash provided.</p>
288
- </div></span>
289
-
290
- </li>
291
-
292
-
293
- </ul>
294
-
295
-
296
-
297
-
298
- <div id="class_method_details" class="method_details_list">
299
- <h2>Class Method Details</h2>
300
-
301
-
302
- <div class="method_details first">
303
- <h3 class="signature first" id="collection_diff-class_method">
304
-
305
- .<strong>collection_diff</strong>(items_a, items_b, opts = {}) &#x21d2; <tt>Hash</tt>
306
-
307
-
308
-
309
-
310
-
311
- </h3><div class="docstring">
312
- <div class="discussion">
313
-
314
- <p>Generate a diff over 2 collections.</p>
315
-
316
-
317
- </div>
318
- </div>
319
- <div class="tags">
320
- <p class="tag_title">Parameters:</p>
321
- <ul class="param">
322
-
323
- <li>
324
-
325
- <span class='name'>items_a</span>
326
-
327
-
328
- <span class='type'>(<tt>Array</tt>)</span>
329
-
330
-
331
-
332
- &mdash;
333
- <div class='inline'>
334
- <p>List of items to diff.</p>
335
- </div>
336
-
337
- </li>
338
-
339
- <li>
340
-
341
- <span class='name'>items_b</span>
342
-
343
-
344
- <span class='type'>(<tt>Array</tt>)</span>
345
-
346
-
347
-
348
- &mdash;
349
- <div class='inline'>
350
- <p>List of items to diff.</p>
351
- </div>
352
-
353
- </li>
354
-
355
- <li>
356
-
357
- <span class='name'>opts</span>
358
-
359
-
360
- <span class='type'>(<tt>Hash</tt>)</span>
361
-
362
-
363
- <em class="default">(defaults to: <tt>{}</tt>)</em>
364
-
365
-
366
- &mdash;
367
- <div class='inline'>
368
- <p>({}) Configuration options.</p>
369
- </div>
370
-
371
- </li>
372
-
373
- </ul>
374
-
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
- <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
383
- <ul class="option">
384
-
385
- <li>
386
- <span class="name">:exact_match</span>
387
- <span class="type">(<tt>Boolean</tt>)</span>
388
- <span class="default">
389
-
390
- &mdash; default:
391
- <tt>true</tt>
392
-
393
- </span>
394
-
395
- &mdash; <div class='inline'>
396
- <p>Fragmenent should match element exactly.</p>
397
- </div>
398
-
399
- </li>
400
-
401
- <li>
402
- <span class="name">:deep_stringify</span>
403
- <span class="type">(<tt>Boolean</tt>)</span>
404
- <span class="default">
405
-
406
- </span>
407
-
408
- &mdash; <div class='inline'>
409
- <p>If `true` then stringify all hash keys including sublevels before matching.</p>
410
- </div>
411
-
412
- </li>
413
-
414
- <li>
415
- <span class="name">:sanitize</span>
416
- <span class="type">(<tt>Boolean</tt>)</span>
417
- <span class="default">
418
-
419
- &mdash; default:
420
- <tt>true</tt>
421
-
422
- </span>
423
-
424
- &mdash; <div class='inline'>
425
- <p>Sanitize element and filters when `true`.</p>
426
- </div>
427
-
428
- </li>
429
-
430
- <li>
431
- <span class="name">:skip_keys</span>
432
- <span class="type">(<tt>Array</tt>, <tt>nil</tt>)</span>
433
- <span class="default">
434
-
435
- &mdash; default:
436
- <tt>nil</tt>
437
-
438
- </span>
439
-
440
- &mdash; <div class='inline'>
441
- <p>Keys to skip on match.</p>
442
- </div>
443
-
444
- </li>
445
-
446
- <li>
447
- <span class="name">:compare_way</span>
448
- <span class="type">(<tt>Symbol</tt>)</span>
449
- <span class="default">
450
-
451
- &mdash; default:
452
- <tt>:both</tt>
453
-
454
- </span>
455
-
456
- &mdash; <div class='inline'>
457
- <p>Comparison way sense:</p>
458
- <ul><li>
459
- <p>`:both` Compare left and right.</p>
460
- </li><li>
461
- <p>`:right` Compare if `items_a` are inside `items_b`.</p>
462
- </li><li>
463
- <p>`:left` Compare if `items_b` are inside `items_a`.</p>
464
- </li></ul>
465
- </div>
466
-
467
- </li>
468
-
469
- </ul>
470
-
471
-
472
- <p class="tag_title">Returns:</p>
473
- <ul class="return">
474
-
475
- <li>
476
-
477
-
478
- <span class='type'>(<tt>Hash</tt>)</span>
479
-
480
-
481
-
482
- &mdash;
483
- <div class='inline'>
484
- <p>Diff results as follows:</p>
485
- <ul><li>
486
- <p>`[Array] :items_a` Diff items on `items_a` collection.</p>
487
- </li><li>
488
- <p>`[Array] :items_b` Diff items on `items_b` collection.</p>
489
- </li><li>
490
- <p>`[Boolean] :match` `true` when all items match else `false`.</p>
491
- </li></ul>
492
- </div>
493
-
494
- </li>
495
-
496
- </ul>
497
-
498
- </div><table class="source_code">
499
- <tr>
500
- <td>
501
- <pre class="lines">
502
-
503
-
504
- 121
505
- 122
506
- 123
507
- 124
508
- 125
509
- 126
510
- 127
511
- 128
512
- 129
513
- 130
514
- 131
515
- 132
516
- 133
517
- 134
518
- 135
519
- 136
520
- 137
521
- 138
522
- 139
523
- 140
524
- 141
525
- 142
526
- 143
527
- 144
528
- 145
529
- 146
530
- 147
531
- 148
532
- 149
533
- 150
534
- 151
535
- 152
536
- 153
537
- 154
538
- 155
539
- 156
540
- 157
541
- 158
542
- 159</pre>
543
- </td>
544
- <td>
545
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 121</span>
546
-
547
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_collection_diff'>collection_diff</span> <span class='id identifier rubyid_items_a'>items_a</span><span class='comma'>,</span> <span class='id identifier rubyid_items_b'>items_b</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
548
- <span class='comment'># TODO: Improve this function
549
- </span> <span class='comment'>#raise NotImplementedError.new(&#39;Current status WIP, don\&#39;t use it for now.&#39;)
550
- </span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span>
551
- <span class='label'>exact_match:</span> <span class='kw'>true</span><span class='comma'>,</span>
552
- <span class='label'>deep_stringify:</span> <span class='kw'>true</span><span class='comma'>,</span>
553
- <span class='label'>sanitize:</span> <span class='kw'>true</span><span class='comma'>,</span>
554
- <span class='label'>skip_keys:</span> <span class='kw'>nil</span><span class='comma'>,</span>
555
- <span class='label'>compare_way:</span> <span class='symbol'>:both</span>
556
- <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span> <span class='id identifier rubyid_opts'>opts</span>
557
-
558
- <span class='comment'># Match collections items
559
- </span> <span class='id identifier rubyid_match'>match</span> <span class='op'>=</span> <span class='kw'>nil</span>
560
- <span class='id identifier rubyid_compare_right'>compare_right</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:compare_way</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='symbol'>:right</span> <span class='op'>||</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:compare_way</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='symbol'>:both</span>
561
- <span class='id identifier rubyid_compare_left'>compare_left</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:compare_way</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='symbol'>:left</span> <span class='op'>||</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:compare_way</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='symbol'>:both</span>
562
- <span class='id identifier rubyid_items_a'>items_a</span> <span class='op'>=</span> <span class='id identifier rubyid_items_a'>items_a</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span><span class='id identifier rubyid_b'>b</span><span class='op'>|</span><span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='rbrace'>}</span>
563
- <span class='id identifier rubyid_items_b'>items_b</span> <span class='op'>=</span> <span class='id identifier rubyid_items_b'>items_b</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span><span class='id identifier rubyid_b'>b</span><span class='op'>|</span><span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='rbrace'>}</span>
564
- <span class='id identifier rubyid_remaining_items'>remaining_items</span> <span class='op'>=</span> <span class='id identifier rubyid_items_b'>items_b</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
565
- <span class='id identifier rubyid_not_found'>not_found</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
566
- <span class='id identifier rubyid_items_a'>items_a</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item_a'>item_a</span><span class='op'>|</span>
567
- <span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='id identifier rubyid_remaining_items'>remaining_items</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item_b'>item_b</span><span class='op'>|</span>
568
- <span class='id identifier rubyid_match'>match</span> <span class='op'>=</span> <span class='kw'>false</span>
569
- <span class='id identifier rubyid_match'>match</span> <span class='op'>||=</span> <span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='id identifier rubyid_item_a'>item_a</span><span class='comma'>,</span> <span class='id identifier rubyid_item_b'>item_b</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_compare_left'>compare_left</span>
570
- <span class='id identifier rubyid_match'>match</span> <span class='op'>||=</span> <span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='id identifier rubyid_item_b'>item_b</span><span class='comma'>,</span> <span class='id identifier rubyid_item_a'>item_a</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_compare_right'>compare_right</span>
571
- <span class='id identifier rubyid_match'>match</span>
572
- <span class='kw'>end</span>
573
-
574
- <span class='comment'># Save diff
575
- </span> <span class='id identifier rubyid_not_found'>not_found</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_item_a'>item_a</span> <span class='kw'>if</span> <span class='id identifier rubyid_found'>found</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
576
- <span class='id identifier rubyid_remaining_items'>remaining_items</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_found'>found</span>
577
- <span class='kw'>end</span>
578
-
579
- <span class='comment'># Send diff results
580
- </span> <span class='lbrace'>{</span>
581
- <span class='label'>items_a:</span> <span class='id identifier rubyid_not_found'>not_found</span><span class='comma'>,</span>
582
- <span class='label'>items_b:</span> <span class='id identifier rubyid_remaining_items'>remaining_items</span><span class='comma'>,</span>
583
- <span class='label'>match:</span> <span class='lparen'>(</span><span class='id identifier rubyid_not_found'>not_found</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;</span> <span class='int'>1</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_remaining_items'>remaining_items</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;</span> <span class='int'>1</span><span class='rparen'>)</span>
584
- <span class='rbrace'>}</span>
585
- <span class='kw'>end</span></pre>
586
- </td>
587
- </tr>
588
- </table>
589
- </div>
590
-
591
- <div class="method_details ">
592
- <h3 class="signature " id="collection_match?-class_method">
593
-
594
- .<strong>collection_match?</strong>(fragment, universe, opts = {}) &#x21d2; <tt>Boolean</tt>
595
-
596
-
597
-
598
-
599
-
600
- </h3><div class="docstring">
601
- <div class="discussion">
602
-
603
- <p>Validate when an item collection match universe item collection.</p>
604
-
605
-
606
- </div>
607
- </div>
608
- <div class="tags">
609
- <p class="tag_title">Parameters:</p>
610
- <ul class="param">
611
-
612
- <li>
613
-
614
- <span class='name'>fragment</span>
615
-
616
-
617
- <span class='type'>(<tt>Array</tt>)</span>
618
-
619
-
620
-
621
- &mdash;
622
- <div class='inline'>
623
- <p>Fragment of universe items to match.</p>
624
- </div>
625
-
626
- </li>
627
-
628
- <li>
629
-
630
- <span class='name'>universe</span>
631
-
632
-
633
- <span class='type'>(<tt>Array</tt>)</span>
634
-
635
-
636
-
637
- &mdash;
638
- <div class='inline'>
639
- <p>List of items.</p>
640
- </div>
641
-
642
- </li>
643
-
644
- <li>
645
-
646
- <span class='name'>opts</span>
647
-
648
-
649
- <span class='type'>(<tt>Hash</tt>)</span>
650
-
651
-
652
- <em class="default">(defaults to: <tt>{}</tt>)</em>
653
-
654
-
655
- &mdash;
656
- <div class='inline'>
657
- <p>({}) Configuration options.</p>
658
- </div>
659
-
660
- </li>
661
-
662
- </ul>
663
-
664
-
665
-
666
-
667
-
668
-
669
-
670
-
671
- <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
672
- <ul class="option">
673
-
674
- <li>
675
- <span class="name">:exact_match</span>
676
- <span class="type">(<tt>Boolean</tt>)</span>
677
- <span class="default">
678
-
679
- &mdash; default:
680
- <tt>true</tt>
681
-
682
- </span>
683
-
684
- &mdash; <div class='inline'>
685
- <p>Fragmenent should match element exactly.</p>
686
- </div>
687
-
688
- </li>
689
-
690
- <li>
691
- <span class="name">:same_count</span>
692
- <span class="type">(<tt>Boolean</tt>)</span>
693
- <span class="default">
694
-
695
- &mdash; default:
696
- <tt>true</tt>
697
-
698
- </span>
699
-
700
- &mdash; <div class='inline'>
701
- <p>Fragment item count should match universe item count exactly.</p>
702
- </div>
703
-
704
- </li>
705
-
706
- <li>
707
- <span class="name">:deep_stringify</span>
708
- <span class="type">(<tt>Boolean</tt>)</span>
709
- <span class="default">
710
-
711
- </span>
712
-
713
- &mdash; <div class='inline'>
714
- <p>If `true` then stringify all hash keys including sublevels before matching.</p>
715
- </div>
716
-
717
- </li>
718
-
719
- <li>
720
- <span class="name">:sanitize</span>
721
- <span class="type">(<tt>Boolean</tt>)</span>
722
- <span class="default">
723
-
724
- &mdash; default:
725
- <tt>true</tt>
726
-
727
- </span>
728
-
729
- &mdash; <div class='inline'>
730
- <p>Sanitize element and filters when `true`.</p>
731
- </div>
732
-
733
- </li>
734
-
735
- <li>
736
- <span class="name">:skip_keys</span>
737
- <span class="type">(<tt>Array</tt>, <tt>nil</tt>)</span>
738
- <span class="default">
739
-
740
- &mdash; default:
741
- <tt>nil</tt>
742
-
743
- </span>
744
-
745
- &mdash; <div class='inline'>
746
- <p>Keys to skip on match.</p>
747
- </div>
748
-
749
- </li>
750
-
751
- <li>
752
- <span class="name">:compare_way</span>
753
- <span class="type">(<tt>Symbol</tt>)</span>
754
- <span class="default">
755
-
756
- &mdash; default:
757
- <tt>:both</tt>
758
-
759
- </span>
760
-
761
- &mdash; <div class='inline'>
762
- <p>Comparison way sense:</p>
763
- <ul><li>
764
- <p>`:both` Compare left and right.</p>
765
- </li><li>
766
- <p>`:right` Compare if `items_a` are inside `items_b`.</p>
767
- </li><li>
768
- <p>`:left` Compare if `items_b` are inside `items_a`.</p>
769
- </li></ul>
770
- </div>
771
-
772
- </li>
773
-
774
- </ul>
775
-
776
-
777
- <p class="tag_title">Returns:</p>
778
- <ul class="return">
779
-
780
- <li>
781
-
782
-
783
- <span class='type'>(<tt>Boolean</tt>)</span>
784
-
785
-
786
-
787
- </li>
788
-
789
- </ul>
790
-
791
- </div><table class="source_code">
792
- <tr>
793
- <td>
794
- <pre class="lines">
795
-
796
-
797
- 181
798
- 182
799
- 183
800
- 184
801
- 185
802
- 186
803
- 187
804
- 188
805
- 189
806
- 190
807
- 191
808
- 192
809
- 193
810
- 194
811
- 195
812
- 196
813
- 197</pre>
814
- </td>
815
- <td>
816
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 181</span>
817
-
818
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_collection_match?'>collection_match?</span> <span class='id identifier rubyid_fragment'>fragment</span><span class='comma'>,</span> <span class='id identifier rubyid_universe'>universe</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
819
- <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span>
820
- <span class='label'>exact_match:</span> <span class='kw'>true</span><span class='comma'>,</span>
821
- <span class='label'>same_count:</span> <span class='kw'>true</span><span class='comma'>,</span>
822
- <span class='label'>deep_stringify:</span> <span class='kw'>true</span><span class='comma'>,</span>
823
- <span class='label'>sanitize:</span> <span class='kw'>true</span><span class='comma'>,</span>
824
- <span class='label'>skip_keys:</span> <span class='kw'>nil</span><span class='comma'>,</span>
825
- <span class='label'>compare_way:</span> <span class='symbol'>:both</span>
826
- <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span> <span class='id identifier rubyid_opts'>opts</span>
827
-
828
- <span class='comment'># False when item collections count are different
829
- </span> <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:match_quantity</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_fragment'>fragment</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>!=</span> <span class='id identifier rubyid_universe'>universe</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span>
830
-
831
- <span class='id identifier rubyid_diff'>diff</span> <span class='op'>=</span> <span class='id identifier rubyid_collection_diff'>collection_diff</span> <span class='id identifier rubyid_fragment'>fragment</span><span class='comma'>,</span> <span class='id identifier rubyid_universe'>universe</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span>
832
- <span class='id identifier rubyid_match'>match</span> <span class='op'>=</span> <span class='id identifier rubyid_diff'>diff</span><span class='lbracket'>[</span><span class='symbol'>:items_a</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;</span> <span class='int'>1</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_diff'>diff</span><span class='lbracket'>[</span><span class='symbol'>:items_b</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;</span> <span class='int'>1</span>
833
- <span class='id identifier rubyid_match'>match</span>
834
- <span class='kw'>end</span></pre>
835
- </td>
836
- </tr>
837
- </table>
838
- </div>
839
-
840
- <div class="method_details ">
841
- <h3 class="signature " id="delete_keys_from!-class_method">
842
-
843
- .<strong>delete_keys_from!</strong>(hash, keys) &#x21d2; <tt>Hash</tt>
844
-
845
-
846
-
847
-
848
-
849
- </h3><div class="docstring">
850
- <div class="discussion">
851
-
852
- <p>Delete keys from a hash.</p>
853
-
854
-
855
- </div>
856
- </div>
857
- <div class="tags">
858
- <p class="tag_title">Parameters:</p>
859
- <ul class="param">
860
-
861
- <li>
862
-
863
- <span class='name'>hash</span>
864
-
865
-
866
- <span class='type'>(<tt>Hash</tt>)</span>
867
-
868
-
869
-
870
- &mdash;
871
- <div class='inline'>
872
- <p>Base hash to exclude from.</p>
873
- </div>
874
-
875
- </li>
876
-
877
- <li>
878
-
879
- <span class='name'>keys</span>
880
-
881
-
882
- <span class='type'>(<tt>Array</tt>)</span>
883
-
884
-
885
-
886
- &mdash;
887
- <div class='inline'>
888
- <p>Keys to exclude.</p>
889
- </div>
890
-
891
- </li>
892
-
893
- </ul>
894
-
895
- <p class="tag_title">Returns:</p>
896
- <ul class="return">
897
-
898
- <li>
899
-
900
-
901
- <span class='type'>(<tt>Hash</tt>)</span>
902
-
903
-
904
-
905
- </li>
906
-
907
- </ul>
908
-
909
- </div><table class="source_code">
910
- <tr>
911
- <td>
912
- <pre class="lines">
913
-
914
-
915
- 33
916
- 34
917
- 35
918
- 36
919
- 37</pre>
920
- </td>
921
- <td>
922
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 33</span>
923
-
924
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete_keys_from!'>delete_keys_from!</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span>
925
- <span class='kw'>return</span> <span class='id identifier rubyid_hash'>hash</span> <span class='kw'>if</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
926
- <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_k'>k</span><span class='rbrace'>}</span>
927
- <span class='id identifier rubyid_hash'>hash</span>
928
- <span class='kw'>end</span></pre>
929
- </td>
930
- </tr>
931
- </table>
932
- </div>
933
-
934
- <div class="method_details ">
935
- <h3 class="signature " id="load_file-class_method">
936
-
937
- .<strong>load_file</strong>(file_path, should_exists = false) &#x21d2; <tt>String</tt><sup>?</sup>
938
-
939
-
940
-
941
-
942
-
943
- </h3><div class="docstring">
944
- <div class="discussion">
945
-
946
- <p>Load and return file contents when exists.</p>
947
-
948
-
949
- </div>
950
- </div>
951
- <div class="tags">
952
- <p class="tag_title">Parameters:</p>
953
- <ul class="param">
954
-
955
- <li>
956
-
957
- <span class='name'>file_path</span>
958
-
959
-
960
- <span class='type'>(<tt>String</tt>)</span>
961
-
962
-
963
-
964
- &mdash;
965
- <div class='inline'>
966
- <p>File path to load.</p>
967
- </div>
968
-
969
- </li>
970
-
971
- <li>
972
-
973
- <span class='name'>should_exists</span>
974
-
975
-
976
- <span class='type'>(<tt>Boolean</tt>)</span>
977
-
978
-
979
- <em class="default">(defaults to: <tt>false</tt>)</em>
980
-
981
-
982
- &mdash;
983
- <div class='inline'>
984
- <p>(false) Enforce file existance validation.</p>
985
- </div>
986
-
987
- </li>
988
-
989
- </ul>
990
-
991
- <p class="tag_title">Returns:</p>
992
- <ul class="return">
993
-
994
- <li>
995
-
996
-
997
- <span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
998
-
999
-
1000
-
1001
- &mdash;
1002
- <div class='inline'>
1003
- <p>File contents.</p>
1004
- </div>
1005
-
1006
- </li>
1007
-
1008
- </ul>
1009
-
1010
- </div><table class="source_code">
1011
- <tr>
1012
- <td>
1013
- <pre class="lines">
1014
-
1015
-
1016
- 10
1017
- 11
1018
- 12
1019
- 13</pre>
1020
- </td>
1021
- <td>
1022
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 10</span>
1023
-
1024
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_file'>load_file</span> <span class='id identifier rubyid_file_path'>file_path</span><span class='comma'>,</span> <span class='id identifier rubyid_should_exists'>should_exists</span> <span class='op'>=</span> <span class='kw'>false</span>
1025
- <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_should_exists'>should_exists</span> <span class='op'>||</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_file_path'>file_path</span><span class='rparen'>)</span>
1026
- <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_file_path'>file_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>encoding:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>UTF-8</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span>
1027
- <span class='kw'>end</span></pre>
1028
- </td>
1029
- </tr>
1030
- </table>
1031
- </div>
1032
-
1033
- <div class="method_details ">
1034
- <h3 class="signature " id="load_json_file-class_method">
1035
-
1036
- .<strong>load_json_file</strong>(file_path, should_exists = false) &#x21d2; <tt>Hash</tt><sup>?</sup>
1037
-
1038
-
1039
-
1040
-
1041
-
1042
- </h3><div class="docstring">
1043
- <div class="discussion">
1044
-
1045
- <p>Load and return file contents as json when exists.</p>
1046
-
1047
-
1048
- </div>
1049
- </div>
1050
- <div class="tags">
1051
- <p class="tag_title">Parameters:</p>
1052
- <ul class="param">
1053
-
1054
- <li>
1055
-
1056
- <span class='name'>file_path</span>
1057
-
1058
-
1059
- <span class='type'>(<tt>String</tt>)</span>
1060
-
1061
-
1062
-
1063
- &mdash;
1064
- <div class='inline'>
1065
- <p>File path to load.</p>
1066
- </div>
1067
-
1068
- </li>
1069
-
1070
- <li>
1071
-
1072
- <span class='name'>should_exists</span>
1073
-
1074
-
1075
- <span class='type'>(<tt>Boolean</tt>)</span>
1076
-
1077
-
1078
- <em class="default">(defaults to: <tt>false</tt>)</em>
1079
-
1080
-
1081
- &mdash;
1082
- <div class='inline'>
1083
- <p>(false) Enforce file existance validation.</p>
1084
- </div>
1085
-
1086
- </li>
1087
-
1088
- </ul>
1089
-
1090
- <p class="tag_title">Returns:</p>
1091
- <ul class="return">
1092
-
1093
- <li>
1094
-
1095
-
1096
- <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
1097
-
1098
-
1099
-
1100
- &mdash;
1101
- <div class='inline'>
1102
- <p>Json file contents.</p>
1103
- </div>
1104
-
1105
- </li>
1106
-
1107
- </ul>
1108
-
1109
- </div><table class="source_code">
1110
- <tr>
1111
- <td>
1112
- <pre class="lines">
1113
-
1114
-
1115
- 21
1116
- 22
1117
- 23
1118
- 24
1119
- 25</pre>
1120
- </td>
1121
- <td>
1122
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 21</span>
1123
-
1124
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_json_file'>load_json_file</span> <span class='id identifier rubyid_file_path'>file_path</span><span class='comma'>,</span> <span class='id identifier rubyid_should_exists'>should_exists</span> <span class='op'>=</span> <span class='kw'>false</span>
1125
- <span class='id identifier rubyid_file_content'>file_content</span> <span class='op'>=</span> <span class='id identifier rubyid_load_file'>load_file</span> <span class='id identifier rubyid_file_path'>file_path</span><span class='comma'>,</span> <span class='id identifier rubyid_should_exists'>should_exists</span>
1126
- <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_file_content'>file_content</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_file_content'>file_content</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
1127
- <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_file_content'>file_content</span><span class='rparen'>)</span>
1128
- <span class='kw'>end</span></pre>
1129
- </td>
1130
- </tr>
1131
- </table>
1132
- </div>
1133
-
1134
- <div class="method_details ">
1135
- <h3 class="signature " id="match?-class_method">
1136
-
1137
- .<strong>match?</strong>(element, filter, opts = {}) &#x21d2; <tt>Boolean</tt>
1138
-
1139
-
1140
-
1141
-
1142
-
1143
- </h3><div class="docstring">
1144
- <div class="discussion">
1145
-
1146
- <p>Check if an hash element match the filter.</p>
1147
-
1148
-
1149
- </div>
1150
- </div>
1151
- <div class="tags">
1152
- <p class="tag_title">Parameters:</p>
1153
- <ul class="param">
1154
-
1155
- <li>
1156
-
1157
- <span class='name'>element</span>
1158
-
1159
-
1160
- <span class='type'>(<tt>Hash</tt>)</span>
1161
-
1162
-
1163
-
1164
- &mdash;
1165
- <div class='inline'>
1166
- <p>Element to match.</p>
1167
- </div>
1168
-
1169
- </li>
1170
-
1171
- <li>
1172
-
1173
- <span class='name'>filter</span>
1174
-
1175
-
1176
- <span class='type'>(<tt>Hash</tt>)</span>
1177
-
1178
-
1179
-
1180
- &mdash;
1181
- <div class='inline'>
1182
- <p>Filters to apply.</p>
1183
- </div>
1184
-
1185
- </li>
1186
-
1187
- <li>
1188
-
1189
- <span class='name'>opts</span>
1190
-
1191
-
1192
- <span class='type'>(<tt>Hash</tt>)</span>
1193
-
1194
-
1195
- <em class="default">(defaults to: <tt>{}</tt>)</em>
1196
-
1197
-
1198
- &mdash;
1199
- <div class='inline'>
1200
- <p>({}) Configuration options.</p>
1201
- </div>
1202
-
1203
- </li>
1204
-
1205
- </ul>
1206
-
1207
-
1208
-
1209
-
1210
-
1211
-
1212
-
1213
-
1214
- <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
1215
- <ul class="option">
1216
-
1217
- <li>
1218
- <span class="name">:sanitize</span>
1219
- <span class="type">(<tt>Boolean</tt>)</span>
1220
- <span class="default">
1221
-
1222
- &mdash; default:
1223
- <tt>true</tt>
1224
-
1225
- </span>
1226
-
1227
- &mdash; <div class='inline'>
1228
- <p>Sanitize element and filters when `true`.</p>
1229
- </div>
1230
-
1231
- </li>
1232
-
1233
- <li>
1234
- <span class="name">:deep_stringify</span>
1235
- <span class="type">(<tt>Boolean</tt>)</span>
1236
- <span class="default">
1237
-
1238
- </span>
1239
-
1240
- &mdash; <div class='inline'>
1241
- <p>If `true` then stringify all hash keys including sublevels before matching.</p>
1242
- </div>
1243
-
1244
- </li>
1245
-
1246
- <li>
1247
- <span class="name">:exact_match</span>
1248
- <span class="type">(<tt>Boolean</tt>)</span>
1249
- <span class="default">
1250
-
1251
- &mdash; default:
1252
- <tt>true</tt>
1253
-
1254
- </span>
1255
-
1256
- &mdash; <div class='inline'>
1257
- <p>Filter should match element exactly.</p>
1258
- </div>
1259
-
1260
- </li>
1261
-
1262
- <li>
1263
- <span class="name">:skip_keys</span>
1264
- <span class="type">(<tt>Array</tt>, <tt>nil</tt>)</span>
1265
- <span class="default">
1266
-
1267
- &mdash; default:
1268
- <tt>nil</tt>
1269
-
1270
- </span>
1271
-
1272
- &mdash; <div class='inline'>
1273
- <p>Keys to skip on match.</p>
1274
- </div>
1275
-
1276
- </li>
1277
-
1278
- </ul>
1279
-
1280
-
1281
- <p class="tag_title">Returns:</p>
1282
- <ul class="return">
1283
-
1284
- <li>
1285
-
1286
-
1287
- <span class='type'>(<tt>Boolean</tt>)</span>
1288
-
1289
-
1290
-
1291
- &mdash;
1292
- <div class='inline'>
1293
- <p>`true` when element match filters, else `false`.</p>
1294
- </div>
1295
-
1296
- </li>
1297
-
1298
- </ul>
1299
-
1300
- </div><table class="source_code">
1301
- <tr>
1302
- <td>
1303
- <pre class="lines">
1304
-
1305
-
1306
- 74
1307
- 75
1308
- 76
1309
- 77
1310
- 78
1311
- 79
1312
- 80
1313
- 81
1314
- 82
1315
- 83
1316
- 84
1317
- 85
1318
- 86
1319
- 87
1320
- 88
1321
- 89
1322
- 90
1323
- 91
1324
- 92
1325
- 93
1326
- 94
1327
- 95
1328
- 96
1329
- 97
1330
- 98</pre>
1331
- </td>
1332
- <td>
1333
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 74</span>
1334
-
1335
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_match?'>match?</span> <span class='id identifier rubyid_element'>element</span><span class='comma'>,</span> <span class='id identifier rubyid_filter'>filter</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
1336
- <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span>
1337
- <span class='label'>sanitize:</span> <span class='kw'>true</span><span class='comma'>,</span>
1338
- <span class='label'>deep_stringify:</span> <span class='kw'>true</span><span class='comma'>,</span>
1339
- <span class='label'>exact_match:</span> <span class='kw'>true</span><span class='comma'>,</span>
1340
- <span class='label'>skip_keys:</span> <span class='kw'>nil</span>
1341
- <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span> <span class='id identifier rubyid_opts'>opts</span>
1342
-
1343
- <span class='comment'># Sanitize element and filter when need
1344
- </span> <span class='kw'>if</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:sanitize</span><span class='rbracket'>]</span>
1345
- <span class='id identifier rubyid_element'>element</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize'>sanitize</span> <span class='id identifier rubyid_element'>element</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span>
1346
- <span class='id identifier rubyid_filter'>filter</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize'>sanitize</span> <span class='id identifier rubyid_filter'>filter</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span>
1347
- <span class='kw'>end</span>
1348
-
1349
- <span class='comment'># Validate exact match when need
1350
- </span> <span class='id identifier rubyid_exact_match'>exact_match</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:exact_match</span><span class='rbracket'>]</span>
1351
- <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_exact_match'>exact_match</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_element'>element</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>!=</span> <span class='id identifier rubyid_filter'>filter</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span>
1352
-
1353
- <span class='comment'># Match element filter
1354
- </span> <span class='id identifier rubyid_filter'>filter</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
1355
- <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_exact_match'>exact_match</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_element'>element</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_k'>k</span><span class='rparen'>)</span>
1356
- <span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_element'>element</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_v'>v</span>
1357
- <span class='kw'>end</span>
1358
- <span class='kw'>true</span>
1359
- <span class='kw'>end</span></pre>
1360
- </td>
1361
- </tr>
1362
- </table>
1363
- </div>
1364
-
1365
- <div class="method_details ">
1366
- <h3 class="signature " id="match_collections-class_method">
1367
-
1368
- .<strong>match_collections</strong>(items_a, items_b, opts = {}) &#x21d2; <tt>Hash</tt>
1369
-
1370
-
1371
-
1372
-
1373
-
1374
- </h3><div class="docstring">
1375
- <div class="discussion">
1376
-
1377
- <p>Match two collections and calculate diff.</p>
1378
-
1379
-
1380
- </div>
1381
- </div>
1382
- <div class="tags">
1383
- <p class="tag_title">Parameters:</p>
1384
- <ul class="param">
1385
-
1386
- <li>
1387
-
1388
- <span class='name'>items_a</span>
1389
-
1390
-
1391
- <span class='type'>(<tt>Array</tt>)</span>
1392
-
1393
-
1394
-
1395
- &mdash;
1396
- <div class='inline'>
1397
- <p>Item collection to match.</p>
1398
- </div>
1399
-
1400
- </li>
1401
-
1402
- <li>
1403
-
1404
- <span class='name'>items_b</span>
1405
-
1406
-
1407
- <span class='type'>(<tt>Array</tt>)</span>
1408
-
1409
-
1410
-
1411
- &mdash;
1412
- <div class='inline'>
1413
- <p>Item collection to match.</p>
1414
- </div>
1415
-
1416
- </li>
1417
-
1418
- <li>
1419
-
1420
- <span class='name'>opts</span>
1421
-
1422
-
1423
- <span class='type'>(<tt>Hash</tt>)</span>
1424
-
1425
-
1426
- <em class="default">(defaults to: <tt>{}</tt>)</em>
1427
-
1428
-
1429
- &mdash;
1430
- <div class='inline'>
1431
- <p>({}) Configuration options.</p>
1432
- </div>
1433
-
1434
- </li>
1435
-
1436
- </ul>
1437
-
1438
-
1439
-
1440
-
1441
-
1442
-
1443
-
1444
-
1445
- <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
1446
- <ul class="option">
1447
-
1448
- <li>
1449
- <span class="name">:skip</span>
1450
- <span class="type">(<tt>Array</tt>)</span>
1451
- <span class="default">
1452
-
1453
- &mdash; default:
1454
- <tt>nil</tt>
1455
-
1456
- </span>
1457
-
1458
- &mdash; <div class='inline'>
1459
- <p>Keys to skip on match.</p>
1460
- </div>
1461
-
1462
- </li>
1463
-
1464
- <li>
1465
- <span class="name">:compare_way</span>
1466
- <span class="type">(<tt>Symbol</tt>)</span>
1467
- <span class="default">
1468
-
1469
- &mdash; default:
1470
- <tt>:left</tt>
1471
-
1472
- </span>
1473
-
1474
- &mdash; <div class='inline'>
1475
- <p>Comparison way sense:</p>
1476
- <ul><li>
1477
- <p>`:both` Compare left and right.</p>
1478
- </li><li>
1479
- <p>`:right` Compare if `items_a` are inside `items_b`.</p>
1480
- </li><li>
1481
- <p>`:left` Compare if `items_b` are inside `items_a`.</p>
1482
- </li></ul>
1483
- </div>
1484
-
1485
- </li>
1486
-
1487
- </ul>
1488
-
1489
-
1490
- <p class="tag_title">Returns:</p>
1491
- <ul class="return">
1492
-
1493
- <li>
1494
-
1495
-
1496
- <span class='type'>(<tt>Hash</tt>)</span>
1497
-
1498
-
1499
-
1500
- &mdash;
1501
- <div class='inline'>
1502
- <p>A hash with the following key pairs:</p>
1503
- <ul><li>
1504
- <p>`[Hash] :diff` Diff results with `:items_a` and `:items_b` keys.</p>
1505
- </li><li>
1506
- <p>`[Boolean] :match` `true` when match else `false`.</p>
1507
- </li></ul>
1508
- </div>
1509
-
1510
- </li>
1511
-
1512
- </ul>
1513
-
1514
- </div><table class="source_code">
1515
- <tr>
1516
- <td>
1517
- <pre class="lines">
1518
-
1519
-
1520
- 213
1521
- 214
1522
- 215
1523
- 216
1524
- 217
1525
- 218
1526
- 219
1527
- 220
1528
- 221
1529
- 222</pre>
1530
- </td>
1531
- <td>
1532
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 213</span>
1533
-
1534
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_match_collections'>match_collections</span> <span class='id identifier rubyid_items_a'>items_a</span><span class='comma'>,</span> <span class='id identifier rubyid_items_b'>items_b</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
1535
- <span class='id identifier rubyid_diff'>diff</span> <span class='op'>=</span> <span class='id identifier rubyid_collection_diff'>collection_diff</span><span class='lparen'>(</span>
1536
- <span class='id identifier rubyid_items_a'>items_a</span><span class='comma'>,</span>
1537
- <span class='id identifier rubyid_items_b'>items_b</span><span class='comma'>,</span>
1538
- <span class='label'>skip_keys:</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:skip</span><span class='rbracket'>]</span><span class='comma'>,</span>
1539
- <span class='label'>compare_way:</span> <span class='symbol'>:both</span>
1540
- <span class='rparen'>)</span>
1541
- <span class='id identifier rubyid_match'>match</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_diff'>diff</span><span class='lbracket'>[</span><span class='symbol'>:items_a</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;</span> <span class='int'>1</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_diff'>diff</span><span class='lbracket'>[</span><span class='symbol'>:items_b</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&lt;</span> <span class='int'>1</span><span class='rparen'>)</span>
1542
- <span class='lbrace'>{</span><span class='label'>diff:</span> <span class='id identifier rubyid_diff'>diff</span><span class='comma'>,</span> <span class='label'>match:</span> <span class='id identifier rubyid_diff'>diff</span><span class='lbracket'>[</span><span class='symbol'>:match</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
1543
- <span class='kw'>end</span></pre>
1544
- </td>
1545
- </tr>
1546
- </table>
1547
- </div>
1548
-
1549
- <div class="method_details ">
1550
- <h3 class="signature " id="sanitize-class_method">
1551
-
1552
- .<strong>sanitize</strong>(raw_hash, opts) &#x21d2; <tt>Hash</tt>
1553
-
1554
-
1555
-
1556
-
1557
-
1558
- </h3><div class="docstring">
1559
- <div class="discussion">
1560
-
1561
- <p>Sanitize a copy of the hash provided.</p>
1562
-
1563
-
1564
- </div>
1565
- </div>
1566
- <div class="tags">
1567
- <p class="tag_title">Parameters:</p>
1568
- <ul class="param">
1569
-
1570
- <li>
1571
-
1572
- <span class='name'>raw_hash</span>
1573
-
1574
-
1575
- <span class='type'>(<tt>Hash</tt>)</span>
1576
-
1577
-
1578
-
1579
- &mdash;
1580
- <div class='inline'>
1581
- <p>Hash to sanitize.</p>
1582
- </div>
1583
-
1584
- </li>
1585
-
1586
- <li>
1587
-
1588
- <span class='name'>opts</span>
1589
-
1590
-
1591
- <span class='type'>(<tt>Hash</tt>)</span>
1592
-
1593
-
1594
-
1595
- &mdash;
1596
- <div class='inline'>
1597
- <p>({}) Configuration options.</p>
1598
- </div>
1599
-
1600
- </li>
1601
-
1602
- </ul>
1603
-
1604
-
1605
-
1606
-
1607
-
1608
-
1609
- <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
1610
- <ul class="option">
1611
-
1612
- <li>
1613
- <span class="name">:deep_stringify</span>
1614
- <span class="type">(<tt>Boolean</tt>)</span>
1615
- <span class="default">
1616
-
1617
- </span>
1618
-
1619
- &mdash; <div class='inline'>
1620
- <p>If `true` then stringify all hash keys including sublevels.</p>
1621
- </div>
1622
-
1623
- </li>
1624
-
1625
- <li>
1626
- <span class="name">:skip_keys</span>
1627
- <span class="type">(<tt>Array</tt>, <tt>nil</tt>)</span>
1628
- <span class="default">
1629
-
1630
- &mdash; default:
1631
- <tt>nil</tt>
1632
-
1633
- </span>
1634
-
1635
- &mdash; <div class='inline'>
1636
- <p>Key array to delete from sanitized hash clone.</p>
1637
- </div>
1638
-
1639
- </li>
1640
-
1641
- </ul>
1642
-
1643
-
1644
- <p class="tag_title">Returns:</p>
1645
- <ul class="return">
1646
-
1647
- <li>
1648
-
1649
-
1650
- <span class='type'>(<tt>Hash</tt>)</span>
1651
-
1652
-
1653
-
1654
- &mdash;
1655
- <div class='inline'>
1656
- <p>Sanitized hash clone.</p>
1657
- </div>
1658
-
1659
- </li>
1660
-
1661
- </ul>
1662
-
1663
- </div><table class="source_code">
1664
- <tr>
1665
- <td>
1666
- <pre class="lines">
1667
-
1668
-
1669
- 49
1670
- 50
1671
- 51
1672
- 52
1673
- 53
1674
- 54
1675
- 55
1676
- 56
1677
- 57
1678
- 58</pre>
1679
- </td>
1680
- <td>
1681
- <pre class="code"><span class="info file"># File 'lib/ae_easy/test/helper.rb', line 49</span>
1682
-
1683
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_sanitize'>sanitize</span> <span class='id identifier rubyid_raw_hash'>raw_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span>
1684
- <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span>
1685
- <span class='label'>deep_stringify:</span> <span class='kw'>true</span><span class='comma'>,</span>
1686
- <span class='label'>skip_keys:</span> <span class='kw'>nil</span>
1687
- <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span> <span class='id identifier rubyid_opts'>opts</span>
1688
- <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:deep_stringify</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>?</span>
1689
- <span class='const'><span class='object_link'><a href="../../AeEasy.html" title="AeEasy (module)">AeEasy</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Core.html" title="AeEasy::Core (module)">Core</a></span></span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_hash'>raw_hash</span><span class='rparen'>)</span> <span class='op'>:</span>
1690
- <span class='const'><span class='object_link'><a href="../../AeEasy.html" title="AeEasy (module)">AeEasy</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Core.html" title="AeEasy::Core (module)">Core</a></span></span><span class='period'>.</span><span class='id identifier rubyid_deep_clone'>deep_clone</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_hash'>raw_hash</span><span class='rparen'>)</span>
1691
- <span class='id identifier rubyid_delete_keys_from!'>delete_keys_from!</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:skip_keys</span><span class='rbracket'>]</span>
1692
- <span class='kw'>end</span></pre>
1693
- </td>
1694
- </tr>
1695
- </table>
1696
- </div>
1697
-
1698
- </div>
1699
-
1700
- </div>
1701
-
1702
- <div id="footer">
1703
- Generated on Thu Apr 25 19:39:30 2019 by
1704
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1705
- 0.9.19 (ruby-2.5.3).
1706
- </div>
1707
-
1708
- </div>
1709
- </body>
1710
- </html>