mbrao 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +1 -1
  4. data/doc/ActionView/Template/Handlers.html +1 -1
  5. data/doc/HTML/Pipeline/KramdownFilter.html +1 -1
  6. data/doc/HTML/Pipeline.html +1 -1
  7. data/doc/HTML.html +1 -1
  8. data/doc/Mbrao/Author.html +1 -1
  9. data/doc/Mbrao/Content.html +641 -94
  10. data/doc/Mbrao/ContentPublicInterface.html +1 -1
  11. data/doc/Mbrao/Exceptions/InvalidDate.html +1 -1
  12. data/doc/Mbrao/Exceptions/InvalidMetadata.html +1 -1
  13. data/doc/Mbrao/Exceptions/Parsing.html +1 -1
  14. data/doc/Mbrao/Exceptions/Rendering.html +1 -1
  15. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +1 -1
  16. data/doc/Mbrao/Exceptions/Unimplemented.html +1 -1
  17. data/doc/Mbrao/Exceptions/UnknownEngine.html +1 -1
  18. data/doc/Mbrao/Exceptions.html +1 -1
  19. data/doc/Mbrao/Parser.html +1 -1
  20. data/doc/Mbrao/ParsingEngines/Base.html +1 -1
  21. data/doc/Mbrao/ParsingEngines/PlainText.html +1 -1
  22. data/doc/Mbrao/ParsingEngines.html +1 -1
  23. data/doc/Mbrao/PublicInterface/ClassMethods.html +1 -1
  24. data/doc/Mbrao/PublicInterface.html +1 -1
  25. data/doc/Mbrao/RenderingEngines/Base.html +1 -1
  26. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +1 -1
  27. data/doc/Mbrao/RenderingEngines.html +1 -1
  28. data/doc/Mbrao/Validations/ClassMethods.html +1 -1
  29. data/doc/Mbrao/Validations.html +1 -1
  30. data/doc/Mbrao/Version.html +2 -2
  31. data/doc/Mbrao.html +1 -1
  32. data/doc/_index.html +1 -1
  33. data/doc/file.README.html +1 -1
  34. data/doc/index.html +1 -1
  35. data/doc/top-level-namespace.html +1 -1
  36. data/lib/mbrao/content.rb +33 -7
  37. data/lib/mbrao/version.rb +1 -1
  38. data/spec/mbrao/content_spec.rb +35 -2
  39. metadata +2 -2
@@ -114,6 +114,33 @@
114
114
 
115
115
 
116
116
  </div>
117
+ <h2>Constant Summary</h2>
118
+
119
+ <dl class="constants">
120
+
121
+ <dt id="ALLOWED_DATETIME_FORMATS-constant" class="">ALLOWED_DATETIME_FORMATS =
122
+ <div class="docstring">
123
+ <div class="discussion">
124
+ <p>The allowed string format for a datetime.</p>
125
+
126
+
127
+ </div>
128
+ </div>
129
+ <div class="tags">
130
+
131
+
132
+ </div>
133
+ </dt>
134
+ <dd><pre class="code"><span class='lbracket'>[</span>
135
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
136
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
137
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
138
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
139
+ <span class='rbracket'>]</span></pre></dd>
140
+
141
+ </dl>
142
+
143
+
117
144
 
118
145
 
119
146
 
@@ -585,12 +612,12 @@
585
612
  <pre class="lines">
586
613
 
587
614
 
588
- 137
589
- 138
590
- 139</pre>
615
+ 145
616
+ 146
617
+ 147</pre>
591
618
  </td>
592
619
  <td>
593
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 137</span>
620
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 145</span>
594
621
 
595
622
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_uid'>uid</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
596
623
  <span class='ivar'>@uid</span> <span class='op'>=</span> <span class='id identifier rubyid_uid'>uid</span>
@@ -886,7 +913,33 @@
886
913
  353
887
914
  354
888
915
  355
889
- 356</pre>
916
+ 356
917
+ 357
918
+ 358
919
+ 359
920
+ 360
921
+ 361
922
+ 362
923
+ 363
924
+ 364
925
+ 365
926
+ 366
927
+ 367
928
+ 368
929
+ 369
930
+ 370
931
+ 371
932
+ 372
933
+ 373
934
+ 374
935
+ 375
936
+ 376
937
+ 377
938
+ 378
939
+ 379
940
+ 380
941
+ 381
942
+ 382</pre>
890
943
  </td>
891
944
  <td>
892
945
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -906,6 +959,14 @@
906
959
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
907
960
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
908
961
 
962
+ <span class='comment'># The allowed string format for a datetime.
963
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
964
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
965
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
966
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
967
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
968
+ <span class='rbracket'>]</span>
969
+
909
970
  <span class='comment'># Creates a new content.
910
971
  </span> <span class='comment'>#
911
972
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -1069,7 +1130,7 @@
1069
1130
  <span class='id identifier rubyid_content'>content</span>
1070
1131
  <span class='kw'>end</span>
1071
1132
 
1072
- <span class='comment'># Extract locales from metadata.
1133
+ <span class='comment'># Extracts locales from metadata.
1073
1134
  </span> <span class='comment'>#
1074
1135
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
1075
1136
  </span> <span class='comment'># @return [Array] The locales.
