sadie 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -0,0 +1,17 @@
1
+ ==About
2
+
3
+ Sadie is a data framework intended to ease the pain of constructing, accessing, and managing the resources required by large stores of inter-related data. It supports sessions, lazy on-demand, one-time evaluation and file-based storage/retrieval operations for resource-heavy data.
4
+
5
+ It can be downloaded via its rubygems page
6
+
7
+ https://rubygems.org/gems/sadie
8
+
9
+ or from github:
10
+
11
+ https://github.com/FredAtLandMetrics/sadie
12
+
13
+ ==Summary
14
+
15
+ Sadie exists to de-couple the assembling of large, related datasets from the rest of an application so that intelligent, manual optimizations become more apparent. A common usage would be to query an entire table, then, as the single query is iterated on, perform multiple, simultaneous calculations on the dataset where, in other situations, the calculations might have required multiple similar queries to the database.
16
+
17
+ In LandMetrics' perimetercomps ( http://perimetercomps.com ), a similar framework was developed such that, given just a few initial parameters, all of the information for the 50+ page report was assembled with only 12 queries and a myriad of graphs, charts and tables are constructed from the single optimized data storage mechanism.
data/lib/sadie/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # this file sets the version of the Sadie gem
3
3
 
4
4
  class Sadie
5
- VERSION = "0.0.4"
5
+ VERSION = "0.0.5"
6
6
  end
