lazier 2.8.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/Gemfile +3 -3
  2. data/doc/Lazier.html +69 -99
  3. data/doc/Lazier/Boolean.html +6 -6
  4. data/doc/Lazier/DateTime.html +35 -39
  5. data/doc/Lazier/DateTime/ClassMethods.html +59 -85
  6. data/doc/Lazier/Exceptions.html +6 -6
  7. data/doc/Lazier/Exceptions/Debug.html +133 -0
  8. data/doc/Lazier/Exceptions/MissingTranslation.html +8 -8
  9. data/doc/Lazier/Hash.html +5 -270
  10. data/doc/Lazier/I18n.html +68 -26
  11. data/doc/Lazier/Localizer.html +17 -21
  12. data/doc/Lazier/Math.html +5 -5
  13. data/doc/Lazier/Math/ClassMethods.html +5 -5
  14. data/doc/Lazier/Object.html +681 -218
  15. data/doc/Lazier/Pathname.html +7 -11
  16. data/doc/Lazier/Settings.html +166 -262
  17. data/doc/Lazier/String.html +21 -25
  18. data/doc/Lazier/TimeZone.html +119 -130
  19. data/doc/Lazier/TimeZone/ClassMethods.html +75 -83
  20. data/doc/Lazier/Version.html +8 -8
  21. data/doc/_index.html +7 -7
  22. data/doc/class_list.html +2 -2
  23. data/doc/file.README.html +5 -5
  24. data/doc/file_list.html +1 -1
  25. data/doc/frames.html +1 -1
  26. data/doc/index.html +5 -5
  27. data/doc/js/full_list.js +6 -1
  28. data/doc/method_list.html +134 -324
  29. data/doc/top-level-namespace.html +5 -5
  30. data/lazier.gemspec +4 -3
  31. data/lib/lazier.rb +9 -23
  32. data/lib/lazier/boolean.rb +1 -1
  33. data/lib/lazier/datetime.rb +47 -79
  34. data/lib/lazier/exceptions.rb +4 -4
  35. data/lib/lazier/hash.rb +0 -24
  36. data/lib/lazier/i18n.rb +13 -6
  37. data/lib/lazier/localizer.rb +3 -5
  38. data/lib/lazier/object.rb +107 -78
  39. data/lib/lazier/pathname.rb +1 -3
  40. data/lib/lazier/settings.rb +22 -30
  41. data/lib/lazier/string.rb +3 -5
  42. data/lib/lazier/version.rb +3 -3
  43. data/spec/lazier/datetime_spec.rb +8 -8
  44. data/spec/lazier/hash_spec.rb +9 -10
  45. data/spec/lazier/object_spec.rb +85 -11
  46. data/spec/lazier/settings_spec.rb +10 -17
  47. data/spec/lazier_spec.rb +1 -1
  48. metadata +26 -9
@@ -6,13 +6,13 @@
6
6
  <title>
7
7
  Exception: Lazier::Exceptions::MissingTranslation
8
8
 
9
- &mdash; Documentation by YARD 0.8.5.2
9
+ &mdash; Documentation by YARD 0.8.6.1
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
14
 
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
16
 
17
17
  <script type="text/javascript" charset="utf-8">
18
18
  hasFrames = window.top.frames.main ? true : false;
@@ -73,12 +73,12 @@
73
73
 
74
74
  <dt class="r1">Inherits:</dt>
75
75
  <dd class="r1">
76
- <span class="inheritName">Exception</span>
76
+ <span class="inheritName">StandardError</span>
77
77
 
78
78
  <ul class="fullTree">
79
79
  <li>Object</li>
80
80
 
81
- <li class="next">Exception</li>
81
+ <li class="next">StandardError</li>
82
82
 
83
83
  <li class="next">Lazier::Exceptions::MissingTranslation</li>
84
84
 
@@ -225,7 +225,7 @@
225
225
  <pre class="code"><span class="info file"># File 'lib/lazier/exceptions.rb', line 20</span>