@@ -1079,7 +1140,7 @@
1079
1140
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1080
1141
  <span class='kw'>end</span>
1081
1142
 
1082
- <span class='comment'># Normalize locales for further usage.
1143
+ <span class='comment'># Normalizes locales for further usage.
1083
1144
  </span> <span class='comment'>#
1084
1145
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
1085
1146
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -1100,7 +1161,8 @@
1100
1161
  <span class='kw'>end</span>
1101
1162
  <span class='kw'>end</span>
1102
1163
 
1103
- <span class='comment'># Parse a datetime
1164
+ <span class='comment'># Parses a datetime.
1165
+ </span> <span class='comment'>#
1104
1166
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1105
1167
  </span> <span class='comment'># @return [DateTime] The extracted value.
1106
1168
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -1108,12 +1170,29 @@
1108
1170
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
1109
1171
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
1110
1172
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
1111
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
1112
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1173
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
1174
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1113
1175
  <span class='kw'>end</span>
1114
1176
  <span class='kw'>end</span>
1115
1177
 
1116
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
1178
+ <span class='comment'># Parses a datetime string.
1179
+ </span> <span class='comment'>#
1180
+ </span> <span class='comment'># @param value [String] The value to parse.
1181
+ </span> <span class='comment'># @return [DateTime] The extracted value.
1182
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1183
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1184
+
1185
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
1186
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
1187
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
1188
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
1189
+ <span class='kw'>end</span>
1190
+
1191
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
1192
+ <span class='kw'>end</span>
1193
+ <span class='kw'>end</span>
1194
+
1195
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
1117
1196
  </span> <span class='comment'>#
1118
1197
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
1119
1198
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -1415,7 +1494,33 @@
1415
1494
  353
1416
1495
  354
1417
1496
  355
1418
- 356</pre>
1497
+ 356
1498
+ 357
1499
+ 358
1500
+ 359
1501
+ 360
1502
+ 361
1503
+ 362
1504
+ 363
1505
+ 364
1506
+ 365
1507
+ 366
1508
+ 367
1509
+ 368
1510
+ 369
1511
+ 370
1512
+ 371
1513
+ 372
1514
+ 373
1515
+ 374
1516
+ 375
1517
+ 376
1518
+ 377
1519
+ 378
1520
+ 379
1521
+ 380
1522
+ 381
1523
+ 382</pre>
1419
1524
  </td>
1420
1525
  <td>
1421
1526
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -1435,6 +1540,14 @@
1435
1540
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
1436
1541
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
1437
1542
 
1543
+ <span class='comment'># The allowed string format for a datetime.
1544
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
1545
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
1546
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
1547
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
1548
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
1549
+ <span class='rbracket'>]</span>
1550
+
1438
1551
  <span class='comment'># Creates a new content.
1439
1552
  </span> <span class='comment'>#
1440
1553
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -1598,7 +1711,7 @@
1598
1711
  <span class='id identifier rubyid_content'>content</span>
1599
1712
  <span class='kw'>end</span>
1600
1713
 
1601
- <span class='comment'># Extract locales from metadata.
1714
+ <span class='comment'># Extracts locales from metadata.
1602
1715
  </span> <span class='comment'>#
1603
1716
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
1604
1717
  </span> <span class='comment'># @return [Array] The locales.
@@ -1608,7 +1721,7 @@
1608
1721
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
1609
1722
  <span class='kw'>end</span>
1610
1723
 
1611
- <span class='comment'># Normalize locales for further usage.
1724
+ <span class='comment'># Normalizes locales for further usage.
1612
1725
  </span> <span class='comment'>#
1613
1726
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
1614
1727
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -1629,7 +1742,8 @@
1629
1742
  <span class='kw'>end</span>
1630
1743
  <span class='kw'>end</span>
1631
1744
 
1632
- <span class='comment'># Parse a datetime
1745
+ <span class='comment'># Parses a datetime.
1746
+ </span> <span class='comment'>#
1633
1747
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
1634
1748
  </span> <span class='comment'># @return [DateTime] The extracted value.
1635
1749
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -1637,12 +1751,29 @@
1637
1751
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
1638
1752
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
1639
1753
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
1640
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
1641
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1754
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
1755
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1642
1756
  <span class='kw'>end</span>
1643
1757
  <span class='kw'>end</span>
1644
1758
 
1645
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
1759
+ <span class='comment'># Parses a datetime string.
1760
+ </span> <span class='comment'>#
1761
+ </span> <span class='comment'># @param value [String] The value to parse.
1762
+ </span> <span class='comment'># @return [DateTime] The extracted value.
1763
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1764
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1765
+
1766
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
1767
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
1768
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
1769
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
1770
+ <span class='kw'>end</span>
1771
+
1772
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
1773
+ <span class='kw'>end</span>
1774
+ <span class='kw'>end</span>
1775
+
1776
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
1646
1777
  </span> <span class='comment'>#
1647
1778
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
1648
1779
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -1944,7 +2075,33 @@
1944
2075
  353
1945
2076
  354
1946
2077
  355
