volatiledb 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/TODO.md CHANGED
@@ -1,4 +1,5 @@
1
- *TODOS*
2
- - the API assumes that put is called before all
3
- other methods. ensure that get/fetch/pull return
4
- nil if no action has been defined for the given key.
1
+ **TODOS**
2
+
3
+ - add some minitest tests to demonstrate usage
4
+ - flesh out documentation
5
+ - make sure the documentation is hosted
data/doc/Gemfile.html ADDED
@@ -0,0 +1,94 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
8
+
9
+ <title>File: Gemfile [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file">
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="project-metadata">
36
+
37
+
38
+ <div id="fileindex-section" class="section project-section">
39
+ <h3 class="section-header">Files</h3>
40
+ <ul>
41
+
42
+ <li class="file"><a href="./Gemfile.html">Gemfile</a></li>
43
+
44
+ <li class="file"><a href="./Rakefile.html">Rakefile</a></li>
45
+
46
+ </ul>
47
+ </div>
48
+
49
+
50
+ <div id="classindex-section" class="section project-section">
51
+ <h3 class="section-header">Class Index
52
+ <span class="search-toggle"><img src="./images/find.png"
53
+ height="16" width="16" alt="[+]"
54
+ title="show/hide quicksearch" /></span></h3>
55
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
56
+ <fieldset>
57
+ <legend>Quicksearch</legend>
58
+ <input type="text" name="quicksearch" value=""
59
+ class="quicksearch-field" />
60
+ </fieldset>
61
+ </form>
62
+
63
+ <ul class="link-list">
64
+
65
+ <li><a href="./Volatile.html">Volatile</a></li>
66
+
67
+ <li><a href="./Volatile/DB.html">Volatile::DB</a></li>
68
+
69
+ <li><a href="./Volatile/Raw.html">Volatile::Raw</a></li>
70
+
71
+ </ul>
72
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
73
+ </div>
74
+
75
+
76
+ </div>
77
+ </div>
78
+
79
+ <div id="documentation">
80
+
81
+ <p>source "<a href="http://rubygems.org">rubygems.org</a>"</p>
82
+
83
+ <p># Specify your gem's dependencies in volatiledb.gemspec gemspec</p>
84
+
85
+ </div>
86
+
87
+ <div id="validator-badges">
88
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
89
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
90
+ Rdoc Generator</a> 2</small>.</p>
91
+ </div>
92
+ </body>
93
+ </html>
94
+
data/doc/Rakefile.html ADDED
@@ -0,0 +1,92 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
8
+
9
+ <title>File: Rakefile [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file">
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="project-metadata">
36
+
37
+
38
+ <div id="fileindex-section" class="section project-section">
39
+ <h3 class="section-header">Files</h3>
40
+ <ul>
41
+
42
+ <li class="file"><a href="./Gemfile.html">Gemfile</a></li>
43
+
44
+ <li class="file"><a href="./Rakefile.html">Rakefile</a></li>
45
+
46
+ </ul>
47
+ </div>
48
+
49
+
50
+ <div id="classindex-section" class="section project-section">
51
+ <h3 class="section-header">Class Index
52
+ <span class="search-toggle"><img src="./images/find.png"
53
+ height="16" width="16" alt="[+]"
54
+ title="show/hide quicksearch" /></span></h3>
55
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
56
+ <fieldset>
57
+ <legend>Quicksearch</legend>
58
+ <input type="text" name="quicksearch" value=""
59
+ class="quicksearch-field" />
60
+ </fieldset>
61
+ </form>
62
+
63
+ <ul class="link-list">
64
+
65
+ <li><a href="./Volatile.html">Volatile</a></li>
66
+
67
+ <li><a href="./Volatile/DB.html">Volatile::DB</a></li>
68
+
69
+ <li><a href="./Volatile/Raw.html">Volatile::Raw</a></li>
70
+
71
+ </ul>
72
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
73
+ </div>
74
+
75
+
76
+ </div>
77
+ </div>
78
+
79
+ <div id="documentation">
80
+
81
+ <p>require "bundler/gem_tasks"</p>
82
+
83
+ </div>
84
+
85
+ <div id="validator-badges">
86
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
87
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
88
+ Rdoc Generator</a> 2</small>.</p>
89
+ </div>
90
+ </body>
91
+ </html>
92
+
@@ -0,0 +1,366 @@
1
+ <?xml version="1.0" encoding="US-ASCII"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
7
+
8
+ <title>Class: Volatile::DB</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="class">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="../index.html">Home</a>
25
+ <a href="../index.html#classes">Classes</a>
26
+ <a href="../index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../lib/volatiledb_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/volatiledb.rb">lib/volatiledb.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+ <!-- Parent Class -->
50
+ <div id="parent-class-section" class="section">
51
+ <h3 class="section-header">Parent</h3>
52
+
53
+ <p class="link">Object</p>
54
+
55
+ </div>
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ <!-- Method Quickref -->
64
+ <div id="method-list-section" class="section">
65
+ <h3 class="section-header">Methods</h3>
66
+ <ul class="link-list">
67
+
68
+ <li><a href="#method-c-new">::new</a></li>
69
+
70
+ <li><a href="#method-i-fetch">#fetch</a></li>
71
+
72
+ <li><a href="#method-i-get">#get</a></li>
73
+
74
+ <li><a href="#method-i-pull">#pull</a></li>
75
+
76
+ <li><a href="#method-i-put">#put</a></li>
77
+
78
+ </ul>
79
+ </div>
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="project-metadata">
86
+
87
+
88
+ <div id="fileindex-section" class="section project-section">
89
+ <h3 class="section-header">Files</h3>
90
+ <ul>
91
+
92
+ <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
93
+
94
+ <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
95
+
96
+ </ul>
97
+ </div>
98
+
99
+
100
+ <div id="classindex-section" class="section project-section">
101
+ <h3 class="section-header">Class/Module Index
102
+ <span class="search-toggle"><img src="../images/find.png"
103
+ height="16" width="16" alt="[+]"
104
+ title="show/hide quicksearch" /></span></h3>
105
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
106
+ <fieldset>
107
+ <legend>Quicksearch</legend>
108
+ <input type="text" name="quicksearch" value=""
109
+ class="quicksearch-field" />
110
+ </fieldset>
111
+ </form>
112
+
113
+ <ul class="link-list">
114
+
115
+ <li><a href="../Volatile.html">Volatile</a></li>
116
+
117
+ <li><a href="../Volatile/DB.html">Volatile::DB</a></li>
118
+
119
+ <li><a href="../Volatile/Raw.html">Volatile::Raw</a></li>
120
+
121
+ </ul>
122
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
123
+ </div>
124
+
125
+
126
+ </div>
127
+ </div>
128
+
129
+ <div id="documentation">
130
+ <h1 class="class">Volatile::DB</h1>
131
+
132
+ <div id="description" class="description">
133
+
134
+ <p>The main <a href="DB.html">DB</a> class. This is the public API for the
135
+ library.</p>
136
+
137
+ </div><!-- description -->
138
+
139
+
140
+ <div id="5Buntitled-5D" class="documentation-section">
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ <!-- Methods -->
150
+
151
+ <div id="public-class-method-details" class="method-section section">
152
+ <h3 class="section-header">Public Class Methods</h3>
153
+
154
+
155
+ <div id="new-method" class="method-detail ">
156
+ <a name="method-c-new"></a>
157
+
158
+
159
+ <div class="method-heading">
160
+ <span class="method-name">new</span><span
161
+ class="method-args">()</span>
162
+ <span class="method-click-advice">click to toggle source</span>
163
+ </div>
164
+
165
+
166
+ <div class="method-description">
167
+
168
+ <p>Constructor, nothing fancy.</p>
169
+
170
+
171
+
172
+ <div class="method-source-code" id="new-source">
173
+ <pre>
174
+ <span class="ruby-comment"># File lib/volatiledb.rb, line 17</span>
175
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
176
+ <span class="ruby-ivar">@raw</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Volatile</span><span class="ruby-operator">::</span><span class="ruby-constant">Raw</span>.<span class="ruby-identifier">new</span>
177
+ <span class="ruby-ivar">@db</span> <span class="ruby-operator">||=</span> {}
178
+ <span class="ruby-keyword">end</span></pre>
179
+ </div><!-- new-source -->
180
+
181
+ </div>
182
+
183
+
184
+
185
+
186
+ </div><!-- new-method -->
187
+
188
+
189
+ </div><!-- public-class-method-details -->
190
+
191
+ <div id="public-instance-method-details" class="method-section section">
192
+ <h3 class="section-header">Public Instance Methods</h3>
193
+
194
+
195
+ <div id="fetch-method" class="method-detail ">
196
+ <a name="method-i-fetch"></a>
197
+
198
+
199
+ <div class="method-heading">
200
+ <span class="method-name">fetch</span><span
201
+ class="method-args">(key)</span>
202
+ <span class="method-click-advice">click to toggle source</span>
203
+ </div>
204
+
205
+
206
+ <div class="method-description">
207
+
208
+ <p>Works the same as get, but will fire the action defined for the given key
209
+ after the timeout defined for that key has elapsed.</p>
210
+
211
+ <p>Returns nil for a key which has not had any action defined for it yet.</p>
212
+
213
+
214
+
215
+ <div class="method-source-code" id="fetch-source">
216
+ <pre>
217
+ <span class="ruby-comment"># File lib/volatiledb.rb, line 55</span>
218
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">key</span>)
219
+ <span class="ruby-identifier">checking</span> <span class="ruby-identifier">key</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
220
+ <span class="ruby-identifier">item</span> = <span class="ruby-ivar">@db</span>[<span class="ruby-identifier">k</span>]
221
+ <span class="ruby-identifier">delta</span> = <span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">item</span>[<span class="ruby-value">:last_access</span>]
222
+ <span class="ruby-identifier">delta</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">item</span>[<span class="ruby-value">:timeout</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">sync</span>(<span class="ruby-identifier">k</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">k</span>)
223
+ <span class="ruby-keyword">end</span>
224
+ <span class="ruby-keyword">end</span></pre>
225
+ </div><!-- fetch-source -->
226
+
227
+ </div>
228
+
229
+
230
+
231
+
232
+ </div><!-- fetch-method -->
233
+
234
+
235
+ <div id="get-method" class="method-detail ">
236
+ <a name="method-i-get"></a>
237
+
238
+
239
+ <div class="method-heading">
240
+ <span class="method-name">get</span><span
241
+ class="method-args">(key)</span>
242
+ <span class="method-click-advice">click to toggle source</span>
243
+ </div>
244
+
245
+
246
+ <div class="method-description">
247
+
248
+ <p>Read the data for the given key from storage. If the underlying storage
249
+ has disappeared, it will be re-initialized by calling the action defined
250
+ for that key again. After the storage has been re-initialized, its value
251
+ will be read and returned.</p>
252
+
253
+ <p>Returns nil for a key which has not had any action defined for it yet.</p>
254
+
255
+
256
+
257
+ <div class="method-source-code" id="get-source">
258
+ <pre>
259
+ <span class="ruby-comment"># File lib/volatiledb.rb, line 40</span>
260
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
261
+ <span class="ruby-identifier">data</span> = <span class="ruby-ivar">@raw</span>.<span class="ruby-identifier">get</span> <span class="ruby-identifier">key</span>
262
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
263
+ <span class="ruby-identifier">sync</span> <span class="ruby-identifier">key</span>
264
+ <span class="ruby-keyword">else</span>
265
+ <span class="ruby-identifier">data</span>
266
+ <span class="ruby-keyword">end</span>
267
+ <span class="ruby-keyword">end</span></pre>
268
+ </div><!-- get-source -->
269
+
270
+ </div>
271
+
272
+
273
+
274
+
275
+ </div><!-- get-method -->
276
+
277
+
278
+ <div id="pull-method" class="method-detail ">
279
+ <a name="method-i-pull"></a>
280
+
281
+
282
+ <div class="method-heading">
283
+ <span class="method-name">pull</span><span
284
+ class="method-args">(key)</span>
285
+ <span class="method-click-advice">click to toggle source</span>
286
+ </div>
287
+
288
+
289
+ <div class="method-description">
290
+
291
+ <p>Works the same as fetch, but ignores timeout and calls the defined action
292
+ every time. Should be used sparingly as it re-initializes storage on every
293
+ call.</p>
294
+
295
+ <p>Returns nil for a key which has not had any action defined for it yet.</p>
296
+
297
+
298
+
299
+ <div class="method-source-code" id="pull-source">
300
+ <pre>
301
+ <span class="ruby-comment"># File lib/volatiledb.rb, line 70</span>
302
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">pull</span>(<span class="ruby-identifier">key</span>)
303
+ <span class="ruby-identifier">sync</span> <span class="ruby-identifier">key</span>
304
+ <span class="ruby-keyword">end</span></pre>
305
+ </div><!-- pull-source -->
306
+
307
+ </div>
308
+
309
+
310
+
311
+
312
+ </div><!-- pull-method -->
313
+
314
+
315
+ <div id="put-method" class="method-detail ">
316
+ <a name="method-i-put"></a>
317
+
318
+
319
+ <div class="method-heading">
320
+ <span class="method-name">put</span><span
321
+ class="method-args">(key, timeout=3, &action)</span>
322
+ <span class="method-click-advice">click to toggle source</span>
323
+ </div>
324
+
325
+
326
+ <div class="method-description">
327
+
328
+ <p>Define an action for a given key. The action should return a String. A
329
+ timeout in seconds may optionally be defined. Default is 3 seconds.</p>
330
+
331
+
332
+
333
+ <div class="method-source-code" id="put-source">
334
+ <pre>
335
+ <span class="ruby-comment"># File lib/volatiledb.rb, line 26</span>
336
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">timeout</span>=<span class="ruby-value">3</span>, &amp;<span class="ruby-identifier">action</span>)
337
+ <span class="ruby-identifier">populate_db</span> <span class="ruby-identifier">key</span>, <span class="ruby-identifier">timeout</span>, <span class="ruby-identifier">action</span>
338
+ <span class="ruby-identifier">raw_put</span> <span class="ruby-identifier">key</span>
339
+ <span class="ruby-identifier">key</span>
340
+ <span class="ruby-keyword">end</span></pre>
341
+ </div><!-- put-source -->
342
+
343
+ </div>
344
+
345
+
346
+
347
+
348
+ </div><!-- put-method -->
349
+
350
+
351
+ </div><!-- public-instance-method-details -->
352
+
353
+ </div><!-- 5Buntitled-5D -->
354
+
355
+
356
+ </div><!-- documentation -->
357
+
358
+ <div id="validator-badges">
359
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
360
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
361
+ Rdoc Generator</a> 2</small>.</p>
362
+ </div>
363
+
364
+ </body>
365
+ </html>
366
+