226
226
 
227
227
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
228
- <span class='kw'>super</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to load any of the following translation in </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
228
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to load any of the following translation in </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_locales'>locales</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>, </span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
229
229
  <span class='kw'>end</span></pre>
230
230
  </td>
231
231
  </tr>
@@ -238,9 +238,9 @@
238
238
  </div>
239
239
 
240
240
  <div id="footer">
241
- Generated on Sat Apr 13 11:56:54 2013 by
241
+ Generated on Fri May 17 12:03:22 2013 by
242
242
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
243
- 0.8.5.2 (ruby-1.9.3).
243
+ 0.8.6.1 (ruby-1.9.3).
244
244
  </div>
245
245
 
246
246
  </body>
data/doc/Lazier/Hash.html CHANGED
@@ -6,13 +6,13 @@
6
6
  <title>
7
7
  Module: Lazier::Hash
8
8
 
9
- &mdash; Documentation by YARD 0.8.5.2
9
+ &mdash; Documentation by YARD 0.8.6.1
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
14
 
15
- <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
16
 
17
17
  <script type="text/javascript" charset="utf-8">
18
18
  hasFrames = window.top.frames.main ? true : false;
@@ -105,280 +105,15 @@
105
105
 
106
106
 
107
107
 
108
-
109
- <h2>
110
- Instance Method Summary
111
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
112
- </h2>
113
-
114
- <ul class="summary">
115
-
116
- <li class="public ">
117
- <span class="summary_signature">
118
-
119
- <a href="#method_missing-instance_method" title="#method_missing (instance method)">- (Object) <strong>method_missing</strong>(method, *args, &amp;block) </a>
120
-
121
-
122
-
123
- </span>
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
- <span class="summary_desc"><div class='inline'><p>This is called when the user access a member using dotted notation.</p>
134
- </div></span>
135
-
136
- </li>
137
-
138
-
139
- <li class="public ">
140
- <span class="summary_signature">
141
-
142
- <a href="#respond_to%3F-instance_method" title="#respond_to? (instance method)">- (Boolean) <strong>respond_to?</strong>(method) </a>
143
-
144
-
145
-
146
- </span>
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
- <span class="summary_desc"><div class='inline'><p>This is called when the user access a member using dotted notation.</p>
157
- </div></span>
158
-
159
- </li>
160
-
161
-
162
- </ul>
163
-
164
-
165
-
166
- <div id="method_missing_details" class="method_details_list">
167
- <h2>Dynamic Method Handling</h2>
168
- <p class="notice this">
169
- This class handles dynamic methods through the <tt>method_missing</tt> method
170
-
171
- </p>
172
-
173
- <div class="method_details first">
174
- <h3 class="signature first" id="method_missing-instance_method">
175
-
176
- - (<tt><span class='object_link'><a href="Object.html" title="Lazier::Object (module)">Object</a></span></tt>) <strong>method_missing</strong>(method, *args, &amp;block)
177
-
178
-
179
-
180
-
181
-
182
- </h3><div class="docstring">
183
- <div class="discussion">
184
- <p>This is called when the user access a member using dotted notation.</p>
185
-
186
-
187
- </div>
188
- </div>
189
- <div class="tags">
190
- <p class="tag_title">Parameters:</p>
191
- <ul class="param">
192
-
193
- <li>
194
-
195
- <span class='name'>method</span>
196
-
197
-
198
- <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|Symbol</tt>)</span>
199
-
200
-
201
-
202
- &mdash;
203
- <div class='inline'><p>Key to search.</p>
204
- </div>
205
-
206
- </li>
207
-
208
- <li>
209
-
210
- <span class='name'>args</span>
211
-
212
-
213
- <span class='type'>(<tt>Array</tt>)</span>
214
-
215
-
216
-
217
- &mdash;
218
- <div class='inline'><p><em>Unused.</em></p>
219
- </div>
220
-
221
- </li>
222
-
223
- <li>
224
-
225
- <span class='name'>block</span>
226
-
227
-
228
- <span class='type'>(<tt>Proc</tt>)</span>
229
-
230
-
231
-
232
- &mdash;
233
- <div class='inline'><p><em>Unused.</em></p>
234
- </div>
235
-
236
- </li>
237
-
238
- </ul>
239
108
 