1947
- 356</pre>
2078
+ 356
2079
+ 357
2080
+ 358
2081
+ 359
2082
+ 360
2083
+ 361
2084
+ 362
2085
+ 363
2086
+ 364
2087
+ 365
2088
+ 366
2089
+ 367
2090
+ 368
2091
+ 369
2092
+ 370
2093
+ 371
2094
+ 372
2095
+ 373
2096
+ 374
2097
+ 375
2098
+ 376
2099
+ 377
2100
+ 378
2101
+ 379
2102
+ 380
2103
+ 381
2104
+ 382</pre>
1948
2105
  </td>
1949
2106
  <td>
1950
2107
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -1964,6 +2121,14 @@
1964
2121
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
1965
2122
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
1966
2123
 
2124
+ <span class='comment'># The allowed string format for a datetime.
2125
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
2126
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
2127
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
2128
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
2129
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
2130
+ <span class='rbracket'>]</span>
2131
+
1967
2132
  <span class='comment'># Creates a new content.
1968
2133
  </span> <span class='comment'>#
1969
2134
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -2127,7 +2292,7 @@
2127
2292
  <span class='id identifier rubyid_content'>content</span>
2128
2293
  <span class='kw'>end</span>
2129
2294
 
2130
- <span class='comment'># Extract locales from metadata.
2295
+ <span class='comment'># Extracts locales from metadata.
2131
2296
  </span> <span class='comment'>#
2132
2297
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
2133
2298
  </span> <span class='comment'># @return [Array] The locales.
@@ -2137,7 +2302,7 @@
2137
2302
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2138
2303
  <span class='kw'>end</span>
2139
2304
 
2140
- <span class='comment'># Normalize locales for further usage.
2305
+ <span class='comment'># Normalizes locales for further usage.
2141
2306
  </span> <span class='comment'>#
2142
2307
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
2143
2308
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -2158,7 +2323,8 @@
2158
2323
  <span class='kw'>end</span>
2159
2324
  <span class='kw'>end</span>
2160
2325
 
2161
- <span class='comment'># Parse a datetime
2326
+ <span class='comment'># Parses a datetime.
2327
+ </span> <span class='comment'>#
2162
2328
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2163
2329
  </span> <span class='comment'># @return [DateTime] The extracted value.
2164
2330
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -2166,12 +2332,29 @@
2166
2332
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
2167
2333
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
2168
2334
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
2169
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
2170
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
2335
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
2336
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2171
2337
  <span class='kw'>end</span>
2172
2338
  <span class='kw'>end</span>
2173
2339
 
2174
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
2340
+ <span class='comment'># Parses a datetime string.
2341
+ </span> <span class='comment'>#
2342
+ </span> <span class='comment'># @param value [String] The value to parse.
2343
+ </span> <span class='comment'># @return [DateTime] The extracted value.
2344
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2345
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2346
+
2347
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
2348
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
2349
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
2350
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
2351
+ <span class='kw'>end</span>
2352
+
2353
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
2354
+ <span class='kw'>end</span>
2355
+ <span class='kw'>end</span>
2356
+
2357
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
2175
2358
  </span> <span class='comment'>#
2176
2359
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
2177
2360
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -2473,7 +2656,33 @@
2473
2656
  353
2474
2657
  354
2475
2658
  355
2476
- 356</pre>
2659
+ 356
2660
+ 357
2661
+ 358
2662
+ 359
2663
+ 360
2664
+ 361
2665
+ 362
2666
+ 363
2667
+ 364
2668
+ 365
2669
+ 366
2670
+ 367
2671
+ 368
2672
+ 369
2673
+ 370
2674
+ 371
2675
+ 372
2676
+ 373
2677
+ 374
2678
+ 375
2679
+ 376
2680
+ 377
2681
+ 378
2682
+ 379
2683
+ 380
2684
+ 381
2685
+ 382</pre>
2477
2686
  </td>
2478
2687
  <td>
2479
2688
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -2493,6 +2702,14 @@
2493
2702
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
2494
2703
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
2495
2704
 
2705
+ <span class='comment'># The allowed string format for a datetime.
2706
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
2707
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
2708
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
2709
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
2710
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
2711
+ <span class='rbracket'>]</span>
2712
+
2496
2713
  <span class='comment'># Creates a new content.
2497
2714
  </span> <span class='comment'>#
2498
2715
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -2656,7 +2873,7 @@
2656
2873
  <span class='id identifier rubyid_content'>content</span>
2657
2874
  <span class='kw'>end</span>
2658
2875
 
2659
- <span class='comment'># Extract locales from metadata.
2876
+ <span class='comment'># Extracts locales from metadata.
2660
2877
  </span> <span class='comment'>#
2661
2878
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
2662
2879
  </span> <span class='comment'># @return [Array] The locales.
@@ -2666,7 +2883,7 @@
2666
2883
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
2667
2884
  <span class='kw'>end</span>
2668
2885
 
2669
- <span class='comment'># Normalize locales for further usage.
2886
+ <span class='comment'># Normalizes locales for further usage.
2670
2887
  </span> <span class='comment'>#
2671
2888
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
2672
2889
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -2687,7 +2904,8 @@
2687
2904
  <span class='kw'>end</span>
2688
2905
  <span class='kw'>end</span>
2689
2906
 
