diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/develop/ao_composite.rb | 8 | ||||
-rw-r--r-- | lib/sisu/develop/hub_actions.rb | 2 | ||||
-rw-r--r-- | lib/sisu/develop/src_shared.rb | 72 | ||||
-rw-r--r-- | lib/sisu/develop/utils_composite.rb | 115 |
4 files changed, 151 insertions, 46 deletions
diff --git a/lib/sisu/develop/ao_composite.rb b/lib/sisu/develop/ao_composite.rb index d6a4867b..a60593d9 100644 --- a/lib/sisu/develop/ao_composite.rb +++ b/lib/sisu/develop/ao_composite.rb @@ -57,6 +57,7 @@ =end module SiSU_Assemble require_relative 'se' # se.rb + require_relative 'utils_composite' # utils_composite.rb class RemoteImage def initialize @env=SiSU_Env::InfoEnv.new @@ -86,6 +87,7 @@ module SiSU_Assemble end end class Composite + include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test def initialize(opt) @opt=opt @env=SiSU_Env::InfoEnv.new @@ -100,14 +102,14 @@ module SiSU_Assemble 'Composite Document', "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}", ).grey_title_hi unless @opt.act[:quiet][:set]==:on + composite_and_imported_filenames_array(@opt.fno) # composite doc, .ssm, extract all related insert files, array of filenames test assembled=loadfile(@opt.fno) - #assembled=insertions?(fns_array) - write(assembled) write(assembled) end Dir.chdir(pwd) rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do + SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns). + location do __LINE__.to_s + ':' + __FILE__ end ensure diff --git a/lib/sisu/develop/hub_actions.rb b/lib/sisu/develop/hub_actions.rb index 36a06000..68f0aef9 100644 --- a/lib/sisu/develop/hub_actions.rb +++ b/lib/sisu/develop/hub_actions.rb @@ -56,6 +56,8 @@ =end module SiSU_Hub_Actions class HubActions + require_relative 'utils_composite' # utils_composite.rb + include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test def initialize(opt) @opt=opt end diff --git a/lib/sisu/develop/src_shared.rb b/lib/sisu/develop/src_shared.rb index ebd4f9d9..948342c7 100644 --- a/lib/sisu/develop/src_shared.rb +++ b/lib/sisu/develop/src_shared.rb @@ -59,6 +59,8 @@ module SiSU_Source class SiSUpodSource require_relative 'se' # se.rb require_relative 'se_hub_particulars' # se_hub_particulars.rb + require_relative 'utils_composite' # utils_composite.rb + include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test def initialize(opt,build=nil,place=nil) @opt=opt @date=SiSU_Env::InfoDate.new.dt @@ -74,7 +76,6 @@ 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, @@ -102,8 +103,7 @@ module SiSU_Source end unless @opt.fns.empty? directories - 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=composite_and_imported_filenames_array(@opt.fno) doc_import_list=[@opt.fno, doc_import_list].flatten image_extraction(doc_import_list) language_versions @@ -165,7 +165,10 @@ module SiSU_Source images=images.uniq images.each do |i| if FileTest.file?("#{images_pwd}/#{i}") - FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}") + FileUtils::cp( + "#{images_pwd}/#{i}", + "#{@path_pod[:image]}/#{i}" + ) else STDERR.puts \ %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} @@ -180,7 +183,10 @@ module SiSU_Source and @opt.fno =~/\.ssm$/ 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}") + 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__}]} @@ -194,14 +200,17 @@ module SiSU_Source if x[:f] \ and x[:f].length > 0 #store multiple document language versions, sisupod x[:f].each do |f| - FileUtils::mkdir_p(@path_pod[:doc]) unless FileTest.directory?(@path_pod[:doc]) + FileUtils::mkdir_p(@path_pod[:doc]) \ + unless FileTest.directory?(@path_pod[:doc]) if f[:f] =~/\~(\S{2,3})\.ss[tm]$/ lng_f=$1 if @opt.lng == lng_f if @opt.fno =~/\.ssm$/ 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]}") + 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__}]} @@ -218,8 +227,10 @@ module SiSU_Source else :no end if cpy == :yes - FileUtils::cp("#{@opt.base_path}/#{f[:f]}", - "#{@path_pod[:doc]}/#{f[:n]}") + FileUtils::cp( + "#{@opt.base_path}/#{f[:f]}", + "#{@path_pod[:doc]}/#{f[:n]}" + ) end else STDERR.puts \ @@ -230,8 +241,10 @@ module SiSU_Source else if @opt.fno =~/\.ssm$/ 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]}") + 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__}]} @@ -248,8 +261,10 @@ module SiSU_Source else :no end if cpy == :yes - FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", - "#{@path_pod[:doc]}/#{f[:n]}") + FileUtils::cp( + "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", + "#{@path_pod[:doc]}/#{f[:n]}" + ) end else STDERR.puts \ @@ -263,35 +278,6 @@ module SiSU_Source def directories SiSU_Env::InfoEnv.new.sisupod_v4(@opt) end - def ssm_doc_import_list(f) - if @opt.fno =~/\.ss[mi]$/ - doc_import_list=[] - if f =~@rgx_doc_import - doc_import_list << f.scan(@rgx_doc_import) - end - 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=/^<<\s*(\S+?\.ss[ti])/ - doc_import_list=[] - file_array.each do |f| #% work area - if f !~/^%+\s/ - if @opt.fno =~/\.ss[mi]$/ - @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/develop/utils_composite.rb b/lib/sisu/develop/utils_composite.rb new file mode 100644 index 00000000..ee8fe77c --- /dev/null +++ b/lib/sisu/develop/utils_composite.rb @@ -0,0 +1,115 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, debug related + +** Author: Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 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.sisudoc.org/sisu/en/manifest/gpl.fsf.html> + +** 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> + +** Git + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/develop/utils_composite.rb;hb=HEAD> + +=end +module SiSU_Composite_Doc_Utils + def inserts_array(loadfilename) + IO.readlines(loadfilename,'') + end + def insert_filename?(para) + if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest + url($1.strip) + elsif para =~/^<<\s*(\S+?\.ss[it])$/ + $1.strip + end + end + def extract_filenames(loadfilename,file_names_arr) + file_names_arr << loadfilename + ssi_files=[] + if loadfilename =~/\S+?\.ss[im]$/ + inserts_array(loadfilename).each do |para| + filen=insert_filename?(para) + file_names_arr << filen + if filen =~/\S+?\.ssi$/ + ssi_files << filen + end + end + end + ssi_files.each do |fn| + extract_filenames(fn,file_names_arr) + end + file_names_arr.flatten.compact.uniq.sort + end + def composite_and_imported_filenames_array(loadfilename) + file_names_arr=[] + begin + if FileTest.file?(loadfilename) + if loadfilename =~/\S+?\.ss[itm]$/ + 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 + file_names_arr=extract_filenames(loadfilename,file_names_arr) + end + end + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + p file_names_arr ;p file_names_arr.length + end + file_names_arr + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end +end +__END__ |