sadie 0.0.52 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +2 -1
  3. data/README +76 -22
  4. data/Rakefile +41 -1
  5. data/TODO +2 -31
  6. data/bin/sadie +17 -0
  7. data/bin/sadie_query_server +15 -0
  8. data/bin/sadie_server +27 -0
  9. data/bin/sadie_server.rb +23 -0
  10. data/doc/v2 +161 -0
  11. data/lib/primer.rb +201 -0
  12. data/lib/sadie/version.rb +1 -1
  13. data/lib/sadie_server.rb +59 -0
  14. data/lib/sadie_session.rb +194 -0
  15. data/lib/sadie_storage_manager.rb +60 -0
  16. data/lib/sadie_storage_mechanism.rb +18 -0
  17. data/lib/storage/memory.rb +24 -0
  18. data/sadie.gemspec +6 -2
  19. data/spec/primer.rb +167 -0
  20. data/spec/sadie_server.rb +39 -0
  21. data/spec/sadie_server_lib.rb +31 -0
  22. data/spec/sadie_session.rb +99 -0
  23. data/spec/storage_manager.rb +58 -0
  24. data/spec/storage_mechanisms/memory.rb +28 -0
  25. data/test/v2/test_installation/primers/minimal.rb +5 -0
  26. data/test/v2/test_installation/primers/onelevel/twolevel/test_subdir.rb +5 -0
  27. data/test/v2/test_installation/primers/test_after_each.rb +14 -0
  28. data/test/v2/test_installation/primers/test_after_key.rb +14 -0
  29. data/test/v2/test_installation/primers/test_before_each.rb +14 -0
  30. data/test/v2/test_installation/primers/test_before_key.rb +14 -0
  31. data/test/v2/test_installation/primers/test_expires_after_n_secs.rb +6 -0
  32. data/test/v2/test_installation/primers/test_expires_on_get.rb +6 -0
  33. data/test/v2/test_installation/primers/test_refresh.rb +10 -0
  34. metadata +84 -49
  35. data/lib/sadie/debug.rb +0 -1
  36. data/lib/sadie/defaults.rb +0 -14
  37. data/lib/sadie/primer_plugins/DatabaseConnection.plugin.rb +0 -80
  38. data/lib/sadie/primer_plugins/IniFile.plugin.rb +0 -23
  39. data/lib/sadie/primer_plugins/Resource.plugin.rb +0 -7
  40. data/lib/sadie/primer_plugins/SQLQueryTo2DArray.plugin.rb +0 -39
  41. data/lib/sadie/primer_plugins/TemplateTextFile.plugin.rb +0 -13
  42. data/lib/sadie.rb +0 -1315
  43. data/test/README +0 -9
  44. data/test/tc_sadie_toplevel.rb +0 -43
  45. data/test/tc_sadie_twodeep.rb +0 -48
  46. data/test/test_primers/.gitignore +0 -1
  47. data/test/test_primers/onedeep/multiresult.res +0 -5
  48. data/test/test_primers/toplevel.ini +0 -5
  49. data/test/test_primers/toplevel.somegroup.somekey.each +0 -15
  50. data/test/test_primers/toplevel_destructonget.res.rb +0 -9
  51. data/test/test_primers/toplevel_double.oneprime.each +0 -14
  52. data/test/test_primers/toplevel_double.res.rb +0 -5
  53. data/test/test_primers/toplevel_single.res.rb +0 -3
  54. data/test/test_primers/toplevel_testeach.res.rb +0 -4
  55. data/test/test_primers/two/deep/conf.ini +0 -2
  56. data/test/test_primers/two/deep/expensive.res +0 -3
  57. data/test/test_primers/two/deep/test.dbi.conx +0 -4
  58. data/test/test_primers/two/deep/test_template.txt.tmpl +0 -10
  59. data/test/test_primers/two/deep/testquery.test.sql2ar +0 -1
  60. data/test/test_primers/two/deep/testquery.test.sql2ar.each +0 -16
  61. data/test/test_primers/two/deep/two_results.res +0 -8