2690
- <span class='comment'># Parse a datetime
2907
+ <span class='comment'># Parses a datetime.
2908
+ </span> <span class='comment'>#
2691
2909
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
2692
2910
  </span> <span class='comment'># @return [DateTime] The extracted value.
2693
2911
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -2695,12 +2913,29 @@
2695
2913
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
2696
2914
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
2697
2915
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
2698
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
2699
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
2916
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
2917
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2700
2918
  <span class='kw'>end</span>
2701
2919
  <span class='kw'>end</span>
2702
2920
 
2703
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
2921
+ <span class='comment'># Parses a datetime string.
2922
+ </span> <span class='comment'>#
2923
+ </span> <span class='comment'># @param value [String] The value to parse.
2924
+ </span> <span class='comment'># @return [DateTime] The extracted value.
2925
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
2926
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
2927
+
2928
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
2929
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
2930
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
2931
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
2932
+ <span class='kw'>end</span>
2933
+
2934
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
2935
+ <span class='kw'>end</span>
2936
+ <span class='kw'>end</span>
2937
+
2938
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
2704
2939
  </span> <span class='comment'>#
2705
2940
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
2706
2941
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -3002,7 +3237,33 @@
3002
3237
  353
3003
3238
  354
3004
3239
  355
3005
- 356</pre>
3240
+ 356
3241
+ 357
3242
+ 358
3243
+ 359
3244
+ 360
3245
+ 361
3246
+ 362
3247
+ 363
3248
+ 364
3249
+ 365
3250
+ 366
3251
+ 367
3252
+ 368
3253
+ 369
3254
+ 370
3255
+ 371
3256
+ 372
3257
+ 373
3258
+ 374
3259
+ 375
3260
+ 376
3261
+ 377
3262
+ 378
3263
+ 379
3264
+ 380
3265
+ 381
3266
+ 382</pre>
3006
3267
  </td>
3007
3268
  <td>
3008
3269
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -3022,6 +3283,14 @@
3022
3283
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
3023
3284
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
3024
3285
 
3286
+ <span class='comment'># The allowed string format for a datetime.
3287
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
3288
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
3289
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
3290
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
3291
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
3292
+ <span class='rbracket'>]</span>
3293
+
3025
3294
  <span class='comment'># Creates a new content.
3026
3295
  </span> <span class='comment'>#
3027
3296
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -3185,7 +3454,7 @@
3185
3454
  <span class='id identifier rubyid_content'>content</span>
3186
3455
  <span class='kw'>end</span>
3187
3456
 
3188
- <span class='comment'># Extract locales from metadata.
3457
+ <span class='comment'># Extracts locales from metadata.
3189
3458
  </span> <span class='comment'>#
3190
3459
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
3191
3460
  </span> <span class='comment'># @return [Array] The locales.
@@ -3195,7 +3464,7 @@
3195
3464
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3196
3465
  <span class='kw'>end</span>
3197
3466
 
3198
- <span class='comment'># Normalize locales for further usage.
3467
+ <span class='comment'># Normalizes locales for further usage.
3199
3468
  </span> <span class='comment'>#
3200
3469
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
3201
3470
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -3216,7 +3485,8 @@
3216
3485
  <span class='kw'>end</span>
3217
3486
  <span class='kw'>end</span>
3218
3487
 
3219
- <span class='comment'># Parse a datetime
3488
+ <span class='comment'># Parses a datetime.
3489
+ </span> <span class='comment'>#
3220
3490
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3221
3491
  </span> <span class='comment'># @return [DateTime] The extracted value.
3222
3492
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -3224,12 +3494,29 @@
3224
3494
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
3225
3495
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
3226
3496
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
3227
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
3228
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
3497
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
3498
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3499
+ <span class='kw'>end</span>
3500
+ <span class='kw'>end</span>
3501
+
3502
+ <span class='comment'># Parses a datetime string.
3503
+ </span> <span class='comment'>#
3504
+ </span> <span class='comment'># @param value [String] The value to parse.
3505
+ </span> <span class='comment'># @return [DateTime] The extracted value.
3506
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
3507
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
3508
+
3509
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
3510
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
3511
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
3512
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
3513
+ <span class='kw'>end</span>
3514
+
3515
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
3229
3516
  <span class='kw'>end</span>
3230
3517
  <span class='kw'>end</span>
3231
3518
 
3232
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
3519
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
3233
3520
  </span> <span class='comment'>#
3234
3521
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
3235
3522
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -3575,7 +3862,33 @@ for multiple locales.</p>
3575
3862
  353
3576
3863
  354
3577
3864
  355
3578
- 356</pre>
3865
+ 356
3866
+ 357
3867
+ 358
3868
+ 359
3869
+ 360
3870
+ 361
3871
+ 362
3872
+ 363
3873
+ 364
3874
+ 365
3875
+ 366
3876
+ 367
3877
+ 368
3878
+ 369
3879
+ 370
3880
+ 371
3881
+ 372
3882
+ 373
3883
+ 374
3884
+ 375
3885
+ 376
3886
+ 377
3887
+ 378
3888
+ 379
3889
+ 380
3890
+ 381
3891
+ 382</pre>
3579
3892
  </td>
3580
3893
  <td>
3581
3894
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -3595,6 +3908,14 @@ for multiple locales.</p>
3595
3908
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
3596
3909
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
3597
3910
 
