elephas 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +5 -0
  2. data/.travis.yml +8 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +9 -0
  5. data/README.md +28 -0
  6. data/Rakefile +18 -0
  7. data/doc/Elephas/Cache.html +815 -0
  8. data/doc/Elephas/Entry.html +1085 -0
  9. data/doc/Elephas/Exceptions.html +115 -0
  10. data/doc/Elephas/Providers/Base.html +701 -0
  11. data/doc/Elephas/Providers/Hash.html +775 -0
  12. data/doc/Elephas/Providers/RubyOnRails.html +609 -0
  13. data/doc/Elephas/Providers.html +129 -0
  14. data/doc/Elephas/Version.html +189 -0
  15. data/doc/Elephas.html +130 -0
  16. data/doc/_index.html +207 -0
  17. data/doc/class_list.html +53 -0
  18. data/doc/css/common.css +1 -0
  19. data/doc/css/full_list.css +57 -0
  20. data/doc/css/style.css +328 -0
  21. data/doc/file.README.html +103 -0
  22. data/doc/file_list.html +55 -0
  23. data/doc/frames.html +28 -0
  24. data/doc/index.html +103 -0
  25. data/doc/js/app.js +214 -0
  26. data/doc/js/full_list.js +173 -0
  27. data/doc/js/jquery.js +4 -0
  28. data/doc/method_list.html +300 -0
  29. data/doc/top-level-namespace.html +112 -0
  30. data/elephas.gemspec +34 -0
  31. data/lib/elephas/cache.rb +89 -0
  32. data/lib/elephas/entry.rb +86 -0
  33. data/lib/elephas/provider.rb +57 -0
  34. data/lib/elephas/providers/hash.rb +65 -0
  35. data/lib/elephas/providers/ruby_on_rails.rb +57 -0
  36. data/lib/elephas/version.rb +25 -0
  37. data/lib/elephas.rb +20 -0
  38. data/spec/coverage_helper.rb +19 -0
  39. data/spec/elephas/cache_spec.rb +41 -0
  40. data/spec/elephas/entry_spec.rb +11 -0
  41. data/spec/elephas/provider_spec.rb +46 -0
  42. data/spec/elephas/providers/hash_spec.rb +80 -0
  43. data/spec/elephas/providers/ruby_on_rails_spec.rb +86 -0
  44. data/spec/spec_helper.rb +16 -0
  45. metadata +231 -0
