diff options
| author | Ralph Amissah <ralph@amissah.com> | 2012-03-12 18:49:49 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2012-03-12 18:50:04 -0400 | 
| commit | 86b767b0f9a5aeac4708e48231d2010215b35e2b (patch) | |
| tree | 0d9f69401731ac3cc670e6826e88a390558c9a06 | |
| parent | v3dv: documentation sisu_commands, rearranged & update with regard to excludes (diff) | |
v3dv: sqlite3 discreet .sql.db file for each document (possibility added)
* in addition to existing possibility of a shared db in sqlite3 or postgresql
| -rw-r--r-- | conf/sisu/v3dv/sisurc.yml | 8 | ||||
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v3 | 3 | ||||
| -rw-r--r-- | lib/sisu/v3dv/db_create.rb | 4 | ||||
| -rw-r--r-- | lib/sisu/v3dv/db_dbi.rb | 12 | ||||
| -rw-r--r-- | lib/sisu/v3dv/db_drop.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v3dv/db_select.rb | 50 | ||||
| -rw-r--r-- | lib/sisu/v3dv/dbi.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v3dv/dbi_discreet.rb | 158 | ||||
| -rw-r--r-- | lib/sisu/v3dv/hub.rb | 8 | ||||
| -rw-r--r-- | lib/sisu/v3dv/options.rb | 6 | ||||
| -rw-r--r-- | lib/sisu/v3dv/sysenv.rb | 276 | ||||
| -rw-r--r-- | lib/sisu/v3dv/urls.rb | 2 | 
12 files changed, 384 insertions, 147 deletions
| diff --git a/conf/sisu/v3dv/sisurc.yml b/conf/sisu/v3dv/sisurc.yml index 5416a65e..de2288f9 100644 --- a/conf/sisu/v3dv/sisurc.yml +++ b/conf/sisu/v3dv/sisurc.yml @@ -49,11 +49,11 @@ show_output_on: 'filesystem_url'  #% flag - set (non-default) processing flag shortcuts -1, -2 etc. (here adding colour and verbosity as default)  flag:    color:        true                        # making colour default -c is toggle, and will now toggle colour off -  default:      '-NhewpotbxXyYv'            # -m run by default; includes verbose +  default:      '-NhewpotbxXyYdv'           # -m run by default; includes verbose    i:            '-Nhewpoty'                 # -m run by default -  ii:           '-NhewpotbxX'               # -m run by default -  iii:          '-NhewpotbxXY'              # -m run by default -  iv:           '-NhewpotbxXiIY'            # -m run by default +  ii:           '-NhewpotbxXd'              # -m run by default +  iii:          '-NhewpotbxXYd'             # -m run by default +  iv:           '-NhewpotbxXiIYd'           # -m run by default    v:            '-NhewpotbxXYDv --update'   # -m run by default; includes verbose  #% papersize, (LaTeX/pdf) available values: A4, US_letter, book_b5, book_a5, US_legal diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index b432aab8..d2a460b9 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -73,6 +73,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.1.15.orig.tar.xz  * v3dv, documentation sisu_commands, rearranged & update with regard to excludes +* v3dv, sqlite3 discreet .sql.db file for each document (in addition to +  existing possibility of a shared db in sqlite3 or postgresql) +  * texinfo, fix (break holding back 3.2 merge)    [proposed next version starts 3.2, (merge dev branch after 3.1.15)] diff --git a/lib/sisu/v3dv/db_create.rb b/lib/sisu/v3dv/db_create.rb index 6420c3ec..627f0ea5 100644 --- a/lib/sisu/v3dv/db_create.rb +++ b/lib/sisu/v3dv/db_create.rb @@ -81,9 +81,9 @@ module SiSU_DbCreate      def create_db        @env=SiSU_Env::InfoEnv.new(@opt.fns)        tell=(@sql_type=='sqlite') \ -      ? SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create Sqlite db tables in:',%{"#{@env.path.output}/sisu_sqlite.db"}) +      ? SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create Sqlite db tables in:',%{"#{@file}"})        : SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create PG db tables in:',%{"#{Db[:name_prefix]}#{@env.path.stub_pwd}"}) -      tell.colorize if @opt.cmd =~/vVM/ +      tell.colorize if @opt.cmd =~/[vVM]/        SiSU_Env::SystemCall.new.create_pg_db(@env.path.stub_pwd) if @sql_type=='pg' #watch use of path.stub_pwd instead of stub      end      def output_dir? diff --git a/lib/sisu/v3dv/db_dbi.rb b/lib/sisu/v3dv/db_dbi.rb index f15b2456..0c19578f 100644 --- a/lib/sisu/v3dv/db_dbi.rb +++ b/lib/sisu/v3dv/db_dbi.rb @@ -69,17 +69,17 @@ module  SiSU_DbDBI    require_relative 'db_import'                                              # db_import.rb    class ColumnSize < SiSU_DbColumns::ColumnSize                             # db_columns.rb    end -  class Test < SiSU_DbTests::Test                                             # db_tests.rb +  class Test < SiSU_DbTests::Test                                           # db_tests.rb    end -  class Create <SiSU_DbCreate::Create                                         # db_create.rb +  class Create <SiSU_DbCreate::Create                                       # db_create.rb    end -  class Case <SiSU_DbSelect::Case                                             # db_select.rb +  class Case <SiSU_DbSelect::Case                                           # db_select.rb    end -  class Index <SiSU_DbIndex::Index                                            # db_indexes.rb +  class Index <SiSU_DbIndex::Index                                          # db_indexes.rb    end -  class Drop <SiSU_DbDrop::Drop                                               # db_drop.rb +  class Drop <SiSU_DbDrop::Drop                                             # db_drop.rb    end -  class Remove <SiSU_DbRemove::Remove                                         # db_remove.rb +  class Remove <SiSU_DbRemove::Remove                                       # db_remove.rb    end    class LoadDocuments <SiSU_DbTuple::LoadDocuments                          # db_load_tuple.rb    end diff --git a/lib/sisu/v3dv/db_drop.rb b/lib/sisu/v3dv/db_drop.rb index 97bf8665..4b9aba7d 100644 --- a/lib/sisu/v3dv/db_drop.rb +++ b/lib/sisu/v3dv/db_drop.rb @@ -104,7 +104,7 @@ module SiSU_DbDrop                  sdb.create_table.endnotes_plus                  sdb.create_table.urls                  sdb_index.create_indexes -              rescue;  SiSU_Errors::InfoError.new($!,$@,'-D').error; @sdb.output_dir? +              rescue;  SiSU_Errors::InfoError.new($!,$@,'-D').error; sdb.output_dir?                end                exit              else diff --git a/lib/sisu/v3dv/db_select.rb b/lib/sisu/v3dv/db_select.rb index bab898f0..52fbe8ba 100644 --- a/lib/sisu/v3dv/db_select.rb +++ b/lib/sisu/v3dv/db_select.rb @@ -108,56 +108,56 @@ module SiSU_DbSelect          when /^--createdb$/            @sdb.output_dir?            begin -          @sdb.create_db +            @sdb.create_db            rescue; @sdb.output_dir?            end          when /^--(?:init(?:ialize)?|create(?:all)?)$/            @sdb.output_dir?            begin -          @sdb.create_table.metadata_and_text -          @sdb.create_table.doc_objects -          @sdb.create_table.endnotes -          @sdb.create_table.endnotes_asterisk -          @sdb.create_table.endnotes_plus -          @sdb.create_table.urls -          @sdb_index.create_indexes +            @sdb.create_table.metadata_and_text +            @sdb.create_table.doc_objects +            @sdb.create_table.endnotes +            @sdb.create_table.endnotes_asterisk +            @sdb.create_table.endnotes_plus +            @sdb.create_table.urls +            @sdb_index.create_indexes            rescue;  SiSU_Errors::InfoError.new($!,$@,'-D').error; @sdb.output_dir?            end          when /^--createtables?$/            @sdb.output_dir?            begin -          @sdb.create_table.metadata_and_text -          @sdb.create_table.doc_objects -          @sdb.create_table.endnotes -          @sdb.create_table.endnotes_asterisk -          @sdb.create_table.endnotes_plus -          @sdb.create_table.urls -          @sdb_index.create_indexes +            @sdb.create_table.metadata_and_text +            @sdb.create_table.doc_objects +            @sdb.create_table.endnotes +            @sdb.create_table.endnotes_asterisk +            @sdb.create_table.endnotes_plus +            @sdb.create_table.urls +            @sdb_index.create_indexes            rescue; @sdb.output_dir?            end          when /^--recreate$/            @sdb.output_dir?            begin -          @sdb_no.drop.tables -          @sdb.create_table.metadata_and_text -          @sdb.create_table.doc_objects -          @sdb.create_table.endnotes -          @sdb.create_table.endnotes_asterisk -          @sdb.create_table.endnotes_plus -          @sdb.create_table.urls -          @sdb_index.create_indexes +            @sdb_no.drop.tables +            @sdb.create_table.metadata_and_text +            @sdb.create_table.doc_objects +            @sdb.create_table.endnotes +            @sdb.create_table.endnotes_asterisk +            @sdb.create_table.endnotes_plus +            @sdb.create_table.urls +            @sdb_index.create_indexes            rescue; @sdb.output_dir?            end          when /^--cr(eate)?lex$/            @sdb.output_dir?            begin -          @sdb.create_table.doc_objects +            @sdb.create_table.doc_objects            rescue; @sdb.output_dir?            end          when /^--cr(eate)?metadata$/            @sdb.output_dir?            begin -          @sdb.create_table.metadata_and_text +            @sdb.create_table.metadata_and_text            rescue; @sdb.output_dir?            end          when /^--import$/ diff --git a/lib/sisu/v3dv/dbi.rb b/lib/sisu/v3dv/dbi.rb index e0bd169e..f11d9e81 100644 --- a/lib/sisu/v3dv/dbi.rb +++ b/lib/sisu/v3dv/dbi.rb @@ -71,7 +71,7 @@ module  SiSU_DBI        SiSU_Env::Load.new('dbi',true).prog        @opt=opt        @db=SiSU_Env::InfoDb.new -      if @opt.cmd =~/d/i \ +      if @opt.cmd =~/[Dd]/ \        or  @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/          @sql_type=if @opt.cmd=~/D/ \          or @opt.mod.inspect =~/--pg(?:sql)?/ diff --git a/lib/sisu/v3dv/dbi_discreet.rb b/lib/sisu/v3dv/dbi_discreet.rb new file mode 100644 index 00000000..d9ecd8e7 --- /dev/null +++ b/lib/sisu/v3dv/dbi_discreet.rb @@ -0,0 +1,158 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997 - 2012, Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/licenses/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: postgresql module, dbi import frame + +=end +module  SiSU_DBI_Discreet                               #% database building +  require_relative 'help'                               # help.rb +  require_relative 'sysenv'                             # sysenv.rb +    include SiSU_Env; include SiSU_Screen +  require_relative 'param'                              # param.rb +    include SiSU_Param +  require_relative 'db_dbi'                             # db_dbi.rb +    include SiSU_DbDBI +  require_relative 'shared_html_lite'                   # shared_html_lite.rb +    include SiSU_FormatShared +  require 'fileutils' +    include FileUtils::Verbose +  class SQL +    def initialize(opt) +      SiSU_Env::Load.new('dbi',true).prog +      @opt=opt +      @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) +      @md=@particulars.md +      if @opt.cmd =~/[d]/ \ +      or  @opt.mod.inspect =~/--((?:sq)?lite)/ +        @sql_type='sqlite' +        maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ +      end +      @output_path=@md.file.output_path.sqlite_discreet.dir +      @filename=@md.file.base_filename.sqlite_discreet +      @file="#{@output_path}/#{@filename}" +    end +    def build +      prepare +      create_and_populate +    end +    def maintenance_check(opt,file,line) +      p opt.mod +      p opt.cmd +      p "at #{file} #{line}" +    end +    def prepare +      if not FileTest.directory?(@output_path) +        FileUtils::mkdir_p(@output_path) +      elsif @file +        FileUtils::rm_rf(@file) +      end +    end +    def db_exist?(db,conn) +      msg=%{no connection with sqlite database established, createdb "#{db.sqlite.db}"?} +      if (not (FileTest.file?(db.sqlite.db)) \ +      or FileTest.zero?(db.sqlite.db)) +        puts msg +        exit +      end +      if conn.class==NilClass +        puts msg +        exit +      end +    end +    def create_and_populate +      db=SiSU_Env::DbOp.new(@md) +      conn=db.sqlite_discreet.conn_sqlite3 +      sdb=SiSU_DbDBI::Create.new(@opt,conn,@file,'sqlite') +      sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file,'sqlite') +      sdb.output_dir? +      begin +        sdb.create_db +        sdb.create_table.metadata_and_text +        sdb.create_table.doc_objects +        sdb.create_table.endnotes +        sdb.create_table.endnotes_asterisk +        sdb.create_table.endnotes_plus +        sdb.create_table.urls +        sdb_index.create_indexes +        db_exist?(db,conn) +        sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file,'sqlite') +        sdb_import.marshal_load +        tell=SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{db.sqlite.db} database?") +        tell.puts_grey if @opt.cmd =~/v/ +      rescue;  SiSU_Errors::InfoError.new($!,$@,'-d').error; sdb.output_dir? +      end +    end +    def read_sqlite +      begin +        @conn=@db.sqlite.conn_sqlite3 +      rescue +      ensure +      end +    end +    def connect +      begin +        sql_type='sqlite' +        SiSU_Screen::Ansi.new(@opt.cmd,"DBI (#{@sql_type}) #{@opt.mod}",@opt.fns).dbi_title unless @opt.cmd =~/q/ +        @db.sqlite_discreet.conn_sqlite3 +      rescue +        SiSU_Errors::InfoError.new($!,$@,@cf,@opt.fns).error +      ensure +      end +    end +    def populate +    end +  end +end +__END__ diff --git a/lib/sisu/v3dv/hub.rb b/lib/sisu/v3dv/hub.rb index fd7909ec..5f256314 100644 --- a/lib/sisu/v3dv/hub.rb +++ b/lib/sisu/v3dv/hub.rb @@ -224,7 +224,8 @@ module SiSU                    when /^qrcode$/;          SiSU_QRcode::Source.new(@opt).read           # -Q     qrcode.rb                    when /^sitemaps$/;        SiSU_Sitemaps::Source.new(@opt).read         # -Y     sitemaps.rb                    when /^zap$/;             SiSU_Zap::Source.new(@opt).read              # -Z     zap.rb -                  when /^dbi$/;             SiSU_DBI::SQL.new(@opt).connect         # -D -d  dbi.rb +                  when /^dbi$/;             SiSU_DBI::SQL.new(@opt).connect              # -D -d  dbi.rb +                  when /^dbi_discreet$/;    SiSU_DBI_Discreet::SQL.new(@opt).build       # -d     dbi_discreet.rb                    end                    @n_do=@n_do+1                    SiSU_Screen::Ansi.new(@opt.cmd,@n_do,"#{@req.upcase} processed").files_processed if @opt.cmd =~/[MVv]/ @@ -255,7 +256,7 @@ module SiSU              end            end          end -      elsif @req =~/^dbi$/;            SiSU_DBI::SQL.new(@opt).connect    # -D -d +      elsif @req =~/^dbi$/;            SiSU_DBI::SQL.new(@opt).connect         # -D -d        elsif @req=~/^sisupod_make$/;    SiSU_Doc::Source.new(@opt).read         # -S        end        SiSU::Operations.new.counter @@ -564,6 +565,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/          if @opt.act[:psql][:bool]                                              #% --pg, -D DB postgresql            op('dbi','postgresql')          end +        if @opt.act[:sqlite_discreet][:bool]                                            #% --sqlite, -d DB sqlite +          op('dbi_discreet','sqlite') +        end          if @opt.act[:sqlite][:bool]                                            #% --sqlite, -d DB sqlite            op('dbi','sqlite')          end diff --git a/lib/sisu/v3dv/options.rb b/lib/sisu/v3dv/options.rb index 44eb1020..11d03e1d 100644 --- a/lib/sisu/v3dv/options.rb +++ b/lib/sisu/v3dv/options.rb @@ -665,6 +665,12 @@ module SiSU_Commandline        && (mod.inspect =~/"--createdb"|"--create"|"--recreate"|"--dropall"|"--recreate"|"--import"|"--update"|"--remove"/) \        ? { bool: true, set: :on }        : { bool: false, set: :na } +      act[:sqlite_discreet]=(cmd =~/d/ \ +      || mod.inspect =~/"--sql"|"--sqlite"/) \ +      && (mod.inspect =~/"--both"/ \ +      || mod.inspect !~/"--createdb"|"--create"|"--recreate"|"--dropall"|"--recreate"|"--import"|"--update"|"--remove"/) \ +      ? { bool: true, set: :on } +      : { bool: false, set: :na }        act[:harvest]=(mod.inspect =~/"--harvest"/) \        ? { bool: true, set: :on }        : { bool: false, set: :na } 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 <InfoDb +    def initialize(md) +      begin +        @md=md +      rescue; STDERR.puts SiSU_Screen::Ansi.new(@cmd,$!,$@).rescue +      ensure +      end +    end +    def sqlite_discreet +      def db +        "#{@md.file.output_path.sqlite_discreet.dir}/#{@md.file.base_filename.sqlite_discreet}" +      end +      def dbi +        "DBI:SQLite3:#{sqlite_discreet.db}" +      end +      def sqlite3 +        sqlite_discreet.db +      end +      def conn_dbi +        DBI.connect(sqlite_discreet.dbi) +      end +      def conn_sqlite3 +        SQLite3::Database.new(sqlite_discreet.sqlite3) +      end +      self +    end +  end    class FileOp <InfoFile                                                    #todo unify with CreateFile      def initialize(md,fno='')        begin @@ -4055,6 +4183,15 @@ WOK          end          self        end +      def sqlite_discreet +        def dir +          output_path.sqlite_discreet.dir + '/' + base_filename.sqlite_discreet +        end +        def rel +          output_path.sqlite_discreet.rel + '/' + base_filename.sqlite_discreet +        end +        self +      end        def hash_digest          def dir            output_path.hash_digest.dir + '/' + base_filename.hash_digest @@ -4345,6 +4482,14 @@ WOK            @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft          end        end +      def sqlite_discreet +        ft='.sql.db' +        if output_dir_structure.by_language_code? +          @md.fnb + ft +        else +          @md.fnb + @md.lang_code_insert + ft +        end +      end        def hash_digest          ft='.txt'          if output_dir_structure.by_language_code? @@ -5002,6 +5147,27 @@ WOK          end          self        end +      def sqlite_discreet +        def ft +         'sql' +        end +        def dir +          set_path(ft).dir.ab +        end +        def url +          set_path(ft).url.ab +        end +        def rel +          set_path(ft).rel.ab +        end +        def rcp +          set_path(ft).rcp.ab +        end +        def rel_sm +          set_path(ft).rel_sm.ab +        end +        self +      end        def hash_digest          def ft           'hashes' @@ -5339,106 +5505,6 @@ WOK        @@publisher='SiSU scribe'      end    end -  class InfoDb < InfoEnv -    @@rc=nil -    def initialize -      @@pwd ||=Dir.pwd -      @pwd=Dir.pwd -      @env=SiSU_Env::InfoEnv.new -      #m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m -      #@pwd_stub=@pwd[m,1] -      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 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 InfoPort < InfoEnv      def initialize        @env=SiSU_Env::InfoEnv.new diff --git a/lib/sisu/v3dv/urls.rb b/lib/sisu/v3dv/urls.rb index 39156dff..31614a37 100644 --- a/lib/sisu/v3dv/urls.rb +++ b/lib/sisu/v3dv/urls.rb @@ -215,7 +215,7 @@ module SiSU_Urls            SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x} DBI psql","#{@pwd_stub}::#{@opt.fns}",y).result          end          def sqlite(x,y) -          SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x} DBI sqlite","sqlite3 #{@env.path.webserv}/#{@md.opt.f_pth[:pth_stub]}/sisu_sqlite.db", "#{y}").result +          SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x} DBI sqlite","sqlite3 #{@md.file.output_path.sqlite_discreet.dir}/#{@md.file.base_filename.sqlite_discreet}\n          sqlite3 #{@env.path.webserv}/#{@md.opt.f_pth[:pth_stub]}/sisu_sqlite.db\n", "#{y}").result          end          self        end | 