3911
+ <span class='comment'># The allowed string format for a datetime.
3912
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
3913
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
3914
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
3915
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
3916
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
3917
+ <span class='rbracket'>]</span>
3918
+
3598
3919
  <span class='comment'># Creates a new content.
3599
3920
  </span> <span class='comment'>#
3600
3921
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -3758,7 +4079,7 @@ for multiple locales.</p>
3758
4079
  <span class='id identifier rubyid_content'>content</span>
3759
4080
  <span class='kw'>end</span>
3760
4081
 
3761
- <span class='comment'># Extract locales from metadata.
4082
+ <span class='comment'># Extracts locales from metadata.
3762
4083
  </span> <span class='comment'>#
3763
4084
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
3764
4085
  </span> <span class='comment'># @return [Array] The locales.
@@ -3768,7 +4089,7 @@ for multiple locales.</p>
3768
4089
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
3769
4090
  <span class='kw'>end</span>
3770
4091
 
3771
- <span class='comment'># Normalize locales for further usage.
4092
+ <span class='comment'># Normalizes locales for further usage.
3772
4093
  </span> <span class='comment'>#
3773
4094
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
3774
4095
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -3789,7 +4110,8 @@ for multiple locales.</p>
3789
4110
  <span class='kw'>end</span>
3790
4111
  <span class='kw'>end</span>
3791
4112
 
3792
- <span class='comment'># Parse a datetime
4113
+ <span class='comment'># Parses a datetime.
4114
+ </span> <span class='comment'>#
3793
4115
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
3794
4116
  </span> <span class='comment'># @return [DateTime] The extracted value.
3795
4117
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -3797,12 +4119,29 @@ for multiple locales.</p>
3797
4119
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
3798
4120
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
3799
4121
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
3800
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
3801
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
4122
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
4123
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4124
+ <span class='kw'>end</span>
4125
+ <span class='kw'>end</span>
4126
+
4127
+ <span class='comment'># Parses a datetime string.
4128
+ </span> <span class='comment'>#
4129
+ </span> <span class='comment'># @param value [String] The value to parse.
4130
+ </span> <span class='comment'># @return [DateTime] The extracted value.
4131
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4132
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4133
+
4134
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
4135
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
4136
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
4137
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
4138
+ <span class='kw'>end</span>
4139
+
4140
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
3802
4141
  <span class='kw'>end</span>
3803
4142
  <span class='kw'>end</span>
3804
4143
 
3805
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
4144
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
3806
4145
  </span> <span class='comment'>#
3807
4146
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
3808
4147
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -4106,7 +4445,33 @@ are specified for multiple locales.</p>
4106
4445
  353
4107
4446
  354
4108
4447
  355
4109
- 356</pre>
4448
+ 356
4449
+ 357
4450
+ 358
4451
+ 359
4452
+ 360
4453
+ 361
4454
+ 362
4455
+ 363
4456
+ 364
4457
+ 365
4458
+ 366
4459
+ 367
4460
+ 368
4461
+ 369
4462
+ 370
4463
+ 371
4464
+ 372
4465
+ 373
4466
+ 374
4467
+ 375
4468
+ 376
4469
+ 377
4470
+ 378
4471
+ 379
4472
+ 380
4473
+ 381
4474
+ 382</pre>
4110
4475
  </td>
4111
4476
  <td>
4112
4477
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -4126,6 +4491,14 @@ are specified for multiple locales.</p>
4126
4491
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
4127
4492
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
4128
4493
 
4494
+ <span class='comment'># The allowed string format for a datetime.
4495
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
4496
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
4497
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
4498
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
4499
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
4500
+ <span class='rbracket'>]</span>
4501
+
4129
4502
  <span class='comment'># Creates a new content.
4130
4503
  </span> <span class='comment'>#
4131
4504
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -4289,7 +4662,7 @@ are specified for multiple locales.</p>
4289
4662
  <span class='id identifier rubyid_content'>content</span>
4290
4663
  <span class='kw'>end</span>
4291
4664
 
4292
- <span class='comment'># Extract locales from metadata.
4665
+ <span class='comment'># Extracts locales from metadata.
4293
4666
  </span> <span class='comment'>#
4294
4667
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
4295
4668
  </span> <span class='comment'># @return [Array] The locales.
@@ -4299,7 +4672,7 @@ are specified for multiple locales.</p>
4299
4672
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4300
4673
  <span class='kw'>end</span>
4301
4674
 
4302
- <span class='comment'># Normalize locales for further usage.
4675
+ <span class='comment'># Normalizes locales for further usage.
4303
4676
  </span> <span class='comment'>#
4304
4677
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
4305
4678
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -4320,7 +4693,8 @@ are specified for multiple locales.</p>
4320
4693
  <span class='kw'>end</span>
4321
4694
  <span class='kw'>end</span>
4322
4695
 
4323
- <span class='comment'># Parse a datetime
4696
+ <span class='comment'># Parses a datetime.
4697
+ </span> <span class='comment'>#
4324
4698
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4325
4699
  </span> <span class='comment'># @return [DateTime] The extracted value.
4326
4700
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -4328,12 +4702,29 @@ are specified for multiple locales.</p>
4328
4702
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
4329
4703
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
4330
4704
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
4331
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
4332
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
4705
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
4706
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4333
4707
  <span class='kw'>end</span>
