api_wrapper 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +7 -0
  3. data/CHANGELOG.md +18 -0
  4. data/CODE_OF_CONDUCT.md +84 -0
  5. data/Gemfile +22 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +153 -0
  8. data/Rakefile +31 -0
  9. data/api_wrapper.gemspec +34 -0
  10. data/doc/ApiWrapper/ApiManager.html +807 -0
  11. data/doc/ApiWrapper/Cache/CachePolicy.html +907 -0
  12. data/doc/ApiWrapper/Cache/CacheStore.html +674 -0
  13. data/doc/ApiWrapper/Cache.html +117 -0
  14. data/doc/ApiWrapper/Configuration.html +366 -0
  15. data/doc/ApiWrapper/HttpClient/BaseClient.html +349 -0
  16. data/doc/ApiWrapper/HttpClient/FaradayClient.html +299 -0
  17. data/doc/ApiWrapper/HttpClient.html +117 -0
  18. data/doc/ApiWrapper.html +543 -0
  19. data/doc/_index.html +195 -0
  20. data/doc/class_list.html +54 -0
  21. data/doc/css/common.css +1 -0
  22. data/doc/css/full_list.css +58 -0
  23. data/doc/css/style.css +503 -0
  24. data/doc/file.README.html +248 -0
  25. data/doc/file_list.html +59 -0
  26. data/doc/frames.html +22 -0
  27. data/doc/index.html +248 -0
  28. data/doc/js/app.js +344 -0
  29. data/doc/js/full_list.js +242 -0
  30. data/doc/js/jquery.js +4 -0
  31. data/doc/method_list.html +286 -0
  32. data/doc/top-level-namespace.html +110 -0
  33. data/lib/api_wrapper/api_manager.rb +86 -0
  34. data/lib/api_wrapper/cache/README.md +78 -0
  35. data/lib/api_wrapper/cache/cache_policy.rb +115 -0
  36. data/lib/api_wrapper/cache/cache_store.rb +84 -0
  37. data/lib/api_wrapper/cache/redis_cache_store.rb +3 -0
  38. data/lib/api_wrapper/http_client/base_client.rb +26 -0
  39. data/lib/api_wrapper/http_client/faraday_client.rb +81 -0
  40. data/lib/api_wrapper/version.rb +5 -0
  41. data/lib/api_wrapper.rb +83 -0
  42. metadata +121 -0
