mbrao 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/doc/ActionView/Template/Handlers/MbraoTemplate.html +1 -1
- data/doc/ActionView/Template/Handlers.html +1 -1
- data/doc/HTML/Pipeline/KramdownFilter.html +1 -1
- data/doc/HTML/Pipeline.html +1 -1
- data/doc/HTML.html +1 -1
- data/doc/Mbrao/Author.html +1 -1
- data/doc/Mbrao/Content.html +641 -94
- data/doc/Mbrao/ContentPublicInterface.html +1 -1
- data/doc/Mbrao/Exceptions/InvalidDate.html +1 -1
- data/doc/Mbrao/Exceptions/InvalidMetadata.html +1 -1
- data/doc/Mbrao/Exceptions/Parsing.html +1 -1
- data/doc/Mbrao/Exceptions/Rendering.html +1 -1
- data/doc/Mbrao/Exceptions/UnavailableLocalization.html +1 -1
- data/doc/Mbrao/Exceptions/Unimplemented.html +1 -1
- data/doc/Mbrao/Exceptions/UnknownEngine.html +1 -1
- data/doc/Mbrao/Exceptions.html +1 -1
- data/doc/Mbrao/Parser.html +1 -1
- data/doc/Mbrao/ParsingEngines/Base.html +1 -1
- data/doc/Mbrao/ParsingEngines/PlainText.html +1 -1
- data/doc/Mbrao/ParsingEngines.html +1 -1
- data/doc/Mbrao/PublicInterface/ClassMethods.html +1 -1
- data/doc/Mbrao/PublicInterface.html +1 -1
- data/doc/Mbrao/RenderingEngines/Base.html +1 -1
- data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +1 -1
- data/doc/Mbrao/RenderingEngines.html +1 -1
- data/doc/Mbrao/Validations/ClassMethods.html +1 -1
- data/doc/Mbrao/Validations.html +1 -1
- data/doc/Mbrao/Version.html +2 -2
- data/doc/Mbrao.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/mbrao/content.rb +33 -7
- data/lib/mbrao/version.rb +1 -1
- data/spec/mbrao/content_spec.rb +35 -2
- metadata +2 -2
@@ -653,7 +653,7 @@ is returned, else a <code>HashWithIndifferentAccess</code> with locales as keys.
|
|
653
653
|
</div>
|
654
654
|
|
655
655
|
<div id="footer">
|
656
|
-
Generated on
|
656
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
657
657
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
658
658
|
0.8.7.3 (ruby-2.0.0).
|
659
659
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.7.3 (ruby-2.0.0).
|
130
130
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.7.3 (ruby-2.0.0).
|
130
130
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.7.3 (ruby-2.0.0).
|
130
130
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.7.3 (ruby-2.0.0).
|
130
130
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.7.3 (ruby-2.0.0).
|
130
130
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.7.3 (ruby-2.0.0).
|
130
130
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.7.3 (ruby-2.0.0).
|
130
130
|
</div>
|
data/doc/Mbrao/Exceptions.html
CHANGED
@@ -116,7 +116,7 @@
|
|
116
116
|
</div>
|
117
117
|
|
118
118
|
<div id="footer">
|
119
|
-
Generated on
|
119
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
121
|
0.8.7.3 (ruby-2.0.0).
|
122
122
|
</div>
|
data/doc/Mbrao/Parser.html
CHANGED
@@ -409,7 +409,7 @@
|
|
409
409
|
</div>
|
410
410
|
|
411
411
|
<div id="footer">
|
412
|
-
Generated on
|
412
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
413
413
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
414
414
|
0.8.7.3 (ruby-2.0.0).
|
415
415
|
</div>
|
@@ -650,7 +650,7 @@ returned, else a <code>HashWithIndifferentAccess</code> with locales as keys.</p
|
|
650
650
|
</div>
|
651
651
|
|
652
652
|
<div id="footer">
|
653
|
-
Generated on
|
653
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
654
654
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
655
655
|
0.8.7.3 (ruby-2.0.0).
|
656
656
|
</div>
|
@@ -563,7 +563,7 @@ returned, else a <code>HashWithIndifferentAccess</code> with locales as keys.</p
|
|
563
563
|
</div>
|
564
564
|
|
565
565
|
<div id="footer">
|
566
|
-
Generated on
|
566
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
567
567
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
568
568
|
0.8.7.3 (ruby-2.0.0).
|
569
569
|
</div>
|
@@ -118,7 +118,7 @@
|
|
118
118
|
</div>
|
119
119
|
|
120
120
|
<div id="footer">
|
121
|
-
Generated on
|
121
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
122
122
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
123
123
|
0.8.7.3 (ruby-2.0.0).
|
124
124
|
</div>
|
@@ -1706,7 +1706,7 @@ The only supported value are:</p>
|
|
1706
1706
|
</div>
|
1707
1707
|
|
1708
1708
|
<div id="footer">
|
1709
|
-
Generated on
|
1709
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
1710
1710
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1711
1711
|
0.8.7.3 (ruby-2.0.0).
|
1712
1712
|
</div>
|
@@ -125,7 +125,7 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
<div id="footer">
|
128
|
-
Generated on
|
128
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
129
129
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
130
130
|
0.8.7.3 (ruby-2.0.0).
|
131
131
|
</div>
|
@@ -271,7 +271,7 @@
|
|
271
271
|
</div>
|
272
272
|
|
273
273
|
<div id="footer">
|
274
|
-
Generated on
|
274
|
+
Generated on Fri Nov 29 10:05:17 2013 by
|
275
275
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
276
276
|
0.8.7.3 (ruby-2.0.0).
|
277
277
|
</div>
|
@@ -876,7 +876,7 @@
|
|
876
876
|
</div>
|
877
877
|
|
878
878
|
<div id="footer">
|
879
|
-
Generated on
|
879
|
+
Generated on Fri Nov 29 10:05:18 2013 by
|
880
880
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
881
881
|
0.8.7.3 (ruby-2.0.0).
|
882
882
|
</div>
|
@@ -118,7 +118,7 @@
|
|
118
118
|
</div>
|
119
119
|
|
120
120
|
<div id="footer">
|
121
|
-
Generated on
|
121
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
122
122
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
123
123
|
0.8.7.3 (ruby-2.0.0).
|
124
124
|
</div>
|
@@ -345,7 +345,7 @@
|
|
345
345
|
</div>
|
346
346
|
|
347
347
|
<div id="footer">
|
348
|
-
Generated on
|
348
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
349
349
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
350
350
|
0.8.7.3 (ruby-2.0.0).
|
351
351
|
</div>
|
data/doc/Mbrao/Validations.html
CHANGED
@@ -125,7 +125,7 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
<div id="footer">
|
128
|
-
Generated on
|
128
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
129
129
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
130
130
|
0.8.7.3 (ruby-2.0.0).
|
131
131
|
</div>
|
data/doc/Mbrao/Version.html
CHANGED
@@ -149,7 +149,7 @@
|
|
149
149
|
|
150
150
|
</div>
|
151
151
|
</dt>
|
152
|
-
<dd><pre class="code"><span class='int'>
|
152
|
+
<dd><pre class="code"><span class='int'>2</span></pre></dd>
|
153
153
|
|
154
154
|
<dt id="STRING-constant" class="">STRING =
|
155
155
|
<div class="docstring">
|
@@ -180,7 +180,7 @@
|
|
180
180
|
</div>
|
181
181
|
|
182
182
|
<div id="footer">
|
183
|
-
Generated on
|
183
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
184
184
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
185
|
0.8.7.3 (ruby-2.0.0).
|
186
186
|
</div>
|
data/doc/Mbrao.html
CHANGED
@@ -121,7 +121,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
|
|
121
121
|
</div>
|
122
122
|
|
123
123
|
<div id="footer">
|
124
|
-
Generated on
|
124
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
125
125
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
126
126
|
0.8.7.3 (ruby-2.0.0).
|
127
127
|
</div>
|
data/doc/_index.html
CHANGED
@@ -386,7 +386,7 @@
|
|
386
386
|
</div>
|
387
387
|
|
388
388
|
<div id="footer">
|
389
|
-
Generated on
|
389
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
390
390
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
391
391
|
0.8.7.3 (ruby-2.0.0).
|
392
392
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -130,7 +130,7 @@ Mbrao::Parser.render(content)
|
|
130
130
|
</div></div>
|
131
131
|
|
132
132
|
<div id="footer">
|
133
|
-
Generated on
|
133
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
134
134
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
135
135
|
0.8.7.3 (ruby-2.0.0).
|
136
136
|
</div>
|
data/doc/index.html
CHANGED
@@ -130,7 +130,7 @@ Mbrao::Parser.render(content)
|
|
130
130
|
</div></div>
|
131
131
|
|
132
132
|
<div id="footer">
|
133
|
-
Generated on
|
133
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
134
134
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
135
135
|
0.8.7.3 (ruby-2.0.0).
|
136
136
|
</div>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Fri Nov 29 10:05:16 2013 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.3 (ruby-2.0.0).
|
109
109
|
</div>
|
data/lib/mbrao/content.rb
CHANGED
@@ -131,6 +131,14 @@ module Mbrao
|
|
131
131
|
attr_accessor :updated_at
|
132
132
|
attr_accessor :metadata
|
133
133
|
|
134
|
+
# The allowed string format for a datetime.
|
135
|
+
ALLOWED_DATETIME_FORMATS = [
|
136
|
+
"%Y%m%dT%H%M%S%z", "%Y%m%dT%H%M%S%Z",
|
137
|
+
"%FT%T%z", "%FT%T%Z", "%F %T %Z", "%F %T %z",
|
138
|
+
"%F %T", "%F %H:%M", "%F",
|
139
|
+
"%d/%m/%Y %T", "%d/%m/%Y %H:%M", "%d/%m/%Y"
|
140
|
+
]
|
141
|
+
|
134
142
|
# Creates a new content.
|
135
143
|
#
|
136
144
|
# @param uid [String] The UID for this content.
|
@@ -294,7 +302,7 @@ module Mbrao
|
|
294
302
|
content
|
295
303
|
end
|
296
304
|
|
297
|
-
#
|
305
|
+
# Extracts locales from metadata.
|
298
306
|
#
|
299
307
|
# @param metadata [Hash] The metadata that contains the locales.
|
300
308
|
# @return [Array] The locales.
|
@@ -304,7 +312,7 @@ module Mbrao
|
|
304
312
|
normalize_locales(locales)
|
305
313
|
end
|
306
314
|
|
307
|
-
#
|
315
|
+
# Normalizes locales for further usage.
|
308
316
|
#
|
309
317
|
# @param locales [Array] The locales to normalize.
|
310
318
|
# @return [Array] The normalized locales.
|
@@ -325,7 +333,8 @@ module Mbrao
|
|
325
333
|
end
|
326
334
|
end
|
327
335
|
|
328
|
-
#
|
336
|
+
# Parses a datetime.
|
337
|
+
#
|
329
338
|
# @param value [String|DateTime|Fixnum] The value to parse.
|
330
339
|
# @return [DateTime] The extracted value.
|
331
340
|
def parse_datetime(value)
|
@@ -333,12 +342,29 @@ module Mbrao
|
|
333
342
|
when "DateTime" then value
|
334
343
|
when "Date", "Time" then value.to_datetime
|
335
344
|
when "Float", "Fixnum" then
|
336
|
-
value.to_float > 0 ? Time.at(value.to_float).to_datetime :
|
337
|
-
else
|
345
|
+
value.to_float > 0 ? Time.at(value.to_float).to_datetime : raise(ArgumentError.new)
|
346
|
+
else parse_datetime_string(value)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
# Parses a datetime string.
|
351
|
+
#
|
352
|
+
# @param value [String] The value to parse.
|
353
|
+
# @return [DateTime] The extracted value.
|
354
|
+
def parse_datetime_string(value)
|
355
|
+
value = value.ensure_string
|
356
|
+
|
357
|
+
catch(:parsed) do
|
358
|
+
ALLOWED_DATETIME_FORMATS.each do |format|
|
359
|
+
rv = DateTime.strptime(value, format) rescue nil
|
360
|
+
throw(:parsed, rv) if rv
|
361
|
+
end
|
362
|
+
|
363
|
+
raise(ArgumentError.new)
|
338
364
|
end
|
339
365
|
end
|
340
366
|
|
341
|
-
#
|
367
|
+
# Extracts tags from an array, making sure all the comma separated strings are evaluated.
|
342
368
|
#
|
343
369
|
# @param value [String|Array] The string or array to parse.
|
344
370
|
# @return [Array] The list of tags.
|
@@ -354,4 +380,4 @@ module Mbrao
|
|
354
380
|
value.is_a?(Hash)
|
355
381
|
end
|
356
382
|
end
|
357
|
-
end
|
383
|
+
end
|
data/lib/mbrao/version.rb
CHANGED
data/spec/mbrao/content_spec.rb
CHANGED
@@ -116,10 +116,43 @@ describe Mbrao::Content do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should try to parse everything else as a ISO8601 format" do
|
119
|
-
subject.send("#{attribute}=", "
|
119
|
+
subject.send("#{attribute}=", "20120808T083045-0200")
|
120
120
|
value = subject.send(attribute)
|
121
121
|
expect(value).to be_a(DateTime)
|
122
|
-
expect(value.strftime("%Y%m%dT%H%M%S%z")).to eq("
|
122
|
+
expect(value.strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T103045+0000")
|
123
|
+
|
124
|
+
subject.send("#{attribute}=", "20120808T083045-02:00")
|
125
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T103045+0000")
|
126
|
+
|
127
|
+
subject.send("#{attribute}=", "2012-08-08T08:30:45-0200")
|
128
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T103045+0000")
|
129
|
+
|
130
|
+
subject.send("#{attribute}=", "2012-08-08T08:30:45-02:00")
|
131
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T103045+0000")
|
132
|
+
|
133
|
+
subject.send("#{attribute}=", "2012-08-08 08:30:45 -0200")
|
134
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T103045+0000")
|
135
|
+
|
136
|
+
subject.send("#{attribute}=", "2012-08-08 08:30:45 -02:00")
|
137
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T103045+0000")
|
138
|
+
|
139
|
+
subject.send("#{attribute}=", "2012-08-08")
|
140
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T000000+0000")
|
141
|
+
|
142
|
+
subject.send("#{attribute}=", "2012-08-08 08:30:45")
|
143
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T083045+0000")
|
144
|
+
|
145
|
+
subject.send("#{attribute}=", "2012-08-08 08:30")
|
146
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120808T083000+0000")
|
147
|
+
|
148
|
+
subject.send("#{attribute}=", "08/09/2012")
|
149
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120908T000000+0000")
|
150
|
+
|
151
|
+
subject.send("#{attribute}=", "08/09/2012 08:30:45")
|
152
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120908T083045+0000")
|
153
|
+
|
154
|
+
subject.send("#{attribute}=", "08/09/2012 08:30")
|
155
|
+
expect(subject.send(attribute).strftime("%Y%m%dT%H%M%S%z")).to eq("20120908T083000+0000")
|
123
156
|
|
124
157
|
expect { subject.send("#{attribute}=", "ABC") }.to raise_error(Mbrao::Exceptions::InvalidDate)
|
125
158
|
expect { subject.send("#{attribute}=", []) }.to raise_error(Mbrao::Exceptions::InvalidDate)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mbrao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shogun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lazier
|