From f36e8bf79f92b0be3d87788e6a48605f031698da Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 22 Jul 2014 21:39:25 -0400 Subject: v5 v6: db, pqsl, sqlite, reorganise triggers --- lib/sisu/v5/db_columns.rb | 17 +++- lib/sisu/v5/db_create.rb | 5 +- lib/sisu/v5/db_drop.rb | 2 +- lib/sisu/v5/db_indexes.rb | 2 +- lib/sisu/v5/db_select.rb | 234 +++++++++++++++++++------------------------- lib/sisu/v5/dbi.rb | 18 ++-- lib/sisu/v5/dbi_discrete.rb | 13 ++- lib/sisu/v5/options.rb | 157 ++++++++++++++++++++++++----- lib/sisu/v6/db_columns.rb | 17 +++- lib/sisu/v6/db_create.rb | 5 +- lib/sisu/v6/db_drop.rb | 2 +- lib/sisu/v6/db_indexes.rb | 2 +- lib/sisu/v6/db_select.rb | 234 +++++++++++++++++++------------------------- lib/sisu/v6/dbi.rb | 18 ++-- lib/sisu/v6/dbi_discrete.rb | 13 ++- lib/sisu/v6/options.rb | 157 ++++++++++++++++++++++++----- 16 files changed, 532 insertions(+), 364 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/db_columns.rb b/lib/sisu/v5/db_columns.rb index 42c23cfc..04be289d 100644 --- a/lib/sisu/v5/db_columns.rb +++ b/lib/sisu/v5/db_columns.rb @@ -69,8 +69,11 @@ module SiSU_DbColumns @md=md @db=SiSU_Env::InfoDb.new #watch @lang ||=SiSU_i18n::Languages.new - if defined? md.opt.mod \ - and md.opt.mod.inspect=~/import|update/ \ + if defined? md.opt.act \ + and ((md.opt.act[:psql_import][:set]==:on \ + || md.opt.act[:psql_update][:set]==:on) \ + or (md.opt.act[:sqlite_import][:set]==:on \ + || md.opt.act[:sqlite_update][:set]==:on)) \ and FileTest.exist?(md.fns) txt_arr=IO.readlines(md.fns,'') src=txt_arr.join("\n") @@ -1920,7 +1923,10 @@ module SiSU_DbColumns IS 'sisu markup source text (if shared)';} end def tuple - if @md.opt.mod.inspect=~/import|update/ \ + if ((@md.opt.act[:psql_import][:set]==:on \ + || @md.opt.act[:psql_update][:set]==:on) \ + or (@md.opt.act[:sqlite_import][:set]==:on \ + || @md.opt.act[:sqlite_update][:set]==:on)) \ and FileTest.exist?(@md.fns) ["#{name}, ","'#{@sisutxt}', "] else ['',''] @@ -1944,7 +1950,10 @@ module SiSU_DbColumns IS 'document full text clean, searchable';} end def tuple - if @md.opt.mod.inspect=~/import|update/ \ + if ((@md.opt.act[:psql_import][:set]==:on \ + || @md.opt.act[:psql_update][:set]==:on) \ + or (@md.opt.act[:sqlite_import][:set]==:on \ + || @md.opt.act[:sqlite_update][:set]==:on)) \ and FileTest.exist?(@md.fns) ["#{name}, ","'#{@fulltext}', "] else ['',''] diff --git a/lib/sisu/v5/db_create.rb b/lib/sisu/v5/db_create.rb index 20b2d6ad..142318f5 100644 --- a/lib/sisu/v5/db_create.rb +++ b/lib/sisu/v5/db_create.rb @@ -87,7 +87,8 @@ module SiSU_DbCreate tell=(@sql_type==:sqlite) \ ? SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], - 'Create SQLite db tables in:',%{"#{@file}"} + 'Create SQLite db tables in:', + %{"#{@file}"} ) : SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], @@ -103,7 +104,7 @@ module SiSU_DbCreate end def output_dir? dir=SiSU_Env::InfoEnv.new('') - if @opt.cmd =~/d/ + if @opt.act[:sqlite][:set]==:on dir.path.webserv_stub_ensure end end diff --git a/lib/sisu/v5/db_drop.rb b/lib/sisu/v5/db_drop.rb index 75e98faa..ba7b57cd 100644 --- a/lib/sisu/v5/db_drop.rb +++ b/lib/sisu/v5/db_drop.rb @@ -206,7 +206,7 @@ module SiSU_DbDrop self end indexes.base - @opt.cmd=~/D/ || ((@opt.mod=~/psql/) ? '' : indexes.text) + @opt.act[:psql][:set]==:on ? '' : indexes.text self end end diff --git a/lib/sisu/v5/db_indexes.rb b/lib/sisu/v5/db_indexes.rb index 7e1164ab..b76e4b26 100644 --- a/lib/sisu/v5/db_indexes.rb +++ b/lib/sisu/v5/db_indexes.rb @@ -132,7 +132,7 @@ module SiSU_DbIndex conn_execute_array(sql_arr) end base - @opt.cmd=~/D/ || ((@opt.mod=~/psql/) ? '' : text) + @opt.act[:psql][:set]==:on ? '' : text end end end diff --git a/lib/sisu/v5/db_select.rb b/lib/sisu/v5/db_select.rb index d52df2bf..3f232c14 100644 --- a/lib/sisu/v5/db_select.rb +++ b/lib/sisu/v5/db_select.rb @@ -67,14 +67,24 @@ module SiSU_DbSelect @opt,@conn,@sql_type=opt,conn,sql_type @db=SiSU_Env::InfoDb.new @file_maint=sql_maintenance_file - @sdb=SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb - @sdb_index=SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb - @sdb_no=SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb - if @opt.mod.inspect =~/update|import/ - @sdb_import=SiSU_DbDBI::Import.new(@opt,@conn,@file_maint,@sql_type) - @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) - elsif @opt.mod.inspect =~/remove/ - @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) + @sdb= + SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type) + @sdb_index= + SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type) + @sdb_no= + SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type) + if (@opt.act[:psql_import][:set]==:on \ + || @opt.act[:psql_update][:set]==:on) \ + or (@opt.act[:sqlite_import][:set]==:on \ + || @opt.act[:sqlite_update][:set]==:on) + @sdb_import= + SiSU_DbDBI::Import.new(@opt,@conn,@file_maint,@sql_type) + @sdb_remove_doc= + SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) + elsif (@opt.act[:psql_remove][:set]==:on \ + or @opt.act[:sqlite_remove][:set]==:on) + @sdb_remove_doc= + SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) end end def db_exist? @@ -104,15 +114,18 @@ module SiSU_DbSelect end end def sql_maintenance_file - file=if @opt.inspect =~/M/ + file=if @opt.act[:maintenance][:set]==:on if @opt.fns and not @opt.fns.empty? @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" + end @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') elsif @opt.fns \ - and @opt.fns.inspect =~/create/ + and (@opt.act[:sqlite_create][:set] ==:on \ + || @opt.act[:psql_create][:set] ==:on) nil #sort variations later else nil end @@ -120,135 +133,88 @@ module SiSU_DbSelect end file end - def cases - @opt.mod.each do |mod| - case mod - when /^--createdb$/ - @sdb.output_dir? - begin - @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 - rescue - SiSU_Errors::Rescued.new($!,$@,'-D').location; @sdb.output_dir? do - __LINE__.to_s + ':' + __FILE__ - end - 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 - rescue; @sdb.output_dir? - end - when /^--recreate$/ + def db_action + def createdb + @sdb.output_dir? + begin + @sdb.create_db + rescue @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 - rescue; @sdb.output_dir? - end - when /^--cr(eate)?lex$/ - @sdb.output_dir? - begin - @sdb.create_table.doc_objects - rescue; @sdb.output_dir? - end - when /^--cr(eate)?metadata$/ - @sdb.output_dir? - begin - @sdb.create_table.metadata_and_text - rescue; @sdb.output_dir? - end - when /^--import$/ - db_exist? - @sdb_import.marshal_load - tell=case @sql_type - when :sqlite - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{@db.sqlite.db} database?" - ) - when :pg - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "pgaccess or psql #{@db.psql.db} database?" - ) - else '???' - end - tell.puts_grey if @opt.act[:verbose][:set]==:on - when /^--update$/ - db_exist? - @sdb_remove_doc.remove - @sdb_import.marshal_load - tell=case @sql_type - when :sqlite - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{@db.sqlite.db} database?" - ) - when :pg - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "pgaccess or psql #{@db.psql.db} database?" - ) - else '???' - end - tell.puts_grey if @opt.act[:verbose][:set]==:on - when /^--remove$/ - db_exist? - @sdb_remove_doc.remove - when /^--index$/ - db_exist? + end + end + def drop + @sdb_no.drop.tables + end + def create + @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 - when /^--droptable(s)?$/ - db_exist? - @sdb_no.drop.tables - when /^--dropindex(es)?$/ - db_exist? - @sdb_no.drop.indexes - when /^--(?:dropall|drop)$/ - db_exist? - @sdb_no.drop.tables - when /^--(?:db=)?(?:(?:sq)?lite|pg(?:sql)?|my(?:sql)?)$/ - when /^--(?:v\d+|dev)$/ - else + rescue + SiSU_Errors::Rescued.new($!,$@,'--sqlite').location + @sdb.output_dir? do + __LINE__.to_s + ':' + __FILE__ + end end - if @opt.act[:maintenance][:set]==:on \ - and @opt.cmd =~/d/ - puts @job + end + def import + db_exist? + @sdb_import.marshal_load + tell=case @sql_type + when :sqlite + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + "sqlite3 #{@db.sqlite.db} database?" + ) + when :pg + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + "pgaccess or psql #{@db.psql.db} database?" + ) + else '???' end + tell.puts_grey if @opt.act[:verbose][:set]==:on + end + def remove + db_exist? + @sdb_remove_doc.remove end - if @opt.act[:psql][:set]==:on \ - and @opt.mod.inspect !~/--(?:createdb|init(?:ialize)?|create(?:all)?|createtables?|recreate|cr(eate)?lex|cr(eate)?metadata|import|update|remove|index|droptable(s)?|dropindex(es)?|dropall|drop)/ - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "--pg requires further instruction" - ).warn unless @opt.act[:quiet][:set]==:on + def update + remove + import end - begin - rescue; @sdb.output_dir? + self + end + def cases + if @opt.act[:psql_drop][:set] ==:on \ + or @opt.act[:sqlite_drop][:set] ==:on + db_action.drop + end + if @opt.act[:psql_createdb][:set] ==:on \ + or @opt.act[:sqlite_createdb][:set] ==:on + db_action.createdb + end + if @opt.act[:psql_create][:set] ==:on \ + or @opt.act[:sqlite_create][:set] ==:on + db_action.create + end + if @opt.act[:psql_update][:set] ==:on \ + or @opt.act[:sqlite_update][:set] ==:on + db_action.update + else + if @opt.act[:psql_remove][:set] ==:on \ + or @opt.act[:sqlite_remove][:set] ==:on + db_action.remove + end + if @opt.act[:psql_import][:set] ==:on \ + or @opt.act[:sqlite_import][:set] ==:on + db_action.import + end end end end diff --git a/lib/sisu/v5/dbi.rb b/lib/sisu/v5/dbi.rb index d6454f48..83021b20 100644 --- a/lib/sisu/v5/dbi.rb +++ b/lib/sisu/v5/dbi.rb @@ -73,22 +73,18 @@ module SiSU_DBI def initialize(opt) @opt=opt @db=SiSU_Env::InfoDb.new - if @opt.cmd =~/[Dd]/ \ - or @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/ - @sql_type=if @opt.cmd=~/D/ \ - or @opt.mod.inspect =~/--pg(?:sql)?/ + if @opt.act[:psql][:set]==:on \ + or @opt.act[:sqlite][:set]==:on + @sql_type=if @opt.act[:psql][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :pg - elsif @opt.cmd =~/d/ \ - and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/ + elsif @opt.act[:psql][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :pg - elsif @opt.cmd=~/d/ \ - or @opt.mod.inspect =~/--(?:sq)?lite/ + elsif @opt.act[:sqlite][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :sqlite - elsif @opt.cmd =~/d/ \ - and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/ + elsif @opt.act[:sqlite][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :sqlite else @@ -110,7 +106,7 @@ module SiSU_DBI require 'pg' @conn=@db.psql.conn_pg rescue - if @opt.mod.inspect=~/--(?:createall|create)/ + if @opt.act[:psql_create][:set]==:on cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX puts <<-WOK manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet exist diff --git a/lib/sisu/v5/dbi_discrete.rb b/lib/sisu/v5/dbi_discrete.rb index cb0116b3..a2aa3d09 100644 --- a/lib/sisu/v5/dbi_discrete.rb +++ b/lib/sisu/v5/dbi_discrete.rb @@ -81,8 +81,7 @@ module SiSU_DBI_Discrete #% database building @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @md=@particulars.md - if @opt.cmd =~/[d]/ \ - or @opt.mod.inspect =~/--((?:sq)?lite)/ + if @opt.act[:sqlite][:set]==:on @sql_type=:sqlite maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on end @@ -96,8 +95,8 @@ module SiSU_DBI_Discrete #% database building create_and_populate end def maintenance_check(opt,file,line) - p opt.mod - p opt.cmd + #p opt.mod + #p opt.cmd p "at #{file} #{line}" end def prepare @@ -143,9 +142,9 @@ module SiSU_DBI_Discrete #% database building sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file_maint,:sqlite) sdb_import.marshal_load tell=SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{db.sqlite.db} database?" - ) + @opt.act[:color_state][:set], + "sqlite3 #{db.sqlite.db} database?" + ) tell.puts_grey if @opt.act[:verbose][:set]==:on rescue SiSU_Errors::Rescued.new($!,$@,'-d').location do diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb index 7645c48e..7da84b04 100644 --- a/lib/sisu/v5/options.rb +++ b/lib/sisu/v5/options.rb @@ -537,6 +537,7 @@ module SiSU_Commandline mod << s when /^--(?:epub)$/ then c=c+'e' when /^--(?:od[ft])$/ then c=c+'o' + when /^--docbook$/ then c=c+'d' when /^--(?:pdf)$/ then c=c+'p' when /^--pdf-(?:a4|a5|b5|legal|letter)$/ then c=c+'p' when /^--pdf-(?:p|l|portrait|landscape)$/ then c=c+'L' @@ -554,8 +555,6 @@ module SiSU_Commandline when /^--(?:termsheet)$/ then c=c+'T' when /^--(?:manifest)$/ then c=c+'y' when /^--(?:qrcode)$/ then c=c+'Q' - when /^--(?:sqlite)$/ then c=c+'d' - when /^--(?:pg|pg?sql|postgresql)$/ then c=c+'D' when /^--(?:remote|rsync)$/ then c=c+'R' when /^--(?:scp)$/ then c=c+'r' when /^--(?:source)$/ then c=c+'s' @@ -587,8 +586,7 @@ module SiSU_Commandline extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ and cmd !~/[mn]/ 'm' #% add ao - elsif ((cmd =~/[Dd]/ \ - or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ + elsif ((mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ and cmd !~/[mn]/ 'm' #% add ao @@ -596,18 +594,17 @@ module SiSU_Commandline end end if cmd !~/j/ - extra+=if cmd =~/[bHhwXxyz]/ \ + extra+=if cmd =~/[bdHhwXxyz]/ \ and cmd !~/[j]/ 'j' #% copy images else '' end end if cmd !~/y/ - extra+=if cmd =~/[abeHhIiNopQSstwXxz]/ \ + extra+=if cmd =~/[abdeHhIiNopQSstwXxz]/ \ and cmd !~/y/ 'ym' #% add manifest - elsif (cmd =~/[Dd]/ \ - or mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + elsif mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ \ and files[0] !~/^remove$/ \ and cmd !~/y/ 'ym' #% add manifest @@ -916,7 +913,8 @@ module SiSU_Commandline || mod.inspect =~/"--xml-dom"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:xml_docbook_book]=mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/ \ + act[:xml_docbook_book]=(cmd =~/d/ \ + || mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } act[:xml_fictionbook]=(cmd =~/f/ \ @@ -967,19 +965,134 @@ module SiSU_Commandline || mod.inspect =~/"--texinfo"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:psql]=(cmd =~/D/ \ - || mod.inspect =~/"--pg"|"--pgsql"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sqlite]=(cmd =~/d/ \ - || mod.inspect =~/"--sqlite"/) \ - && (mod.inspect =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sqlite_discrete]=(cmd =~/d/ \ - || mod.inspect =~/"--sql"|"--sqlite"/) \ - && (mod.inspect =~/"--both"/ \ - || mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ + act[:psql]=if mod.inspect =~/"--pg-\S+"/ \ + or ((mod.inspect =~/"--pg"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:psql_createdb]=if mod.inspect \ + =~/"--pg-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--pg-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:psql_drop]={ bool: true, set: :on } + act[:psql_create]={ bool: true, set: :on } + else + act[:psql_drop]=if mod.inspect \ + =~/"--pg-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_create]=if mod.inspect \ + =~/"--pg-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:psql_import]=if mod.inspect \ + =~/"--pg-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_update]=if mod.inspect \ + =~/"--pg-update"|"--update"/ + act[:psql_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:psql_remove]=if mod.inspect \ + =~/"--pg-remove"|"--remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:psql_createdb]= + { bool: false, set: :na } + act[:psql_drop]= + { bool: false, set: :na } + act[:psql_create]= + { bool: false, set: :na } + act[:psql_import]= + { bool: false, set: :na } + act[:psql_update]= + { bool: false, set: :na } + act[:psql_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite]=if (mod.inspect =~/"--sqlite-\S+"/) \ + or ((mod.inspect =~/"--sqlite"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:sqlite_createdb]=if mod.inspect \ + =~/"--sqlite-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--sqlite-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:sqlite_drop]={ bool: true, set: :on } + act[:sqlite_create]={ bool: true, set: :on } + else + act[:sqlite_create]=if mod.inspect \ + =~/"--sqlite-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_drop]=if mod.inspect \ + =~/"--sqlite-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:sqlite_import]=if mod.inspect \ + =~/"--sqlite-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_update]=if mod.inspect \ + =~/"--sqlite-update"|"--update"/ + act[:sqlite_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:sqlite_remove]=if mod.inspect \ + =~/"--sqlite-remove"|"--sqlite-remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:sqlite_createdb]= + { bool: false, set: :na } + act[:sqlite_drop]= + { bool: false, set: :na } + act[:sqlite_create]= + { bool: false, set: :na } + act[:sqlite_import]= + { bool: false, set: :na } + act[:sqlite_update]= + { bool: false, set: :na } + act[:sqlite_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite_discrete]=mod.inspect =~/"--sql"|"--sqlite"/ \ + && (mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } act[:harvest]=(mod.inspect =~/"--harvest"/) \ diff --git a/lib/sisu/v6/db_columns.rb b/lib/sisu/v6/db_columns.rb index 8dd14ddb..f7db347e 100644 --- a/lib/sisu/v6/db_columns.rb +++ b/lib/sisu/v6/db_columns.rb @@ -69,8 +69,11 @@ module SiSU_DbColumns @md=md @db=SiSU_Env::InfoDb.new #watch @lang ||=SiSU_i18n::Languages.new - if defined? md.opt.mod \ - and md.opt.mod.inspect=~/import|update/ \ + if defined? md.opt.act \ + and ((md.opt.act[:psql_import][:set]==:on \ + || md.opt.act[:psql_update][:set]==:on) \ + or (md.opt.act[:sqlite_import][:set]==:on \ + || md.opt.act[:sqlite_update][:set]==:on)) \ and FileTest.exist?(md.fns) txt_arr=IO.readlines(md.fns,'') src=txt_arr.join("\n") @@ -1920,7 +1923,10 @@ module SiSU_DbColumns IS 'sisu markup source text (if shared)';} end def tuple - if @md.opt.mod.inspect=~/import|update/ \ + if ((@md.opt.act[:psql_import][:set]==:on \ + || @md.opt.act[:psql_update][:set]==:on) \ + or (@md.opt.act[:sqlite_import][:set]==:on \ + || @md.opt.act[:sqlite_update][:set]==:on)) \ and FileTest.exist?(@md.fns) ["#{name}, ","'#{@sisutxt}', "] else ['',''] @@ -1944,7 +1950,10 @@ module SiSU_DbColumns IS 'document full text clean, searchable';} end def tuple - if @md.opt.mod.inspect=~/import|update/ \ + if ((@md.opt.act[:psql_import][:set]==:on \ + || @md.opt.act[:psql_update][:set]==:on) \ + or (@md.opt.act[:sqlite_import][:set]==:on \ + || @md.opt.act[:sqlite_update][:set]==:on)) \ and FileTest.exist?(@md.fns) ["#{name}, ","'#{@fulltext}', "] else ['',''] diff --git a/lib/sisu/v6/db_create.rb b/lib/sisu/v6/db_create.rb index 4b4fe080..e9e6aa40 100644 --- a/lib/sisu/v6/db_create.rb +++ b/lib/sisu/v6/db_create.rb @@ -87,7 +87,8 @@ module SiSU_DbCreate tell=(@sql_type==:sqlite) \ ? SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], - 'Create SQLite db tables in:',%{"#{@file}"} + 'Create SQLite db tables in:', + %{"#{@file}"} ) : SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], @@ -103,7 +104,7 @@ module SiSU_DbCreate end def output_dir? dir=SiSU_Env::InfoEnv.new('') - if @opt.cmd =~/d/ + if @opt.act[:sqlite][:set]==:on dir.path.webserv_stub_ensure end end diff --git a/lib/sisu/v6/db_drop.rb b/lib/sisu/v6/db_drop.rb index 926da47f..e93d2889 100644 --- a/lib/sisu/v6/db_drop.rb +++ b/lib/sisu/v6/db_drop.rb @@ -206,7 +206,7 @@ module SiSU_DbDrop self end indexes.base - @opt.cmd=~/D/ || ((@opt.mod=~/psql/) ? '' : indexes.text) + @opt.act[:psql][:set]==:on ? '' : indexes.text self end end diff --git a/lib/sisu/v6/db_indexes.rb b/lib/sisu/v6/db_indexes.rb index 7df20889..876fd856 100644 --- a/lib/sisu/v6/db_indexes.rb +++ b/lib/sisu/v6/db_indexes.rb @@ -132,7 +132,7 @@ module SiSU_DbIndex conn_execute_array(sql_arr) end base - @opt.cmd=~/D/ || ((@opt.mod=~/psql/) ? '' : text) + @opt.act[:psql][:set]==:on ? '' : text end end end diff --git a/lib/sisu/v6/db_select.rb b/lib/sisu/v6/db_select.rb index e4c00cc0..61522e3b 100644 --- a/lib/sisu/v6/db_select.rb +++ b/lib/sisu/v6/db_select.rb @@ -67,14 +67,24 @@ module SiSU_DbSelect @opt,@conn,@sql_type=opt,conn,sql_type @db=SiSU_Env::InfoDb.new @file_maint=sql_maintenance_file - @sdb=SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb - @sdb_index=SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb - @sdb_no=SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb - if @opt.mod.inspect =~/update|import/ - @sdb_import=SiSU_DbDBI::Import.new(@opt,@conn,@file_maint,@sql_type) - @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) - elsif @opt.mod.inspect =~/remove/ - @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) + @sdb= + SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type) + @sdb_index= + SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type) + @sdb_no= + SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type) + if (@opt.act[:psql_import][:set]==:on \ + || @opt.act[:psql_update][:set]==:on) \ + or (@opt.act[:sqlite_import][:set]==:on \ + || @opt.act[:sqlite_update][:set]==:on) + @sdb_import= + SiSU_DbDBI::Import.new(@opt,@conn,@file_maint,@sql_type) + @sdb_remove_doc= + SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) + elsif (@opt.act[:psql_remove][:set]==:on \ + or @opt.act[:sqlite_remove][:set]==:on) + @sdb_remove_doc= + SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) end end def db_exist? @@ -104,15 +114,18 @@ module SiSU_DbSelect end end def sql_maintenance_file - file=if @opt.inspect =~/M/ + file=if @opt.act[:maintenance][:set]==:on if @opt.fns and not @opt.fns.empty? @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" + end @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') elsif @opt.fns \ - and @opt.fns.inspect =~/create/ + and (@opt.act[:sqlite_create][:set] ==:on \ + || @opt.act[:psql_create][:set] ==:on) nil #sort variations later else nil end @@ -120,135 +133,88 @@ module SiSU_DbSelect end file end - def cases - @opt.mod.each do |mod| - case mod - when /^--createdb$/ - @sdb.output_dir? - begin - @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 - rescue - SiSU_Errors::Rescued.new($!,$@,'-D').location; @sdb.output_dir? do - __LINE__.to_s + ':' + __FILE__ - end - 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 - rescue; @sdb.output_dir? - end - when /^--recreate$/ + def db_action + def createdb + @sdb.output_dir? + begin + @sdb.create_db + rescue @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 - rescue; @sdb.output_dir? - end - when /^--cr(eate)?lex$/ - @sdb.output_dir? - begin - @sdb.create_table.doc_objects - rescue; @sdb.output_dir? - end - when /^--cr(eate)?metadata$/ - @sdb.output_dir? - begin - @sdb.create_table.metadata_and_text - rescue; @sdb.output_dir? - end - when /^--import$/ - db_exist? - @sdb_import.marshal_load - tell=case @sql_type - when :sqlite - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{@db.sqlite.db} database?" - ) - when :pg - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "pgaccess or psql #{@db.psql.db} database?" - ) - else '???' - end - tell.puts_grey if @opt.act[:verbose][:set]==:on - when /^--update$/ - db_exist? - @sdb_remove_doc.remove - @sdb_import.marshal_load - tell=case @sql_type - when :sqlite - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{@db.sqlite.db} database?" - ) - when :pg - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "pgaccess or psql #{@db.psql.db} database?" - ) - else '???' - end - tell.puts_grey if @opt.act[:verbose][:set]==:on - when /^--remove$/ - db_exist? - @sdb_remove_doc.remove - when /^--index$/ - db_exist? + end + end + def drop + @sdb_no.drop.tables + end + def create + @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 - when /^--droptable(s)?$/ - db_exist? - @sdb_no.drop.tables - when /^--dropindex(es)?$/ - db_exist? - @sdb_no.drop.indexes - when /^--(?:dropall|drop)$/ - db_exist? - @sdb_no.drop.tables - when /^--(?:db=)?(?:(?:sq)?lite|pg(?:sql)?|my(?:sql)?)$/ - when /^--(?:v\d+|dev)$/ - else + rescue + SiSU_Errors::Rescued.new($!,$@,'--sqlite').location + @sdb.output_dir? do + __LINE__.to_s + ':' + __FILE__ + end end - if @opt.act[:maintenance][:set]==:on \ - and @opt.cmd =~/d/ - puts @job + end + def import + db_exist? + @sdb_import.marshal_load + tell=case @sql_type + when :sqlite + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + "sqlite3 #{@db.sqlite.db} database?" + ) + when :pg + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + "pgaccess or psql #{@db.psql.db} database?" + ) + else '???' end + tell.puts_grey if @opt.act[:verbose][:set]==:on + end + def remove + db_exist? + @sdb_remove_doc.remove end - if @opt.act[:psql][:set]==:on \ - and @opt.mod.inspect !~/--(?:createdb|init(?:ialize)?|create(?:all)?|createtables?|recreate|cr(eate)?lex|cr(eate)?metadata|import|update|remove|index|droptable(s)?|dropindex(es)?|dropall|drop)/ - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "--pg requires further instruction" - ).warn unless @opt.act[:quiet][:set]==:on + def update + remove + import end - begin - rescue; @sdb.output_dir? + self + end + def cases + if @opt.act[:psql_drop][:set] ==:on \ + or @opt.act[:sqlite_drop][:set] ==:on + db_action.drop + end + if @opt.act[:psql_createdb][:set] ==:on \ + or @opt.act[:sqlite_createdb][:set] ==:on + db_action.createdb + end + if @opt.act[:psql_create][:set] ==:on \ + or @opt.act[:sqlite_create][:set] ==:on + db_action.create + end + if @opt.act[:psql_update][:set] ==:on \ + or @opt.act[:sqlite_update][:set] ==:on + db_action.update + else + if @opt.act[:psql_remove][:set] ==:on \ + or @opt.act[:sqlite_remove][:set] ==:on + db_action.remove + end + if @opt.act[:psql_import][:set] ==:on \ + or @opt.act[:sqlite_import][:set] ==:on + db_action.import + end end end end diff --git a/lib/sisu/v6/dbi.rb b/lib/sisu/v6/dbi.rb index d862b1a2..5880aa1a 100644 --- a/lib/sisu/v6/dbi.rb +++ b/lib/sisu/v6/dbi.rb @@ -73,22 +73,18 @@ module SiSU_DBI def initialize(opt) @opt=opt @db=SiSU_Env::InfoDb.new - if @opt.cmd =~/[Dd]/ \ - or @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/ - @sql_type=if @opt.cmd=~/D/ \ - or @opt.mod.inspect =~/--pg(?:sql)?/ + if @opt.act[:psql][:set]==:on \ + or @opt.act[:sqlite][:set]==:on + @sql_type=if @opt.act[:psql][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :pg - elsif @opt.cmd =~/d/ \ - and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/ + elsif @opt.act[:psql][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :pg - elsif @opt.cmd=~/d/ \ - or @opt.mod.inspect =~/--(?:sq)?lite/ + elsif @opt.act[:sqlite][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :sqlite - elsif @opt.cmd =~/d/ \ - and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/ + elsif @opt.act[:sqlite][:set]==:on maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :sqlite else @@ -110,7 +106,7 @@ module SiSU_DBI require 'pg' @conn=@db.psql.conn_pg rescue - if @opt.mod.inspect=~/--(?:createall|create)/ + if @opt.act[:psql_create][:set]==:on cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX puts <<-WOK manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet exist diff --git a/lib/sisu/v6/dbi_discrete.rb b/lib/sisu/v6/dbi_discrete.rb index 7e5a4a48..9e83009e 100644 --- a/lib/sisu/v6/dbi_discrete.rb +++ b/lib/sisu/v6/dbi_discrete.rb @@ -81,8 +81,7 @@ module SiSU_DBI_Discrete #% database building @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @md=@particulars.md - if @opt.cmd =~/[d]/ \ - or @opt.mod.inspect =~/--((?:sq)?lite)/ + if @opt.act[:sqlite][:set]==:on @sql_type=:sqlite maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on end @@ -96,8 +95,8 @@ module SiSU_DBI_Discrete #% database building create_and_populate end def maintenance_check(opt,file,line) - p opt.mod - p opt.cmd + #p opt.mod + #p opt.cmd p "at #{file} #{line}" end def prepare @@ -143,9 +142,9 @@ module SiSU_DBI_Discrete #% database building sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file_maint,:sqlite) sdb_import.marshal_load tell=SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{db.sqlite.db} database?" - ) + @opt.act[:color_state][:set], + "sqlite3 #{db.sqlite.db} database?" + ) tell.puts_grey if @opt.act[:verbose][:set]==:on rescue SiSU_Errors::Rescued.new($!,$@,'-d').location do diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb index ae641be4..232481c8 100644 --- a/lib/sisu/v6/options.rb +++ b/lib/sisu/v6/options.rb @@ -537,6 +537,7 @@ module SiSU_Commandline mod << s when /^--(?:epub)$/ then c=c+'e' when /^--(?:od[ft])$/ then c=c+'o' + when /^--docbook$/ then c=c+'d' when /^--(?:pdf)$/ then c=c+'p' when /^--pdf-(?:a4|a5|b5|legal|letter)$/ then c=c+'p' when /^--pdf-(?:p|l|portrait|landscape)$/ then c=c+'L' @@ -554,8 +555,6 @@ module SiSU_Commandline when /^--(?:termsheet)$/ then c=c+'T' when /^--(?:manifest)$/ then c=c+'y' when /^--(?:qrcode)$/ then c=c+'Q' - when /^--(?:sqlite)$/ then c=c+'d' - when /^--(?:pg|pg?sql|postgresql)$/ then c=c+'D' when /^--(?:remote|rsync)$/ then c=c+'R' when /^--(?:scp)$/ then c=c+'r' when /^--(?:source)$/ then c=c+'s' @@ -587,8 +586,7 @@ module SiSU_Commandline extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ and cmd !~/[mn]/ 'm' #% add ao - elsif ((cmd =~/[Dd]/ \ - or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ + elsif ((mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ and cmd !~/[mn]/ 'm' #% add ao @@ -596,18 +594,17 @@ module SiSU_Commandline end end if cmd !~/j/ - extra+=if cmd =~/[bHhwXxyz]/ \ + extra+=if cmd =~/[bdHhwXxyz]/ \ and cmd !~/[j]/ 'j' #% copy images else '' end end if cmd !~/y/ - extra+=if cmd =~/[abeHhIiNopQSstwXxz]/ \ + extra+=if cmd =~/[abdeHhIiNopQSstwXxz]/ \ and cmd !~/y/ 'ym' #% add manifest - elsif (cmd =~/[Dd]/ \ - or mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + elsif mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ \ and files[0] !~/^remove$/ \ and cmd !~/y/ 'ym' #% add manifest @@ -916,7 +913,8 @@ module SiSU_Commandline || mod.inspect =~/"--xml-dom"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:xml_docbook_book]=mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/ \ + act[:xml_docbook_book]=(cmd =~/d/ \ + || mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } act[:xml_fictionbook]=(cmd =~/f/ \ @@ -967,19 +965,134 @@ module SiSU_Commandline || mod.inspect =~/"--texinfo"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:psql]=(cmd =~/D/ \ - || mod.inspect =~/"--pg"|"--pgsql"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sqlite]=(cmd =~/d/ \ - || mod.inspect =~/"--sqlite"/) \ - && (mod.inspect =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sqlite_discrete]=(cmd =~/d/ \ - || mod.inspect =~/"--sql"|"--sqlite"/) \ - && (mod.inspect =~/"--both"/ \ - || mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ + act[:psql]=if mod.inspect =~/"--pg-\S+"/ \ + or ((mod.inspect =~/"--pg"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:psql_createdb]=if mod.inspect \ + =~/"--pg-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--pg-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:psql_drop]={ bool: true, set: :on } + act[:psql_create]={ bool: true, set: :on } + else + act[:psql_drop]=if mod.inspect \ + =~/"--pg-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_create]=if mod.inspect \ + =~/"--pg-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:psql_import]=if mod.inspect \ + =~/"--pg-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_update]=if mod.inspect \ + =~/"--pg-update"|"--update"/ + act[:psql_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:psql_remove]=if mod.inspect \ + =~/"--pg-remove"|"--remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:psql_createdb]= + { bool: false, set: :na } + act[:psql_drop]= + { bool: false, set: :na } + act[:psql_create]= + { bool: false, set: :na } + act[:psql_import]= + { bool: false, set: :na } + act[:psql_update]= + { bool: false, set: :na } + act[:psql_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite]=if (mod.inspect =~/"--sqlite-\S+"/) \ + or ((mod.inspect =~/"--sqlite"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:sqlite_createdb]=if mod.inspect \ + =~/"--sqlite-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--sqlite-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:sqlite_drop]={ bool: true, set: :on } + act[:sqlite_create]={ bool: true, set: :on } + else + act[:sqlite_create]=if mod.inspect \ + =~/"--sqlite-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_drop]=if mod.inspect \ + =~/"--sqlite-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:sqlite_import]=if mod.inspect \ + =~/"--sqlite-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_update]=if mod.inspect \ + =~/"--sqlite-update"|"--update"/ + act[:sqlite_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:sqlite_remove]=if mod.inspect \ + =~/"--sqlite-remove"|"--sqlite-remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:sqlite_createdb]= + { bool: false, set: :na } + act[:sqlite_drop]= + { bool: false, set: :na } + act[:sqlite_create]= + { bool: false, set: :na } + act[:sqlite_import]= + { bool: false, set: :na } + act[:sqlite_update]= + { bool: false, set: :na } + act[:sqlite_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite_discrete]=mod.inspect =~/"--sql"|"--sqlite"/ \ + && (mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } act[:harvest]=(mod.inspect =~/"--harvest"/) \ -- cgit v1.2.3