@@ -0,0 +1,533 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Sadie</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Sadie</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/sadie_rb.html">
59
+ lib/sadie.rb
60
+ </a>
61
+ <br />
62
+ <a href="../files/lib/sadie/version_rb.html">
63
+ lib/sadie/version.rb
64
+ </a>
65
+ <br />
66
+ <a href="../files/lib/sadie/defaults_rb.html">
67
+ lib/sadie/defaults.rb
68
+ </a>
69
+ <br />
70
+ </td>
71
+ </tr>
72
+
73
+ <tr class="top-aligned-row">
74
+ <td><strong>Parent:</strong></td>
75
+ <td>
76
+ Object
77
+ </td>
78
+ </tr>
79
+ </table>
80
+ </div>
81
+ <!-- banner header -->
82
+
83
+ <div id="bodyContent">
84
+
85
+
86
+
87
+ <div id="contextContent">
88
+
89
+ <div id="description">
90
+ <h2>Notes</h2>
91
+ <p>
92
+ this file sets defaults which can and should be overridden using arguments
93
+ the sadie constructor
94
+ </p>
95
+
96
+ </div>
97
+
98
+
99
+ </div>
100
+
101
+ <div id="method-list">
102
+ <h3 class="section-bar">Methods</h3>
103
+
104
+ <div class="name-list">
105
+ <a href="#M000003">Prime</a>&nbsp;&nbsp;
106
+ <a href="#M000004">get</a>&nbsp;&nbsp;
107
+ <a href="#M000002">getSadieInstance</a>&nbsp;&nbsp;
108
+ <a href="#M000001">new</a>&nbsp;&nbsp;
109
+ <a href="#M000009">revert!</a>&nbsp;&nbsp;
110
+ <a href="#M000008">save</a>&nbsp;&nbsp;
111
+ <a href="#M000006">set</a>&nbsp;&nbsp;
112
+ <a href="#M000007">setCheap</a>&nbsp;&nbsp;
113
+ <a href="#M000005">setExpensive</a>&nbsp;&nbsp;
114
+ </div>
115
+ </div>
116
+
117
+ </div>
118
+
119
+
120
+ <!-- if includes -->
121
+
122
+ <div id="section">
123
+
124
+
125
+ <div id="constants-list">
126
+ <h3 class="section-bar">Constants</h3>
127
+
128
+ <div class="name-list">
129
+ <table summary="Constants">
130
+ <tr class="top-aligned-row context-row">
131
+ <td class="context-item-name">VERSION</td>
132
+ <td>=</td>
133
+ <td class="context-item-value">&quot;0.0.4&quot;</td>
134
+ </tr>
135
+ <tr class="top-aligned-row context-row">
136
+ <td class="context-item-name">DEFAULTS</td>
137
+ <td>=</td>
138
+ <td class="context-item-value">{ &quot;sadie.primers_dirpath&quot; =&gt; File.expand_path(&quot;primers&quot;,&quot;/var/sadie&quot;), &quot;sadie.sessions_dirpath&quot; =&gt; File.expand_path(&quot;sessions&quot;,&quot;/var/sadie&quot;)</td>
139
+ </tr>
140
+ </table>
141
+ </div>
142
+ </div>
143
+
144
+
145
+
146
+
147
+
148
+
149
+ <!-- if method_list -->
150
+ <div id="methods">
151
+ <h3 class="section-bar">Public Class methods</h3>
152
+
153
+ <div id="method-M000003" class="method-detail">
154
+ <a name="M000003"></a>
155
+
156
+ <div class="method-heading">
157
+ <a href="#M000003" class="method-signature">
158
+ <span class="method-name">Prime</span><span class="method-args">( primer_definition ) {|current_sadie_instance| ...}</span>
159
+ </a>
160
+ </div>
161
+
162
+ <div class="method-description">
163
+ <h2>method: Sadie::Prime</h2>
164
+ <p>
165
+ called my the .res files to register the keys the .res will prime for
166
+ </p>
167
+ <p>
168
+ accepts as an argument a hash and a block. The hash must include the key:
169
+ &#8216;provides&#8217; and it must define an array of keys that the calling
170
+ resource (.res) file will have provided after the block is evaluated
171
+ </p>
172
+ <p><a class="source-toggle" href="#"
173
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
174
+ <div class="method-source-code" id="M000003-source">
175
+ <pre>
176
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 95</span>
177
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-constant">Prime</span> ( <span class="ruby-identifier">primer_definition</span> )
178
+
179
+ <span class="ruby-comment cmt"># validate params</span>
180
+ <span class="ruby-keyword kw">defined?</span> <span class="ruby-identifier">primer_definition</span> \
181
+ <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Prime called without parameters&quot;</span>
182
+ <span class="ruby-identifier">primer_definition</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span> \
183
+ <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Prime called without hash parameters&quot;</span>
184
+ <span class="ruby-keyword kw">defined?</span> <span class="ruby-identifier">primer_definition</span>[<span class="ruby-value str">&quot;provides&quot;</span>] \
185
+ <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Prime called without provides parameter&quot;</span>
186
+
187
+ <span class="ruby-comment cmt"># if initializing primers, just remember how to get back to the primer later,</span>
188
+ <span class="ruby-comment cmt"># otherwise, prime</span>
189
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_midPrimerInit?</span>
190
+ <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_memorizePrimerLocation</span>( <span class="ruby-ivar">@@mid_primer_filepath</span>, <span class="ruby-identifier">primer_definition</span>[<span class="ruby-value str">&quot;provides&quot;</span>] )
191
+ <span class="ruby-keyword kw">else</span>
192
+ <span class="ruby-identifier">current_sadie_instance</span> = <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_getCurrentSadieInstance</span>
193
+ <span class="ruby-identifier">current_primer_filepath</span> = <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_getCurrentPrimerFilepath</span>
194
+ <span class="ruby-keyword kw">yield</span>( <span class="ruby-identifier">current_sadie_instance</span> )
195
+ <span class="ruby-identifier">primer_definition</span>[<span class="ruby-value str">&quot;provides&quot;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">|</span>
196
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">match</span> <span class="ruby-regexp re">/^\s*$/</span>
197
+ <span class="ruby-comment cmt">#puts &quot;Prime&gt; providing: #{key}&quot;</span>
198
+ <span class="ruby-identifier">current_sadie_instance</span>.<span class="ruby-identifier">primed?</span> <span class="ruby-identifier">key</span> \
199
+ <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;primer definition file: #{current_primer_filepath} was supposed to define #{key}, but did not&quot;</span>
200
+ <span class="ruby-keyword kw">end</span>
201
+ <span class="ruby-keyword kw">end</span>
202
+ <span class="ruby-keyword kw">end</span>
203
+ </pre>
204
+ </div>
205
+ </div>
206
+ </div>
207
+
208
+ <div id="method-M000002" class="method-detail">
209
+ <a name="M000002"></a>
210
+
211
+ <div class="method-heading">
212
+ <a href="#M000002" class="method-signature">
213
+ <span class="method-name">getSadieInstance</span><span class="method-args">( options )</span>
214
+ </a>
215
+ </div>
216
+
217
+ <div class="method-description">
218
+ <h2>method: Sadie::getSadieInstance</h2>
219
+ <p>
220
+ returns a <a href="Sadie.html#M000001">new</a> <a
221
+ href="Sadie.html">Sadie</a> instance. Options match those of <a
222
+ href="Sadie.html">Sadie</a>&#8216;s constructor method
223
+ </p>
224
+ <p><a class="source-toggle" href="#"
225
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
226
+ <div class="method-source-code" id="M000002-source">
227
+ <pre>
228
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 83</span>
229
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">getSadieInstance</span>( <span class="ruby-identifier">options</span> )
230
+ <span class="ruby-constant">Sadie</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)
231
+ <span class="ruby-keyword kw">end</span>
232
+ </pre>
233
+ </div>
234
+ </div>
235
+ </div>
236
+
237
+ <div id="method-M000001" class="method-detail">
238
+ <a name="M000001"></a>
239
+
240
+ <div class="method-heading">
241
+ <a href="#M000001" class="method-signature">
242
+ <span class="method-name">new</span><span class="method-args">( options )</span>
243
+ </a>
244
+ </div>
245
+
246
+ <div class="method-description">
247
+ <h2>method: constructor</h2>
248
+ <pre>
249
+ options can include any kay, value pairs but the following key values bear mention:
250
+ REQUIRED
251
+
252
+ sadie.sessions_dirpath
253
+ or
254
+ sadie.session_id
255
+ or
256
+ sadie.session_filepath &lt;- this is probably a bad call, use with caution
257
+
258
+ and
259
+
260
+ sadie.primers_dirpath
261
+ </pre>
262
+ <p><a class="source-toggle" href="#"
263
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
264
+ <div class="method-source-code" id="M000001-source">
265
+ <pre>
266
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 36</span>
267
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">options</span> )
268
+
269
+ <span class="ruby-comment cmt"># start with blank slate short-term memory, primed and expensive flag hashes</span>
270
+ <span class="ruby-ivar">@shortterm</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
271
+ <span class="ruby-ivar">@flag_expensive</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
272
+ <span class="ruby-ivar">@flag_primed</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
273
+
274
+ <span class="ruby-comment cmt"># init class</span>
275
+ <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_checkSanity</span>
276
+
277
+ <span class="ruby-comment cmt"># init mid_primer_initialization if not already done</span>
278
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@mid_primer_initialization</span>
279
+ <span class="ruby-ivar">@@mid_primer_initialization</span> = <span class="ruby-keyword kw">false</span>
280
+ <span class="ruby-ivar">@@mid_primer_filepath</span> = <span class="ruby-keyword kw">nil</span>
281
+ <span class="ruby-ivar">@@mid_primer_toplevel_primer_dirpath</span> = <span class="ruby-keyword kw">nil</span>
282
+ <span class="ruby-keyword kw">end</span>
283
+
284
+ <span class="ruby-comment cmt"># internalize defaults to shortterm</span>
285
+ <span class="ruby-constant">DEFAULTS</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
286
+ <span class="ruby-identifier">_set</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span> )
287
+ <span class="ruby-keyword kw">end</span>
288
+
289
+ <span class="ruby-comment cmt"># internalize supplied defaults</span>
290
+ <span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
291
+ <span class="ruby-identifier">set</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span> )
292
+ <span class="ruby-keyword kw">end</span>
293
+
294
+ <span class="ruby-comment cmt"># if a path to a session is given, init using session file</span>
295
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sadie</span>.<span class="ruby-identifier">session_filepath</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sadie</span>.<span class="ruby-identifier">session_filepath</span>].<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/^[^\s]+$/</span>)
296
+ <span class="ruby-identifier">set</span>( <span class="ruby-value str">&quot;sadie.session_filepath&quot;</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sadie</span>.<span class="ruby-identifier">session_filepath</span>] )
297
+ <span class="ruby-identifier">_initializeWithSessionFilePath</span>( <span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;sadie.session_filepath&quot;</span>) )
298
+ <span class="ruby-keyword kw">return</span>
299
+ <span class="ruby-keyword kw">end</span>
300
+
301
+ <span class="ruby-comment cmt"># determine session id, init from session if provided as arg</span>
302
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sadie</span>.<span class="ruby-identifier">session_id</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sadie</span>.<span class="ruby-identifier">session_id</span>].<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/^[^\s]+$/</span>)
303
+ <span class="ruby-identifier">set</span>( <span class="ruby-value str">&quot;sadie.session_id&quot;</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sadie</span>.<span class="ruby-identifier">session_id</span>] )
304
+ <span class="ruby-identifier">_initializeWithSessionId</span>( <span class="ruby-identifier">get</span>( <span class="ruby-value str">&quot;sadie.session_id&quot;</span> ) )
305
+ <span class="ruby-keyword kw">else</span>
306
+ <span class="ruby-identifier">set</span>( <span class="ruby-value str">&quot;sadie.session_id&quot;</span>, <span class="ruby-identifier">_generateNewSessionId</span> )
307
+ <span class="ruby-keyword kw">end</span>
308
+
309
+ <span class="ruby-keyword kw">end</span>
310
+ </pre>
311
+ </div>
312
+ </div>
313
+ </div>
314
+
315
+ <h3 class="section-bar">Public Instance methods</h3>
316
+
317
+ <div id="method-M000004" class="method-detail">
318
+ <a name="M000004"></a>
319
+
320
+ <div class="method-heading">
321
+ <a href="#M000004" class="method-signature">
322
+ <span class="method-name">get</span><span class="method-args">( k )</span>
323
+ </a>
324
+ </div>
325
+
326
+ <div class="method-description">
327
+ <h2>method: <a href="Sadie.html#M000004">get</a></h2>
328
+ <p>
329
+ a standard getter which primes the unprimed and recalls
330
+ &quot;expensive&quot; facts from files completely behind-the-scenes as
331
+ directed by the resource (.res) files
332
+ </p>
333
+ <p><a class="source-toggle" href="#"
334
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
335
+ <div class="method-source-code" id="M000004-source">
336
+ <pre>
337
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 126</span>
338
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>( <span class="ruby-identifier">k</span> )
339
+
340
+ <span class="ruby-comment cmt"># prime if not yet primed</span>
341
+ <span class="ruby-identifier">primed?</span>( <span class="ruby-identifier">k</span> ) \
342
+ <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">_prime</span>( <span class="ruby-identifier">k</span> )
343
+
344
+ <span class="ruby-comment cmt"># if not expensive, then return what's already known</span>
345
+ <span class="ruby-identifier">expensive?</span>( <span class="ruby-identifier">k</span> ) \
346
+ <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">_get</span>( <span class="ruby-identifier">k</span> )
347
+
348
+ <span class="ruby-comment cmt"># expensive, so recall from file</span>
349
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">_recallExpensive</span>( <span class="ruby-identifier">k</span> )
350
+ <span class="ruby-keyword kw">end</span>
351
+ </pre>
352
+ </div>
353
+ </div>
354
+ </div>
355
+
356
+ <div id="method-M000009" class="method-detail">
357
+ <a name="M000009"></a>
358
+
359
+ <div class="method-heading">
360
+ <a href="#M000009" class="method-signature">
361
+ <span class="method-name">revert!</span><span class="method-args">()</span>
362
+ </a>
363
+ </div>
364
+
365
+ <div class="method-description">
366
+ <h2>method: <a href="Sadie.html#M000009">revert!</a></h2>
367
+ <p>
368
+ return to last saved state
369
+ </p>
370
+ <p><a class="source-toggle" href="#"
371
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
372
+ <div class="method-source-code" id="M000009-source">
373
+ <pre>
374
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 194</span>
375
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert!</span>
376
+
377
+ <span class="ruby-ivar">@shortterm</span> = {
378
+ <span class="ruby-value str">&quot;sadie.session_id&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">get</span>( <span class="ruby-value str">&quot;sadie.session_id&quot;</span> ),
379
+ <span class="ruby-value str">&quot;sadie.sessions_dirpath&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">get</span>( <span class="ruby-value str">&quot;sadie.sessions_dirpath&quot;</span> )
380
+ }
381
+
382
+ <span class="ruby-identifier">_initializeWithSessionId</span>( <span class="ruby-identifier">get</span>( <span class="ruby-value str">&quot;sadie.session_id&quot;</span> ) )
383
+ <span class="ruby-keyword kw">end</span>
384
+ </pre>
385
+ </div>
386
+ </div>
387
+ </div>
388
+
389
+ <div id="method-M000008" class="method-detail">
390
+ <a name="M000008"></a>
391
+
392
+ <div class="method-heading">
393
+ <a href="#M000008" class="method-signature">
394
+ <span class="method-name">save</span><span class="method-args">()</span>
395
+ </a>
396
+ </div>
397
+
398
+ <div class="method-description">
399
+ <h2>method: <a href="Sadie.html#M000008">save</a></h2>
400
+ <p>
401
+ serialize to session file
402
+ </p>
403
+ <p><a class="source-toggle" href="#"
404
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
405
+ <div class="method-source-code" id="M000008-source">
406
+ <pre>
407
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 182</span>
408
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>
409
+ <span class="ruby-identifier">session_filepath</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-value str">&quot;session.&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">get</span>( <span class="ruby-value str">&quot;sadie.sessions_dirpath&quot;</span> ) )
410
+ <span class="ruby-identifier">serialized_value</span> = <span class="ruby-constant">Marshal</span><span class="ruby-operator">::</span><span class="ruby-identifier">dump</span>( [ <span class="ruby-ivar">@shortterm</span>, <span class="ruby-ivar">@flag_primed</span>, <span class="ruby-ivar">@flag_expensive</span> ] )
411
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">session_filepath</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
412
+ <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>( <span class="ruby-identifier">serialized_value</span> )
413
+ }
414
+ <span class="ruby-keyword kw">end</span>
415
+ </pre>
416
+ </div>
417
+ </div>
418
+ </div>
419
+
420
+ <div id="method-M000006" class="method-detail">
421
+ <a name="M000006"></a>
422
+
423
+ <div class="method-heading">
424
+ <a href="#M000006" class="method-signature">
425
+ <span class="method-name">set</span><span class="method-args">( k, v )</span>
426
+ </a>
427
+ </div>
428
+
429
+ <div class="method-description">
430
+ <h2>method: <a href="Sadie.html#M000006">set</a></h2>
431
+ <p>
432
+ alias for <a href="Sadie.html#M000007">setCheap</a>(k,v)
433
+ </p>
434
+ <p><a class="source-toggle" href="#"
435
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
436
+ <div class="method-source-code" id="M000006-source">
437
+ <pre>
438
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 156</span>
439
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>( <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> )
440
+ <span class="ruby-identifier">setCheap</span>( <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> )
441
+ <span class="ruby-keyword kw">end</span>
442
+ </pre>
443
+ </div>
444
+ </div>
445
+ </div>
446
+
447
+ <div id="method-M000007" class="method-detail">
448
+ <a name="M000007"></a>
449
+
450
+ <div class="method-heading">
451
+ <a href="#M000007" class="method-signature">
452
+ <span class="method-name">setCheap</span><span class="method-args">(k,v)</span>
453
+ </a>
454
+ </div>
455
+
456
+ <div class="method-description">
457
+ <h2>method: <a href="Sadie.html#M000007">setCheap</a></h2>
458
+ <p>
459
+ the cheap setter. key, value pairs stored via this method are kept in
460
+ memory
461
+ </p>
462
+ <p><a class="source-toggle" href="#"
463
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
464
+ <div class="method-source-code" id="M000007-source">
465
+ <pre>
466
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 163</span>
467
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setCheap</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)
468
+
469
+ <span class="ruby-comment cmt"># set it, mark not expensive and primed</span>
470
+ <span class="ruby-identifier">_set</span>( <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> )
471
+ <span class="ruby-identifier">_expensive</span>( <span class="ruby-identifier">k</span>, <span class="ruby-keyword kw">false</span> )
472
+ <span class="ruby-identifier">_primed</span>( <span class="ruby-identifier">k</span>, <span class="ruby-keyword kw">true</span> )
473
+
474
+ <span class="ruby-comment cmt"># if we've reset the primers dirpath, init the primers</span>
475
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">eql?</span>( <span class="ruby-value str">&quot;sadie.primers_dirpath&quot;</span> )
476
+ <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_setMidPrimerTopLevelPrimersDirpath</span>( <span class="ruby-identifier">v</span> )
477
+ <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_setCurrentSadieInstance</span>( <span class="ruby-keyword kw">self</span> )
478
+ <span class="ruby-constant">Sadie</span><span class="ruby-operator">::</span><span class="ruby-identifier">_init_primers</span>
479
+ <span class="ruby-keyword kw">end</span>
480
+
481
+ <span class="ruby-keyword kw">end</span>
482
+ </pre>
483
+ </div>
484
+ </div>
485
+ </div>
486
+
487
+ <div id="method-M000005" class="method-detail">
488
+ <a name="M000005"></a>
489
+
490
+ <div class="method-heading">
491
+ <a href="#M000005" class="method-signature">
492
+ <span class="method-name">setExpensive</span><span class="method-args">(k,v)</span>
493
+ </a>
494
+ </div>
495
+
496
+ <div class="method-description">
497
+ <h2>method: <a href="Sadie.html#M000007">setCheap</a></h2>
498
+ <p>
499
+ the expensive setter. key, value pairs stored via this method are not kept
500
+ in memory but are stored to file and recalled as needed
501
+ </p>
502
+ <p><a class="source-toggle" href="#"
503
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
504
+ <div class="method-source-code" id="M000005-source">
505
+ <pre>
506
+ <span class="ruby-comment cmt"># File lib/sadie.rb, line 144</span>
507
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setExpensive</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)
508
+ <span class="ruby-identifier">expensive_filepath</span> = <span class="ruby-identifier">_computeExpensiveFilepath</span>( <span class="ruby-identifier">k</span> )
509
+ <span class="ruby-identifier">serialized_value</span> = <span class="ruby-constant">Marshal</span><span class="ruby-operator">::</span><span class="ruby-identifier">dump</span>( <span class="ruby-identifier">v</span> )
510
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">expensive_filepath</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
511
+ <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>( <span class="ruby-identifier">serialized_value</span> )
512
+ }
513
+ <span class="ruby-identifier">_expensive</span>( <span class="ruby-identifier">k</span>, <span class="ruby-keyword kw">true</span> )
514
+ <span class="ruby-identifier">_primed</span>( <span class="ruby-identifier">k</span>, <span class="ruby-keyword kw">true</span> )
515
+ <span class="ruby-keyword kw">end</span>
516
+ </pre>
517
+ </div>
518
+ </div>
519
+ </div>
520
+
521
+
522
+ </div>
523
+
524
+
525
+ </div>
526
+
527
+
528
+ <div id="validator-badges">
529
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
530
+ </div>
531
+
532
+ </body>
533
+ </html>
data/rdoc/created.rid ADDED
@@ -0,0 +1 @@
1
+ Thu, 19 Jan 2012 17:31:13 -0500