@@ -0,0 +1,99 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'sadie_session'
3
+ require 'pp'
4
+ describe SadieSession do
5
+
6
+ it "should be able to get and set" do
7
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
8
+ session.set('test.key','test.value')
9
+ session.get('test.key').should == 'test.value'
10
+ end
11
+
12
+ it "should register primers" do
13
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
14
+ session.primer_registered?("minimal.primer").should be_true
15
+ end
16
+
17
+ it "should not execute primer assign directives" do
18
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
19
+ session.has_key?("minimal.primer").should be_false
20
+ end
21
+
22
+ it "should be possible to _get_ registered keys" do
23
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
24
+ session.get("minimal.primer").should == "testval"
25
+ end
26
+
27
+ it "should find primers in subdirectories" do
28
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
29
+ session.get("subdir.test").should == "testval"
30
+ end
31
+
32
+ it "should be possible to expire on get" do
33
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
34
+ session.get("test.expires.onget").should == "testval"
35
+ session.has_key?("test.expires.onget").should be_false
36
+ end
37
+
38
+ it "should put keys in the expire schedule" do
39
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
40
+
41
+ def session.in_expire_schedule?( key )
42
+ ( ! @expire_schedule.values.index(key).nil? )
43
+ end
44
+
45
+ session.get("test.expires.nsecs").should == "testval"
46
+ session.in_expire_schedule?("test.expires.nsecs").should be true
47
+ end
48
+
49
+ it "should expire keys using _expire_pass" do
50
+
51
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
52
+ def session.run_expiry_pass
53
+ _expiry_pass
54
+ end
55
+ session.stub(:_current_time).and_return(2,5,8,11,14)
56
+ session.stub(:_expiry_loop).and_return(false)
57
+ session.get("test.expires.nsecs").should == "testval"
58
+ session.has_key?("test.expires.nsecs").should be_true
59
+ session.run_expiry_pass
60
+ session.has_key?("test.expires.nsecs").should be_false
61
+ end
62
+
63
+ it "should refresh keys" do
64
+
65
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
66
+ def session.run_refresh_pass
67
+ _refresh_pass
68
+ end
69
+ session.stub(:_current_time).and_return(2,5,8,11,14)
70
+ session.stub(:_refresh_loop).and_return(false)
71
+ session.get("test.refresh").should == "refresh"
72
+ session.run_refresh_pass
73
+ session.get("test.refresh").should == "rrefresh"
74
+ end
75
+
76
+ # --- SLOW!
77
+ if ENV.has_key?('SADIE_SESSION_TEST_TIMERS') && ENV['SADIE_SESSION_TEST_TIMERS'].to_i == 1
78
+
79
+ it "should expire keys after specified time" do
80
+
81
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
82
+ session.get("test.expires.nsecs").should == "testval"
83
+ session.has_key?("test.expires.nsecs").should be_true
84
+ sleep 2
85
+ session.has_key?("test.expires.nsecs").should be_false
86
+ end
87
+
88
+ it "should refresh keys after specified time" do
89
+
90
+ session = SadieSession.new( :primers_dirpath => File.join( File.dirname( __FILE__ ), '..','test','v2','test_installation','primers' ))
91
+ session.get("test.refresh").should == "refresh"
92
+ sleep 2
93
+ session.get("test.refresh").should == "rrefresh"
94
+ end
95
+
96
+ end
97
+
98
+
99
+ end
@@ -0,0 +1,58 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'sadie_storage_manager'
3
+ require 'storage_mechanisms/memory'
4
+
5
+ describe SadieStorageManager do
6
+
7
+ it "should be able to get and set using the memory storage mechanism" do
8
+
9
+ storage = SadieStorageManager.new
10
+ mech = SadieStorageMechanismMemory.new
11
+ storage.register_storage_mechanism :memory, mech
12
+ storage.set( :mechanism => :memory,
13
+ :keys => [ "simple.test" ],
14
+ :value => "test.value" )
15
+ mech.get( "simple.test" ).should == "test.value"
16
+ end
17
+
18
+ it "should report a mechanism is registered after it has been registered" do
19
+ storage = SadieStorageManager.new
20
+ mech = SadieStorageMechanismMemory.new
21
+ storage.register_storage_mechanism :memory, mech
22
+ storage.mechanism_is_registered?( :memory ).should be_true
23
+ end
24
+
25
+ it "should have a functional has_key? method" do
26
+ storage = SadieStorageManager.new
27
+ mech = SadieStorageMechanismMemory.new
28
+ storage.register_storage_mechanism :memory, mech
29
+ storage.has_key?( "test.key" ).should be_false
30
+ storage.set( :keys => ["test.key"],
31
+ :value => "test.value",
32
+ :mechanism => :memory )
33
+ storage.has_key?( "test.key" ).should be_true
34
+ end
35
+
36
+ it "should have a functional get method" do
37
+ storage = SadieStorageManager.new
38
+ mech = SadieStorageMechanismMemory.new
39
+ storage.register_storage_mechanism :memory, mech
40
+ storage.set( :keys => ["test.key"],
41
+ :value => "test.value",
42
+ :mechanism => :memory )
43
+ storage.get( "test.key" ).should == "test.value"
44
+ end
45
+
46
+ it "should have a functional unset method" do
47
+ storage = SadieStorageManager.new
48
+ mech = SadieStorageMechanismMemory.new
49
+ storage.register_storage_mechanism :memory, mech
50
+ storage.set( :keys => ["test.key"],
51
+ :value => "test.value",
52
+ :mechanism => :memory )
53
+ storage.has_key?( "test.key" ).should be_true
54
+ storage.unset "test.key"
55
+ storage.has_key?( "test.key" ).should be_false
56
+ end
57
+
58
+ end
@@ -0,0 +1,28 @@
1
+ require 'storage/memory'
2
+ describe SadieStorageMechanismMemory do
3
+
4
+ it "should successfully return a set value" do
5
+
6
+ mech = SadieStorageMechanismMemory.new
7
+ mech.set 'somekey.test','some_value'
8
+ mech.get( 'somekey.test' ).should == 'some_value'
9
+
10
+ end
11
+
12
+ it "should have a functional has_key? method" do
13
+ mech = SadieStorageMechanismMemory.new
14
+ mech.has_key?( "somekey.test" ).should be_false
15
+ mech.set 'somekey.test','some_value'
16
+ mech.has_key?( "somekey.test" ).should be_true
17
+ end
18
+
19
+ it "should have a functional unset method" do
20
+ mech = SadieStorageMechanismMemory.new
21
+ mech.set 'somekey.test','some_value'
22
+ mech.has_key?( "somekey.test" ).should be_true
23
+ mech.unset 'somekey.test'
24
+ mech.has_key?( "somekey.test" ).should be_false
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,5 @@
1
+ prime ["minimal.primer"] do
2
+ assign do
3
+ set "testval"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ prime ["subdir.test"] do
2
+ assign do
3
+ set "testval"
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ prime ["test.var1","test.var2"] do
2
+
3
+ @r = {}
4
+
5
+ after :each do |varname,val|
6
+ @r[varname] = val
7
+ end
8
+
9
+ assign do
10
+ set "test.var1","val1"
11
+ set "test.var2","val2"
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ prime ["test.var1","test.var2"] do
2
+
3
+ @r = {}
4
+
5
+ after "test.var1" do |varname,val|
6
+ @r[varname] = val
7
+ end
8
+
9
+ assign do
10
+ set "test.var1","val1"
11
+ set "test.var2","val2"
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ prime ["test.var1","test.var2"] do
2
+
3
+ @r = {}
4
+
5
+ before :each do |varname|
6
+ @r[varname] = 1
7
+ end
8
+
9
+ assign do
10
+ set "test.var1","val1"
11
+ set "test.var2","val2"
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ prime ["test.var1","test.var2"] do
2
+
3
+ @r = {}
4
+
5
+ before "test.var1" do |varname|
6
+ @r[varname] = 1
7
+ end
8
+
9
+ assign do
10
+ set "test.var1","val1"
11
+ set "test.var2","val2"
12
+ end
13
+
14
+ end
@@ -0,0 +1,6 @@
1
+ prime ["test.expires.nsecs"] do
2
+ expire 1
3
+ assign do
4
+ set "testval"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ prime ["test.expires.onget"] do
2
+ expire :on_get
3
+ assign do
4
+ set "testval"
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ prime ["test.refresh"] do
2
+ refresh 1
3
+ assign do
4
+ if session.has_key?( "test.refresh" )
5
+ set session.get("test.refresh").gsub(/^r/,"rr")
6
+ else
7
+ set "refresh"
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,43 +1,80 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sadie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.52
5
- prerelease:
4
+ version: 0.1.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fred McDavid
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-05-01 00:00:00.000000000Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: dbi
16
- requirement: &14999900 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 1.4.4
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *14999900
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.4
25
27
  - !ruby/object:Gem::Dependency
