apes 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rubocop.yml +82 -0
  4. data/.travis-gemfile +15 -0
  5. data/.travis.yml +15 -0
  6. data/.yardopts +1 -0
  7. data/CHANGELOG.md +3 -0
  8. data/Gemfile +22 -0
  9. data/README.md +177 -0
  10. data/Rakefile +44 -0
  11. data/apes.gemspec +34 -0
  12. data/doc/Apes.html +130 -0
  13. data/doc/Apes/Concerns.html +127 -0
  14. data/doc/Apes/Concerns/Errors.html +1089 -0
  15. data/doc/Apes/Concerns/Pagination.html +636 -0
  16. data/doc/Apes/Concerns/Request.html +766 -0
  17. data/doc/Apes/Concerns/Response.html +940 -0
  18. data/doc/Apes/Controller.html +1100 -0
  19. data/doc/Apes/Errors.html +125 -0
  20. data/doc/Apes/Errors/AuthenticationError.html +133 -0
  21. data/doc/Apes/Errors/BadRequestError.html +157 -0
  22. data/doc/Apes/Errors/BaseError.html +320 -0
  23. data/doc/Apes/Errors/InvalidDataError.html +157 -0
  24. data/doc/Apes/Errors/MissingDataError.html +157 -0
  25. data/doc/Apes/Model.html +378 -0
  26. data/doc/Apes/PaginationCursor.html +2138 -0
  27. data/doc/Apes/RuntimeConfiguration.html +909 -0
  28. data/doc/Apes/Serializers.html +125 -0
  29. data/doc/Apes/Serializers/JSON.html +389 -0
  30. data/doc/Apes/Serializers/JWT.html +452 -0
  31. data/doc/Apes/Serializers/List.html +347 -0
  32. data/doc/Apes/UrlsParser.html +1432 -0
  33. data/doc/Apes/Validators.html +125 -0
  34. data/doc/Apes/Validators/BaseValidator.html +278 -0
  35. data/doc/Apes/Validators/BooleanValidator.html +494 -0
  36. data/doc/Apes/Validators/EmailValidator.html +350 -0
  37. data/doc/Apes/Validators/PhoneValidator.html +375 -0
  38. data/doc/Apes/Validators/ReferenceValidator.html +372 -0
  39. data/doc/Apes/Validators/TimestampValidator.html +640 -0
  40. data/doc/Apes/Validators/UuidValidator.html +372 -0
  41. data/doc/Apes/Validators/ZipCodeValidator.html +372 -0
  42. data/doc/Apes/Version.html +189 -0
  43. data/doc/ApplicationController.html +547 -0
  44. data/doc/Concerns.html +128 -0
  45. data/doc/Concerns/ErrorHandling.html +826 -0
  46. data/doc/Concerns/PaginationHandling.html +463 -0
  47. data/doc/Concerns/RequestHandling.html +512 -0
  48. data/doc/Concerns/ResponseHandling.html +579 -0
  49. data/doc/Errors.html +126 -0
  50. data/doc/Errors/AuthenticationError.html +123 -0
  51. data/doc/Errors/BadRequestError.html +147 -0
  52. data/doc/Errors/BaseError.html +289 -0
  53. data/doc/Errors/InvalidDataError.html +147 -0
  54. data/doc/Errors/MissingDataError.html +147 -0
  55. data/doc/Model.html +315 -0
  56. data/doc/PaginationCursor.html +764 -0
  57. data/doc/Serializers.html +126 -0
  58. data/doc/Serializers/JSON.html +253 -0
  59. data/doc/Serializers/JWT.html +253 -0
  60. data/doc/Serializers/List.html +245 -0
  61. data/doc/Validators.html +126 -0
  62. data/doc/Validators/BaseValidator.html +209 -0
  63. data/doc/Validators/BooleanValidator.html +391 -0
  64. data/doc/Validators/EmailValidator.html +298 -0
  65. data/doc/Validators/PhoneValidator.html +313 -0
  66. data/doc/Validators/ReferenceValidator.html +284 -0
  67. data/doc/Validators/TimestampValidator.html +476 -0
  68. data/doc/Validators/UuidValidator.html +310 -0
  69. data/doc/Validators/ZipCodeValidator.html +310 -0
  70. data/doc/_index.html +435 -0
  71. data/doc/class_list.html +58 -0
  72. data/doc/css/common.css +1 -0
  73. data/doc/css/full_list.css +57 -0
  74. data/doc/css/style.css +339 -0
  75. data/doc/file.README.html +252 -0
  76. data/doc/file_list.html +60 -0
  77. data/doc/frames.html +26 -0
  78. data/doc/index.html +252 -0
  79. data/doc/js/app.js +219 -0
  80. data/doc/js/full_list.js +181 -0
  81. data/doc/js/jquery.js +4 -0
  82. data/doc/method_list.html +615 -0
  83. data/doc/top-level-namespace.html +112 -0
  84. data/lib/apes.rb +40 -0
  85. data/lib/apes/concerns/errors.rb +111 -0
  86. data/lib/apes/concerns/pagination.rb +81 -0
  87. data/lib/apes/concerns/request.rb +237 -0
  88. data/lib/apes/concerns/response.rb +74 -0
  89. data/lib/apes/controller.rb +77 -0
  90. data/lib/apes/errors.rb +38 -0
  91. data/lib/apes/model.rb +94 -0
  92. data/lib/apes/pagination_cursor.rb +152 -0
  93. data/lib/apes/runtime_configuration.rb +80 -0
  94. data/lib/apes/serializers.rb +88 -0
  95. data/lib/apes/urls_parser.rb +233 -0
  96. data/lib/apes/validators.rb +234 -0
  97. data/lib/apes/version.rb +24 -0
  98. data/spec/apes/concerns/errors_spec.rb +141 -0
  99. data/spec/apes/concerns/pagination_spec.rb +114 -0
  100. data/spec/apes/concerns/request_spec.rb +244 -0
  101. data/spec/apes/concerns/response_spec.rb +79 -0
  102. data/spec/apes/controller_spec.rb +54 -0
  103. data/spec/apes/errors_spec.rb +14 -0
  104. data/spec/apes/models_spec.rb +148 -0
  105. data/spec/apes/pagination_cursor_spec.rb +113 -0
  106. data/spec/apes/runtime_configuration_spec.rb +100 -0
  107. data/spec/apes/serializers_spec.rb +70 -0
  108. data/spec/apes/urls_parser_spec.rb +150 -0
  109. data/spec/apes/validators_spec.rb +237 -0
  110. data/spec/spec_helper.rb +30 -0
  111. data/views/_included.json.jbuilder +9 -0
  112. data/views/_pagination.json.jbuilder +9 -0
  113. data/views/collection.json.jbuilder +4 -0
  114. data/views/errors/400.json.jbuilder +9 -0
  115. data/views/errors/403.json.jbuilder +7 -0
  116. data/views/errors/404.json.jbuilder +6 -0
  117. data/views/errors/422.json.jbuilder +19 -0
  118. data/views/errors/500.json.jbuilder +12 -0
  119. data/views/errors/501.json.jbuilder +7 -0
  120. data/views/layouts/general.json.jbuilder +36 -0
  121. data/views/object.json.jbuilder +4 -0
  122. metadata +262 -0
