sadie 0.0.35 → 0.0.39
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -1
- data/README +2 -0
- data/lib/sadie/primer_plugins/SQLQueryTo2DArray.plugin.rb +8 -7
- data/lib/sadie/version.rb +1 -1
- data/lib/sadie.rb +294 -75
- data/test/tc_sadie_twodeep.rb +11 -2
- data/test/test_primers/two/deep/testquery.test.sql2ar.each +19 -0
- metadata +9 -9
- data/.README.kate-swp +0 -0
data/CHANGELOG
CHANGED
@@ -10,4 +10,7 @@
|
|
10
10
|
[0.0.15] actually committed changes to code this time...doh
|
11
11
|
[0.0.16] bugfixes, updated tests
|
12
12
|
[0.0.17] bugfixes, updated tests
|
13
|
-
[0.0.18]
|
13
|
+
[0.0.18...0.0.34] bugfixes, working on more natural integration with olsen
|
14
|
+
[0.0.35] initializePrimers is no longer called by constructor...must now call manually before using get method
|
15
|
+
[0.0.36] added lots of debugging that's going to need to come out, but also added eachers, a VERY cool
|
16
|
+
enhancement that offers a huge optimization path with very low developer resources
|
data/README
CHANGED
@@ -12,6 +12,8 @@ Valid primers currently are:
|
|
12
12
|
.res, .res.rb - provides access to general-purpose, programatic manipulation of data (i.e. just use sadie instance for input and output of data)
|
13
13
|
.tmpl - simple templating engine for text-based file types
|
14
14
|
|
15
|
+
There's also another file type that can be found in the primer directory called "eacher files". These are simple files which allow for certain tasks to be performed before, after and during the priming of a key/value pair. Currently, the only plugin that makes effective use of eachers is sql2ar and it provides a way for developers to iterate on the rows of a query result as it is initially processed into the resultant array.
|
16
|
+
|
15
17
|
It's very simple to add new primer types, so it would be simple to create primers for html, xml, csv, xls, pointers to all of the above on remote machines, or any- and everything else.
|
16
18
|
|
17
19
|
At Landmetrics, we use a predecessor to Sadie to power perimetercomps[http://perimetercomps.com], producing each 50+ page report with charts, graphs and tables with only 12 queries to the database.
|
@@ -4,27 +4,28 @@ Sadie::registerPrimerPlugin( { "match" => /\.sql2ar$/,
|
|
4
4
|
primer_file_basename = File.basename( primer_file_filepath )
|
5
5
|
sadie_key = key_prefix + '.' + primer_file_basename
|
6
6
|
sadie_key = sadie_key.gsub(/^\./,"")
|
7
|
-
|
7
|
+
puts "DEFINING sql2ar primer for: #{sadie_key}"
|
8
8
|
Sadie::prime( { "provides" => [ sadie_key ] }) do |sadie|
|
9
|
-
|
9
|
+
puts "priming via sql2ar for: #{sadie_key}"
|
10
10
|
if ( matches = primer_file_basename.match( /^(.*)\.([^\.]+)\.sql2ar$/ ) )
|
11
11
|
dbi_sadie_key = key_prefix + '.' + matches[2] + ".dbi.conx"
|
12
|
-
# puts "dbi_sadie_key: #{dbi_sadie_key}, connecting..."
|
13
12
|
dbconx = sadie.get( dbi_sadie_key )
|
14
|
-
# puts "dbconx: #{dbconx}"
|
15
13
|
if ( dbconx = sadie.get( dbi_sadie_key ) )
|
16
|
-
# puts " connected."
|
17
14
|
if sql_query = Sadie::templatedFileToString( primer_file_filepath )
|
18
15
|
|
19
16
|
sth = dbconx.prepare(sql_query)
|
20
17
|
sth.execute
|
21
18
|
|
19
|
+
|
20
|
+
puts "looping thru db query results"
|
22
21
|
result = Array.new
|
23
22
|
while row = sth.fetch
|
24
|
-
|
23
|
+
row_as_array = row.to_a
|
24
|
+
puts "calling eacherFrame each for sadiekey: #{sadie_key}"
|
25
|
+
Sadie::eacherFrame sadie_key, Sadie::EACH, row_as_array
|
26
|
+
result.push row_as_array
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
29
|
sadie.setExpensive( sadie_key, result )
|
29
30
|
|
30
31
|
# Close the statement handle when done
|
data/lib/sadie/version.rb
CHANGED
data/lib/sadie.rb
CHANGED
@@ -23,6 +23,10 @@ end
|
|
23
23
|
|
24
24
|
class Sadie
|
25
25
|
|
26
|
+
BEFORE = 1
|
27
|
+
AFTER = 2
|
28
|
+
EACH = 3
|
29
|
+
|
26
30
|
# ==method: Sadie::getSadieInstance
|
27
31
|
#
|
28
32
|
# returns a new Sadie instance. Options match those of Sadie's constructor method
|
@@ -58,6 +62,252 @@ class Sadie
|
|
58
62
|
current_sadie_instance.prime( primer_definition, &block )
|
59
63
|
end
|
60
64
|
|
65
|
+
def memorizeEacherFileLocation( sadiekey, filepath )
|
66
|
+
|
67
|
+
# store the file path
|
68
|
+
defined? @eacher_filepaths or @eacher_filepaths = Hash.new
|
69
|
+
if ! @eacher_filepaths.has_key? sadiekey
|
70
|
+
puts "memorizing eacher filepath #{filepath} for sadiekey: #{sadiekey}"
|
71
|
+
@eacher_filepaths[sadiekey] = [filepath]
|
72
|
+
elsif ! @eacher_filepaths[sadiekey].include? filepath
|
73
|
+
puts "memorizing eacher filepath #{filepath} for sadiekey: #{sadiekey}"
|
74
|
+
@eacher_filepaths[sadiekey].push filepath
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def eacherFilepaths( sadiekey )
|
79
|
+
defined? @eacher_filepaths or return nil
|
80
|
+
@eacher_filepaths.has_key? sadiekey or return nil
|
81
|
+
@eacher_filepaths[sadiekey]
|
82
|
+
end
|
83
|
+
|
84
|
+
def midEacherInit?
|
85
|
+
defined? @eacher_init or return false
|
86
|
+
@eacher_init or return false
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def setEacherInit
|
91
|
+
@eacher_init = true
|
92
|
+
end
|
93
|
+
|
94
|
+
def clearEacherInit
|
95
|
+
@eacher_init = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
# ==method: Sadie::eacher
|
99
|
+
#
|
100
|
+
# called by eacher files to hook into priming operations
|
101
|
+
# def self.eacher( eacher_params, &block )
|
102
|
+
# puts "HERE!!!"
|
103
|
+
# current_sadie_instance = Sadie::getCurrentSadieInstance
|
104
|
+
# filepath = current_sadie_instance.getCurrentPrimerFilepath
|
105
|
+
# key_prefix = current_sadie_instance.getCurrentPrimerKeyPrefix
|
106
|
+
#
|
107
|
+
# occur_at = eacher_params[:when]
|
108
|
+
# puts "eacher, occur_at: #{occur_at}"
|
109
|
+
#
|
110
|
+
# # gen sadie key
|
111
|
+
# basefilename = filepath.gsub(/^.*\//,"")
|
112
|
+
# sadiekey = key_prefix + "." + basefilename.gsub(/\.each(?:\..*)$/,"")
|
113
|
+
# if eacher_params.has_key? "sadiekey"
|
114
|
+
# sadiekey = eacher_params["sadiekey"]
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# if current_sadie_instance.midEacherInit?
|
118
|
+
# memorizeEacherFileLocation( sadiekey, filepath )
|
119
|
+
# elsif current_sadie_instance.whichEacherFrame == occur_at
|
120
|
+
# current_sadie_instance.eacher( eacher_params, &block )
|
121
|
+
# end
|
122
|
+
# end
|
123
|
+
|
124
|
+
def eacher( params, &block )
|
125
|
+
filepath = getCurrentPrimerFilepath
|
126
|
+
key_prefix = getCurrentPrimerKeyPrefix
|
127
|
+
occur_at = params[:when]
|
128
|
+
# puts "eacher, occur_at: #{occur_at}"
|
129
|
+
|
130
|
+
# gen sadie key
|
131
|
+
basefilename = filepath.gsub(/^.*\//,"")
|
132
|
+
sadiekey = key_prefix + "." + basefilename.gsub(/\.each(?:\..*)*$/,"")
|
133
|
+
if params.has_key? "sadiekey"
|
134
|
+
sadiekey = params["sadiekey"]
|
135
|
+
end
|
136
|
+
|
137
|
+
if midEacherInit?
|
138
|
+
memorizeEacherFileLocation( sadiekey, filepath )
|
139
|
+
|
140
|
+
if params.has_key? :provides
|
141
|
+
#puts "> got provides!"
|
142
|
+
provide_array = params[:provides]
|
143
|
+
provide_array.respond_to? "each" or provide_array = [provide_array]
|
144
|
+
|
145
|
+
# tell sadie that the sadiekey primer also provides everything in the provide array
|
146
|
+
setEachersProvidedByPrimer( sadiekey, provide_array )
|
147
|
+
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
elsif whichEacherFrame == occur_at
|
152
|
+
if block.arity == 0
|
153
|
+
yield self
|
154
|
+
else
|
155
|
+
yield self, getEacherParam
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def setEachersProvidedByPrimer( sadiekey, providers )
|
161
|
+
puts "setting eachers to be provided by #{sadiekey} primer to #{providers}"
|
162
|
+
|
163
|
+
# record reverse map for use by eacherFrame
|
164
|
+
defined? @eacher_frame_redirect \
|
165
|
+
or @eacher_frame_redirect = Hash.new
|
166
|
+
providers.each do |provider|
|
167
|
+
@eacher_frame_redirect[provider] = sadiekey
|
168
|
+
end
|
169
|
+
|
170
|
+
defined? @eachers_provided or @eachers_provided = Hash.new
|
171
|
+
if @eachers_provided.has_key? sadiekey
|
172
|
+
@eachers_provided[sadiekey] = @eachers_provided[sadiekey].concat( providers )
|
173
|
+
else
|
174
|
+
@eachers_provided[sadiekey] = providers
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def isEacherKey?( key )
|
179
|
+
defined? @eacher_frame_redirect or return false
|
180
|
+
@eacher_frame_redirect.has_key? key or return false
|
181
|
+
true
|
182
|
+
end
|
183
|
+
|
184
|
+
def getEacherDependency( key )
|
185
|
+
defined? @eacher_frame_redirect or return nil
|
186
|
+
@eacher_frame_redirect.has_key? key or return nil
|
187
|
+
@eacher_frame_redirect[key]
|
188
|
+
end
|
189
|
+
|
190
|
+
def getEachersProvidedByPrimer( sadiekey )
|
191
|
+
puts "looking for eachers provided by: #{sadiekey}"
|
192
|
+
defined? @eachers_provided or return nil
|
193
|
+
@eachers_provided.has_key? sadiekey or return nil
|
194
|
+
puts "found eachers for #{sadiekey}"
|
195
|
+
@eachers_provided[sadiekey]
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.eacher( eacher_params, &block )
|
199
|
+
current_sadie_instance = Sadie::getCurrentSadieInstance
|
200
|
+
current_sadie_instance.eacher( eacher_params, &block )
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
def self.eacherFrame( sadiekey, occur_at, param=nil )
|
205
|
+
current_sadie_instance = Sadie::getCurrentSadieInstance
|
206
|
+
current_sadie_instance.eacherFrame( sadiekey, occur_at, param )
|
207
|
+
end
|
208
|
+
|
209
|
+
def eacherFrame( sadiekey, occur_at, param=nil )
|
210
|
+
|
211
|
+
key = sadiekey
|
212
|
+
if defined? @eacher_frame_redirect
|
213
|
+
if @eacher_frame_redirect.has_key? key
|
214
|
+
key = @eacher_frame_redirect[key]
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
puts "eacherFrame (#{key},#{occur_at})"
|
219
|
+
setEacherFrame( occur_at )
|
220
|
+
defined? param and setEacherParam( param )
|
221
|
+
if filepaths = eacherFilepaths( key )
|
222
|
+
# puts "found each file paths for key: #{key}, filepaths: #{filepaths}"
|
223
|
+
filepaths.each do |filepath|
|
224
|
+
load filepath
|
225
|
+
end
|
226
|
+
end
|
227
|
+
unsetEacherParam
|
228
|
+
unsetEacherFrame
|
229
|
+
end
|
230
|
+
|
231
|
+
def whichEacherFrame
|
232
|
+
@eacher_frame
|
233
|
+
end
|
234
|
+
|
235
|
+
def setEacherFrame( f )
|
236
|
+
@eacher_frame = f
|
237
|
+
end
|
238
|
+
|
239
|
+
def unsetEacherFrame
|
240
|
+
@eacher_frame = nil
|
241
|
+
end
|
242
|
+
|
243
|
+
def setEacherParam( p )
|
244
|
+
@eacher_param = p
|
245
|
+
end
|
246
|
+
|
247
|
+
def unsetEacherParam
|
248
|
+
@eacher_param = nil
|
249
|
+
end
|
250
|
+
|
251
|
+
def getEacherParam
|
252
|
+
@eacher_param
|
253
|
+
end
|
254
|
+
# == initialize eachers
|
255
|
+
#
|
256
|
+
# register all the eachers
|
257
|
+
#
|
258
|
+
# called by initializePrimers so it's not necessary to call this separate from that
|
259
|
+
def initializeEachers
|
260
|
+
|
261
|
+
primers_dirpath = get( "sadie.primers_dirpath" ) \
|
262
|
+
or raise "sadie.primers_dirpath not set"
|
263
|
+
|
264
|
+
puts "Initializing eachers..."
|
265
|
+
setEacherInit
|
266
|
+
initializeEacherDirectory( "", primers_dirpath )
|
267
|
+
clearEacherInit
|
268
|
+
puts "...finished initializing eachers."
|
269
|
+
|
270
|
+
|
271
|
+
@@eachers_initialized = true
|
272
|
+
end
|
273
|
+
|
274
|
+
def initializeEacherDirectory( key_prefix, current_dirpath )
|
275
|
+
|
276
|
+
puts "initializing eacher directory: #{current_dirpath}"
|
277
|
+
Dir.foreach( current_dirpath ) do |filename|
|
278
|
+
|
279
|
+
# skip the dit dirs
|
280
|
+
next if filename.eql?(".") || filename.eql?("..") || filename =~ /\~$/
|
281
|
+
|
282
|
+
|
283
|
+
filepath = File.expand_path( filename, current_dirpath )
|
284
|
+
|
285
|
+
if File.directory? filepath
|
286
|
+
new_key_prefix = key_prefix + '.' + filename
|
287
|
+
new_key_prefix = new_key_prefix.gsub(/^\.+/,"")
|
288
|
+
initializeEacherDirectory( new_key_prefix, filepath )
|
289
|
+
else
|
290
|
+
if filename =~ /\.each(?:\..*)*$/
|
291
|
+
initializeEacherFile( key_prefix, filepath )
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def initializeEacherFile( key_prefix, filepath )
|
298
|
+
puts "initializing eacher file (#{key_prefix}): #{filepath}"
|
299
|
+
setCurrentPrimerFilepath filepath
|
300
|
+
setCurrentPrimerKeyPrefix key_prefix
|
301
|
+
load filepath
|
302
|
+
end
|
303
|
+
|
304
|
+
def eachersInitialized?
|
305
|
+
defined? @@eachers_initialized or return false
|
306
|
+
@@eachers_initialized and return true
|
307
|
+
return false
|
308
|
+
end
|
309
|
+
|
310
|
+
|
61
311
|
# ==method: Sadie::registerPrimerPlugin
|
62
312
|
#
|
63
313
|
# this method is called in the .plugin.rb files to register new plugin types
|
@@ -132,32 +382,15 @@ class Sadie
|
|
132
382
|
|
133
383
|
# internalize defaults to shortterm
|
134
384
|
DEFAULTS.each do |key, value|
|
135
|
-
# if key.eql? "sadie.primer_plugins_dirpath"
|
136
|
-
# addPrimerPluginsDirPath value
|
137
|
-
# else
|
138
385
|
_set( key, value )
|
139
|
-
# end
|
140
386
|
end
|
141
387
|
|
142
|
-
# internalize supplied defaults, postponing a set of sadie.primers_dirpath
|
143
|
-
# until the end if one is supplied. The reason for this is that the setter
|
144
|
-
# attempts to read the plugins and if the primer plugin dirpath has not
|
145
|
-
# yet been set, then it'll choke if it processes the wrong one first
|
146
|
-
# delay_set_primers_dirpath = nil
|
147
|
-
|
148
388
|
# iterate over constructor args, but do primers_dirpath last since it
|
149
389
|
# causes a call to initializePrimers
|
150
390
|
options.each do |key, value|
|
151
|
-
# if key.eql? "sadie.primers_dirpath"
|
152
|
-
# delay_set_primers_dirpath = value
|
153
|
-
# else
|
154
391
|
set( key, value )
|
155
|
-
# end
|
156
392
|
end
|
157
|
-
|
158
|
-
# defined? delay_set_primers_dirpath \
|
159
|
-
# and set( "sadie.primers_dirpath", delay_set_primers_dirpath )
|
160
|
-
|
393
|
+
|
161
394
|
# if a path to a session is given, init using session file
|
162
395
|
if options.has_key?( "sadie.session_filepath" )
|
163
396
|
set( "sadie.session_filepath", options["sadie.session_filepath"] )
|
@@ -170,13 +403,14 @@ class Sadie
|
|
170
403
|
end
|
171
404
|
|
172
405
|
# add the default sadie plugins dir
|
173
|
-
plugins_dirpath =
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
406
|
+
plugins_dirpath = "lib/sadie/primer_plugins" # for dev
|
407
|
+
if ! File.exists? plugins_dirpath
|
408
|
+
plugins_dirpath = File.join(
|
409
|
+
ENV['GEM_HOME'],
|
410
|
+
"gems/sadie-#{Sadie::VERSION}",
|
411
|
+
"lib/sadie/primer_plugins"
|
412
|
+
)
|
413
|
+
|
180
414
|
end
|
181
415
|
addPrimerPluginsDirPath plugins_dirpath
|
182
416
|
|
@@ -197,6 +431,7 @@ class Sadie
|
|
197
431
|
or @plugins_dir_paths.unshift(exppath)
|
198
432
|
|
199
433
|
@@primer_plugins_initialized = nil
|
434
|
+
return self
|
200
435
|
end
|
201
436
|
|
202
437
|
|
@@ -228,8 +463,6 @@ class Sadie
|
|
228
463
|
# skip blank lines
|
229
464
|
next if key.match /^\s*$/
|
230
465
|
|
231
|
-
#puts "Prime> providing: #{key}"
|
232
|
-
|
233
466
|
# key primed or raise error
|
234
467
|
primed? key \
|
235
468
|
or raise "primer definition file: #{current_primer_filepath} was supposed to define #{key}, but did not"
|
@@ -245,10 +478,6 @@ class Sadie
|
|
245
478
|
accepts_block = arghash.has_key?( "accepts-block" ) && arghash["accepts-block"] ? true : false
|
246
479
|
prime_on_init = arghash.has_key?( "prime-on-init" ) && arghash["prime-on-init"] ? true : false
|
247
480
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
481
|
# if mid plugin init, register the plugin params with the match
|
253
482
|
if midPluginInit?
|
254
483
|
|
@@ -257,7 +486,7 @@ class Sadie
|
|
257
486
|
# midplugininit returned false, we're actually in the process of either initializing
|
258
487
|
# a primer or actually priming
|
259
488
|
else
|
260
|
-
yield
|
489
|
+
yield self, getCurrentPrimerKeyPrefix, @@current_primer_filepath
|
261
490
|
end
|
262
491
|
end
|
263
492
|
|
@@ -334,11 +563,6 @@ class Sadie
|
|
334
563
|
# returns true if the destructOnGet flag is set for the key
|
335
564
|
def destroyOnGet?( key )
|
336
565
|
( @flag_destroyonget.has_key?( key ) && @flag_destroyonget["#{key}"] )
|
337
|
-
# @flag_destroyonget.has_key?( key ) \
|
338
|
-
# or return _newline( false )
|
339
|
-
# @flag_destroyonget["#{key}"] \
|
340
|
-
# and return _newline( true )
|
341
|
-
# return _newline(false)
|
342
566
|
end
|
343
567
|
|
344
568
|
# ==method: set
|
@@ -352,38 +576,13 @@ class Sadie
|
|
352
576
|
# the cheap setter. key, value pairs stored via this method are kept in memory
|
353
577
|
def setCheap( k, v )
|
354
578
|
|
355
|
-
# puts "setCheap( #{k}, #{v} )"
|
356
|
-
|
357
|
-
# if k.eql? "sadie.primer_plugins_dirpath"
|
358
|
-
# puts "adding primer plugins dirpath via setCheap"
|
359
|
-
# if v.respond_to? "each"
|
360
|
-
# v.each do |plugindir|
|
361
|
-
# addPrimerPluginsDirPath plugindir
|
362
|
-
# end
|
363
|
-
# else
|
364
|
-
# addPrimerPluginsDirPath v
|
365
|
-
# end
|
366
|
-
# v = @plugins_dir_paths
|
367
|
-
# end
|
368
|
-
|
369
|
-
|
370
|
-
|
371
579
|
# set it, mark not expensive and primed
|
372
580
|
_set( k, v )
|
373
581
|
_expensive( k, false )
|
374
582
|
|
375
|
-
# if we've reset the primers dirpath, init the primers
|
376
|
-
# if k.eql?( "sadie.primers_dirpath" )
|
377
|
-
# initializePrimers
|
378
|
-
# end
|
379
583
|
|
380
584
|
_primed( k, true )
|
381
585
|
|
382
|
-
# if we've reset the primers dirpath, init the primers
|
383
|
-
#if k.eql?( "sadie.primers_dirpath" )
|
384
|
-
# Sadie::setCurrentSadieInstance( self )
|
385
|
-
#end
|
386
|
-
|
387
586
|
end
|
388
587
|
|
389
588
|
def cheap?( k )
|
@@ -395,7 +594,6 @@ class Sadie
|
|
395
594
|
# the expensive setter. key, value pairs stored via this method are not kept in memory
|
396
595
|
# but are stored to file and recalled as needed
|
397
596
|
def setExpensive(k,v)
|
398
|
-
# puts "setting expensive, key: #{k}"
|
399
597
|
expensive_filepath = _computeExpensiveFilepath( k )
|
400
598
|
serialized_value = Marshal::dump( v )
|
401
599
|
File.open(expensive_filepath, 'w') { |f|
|
@@ -452,6 +650,8 @@ class Sadie
|
|
452
650
|
primerPluginsInitialized? \
|
453
651
|
or initializePrimerPlugins
|
454
652
|
|
653
|
+
eachersInitialized? \
|
654
|
+
or initializeEachers
|
455
655
|
|
456
656
|
primers_dirpath = get( "sadie.primers_dirpath" ) \
|
457
657
|
or raise "sadie.primers_dirpath not set"
|
@@ -602,7 +802,7 @@ class Sadie
|
|
602
802
|
Dir.foreach( current_dirpath ) do |filename|
|
603
803
|
|
604
804
|
# skip the dit dirs
|
605
|
-
next if filename.eql?(".") || filename.eql?("..")
|
805
|
+
next if filename.eql?(".") || filename.eql?("..") || filename =~ /\~$/
|
606
806
|
|
607
807
|
filepath = File.expand_path( filename, current_dirpath )
|
608
808
|
|
@@ -706,7 +906,22 @@ class Sadie
|
|
706
906
|
# interate over provides setting primer providers for each
|
707
907
|
primer_provides.each do | key |
|
708
908
|
setPrimerProvider( key, filepath, plugin_filepath, getCurrentPrimerKeyPrefix )
|
909
|
+
|
910
|
+
# # handle eachers
|
911
|
+
# if eachers_provided = getEachersProvidedByPrimer( key )
|
912
|
+
# eachers_provided.each do |eacherkey|
|
913
|
+
#
|
914
|
+
# # Sadie::prime( { "provides" => [ eacherkey ] }) do |sadie|
|
915
|
+
# # puts "calling sadie.get(#{key} to produce #{eacherkey}"
|
916
|
+
# # sadie.get key
|
917
|
+
# # end
|
918
|
+
#
|
919
|
+
# # puts "setting eacher #{eacherkey} to be provided by file: #{filepath}"
|
920
|
+
# # setPrimerProvider( eacherkey, filepath, plugin_filepath, getCurrentPrimerKeyPrefix )
|
921
|
+
# end
|
922
|
+
# end
|
709
923
|
end
|
924
|
+
|
710
925
|
end
|
711
926
|
|
712
927
|
|
@@ -754,19 +969,25 @@ class Sadie
|
|
754
969
|
end
|
755
970
|
|
756
971
|
def _prime ( k )
|
972
|
+
puts ">>>priming: #{k}"
|
757
973
|
|
758
|
-
if
|
759
|
-
|
974
|
+
if isEacherKey? k
|
975
|
+
get( getEacherDependency( k ) )
|
976
|
+
else
|
760
977
|
|
761
|
-
|
762
|
-
|
763
|
-
|
978
|
+
Sadie::eacherFrame( k, BEFORE )
|
979
|
+
if provider = getPrimerProvider( k )
|
980
|
+
puts "got provider for sadiekey: #{k}"
|
981
|
+
primer_filepath, plugin_filepath, key_prefix = provider
|
764
982
|
|
765
|
-
|
766
|
-
|
767
|
-
|
983
|
+
setCurrentPrimerFilepath(primer_filepath)
|
984
|
+
setCurrentPrimerKeyPrefix( key_prefix )
|
985
|
+
Sadie::setCurrentSadieInstance( self )
|
986
|
+
|
987
|
+
load plugin_filepath
|
988
|
+
end
|
989
|
+
Sadie::eacherFrame( k, AFTER )
|
768
990
|
end
|
769
|
-
|
770
991
|
end
|
771
992
|
|
772
993
|
|
@@ -807,9 +1028,7 @@ class Sadie
|
|
807
1028
|
|
808
1029
|
# direct access setter for shortterm memory
|
809
1030
|
def _set( key, value )
|
810
|
-
# puts "_set> key: #{key}, value: #{value}"
|
811
1031
|
@shortterm["#{key}"] = value
|
812
|
-
# end
|
813
1032
|
end
|
814
1033
|
|
815
1034
|
def _unset( key )
|
data/test/tc_sadie_twodeep.rb
CHANGED
@@ -26,16 +26,25 @@ class TestSadieTwoDeep < Test::Unit::TestCase
|
|
26
26
|
dbconx = sadie.get( "two.deep.test.dbi.conx" )
|
27
27
|
assert_not_nil( dbconx )
|
28
28
|
|
29
|
-
# test
|
29
|
+
# test eacher
|
30
|
+
puts "!!!"
|
31
|
+
puts "!!!"
|
32
|
+
eachertest = sadie.get("simple.eacher.test")
|
33
|
+
#assert_equal( eachertest, "start12end")
|
34
|
+
|
35
|
+
# test sqlTo2DArray
|
30
36
|
tablearray = sadie.get( "two.deep.testquery.test.sql2ar" )
|
37
|
+
puts "!!!"
|
38
|
+
puts "!!!"
|
31
39
|
assert_not_nil( tablearray )
|
40
|
+
puts "tablearray: #{tablearray}"
|
32
41
|
assert_equal( tablearray[0][0], 1 )
|
33
42
|
assert_equal( tablearray[1][1], "testing456" )
|
34
43
|
|
35
44
|
# test templating
|
36
45
|
template_text = sadie.get( "two.deep.test_template.txt.tmpl" )
|
37
46
|
template_text = template_text.gsub(/\s+/," ").gsub(/^\s*/,"").gsub(/\s*$/,"")
|
38
|
-
|
47
|
+
puts "template text\n#{template_text}"
|
39
48
|
assert( (template_text.match(/later\s+gator/)), "incorrect match on template text" )
|
40
49
|
assert( (template_text.match(/test\/test\_primers/)), "incorrect match on template text" )
|
41
50
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'sadie'
|
2
|
+
|
3
|
+
Sadie::eacher( :when => Sadie::BEFORE ) do |sadie|
|
4
|
+
@testeach = "start"
|
5
|
+
puts "testeach[start]: #{@testeach}"
|
6
|
+
end
|
7
|
+
|
8
|
+
Sadie::eacher( :when => Sadie::EACH, :sadiekey => "two.deep.testquery.test.sql2ar" ) do |sadie,param|
|
9
|
+
@testeach = "#{@testeach}#{param[0]}"
|
10
|
+
puts "testeach[each]: #{@testeach}"
|
11
|
+
end
|
12
|
+
|
13
|
+
Sadie::eacher( :when => Sadie::AFTER, :provides => ["simple.eacher.test"] ) do |sadie|
|
14
|
+
@testeach = "#{@testeach}end"
|
15
|
+
sadie.set "simple.eacher.test", @testeach
|
16
|
+
puts "testeach[end]: #{@testeach}"
|
17
|
+
end
|
18
|
+
|
19
|
+
#def dsl_correct?; ( bitch_to_wrap_head_around? ) && ( rewritten_atleast_three_times? ) && ( seems_easy_now_that_its_done? ) && ( have_less_hair_now? ); end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sadie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.39
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dbi
|
16
|
-
requirement: &
|
16
|
+
requirement: &11389960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11389960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mysql
|
27
|
-
requirement: &
|
27
|
+
requirement: &11439500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *11439500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dbd-mysql
|
38
|
-
requirement: &
|
38
|
+
requirement: &11439080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *11439080
|
47
47
|
description: Sadie is a data framework intended to ease the pain of managing related
|
48
48
|
data.
|
49
49
|
email:
|
@@ -55,7 +55,6 @@ extra_rdoc_files:
|
|
55
55
|
- CHANGELOG
|
56
56
|
- TODO
|
57
57
|
files:
|
58
|
-
- .README.kate-swp
|
59
58
|
- .gitignore
|
60
59
|
- CHANGELOG
|
61
60
|
- Gemfile
|
@@ -99,6 +98,7 @@ files:
|
|
99
98
|
- test/test_primers/two/deep/test.dbi.conx
|
100
99
|
- test/test_primers/two/deep/test_template.txt.tmpl
|
101
100
|
- test/test_primers/two/deep/testquery.test.sql2ar
|
101
|
+
- test/test_primers/two/deep/testquery.test.sql2ar.each
|
102
102
|
- test/test_primers/two/deep/two_results.res
|
103
103
|
homepage: http://www.landmetrics.com/Sadie
|
104
104
|
licenses: []
|
data/.README.kate-swp
DELETED
Binary file
|