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,701 @@
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
+ Module: Elephas::Providers::Base
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 (B)</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">Base</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>Module: Elephas::Providers::Base
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+ <dt class="r1">Extended by:</dt>
77
+ <dd class="r1">ActiveSupport::Concern</dd>
78
+
79
+
80
+
81
+
82
+
83
+
84
+ <dt class="r2">Included in:</dt>
85
+ <dd class="r2"><span class='object_link'><a href="Hash.html" title="Elephas::Providers::Hash (class)">Hash</a></span>, <span class='object_link'><a href="RubyOnRails.html" title="Elephas::Providers::RubyOnRails (class)">RubyOnRails</a></span></dd>
86
+
87
+
88
+
89
+ <dt class="r1 last">Defined in:</dt>
90
+ <dd class="r1 last">lib/elephas/provider.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+ <h2>Overview</h2><div class="docstring">
96
+ <div class="discussion">
97
+ <p>The base provider, with all methods a valid provider should override.</p>
98
+
99
+
100
+ </div>
101
+ </div>
102
+ <div class="tags">
103
+
104
+
105
+ </div>
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+ <h2>
114
+ Instance Method Summary
115
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
116
+ </h2>
117
+
118
+ <ul class="summary">
119
+
120
+ <li class="public ">
121
+ <span class="summary_signature">
122
+
123
+ <a href="#delete-instance_method" title="#delete (instance method)">- (TrueClass|FalseClass) <strong>delete</strong>(key) </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ <span class="summary_desc"><div class='inline'><p>Deletes a value from the cache.</p>
138
+ </div></span>
139
+
140
+ </li>
141
+
142
+
143
+ <li class="public ">
144
+ <span class="summary_signature">
145
+
146
+ <a href="#exists%3F-instance_method" title="#exists? (instance method)">- (TrueClass|FalseClass) <strong>exists?</strong>(key) </a>
147
+
148
+
149
+
150
+ </span>
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+ <span class="summary_desc"><div class='inline'><p>Checks if a key exists in the cache.</p>
161
+ </div></span>
162
+
163
+ </li>
164
+
165
+
166
+ <li class="public ">
167
+ <span class="summary_signature">
168
+
169
+ <a href="#now-instance_method" title="#now (instance method)">- (Object) <strong>now</strong> </a>
170
+
171
+
172
+
173
+ </span>
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+ <span class="summary_desc"><div class='inline'><p>Returns the current time for comparing with entries TTL.</p>
184
+ </div></span>
185
+
186
+ </li>
187
+
188
+
189
+ <li class="public ">
190
+ <span class="summary_signature">
191
+
192
+ <a href="#read-instance_method" title="#read (instance method)">- (Entry|NilClass) <strong>read</strong>(key) </a>
193
+
194
+
195
+
196
+ </span>
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+ <span class="summary_desc"><div class='inline'><p>Reads a value from the cache.</p>
207
+ </div></span>
208
+
209
+ </li>
210
+
211
+
212
+ <li class="public ">
213
+ <span class="summary_signature">
214
+
215
+ <a href="#write-instance_method" title="#write (instance method)">- (Object) <strong>write</strong>(key, value, options = {}) </a>
216
+
217
+
218
+
219
+ </span>
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+ <span class="summary_desc"><div class='inline'><p>Writes a value to the cache.</p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ </ul>
236
+
237
+
238
+
239
+
240
+
241
+ <div id="instance_method_details" class="method_details_list">
242
+ <h2>Instance Method Details</h2>
243
+
244
+
245
+ <div class="method_details first">
246
+ <h3 class="signature first" id="delete-instance_method">
247
+
248
+ - (<tt>TrueClass|FalseClass</tt>) <strong>delete</strong>(key)
249
+
250
+
251
+
252
+
253
+
254
+ </h3><div class="docstring">
255
+ <div class="discussion">
256
+ <p>Deletes a value from the cache.</p>
257
+
258
+
259
+ </div>
260
+ </div>
261
+ <div class="tags">
262
+ <p class="tag_title">Parameters:</p>
263
+ <ul class="param">
264
+
265
+ <li>
266
+
267
+ <span class='name'>key</span>
268
+
269
+
270
+ <span class='type'>(<tt>String</tt>)</span>
271
+
272
+
273
+
274
+ &mdash;
275
+ <div class='inline'><p>The key to delete.</p>
276
+ </div>
277
+
278
+ </li>
279
+
280
+ </ul>
281
+
282
+ <p class="tag_title">Returns:</p>
283
+ <ul class="return">
284
+
285
+ <li>
286
+
287
+
288
+ <span class='type'>(<tt>TrueClass|FalseClass</tt>)</span>
289
+
290
+
291
+
292
+ &mdash;
293
+ <div class='inline'><p><code>true</code> if the key was in the cache, <code>false</code> otherwise.</p>
294
+ </div>
295
+
296
+ </li>
297
+
298
+ </ul>
299
+ <p class="tag_title">Raises:</p>
300
+ <ul class="raise">
301
+
302
+ <li>
303
+
304
+
305
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
306
+
307
+
308
+
309
+ </li>
310
+
311
+ </ul>
312
+
313
+ </div><table class="source_code">
314
+ <tr>
315
+ <td>
316
+ <pre class="lines">
317
+
318
+
319
+ 37
320
+ 38
321
+ 39</pre>
322
+ </td>
323
+ <td>
324
+ <pre class="code"><span class="info file"># File 'lib/elephas/provider.rb', line 37</span>
325
+
326
+ <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>
327
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>A Elephas::Providers subclass should override this module.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
328
+ <span class='kw'>end</span></pre>
329
+ </td>
330
+ </tr>
331
+ </table>
332
+ </div>
333
+
334
+ <div class="method_details ">
335
+ <h3 class="signature " id="exists?-instance_method">
336
+
337
+ - (<tt>TrueClass|FalseClass</tt>) <strong>exists?</strong>(key)
338
+
339
+
340
+
341
+
342
+
343
+ </h3><div class="docstring">
344
+ <div class="discussion">
345
+ <p>Checks if a key exists in the cache.</p>
346
+
347
+
348
+ </div>
349
+ </div>
350
+ <div class="tags">
351
+ <p class="tag_title">Parameters:</p>
352
+ <ul class="param">
353
+
354
+ <li>
355
+
356
+ <span class='name'>key</span>
357
+
358
+
359
+ <span class='type'>(<tt>String</tt>)</span>
360
+
361
+
362
+
363
+ &mdash;
364
+ <div class='inline'><p>The key to lookup.</p>
365
+ </div>
366
+
367
+ </li>
368
+
369
+ </ul>
370
+
371
+ <p class="tag_title">Returns:</p>
372
+ <ul class="return">
373
+
374
+ <li>
375
+
376
+
377
+ <span class='type'>(<tt>TrueClass|FalseClass</tt>)</span>
378
+
379
+
380
+
381
+ &mdash;
382
+ <div class='inline'><p><code>true</code> if the key is in the cache, <code>false</code> otherwise.</p>
383
+ </div>
384
+
385
+ </li>
386
+
387
+ </ul>
388
+ <p class="tag_title">Raises:</p>
389
+ <ul class="raise">
390
+
391
+ <li>
392
+
393
+
394
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
395
+
396
+
397
+
398
+ </li>
399
+
400
+ </ul>
401
+
402
+ </div><table class="source_code">
403
+ <tr>
404
+ <td>
405
+ <pre class="lines">
406
+
407
+
408
+ 45
409
+ 46
410
+ 47</pre>
411
+ </td>
412
+ <td>
413
+ <pre class="code"><span class="info file"># File 'lib/elephas/provider.rb', line 45</span>
414
+
415
+ <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>
416
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>A Elephas::Providers subclass should override this module.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
417
+ <span class='kw'>end</span></pre>
418
+ </td>
419
+ </tr>
420
+ </table>
421
+ </div>
422
+
423
+ <div class="method_details ">
424
+ <h3 class="signature " id="now-instance_method">
425
+
426
+ - (<tt>Object</tt>) <strong>now</strong>
427
+
428
+
429
+
430
+
431
+
432
+ </h3><div class="docstring">
433
+ <div class="discussion">
434
+ <p>Returns the current time for comparing with entries TTL.</p>
435
+
436
+
437
+ </div>
438
+ </div>
439
+ <div class="tags">
440
+
441
+ <p class="tag_title">Returns:</p>
442
+ <ul class="return">
443
+
444
+ <li>
445
+
446
+
447
+ <span class='type'>(<tt>Object</tt>)</span>
448
+
449
+
450
+
451
+ &mdash;
452
+ <div class='inline'><p>A representation of the current time.</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
+ 52
466
+ 53
467
+ 54</pre>
468
+ </td>
469
+ <td>
470
+ <pre class="code"><span class="info file"># File 'lib/elephas/provider.rb', line 52</span>
471
+
472
+ <span class='kw'>def</span> <span class='id identifier rubyid_now'>now</span>
473
+ <span class='op'>::</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</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="read-instance_method">
482
+
483
+ - (<tt><span class='object_link'><a href="../Entry.html" title="Elephas::Entry (class)">Entry</a></span>|NilClass</tt>) <strong>read</strong>(key)
484
+
485
+
486
+
487
+
488
+
489
+ </h3><div class="docstring">
490
+ <div class="discussion">
491
+ <p>Reads a value from 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 lookup.</p>
511
+ </div>
512
+
513
+ </li>
514
+
515
+ </ul>
516
+
517
+ <p class="tag_title">Returns:</p>
518
+ <ul class="return">
519
+
520
+ <li>
521
+
522
+
523
+ <span class='type'>(<tt><span class='object_link'><a href="../Entry.html" title="Elephas::Entry (class)">Entry</a></span>|NilClass</tt>)</span>
524
+
525
+
526
+
527
+ &mdash;
528
+ <div class='inline'><p>The read value or <code>nil</code>.</p>
529
+ </div>
530
+
531
+ </li>
532
+
533
+ </ul>
534
+ <p class="tag_title">Raises:</p>
535
+ <ul class="raise">
536
+
537
+ <li>
538
+
539
+
540
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
541
+
542
+
543
+
544
+ </li>
545
+
546
+ </ul>
547
+
548
+ </div><table class="source_code">
549
+ <tr>
550
+ <td>
551
+ <pre class="lines">
552
+
553
+
554
+ 19
555
+ 20
556
+ 21</pre>
557
+ </td>
558
+ <td>
559
+ <pre class="code"><span class="info file"># File 'lib/elephas/provider.rb', line 19</span>
560
+
561
+ <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>
562
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>A Elephas::Providers subclass should override this module.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
563
+ <span class='kw'>end</span></pre>
564
+ </td>
565
+ </tr>
566
+ </table>
567
+ </div>
568
+
569
+ <div class="method_details ">
570
+ <h3 class="signature " id="write-instance_method">
571
+
572
+ - (<tt>Object</tt>) <strong>write</strong>(key, value, options = {})
573
+
574
+
575
+
576
+
577
+
578
+ </h3><div class="docstring">
579
+ <div class="discussion">
580
+ <p>Writes a value to the cache.</p>
581
+
582
+
583
+ </div>
584
+ </div>
585
+ <div class="tags">
586
+ <p class="tag_title">Parameters:</p>
587
+ <ul class="param">
588
+
589
+ <li>
590
+
591
+ <span class='name'>key</span>
592
+
593
+
594
+ <span class='type'>(<tt>String</tt>)</span>
595
+
596
+
597
+
598
+ &mdash;
599
+ <div class='inline'><p>The key to associate the value with.</p>
600
+ </div>
601
+
602
+ </li>
603
+
604
+ <li>
605
+
606
+ <span class='name'>value</span>
607
+
608
+
609
+ <span class='type'>(<tt>Object</tt>)</span>
610
+
611
+
612
+
613
+ &mdash;
614
+ <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>
615
+ </div>
616
+
617
+ </li>
618
+
619
+ <li>
620
+
621
+ <span class='name'>options</span>
622
+
623
+
624
+ <span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="Elephas::Providers::Hash (class)">Hash</a></span></tt>)</span>
625
+
626
+
627
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
628
+
629
+
630
+ &mdash;
631
+ <div class='inline'><p>A list of options for writing. @see Elephas::Cache.write</p>
632
+ </div>
633
+
634
+ </li>
635
+
636
+ </ul>
637
+
638
+ <p class="tag_title">Returns:</p>
639
+ <ul class="return">
640
+
641
+ <li>
642
+
643
+
644
+ <span class='type'>(<tt>Object</tt>)</span>
645
+
646
+
647
+
648
+ &mdash;
649
+ <div class='inline'><p>The value itself.</p>
650
+ </div>
651
+
652
+ </li>
653
+
654
+ </ul>
655
+ <p class="tag_title">Raises:</p>
656
+ <ul class="raise">
657
+
658
+ <li>
659
+
660
+
661
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
662
+
663
+
664
+
665
+ </li>
666
+
667
+ </ul>
668
+
669
+ </div><table class="source_code">
670
+ <tr>
671
+ <td>
672
+ <pre class="lines">
673
+
674
+
675
+ 29
676
+ 30
677
+ 31</pre>
678
+ </td>
679
+ <td>
680
+ <pre class="code"><span class="info file"># File 'lib/elephas/provider.rb', line 29</span>
681
+
682
+ <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>
683
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>A Elephas::Providers subclass should override this module.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
684
+ <span class='kw'>end</span></pre>
685
+ </td>
686
+ </tr>
687
+ </table>
688
+ </div>
689
+
690
+ </div>
691
+
692
+ </div>
693
+
694
+ <div id="footer">
695
+ Generated on Sat Jul 28 14:29:52 2012 by
696
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
697
+ 0.8.2.1 (ruby-1.9.2).
698
+ </div>
699
+
700
+ </body>
701
+ </html>