26
- name: dbd-mysql
27
- requirement: &14999480 !ruby/object:Gem::Requirement
28
- none: false
28
+ name: rbtree
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ~>
31
32
  - !ruby/object:Gem::Version
32
- version: '0'
33
+ version: 0.4.2
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *14999480
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
36
69
  description: Sadie is a data framework intended to ease the pain of managing related
37
70
  data.
38
71
  email:
39
72
  - fred@landmetrics.com
40
- executables: []
73
+ executables:
74
+ - sadie
75
+ - sadie_query_server
76
+ - sadie_server
77
+ - sadie_server.rb
41
78
  extensions: []
42
79
  extra_rdoc_files:
43
80
  - README
@@ -52,16 +89,19 @@ files:
52
89
  - README
53
90
  - Rakefile
54
91
  - TODO
92
+ - bin/sadie
93
+ - bin/sadie_query_server
94
+ - bin/sadie_server
95
+ - bin/sadie_server.rb
96
+ - doc/v2
55
97
  - lib/.gitignore
56
- - lib/sadie.rb
57
- - lib/sadie/debug.rb
58
- - lib/sadie/defaults.rb
59
- - lib/sadie/primer_plugins/DatabaseConnection.plugin.rb
60
- - lib/sadie/primer_plugins/IniFile.plugin.rb
61
- - lib/sadie/primer_plugins/Resource.plugin.rb
62
- - lib/sadie/primer_plugins/SQLQueryTo2DArray.plugin.rb
63
- - lib/sadie/primer_plugins/TemplateTextFile.plugin.rb
98
+ - lib/primer.rb
64
99
  - lib/sadie/version.rb