240
- <p class="tag_title">Returns:</p>
241
- <ul class="return">
242
109
 
243
- <li>
244
-
245
-
246
- <span class='type'>(<tt><span class='object_link'><a href="Object.html" title="Lazier::Object (module)">Object</a></span></tt>)</span>
247
-
248
-
249
-
250
- &mdash;
251
- <div class='inline'><p>The value for the key.</p>
252
- </div>
253
-
254
- </li>
255
-
256
- </ul>
257
-
258
- </div><table class="source_code">
259
- <tr>
260
- <td>
261
- <pre class="lines">
262
-
263
-
264
- 18
265
- 19
266
- 20
267
- 21
268
- 22
269
- 23
270
- 24
271
- 25
272
- 26</pre>
273
- </td>
274
- <td>
275
- <pre class="code"><span class="info file"># File 'lib/lazier/hash.rb', line 18</span>
276
-
277
- <span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
278
- <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span> <span class='kw'>then</span>
279
- <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span>
280
- <span class='kw'>elsif</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span> <span class='kw'>then</span>
281
- <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbracket'>]</span>
282
- <span class='kw'>else</span>
283
- <span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
284
- <span class='kw'>end</span>
285
- <span class='kw'>end</span></pre>
286
- </td>
287
- </tr>
288
- </table>
289
- </div>
290
-
291
- </div>
292
-
293
-
294
- <div id="instance_method_details" class="method_details_list">
295
- <h2>Instance Method Details</h2>
296
-
297
-
298
- <div class="method_details first">
299
- <h3 class="signature first" id="respond_to?-instance_method">
300
-
301
- - (<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>) <strong>respond_to?</strong>(method)
302
-
303
-
304
-
305
-
306
-
307
- </h3><div class="docstring">
308
- <div class="discussion">
309
- <p>This is called when the user access a member using dotted notation.</p>
310
-
311
-
312
- </div>
313
- </div>
314
- <div class="tags">
315
- <p class="tag_title">Parameters:</p>
316
- <ul class="param">
317
-
318
- <li>
319
-
320
- <span class='name'>method</span>
321
-
322
-
323
- <span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span>|Symbol</tt>)</span>
324
-
325
-
326
-
327
- &mdash;
328
- <div class='inline'><p>Key to search.</p>
329
- </div>
330
-
331
- </li>
332
-
333
- </ul>
334
-
335
- <p class="tag_title">Returns:</p>
336
- <ul class="return">
337
-
338
- <li>
339
-
340
-
341
- <span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
342
-
343
-
344
-
345
- &mdash;
346
- <div class='inline'><p><code>true</code> if the key exists, <code>false</code> otherwise.</p>
347
- </div>
348
-
349
- </li>
350
-
351
- </ul>
352
-
353
- </div><table class="source_code">
354
- <tr>
355
- <td>
356
- <pre class="lines">
357
-
358
-
359
- 32
360
- 33
361
- 34</pre>
362
- </td>
363
- <td>
364
- <pre class="code"><span class="info file"># File 'lib/lazier/hash.rb', line 32</span>
365
-
366
- <span class='kw'>def</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
367
- <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>true</span> <span class='op'>:</span> <span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
368
- <span class='kw'>end</span></pre>
369
- </td>
370
- </tr>
371
- </table>
372
- </div>
373
-
374
- </div>
375
110
 
376
111
  </div>
377
112
 
378
113
  <div id="footer">
379
- Generated on Sat Apr 13 11:56:53 2013 by
114
+ Generated on Fri May 17 12:03:20 2013 by
380
115
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
381
- 0.8.5.2 (ruby-1.9.3).
116
+ 0.8.6.1 (ruby-1.9.3).
382
117
  </div>