@@ -0,0 +1,609 @@
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: Elephas::Providers::RubyOnRails
8
+
9
+ &mdash; Documentation by YARD 0.8.2.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (R)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Elephas.html" title="Elephas (module)">Elephas</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Providers.html" title="Elephas::Providers (module)">Providers</a></span></span>
36
+ &raquo;
37
+ <span class="title">RubyOnRails</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: Elephas::Providers::RubyOnRails
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">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">Elephas::Providers::RubyOnRails</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+ <dt class="r2">Includes:</dt>
94
+ <dd class="r2"><span class='object_link'><a href="Base.html" title="Elephas::Providers::Base (module)">Base</a></span></dd>
95
+
96
+
97
+
98
+
99
+
100
+ <dt class="r1 last">Defined in:</dt>
101
+ <dd class="r1 last">lib/elephas/providers/ruby_on_rails.rb</dd>
102
+
103
+ </dl>
104
+ <div class="clear"></div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+ <p>This is a Ruby on Rails providers, which uses Rails.cache.</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="#delete-instance_method" title="#delete (instance method)">- (Boolean) <strong>delete</strong>(key) </a>
135
+
136
+
137
+
138
+ </span>
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+ <span class="summary_desc"><div class='inline'><p>Deletes a value from the cache.</p>
149
+ </div></span>
150
+
151
+ </li>
152
+
153
+
154
+ <li class="public ">
155
+ <span class="summary_signature">
156
+
157
+ <a href="#exists%3F-instance_method" title="#exists? (instance method)">- (Boolean) <strong>exists?</strong>(key) </a>
158
+
159
+
160
+
161
+ </span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'><p>Checks if a key exists in the cache.</p>
172
+ </div></span>
173
+
174
+ </li>
175
+
176
+
177
+ <li class="public ">
178
+ <span class="summary_signature">
179
+
180
+ <a href="#read-instance_method" title="#read (instance method)">- (Entry|NilClass) <strong>read</strong>(key) </a>
181
+
182
+
183
+
184
+ </span>
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+ <span class="summary_desc"><div class='inline'><p>Reads a value from the cache.</p>
195
+ </div></span>
196
+
197
+ </li>
198
+
199
+
200
+ <li class="public ">
201
+ <span class="summary_signature">
202
+
203
+ <a href="#write-instance_method" title="#write (instance method)">- (Object) <strong>write</strong>(key, value, options = {}) </a>
204
+
205
+
206
+
207
+ </span>
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+ <span class="summary_desc"><div class='inline'><p>Writes a value to the cache.</p>
218
+ </div></span>
219
+
220
+ </li>
221
+
222
+
223
+ </ul>
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Base.html" title="Elephas::Providers::Base (module)">Base</a></span></h3>
236
+ <p class="inherited"><span class='object_link'><a href="Base.html#now-instance_method" title="Elephas::Providers::Base#now (method)">#now</a></span></p>
237
+
238
+
239
+
240
+ <div id="instance_method_details" class="method_details_list">
241
+ <h2>Instance Method Details</h2>
242
+
243
+
244
+ <div class="method_details first">
245
+ <h3 class="signature first" id="delete-instance_method">
246
+
247
+ - (<tt>Boolean</tt>) <strong>delete</strong>(key)
248
+
249
+
250
+
251
+
252
+
253
+ </h3><div class="docstring">
254
+ <div class="discussion">
255
+ <p>Deletes a value from the cache.</p>
256
+
257
+
258
+ </div>
259
+ </div>
260
+ <div class="tags">
261
+ <p class="tag_title">Parameters:</p>
262
+ <ul class="param">
263
+
264
+ <li>
265
+
266
+ <span class='name'>key</span>
267
+
268
+
269
+ <span class='type'>(<tt>String</tt>)</span>
270
+
271
+
272
+
273
+ &mdash;
274
+ <div class='inline'><p>The key to delete.</p>
275
+ </div>
276
+
277
+ </li>
278
+
279
+ </ul>
280
+
281
+ <p class="tag_title">Returns:</p>
282
+ <ul class="return">
283
+
284
+ <li>
285
+
286
+
287
+ <span class='type'>(<tt>Boolean</tt>)</span>
288
+
289
+
290
+
291
+ &mdash;
292
+ <div class='inline'><p><code>true</code> if the key was in the cache, <code>false</code> otherwise.</p>
293
+ </div>
294
+
295
+ </li>
296
+
297
+ </ul>
298
+
299
+ </div><table class="source_code">
300
+ <tr>
301
+ <td>
302
+ <pre class="lines">
303
+
304
+
305
+ 40
306
+ 41
307
+ 42
308
+ 43
309
+ 44
310
+ 45</pre>
311
+ </td>
312
+ <td>
313
+ <pre class="code"><span class="info file"># File 'lib/elephas/providers/ruby_on_rails.rb', line 40</span>
314
+
315
+ <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
316
+ <span class='id identifier rubyid_fkey'>fkey</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
317
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span><span class='lparen'>(</span><span class='id identifier rubyid_fkey'>fkey</span><span class='rparen'>)</span>
318
+ <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_fkey'>fkey</span><span class='rparen'>)</span>
319
+ <span class='id identifier rubyid_rv'>rv</span>
320
+ <span class='kw'>end</span></pre>
321
+ </td>
322
+ </tr>
323
+ </table>
324
+ </div>
325
+
326
+ <div class="method_details ">
327
+ <h3 class="signature " id="exists?-instance_method">
328
+
329
+ - (<tt>Boolean</tt>) <strong>exists?</strong>(key)
330
+
331
+
332
+
333
+
334
+
335
+ </h3><div class="docstring">
336
+ <div class="discussion">
337
+ <p>Checks if a key exists in the cache.</p>
338
+
339
+
340
+ </div>
341
+ </div>
342
+ <div class="tags">
343
+ <p class="tag_title">Parameters:</p>
344
+ <ul class="param">
345
+
346
+ <li>
347
+
348
+ <span class='name'>key</span>
349
+
350
+
351
+ <span class='type'>(<tt>String</tt>)</span>
352
+
353
+
354
+
355
+ &mdash;
356
+ <div class='inline'><p>The key to lookup.</p>
357
+ </div>
358
+
359
+ </li>
360
+
361
+ </ul>
362
+
363
+ <p class="tag_title">Returns:</p>
364
+ <ul class="return">
365
+
366
+ <li>
367
+
368
+
369
+ <span class='type'>(<tt>Boolean</tt>)</span>
370
+
371
+
372
+
373
+ &mdash;
374
+ <div class='inline'><p><code>true</code> if the key is in the cache, <code>false</code> otherwise.</p>
375
+ </div>
376
+
377
+ </li>
378
+
379
+ </ul>
380
+
381
+ </div><table class="source_code">
382
+ <tr>
383
+ <td>
384
+ <pre class="lines">
385
+
386
+
387
+ 51
388
+ 52
389
+ 53
390
+ 54</pre>
391
+ </td>
392
+ <td>
393
+ <pre class="code"><span class="info file"># File 'lib/elephas/providers/ruby_on_rails.rb', line 51</span>
394
+
395
+ <span class='kw'>def</span> <span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
396
+ <span class='id identifier rubyid_fkey'>fkey</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
397
+ <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span><span class='lparen'>(</span><span class='id identifier rubyid_fkey'>fkey</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_fkey'>fkey</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span>
398
+ <span class='kw'>end</span></pre>
399
+ </td>
400
+ </tr>
401
+ </table>
402
+ </div>
403
+
404
+ <div class="method_details ">
405
+ <h3 class="signature " id="read-instance_method">
406
+
407
+ - (<tt><span class='object_link'><a href="../Entry.html" title="Elephas::Entry (class)">Entry</a></span>|NilClass</tt>) <strong>read</strong>(key)
408
+
409
+
410
+
411
+
412
+
413
+ </h3><div class="docstring">
414
+ <div class="discussion">
415
+ <p>Reads a value from the cache.</p>
416
+
417
+
418
+ </div>
419
+ </div>
420
+ <div class="tags">
421
+ <p class="tag_title">Parameters:</p>
422
+ <ul class="param">
423
+
424
+ <li>
425
+
426
+ <span class='name'>key</span>
427
+
428
+
429
+ <span class='type'>(<tt>String</tt>)</span>
430
+
431
+
432
+
433
+ &mdash;
434
+ <div class='inline'><p>The key to lookup.</p>
435
+ </div>
436
+
437
+ </li>
438
+
439
+ </ul>
440
+
441
+ <p class="tag_title">Returns:</p>
442
+ <ul class="return">
443
+
444
+ <li>
445
+
446
+
447
+ <span class='type'>(<tt><span class='object_link'><a href="../Entry.html" title="Elephas::Entry (class)">Entry</a></span>|NilClass</tt>)</span>
448
+
449
+
450
+
451
+ &mdash;
452
+ <div class='inline'><p>The read value or <code>nil</code>.</p>
453
+ </div>
454
+
455
+ </li>
456
+
457
+ </ul>
458
+
459
+ </div><table class="source_code">
460
+ <tr>
461
+ <td>
462
+ <pre class="lines">
463
+
464
+
465
+ 17
466
+ 18
467
+ 19</pre>
468
+ </td>
469
+ <td>
470
+ <pre class="code"><span class="info file"># File 'lib/elephas/providers/ruby_on_rails.rb', line 17</span>
471
+
472
+ <span class='kw'>def</span> <span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
473
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
474
+ <span class='kw'>end</span></pre>
475
+ </td>
476
+ </tr>
477
+ </table>
478
+ </div>
479
+
480
+ <div class="method_details ">
481
+ <h3 class="signature " id="write-instance_method">
482
+
483
+ - (<tt>Object</tt>) <strong>write</strong>(key, value, options = {})
484
+
485
+
486
+
487
+
488
+
489
+ </h3><div class="docstring">
490
+ <div class="discussion">
491
+ <p>Writes a value to the cache.</p>
492
+
493
+
494
+ </div>
495
+ </div>
496
+ <div class="tags">
497
+ <p class="tag_title">Parameters:</p>
498
+ <ul class="param">
499
+
500
+ <li>
501
+
502
+ <span class='name'>key</span>
503
+
504
+
505
+ <span class='type'>(<tt>String</tt>)</span>
506
+
507
+
508
+
509
+ &mdash;
510
+ <div class='inline'><p>The key to associate the value with.</p>
511
+ </div>
512
+
513
+ </li>
514
+
515
+ <li>
516
+
517
+ <span class='name'>value</span>
518
+
519
+
520
+ <span class='type'>(<tt>Object</tt>)</span>
521
+
522
+
523
+
524
+ &mdash;
525
+ <div class='inline'><p>The value to write. *<em>Setting a value to <code>nil</code> doesn&#39;t mean *deleting</em> the value.</p>
526
+ </div>
527
+
528
+ </li>
529
+
530
+ <li>
531
+
532
+ <span class='name'>options</span>
533
+
534
+
535
+ <span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="Elephas::Providers::Hash (class)">Hash</a></span></tt>)</span>
536
+
537
+
538
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
539
+
540
+
541
+ &mdash;
542
+ <div class='inline'><p>A list of options for writing. @see Elephas::Cache.write</p>
543
+ </div>
544
+
545
+ </li>
546
+
547
+ </ul>
548
+
549
+ <p class="tag_title">Returns:</p>
550
+ <ul class="return">
551
+
552
+ <li>
553
+
554
+
555
+ <span class='type'>(<tt>Object</tt>)</span>
556
+
557
+
558
+
559
+ &mdash;
560
+ <div class='inline'><p>The value itself.</p>
561
+ </div>
562
+
563
+ </li>
564
+
565
+ </ul>
566
+
567
+ </div><table class="source_code">
568
+ <tr>
569
+ <td>
570
+ <pre class="lines">
571
+
572
+
573
+ 27
574
+ 28
575
+ 29
576
+ 30
577
+ 31
578
+ 32
579
+ 33
580
+ 34</pre>
581
+ </td>
582
+ <td>
583
+ <pre class="code"><span class="info file"># File 'lib/elephas/providers/ruby_on_rails.rb', line 27</span>
584
+
585
+ <span class='kw'>def</span> <span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
586
+ <span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
587
+ <span class='id identifier rubyid_fvalue'>fvalue</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='period'>.</span><span class='id identifier rubyid_ensure'>ensure</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
588
+ <span class='id identifier rubyid_fvalue'>fvalue</span><span class='period'>.</span><span class='id identifier rubyid_refresh'>refresh</span>
589
+
590
+ <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_cache'>cache</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='symbol'>:expires_in</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
591
+ <span class='id identifier rubyid_value'>value</span>
592
+ <span class='kw'>end</span></pre>
593
+ </td>
594
+ </tr>
595
+ </table>
596
+ </div>
597
+
598
+ </div>
599
+
600
+ </div>
601
+
602
+ <div id="footer">
603
+ Generated on Sat Jul 28 14:29:52 2012 by
604
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
605
+ 0.8.2.1 (ruby-1.9.2).
606
+ </div>
607
+
608
+ </body>
609
+ </html>