100
+ - lib/sadie_server.rb
101
+ - lib/sadie_session.rb
102
+ - lib/sadie_storage_manager.rb
103
+ - lib/sadie_storage_mechanism.rb
104
+ - lib/storage/memory.rb
65
105
  - rdoc/classes/Sadie.html
66
106
  - rdoc/created.rid
67
107
  - rdoc/files/README.html
@@ -74,47 +114,42 @@ files:
74
114
  - rdoc/index.html
75
115
  - rdoc/rdoc-style.css
76
116
  - sadie.gemspec
77
- - test/README
78
- - test/tc_sadie_toplevel.rb
79
- - test/tc_sadie_twodeep.rb
80
- - test/test_primers/.gitignore
81
- - test/test_primers/onedeep/multiresult.res
82
- - test/test_primers/toplevel.ini
83
- - test/test_primers/toplevel.somegroup.somekey.each
84
- - test/test_primers/toplevel_destructonget.res.rb
85
- - test/test_primers/toplevel_double.oneprime.each
86
- - test/test_primers/toplevel_double.res.rb
87
- - test/test_primers/toplevel_single.res.rb
88
- - test/test_primers/toplevel_testeach.res.rb
89
- - test/test_primers/two/deep/conf.ini
90
- - test/test_primers/two/deep/expensive.res
91
- - test/test_primers/two/deep/test.dbi.conx
92
- - test/test_primers/two/deep/test_template.txt.tmpl
93
- - test/test_primers/two/deep/testquery.test.sql2ar
94
- - test/test_primers/two/deep/testquery.test.sql2ar.each
95
- - test/test_primers/two/deep/two_results.res
117
+ - spec/primer.rb
118
+ - spec/sadie_server.rb
119
+ - spec/sadie_server_lib.rb
120
+ - spec/sadie_session.rb
121
+ - spec/storage_manager.rb
122
+ - spec/storage_mechanisms/memory.rb
123
+ - test/v2/test_installation/primers/minimal.rb
124
+ - test/v2/test_installation/primers/onelevel/twolevel/test_subdir.rb
125
+ - test/v2/test_installation/primers/test_after_each.rb
126
+ - test/v2/test_installation/primers/test_after_key.rb
127
+ - test/v2/test_installation/primers/test_before_each.rb
128
+ - test/v2/test_installation/primers/test_before_key.rb
129
+ - test/v2/test_installation/primers/test_expires_after_n_secs.rb
130
+ - test/v2/test_installation/primers/test_expires_on_get.rb
131
+ - test/v2/test_installation/primers/test_refresh.rb
96
132
  homepage: http://www.landmetrics.com/Sadie
