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