mbrao 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. data/.gitignore +6 -0
  2. data/.travis-gemfile +13 -0
  3. data/.travis.yml +8 -0
  4. data/.yardopts +1 -0
  5. data/Gemfile +21 -0
  6. data/README.md +60 -0
  7. data/Rakefile +11 -0
  8. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +568 -0
  9. data/doc/ActionView/Template/Handlers.html +125 -0
  10. data/doc/HTML/Pipeline/KramdownFilter.html +354 -0
  11. data/doc/HTML/Pipeline.html +140 -0
  12. data/doc/HTML.html +125 -0
  13. data/doc/Mbrao/Author.html +1402 -0
  14. data/doc/Mbrao/Content.html +4779 -0
  15. data/doc/Mbrao/ContentPublicInterface.html +658 -0
  16. data/doc/Mbrao/Exceptions/InvalidDate.html +133 -0
  17. data/doc/Mbrao/Exceptions/InvalidMetadata.html +133 -0
  18. data/doc/Mbrao/Exceptions/Parsing.html +133 -0
  19. data/doc/Mbrao/Exceptions/Rendering.html +133 -0
  20. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +133 -0
  21. data/doc/Mbrao/Exceptions/Unimplemented.html +133 -0
  22. data/doc/Mbrao/Exceptions/UnknownEngine.html +133 -0
  23. data/doc/Mbrao/Exceptions.html +125 -0
  24. data/doc/Mbrao/Parser.html +418 -0
  25. data/doc/Mbrao/ParsingEngines/Base.html +658 -0
  26. data/doc/Mbrao/ParsingEngines/PlainText.html +571 -0
  27. data/doc/Mbrao/ParsingEngines.html +127 -0
  28. data/doc/Mbrao/PublicInterface/ClassMethods.html +1727 -0
  29. data/doc/Mbrao/PublicInterface.html +134 -0
  30. data/doc/Mbrao/RenderingEngines/Base.html +280 -0
  31. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +873 -0
  32. data/doc/Mbrao/RenderingEngines.html +127 -0
  33. data/doc/Mbrao/Validations/ClassMethods.html +692 -0
  34. data/doc/Mbrao/Validations.html +134 -0
  35. data/doc/Mbrao/Version.html +189 -0
  36. data/doc/Mbrao.html +130 -0
  37. data/doc/_index.html +395 -0
  38. data/doc/class_list.html +53 -0
  39. data/doc/css/common.css +1 -0
  40. data/doc/css/full_list.css +57 -0
  41. data/doc/css/style.css +338 -0
  42. data/doc/file.README.html +135 -0
  43. data/doc/file_list.html +55 -0
  44. data/doc/frames.html +28 -0
  45. data/doc/index.html +135 -0
  46. data/doc/js/app.js +214 -0
  47. data/doc/js/full_list.js +173 -0
  48. data/doc/js/jquery.js +4 -0
  49. data/doc/method_list.html +516 -0
  50. data/doc/top-level-namespace.html +112 -0
  51. data/lib/mbrao/author.rb +61 -0
  52. data/lib/mbrao/content.rb +300 -0
  53. data/lib/mbrao/exceptions.rb +38 -0
  54. data/lib/mbrao/integrations/rails.rb +51 -0
  55. data/lib/mbrao/parser.rb +276 -0
  56. data/lib/mbrao/parsing_engines/base.rb +51 -0
  57. data/lib/mbrao/parsing_engines/plain_text.rb +187 -0
  58. data/lib/mbrao/rendering_engines/base.rb +22 -0
  59. data/lib/mbrao/rendering_engines/html_pipeline.rb +147 -0
  60. data/lib/mbrao/version.rb +25 -0
  61. data/lib/mbrao.rb +24 -0
  62. data/mbrao.gemspec +31 -0
  63. data/spec/coverage_helper.rb +17 -0
  64. data/spec/mbrao/author_spec.rb +62 -0
  65. data/spec/mbrao/content_spec.rb +280 -0
  66. data/spec/mbrao/integrations/rails_spec.rb +92 -0
  67. data/spec/mbrao/parser_spec.rb +269 -0
  68. data/spec/mbrao/parsing_engines/base_spec.rb +52 -0
  69. data/spec/mbrao/parsing_engines/plain_text_spec.rb +141 -0
  70. data/spec/mbrao/rendering_engines/base_spec.rb +17 -0
  71. data/spec/mbrao/rendering_engines/html_pipeline_spec.rb +128 -0
  72. data/spec/spec_helper.rb +15 -0
  73. metadata +195 -0