@@ -0,0 +1,372 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Apes::Validators::ReferenceValidator
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!Apes/Validators/ReferenceValidator.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (R)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Apes.html" title="Apes (module)">Apes</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Validators.html" title="Apes::Validators (module)">Validators</a></span></span>
36
+ &raquo;
37
+ <span class="title">ReferenceValidator</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: Apes::Validators::ReferenceValidator
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName"><span class='object_link'><a href="BaseValidator.html" title="Apes::Validators::BaseValidator (class)">BaseValidator</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">ActiveModel::EachValidator</li>
82
+
83
+ <li class="next"><span class='object_link'><a href="BaseValidator.html" title="Apes::Validators::BaseValidator (class)">BaseValidator</a></span></li>
84
+
85
+ <li class="next">Apes::Validators::ReferenceValidator</li>
86
+
87
+ </ul>
88
+ <a href="#" class="inheritanceTree">show all</a>
89
+
90
+ </dd>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <dt class="r2 last">Defined in:</dt>
101
+ <dd class="r2 last">lib/apes/validators.rb</dd>
102
+
103
+ </dl>
104
+ <div class="clear"></div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+ <p>Validates references (relationships in the JSON API nomenclature).</p>
109
+
110
+
111
+ </div>
112
+ </div>
113
+ <div class="tags">
114
+
115
+
116
+ </div>
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+ <h2>
125
+ Instance Method Summary
126
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
127
+ </h2>
128
+
129
+ <ul class="summary">
130
+
131
+ <li class="public ">
132
+ <span class="summary_signature">
133
+
134
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Apes::Validators::ReferenceValidator) <strong>initialize</strong>(options) </a>
135
+
136
+
137
+
138
+ </span>
139
+
140
+
141
+ <span class="note title constructor">constructor</span>
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+ <span class="summary_desc"><div class='inline'><p>Creates a new validator.</p>
151
+ </div></span>
152
+
153
+ </li>
154
+
155
+
156
+ <li class="public ">
157
+ <span class="summary_signature">
158
+
159
+ <a href="#validate_each-instance_method" title="#validate_each (instance method)">- (Object) <strong>validate_each</strong>(model, attribute, values) </a>
160
+
161
+
162
+
163
+ </span>
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+ <span class="summary_desc"><div class='inline'><p>Perform validation on a attribute of a model.</p>
174
+ </div></span>
175
+
176
+ </li>
177
+
178
+
179
+ </ul>
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+ <div id="constructor_details" class="method_details_list">
190
+ <h2>Constructor Details</h2>
191
+
192
+ <div class="method_details first">
193
+ <h3 class="signature first" id="initialize-instance_method">
194
+
195
+ - (<tt><span class='object_link'><a href="" title="Apes::Validators::ReferenceValidator (class)">Apes::Validators::ReferenceValidator</a></span></tt>) <strong>initialize</strong>(options)
196
+
197
+
198
+
199
+
200
+
201
+ </h3><div class="docstring">
202
+ <div class="discussion">
203
+ <p>Creates a new validator.</p>
204
+
205
+
206
+ </div>
207
+ </div>
208
+ <div class="tags">
209
+ <p class="tag_title">Parameters:</p>
210
+ <ul class="param">
211
+
212
+ <li>
213
+
214
+ <span class='name'>options</span>
215
+
216
+
217
+ <span class='type'>(<tt>Hash</tt>)</span>
218
+
219
+
220
+
221
+ &mdash;
222
+ <div class='inline'><p>The options for the validations.</p>
223
+ </div>
224
+
225
+ </li>
226
+
227
+ </ul>
228
+
229
+
230
+ </div><table class="source_code">
231
+ <tr>
232
+ <td>
233
+ <pre class="lines">
234
+
235
+
236
+ 33
237
+ 34
238
+ 35
239
+ 36
240
+ 37</pre>
241
+ </td>
242
+ <td>
243
+ <pre class="code"><span class="info file"># File 'lib/apes/validators.rb', line 33</span>
244
+
245
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
246
+ <span class='ivar'>@class_name</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:class_name</span><span class='rbracket'>]</span>
247
+ <span class='id identifier rubyid_label'>label</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:label</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:class_name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span>
248
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_reverse_merge'>reverse_merge</span><span class='lparen'>(</span><span class='label'>default_message:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>must be a valid </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_label'>label</span><span class='embexpr_end'>}</span><span class='tstring_content'> (cannot find a </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_label'>label</span><span class='embexpr_end'>}</span><span class='tstring_content'> with id \&quot;%s\&quot;)</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
249
+ <span class='kw'>end</span></pre>
250
+ </td>
251
+ </tr>
252
+ </table>
253
+ </div>
254
+
255
+ </div>
256
+
257
+
258
+ <div id="instance_method_details" class="method_details_list">
259
+ <h2>Instance Method Details</h2>
260
+
261
+
262
+ <div class="method_details first">
263
+ <h3 class="signature first" id="validate_each-instance_method">
264
+
265
+ - (<tt>Object</tt>) <strong>validate_each</strong>(model, attribute, values)
266
+
267
+
268
+
269
+
270
+
271
+ </h3><div class="docstring">
272
+ <div class="discussion">
273
+ <p>Perform validation on a attribute of a model.</p>
274
+
275
+
276
+ </div>
277
+ </div>
278
+ <div class="tags">
279
+ <p class="tag_title">Parameters:</p>
280
+ <ul class="param">
281
+
282
+ <li>
283
+
284
+ <span class='name'>model</span>
285
+
286
+
287
+ <span class='type'>(<tt>Object</tt>)</span>
288
+
289
+
290
+
291
+ &mdash;
292
+ <div class='inline'><p>The object to validate.</p>
293
+ </div>
294
+
295
+ </li>
296
+
297
+ <li>
298
+
299
+ <span class='name'>attribute</span>
300
+
301
+
302
+ <span class='type'>(<tt>String|Symbol</tt>)</span>
303
+
304
+
305
+
306
+ &mdash;
307
+ <div class='inline'><p>The attribute to validate.</p>
308
+ </div>
309
+
310
+ </li>
311
+
312
+ <li>
313
+
314
+ <span class='name'>values</span>
315
+
316
+
317
+ <span class='type'>(<tt>Array</tt>)</span>
318
+
319
+
320
+
321
+ &mdash;
322
+ <div class='inline'><p>The values of the attribute.</p>
323
+ </div>
324
+
325
+ </li>
326
+
327
+ </ul>
328
+
329
+
330
+ </div><table class="source_code">
331
+ <tr>
332
+ <td>
333
+ <pre class="lines">
334
+
335
+
336
+ 44
337
+ 45
338
+ 46
339
+ 47
340
+ 48
341
+ 49
342
+ 50
343
+ 51</pre>
344
+ </td>
345
+ <td>
346
+ <pre class="code"><span class="info file"># File 'lib/apes/validators.rb', line 44</span>
347
+
348
+ <span class='kw'>def</span> <span class='id identifier rubyid_validate_each'>validate_each</span><span class='lparen'>(</span><span class='id identifier rubyid_model'>model</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
349
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='const'>Serializers</span><span class='op'>::</span><span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_values'>values</span><span class='comma'>,</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
350
+
351
+ <span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</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_value'>value</span><span class='op'>|</span>
352
+ <span class='id identifier rubyid_checked'>checked</span> <span class='op'>=</span> <span class='ivar'>@class_name</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='period'>.</span><span class='id identifier rubyid_constantize'>constantize</span><span class='period'>.</span><span class='id identifier rubyid_find_with_any'>find_with_any</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
353
+ <span class='id identifier rubyid_add_failure'>add_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_model'>model</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_checked'>checked</span>
354
+ <span class='kw'>end</span>
355
+ <span class='kw'>end</span></pre>
356
+ </td>
357
+ </tr>
358
+ </table>
359
+ </div>
360
+
361
+ </div>
362
+
363
+ </div>
364
+
365
+ <div id="footer">
366
+ Generated on Sat Jun 4 12:41:53 2016 by
367
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
368
+ 0.8.7.6 (ruby-2.3.0).
369
+ </div>
370
+
371
+ </body>
372
+ </html>
@@ -0,0 +1,640 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Apes::Validators::TimestampValidator
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!Apes/Validators/TimestampValidator.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (T)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Apes.html" title="Apes (module)">Apes</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Validators.html" title="Apes::Validators (module)">Validators</a></span></span>
36
+ &raquo;
37
+ <span class="title">TimestampValidator</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: Apes::Validators::TimestampValidator
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName"><span class='object_link'><a href="BaseValidator.html" title="Apes::Validators::BaseValidator (class)">BaseValidator</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">ActiveModel::EachValidator</li>
82
+
83
+ <li class="next"><span class='object_link'><a href="BaseValidator.html" title="Apes::Validators::BaseValidator (class)">BaseValidator</a></span></li>
84
+
85
+ <li class="next">Apes::Validators::TimestampValidator</li>
86
+
87
+ </ul>
88
+ <a href="#" class="inheritanceTree">show all</a>
89
+
90
+ </dd>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <dt class="r2 last">Defined in:</dt>
101
+ <dd class="r2 last">lib/apes/validators.rb</dd>
102
+
103
+ </dl>
104
+ <div class="clear"></div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+ <p>Validates timestamps.</p>
109
+
110
+
111
+ </div>
112
+ </div>
113
+ <div class="tags">
114
+
115
+
116
+ </div>
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+ <h2>
125
+ Class Method Summary
126
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
127
+ </h2>
128
+
129
+ <ul class="summary">
130
+
131
+ <li class="public ">
132
+ <span class="summary_signature">
133
+
134
+ <a href="#parse-class_method" title="parse (class method)">+ (DateTime|NilClass) <strong>parse</strong>(value, formats: nil, raise_errors: false) </a>
135
+
136
+
137
+
138
+ </span>
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+ <span class="summary_desc"><div class='inline'><p>Parses a timestamp value according to a list of formats.</p>
149
+ </div></span>
150
+
151
+ </li>
152
+
153
+
154
+ <li class="public ">
155
+ <span class="summary_signature">
156
+
157
+ <a href="#safe_parse-class_method" title="safe_parse (class method)">+ (DateTime|NilClass) <strong>safe_parse</strong>(value, format) </a>
158
+
159
+
160
+
161
+ </span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'><p>Parses a timestamp without raising exceptions.</p>
172
+ </div></span>
173
+
174
+ </li>
175
+
176
+
177
+ </ul>
178
+
179
+ <h2>
180
+ Instance Method Summary
181
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
182
+ </h2>
183
+
184
+ <ul class="summary">
185
+
186
+ <li class="public ">
187
+ <span class="summary_signature">
188
+
189
+ <a href="#check_valid%3F-instance_method" title="#check_valid? (instance method)">- (Boolean) <strong>check_valid?</strong>(value) </a>
190
+
191
+
192
+
193
+ </span>
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+ <span class="summary_desc"><div class='inline'><p>Checks if the value is valid for this validator.</p>
204
+ </div></span>
205
+
206
+ </li>
207
+
208
+
209
+ <li class="public ">
210
+ <span class="summary_signature">
211
+
212
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Apes::Validators::TimestampValidator) <strong>initialize</strong>(options) </a>
213
+
214
+
215
+
216
+ </span>
217
+
218
+
219
+ <span class="note title constructor">constructor</span>
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+ <span class="summary_desc"><div class='inline'><p>Creates a new validator.</p>
229
+ </div></span>
230
+
231
+ </li>
232
+
233
+
234
+ </ul>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="BaseValidator.html" title="Apes::Validators::BaseValidator (class)">BaseValidator</a></span></h3>
247
+ <p class="inherited"><span class='object_link'><a href="BaseValidator.html#validate_each-instance_method" title="Apes::Validators::BaseValidator#validate_each (method)">#validate_each</a></span></p>
248
+
249
+ <div id="constructor_details" class="method_details_list">
250
+ <h2>Constructor Details</h2>
251
+
252
+ <div class="method_details first">
253
+ <h3 class="signature first" id="initialize-instance_method">
254
+
255
+ - (<tt><span class='object_link'><a href="" title="Apes::Validators::TimestampValidator (class)">Apes::Validators::TimestampValidator</a></span></tt>) <strong>initialize</strong>(options)
256
+
257
+
258
+
259
+
260
+
261
+ </h3><div class="docstring">
262
+ <div class="discussion">
263
+ <p>Creates a new validator.</p>
264
+
265
+
266
+ </div>
267
+ </div>
268
+ <div class="tags">
269
+ <p class="tag_title">Parameters:</p>
270
+ <ul class="param">
271
+
272
+ <li>
273
+
274
+ <span class='name'>options</span>
275
+
276
+
277
+ <span class='type'>(<tt>Hash</tt>)</span>
278
+
279
+
280
+
281
+ &mdash;
282
+ <div class='inline'><p>The options for the validations.</p>
283
+ </div>
284
+
285
+ </li>
286
+
287
+ </ul>
288
+
289
+
290
+ </div><table class="source_code">
291
+ <tr>
292
+ <td>
293
+ <pre class="lines">
294
+
295
+
296
+ 221
297
+ 222
298
+ 223</pre>
299
+ </td>
300
+ <td>
301
+ <pre class="code"><span class="info file"># File 'lib/apes/validators.rb', line 221</span>
302
+
303
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
304
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_reverse_merge'>reverse_merge</span><span class='lparen'>(</span><span class='label'>default_message:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>must be a valid ISO 8601 timestamp</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
305
+ <span class='kw'>end</span></pre>
306
+ </td>
307
+ </tr>
308
+ </table>
309
+ </div>
310
+
311
+ </div>
312
+
313
+
314
+ <div id="class_method_details" class="method_details_list">
315
+ <h2>Class Method Details</h2>
316
+
317
+
318
+ <div class="method_details first">
319
+ <h3 class="signature first" id="parse-class_method">
320
+
321
+ + (<tt>DateTime|NilClass</tt>) <strong>parse</strong>(value, formats: nil, raise_errors: false)
322
+
323
+
324
+
325
+
326
+
327
+ </h3><div class="docstring">
328
+ <div class="discussion">
329
+ <p>Parses a timestamp value according to a list of formats.</p>
330
+
331
+
332
+ </div>
333
+ </div>
334
+ <div class="tags">
335
+ <p class="tag_title">Parameters:</p>
336
+ <ul class="param">
337
+
338
+ <li>
339
+
340
+ <span class='name'>value</span>
341
+
342
+
343
+ <span class='type'>(<tt>Object</tt>)</span>
344
+
345
+
346
+
347
+ &mdash;
348
+ <div class='inline'><p>The value to parse.</p>
349
+ </div>
350
+
351
+ </li>
352
+
353
+ <li>
354
+
355
+ <span class='name'>formats</span>
356
+
357
+
358
+ <span class='type'>(<tt>Array|NilClass</tt>)</span>
359
+
360
+
361
+
362
+ &mdash;
363
+ <div class='inline'><p>A list of valid formats (see strftime). Will fallback to formats defined in Rails configuration.</p>
364
+ </div>
365
+
366
+ </li>
367
+
368
+ <li>
369
+
370
+ <span class='name'>raise_errors</span>
371
+
372
+
373
+ <span class='type'>(<tt>Boolean</tt>)</span>
374
+
375
+
376
+
377
+ &mdash;
378
+ <div class='inline'><p>Whether to raise errors in case the value couldn’t be parsed with any format.</p>
379
+ </div>
380
+
381
+ </li>
382
+
383
+ </ul>
384
+
385
+ <p class="tag_title">Returns:</p>
386
+ <ul class="return">
387
+
388
+ <li>
389
+
390
+
391
+ <span class='type'>(<tt>DateTime|NilClass</tt>)</span>
392
+
393
+
394
+
395
+ &mdash;
396
+ <div class='inline'><p>A <code>DateTime</code> if parsing succeded, <code>nil</code> otherwise.</p>
397
+ </div>
398
+
399
+ </li>
400
+
401
+ </ul>
402
+ <p class="tag_title">Raises:</p>
403
+ <ul class="raise">
404
+
405
+ <li>
406
+
407
+
408
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
409
+
410
+
411
+
412
+ </li>
413
+
414
+ </ul>
415
+
416
+ </div><table class="source_code">
417
+ <tr>
418
+ <td>
419
+ <pre class="lines">
420
+
421
+
422
+ 188
423
+ 189
424
+ 190
425
+ 191
426
+ 192
427
+ 193
428
+ 194
429
+ 195
430
+ 196
431
+ 197
432
+ 198
433
+ 199
434
+ 200
435
+ 201
436
+ 202
437
+ 203
438
+ 204
439
+ 205</pre>
440
+ </td>
441
+ <td>
442
+ <pre class="code"><span class="info file"># File 'lib/apes/validators.rb', line 188</span>
443
+
444
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='label'>formats:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>raise_errors:</span> <span class='kw'>false</span><span class='rparen'>)</span>
445
+ <span class='kw'>return</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='lbracket'>[</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeWithZone</span><span class='comma'>,</span> <span class='const'>DateTime</span><span class='comma'>,</span> <span class='const'>Date</span><span class='comma'>,</span> <span class='const'>Time</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rparen'>)</span>
446
+
447
+ <span class='id identifier rubyid_formats'>formats</span> <span class='op'>||=</span> <span class='const'>Apes</span><span class='op'>::</span><span class='const'>RuntimeConfiguration</span><span class='period'>.</span><span class='id identifier rubyid_timestamp_formats'>timestamp_formats</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span>
448
+
449
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='rparen'>)</span> <span class='kw'>do</span>
450
+ <span class='id identifier rubyid_formats'>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>
451
+ <span class='id identifier rubyid_parsed'>parsed</span> <span class='op'>=</span> <span class='id identifier rubyid_safe_parse'>safe_parse</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>
452
+
453
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='comma'>,</span> <span class='id identifier rubyid_parsed'>parsed</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_parsed'>parsed</span>
454
+ <span class='kw'>end</span>
455
+
456
+ <span class='kw'>nil</span>
457
+ <span class='kw'>end</span>
458
+
459
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid timestamp \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot;.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_rv'>rv</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_raise_errors'>raise_errors</span>
460
+ <span class='id identifier rubyid_rv'>rv</span>
461
+ <span class='kw'>end</span></pre>
462
+ </td>
463
+ </tr>
464
+ </table>
465
+ </div>
466
+
467
+ <div class="method_details ">
468
+ <h3 class="signature " id="safe_parse-class_method">
469
+
470
+ + (<tt>DateTime|NilClass</tt>) <strong>safe_parse</strong>(value, format)
471
+
472
+
473
+
474
+
475
+
476
+ </h3><div class="docstring">
477
+ <div class="discussion">
478
+ <p>Parses a timestamp without raising exceptions.</p>
479
+
480
+
481
+ </div>
482
+ </div>
483
+ <div class="tags">
484
+ <p class="tag_title">Parameters:</p>
485
+ <ul class="param">
486
+
487
+ <li>
488
+
489
+ <span class='name'>value</span>
490
+
491
+
492
+ <span class='type'>(<tt>String</tt>)</span>
493
+
494
+
495
+
496
+ &mdash;
497
+ <div class='inline'><p>The value to parse.</p>
498
+ </div>
499
+
500
+ </li>
501
+
502
+ </ul>
503
+
504
+ <p class="tag_title">Returns:</p>
505
+ <ul class="return">
506
+
507
+ <li>
508
+
509
+
510
+ <span class='type'>(<tt>DateTime|NilClass</tt>)</span>
511
+
512
+
513
+
514
+ &mdash;
515
+ <div class='inline'><p>A <code>DateTime</code> if parsing succeded, <code>nil</code> otherwise.</p>
516
+ </div>
517
+
518
+ </li>
519
+
520
+ </ul>
521
+
522
+ </div><table class="source_code">
523
+ <tr>
524
+ <td>
525
+ <pre class="lines">
526
+
527
+
528
+ 211
529
+ 212
530
+ 213
531
+ 214
532
+ 215</pre>
533
+ </td>
534
+ <td>
535
+ <pre class="code"><span class="info file"># File 'lib/apes/validators.rb', line 211</span>
536
+
537
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_safe_parse'>safe_parse</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>
538
+ <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>
539
+ <span class='kw'>rescue</span>
540
+ <span class='kw'>nil</span>
541
+ <span class='kw'>end</span></pre>
542
+ </td>
543
+ </tr>
544
+ </table>
545
+ </div>
546
+
547
+ </div>
548
+
549
+ <div id="instance_method_details" class="method_details_list">
550
+ <h2>Instance Method Details</h2>
551
+
552
+
553
+ <div class="method_details first">
554
+ <h3 class="signature first" id="check_valid?-instance_method">
555
+
556
+ - (<tt>Boolean</tt>) <strong>check_valid?</strong>(value)
557
+
558
+
559
+
560
+
561
+
562
+ </h3><div class="docstring">
563
+ <div class="discussion">
564
+ <p>Checks if the value is valid for this validator.</p>
565
+
566
+
567
+ </div>
568
+ </div>
569
+ <div class="tags">
570
+ <p class="tag_title">Parameters:</p>
571
+ <ul class="param">
572
+
573
+ <li>
574
+
575
+ <span class='name'>value</span>
576
+
577
+
578
+ <span class='type'>(<tt>Object</tt>)</span>
579
+
580
+
581
+
582
+ &mdash;
583
+ <div class='inline'><p>The value to validate.</p>
584
+ </div>
585
+
586
+ </li>
587
+
588
+ </ul>
589
+
590
+ <p class="tag_title">Returns:</p>
591
+ <ul class="return">
592
+
593
+ <li>
594
+
595
+
596
+ <span class='type'>(<tt>Boolean</tt>)</span>
597
+
598
+
599
+
600
+ &mdash;
601
+ <div class='inline'><p><code>true</code> if the value is valid, false otherwise.</p>
602
+ </div>
603
+
604
+ </li>
605
+
606
+ </ul>
607
+
608
+ </div><table class="source_code">
609
+ <tr>
610
+ <td>
611
+ <pre class="lines">
612
+
613
+
614
+ 229
615
+ 230
616
+ 231</pre>
617
+ </td>
618
+ <td>
619
+ <pre class="code"><span class="info file"># File 'lib/apes/validators.rb', line 229</span>
620
+
621
+ <span class='kw'>def</span> <span class='id identifier rubyid_check_valid?'>check_valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
622
+ <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='const'>TimestampValidator</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='label'>formats:</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:formats</span><span class='rbracket'>]</span><span class='rparen'>)</span>
623
+ <span class='kw'>end</span></pre>
624
+ </td>
625
+ </tr>
626
+ </table>
627
+ </div>
628
+
629
+ </div>
630
+
631
+ </div>
632
+
633
+ <div id="footer">
634
+ Generated on Sat Jun 4 12:41:54 2016 by
635
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
636
+ 0.8.7.6 (ruby-2.3.0).
637
+ </div>
638
+
639
+ </body>
640
+ </html>