4334
4708
  <span class='kw'>end</span>
4335
4709
 
4336
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
4710
+ <span class='comment'># Parses a datetime string.
4711
+ </span> <span class='comment'>#
4712
+ </span> <span class='comment'># @param value [String] The value to parse.
4713
+ </span> <span class='comment'># @return [DateTime] The extracted value.
4714
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
4715
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
4716
+
4717
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
4718
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
4719
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
4720
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
4721
+ <span class='kw'>end</span>
4722
+
4723
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
4724
+ <span class='kw'>end</span>
4725
+ <span class='kw'>end</span>
4726
+
4727
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
4337
4728
  </span> <span class='comment'>#
4338
4729
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
4339
4730
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -4637,7 +5028,33 @@ multiple locales.</p>
4637
5028
  353
4638
5029
  354
4639
5030
  355
4640
- 356</pre>
5031
+ 356
5032
+ 357
5033
+ 358
5034
+ 359
5035
+ 360
5036
+ 361
5037
+ 362
5038
+ 363
5039
+ 364
5040
+ 365
5041
+ 366
5042
+ 367
5043
+ 368
5044
+ 369
5045
+ 370
5046
+ 371
5047
+ 372
5048
+ 373
5049
+ 374
5050
+ 375
5051
+ 376
5052
+ 377
5053
+ 378
5054
+ 379
5055
+ 380
5056
+ 381
5057
+ 382</pre>
4641
5058
  </td>
4642
5059
  <td>
4643
5060
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -4657,6 +5074,14 @@ multiple locales.</p>
4657
5074
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
4658
5075
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
4659
5076
 
5077
+ <span class='comment'># The allowed string format for a datetime.
5078
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
5079
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
5080
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
5081
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
5082
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
5083
+ <span class='rbracket'>]</span>
5084
+
4660
5085
  <span class='comment'># Creates a new content.
4661
5086
  </span> <span class='comment'>#
4662
5087
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -4820,7 +5245,7 @@ multiple locales.</p>
4820
5245
  <span class='id identifier rubyid_content'>content</span>
4821
5246
  <span class='kw'>end</span>
4822
5247
 
4823
- <span class='comment'># Extract locales from metadata.
5248
+ <span class='comment'># Extracts locales from metadata.
4824
5249
  </span> <span class='comment'>#
4825
5250
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
4826
5251
  </span> <span class='comment'># @return [Array] The locales.
@@ -4830,7 +5255,7 @@ multiple locales.</p>
4830
5255
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
4831
5256
  <span class='kw'>end</span>
4832
5257
 
4833
- <span class='comment'># Normalize locales for further usage.
5258
+ <span class='comment'># Normalizes locales for further usage.
4834
5259
  </span> <span class='comment'>#
4835
5260
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
4836
5261
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -4851,7 +5276,8 @@ multiple locales.</p>
4851
5276
  <span class='kw'>end</span>
4852
5277
  <span class='kw'>end</span>
4853
5278
 
4854
- <span class='comment'># Parse a datetime
5279
+ <span class='comment'># Parses a datetime.
5280
+ </span> <span class='comment'>#
4855
5281
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
4856
5282
  </span> <span class='comment'># @return [DateTime] The extracted value.
4857
5283
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -4859,12 +5285,29 @@ multiple locales.</p>
4859
5285
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
4860
5286
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
4861
5287
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
4862
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
4863
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
5288
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
5289
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5290
+ <span class='kw'>end</span>
5291
+ <span class='kw'>end</span>
5292
+
5293
+ <span class='comment'># Parses a datetime string.
5294
+ </span> <span class='comment'>#
5295
+ </span> <span class='comment'># @param value [String] The value to parse.
5296
+ </span> <span class='comment'># @return [DateTime] The extracted value.
5297
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5298
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
5299
+
5300
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
5301
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
5302
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
5303
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
5304
+ <span class='kw'>end</span>
5305
+
5306
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
4864
5307
  <span class='kw'>end</span>
4865
5308
  <span class='kw'>end</span>
4866
5309
 
4867
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
5310
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
4868
5311
  </span> <span class='comment'>#
4869
5312
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
4870
5313
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -5166,7 +5609,33 @@ multiple locales.</p>
5166
5609
  353
5167
5610
  354
5168
5611
  355
5169
- 356</pre>
5612
+ 356
5613
+ 357
5614
+ 358
5615
+ 359
5616
+ 360
5617
+ 361
5618
+ 362
5619
+ 363
5620
+ 364
5621
+ 365
5622
+ 366
5623
+ 367
5624
+ 368
5625
+ 369
5626
+ 370
5627
+ 371
5628
+ 372
5629
+ 373
5630
+ 374
5631
+ 375
5632
+ 376
5633
+ 377
5634
+ 378
5635
+ 379
5636
+ 380
5637
+ 381
5638
+ 382</pre>
5170
5639
  </td>
5171
5640
  <td>
5172
5641
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -5186,6 +5655,14 @@ multiple locales.</p>
5186
5655
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
5187
5656
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
5188
5657
 
