aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/db_import.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v0/db_import.rb')
-rw-r--r--lib/sisu/v0/db_import.rb87
1 files changed, 43 insertions, 44 deletions
diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb
index 631c3209..4dc360f8 100644
--- a/lib/sisu/v0/db_import.rb
+++ b/lib/sisu/v0/db_import.rb
@@ -77,8 +77,7 @@ module SiSU_DB_import
end
@suffix=@opt.fns[/(?:.+?)(?:\.ssm\.sst|\.-?sst)/,1]
@fnm="#@dal/#{@opt.fns}.meta.rbm"
- @@seg=''
- @@seg_full='' #create? consider placing field just before clean text as opposed to seg which contains seg(.html) name info seg_full would contain seg info for levels 5 & 6 where available eg seg_full may be 7.3 (level 5) and 7.3.1 (level 6) where seg is 7
+ @@seg,@@seg_full='','' #create? consider placing field just before clean text as opposed to seg which contains seg(.html) name info seg_full would contain seg info for levels 5 & 6 where available eg seg_full may be 7.3 (level 5) and 7.3.1 (level 6) where seg is 7
@col=Hash.new('')
@col[:ocn]=''
@counter={}
@@ -100,18 +99,18 @@ module SiSU_DB_import
tell=SiSU_Screen::Ansi.new(@opt.cmd,'Marshal Load',@fnm)
tell.print_grey if @opt.cmd =~/v/
case @sql_type
- when /sqlite/ #fix logic for sqlite !
+ when /sqlite/ #fix logic for sqlite !
import_db_metadata(@dal_array)
import_documents(@dal_array)
- import_db_urls(@dal_array,@fnm) #import OID on/off
- @conn.commit #sqlite watch
+ import_db_urls(@dal_array,@fnm) #import OID on/off
+ @conn.commit #sqlite watch
else
file_exist=@conn.select_one(%{ SELECT metadata.tid FROM metadata WHERE metadata.filename ~ '#{@opt.fns}'; })
unless file_exist
@conn.execute('BEGIN')
import_db_metadata(@dal_array)
import_documents(@dal_array)
- import_db_urls(@dal_array,@fnm) #import OID on/off
+ import_db_urls(@dal_array,@fnm) #import OID on/off
@conn.execute('COMMIT')
else
@db=SiSU_Env::Info_db.new
@@ -337,12 +336,12 @@ module SiSU_DB_import
# #id,info='Generated by',"#{@md.sisu_version[:project]} #{@md.sisu_version[:version]} #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})"
#end
#if @md.ruby_version; special_character_escape(@md.ruby_version)
- SiSU_DB_DBI::Test.new(self,@opt).verify #% import title names, filenames (tuple)
+ SiSU_DB_DBI::Test.new(self,@opt).verify #% import title names, filenames (tuple)
t=SiSU_DB_tuple::Load_metadata.new(@conn,@tp,@@id_t)
t.tuple
end
- def import_documents(dbi_unit) #% import documents - populate main database table
- #% import into substantive database tables (tuple)
+ def import_documents(dbi_unit) #% import documents - populate main database table
+ #% import into substantive database tables (tuple)
begin
@col[:tid]=@@id_t
@en,@en_ast,@en_pls=[],[],[]
@@ -502,7 +501,7 @@ module SiSU_DB_import
t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt)
t.tuple
@col[:lev]=@col[:plaintext]=@col[:body]=''
- else #% regular text
+ else #% regular text
@col[:lid]+=1
txt=''
txt,@col[:ocn],@col[:ocnd],@col[:ocns],@col[:digest_clean],@col[:digest_all]=(/(.+?)<~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)><([0-9a-f]{#{@@dl}}):([0-9a-f]{#{@@dl}})>/m).match(data).captures
@@ -555,11 +554,11 @@ module SiSU_DB_import
@col[:en_a]=@col[:en_z]=nil
@col[:lev]=@col[:plaintext]=@col[:body]=''
end
- if notedata =~ /~\{.+?\}~/ #% import into database endnotes tables
+ if notedata =~ /~\{.+?\}~/ #% import into database endnotes tables
endnote_array=notedata.scan(/~\{.+?\}~/)
endnote_array.each do |inf|
- if inf[/~\{\d+.+?<[0-9a-f]{#{@@dl}}>\}~/] # dal new endnotes 2003w31/1
- if inf[/~\{(\d+)(.+?)<([0-9a-f]{#{@@dl}})>\}~/] # dal new endnotes 2003w31/1
+ if inf[/~\{\d+.+?<[0-9a-f]{#{@@dl}}>\}~/] # dal new endnotes 2003w31/1
+ if inf[/~\{(\d+)(.+?)<([0-9a-f]{#{@@dl}})>\}~/] # dal new endnotes 2003w31/1
nr,txt,digest_clean=$1,$2,$3
end
@id_n+=1
@@ -576,17 +575,17 @@ module SiSU_DB_import
end
if txt
en={}
- en={ :type => 'endnotes',
- :id => @id_n,
- :lid => @col[:lid],
- :nr => nr,
- :txt => txt,
- :body => body,
- :ocn => @col[:ocn],
- :ocnd => @col[:ocnd],
- :ocns => @col[:ocns],
- :id_t => @@id_t,
- :hash => digest_clean
+ en={ :type => 'endnotes',
+ :id => @id_n,
+ :lid => @col[:lid],
+ :nr => nr,
+ :txt => txt,
+ :body => body,
+ :ocn => @col[:ocn],
+ :ocnd => @col[:ocnd],
+ :ocns => @col[:ocns],
+ :id_t => @@id_t,
+ :hash => digest_clean
}
t=SiSU_DB_tuple::Load_endnotes.new(@conn,en)
t.tuple
@@ -595,11 +594,11 @@ module SiSU_DB_import
end
word_mode=notedata.scan(/\S+/)
end
- if notedata =~ /~\[\*.+?\]~/ #% import into database endnotes tables
+ if notedata =~ /~\[\*.+?\]~/ #% import into database endnotes tables
endnote_array=notedata.scan(/~\[\*.+?\]~/)
endnote_array.each do |inf|
- if inf[/~\[\*\d+.+?<[0-9a-f]{#{@@dl}}>\]~/] # dal new endnotes 2003w31/1
- if inf[/~\[[*](\d+)(.+?)<([0-9a-f]{#{@@dl}})>\]~/] # dal new endnotes 2003w31/1
+ if inf[/~\[\*\d+.+?<[0-9a-f]{#{@@dl}}>\]~/] # dal new endnotes 2003w31/1
+ if inf[/~\[[*](\d+)(.+?)<([0-9a-f]{#{@@dl}})>\]~/] # dal new endnotes 2003w31/1
nr,txt,digest_clean=$1,$2,$3
end
@id_n+=1
@@ -624,10 +623,10 @@ module SiSU_DB_import
:txt => txt,
:body => body,
:ocn => @col[:ocn],
- :ocnd => @col[:ocnd],
- :ocns => @col[:ocns],
- :id_t => @@id_t,
- :hash => digest_clean
+ :ocnd => @col[:ocnd],
+ :ocns => @col[:ocns],
+ :id_t => @@id_t,
+ :hash => digest_clean
}
t=SiSU_DB_tuple::Load_endnotes.new(@conn,en)
t.tuple
@@ -639,8 +638,8 @@ module SiSU_DB_import
if notedata =~ /~\[\+.+?\]~/ #% import into database endnotes tables
endnote_array=notedata.scan(/~\[\+.+?\]~/)
endnote_array.each do |inf|
- if inf[/~\[\+\d+.+?<[0-9a-f]{#{@@dl}}>\]~/] # dal new endnotes 2003w31/1
- if inf[/~\[[+](\d+)(.+?)<([0-9a-f]{#{@@dl}})>\]~/] # dal new endnotes 2003w31/1
+ if inf[/~\[\+\d+.+?<[0-9a-f]{#{@@dl}}>\]~/] # dal new endnotes 2003w31/1
+ if inf[/~\[[+](\d+)(.+?)<([0-9a-f]{#{@@dl}})>\]~/] # dal new endnotes 2003w31/1
nr,txt,digest_clean=$1,$2,$3
end
@id_n+=1
@@ -657,17 +656,17 @@ module SiSU_DB_import
end
if txt
en={}
- en={ :type => 'endnotes_plus',
- :id => @id_n,
- :lid => @col[:lid],
- :nr => nr,
- :txt => txt,
- :body => body,
- :ocn => @col[:ocn],
- :ocnd => @col[:ocnd],
- :ocns => @col[:ocns],
- :id_t => @@id_t,
- :hash => digest_clean
+ en={ :type => 'endnotes_plus',
+ :id => @id_n,
+ :lid => @col[:lid],
+ :nr => nr,
+ :txt => txt,
+ :body => body,
+ :ocn => @col[:ocn],
+ :ocnd => @col[:ocnd],
+ :ocns => @col[:ocns],
+ :id_t => @@id_t,
+ :hash => digest_clean
}
t=SiSU_DB_tuple::Load_endnotes.new(@conn,en)
t.tuple