@@ -0,0 +1,692 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Mbrao::Validations::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.8.5.2
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (C)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Mbrao.html" title="Mbrao (module)">Mbrao</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Validations.html" title="Mbrao::Validations (module)">Validations</a></span></span>
36
+ &raquo;
37
+ <span class="title">ClassMethods</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Mbrao::Validations::ClassMethods
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/mbrao/parser.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+ <h2>Overview</h2><div class="docstring">
88
+ <div class="discussion">
89
+ <p>Class methods.</p>
90
+
91
+
92
+ </div>
93
+ </div>
94
+ <div class="tags">
95
+
96
+
97
+ </div>
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ <h2>
106
+ Instance Method Summary
107
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
108
+ </h2>
109
+
110
+ <ul class="summary">
111
+
112
+ <li class="public ">
113
+ <span class="summary_signature">
114
+
115
+ <a href="#is_email%3F-instance_method" title="#is_email? (instance method)">- (Boolean) <strong>is_email?</strong>(text) </a>
116
+
117
+
118
+
119
+ </span>
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ <span class="summary_desc"><div class='inline'><p>Checks if the text is a valid email.</p>
130
+ </div></span>
131
+
132
+ </li>
133
+
134
+
135
+ <li class="public ">
136
+ <span class="summary_signature">
137
+
138
+ <a href="#is_url%3F-instance_method" title="#is_url? (instance method)">- (Boolean) <strong>is_url?</strong>(text) </a>
139
+
140
+
141
+
142
+ </span>
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+ <span class="summary_desc"><div class='inline'><p>Checks if the text is a valid URL.</p>
153
+ </div></span>
154
+
155
+ </li>
156
+
157
+
158
+ <li class="public ">
159
+ <span class="summary_signature">
160
+
161
+ <a href="#sanitized_array-instance_method" title="#sanitized_array (instance method)">- (Array) <strong>sanitized_array</strong>(object, uniq = true, compact = false, sanitize_method = :ensure_string, &amp;block) </a>
162
+
163
+
164
+
165
+ </span>
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+ <span class="summary_desc"><div class='inline'><p>Converts an object to a a flatten array with all values sanitized.</p>
176
+ </div></span>
177
+
178
+ </li>
179
+
180
+
181
+ <li class="public ">
182
+ <span class="summary_signature">
183
+
184
+ <a href="#sanitized_hash-instance_method" title="#sanitized_hash (instance method)">- (Object) <strong>sanitized_hash</strong>(object, sanitize_method = nil, &amp;block) </a>
185
+
186
+
187
+
188
+ </span>
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+ <span class="summary_desc"><div class='inline'><p>Converts an object making sure that every <code>Hash</code> is converted to a <code>HashWithIndifferentAccess</code>.</p>
199
+ </div></span>
200
+
201
+ </li>
202
+
203
+
204
+ </ul>
205
+
206
+
207
+
208
+
209
+ <div id="instance_method_details" class="method_details_list">
210
+ <h2>Instance Method Details</h2>
211
+
212
+
213
+ <div class="method_details first">
214
+ <h3 class="signature first" id="is_email?-instance_method">
215
+
216
+ - (<tt>Boolean</tt>) <strong>is_email?</strong>(text)
217
+
218
+
219
+
220
+
221
+
222
+ </h3><div class="docstring">
223
+ <div class="discussion">
224
+ <p>Checks if the text is a valid email.</p>
225
+
226
+
227
+ </div>
228
+ </div>
229
+ <div class="tags">
230
+ <p class="tag_title">Parameters:</p>
231
+ <ul class="param">
232
+
233
+ <li>
234
+
235
+ <span class='name'>text</span>
236
+
237
+
238
+ <span class='type'>(<tt>String</tt>)</span>
239
+
240
+
241
+
242
+ &mdash;
243
+ <div class='inline'><p>The text to check.</p>
244
+ </div>
245
+
246
+ </li>
247
+
248
+ </ul>
249
+
250
+ <p class="tag_title">Returns:</p>
251
+ <ul class="return">
252
+
253
+ <li>
254
+
255
+
256
+ <span class='type'>(<tt>Boolean</tt>)</span>
257
+
258
+
259
+
260
+ &mdash;
261
+ <div class='inline'><p><code>true</code> if the string is valid email, <code>false</code> otherwise.</p>
262
+ </div>
263
+
264
+ </li>
265
+
266
+ </ul>
267
+
268
+ </div><table class="source_code">
269
+ <tr>
270
+ <td>
271
+ <pre class="lines">
272
+
273
+
274
+ 137
275
+ 138
276
+ 139
277
+ 140</pre>
278
+ </td>
279
+ <td>
280
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 137</span>
281
+
282
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_email?'>is_email?</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='rparen'>)</span>
283
+ <span class='id identifier rubyid_regex'>regex</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^([a-z0-9_\.\-\+]+)@([\da-z\.\-]+)\.([a-z\.]{2,6})$</span><span class='regexp_end'>/i</span></span>
284
+ <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='op'>=~</span> <span class='id identifier rubyid_regex'>regex</span>
285
+ <span class='kw'>end</span></pre>
286
+ </td>
287
+ </tr>
288
+ </table>
289
+ </div>
290
+
291
+ <div class="method_details ">
292
+ <h3 class="signature " id="is_url?-instance_method">
293
+
294
+ - (<tt>Boolean</tt>) <strong>is_url?</strong>(text)
295
+
296
+
297
+
298
+
299
+
300
+ </h3><div class="docstring">
301
+ <div class="discussion">
302
+ <p>Checks if the text is a valid URL.</p>
303
+
304
+
305
+ </div>
306
+ </div>
307
+ <div class="tags">
308
+ <p class="tag_title">Parameters:</p>
309
+ <ul class="param">
310
+
311
+ <li>
312
+
313
+ <span class='name'>text</span>
314
+
315
+
316
+ <span class='type'>(<tt>String</tt>)</span>
317
+
318
+
319
+
320
+ &mdash;
321
+ <div class='inline'><p>The text to check.</p>
322
+ </div>
323
+
324
+ </li>
325
+
326
+ </ul>
327
+
328
+ <p class="tag_title">Returns:</p>
329
+ <ul class="return">
330
+
331
+ <li>
332
+
333
+
334
+ <span class='type'>(<tt>Boolean</tt>)</span>
335
+
336
+
337
+
338
+ &mdash;
339
+ <div class='inline'><p><code>true</code> if the string is valid URL, <code>false</code> otherwise.</p>
340
+ </div>
341
+
342
+ </li>
343
+
344
+ </ul>
345
+
346
+ </div><table class="source_code">
347
+ <tr>
348
+ <td>
349
+ <pre class="lines">
350
+
351
+
352
+ 146
353
+ 147
354
+ 148
355
+ 149
356
+ 150
357
+ 151
358
+ 152
359
+ 153
360
+ 154
361
+ 155
362
+ 156
363
+ 157
364
+ 158
365
+ 159</pre>
366
+ </td>
367
+ <td>
368
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 146</span>
369
+
370
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_url?'>is_url?</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='rparen'>)</span>
371
+ <span class='id identifier rubyid_regex'>regex</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>
372
+ ^(
373
+ ([a-z0-9\-]+:\/\/) #PROTOCOL
374
+ (([\w-]+\.)?) # LOWEST TLD
375
+ ([\w-]+) # 2nd LEVEL TLD
376
+ (\.[a-z]+) # TOP TLD
377
+ ((:\d+)?) # PORT
378
+ ([\S|\?]*) # PATH, QUERYSTRING AND FRAGMENT
379
+ )$
380
+ </span><span class='regexp_end'>/ix</span></span>
381
+
382
+ <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='op'>=~</span> <span class='id identifier rubyid_regex'>regex</span>
383
+ <span class='kw'>end</span></pre>
384
+ </td>
385
+ </tr>
386
+ </table>
387
+ </div>
388
+
389
+ <div class="method_details ">
390
+ <h3 class="signature " id="sanitized_array-instance_method">
391
+
392
+ - (<tt>Array</tt>) <strong>sanitized_array</strong>(object, uniq = true, compact = false, sanitize_method = :ensure_string, &amp;block)
393
+
394
+
395
+
396
+
397
+
398
+ </h3><div class="docstring">
399
+ <div class="discussion">
400
+ <p>Converts an object to a a flatten array with all values sanitized.</p>
401
+
402
+
403
+ </div>
404
+ </div>
405
+ <div class="tags">
406
+ <p class="tag_title">Parameters:</p>
407
+ <ul class="param">
408
+
409
+ <li>
410
+
411
+ <span class='name'>object</span>
412
+
413
+
414
+ <span class='type'>(<tt>Object</tt>)</span>
415
+
416
+
417
+
418
+ &mdash;
419
+ <div class='inline'><p>The object to convert.</p>
420
+ </div>
421
+
422
+ </li>
423
+
424
+ <li>
425
+
426
+ <span class='name'>uniq</span>
427
+
428
+
429
+ <span class='type'>(<tt>Boolean</tt>)</span>
430
+
431
+
432
+ <em class="default">(defaults to: <tt>true</tt>)</em>
433
+
434
+
435
+ &mdash;
436
+ <div class='inline'><p>If to remove duplicates from the array before sanitizing.</p>
437
+ </div>
438
+
439
+ </li>
440
+
441
+ <li>
442
+
443
+ <span class='name'>compact</span>
444
+
445
+
446
+ <span class='type'>(<tt>Boolean</tt>)</span>
447
+
448
+
449
+ <em class="default">(defaults to: <tt>false</tt>)</em>
450
+
451
+
452
+ &mdash;
453
+ <div class='inline'><p>If to compact the array before sanitizing.</p>
454
+ </div>
455
+
456
+ </li>
457
+
458
+ <li>
459
+
460
+ <span class='name'>sanitize_method</span>
461
+
462
+
463
+ <span class='type'>(<tt>Symbol|nil</tt>)</span>
464
+
465
+
466
+ <em class="default">(defaults to: <tt>:ensure_string</tt>)</em>
467
+
468
+
469
+ &mdash;
470
+ <div class='inline'><p>If not <code>nil</code>, the method to use to sanitize entries. Ignored if a block is present.</p>
471
+ </div>
472
+
473
+ </li>
474
+
475
+ <li>
476
+
477
+ <span class='name'>block</span>
478
+
479
+
480
+ <span class='type'>(<tt>Proc</tt>)</span>
481
+
482
+
483
+
484
+ &mdash;
485
+ <div class='inline'><p>A block to sanitize entries. It must accept the value as unique argument.</p>
486
+ </div>
487
+
488
+ </li>
489
+
490
+ </ul>
491
+
492
+ <p class="tag_title">Returns:</p>
493
+ <ul class="return">
494
+
495
+ <li>
496
+
497
+
498
+ <span class='type'>(<tt>Array</tt>)</span>
499
+
500
+
501
+
502
+ &mdash;
503
+ <div class='inline'><p>An flattened array whose all values are strings.</p>
504
+ </div>
505
+
506
+ </li>
507
+
508
+ </ul>
509
+
510
+ </div><table class="source_code">
511
+ <tr>
512
+ <td>
513
+ <pre class="lines">
514
+
515
+
516
+ 188
517
+ 189
518
+ 190
519
+ 191
520
+ 192
521
+ 193
522
+ 194
523
+ 195
524
+ 196
525
+ 197
526
+ 198
527
+ 199
528
+ 200
529
+ 201
530
+ 202</pre>
531
+ </td>
532
+ <td>
533
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 188</span>
534
+
535
+ <span class='kw'>def</span> <span class='id identifier rubyid_sanitized_array'>sanitized_array</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_uniq'>uniq</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_compact'>compact</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitize_method'>sanitize_method</span> <span class='op'>=</span> <span class='symbol'>:ensure_string</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
536
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>
537
+ <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_uniq!'>uniq!</span> <span class='kw'>if</span> <span class='id identifier rubyid_uniq'>uniq</span>
538
+ <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_compact!'>compact!</span> <span class='kw'>if</span> <span class='id identifier rubyid_compact'>compact</span>
539
+
540
+ <span class='kw'>if</span> <span class='id identifier rubyid_block'>block</span> <span class='kw'>then</span>
541
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
542
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_sanitize_method'>sanitize_method</span> <span class='kw'>then</span>
543
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_sanitize_method'>sanitize_method</span><span class='rparen'>)</span>
544
+ <span class='kw'>end</span>
545
+
546
+ <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_uniq!'>uniq!</span> <span class='kw'>if</span> <span class='id identifier rubyid_uniq'>uniq</span>
547
+ <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_compact!'>compact!</span> <span class='kw'>if</span> <span class='id identifier rubyid_compact'>compact</span>
548
+ <span class='id identifier rubyid_rv'>rv</span>
549
+ <span class='kw'>end</span></pre>
550
+ </td>
551
+ </tr>
552
+ </table>
553
+ </div>
554
+
555
+ <div class="method_details ">
556
+ <h3 class="signature " id="sanitized_hash-instance_method">
557
+
558
+ - (<tt>Object</tt>) <strong>sanitized_hash</strong>(object, sanitize_method = nil, &amp;block)
559
+
560
+
561
+
562
+
563
+
564
+ </h3><div class="docstring">
565
+ <div class="discussion">
566
+ <p>Converts an object making sure that every <code>Hash</code> is converted to a <code>HashWithIndifferentAccess</code>.</p>
567
+
568
+
569
+ </div>
570
+ </div>
571
+ <div class="tags">
572
+ <p class="tag_title">Parameters:</p>
573
+ <ul class="param">
574
+
575
+ <li>
576
+
577
+ <span class='name'>object</span>
578
+
579
+
580
+ <span class='type'>(<tt>Object</tt>)</span>
581
+
582
+
583
+
584
+ &mdash;
585
+ <div class='inline'><p>The object to convert. If the object is not an Hash or doesn’t respond to <code>collect</code> then the original object is returned.</p>
586
+ </div>
587
+
588
+ </li>
589
+
590
+ <li>
591
+
592
+ <span class='name'>sanitize_method</span>
593
+
594
+
595
+ <span class='type'>(<tt>Symbol|nil</tt>)</span>
596
+
597
+
598
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
599
+
600
+
601
+ &mdash;
602
+ <div class='inline'><p>If not <code>nil</code>, the method to use to sanitize entries. Ignored if a block is present.</p>
603
+ </div>
604
+
605
+ </li>
606
+
607
+ <li>
608
+
609
+ <span class='name'>block</span>
610
+
611
+
612
+ <span class='type'>(<tt>Proc</tt>)</span>
613
+
614
+
615
+
616
+ &mdash;
617
+ <div class='inline'><p>A block to sanitize entries. It must accept the value as unique argument.</p>
618
+ </div>
619
+
620
+ </li>
621
+
622
+ </ul>
623
+
624
+ <p class="tag_title">Returns:</p>
625
+ <ul class="return">
626
+
627
+ <li>
628
+
629
+
630
+ <span class='type'>(<tt>Object</tt>)</span>
631
+
632
+
633
+
634
+ &mdash;
635
+ <div class='inline'><p>The converted object.</p>
636
+ </div>
637
+
638
+ </li>
639
+
640
+ </ul>
641
+
642
+ </div><table class="source_code">
643
+ <tr>
644
+ <td>
645
+ <pre class="lines">
646
+
647
+
648
+ 167
649
+ 168
650
+ 169
651
+ 170
652
+ 171
653
+ 172
654
+ 173
655
+ 174
656
+ 175
657
+ 176
658
+ 177
659
+ 178</pre>
660
+ </td>
661
+ <td>
662
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 167</span>
663
+
664
+ <span class='kw'>def</span> <span class='id identifier rubyid_sanitized_hash'>sanitized_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitize_method'>sanitize_method</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
665
+ <span class='kw'>if</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>HashWithIndifferentAccess</span><span class='rparen'>)</span> <span class='kw'>then</span>
666
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_pair'>pair</span><span class='op'>|</span>
667
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_pair'>pair</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_sanitized_hash'>sanitized_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_pair'>pair</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitize_method'>sanitize_method</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
668
+ <span class='id identifier rubyid_hash'>hash</span>
669
+ <span class='kw'>end</span>
670
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:collect</span><span class='rparen'>)</span> <span class='kw'>then</span>
671
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_sanitized_hash'>sanitized_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_item'>item</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitize_method'>sanitize_method</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
672
+ <span class='kw'>else</span>
673
+ <span class='id identifier rubyid_sanitized_hash_entry'>sanitized_hash_entry</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitize_method'>sanitize_method</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
674
+ <span class='kw'>end</span>
675
+ <span class='kw'>end</span></pre>
676
+ </td>
677
+ </tr>
678
+ </table>
679
+ </div>
680
+
681
+ </div>
682
+
683
+ </div>
684
+
685
+ <div id="footer">
686
+ Generated on Fri Mar 1 09:13:30 2013 by
687
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
688
+ 0.8.5.2 (ruby-1.9.3).
689
+ </div>
690
+
691
+ </body>
692
+ </html>