5658
+ <span class='comment'># The allowed string format for a datetime.
5659
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
5660
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
5661
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
5662
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
5663
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
5664
+ <span class='rbracket'>]</span>
5665
+
5189
5666
  <span class='comment'># Creates a new content.
5190
5667
  </span> <span class='comment'>#
5191
5668
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -5349,7 +5826,7 @@ multiple locales.</p>
5349
5826
  <span class='id identifier rubyid_content'>content</span>
5350
5827
  <span class='kw'>end</span>
5351
5828
 
5352
- <span class='comment'># Extract locales from metadata.
5829
+ <span class='comment'># Extracts locales from metadata.
5353
5830
  </span> <span class='comment'>#
5354
5831
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
5355
5832
  </span> <span class='comment'># @return [Array] The locales.
@@ -5359,7 +5836,7 @@ multiple locales.</p>
5359
5836
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5360
5837
  <span class='kw'>end</span>
5361
5838
 
5362
- <span class='comment'># Normalize locales for further usage.
5839
+ <span class='comment'># Normalizes locales for further usage.
5363
5840
  </span> <span class='comment'>#
5364
5841
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
5365
5842
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -5380,7 +5857,8 @@ multiple locales.</p>
5380
5857
  <span class='kw'>end</span>
5381
5858
  <span class='kw'>end</span>
5382
5859
 
5383
- <span class='comment'># Parse a datetime
5860
+ <span class='comment'># Parses a datetime.
5861
+ </span> <span class='comment'>#
5384
5862
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
5385
5863
  </span> <span class='comment'># @return [DateTime] The extracted value.
5386
5864
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -5388,12 +5866,29 @@ multiple locales.</p>
5388
5866
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
5389
5867
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
5390
5868
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
5391
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
5392
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
5869
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
5870
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5393
5871
  <span class='kw'>end</span>
5394
5872
  <span class='kw'>end</span>
5395
5873
 
5396
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
5874
+ <span class='comment'># Parses a datetime string.
5875
+ </span> <span class='comment'>#
5876
+ </span> <span class='comment'># @param value [String] The value to parse.
5877
+ </span> <span class='comment'># @return [DateTime] The extracted value.
5878
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5879
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
5880
+
5881
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
5882
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
5883
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
5884
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
5885
+ <span class='kw'>end</span>
5886
+
5887
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
5888
+ <span class='kw'>end</span>
5889
+ <span class='kw'>end</span>
5890
+
5891
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
5397
5892
  </span> <span class='comment'>#
5398
5893
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
5399
5894
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -5695,7 +6190,33 @@ multiple locales.</p>
5695
6190
  353
5696
6191
  354
5697
6192
  355
5698
- 356</pre>
6193
+ 356
6194
+ 357
6195
+ 358
6196
+ 359
6197
+ 360
6198
+ 361
6199
+ 362
6200
+ 363
6201
+ 364
6202
+ 365
6203
+ 366
6204
+ 367
6205
+ 368
6206
+ 369
6207
+ 370
6208
+ 371
6209
+ 372
6210
+ 373
6211
+ 374
6212
+ 375
6213
+ 376
6214
+ 377
6215
+ 378
6216
+ 379
6217
+ 380
6218
+ 381
6219
+ 382</pre>
5699
6220
  </td>
5700
6221
  <td>
5701
6222
  <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 119</span>
@@ -5715,6 +6236,14 @@ multiple locales.</p>
5715
6236
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:updated_at</span>
5716
6237
  <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:metadata</span>
5717
6238
 
6239
+ <span class='comment'># The allowed string format for a datetime.
6240
+ </span> <span class='const'>ALLOWED_DATETIME_FORMATS</span> <span class='op'>=</span> <span class='lbracket'>[</span>
6241
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
6242
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%FT%T%Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %Z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T %z</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
6243
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%F</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
6244
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %T</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y %H:%M</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%d/%m/%Y</span><span class='tstring_end'>&quot;</span></span>
6245
+ <span class='rbracket'>]</span>
6246
+
5718
6247
  <span class='comment'># Creates a new content.
5719
6248
  </span> <span class='comment'>#
5720
6249
  </span> <span class='comment'># @param uid [String] The UID for this content.
@@ -5878,7 +6407,7 @@ multiple locales.</p>
5878
6407
  <span class='id identifier rubyid_content'>content</span>
5879
6408
  <span class='kw'>end</span>
5880
6409
 
5881
- <span class='comment'># Extract locales from metadata.
6410
+ <span class='comment'># Extracts locales from metadata.
5882
6411
  </span> <span class='comment'>#
5883
6412
  </span> <span class='comment'># @param metadata [Hash] The metadata that contains the locales.
5884
6413
  </span> <span class='comment'># @return [Array] The locales.
@@ -5888,7 +6417,7 @@ multiple locales.</p>
5888
6417
  <span class='id identifier rubyid_normalize_locales'>normalize_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='rparen'>)</span>
5889
6418
  <span class='kw'>end</span>
5890
6419
 
5891
- <span class='comment'># Normalize locales for further usage.
6420
+ <span class='comment'># Normalizes locales for further usage.
5892
6421
  </span> <span class='comment'>#
5893
6422
  </span> <span class='comment'># @param locales [Array] The locales to normalize.
5894
6423
  </span> <span class='comment'># @return [Array] The normalized locales.