383
118
 
384
119
  </body>
data/doc/Lazier/I18n.html CHANGED
@@ -6,13 +6,13 @@
6
6
  <title>
7
7
  Module: Lazier::I18n
8
8
 
9
- &mdash; Documentation by YARD 0.8.5.2
9
+ &mdash; Documentation by YARD 0.8.6.1
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
14
 
15
- <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
16
 
17
17
  <script type="text/javascript" charset="utf-8">
18
18
  hasFrames = window.top.frames.main ? true : false;
@@ -380,7 +380,14 @@
380
380
  71
381
381
  72
382
382
  73
383
- 74</pre>
383
+ 74
384
+ 75
385
+ 76
386
+ 77
387
+ 78
388
+ 79
389
+ 80
390
+ 81</pre>
384
391
  </td>
385
392
  <td>
386
393
  <pre class="code"><span class="info file"># File 'lib/lazier/i18n.rb', line 16</span>
@@ -421,13 +428,11 @@
421
428
  </span> <span class='comment'># @param locale [Symbol] The new locale. Default is the current system locale.
422
429
  </span> <span class='comment'># @return [R18n::Translation] The new translation object.
423
430
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_i18n_load_locale'>i18n_load_locale</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span>
424
- <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='ivar'>@i18n_locales_path</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
425
- <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>LANG</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_system_locale'>system_locale</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='id identifier rubyid_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_l'>l</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='rbrace'>}</span>
426
- <span class='id identifier rubyid_locales'>locales</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span> <span class='comment'># Add English as a fallback
427
- </span> <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_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
431
+ <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='ivar'>@i18n_locales_path</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
432
+ <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
428
433
 
429
434
  <span class='kw'>begin</span>
430
- <span class='id identifier rubyid_translation'>translation</span> <span class='op'>=</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='ivar'>@i18n_root</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
435
+ <span class='id identifier rubyid_translation'>translation</span> <span class='op'>=</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='ivar'>@i18n_root</span><span class='rparen'>)</span>
431
436
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span> <span class='kw'>if</span> <span class='id identifier rubyid_translation'>translation</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>R18n</span><span class='op'>::</span><span class='const'>Untranslated</span><span class='rparen'>)</span>
432
437
  <span class='id identifier rubyid_translation'>translation</span>
433
438
  <span class='kw'>rescue</span>
@@ -435,13 +440,22 @@
435
440
  <span class='kw'>end</span>
436
441
  <span class='kw'>end</span>
437
442
 
443
+ <span class='comment'># Validates locales for messages.
444
+ </span> <span class='comment'>#
445
+ </span> <span class='comment'># @param locales [Array] The list of locales to validate. English is added as fallback.
446
+ </span> <span class='comment'># @param path [String] The path where look into.
447
+ </span> <span class='comment'># @return [Array] The list of valid locales.
448
+ </span> <span class='kw'>def</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_path'>path</span><span class='rparen'>)</span>
449
+ <span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>LANG</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_system_locale'>system_locale</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</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_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_l'>l</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_s</span><span class='rparen'>)</span>
450
+ <span class='kw'>end</span>
451
+
438
452
  <span class='comment'># Find a locale file in a path.
439
453
  </span> <span class='comment'>#
440
454
  </span> <span class='comment'># @param locale [String] The locale to find.
441
455
  </span> <span class='comment'># @param path [String] The path where look into.
442
456
  </span> <span class='comment'># @return [String|nil] The version of the locale found or `nil`, if nothing was found.
443
457
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
444
- <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>5</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_l'>l</span><span class='rbrace'>}</span><span class='tstring_content'>.yml</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
458
+ <span class='id identifier rubyid_locale'>locale</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>5</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_l'>l</span><span class='rbrace'>}</span><span class='tstring_content'>.yml</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>:</span> <span class='kw'>nil</span>
445
459
  <span class='kw'>end</span>