97
133
  licenses: []
134
+ metadata: {}
98
135
  post_install_message:
99
136
  rdoc_options: []
100
137
  require_paths:
101
138
  - lib
102
139
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
140
  requirements:
105
- - - ! '>='
141
+ - - '>='
106
142
  - !ruby/object:Gem::Version
107
143
  version: '0'
108
144
  required_rubygems_version: !ruby/object:Gem::Requirement
109
- none: false
110
145
  requirements:
111
- - - ! '>='
146
+ - - '>='
112
147
  - !ruby/object:Gem::Version
113
148
  version: '0'
114
149
  requirements: []
115
150
  rubyforge_project: sadie
116
- rubygems_version: 1.8.15
151
+ rubygems_version: 2.0.3
117
152
  signing_key:
118
- specification_version: 3
153
+ specification_version: 4
119
154
  summary: A gem that provides sadie, a data access framework
120
155
  test_files: []
data/lib/sadie/debug.rb DELETED
@@ -1 +0,0 @@
1
- #
@@ -1,14 +0,0 @@
1
- # ==Notes
2
- # this file sets defaults which can and should be overridden using arguments
3
- # the sadie constructor
4
- require 'sadie/version'
5
-
6
- class Sadie
7
-
8
- #ppdp = File.join("lib/sadie/primer_plugins",File.join("gems/sadie-#{Sadie::VERSION}",ENV['GEM_HOME']))
9
-
10
- DEFAULTS = {
11
- "sadie.primers_dirpath" => File.expand_path("primers","/var/sadie"),
12
- "sadie.sessions_dirpath" => File.expand_path("sessions","/var/sadie")
13
- }
14
- end
@@ -1,80 +0,0 @@
1
- # WARNING: THIS DOESN'T WORK YET!!!
2
-
3
- Sadie::registerPrimerPlugin( { "match" => /\.dbi\.conx$/,
4
- "accepts-block" => false,
5
- "prime-on-init" => false } ) do |sadie, key_prefix, primer_file_filepath|
6
-
7
- # determine key
8
- sadie_key = key_prefix+'.'+File.basename( primer_file_filepath )
9
-
10
-
11
- Sadie::prime( { "provides" => [ sadie_key ] }) do |sadie|
12
-
13
- if inihash = Sadie::iniFileToHash( primer_file_filepath )
14
- dbparams = Hash.new
15
-
16
- inihash.each do |section, section_hash|
17
- section.match(/^connection$/) \
18
- or next
19
- section_hash.each do |key, value|
20
- dbparams[key] = value
21
- end
22
- end
23
-
24
- if ! dbparams.empty?
25
- # validate dbistr
26
- dbparams.has_key?( 'dbistr' ) \
27
- or raise 'requried connection::dbistr was not defined'
28
-
29
- # default user and pass to nil
30
- user = dbparams.has_key?('user') ? dbparams['user']: nil;
31
- pass = dbparams.has_key?('pass') ? dbparams['pass']: nil;
32
-
33
- # call connect with block
34
- require 'rubygems'
35
- #require 'mysql'
36
- #require 'pg'
37
- require 'dbi'
38
- #require "dbd-mysql"
39
-
40
- begin
41
- dbh = DBI.connect( dbparams['dbistr'], user, pass )
42
- rescue DBI::DatabaseError => e
43
- puts "A database connection error occurred..."
44
- puts " Error code: #{e.err}"
45
- puts " Error message: #{e.errstr}"
46
- exit
47
- end
48
-
49
- # determine key
50
- #sadie_key = key_prefix+'.'+File.basename( primer_file_filepath )
51
-
52
- # puts "installing db connection: #{sadie_key}"
53
-
54
- sadie.set( sadie_key, dbh )
55
-
56
- end
57
- end
58
- end
59
-
60
- # # build parameter hash
61
- # dbparams = Hash.new
62
- # inifile = Ini.new( primer_file_filepath )
63
- # inifile.each do | section, key_from_ini_file, value |
64
- # section.match(/^connection$/) \
65
- # or next
66
- # dbparams[key_from_ini_file] = value
67
- # end
68
- #
69
- # # validate dbistr
70
- # dbparams.has_key?( 'dbistr' ) \
71
- # or raise 'requried connection::dbistr was not defined'
72
- #
73
- # # default user and pass to nil
74
- # user = dbparams.has_key?('user') ? dbparams['user']: nil;
75
- # pass = dbparams.has_key?('pass') ? dbparams['pass']: nil;
76
- #
77
- # # call connect with block
78
- # require 'dbi'
79
- # DBI.connect( dbparams['dbistr'], user, pass, block )
80
- end
@@ -1,23 +0,0 @@
1
- Sadie::registerPrimerPlugin( { "match" => /\.ini$/,
2
- "accepts-block" => false,
3
- "prime-on-init" => true } ) do |sadie, key_prefix, primer_file_filepath|
4
-
5
- puts "processing ini file: #{primer_file_filepath}"
6
-
7
- ini_file_basename = File.basename primer_file_filepath
8
- ini_file_root = ini_file_basename.gsub( /\.ini$/, "" )
9
-
10
- if inihash = Sadie::iniFileToHash( primer_file_filepath )
11
- inihash.each do |section, section_hash|
12
- key_to_set = key_prefix + "." + ini_file_root + "." + section
13
- key_to_set = key_to_set.gsub(/^\./,"")
14
- sadie.set key_to_set, section_hash
15
- section_hash.each do |key, value|
16
- kvkey_to_set = key_to_set + "." + key
17
- sadie.set( kvkey_to_set, value )
18
-
19
- end
20
- end
21
- end
22
-
23
- end
@@ -1,7 +0,0 @@
1
- Sadie::registerPrimerPlugin( { "match" => /(\.res|\.res\.rb)$/,
2
- "accepts-block" => false,
3
- "prime-on-init" => false } ) do |sadie, key_prefix, primer_file_filepath, block|
4
-
5
- load( primer_file_filepath )
6
-
7
- end
@@ -1,39 +0,0 @@
1
- Sadie::registerPrimerPlugin( { "match" => /\.sql2ar$/,
2
- "accepts-block" => false,
3
- "prime-on-init" => false } ) do |sadie, key_prefix, primer_file_filepath|
4
-
5
- primer_file_basename = File.basename( primer_file_filepath )
6
- sadie_key = key_prefix + '.' + primer_file_basename
7
- sadie_key = sadie_key.gsub(/^\./,"")
8
-
9
- #sadie.debug! 10, "registersql2ar[#{sadie_key},#{primer_file_basename}]"
10
-
11
- Sadie::prime( { "provides" => [ sadie_key ] }) do |sadie|
12
- #puts "priming sql2ar: #{sadie_key}"
13
- if ( matches = primer_file_basename.match( /^(.*)\.([^\.]+)\.sql2ar$/ ) )
14
- dbi_sadie_key = key_prefix + '.' + matches[2] + ".dbi.conx"
15
- #puts "dbi_sadie_key: #{dbi_sadie_key}"
16
- #dbconx = sadie.get( dbi_sadie_key )
17
- if ( dbconx = sadie.get( dbi_sadie_key ) )
18
- if sql_query = Sadie::templatedFileToString( primer_file_filepath )
19
- sadie.debug! 5, "sql2ar: querying database: #{sql_query}"
20
- sth = dbconx.prepare(sql_query)
21
- sth.execute
22
-
23
- result = Array.new
24
- while row = sth.fetch
25
- row_as_array = row.to_a
26
- sadie.debug! 10, "row_as_array: #{row_as_array}"
27
- Sadie::eacherFrame sadie_key, Sadie::EACH, row_as_array
28
- result.push row_as_array
29
- end
30
-
31
- sadie.setExpensive( sadie_key, result )
32
-
33
- # Close the statement handle when done
34
- sth.finish
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,13 +0,0 @@
1
- Sadie::registerPrimerPlugin( { "match" => /\.tmpl$/,
2
- "accepts-block" => false,
3
- "prime-on-init" => false } ) do |sadie, key_prefix, primer_file_filepath|
4
- primer_file_basename = File.basename( primer_file_filepath )
5
- sadie_key = key_prefix + '.' + primer_file_basename
6
- sadie_key = sadie_key.gsub(/^\./,"")
7
-
8
- Sadie::prime( { "provides" => [ sadie_key ] }) do |sadie|
9
-
10
- sadie.setExpensive( sadie_key, Sadie::templatedFileToString( primer_file_filepath ) )
11
-
12
- end
13
- end