@@ -5909,7 +6438,8 @@ multiple locales.</p>
5909
6438
  <span class='kw'>end</span>
5910
6439
  <span class='kw'>end</span>
5911
6440
 
5912
- <span class='comment'># Parse a datetime
6441
+ <span class='comment'># Parses a datetime.
6442
+ </span> <span class='comment'>#
5913
6443
  </span> <span class='comment'># @param value [String|DateTime|Fixnum] The value to parse.
5914
6444
  </span> <span class='comment'># @return [DateTime] The extracted value.
5915
6445
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime'>parse_datetime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
@@ -5917,12 +6447,29 @@ multiple locales.</p>
5917
6447
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>DateTime</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span>
5918
6448
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Date</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Time</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span>
5919
6449
  <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Float</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixnum</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>then</span>
5920
- <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='kw'>nil</span>
5921
- <span class='kw'>else</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%dT%H%M%S%z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
6450
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_float'>to_float</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_datetime'>to_datetime</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
6451
+ <span class='kw'>else</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
5922
6452
  <span class='kw'>end</span>
5923
6453
  <span class='kw'>end</span>
5924
6454
 
5925
- <span class='comment'># Extract tags from an array, making sure all the comma separated strings are evaluated.
6455
+ <span class='comment'># Parses a datetime string.
6456
+ </span> <span class='comment'>#
6457
+ </span> <span class='comment'># @param value [String] The value to parse.
6458
+ </span> <span class='comment'># @return [DateTime] The extracted value.
6459
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse_datetime_string'>parse_datetime_string</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
6460
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
6461
+
6462
+ <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='rparen'>)</span> <span class='kw'>do</span>
6463
+ <span class='const'>ALLOWED_DATETIME_FORMATS</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_format'>format</span><span class='op'>|</span>
6464
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span>
6465
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:parsed</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
6466
+ <span class='kw'>end</span>
6467
+
6468
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
6469
+ <span class='kw'>end</span>
6470
+ <span class='kw'>end</span>
6471
+
6472
+ <span class='comment'># Extracts tags from an array, making sure all the comma separated strings are evaluated.
5926
6473
  </span> <span class='comment'>#
5927
6474
  </span> <span class='comment'># @param value [String|Array] The string or array to parse.
5928
6475
  </span> <span class='comment'># @return [Array] The list of tags.
@@ -6026,15 +6573,15 @@ multiple locales.</p>
6026
6573
  <pre class="lines">
6027
6574
 
6028
6575
 
6029
- 269
6030
- 270
6031
- 271
6032
- 272
6033
- 273
6034
- 274</pre>
6576
+ 277
6577
+ 278
6578
+ 279
6579
+ 280
6580
+ 281
6581
+ 282</pre>
6035
6582
  </td>
6036
6583
  <td>
6037
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 269</span>
6584
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 277</span>
6038
6585
 
6039
6586
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_metadata'>metadata</span><span class='comma'>,</span> <span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
6040
6587
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Content</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
@@ -6139,15 +6686,15 @@ used.</p>
6139
6686
  <pre class="lines">
6140
6687
 
6141
6688
 
6142
- 257
6143
- 258
6144
- 259
6145
- 260
6146
- 261
6147
- 262</pre>
6689
+ 265
6690
+ 266
6691
+ 267
6692
+ 268
6693
+ 269
6694
+ 270</pre>
6148
6695
  </td>
6149
6696
  <td>
6150
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 257</span>
6697
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 265</span>
6151
6698
 
6152
6699
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
6153
6700
  <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='id identifier rubyid_l'>l</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='rbrace'>}</span>
@@ -6235,13 +6782,13 @@ The only supported value are:</p>
6235
6782
  <pre class="lines">
6236
6783
 
6237
6784
 
6238
- 246
6239
- 247
6240
- 248
6241
- 249</pre>
6785
+ 254
6786
+ 255
6787
+ 256
6788
+ 257</pre>
6242
6789
  </td>
6243
6790
  <td>
6244
- <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 246</span>
6791
+ <pre class="code"><span class="info file"># File 'lib/mbrao/content.rb', line 254</span>
6245
6792
 
6246
6793
  <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
6247
6794
  <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:uid</span><span class='comma'>,</span> <span class='symbol'>:locales</span><span class='comma'>,</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:summary</span><span class='comma'>,</span> <span class='symbol'>:body</span><span class='comma'>,</span> <span class='symbol'>:tags</span><span class='comma'>,</span> <span class='symbol'>:more</span><span class='comma'>,</span> <span class='symbol'>:author</span><span class='comma'>,</span> <span class='symbol'>:created_at</span><span class='comma'>,</span> <span class='symbol'>:updated_at</span><span class='comma'>,</span> <span class='symbol'>:metadata</span><span class='rbracket'>]</span>
@@ -6257,7 +6804,7 @@ The only supported value are:</p>
6257
6804
  </div>
6258
6805
 
6259
6806
  <div id="footer">
6260
- Generated on Sun Nov 24 16:21:17 2013 by
6807
+ Generated on Fri Nov 29 10:05:17 2013 by
6261
6808
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
6262
6809
  0.8.7.3 (ruby-2.0.0).
6263
6810
  </div>