@@ -0,0 +1,674 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: ApiWrapper::Cache::CacheStore
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "ApiWrapper::Cache::CacheStore";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../ApiWrapper.html" title="ApiWrapper (module)">ApiWrapper</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Cache.html" title="ApiWrapper::Cache (module)">Cache</a></span></span>
41
+ &raquo;
42
+ <span class="title">CacheStore</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: ApiWrapper::Cache::CacheStore
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">ApiWrapper::Cache::CacheStore</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/api_wrapper/cache/cache_store.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>CacheStore class provides an in-memory caching mechanism.</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ <h2>
122
+ Instance Method Summary
123
+ <small><a href="#" class="summary_toggle">collapse</a></small>
124
+ </h2>
125
+
126
+ <ul class="summary">
127
+
128
+ <li class="public ">
129
+ <span class="summary_signature">
130
+
131
+ <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong>(key) &#x21d2; Object </a>
132
+
133
+
134
+
135
+ </span>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <span class="summary_desc"><div class='inline'>
146
+ <p>Deletes data from the cache.</p>
147
+ </div></span>
148
+
149
+ </li>
150
+
151
+
152
+ <li class="public ">
153
+ <span class="summary_signature">
154
+
155
+ <a href="#fetch-instance_method" title="#fetch (instance method)">#<strong>fetch</strong>(key, ttl) { ... } &#x21d2; Object </a>
156
+
157
+
158
+
159
+ </span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'>
170
+ <p>Retrieves the cached data for the given key, or fetches fresh data if not cached or expired.</p>
171
+ </div></span>
172
+
173
+ </li>
174
+
175
+
176
+ <li class="public ">
177
+ <span class="summary_signature">
178
+
179
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> &#x21d2; CacheStore </a>
180
+
181
+
182
+
183
+ </span>
184
+
185
+
186
+ <span class="note title constructor">constructor</span>
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ <span class="summary_desc"><div class='inline'>
196
+ <p>A new instance of CacheStore.</p>
197
+ </div></span>
198
+
199
+ </li>
200
+
201
+
202
+ <li class="public ">
203
+ <span class="summary_signature">
204
+
205
+ <a href="#read-instance_method" title="#read (instance method)">#<strong>read</strong>(key) &#x21d2; Object<sup>?</sup> </a>
206
+
207
+
208
+
209
+ </span>
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+ <span class="summary_desc"><div class='inline'>
220
+ <p>Reads data from the cache.</p>
221
+ </div></span>
222
+
223
+ </li>
224
+
225
+
226
+ <li class="public ">
227
+ <span class="summary_signature">
228
+
229
+ <a href="#write-instance_method" title="#write (instance method)">#<strong>write</strong>(key, data, ttl) &#x21d2; Object </a>
230
+
231
+
232
+
233
+ </span>
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'>
244
+ <p>Writes data to the cache with an expiration time.</p>
245
+ </div></span>
246
+
247
+ </li>
248
+
249
+
250
+ </ul>
251
+
252
+
253
+ <div id="constructor_details" class="method_details_list">
254
+ <h2>Constructor Details</h2>
255
+
256
+ <div class="method_details first">
257
+ <h3 class="signature first" id="initialize-instance_method">
258
+
259
+ #<strong>initialize</strong> &#x21d2; <tt><span class='object_link'><a href="" title="ApiWrapper::Cache::CacheStore (class)">CacheStore</a></span></tt>
260
+
261
+
262
+
263
+
264
+
265
+ </h3><div class="docstring">
266
+ <div class="discussion">
267
+
268
+ <p>Returns a new instance of CacheStore.</p>
269
+
270
+
271
+ </div>
272
+ </div>
273
+ <div class="tags">
274
+
275
+
276
+ </div><table class="source_code">
277
+ <tr>
278
+ <td>
279
+ <pre class="lines">
280
+
281
+
282
+ 7
283
+ 8
284
+ 9</pre>
285
+ </td>
286
+ <td>
287
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_store.rb', line 7</span>
288
+
289
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
290
+ <span class='ivar'>@store</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
291
+ <span class='kw'>end</span></pre>
292
+ </td>
293
+ </tr>
294
+ </table>
295
+ </div>
296
+
297
+ </div>
298
+
299
+
300
+ <div id="instance_method_details" class="method_details_list">
301
+ <h2>Instance Method Details</h2>
302
+
303
+
304
+ <div class="method_details first">
305
+ <h3 class="signature first" id="delete-instance_method">
306
+
307
+ #<strong>delete</strong>(key) &#x21d2; <tt>Object</tt>
308
+
309
+
310
+
311
+
312
+
313
+ </h3><div class="docstring">
314
+ <div class="discussion">
315
+
316
+ <p>Deletes data from the cache.</p>
317
+
318
+
319
+ </div>
320
+ </div>
321
+ <div class="tags">
322
+ <p class="tag_title">Parameters:</p>
323
+ <ul class="param">
324
+
325
+ <li>
326
+
327
+ <span class='name'>key</span>
328
+
329
+
330
+ <span class='type'>(<tt>String</tt>)</span>
331
+
332
+
333
+
334
+ &mdash;
335
+ <div class='inline'>
336
+ <p>The cache key.</p>
337
+ </div>
338
+
339
+ </li>
340
+
341
+ </ul>
342
+
343
+
344
+ </div><table class="source_code">
345
+ <tr>
346
+ <td>
347
+ <pre class="lines">
348
+
349
+
350
+ 47
351
+ 48
352
+ 49</pre>
353
+ </td>
354
+ <td>
355
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_store.rb', line 47</span>
356
+
357
+ <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>
358
+ <span class='ivar'>@store</span><span class='period'>.</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>
359
+ <span class='kw'>end</span></pre>
360
+ </td>
361
+ </tr>
362
+ </table>
363
+ </div>
364
+
365
+ <div class="method_details ">
366
+ <h3 class="signature " id="fetch-instance_method">
367
+
368
+ #<strong>fetch</strong>(key, ttl) { ... } &#x21d2; <tt>Object</tt>
369
+
370
+
371
+
372
+
373
+
374
+ </h3><div class="docstring">
375
+ <div class="discussion">
376
+
377
+ <p>Retrieves the cached data for the given key, or fetches fresh data if not cached or expired.</p>
378
+
379
+
380
+ </div>
381
+ </div>
382
+ <div class="tags">
383
+ <p class="tag_title">Parameters:</p>
384
+ <ul class="param">
385
+
386
+ <li>
387
+
388
+ <span class='name'>key</span>
389
+
390
+
391
+ <span class='type'>(<tt>String</tt>)</span>
392
+
393
+
394
+
395
+ &mdash;
396
+ <div class='inline'>
397
+ <p>The cache key.</p>
398
+ </div>
399
+
400
+ </li>
401
+
402
+ <li>
403
+
404
+ <span class='name'>ttl</span>
405
+
406
+
407
+ <span class='type'>(<tt>Integer</tt>)</span>
408
+
409
+
410
+
411
+ &mdash;
412
+ <div class='inline'>
413
+ <p>The time-to-live in seconds.</p>
414
+ </div>
415
+
416
+ </li>
417
+
418
+ </ul>
419
+
420
+ <p class="tag_title">Yields:</p>
421
+ <ul class="yield">
422
+
423
+ <li>
424
+
425
+
426
+ <span class='type'></span>
427
+
428
+
429
+
430
+
431
+ <div class='inline'>
432
+ <p>Fetches fresh data if cache is expired or not present.</p>
433
+ </div>
434
+
435
+ </li>
436
+
437
+ </ul>
438
+ <p class="tag_title">Returns:</p>
439
+ <ul class="return">
440
+
441
+ <li>
442
+
443
+
444
+ <span class='type'>(<tt>Object</tt>)</span>
445
+
446
+
447
+
448
+ &mdash;
449
+ <div class='inline'>
450
+ <p>The cached data or the result of the block if not cached or expired.</p>
451
+ </div>
452
+
453
+ </li>
454
+
455
+ </ul>
456
+
457
+ </div><table class="source_code">
458
+ <tr>
459
+ <td>
460
+ <pre class="lines">
461
+
462
+
463
+ 17
464
+ 18
465
+ 19
466
+ 20
467
+ 21
468
+ 22
469
+ 23
470
+ 24
471
+ 25</pre>
472
+ </td>
473
+ <td>
474
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_store.rb', line 17</span>
475
+
476
+ <span class='kw'>def</span> <span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
477
+ <span class='kw'>if</span> <span class='id identifier rubyid_cached?'>cached?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
478
+ <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span>
479
+ <span class='kw'>else</span>
480
+ <span class='id identifier rubyid_fresh_data'>fresh_data</span> <span class='op'>=</span> <span class='kw'>yield</span>
481
+ <span class='id identifier rubyid_store'>store</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_fresh_data'>fresh_data</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
482
+ <span class='id identifier rubyid_fresh_data'>fresh_data</span>
483
+ <span class='kw'>end</span>
484
+ <span class='kw'>end</span></pre>
485
+ </td>
486
+ </tr>
487
+ </table>
488
+ </div>
489
+
490
+ <div class="method_details ">
491
+ <h3 class="signature " id="read-instance_method">
492
+
493
+ #<strong>read</strong>(key) &#x21d2; <tt>Object</tt><sup>?</sup>
494
+
495
+
496
+
497
+
498
+
499
+ </h3><div class="docstring">
500
+ <div class="discussion">
501
+
502
+ <p>Reads data from the cache.</p>
503
+
504
+
505
+ </div>
506
+ </div>
507
+ <div class="tags">
508
+ <p class="tag_title">Parameters:</p>
509
+ <ul class="param">
510
+
511
+ <li>
512
+
513
+ <span class='name'>key</span>
514
+
515
+
516
+ <span class='type'>(<tt>String</tt>)</span>
517
+
518
+
519
+
520
+ &mdash;
521
+ <div class='inline'>
522
+ <p>The cache key.</p>
523
+ </div>
524
+
525
+ </li>
526
+
527
+ </ul>
528
+
529
+ <p class="tag_title">Returns:</p>
530
+ <ul class="return">
531
+
532
+ <li>
533
+
534
+
535
+ <span class='type'>(<tt>Object</tt>, <tt>nil</tt>)</span>
536
+
537
+
538
+
539
+ &mdash;
540
+ <div class='inline'>
541
+ <p>The cached data, or nil if not present.</p>
542
+ </div>
543
+
544
+ </li>
545
+
546
+ </ul>
547
+
548
+ </div><table class="source_code">
549
+ <tr>
550
+ <td>
551
+ <pre class="lines">
552
+
553
+
554
+ 31
555
+ 32
556
+ 33</pre>
557
+ </td>
558
+ <td>
559
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_store.rb', line 31</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_cached?'>cached?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='kw'>nil</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
+ #<strong>write</strong>(key, data, ttl) &#x21d2; <tt>Object</tt>
573
+
574
+
575
+
576
+
577
+
578
+ </h3><div class="docstring">
579
+ <div class="discussion">
580
+
581
+ <p>Writes data to the cache with an expiration time.</p>
582
+
583
+
584
+ </div>
585
+ </div>
586
+ <div class="tags">
587
+ <p class="tag_title">Parameters:</p>
588
+ <ul class="param">
589
+
590
+ <li>
591
+
592
+ <span class='name'>key</span>
593
+
594
+
595
+ <span class='type'>(<tt>String</tt>)</span>
596
+
597
+
598
+
599
+ &mdash;
600
+ <div class='inline'>
601
+ <p>The cache key.</p>
602
+ </div>
603
+
604
+ </li>
605
+
606
+ <li>
607
+
608
+ <span class='name'>data</span>
609
+
610
+
611
+ <span class='type'>(<tt>Object</tt>)</span>
612
+
613
+
614
+
615
+ &mdash;
616
+ <div class='inline'>
617
+ <p>The data to cache.</p>
618
+ </div>
619
+
620
+ </li>
621
+
622
+ <li>
623
+
624
+ <span class='name'>ttl</span>
625
+
626
+
627
+ <span class='type'>(<tt>Integer</tt>)</span>
628
+
629
+
630
+
631
+ &mdash;
632
+ <div class='inline'>
633
+ <p>The time-to-live in seconds.</p>
634
+ </div>
635
+
636
+ </li>
637
+
638
+ </ul>
639
+
640
+
641
+ </div><table class="source_code">
642
+ <tr>
643
+ <td>
644
+ <pre class="lines">
645
+
646
+
647
+ 40
648
+ 41
649
+ 42</pre>
650
+ </td>
651
+ <td>
652
+ <pre class="code"><span class="info file"># File 'lib/api_wrapper/cache/cache_store.rb', line 40</span>
653
+
654
+ <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_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
655
+ <span class='id identifier rubyid_store'>store</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
656
+ <span class='kw'>end</span></pre>
657
+ </td>
658
+ </tr>
659
+ </table>
660
+ </div>
661
+
662
+ </div>
663
+
664
+ </div>
665
+
666
+ <div id="footer">
667
+ Generated on Mon Sep 16 23:22:30 2024 by
668
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
669
+ 0.9.37 (ruby-3.2.2).
670
+ </div>
671
+
672
+ </div>
673
+ </body>
674
+ </html>