446
460
  <span class='kw'>end</span></pre>
447
461
  </td>
@@ -551,7 +565,14 @@
551
565
  71
552
566
  72
553
567
  73
554
- 74</pre>
568
+ 74
569
+ 75
570
+ 76
571
+ 77
572
+ 78
573
+ 79
574
+ 80
575
+ 81</pre>
555
576
  </td>
556
577
  <td>
557
578
  <pre class="code"><span class="info file"># File 'lib/lazier/i18n.rb', line 16</span>
@@ -592,13 +613,11 @@
592
613
  </span> <span class='comment'># @param locale [Symbol] The new locale. Default is the current system locale.
593
614
  </span> <span class='comment'># @return [R18n::Translation] The new translation object.
594
615
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_i18n_load_locale'>i18n_load_locale</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span>
595
- <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='ivar'>@i18n_locales_path</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
596
- <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>LANG</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_system_locale'>system_locale</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='id identifier rubyid_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_l'>l</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='rbrace'>}</span>
597
- <span class='id identifier rubyid_locales'>locales</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span> <span class='comment'># Add English as a fallback
598
- </span> <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_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
616
+ <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='ivar'>@i18n_locales_path</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
617
+ <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
599
618
 
600
619
  <span class='kw'>begin</span>
601
- <span class='id identifier rubyid_translation'>translation</span> <span class='op'>=</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='ivar'>@i18n_root</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
620
+ <span class='id identifier rubyid_translation'>translation</span> <span class='op'>=</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='ivar'>@i18n_root</span><span class='rparen'>)</span>
602
621
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span> <span class='kw'>if</span> <span class='id identifier rubyid_translation'>translation</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>R18n</span><span class='op'>::</span><span class='const'>Untranslated</span><span class='rparen'>)</span>
603
622
  <span class='id identifier rubyid_translation'>translation</span>
604
623
  <span class='kw'>rescue</span>
@@ -606,13 +625,22 @@
606
625
  <span class='kw'>end</span>
607
626
  <span class='kw'>end</span>
608
627
 
628
+ <span class='comment'># Validates locales for messages.
629
+ </span> <span class='comment'>#
630
+ </span> <span class='comment'># @param locales [Array] The list of locales to validate. English is added as fallback.
631
+ </span> <span class='comment'># @param path [String] The path where look into.
632
+ </span> <span class='comment'># @return [Array] The list of valid locales.
633
+ </span> <span class='kw'>def</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_path'>path</span><span class='rparen'>)</span>
634
+ <span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>LANG</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_system_locale'>system_locale</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</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_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_l'>l</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_s</span><span class='rparen'>)</span>
635
+ <span class='kw'>end</span>
636
+
609
637
  <span class='comment'># Find a locale file in a path.
610
638
  </span> <span class='comment'>#
611
639
  </span> <span class='comment'># @param locale [String] The locale to find.
612
640
  </span> <span class='comment'># @param path [String] The path where look into.
613
641
  </span> <span class='comment'># @return [String|nil] The version of the locale found or `nil`, if nothing was found.
614
642
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
615
- <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>5</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_l'>l</span><span class='rbrace'>}</span><span class='tstring_content'>.yml</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
643
+ <span class='id identifier rubyid_locale'>locale</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>5</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_l'>l</span><span class='rbrace'>}</span><span class='tstring_content'>.yml</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>:</span> <span class='kw'>nil</span>
616
644
  <span class='kw'>end</span>
617
645
  <span class='kw'>end</span></pre>
618
646
  </td>
@@ -722,7 +750,14 @@
722
750
  71
723
751
  72
724
752
  73
725
- 74</pre>
753
+ 74
754
+ 75
755
+ 76
756
+ 77
757
+ 78
758
+ 79
759
+ 80
760
+ 81</pre>
726
761
  </td>
727
762
  <td>
728
763
  <pre class="code"><span class="info file"># File 'lib/lazier/i18n.rb', line 16</span>
