From 86b767b0f9a5aeac4708e48231d2010215b35e2b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 Mar 2012 18:49:49 -0400 Subject: v3dv: sqlite3 discreet .sql.db file for each document (possibility added) * in addition to existing possibility of a shared db in sqlite3 or postgresql --- lib/sisu/v3dv/sysenv.rb | 276 ++++++++++++++++++++++++++++++------------------ 1 file changed, 171 insertions(+), 105 deletions(-) (limited to 'lib/sisu/v3dv/sysenv.rb') diff --git a/lib/sisu/v3dv/sysenv.rb b/lib/sisu/v3dv/sysenv.rb index 95ebf6d9..4383a893 100644 --- a/lib/sisu/v3dv/sysenv.rb +++ b/lib/sisu/v3dv/sysenv.rb @@ -2733,7 +2733,7 @@ WOK and not (@rc['flag']['default'].nil? \ or @rc['flag']['default'].empty?) @rc['flag']['default'] - else '-NQhewpotbxXyYv' + else '-NQhewpotbxXdyYv' end end def cf_1 #processing flag shortcuts @@ -2749,7 +2749,7 @@ WOK and not (@rc['flag']['ii'].nil? \ or @rc['flag']['ii'].empty?) @rc['flag']['ii'] - else '-NQhewpotbxXy' + else '-NQhewpotbxXdy' end end def cf_3 #processing flag shortcuts @@ -2757,7 +2757,7 @@ WOK and not (@rc['flag']['iii'].nil? \ or @rc['flag']['iii'].empty?) @rc['flag']['iii'] - else '-NQhewpotbxXyY' + else '-NQhewpotbxXdyY' end end def cf_4 #processing flag shortcuts @@ -2765,7 +2765,7 @@ WOK and not (@rc['flag']['iv'].nil? \ or @rc['flag']['iv'].empty?) @rc['flag']['iv'] - else '-NQhewpotbxXDyY --update' + else '-NQhewpotbxXdDyY --update' end end def cf_5 #processing flag shortcuts @@ -2773,7 +2773,7 @@ WOK and not (@rc['flag']['v'].nil? \ or @rc['flag']['v'].empty?) @rc['flag']['v'] - else '-NQhewpotbxXDyYv --update' + else '-NQhewpotbxXdDyYv --update' end end end @@ -3795,6 +3795,134 @@ WOK self end end + class InfoDb < InfoEnv + @@rc=nil + def initialize + @@pwd ||=Dir.pwd + @pwd=Dir.pwd + @env=SiSU_Env::InfoEnv.new + pt=Pathname.new(@pwd) + r=Px[:lng_lst].join('|') + u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ + @pwd_stub=pt.realpath.to_s[u,1] + @rc=@@rc ||=GetInit.instance.sisu_yaml.rc + @defaults=SiSU_Env::InfoEnv.new.defaults + end + def share_source? + ((defined? @rc['db']['share_source']) \ + && @rc['db']['share_source']==true) \ + ? @rc['db']['share_source'] + : false + end + def engine + def default + ((defined? @rc['db']['engine']['default']) \ + && @rc['db']['engine']['default']=~/postgresql|sqlite/) \ + ? @rc['db']['engine']['default'] + : 'sqlite' + end + self + end + def psql + def user + ((defined? @rc['db']['postgresql']['user']) \ + && @rc['db']['postgresql']['user']=~/\S+/) \ + ? @rc['db']['postgresql']['user'] + : @env.user + end + def db #db_name + "#{Db[:name_prefix]}#{@pwd_stub}" + end + def port #PGPORT + ((defined? @rc['db']['postgresql']['port']) \ + && ( @rc['db']['postgresql']['port'] =~/\d+/ \ + || @rc['db']['postgresql']['port'].class==Fixnum)) \ + ? @rc['db']['postgresql']['port'] + : (@defaults[:postgresql_port]) + end + def password + ((defined? @rc['db']['postgresql']['password']) \ + && @rc['db']['postgresql']['password']=~/\S+/) \ + ? @rc['db']['postgresql']['password'] + : '' + end + def host + ((defined? @rc['db']['postgresql']['host']) \ + && @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ + ? @rc['db']['postgresql']['host'] + : '' + end + def dbi + (psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ + ? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}" + : "DBI:Pg:database=#{psql.db};port=#{psql.port}" + end + def conn_dbi + DBI.connect(psql.dbi,psql.user,psql.db) + end + self + end + def mysql + def db + #"#{Db[:name_prefix]}#{@pwd_stub}" + end + def port + '**' + end + def dbi + "dbi:Mysql:database=#{mysql.db};port=#{mysql.port}" + end + self + end + def sqlite + def db + "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db" + end + def db_discreet(md) + # "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db" + end + def dbi + "DBI:SQLite3:#{sqlite.db}" #sqlite3 ? + end + def sqlite3 + sqlite.db #sqlite3 ? + end + def conn_dbi + DBI.connect(sqlite.dbi) + end + def conn_sqlite3 + SQLite3::Database.new(sqlite.sqlite3) + end + self + end + end + class DbOp