From d1c4bb34715672c50a646b11007191ef91fcc287 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jul 2014 00:03:26 -0400 Subject: v5 v6: ao_numbering, auto name segment, extract "number" from heading, fix --- lib/sisu/v5/ao_numbering.rb | 4 ++-- lib/sisu/v6/ao_numbering.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index 278ea514..d213ca4d 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -326,7 +326,7 @@ module SiSU_AO_Numbering if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i prefix + leading_zeros_fixed_width_number(possible_seg_name) - elsif possible_seg_name =~/^[\d.,:-]+$/m + elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') @@ -369,7 +369,7 @@ module SiSU_AO_Numbering @md.set_heading_seg=true end if dob.name !~/^\S+/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name + and dob.obj =~/^\s*(?:\S+\s+)?([0-9][0-9.,:-]*)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name possible_seg_name=$1 possible_seg_name= auto_seg_name(possible_seg_name,heading_num_is,:extract) diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index ffafbf9c..ef85bbd6 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -326,7 +326,7 @@ module SiSU_AO_Numbering if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i prefix + leading_zeros_fixed_width_number(possible_seg_name) - elsif possible_seg_name =~/^[\d.,:-]+$/m + elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') @@ -369,7 +369,7 @@ module SiSU_AO_Numbering @md.set_heading_seg=true end if dob.name !~/^\S+/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name + and dob.obj =~/^\s*(?:\S+\s+)?([0-9][0-9.,:-]*)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name possible_seg_name=$1 possible_seg_name= auto_seg_name(possible_seg_name,heading_num_is,:extract) -- cgit v1.2.3 From 561b66275f186fcf8f3ed6e697e560f28354d38c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jul 2014 00:05:23 -0400 Subject: v5 v6: ao_numbering, check that all auto given number based seg names are unique --- lib/sisu/v5/ao_numbering.rb | 10 +++++++++- lib/sisu/v6/ao_numbering.rb | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index d213ca4d..dc6ec4dd 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -67,6 +67,7 @@ module SiSU_AO_Numbering def initialize(md,data) @md,@data=md,data @obj=@type=@ocn=@lv=@name=@index=@comment=nil + @chosen_seg_names=[] end def number_of_segments? if @@segments_count==0 @@ -323,7 +324,7 @@ module SiSU_AO_Numbering possible_seg_name=possible_seg_name. gsub(/\.$/,'') end - if possible_seg_name =~/^[0-9]+$/m \ + chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i prefix + leading_zeros_fixed_width_number(possible_seg_name) elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m @@ -333,6 +334,13 @@ module SiSU_AO_Numbering prefix + possible_seg_name else prefix + possible_seg_name.to_s end + @chosen_seg_names << chosen_seg_name + if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{chosen_seg_name}; manually name level 1 segments '1~given_name'") + exit + end end def name_para_seg_filename(data) #segment naming, remaining # paragraph name/numbering rules diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index ef85bbd6..5b2137e7 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -67,6 +67,7 @@ module SiSU_AO_Numbering def initialize(md,data) @md,@data=md,data @obj=@type=@ocn=@lv=@name=@index=@comment=nil + @chosen_seg_names=[] end def number_of_segments? if @@segments_count==0 @@ -323,7 +324,7 @@ module SiSU_AO_Numbering possible_seg_name=possible_seg_name. gsub(/\.$/,'') end - if possible_seg_name =~/^[0-9]+$/m \ + chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \ and possible_seg_name.to_i <= heading_num_is.to_i prefix + leading_zeros_fixed_width_number(possible_seg_name) elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m @@ -333,6 +334,13 @@ module SiSU_AO_Numbering prefix + possible_seg_name else prefix + possible_seg_name.to_s end + @chosen_seg_names << chosen_seg_name + if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{chosen_seg_name}; manually name level 1 segments '1~given_name'") + exit + end end def name_para_seg_filename(data) #segment naming, remaining # paragraph name/numbering rules -- cgit v1.2.3 From cc3380a5050a839e4be9b5b12277cd83ce738d02 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jul 2014 00:07:04 -0400 Subject: v5 v6: ao_composite, variable name --- lib/sisu/v5/ao_composite.rb | 38 +++++++++++++++++++------------------- lib/sisu/v6/ao_composite.rb | 38 +++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 38 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_composite.rb b/lib/sisu/v5/ao_composite.rb index a7d0e48c..b35b2419 100644 --- a/lib/sisu/v5/ao_composite.rb +++ b/lib/sisu/v5/ao_composite.rb @@ -174,19 +174,19 @@ module SiSU_Assemble ).grey_title_hi unless @opt.act[:quiet][:set]==:on fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfile=$1.strip + loadfilename=$1.strip if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'loading:', - loadfile, + loadfilename, ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest + tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. - match(loadfile).captures.join + + match(loadfilename).captures.join + '/_sisu/image' #watch begin require 'uri' @@ -197,20 +197,20 @@ module SiSU_Assemble error('uri, open-uri or pp NOT FOUND (LoadError)') end image_uri=URI.parse(imagedir) - insert=open(loadfile) + insert=open(loadfilename) insert_array=insert.dup insert.close - file=insertion(loadfile,insert_array) + file=insertion(loadfilename,insert_array) @@imager[image_uri] ||=[] @@imager[image_uri] << file[:images] file[:prepared] - elsif loadfile =~ /\.ss[it]$/ \ - and FileTest.file?(loadfile) - insert_array=IO.readlines(loadfile,'') - file=insertion(loadfile,insert_array) + elsif loadfilename =~ /\.ss[it]$/ \ + and FileTest.file?(loadfilename) + insert_array=IO.readlines(loadfilename,'') + file=insertion(loadfilename,insert_array) file[:prepared] else - STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"} + STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} $process_document = :skip; break #remove this line to continue processing documents that have missing include files para end @@ -256,23 +256,23 @@ module SiSU_Assemble @ssm=[@opt.fns] fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfile=$1.strip + loadfilename=$1.strip if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'loading:', - loadfile, + loadfilename, ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ - @ssm << loadfile - elsif loadfile =~ /\.ss[it]$/ \ - and FileTest.file?(loadfile) - @ssm << loadfile + tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ + @ssm << loadfilename + elsif loadfilename =~ /\.ss[it]$/ \ + and FileTest.file?(loadfilename) + @ssm << loadfilename else - STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"} + STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} $process_document = :skip; break #remove this line to continue processing documents that have missing include files para end diff --git a/lib/sisu/v6/ao_composite.rb b/lib/sisu/v6/ao_composite.rb index 2f864228..efe3815f 100644 --- a/lib/sisu/v6/ao_composite.rb +++ b/lib/sisu/v6/ao_composite.rb @@ -174,19 +174,19 @@ module SiSU_Assemble ).grey_title_hi unless @opt.act[:quiet][:set]==:on fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfile=$1.strip + loadfilename=$1.strip if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'loading:', - loadfile, + loadfilename, ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest + tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. - match(loadfile).captures.join + + match(loadfilename).captures.join + '/_sisu/image' #watch begin require 'uri' @@ -197,20 +197,20 @@ module SiSU_Assemble error('uri, open-uri or pp NOT FOUND (LoadError)') end image_uri=URI.parse(imagedir) - insert=open(loadfile) + insert=open(loadfilename) insert_array=insert.dup insert.close - file=insertion(loadfile,insert_array) + file=insertion(loadfilename,insert_array) @@imager[image_uri] ||=[] @@imager[image_uri] << file[:images] file[:prepared] - elsif loadfile =~ /\.ss[it]$/ \ - and FileTest.file?(loadfile) - insert_array=IO.readlines(loadfile,'') - file=insertion(loadfile,insert_array) + elsif loadfilename =~ /\.ss[it]$/ \ + and FileTest.file?(loadfilename) + insert_array=IO.readlines(loadfilename,'') + file=insertion(loadfilename,insert_array) file[:prepared] else - STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"} + STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} $process_document = :skip; break #remove this line to continue processing documents that have missing include files para end @@ -256,23 +256,23 @@ module SiSU_Assemble @ssm=[@opt.fns] fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfile=$1.strip + loadfilename=$1.strip if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'loading:', - loadfile, + loadfilename, ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ - @ssm << loadfile - elsif loadfile =~ /\.ss[it]$/ \ - and FileTest.file?(loadfile) - @ssm << loadfile + tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ + @ssm << loadfilename + elsif loadfilename =~ /\.ss[it]$/ \ + and FileTest.file?(loadfilename) + @ssm << loadfilename else - STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"} + STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} $process_document = :skip; break #remove this line to continue processing documents that have missing include files para end -- cgit v1.2.3 From 86ce218124eeca073621a153c5f3f830a90f1a74 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jul 2014 00:09:02 -0400 Subject: v5 v6: ao_composite, nested includes, .ssi (insert) can now include .ssi & .sst * .ssm can contain/include .sst or .ssi .sst files can be processed independently, they do not contain other files .ssi files have been only insertions of text & are not processed independently but as part of an ssm change proposed: .ssm unchanged, .sst unchanged, .ssi as before, but can include .sst or .ssi, so: files are only insertions & are not processed independently but as part of an .ssm or another .ssi i.e. as before with the addition that it like a .ssm can contain/include .sst or .ssi * requested feature, (Closes: #744408) User beware. In previous versions there has been a deliberate attempt to keep it easy to follow documents & not have to dig through different levels of includes, as this is more likely to lead to errors in markup. The idea of nested includes has not been attractive (messy for a document), however, this is now made possible, use with care * it is not as easy to see document structure at a glance, and structural errors may be introduced and will need to be taken care of (requiring document markup debugging) * allowing .ssi to also include other .ssi or .sst could lead to infinite recursion if an .ssi includes another which includes itself; stopping after an additional level of includes seems arbitrary, and possibly prone to error if you are dealing with many documents * requires testing * version bump, new behavior added to .ssi one of the 3 sisu filetypes --- lib/sisu/v5/ao_composite.rb | 143 ++++++++++++++++++++++++-------------------- lib/sisu/v6/ao_composite.rb | 143 ++++++++++++++++++++++++-------------------- 2 files changed, 156 insertions(+), 130 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_composite.rb b/lib/sisu/v5/ao_composite.rb index b35b2419..5cdfaa81 100644 --- a/lib/sisu/v5/ao_composite.rb +++ b/lib/sisu/v5/ao_composite.rb @@ -101,9 +101,17 @@ module SiSU_Assemble begin pwd=Dir.pwd Dir.chdir(@opt.f_pth[:pth]) - fns_array=IO.readlines(@opt.fno,'') - assembled=insertions?(fns_array) - write(assembled) + if @opt.fno =~/\S+?\.ssm$/ + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Composite Document', + "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}", + ).grey_title_hi unless @opt.act[:quiet][:set]==:on + assembled=loadfile(@opt.fno) + #assembled=insertions?(fns_array) + write(assembled) + write(assembled) + end Dir.chdir(pwd) rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do @@ -112,6 +120,73 @@ module SiSU_Assemble ensure end end + def insert?(para) + if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest + url($1.strip) + elsif para =~/^<<\s+(\S+?\.ss[it])$/ + loadfilename=$1.strip + insert_array=loadfile(loadfilename) + file=insertion(loadfilename,insert_array) + file[:prepared] + else para + end + end + def loadfile(loadfilename) + tuned_file=[] + begin + if FileTest.file?(loadfilename) + insert_array=IO.readlines(loadfilename,'') + if loadfilename =~/\S+?\.ss[im]$/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfilename, + ).txt_grey + end + insert_array.each do |para| + tuned_file << insert?(para) + end + elsif loadfilename =~/\S+?\.sst$/ + insert_array.each do |para| + tuned_file << para + end + end + end + tuned_file=tuned_file.flatten.compact + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def url(loadfilename) + if loadfilename =~ /((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest + loadfilename=$1 + imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. + match(loadfilename).captures.join + + '/_sisu/image' #watch + begin + require 'uri' + require 'open-uri' + require 'pp' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri, open-uri or pp NOT FOUND (LoadError)') + end + image_uri=URI.parse(imagedir) + insert=open(loadfilename) + insert_array=insert.dup + insert.close + file=insertion(loadfilename,insert_array) + @@imager[image_uri] ||=[] + @@imager[image_uri] << file[:images] + file[:prepared] + end + end def write(assembled) assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') assembled.each {|a| assembled_file << a } @@ -165,68 +240,6 @@ module SiSU_Assemble end file end - def insertions?(fns_array) - tuned_file,imagedir=[],[] - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Composite Document', - "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}", - ).grey_title_hi unless @opt.act[:quiet][:set]==:on - fns_array.each do |para| - if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfilename=$1.strip - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'loading:', - loadfilename, - ).txt_grey - end - tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest - imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. - match(loadfilename).captures.join + - '/_sisu/image' #watch - begin - require 'uri' - require 'open-uri' - require 'pp' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('uri, open-uri or pp NOT FOUND (LoadError)') - end - image_uri=URI.parse(imagedir) - insert=open(loadfilename) - insert_array=insert.dup - insert.close - file=insertion(loadfilename,insert_array) - @@imager[image_uri] ||=[] - @@imager[image_uri] << file[:images] - file[:prepared] - elsif loadfilename =~ /\.ss[it]$/ \ - and FileTest.file?(loadfilename) - insert_array=IO.readlines(loadfilename,'') - file=insertion(loadfilename,insert_array) - file[:prepared] - else - STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} - $process_document = :skip; break #remove this line to continue processing documents that have missing include files - para - end - else tuned_file << para - end - tuned_file=tuned_file.flatten.compact - end - if @@imager.length >0 - @@imager.each do |d,i| - i=i.flatten.uniq - image_info=d + i - download_images(image_info.flatten) - end - end - tuned_file - end end class CompositeFileList @@imager={} diff --git a/lib/sisu/v6/ao_composite.rb b/lib/sisu/v6/ao_composite.rb index efe3815f..078e8ece 100644 --- a/lib/sisu/v6/ao_composite.rb +++ b/lib/sisu/v6/ao_composite.rb @@ -101,9 +101,17 @@ module SiSU_Assemble begin pwd=Dir.pwd Dir.chdir(@opt.f_pth[:pth]) - fns_array=IO.readlines(@opt.fno,'') - assembled=insertions?(fns_array) - write(assembled) + if @opt.fno =~/\S+?\.ssm$/ + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Composite Document', + "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}", + ).grey_title_hi unless @opt.act[:quiet][:set]==:on + assembled=loadfile(@opt.fno) + #assembled=insertions?(fns_array) + write(assembled) + write(assembled) + end Dir.chdir(pwd) rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do @@ -112,6 +120,73 @@ module SiSU_Assemble ensure end end + def insert?(para) + if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest + url($1.strip) + elsif para =~/^<<\s+(\S+?\.ss[it])$/ + loadfilename=$1.strip + insert_array=loadfile(loadfilename) + file=insertion(loadfilename,insert_array) + file[:prepared] + else para + end + end + def loadfile(loadfilename) + tuned_file=[] + begin + if FileTest.file?(loadfilename) + insert_array=IO.readlines(loadfilename,'') + if loadfilename =~/\S+?\.ss[im]$/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfilename, + ).txt_grey + end + insert_array.each do |para| + tuned_file << insert?(para) + end + elsif loadfilename =~/\S+?\.sst$/ + insert_array.each do |para| + tuned_file << para + end + end + end + tuned_file=tuned_file.flatten.compact + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def url(loadfilename) + if loadfilename =~ /((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest + loadfilename=$1 + imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. + match(loadfilename).captures.join + + '/_sisu/image' #watch + begin + require 'uri' + require 'open-uri' + require 'pp' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri, open-uri or pp NOT FOUND (LoadError)') + end + image_uri=URI.parse(imagedir) + insert=open(loadfilename) + insert_array=insert.dup + insert.close + file=insertion(loadfilename,insert_array) + @@imager[image_uri] ||=[] + @@imager[image_uri] << file[:images] + file[:prepared] + end + end def write(assembled) assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') assembled.each {|a| assembled_file << a } @@ -165,68 +240,6 @@ module SiSU_Assemble end file end - def insertions?(fns_array) - tuned_file,imagedir=[],[] - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Composite Document', - "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}", - ).grey_title_hi unless @opt.act[:quiet][:set]==:on - fns_array.each do |para| - if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfilename=$1.strip - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'loading:', - loadfilename, - ).txt_grey - end - tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest - imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. - match(loadfilename).captures.join + - '/_sisu/image' #watch - begin - require 'uri' - require 'open-uri' - require 'pp' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('uri, open-uri or pp NOT FOUND (LoadError)') - end - image_uri=URI.parse(imagedir) - insert=open(loadfilename) - insert_array=insert.dup - insert.close - file=insertion(loadfilename,insert_array) - @@imager[image_uri] ||=[] - @@imager[image_uri] << file[:images] - file[:prepared] - elsif loadfilename =~ /\.ss[it]$/ \ - and FileTest.file?(loadfilename) - insert_array=IO.readlines(loadfilename,'') - file=insertion(loadfilename,insert_array) - file[:prepared] - else - STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} - $process_document = :skip; break #remove this line to continue processing documents that have missing include files - para - end - else tuned_file << para - end - tuned_file=tuned_file.flatten.compact - end - if @@imager.length >0 - @@imager.each do |d,i| - i=i.flatten.uniq - image_info=d + i - download_images(image_info.flatten) - end - end - tuned_file - end end class CompositeFileList @@imager={} -- cgit v1.2.3 From 3daec543362c334a4c6f4de33fc226401692a37e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jul 2014 00:12:48 -0400 Subject: v5 v6: src sisupod, cosmetic code arrangement --- lib/sisu/v5/src_shared.rb | 57 +++++++++++++++++++++++++++-------------- lib/sisu/v5/src_sisupod_make.rb | 15 ++++++++--- lib/sisu/v6/src_shared.rb | 57 +++++++++++++++++++++++++++-------------- lib/sisu/v6/src_sisupod_make.rb | 15 ++++++++--- 4 files changed, 100 insertions(+), 44 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/src_shared.rb b/lib/sisu/v5/src_shared.rb index 5338a18c..bbeebdc1 100644 --- a/lib/sisu/v5/src_shared.rb +++ b/lib/sisu/v5/src_shared.rb @@ -85,7 +85,7 @@ module SiSU_Source fnb: path_pod_fnb, pod: path_pod, doc: path_pod + '/' + Gt[:doc] + '/' + opt.lng, - po: path_pod + '/' + Gt[:po] + '/' + opt.lng, + po: path_pod + '/' + Gt[:po] + '/' + opt.lng, pot: path_pod + '/' + Gt[:pot], conf: path_pod + '/' + Gt[:conf], image: path_pod + '/' + Gt[:image], @@ -98,7 +98,11 @@ module SiSU_Source (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble SiSU source',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Assemble SiSU source', + "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"). + green_hi_blue : '' end unless @opt.fns.empty? @@ -123,25 +127,25 @@ module SiSU_Source @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/ file_array=IO.readlines(@opt.fno,'') - images,doc_import=[],[] + images,doc_import_list=[],[] doc_import_dir=@opt.sub_location file_array.each do |f| #% work area if f !~/^%+\s/ - f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) end if @opt.fno =~/\.ssm$/ - doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import + doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import end end end - if doc_import.length > 0 - doc_import=doc_import.uniq.flatten - doc_import.each do |fn| + if doc_import_list.length > 0 + doc_import_list=doc_import_list.uniq.flatten + doc_import_list.each do |fn| file_array=IO.readlines(fn,'') - file_array.each do |f| #% work area + file_array.each do |f| #% work area if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) @@ -153,7 +157,8 @@ module SiSU_Source unless FileTest.file?("#{@path_pod[:conf]}/#{gi.makefile_name}") if gi.makefile \ && FileTest.file?(gi.makefile) - FileUtils::mkdir_p(@path_pod[:conf]) unless FileTest.directory?(@path_pod[:conf]) + FileUtils::mkdir_p(@path_pod[:conf]) \ + unless FileTest.directory?(@path_pod[:conf]) FileUtils::cp(gi.makefile,"#{@path_pod[:conf]}/#{gi.makefile_name}") end #get images from makefile, consider placing in param @@ -181,18 +186,24 @@ module SiSU_Source images.each do |i| if FileTest.file?("#{images_pwd}/#{i}") FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}") - else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} end end - else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]} end end - if doc_import.length > 0 \ + if doc_import_list.length > 0 \ and @opt.fno =~/\.ssm$/ - doc_import.each do |f| + doc_import_list.each do |f| if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f}") FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}") - else STDERR.puts %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} end end end @@ -208,7 +219,9 @@ module SiSU_Source if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}") FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end else if FileTest.file?("#{@opt.base_path}/#{f[:f]}") @@ -225,7 +238,9 @@ module SiSU_Source FileUtils::cp("#{@opt.base_path}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") end - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end end end @@ -234,7 +249,9 @@ module SiSU_Source if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}") FileUtils::cp_r("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end else if FileTest.file?("#{@opt.base_path}/#{f[:f]}") @@ -251,7 +268,9 @@ module SiSU_Source FileUtils::cp("#{@opt.base_path}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") end - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end end end diff --git a/lib/sisu/v5/src_sisupod_make.rb b/lib/sisu/v5/src_sisupod_make.rb index 5ae7313f..4e9c83ba 100644 --- a/lib/sisu/v5/src_sisupod_make.rb +++ b/lib/sisu/v5/src_sisupod_make.rb @@ -75,13 +75,22 @@ module SiSU_Doc (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',"#{@opt.fns} -> file://#{pthinfo}").cyan_hi_blue - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',pthinfo).cyan_title_hi + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Assemble source for sisu document', + "#{@opt.fns} -> file://#{pthinfo}"). + cyan_hi_blue + : SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Assemble source for sisu document', + pthinfo). + cyan_title_hi end end def sisupod_tar_xz begin - FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir) + FileUtils::mkdir_p(@file.output_path.sisupod.dir) \ + unless FileTest.directory?(@file.output_path.sisupod.dir) tree=((@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ diff --git a/lib/sisu/v6/src_shared.rb b/lib/sisu/v6/src_shared.rb index 4ce34473..ec021974 100644 --- a/lib/sisu/v6/src_shared.rb +++ b/lib/sisu/v6/src_shared.rb @@ -85,7 +85,7 @@ module SiSU_Source fnb: path_pod_fnb, pod: path_pod, doc: path_pod + '/' + Gt[:doc] + '/' + opt.lng, - po: path_pod + '/' + Gt[:po] + '/' + opt.lng, + po: path_pod + '/' + Gt[:po] + '/' + opt.lng, pot: path_pod + '/' + Gt[:pot], conf: path_pod + '/' + Gt[:conf], image: path_pod + '/' + Gt[:image], @@ -98,7 +98,11 @@ module SiSU_Source (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble SiSU source',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Assemble SiSU source', + "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"). + green_hi_blue : '' end unless @opt.fns.empty? @@ -123,25 +127,25 @@ module SiSU_Source @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/ file_array=IO.readlines(@opt.fno,'') - images,doc_import=[],[] + images,doc_import_list=[],[] doc_import_dir=@opt.sub_location file_array.each do |f| #% work area if f !~/^%+\s/ - f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) end if @opt.fno =~/\.ssm$/ - doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import + doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import end end end - if doc_import.length > 0 - doc_import=doc_import.uniq.flatten - doc_import.each do |fn| + if doc_import_list.length > 0 + doc_import_list=doc_import_list.uniq.flatten + doc_import_list.each do |fn| file_array=IO.readlines(fn,'') - file_array.each do |f| #% work area + file_array.each do |f| #% work area if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) @@ -153,7 +157,8 @@ module SiSU_Source unless FileTest.file?("#{@path_pod[:conf]}/#{gi.makefile_name}") if gi.makefile \ && FileTest.file?(gi.makefile) - FileUtils::mkdir_p(@path_pod[:conf]) unless FileTest.directory?(@path_pod[:conf]) + FileUtils::mkdir_p(@path_pod[:conf]) \ + unless FileTest.directory?(@path_pod[:conf]) FileUtils::cp(gi.makefile,"#{@path_pod[:conf]}/#{gi.makefile_name}") end #get images from makefile, consider placing in param @@ -181,18 +186,24 @@ module SiSU_Source images.each do |i| if FileTest.file?("#{images_pwd}/#{i}") FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}") - else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} end end - else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]} end end - if doc_import.length > 0 \ + if doc_import_list.length > 0 \ and @opt.fno =~/\.ssm$/ - doc_import.each do |f| + doc_import_list.each do |f| if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f}") FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}") - else STDERR.puts %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} end end end @@ -208,7 +219,9 @@ module SiSU_Source if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}") FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end else if FileTest.file?("#{@opt.base_path}/#{f[:f]}") @@ -225,7 +238,9 @@ module SiSU_Source FileUtils::cp("#{@opt.base_path}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") end - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end end end @@ -234,7 +249,9 @@ module SiSU_Source if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}") FileUtils::cp_r("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end else if FileTest.file?("#{@opt.base_path}/#{f[:f]}") @@ -251,7 +268,9 @@ module SiSU_Source FileUtils::cp("#{@opt.base_path}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") end - else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else + STDERR.puts \ + %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end end end diff --git a/lib/sisu/v6/src_sisupod_make.rb b/lib/sisu/v6/src_sisupod_make.rb index ad58453d..ccac91f8 100644 --- a/lib/sisu/v6/src_sisupod_make.rb +++ b/lib/sisu/v6/src_sisupod_make.rb @@ -75,13 +75,22 @@ module SiSU_Doc (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',"#{@opt.fns} -> file://#{pthinfo}").cyan_hi_blue - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',pthinfo).cyan_title_hi + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Assemble source for sisu document', + "#{@opt.fns} -> file://#{pthinfo}"). + cyan_hi_blue + : SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Assemble source for sisu document', + pthinfo). + cyan_title_hi end end def sisupod_tar_xz begin - FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir) + FileUtils::mkdir_p(@file.output_path.sisupod.dir) \ + unless FileTest.directory?(@file.output_path.sisupod.dir) tree=((@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ -- cgit v1.2.3 From a93f8d5da9c2104ebd370ddfcc51021b5a858920 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jul 2014 00:14:36 -0400 Subject: v5 v6: src, sisupod composite source, nested includes --- lib/sisu/v5/src_shared.rb | 63 +++++++++++++++++++++++++++++++---------------- lib/sisu/v6/src_shared.rb | 63 +++++++++++++++++++++++++++++++---------------- 2 files changed, 84 insertions(+), 42 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/src_shared.rb b/lib/sisu/v5/src_shared.rb index bbeebdc1..a4b3a974 100644 --- a/lib/sisu/v5/src_shared.rb +++ b/lib/sisu/v5/src_shared.rb @@ -80,6 +80,7 @@ module SiSU_Source processing_sisupod.make path_pod=processing_sisupod.paths[:sisupod] path_pod_fnb=processing_sisupod.paths[:fnb] + @doc_import_list=[] FileUtils::mkdir_p(path_pod) unless FileTest.directory?(path_pod) @path_pod={ fnb: path_pod_fnb, @@ -107,12 +108,13 @@ module SiSU_Source end unless @opt.fns.empty? directories - pod_source_build #this needs to be built in case of multi-lingual for all of them, before single pass tar + file_array=IO.readlines(@opt.fno,'') + doc_import_list=pod_source_build(file_array) #this needs to be built in case of multi-lingual for all of them, before single pass tar + doc_import_list=[@opt.fno, doc_import_list].flatten + image_extraction(doc_import_list) + language_versions end end - def directories - SiSU_Env::InfoEnv.new.sisupod_v4(@opt) - end def images_extract(f,images) # consider using param info rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m if f !~/^%+\s/ \ @@ -121,31 +123,17 @@ module SiSU_Source end images.flatten end - def pod_source_build - @pwd=Dir.pwd + def image_extraction(doc_import_list) @rgx_rb_image=/["']\S*?([a-zA-Z0-9_-]+?\.(?:png|jpg|gif))["']/ @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/ - file_array=IO.readlines(@opt.fno,'') - images,doc_import_list=[],[] doc_import_dir=@opt.sub_location - file_array.each do |f| #% work area - if f !~/^%+\s/ - f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) - if f !~/^%+\s/ \ - and f =~@rgx_image - images=images_extract(f,images) - end - if @opt.fno =~/\.ssm$/ - doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import - end - end - end + images=[] if doc_import_list.length > 0 doc_import_list=doc_import_list.uniq.flatten doc_import_list.each do |fn| file_array=IO.readlines(fn,'') file_array.each do |f| #% work area + f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) @@ -207,7 +195,10 @@ module SiSU_Source end end end + end + def language_versions x=@env.document_language_versions_found #check multiple document language versions (param not used) + doc_import_dir=@opt.sub_location if x[:f] \ and x[:f].length > 0 #store multiple document language versions, sisupod x[:f].each do |f| @@ -277,6 +268,36 @@ module SiSU_Source end end #NB not all possibilies met, revisit, also in case of composite file may wish to add README end + def directories + SiSU_Env::InfoEnv.new.sisupod_v4(@opt) + end + def ssm_doc_import_list(f) + if @opt.fno =~/\.ssm$/ + doc_import_list=[] + doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import + doc_import_list.flatten.each do |i| + if i =~/.ssi/ + file_array=IO.readlines(i,'') + pod_source_build(file_array) + end + end + end + doc_import_list.uniq.flatten + end + def pod_source_build(file_array) + @pwd=Dir.pwd + @rgx_doc_import_list=/^<<\s*(\S+?\.ss[ti])/ + doc_import_list=[] + file_array.each do |f| #% work area + if f !~/^%+\s/ + if @opt.fno =~/\.ssm$/ + @doc_import_list << ssm_doc_import_list(f) + doc_import_list=@doc_import_list.flatten.uniq + end + end + end + doc_import_list + end end end __END__ diff --git a/lib/sisu/v6/src_shared.rb b/lib/sisu/v6/src_shared.rb index ec021974..cee7e1c5 100644 --- a/lib/sisu/v6/src_shared.rb +++ b/lib/sisu/v6/src_shared.rb @@ -80,6 +80,7 @@ module SiSU_Source processing_sisupod.make path_pod=processing_sisupod.paths[:sisupod] path_pod_fnb=processing_sisupod.paths[:fnb] + @doc_import_list=[] FileUtils::mkdir_p(path_pod) unless FileTest.directory?(path_pod) @path_pod={ fnb: path_pod_fnb, @@ -107,12 +108,13 @@ module SiSU_Source end unless @opt.fns.empty? directories - pod_source_build #this needs to be built in case of multi-lingual for all of them, before single pass tar + file_array=IO.readlines(@opt.fno,'') + doc_import_list=pod_source_build(file_array) #this needs to be built in case of multi-lingual for all of them, before single pass tar + doc_import_list=[@opt.fno, doc_import_list].flatten + image_extraction(doc_import_list) + language_versions end end - def directories - SiSU_Env::InfoEnv.new.sisupod_v4(@opt) - end def images_extract(f,images) # consider using param info rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m if f !~/^%+\s/ \ @@ -121,31 +123,17 @@ module SiSU_Source end images.flatten end - def pod_source_build - @pwd=Dir.pwd + def image_extraction(doc_import_list) @rgx_rb_image=/["']\S*?([a-zA-Z0-9_-]+?\.(?:png|jpg|gif))["']/ @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/ - file_array=IO.readlines(@opt.fno,'') - images,doc_import_list=[],[] doc_import_dir=@opt.sub_location - file_array.each do |f| #% work area - if f !~/^%+\s/ - f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) - if f !~/^%+\s/ \ - and f =~@rgx_image - images=images_extract(f,images) - end - if @opt.fno =~/\.ssm$/ - doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import - end - end - end + images=[] if doc_import_list.length > 0 doc_import_list=doc_import_list.uniq.flatten doc_import_list.each do |fn| file_array=IO.readlines(fn,'') file_array.each do |f| #% work area + f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) @@ -207,7 +195,10 @@ module SiSU_Source end end end + end + def language_versions x=@env.document_language_versions_found #check multiple document language versions (param not used) + doc_import_dir=@opt.sub_location if x[:f] \ and x[:f].length > 0 #store multiple document language versions, sisupod x[:f].each do |f| @@ -277,6 +268,36 @@ module SiSU_Source end end #NB not all possibilies met, revisit, also in case of composite file may wish to add README end + def directories + SiSU_Env::InfoEnv.new.sisupod_v4(@opt) + end + def ssm_doc_import_list(f) + if @opt.fno =~/\.ssm$/ + doc_import_list=[] + doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import + doc_import_list.flatten.each do |i| + if i =~/.ssi/ + file_array=IO.readlines(i,'') + pod_source_build(file_array) + end + end + end + doc_import_list.uniq.flatten + end + def pod_source_build(file_array) + @pwd=Dir.pwd + @rgx_doc_import_list=/^<<\s*(\S+?\.ss[ti])/ + doc_import_list=[] + file_array.each do |f| #% work area + if f !~/^%+\s/ + if @opt.fno =~/\.ssm$/ + @doc_import_list << ssm_doc_import_list(f) + doc_import_list=@doc_import_list.flatten.uniq + end + end + end + doc_import_list + end end end __END__ -- cgit v1.2.3