@@ -763,13 +798,11 @@
763
798
  </span> <span class='comment'># @param locale [Symbol] The new locale. Default is the current system locale.
764
799
  </span> <span class='comment'># @return [R18n::Translation] The new translation object.
765
800
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_i18n_load_locale'>i18n_load_locale</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span>
766
- <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='ivar'>@i18n_locales_path</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
767
- <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>LANG</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_system_locale'>system_locale</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='id identifier rubyid_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_l'>l</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='rbrace'>}</span>
768
- <span class='id identifier rubyid_locales'>locales</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span> <span class='comment'># Add English as a fallback
769
- </span> <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_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
801
+ <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='ivar'>@i18n_locales_path</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
802
+ <span class='id identifier rubyid_locales'>locales</span> <span class='op'>=</span> <span class='id identifier rubyid_validate_locales'>validate_locales</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
770
803
 
771
804
  <span class='kw'>begin</span>
772
- <span class='id identifier rubyid_translation'>translation</span> <span class='op'>=</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='ivar'>@i18n_root</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
805
+ <span class='id identifier rubyid_translation'>translation</span> <span class='op'>=</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='ivar'>@i18n_root</span><span class='rparen'>)</span>
773
806
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span> <span class='kw'>if</span> <span class='id identifier rubyid_translation'>translation</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>R18n</span><span class='op'>::</span><span class='const'>Untranslated</span><span class='rparen'>)</span>
774
807
  <span class='id identifier rubyid_translation'>translation</span>
775
808
  <span class='kw'>rescue</span>
@@ -777,13 +810,22 @@
777
810
  <span class='kw'>end</span>
778
811
  <span class='kw'>end</span>
779
812
 
813
+ <span class='comment'># Validates locales for messages.
814
+ </span> <span class='comment'>#
815
+ </span> <span class='comment'># @param locales [Array] The list of locales to validate. English is added as fallback.
816
+ </span> <span class='comment'># @param path [String] The path where look into.
817
+ </span> <span class='comment'># @return [Array] The list of valid locales.
818
+ </span> <span class='kw'>def</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_path'>path</span><span class='rparen'>)</span>
819
+ <span class='lparen'>(</span><span class='id identifier rubyid_locales'>locales</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>LANG</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>R18n</span><span class='op'>::</span><span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_system_locale'>system_locale</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</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_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_l'>l</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_s</span><span class='rparen'>)</span>
820
+ <span class='kw'>end</span>
821
+
780
822
  <span class='comment'># Find a locale file in a path.
781
823
  </span> <span class='comment'>#
782
824
  </span> <span class='comment'># @param locale [String] The locale to find.
783
825
  </span> <span class='comment'># @param path [String] The path where look into.
784
826
  </span> <span class='comment'># @return [String|nil] The version of the locale found or `nil`, if nothing was found.
785
827
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_find_locale_in_path'>find_locale_in_path</span><span class='lparen'>(</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
786
- <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>5</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_l'>l</span><span class='rbrace'>}</span><span class='tstring_content'>.yml</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
828
+ <span class='id identifier rubyid_locale'>locale</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='id identifier rubyid_locale'>locale</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>5</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_locale'>locale</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_l'>l</span><span class='rbrace'>}</span><span class='tstring_content'>.yml</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>:</span> <span class='kw'>nil</span>
787
829
  <span class='kw'>end</span>
788
830
  <span class='kw'>end</span></pre>
789
831
  </td>
@@ -1014,9 +1056,9 @@
1014
1056
  </div>
1015
1057
 
1016
1058
  <div id="footer">
1017
- Generated on Sat Apr 13 11:56:53 2013 by
1059
+ Generated on Fri May 17 12:03:20 2013 by
1018
1060
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1019
- 0.8.5.2 (ruby-1.9.3).
1061
+ 0.8.6.1 (ruby-1.9.3).
1020
1062
  </div>
1021
1063
 
1022
1064
  </body>