From 64e5c9120ffb7a65b96eded0850f481e116f1d3f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 8 Aug 2014 00:16:16 -0400 Subject: v6: use opt.act, code internals (simplify, cleaner; remove opt.cmd & opt.mod) * v5 dp, indentation changed to retain easy comparison with v6 --- lib/sisu/v6/hub.rb | 962 +++++++++++++++++++++++++++-------------------------- 1 file changed, 497 insertions(+), 465 deletions(-) (limited to 'lib/sisu/v6/hub.rb') diff --git a/lib/sisu/v6/hub.rb b/lib/sisu/v6/hub.rb index 9ebb42d9..11ac947b 100644 --- a/lib/sisu/v6/hub.rb +++ b/lib/sisu/v6/hub.rb @@ -82,10 +82,12 @@ module SiSU def initialize(argv,call_path) begin #% select what to do (set options & start processing (files selected if any)) opt=SiSU_Commandline::Options.new(argv,call_path) # command line selection of what to do, files & operations set - SiSU::Processing.new(opt).actions # do it + SiSU::Processing.new(opt).version_info + SiSU::Processing.new(opt).actions_without_files # do it + SiSU::Processing.new(opt).actions_on_files # do it rescue - cmd=(opt ? opt.cmd : '') - SiSU_Screen::Ansi.new(cmd,$!,$@).rescue do + selection=(opt ? opt.selection : '') + SiSU_Screen::Ansi.new(selection,$!,$@).rescue do __LINE__.to_s + ':' + __FILE__ end ensure @@ -240,10 +242,10 @@ module SiSU SiSU_CGI::SearchSQL.new(@opt).read end def termsheet # -t - system("sisu_termsheet #{@opt.cmd} #{@opt.fns}\n") + system("sisu_termsheet #{@opt.selections.str} #{@opt.fns}\n") @@n_do=@@n_do+1 SiSU_Screen::Ansi.new( - @opt.cmd,@@n_do, + @opt.selections.str,@@n_do, 'Termsheet(s) processed' ).term_sheet_title unless @opt.act[:quiet][:set] ==:on end @@ -254,10 +256,10 @@ module SiSU SiSU_Webserv::WebrickStart.new end def not_found - puts "\n#{@cX.fuchsia}FILE NOT FOUND:#{@cX.off} << #{@opt.fns} >> - requested #{@opt.cmd} processing skipped\n" + puts "\n#{@cX.fuchsia}FILE NOT FOUND:#{@cX.off} << #{@opt.fns} >> - requested #{@opt.selections.str} processing skipped\n" end def convert_name_message(fns,type,i,o,rune) - %{\nIn filename: "#{@cX.fuchsia}#{fns}#{@cX.off}" << #{type} >> #{@cX.fuchsia}is apre 0.36 markup filename.#{@cX.off} #{@cX.brown}Please rename your file.#{@cX.off}\n\tAs of sisu-0.37, SiSU markup files with #{@cX.brown}the extensions #{i} should be re-named #{o}#{@cX.off}\n\tif you have the program called 'rename' installed, the following rune should do the trick:\n\t\t#{rune}\n\talternatively try:\n\t\tsisu --convert --36to37 #{fns}\n\trequested #{@opt.cmd} processing skipped\n} + %{\nIn filename: "#{@cX.fuchsia}#{fns}#{@cX.off}" << #{type} >> #{@cX.fuchsia}is apre 0.36 markup filename.#{@cX.off} #{@cX.brown}Please rename your file.#{@cX.off}\n\tAs of sisu-0.37, SiSU markup files with #{@cX.brown}the extensions #{i} should be re-named #{o}#{@cX.off}\n\tif you have the program called 'rename' installed, the following rune should do the trick:\n\t\t#{rune}\n\talternatively try:\n\t\tsisu --convert --36to37 #{fns}\n\trequested #{@opt.selections.str} processing skipped\n} end def not_recognised case @opt.fns @@ -269,11 +271,11 @@ module SiSU type=@opt.fns.gsub(/\S+?(#{$1})/,'\1') rune=%q{rename 's/\.r[123]$/\.ssm/' *.r{1,2,3}} puts convert_name_message(@opt.fns,type,'.r1 .r2 and .r3','.sst',rune) - puts %{\n\tNote also that you will need to change the names of the files called/required\n\twithin the document text to build the composite document\n\t\t.s1 .s2 .s3 should be .sst \n\t\t.si should be .ssi\n\trequested #{@opt.cmd} processing skipped\n} + puts %{\n\tNote also that you will need to change the names of the files called/required\n\twithin the document text to build the composite document\n\t\t.s1 .s2 .s3 should be .sst \n\t\t.si should be .ssi\n\trequested #{@opt.selections.str} processing skipped\n} when /(\.ssi)$/ - puts "\n#{@cX.fuchsia}component filetype:#{@cX.off} << #{@opt.fns} >> - is not a processed filetype, (it may be used as a component of a .ssm markup file)\n\trequested #{@opt.cmd} processing skipped\n" + puts "\n#{@cX.fuchsia}component filetype:#{@cX.off} << #{@opt.fns} >> - is not a processed filetype, (it may be used as a component of a .ssm markup file)\n\trequested #{@opt.selections.str} processing skipped\n" else - puts "\n#{@cX.fuchsia}FILETYPE NOT RECOGNISED:#{@cX.off} << #{@opt.fns} >> - is not a recognized filetype,\n\trequested #{@opt.cmd} processing skipped\n" + puts "\n#{@cX.fuchsia}FILETYPE NOT RECOGNISED:#{@cX.off} << #{@opt.fns} >> - is not a recognized filetype,\n\trequested #{@opt.selections.str} processing skipped\n" end end end @@ -292,7 +294,11 @@ module SiSU @@env=@env=SiSU_Env::InfoEnv.new @msg,@msgs='',nil @tell=lambda { - SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") + SiSU_Screen::Ansi.new( + @opt.selections.str, + @msg, + "#{@msgs.inspect if @msgs}" + ) } end def remove_skipped_files_if_any_from_processing_files_array @@ -307,309 +313,371 @@ module SiSU @remove_faulty_markup_files_array.join(',') end end - def do_loops - @remove_faulty_markup_files_array=[] - if @opt.act[:zap][:set]==:on #% --zap, -Z - do_loop_files_on_given_option_pre - end - do_each_file_loop_options - remove_skipped_files_if_any_from_processing_files_array - do_loop_files_on_given_option_post - print_error_message_if_files_skipped - end - def do_each_file_loop_options - @opt.files.each_with_index do |fno,i| - @opt.fno=fno - @opt.fns=fno. - gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst'). - gsub(/\.ssm$/,'.ssm.sst') - @opt.f_pth=@opt.f_pths[i] - if @opt.fns !~/\.-sst$/ - @opt.pth=@opt.f_pths[i][:pth] - @opt.lng=@opt.f_pths[i][:lng] - else - @opt.pth=Dir.pwd - @opt.lng='en' - end - unless @opt.pth.nil? - @@pwd=@opt.pth - Dir.chdir(@opt.pth) #watch - end - @env=SiSU_Env::InfoEnv.new(@opt.fns) - if @opt.act[:ao][:set]==:on #% --ao --dal, -m - $process_document = :ok - unless @opt.act[:po4a][:set]==:on # --po4a, -P - if @opt.fno =~ /\.ssm$/ - require_relative 'ao_composite' # ao_composite.rb #pre-processing - SiSU_Assemble::Composite.new(@opt).read + def prepare + def site? + if @opt.act[:site_init][:set]==:on #% --init-site, -C initialize/configure + require_relative 'conf' #% --init-site, -C initialize/configure + SiSU_Initialize::Source.new(@opt).read + if @opt.act[:rsync][:set]==:on + if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ + and @opt.selections.str =~/RZ/ + SiSU::Operations.new(@opt).remote_put_base_site_rsync_match + else SiSU::Operations.new(@opt).remote_put_base_site_rsync end - require_relative 'ao' # -m ao.rb - SiSU_AO::Source.new(@opt).read - end - end - if $process_document == :ok - if @opt.act[:qrcode][:set]==:on #% --qrcode, -Q - require_relative 'qrcode' # qrcode.rb - SiSU_QRcode::Source.new(@opt).read - end - if @opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree - require_relative 'digests' # digests.rb - SiSU_DigestView::Source.new(@opt).read - end - if @opt.act[:txt][:set]==:on #% --txt, -t -a - require_relative 'txt_plain' # txt_plain.rb - SiSU_Txt_Plain::Source.new(@opt).read - end - if @opt.act[:txt_textile][:set]==:on #% --textile - require_relative 'txt_textile' # txt_textile.rb - SiSU_Txt_Textile::Source.new(@opt).read - end - if @opt.act[:txt_asciidoc][:set]==:on #% --asciidoc - require_relative 'txt_asciidoc' # txt_asciidoc.rb - SiSU_Txt_AsciiDoc::Source.new(@opt).read - end - if @opt.act[:txt_markdown][:set]==:on #% --markdown - require_relative 'txt_markdown' # txt_markdown.rb - SiSU_Txt_Markdown::Source.new(@opt).read - end - if @opt.act[:txt_rst][:set]==:on #% --rst, --rest - require_relative 'txt_rst' # txt_rst.rb - SiSU_Txt_rST::Source.new(@opt).read - end - if @opt.act[:html][:set]==:on #% --html, -h -H - require_relative 'html' # html.rb - SiSU_HTML::Source.new(@opt).read - else - if @opt.act[:html_seg][:set]==:on #% --html-seg (-h -H) - require_relative 'html' # html.rb - SiSU_HTML::Source.new(@opt).read + elsif @opt.act[:scp][:set]==:on + if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ + and @opt.selections.str =~/CCr/ + SiSU::Operations.new(@opt).remote_put_base_site_all + else SiSU::Operations.new(@opt).remote_put_base_site end - if @opt.act[:html_scroll][:set]==:on #% --html-scroll (-h -H) - require_relative 'html' # html.rb - SiSU_HTML::Source.new(@opt).read - end - end - if @opt.act[:concordance][:set]==:on #% --concordance, -w - require_relative 'html_concordance' # html_concordance.rb - SiSU_Concordance::Source.new(@opt).read end - if @opt.act[:epub][:set]==:on #% --epub, -e - require_relative 'xhtml_epub2' # xhtml_epub2.rb - SiSU_XHTML_EPUB2::Source.new(@opt).read + end + end + def remote_site? + if @opt.act[:site_init][:set]==:on + if @opt.act[:site_init][:set]==:on #% --init-site, -C initialize/configure + #require_relative 'conf' #% --init-site, -C initialize/configure + #SiSU_Initialize::Source.new(@opt).read + #if @opt.act[:rsync][:set]==:on + # if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ + # and @opt.selection =~/RZ/ + # SiSU::Operations.new(@opt).remote_put_base_site_rsync_match + # else SiSU::Operations.new(@opt).remote_put_base_site_rsync + # end + #elsif @opt.act[:scp][:set]==:on + # if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ + # and @opt.selection =~/CCr/ + # SiSU::Operations.new(@opt).remote_put_base_site_all + # else SiSU::Operations.new(@opt).remote_put_base_site + # end + #end end - if @opt.act[:odt][:set]==:on #% --odt, -o opendocument - require_relative 'xml_odf_odt' # xml_odf_odt.rb - SiSU_XML_ODF_ODT::Source.new(@opt).read + end + end + def sql? + if @opt.act[:psql_createdb][:set]==:on \ + or @opt.act[:psql_create][:set]==:on \ + or @opt.act[:psql_drop][:set]==:on + done=:ok + if @opt.act[:psql][:set]==:on + require_relative 'dbi' + SiSU_DBI::SQL.new(@opt).connect end - if @opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml - require_relative 'xhtml' # xhtml.rb - SiSU_XHTML::Source.new(@opt).read + end + if @opt.act[:sqlite_createdb][:set]==:on \ + or @opt.act[:sqlite_create][:set]==:on \ + or @opt.act[:sqlite_drop][:set]==:on + done=:ok + if @opt.act[:sqlite][:set]==:on + require_relative 'dbi' + SiSU_DBI::SQL.new(@opt).connect end - if @opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu - require_relative 'xml_scaffold_structure_sisu' # xml_scaffold_structure_sisu.rb - SiSU_XML_Scaffold_Structure_Sisu::Source.new(@opt).read + end + end + self + end + def outputs + if @opt.f_pths.length > 0 + def each_file + #if @opt.files.length > 0 + def abstract_objects? + if @opt.act[:ao][:set]==:on #% --ao --dal, -m + unless @opt.act[:po4a][:set]==:on # --po4a, -P + if @opt.fno =~ /\.ssm$/ + require_relative 'ao_composite' # ao_composite.rb #pre-processing + SiSU_Assemble::Composite.new(@opt).read + end + require_relative 'ao' # -m ao.rb + SiSU_AO::Source.new(@opt).read + end + end end - if @opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse - require_relative 'xml_scaffold_structure_collapsed' # xml_scaffold_structure_collapsed.rb - SiSU_XML_Scaffold_Structure_Collapse::Source.new(@opt).read + def qrcode? + if @opt.act[:qrcode][:set]==:on #% --qrcode, -Q + require_relative 'qrcode' # qrcode.rb + SiSU_QRcode::Source.new(@opt).read + end end - if @opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook - require_relative 'xml_docbook5' # xml_docbook5.rb - SiSU_XML_Docbook_Book::Source.new(@opt).read + def hash_digests? + if @opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree + require_relative 'digests' # digests.rb + SiSU_DigestView::Source.new(@opt).read + end end - if @opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook - require_relative 'xml_fictionbook2' # xml_fictionbook2.rb - SiSU_XML_Fictionbook::Source.new(@opt).read + def text? + if @opt.act[:txt][:set]==:on #% --txt, -t -a + require_relative 'txt_plain' # txt_plain.rb + SiSU_Txt_Plain::Source.new(@opt).read + end + if @opt.act[:txt_textile][:set]==:on #% --textile + require_relative 'txt_textile' # txt_textile.rb + SiSU_Txt_Textile::Source.new(@opt).read + end + if @opt.act[:txt_asciidoc][:set]==:on #% --asciidoc + require_relative 'txt_asciidoc' # txt_asciidoc.rb + SiSU_Txt_AsciiDoc::Source.new(@opt).read + end + if @opt.act[:txt_markdown][:set]==:on #% --markdown + require_relative 'txt_markdown' # txt_markdown.rb + SiSU_Txt_Markdown::Source.new(@opt).read + end + if @opt.act[:txt_rst][:set]==:on #% --rst, --rest + require_relative 'txt_rst' # txt_rst.rb + SiSU_Txt_rST::Source.new(@opt).read + end end - if @opt.act[:xml_sax][:set]==:on #% --xml-sax, -x xml sax type - require_relative 'xml_sax' # xml_sax.rb - SiSU_XML_SAX::Source.new(@opt).read + def html? + if @opt.act[:html][:set]==:on #% --html, -h -H + require_relative 'html' # html.rb + SiSU_HTML::Source.new(@opt).read + else + if @opt.act[:html_seg][:set]==:on #% --html-seg (-h -H) + require_relative 'html' # html.rb + SiSU_HTML::Source.new(@opt).read + end + if @opt.act[:html_scroll][:set]==:on #% --html-scroll (-h -H) + require_relative 'html' # html.rb + SiSU_HTML::Source.new(@opt).read + end + end + if @opt.act[:concordance][:set]==:on #% --concordance, -w + require_relative 'html_concordance' # html_concordance.rb + SiSU_Concordance::Source.new(@opt).read + end end - if @opt.act[:xml_dom][:set]==:on #% --xml-dom, -X xml dom type - require_relative 'xml_dom' # xml_dom.rb - SiSU_XML_DOM::Source.new(@opt).read + def xhtml? + if @opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml + require_relative 'xhtml' # xhtml.rb + SiSU_XHTML::Source.new(@opt).read + end + if @opt.act[:epub][:set]==:on #% --epub, -e + require_relative 'xhtml_epub2' # xhtml_epub2.rb + SiSU_XHTML_EPUB2::Source.new(@opt).read + end end - if @opt.act[:pdf][:set]==:on \ - or @opt.act[:pdf_p][:set]==:on \ - or @opt.act[:pdf_l][:set]==:on #% --pdf-l --pdf, -p latex/ texpdf - require_relative 'texpdf' # texpdf.rb - SiSU_TeX::Source.new(@opt).read + def xml? + if @opt.act[:odt][:set]==:on #% --odt, -o opendocument + require_relative 'xml_odf_odt' # xml_odf_odt.rb + SiSU_XML_ODF_ODT::Source.new(@opt).read + end + if @opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu + require_relative 'xml_scaffold_structure_sisu' # xml_scaffold_structure_sisu.rb + SiSU_XML_Scaffold_Structure_Sisu::Source.new(@opt).read + end + if @opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse + require_relative 'xml_scaffold_structure_collapsed' # xml_scaffold_structure_collapsed.rb + SiSU_XML_Scaffold_Structure_Collapse::Source.new(@opt).read + end + if @opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook + require_relative 'xml_docbook5' # xml_docbook5.rb + SiSU_XML_Docbook_Book::Source.new(@opt).read + end + if @opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook + require_relative 'xml_fictionbook2' # xml_fictionbook2.rb + SiSU_XML_Fictionbook::Source.new(@opt).read + end + if @opt.act[:xml_sax][:set]==:on #% --xml-sax, -x xml sax type + require_relative 'xml_sax' # xml_sax.rb + SiSU_XML_SAX::Source.new(@opt).read + end + if @opt.act[:xml_dom][:set]==:on #% --xml-dom, -X xml dom type + require_relative 'xml_dom' # xml_dom.rb + SiSU_XML_DOM::Source.new(@opt).read + end end - if @opt.act[:manpage][:set]==:on #% --manpage, -i - require_relative 'manpage' # manpage.rb - SiSU_Manpage::Source.new(@opt).read + def pdf? + if @opt.act[:pdf][:set]==:on \ + or @opt.act[:pdf_p][:set]==:on \ + or @opt.act[:pdf_l][:set]==:on #% --pdf-l --pdf, -p latex/ texpdf + require_relative 'texpdf' # texpdf.rb + SiSU_TeX::Source.new(@opt).read + end end - if @opt.act[:texinfo][:set]==:on #% --texinfo, -I - require_relative 'texinfo' # texinfo.rb - SiSU_TexInfo::Source.new(@opt).read + def man_or_info? + if @opt.act[:manpage][:set]==:on #% --manpage, -i + require_relative 'manpage' # manpage.rb + SiSU_Manpage::Source.new(@opt).read + end + if @opt.act[:texinfo][:set]==:on #% --texinfo, -I + require_relative 'texinfo' # texinfo.rb + SiSU_TexInfo::Source.new(@opt).read + end end - if @opt.act[:sqlite_discrete][:set]==:on #% --sqlite, -d DB sqlite - require_relative 'dbi_discrete' # dbi_discrete.rb - SiSU_DBI_Discrete::SQL.new(@opt).build + def sqlite_discrete? + if @opt.act[:sqlite_discrete][:set]==:on #% --sqlite, -d DB sqlite + require_relative 'dbi_discrete' # dbi_discrete.rb + SiSU_DBI_Discrete::SQL.new(@opt).build + end end - if @opt.act[:manifest][:set]==:on #% --manifest, -y - require_relative 'manifest' # manifest.rb - ((@opt.act[:sisupod][:set]==:on \ - || @opt.act[:share_source][:set]==:on) \ - && @opt.files.length < 2 ) \ - ? nil - : SiSU_Manifest::Source.new(@opt).read + def manifest? + if @opt.act[:manifest][:set]==:on #% --manifest, -y + require_relative 'manifest' # manifest.rb + ((@opt.act[:sisupod][:set]==:on \ + || @opt.act[:share_source][:set]==:on) \ + && @opt.f_pths.length < 2 ) \ + ? nil + : SiSU_Manifest::Source.new(@opt).read + end end - else - @remove_faulty_markup_files_array << fno - $process_document=:ok - end - end - end - def do_loop_files_on_given_option_pre - begin - if @opt.act[:zap][:set]==:on #% --zap, -Z - OptionLoopFiles.new(@opt).loop_files_on_given_option do - require_relative 'zap' - SiSU_Zap::Source.new(@opt).read # -Z zap.rb + def harvest? + if @opt.act[:harvest][:set]==:on + require_relative 'harvest' # harvest.rb + SiSU_Harvest::Source.new(@opt).read # -h -H html.rb + end end - end - ensure - end - end - def do_loop_files_on_given_option_post - if @opt.act[:share_source][:set]==:on \ - or @opt.act[:sisupod][:set]==:on \ - or @opt.act[:git][:set]==:on - begin - require_relative 'src_shared' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Source::SiSUpodSource.new(@opt).read - end - if @opt.act[:share_source][:set]==:on - require_relative 'src_share' # -s src_share.rb - begin - ensure - OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do - SiSU_Markup::Source.new(@opt).read + self + end + def loop_files + def share_source? + if @opt.act[:share_source][:set]==:on \ + or @opt.act[:sisupod][:set]==:on \ + or @opt.act[:git][:set]==:on + begin + require_relative 'src_shared' + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Source::SiSUpodSource.new(@opt).read + end + if @opt.act[:share_source][:set]==:on + require_relative 'src_share' # -s src_share.rb + begin + ensure + OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do + SiSU_Markup::Source.new(@opt).read + end + end + end + if @opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod + require_relative 'src_sisupod_make' # -S src_sisupod_make.rb + begin + ensure + OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do + SiSU_Doc::Source.new(@opt).sisupod_tar_xz + end + end + end + if @opt.act[:git][:set]==:on #% --git, -g sisu git + require_relative 'git' # -g git.rb + begin + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Git::Source.new(@opt).read + end + ensure + OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do + SiSU_Git::Source.new(@opt).git_commit + end + end + end + if (@opt.act[:sisupod][:set]==:on \ + || @opt.act[:share_source][:set]==:on) \ + and @opt.act[:manifest][:set]==:on #% --manifest, -y + require_relative 'manifest' # -y manifest.rb + begin + ensure + OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do + SiSU_Manifest::Source.new(@opt).read + end + end + end + ensure + path_pod=@env.processing_path.processing_sisupod(@opt).paths + unless @opt.act[:maintenance][:set]==:on + FileUtils::rm_rf("#{path_pod[:sisupod]}/*") \ + if FileTest.directory?(path_pod[:sisupod]) + end + end + end + if @opt.act[:po4a][:set]==:on #% --po4a, -P + require_relative 'po4a' + begin + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Po4a::Source.new(@opt).read # -P po4a.rb + end + ensure + end + end + if @opt.act[:images][:set]==:on #% --images, -j + require_relative 'shared_images' + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Images::Source.new(@opt).read # -j shared_images.rb end end end - if @opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod - require_relative 'src_sisupod_make' # -S src_sisupod_make.rb - begin - ensure - OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do - SiSU_Doc::Source.new(@opt).sisupod_tar_xz + def run_termsheet? #broken, revisit later + if @opt.selections.str =~/--termsheet/ #% -T termsheet/standard form #fix later + @opt.files.each do |fns| + if FileTest.file?(fns) + @opt.fns=fns + case @opt.fns + when /\.(termsheet.rb)$/ + SiSU::Operations.new(@opt).termsheet + else #print "not processed --> ", fns, "\n" + end + else SiSU::Operations.new(@opt).not_found + end end end end - if @opt.act[:git][:set]==:on #% --git, -g sisu git - require_relative 'git' # -g git.rb - begin + def sql? + if @opt.act[:psql][:set]==:on #% --pg, -D DB postgresql + require_relative 'dbi' OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Git::Source.new(@opt).read + SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb end - ensure - OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do - SiSU_Git::Source.new(@opt).git_commit + end + if @opt.act[:sqlite][:set]==:on #% --sqlite, -d DB sqlite + require_relative 'dbi' + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb end end end - if (@opt.act[:sisupod][:set]==:on \ - || @opt.act[:share_source][:set]==:on) \ - and @opt.act[:manifest][:set]==:on #% --manifest, -y - require_relative 'manifest' # -y manifest.rb - begin - ensure - OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do - SiSU_Manifest::Source.new(@opt).read + def manifest? + if @opt.act[:manifest][:set]==:on #% --manifest, -y + require_relative 'manifest' + OptionLoopFiles.new(@opt).manifest_on_files_translated do + SiSU_Manifest::Source.new(@opt).read # -y manifest.rb end end end - ensure - path_pod=@env.processing_path.processing_sisupod(@opt).paths - unless @opt.act[:maintenance][:set]==:on - FileUtils::rm_rf("#{path_pod[:sisupod]}/*") \ - if FileTest.directory?(path_pod[:sisupod]) - end - end - end - if @opt.act[:po4a][:set]==:on #% --po4a, -P - require_relative 'po4a' - begin - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Po4a::Source.new(@opt).read # -P po4a.rb - end - ensure - end - end - if @opt.act[:images][:set]==:on #% --images, -j - require_relative 'shared_images' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Images::Source.new(@opt).read # -j shared_images.rb - end - end - if @opt.cmd =~/T/ #% -T termsheet/standard form - @opt.files.each do |fns| - if FileTest.file?(fns) - @opt.fns=fns - case @opt.fns - when /\.(termsheet.rb)$/ - SiSU::Operations.new(@opt).termsheet - else #print "not processed --> ", fns, "\n" + def sitemaps? + if @opt.act[:sitemap][:set]==:on #% --sitemap, -Y + require_relative 'sitemaps' + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Sitemaps::Source.new(@opt).read # -Y sitemaps.rb + end end - else SiSU::Operations.new(@opt).not_found end - end - SiSU::Operations.new.counter - end - if @opt.act[:psql][:set]==:on #% --pg, -D DB postgresql - require_relative 'dbi' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb - end - end - if @opt.act[:sqlite][:set]==:on #% --sqlite, -d DB sqlite - require_relative 'dbi' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb - end - end - if @opt.act[:manifest][:set]==:on #% --manifest, -y - require_relative 'manifest' - OptionLoopFiles.new(@opt).manifest_on_files_translated do - SiSU_Manifest::Source.new(@opt).read # -y manifest.rb - end - end - if @opt.act[:sitemap][:set]==:on #% --sitemap, -Y - require_relative 'sitemaps' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Sitemaps::Source.new(@opt).read # -Y sitemaps.rb - end - end - if @opt.act[:harvest][:set] !=:on - if @opt.act[:scp][:set]==:on #% -r copy to remote server - require_relative 'remote' # -r remote.rb - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Remote::Put.new(@opt).scp + def remote_placement? + if @opt.act[:harvest][:set] !=:on + if @opt.act[:scp][:set]==:on #% -r copy to remote server + require_relative 'remote' # -r remote.rb + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Remote::Put.new(@opt).scp + end + end + if @opt.act[:rsync][:set]==:on #% -R copy to remote server + require_relative 'remote' # -R remote.rb + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Remote::Put.new(@opt).rsync + end + end + else + end end - end - if @opt.act[:rsync][:set]==:on #% -R copy to remote server - require_relative 'remote' # -R remote.rb - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Remote::Put.new(@opt).rsync + def urls? + if @opt.act[:urls_selected][:set]==:on #% --sitemap, -Y + require_relative 'urls' + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Urls::Source.new(@opt).read #% urls.rb + end + end end - end - else - end - if @opt.act[:urls_selected][:set]==:on #% --sitemap, -Y - require_relative 'urls' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Urls::Source.new(@opt).read #% -u -v -V -M + self end end - end - def do_initialization - @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - SiSU_Env::InfoProcessingFlag.new - if @opt.act[:version_info][:set]==:on #% version information - SiSU_Env::InfoAbout.new(@opt).sisu_version + def init? + @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX + SiSU_Env::InfoProcessingFlag.new if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) @@ -618,89 +686,133 @@ module SiSU ' ' + File.dirname(__FILE__) ).grey end - end - if @opt.act[:ao][:set]==:on \ - or @opt.act[:maintenance][:set]==:on #% --maintenance, -m for -C - path={} - path[:css]=@@env.path.output + '/_sisu/css' - path[:xml]=@@env.path.output + '/_sisu/xml' - path[:xsd]=path[:xml] + '/xsd' - path[:xsd]=path[:xml] + '/rnc' - path[:xsd]=path[:xml] + '/rng' - re_p3=/(sisupod(?:\.txz)?|\S+?\.ss[mt]\.txz|[^\/]+?\.ssp)$/ - unless @opt.files.join(',') =~ re_p3 #do not mix pods with source markup files in command line - if @opt.act[:maintenance][:set] ==:on - $VERBOSE=false #debug $VERBOSE=true + if @opt.act[:ao][:set]==:on \ + or @opt.act[:maintenance][:set]==:on #% --maintenance, -m for -C + path={} + path[:css]=@@env.path.output + '/_sisu/css' + path[:xml]=@@env.path.output + '/_sisu/xml' + path[:xsd]=path[:xml] + '/xsd' + path[:xsd]=path[:xml] + '/rnc' + path[:xsd]=path[:xml] + '/rng' + re_p3=/(sisupod(?:\.txz)?|\S+?\.ss[mt]\.txz|[^\/]+?\.ssp)$/ + unless @opt.files.join(',') =~ re_p3 #do not mix pods with source markup files in command line + if @opt.act[:maintenance][:set] ==:on + $VERBOSE=false #debug $VERBOSE=true + end end - end - re_p2=/(sisupod(?:\.zip)?|\S+?\.ss[mt]\.zip)$/ - unless @opt.files.join(',') =~ re_p2 #do not mix pods with source markup files in command line - if @opt.act[:maintenance][:set] ==:on - $VERBOSE=false #debug $VERBOSE=true + re_p2=/(sisupod(?:\.zip)?|\S+?\.ss[mt]\.zip)$/ + unless @opt.files.join(',') =~ re_p2 #do not mix pods with source markup files in command line + if @opt.act[:maintenance][:set] ==:on + $VERBOSE=false #debug $VERBOSE=true + end end end - end - if @opt.act[:site_init][:set]==:on #% --init-site, -C initialize/configure - require_relative 'conf' #% --init-site, -C initialize/configure - SiSU_Initialize::Source.new(@opt).read - if @opt.act[:rsync][:set]==:on - if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ - and @opt.cmd =~/RZ/ - SiSU::Operations.new(@opt).remote_put_base_site_rsync_match - else SiSU::Operations.new(@opt).remote_put_base_site_rsync - end - elsif @opt.act[:scp][:set]==:on - if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ - and @opt.cmd =~/CCr/ - SiSU::Operations.new(@opt).remote_put_base_site_all - else SiSU::Operations.new(@opt).remote_put_base_site - end + if @opt.act[:sample_search_form][:set]==:on #% --sample-search-form, -F cgi sample search form + SiSU::Operations.new(@opt).cgi end - end - if @opt.act[:sample_search_form][:set]==:on #% --sample-search-form, -F cgi sample search form - SiSU::Operations.new(@opt).cgi - end - if @opt.act[:webrick][:set]==:on #% --webrick, -W webrick - SiSU::Operations.new(@opt).webrick - end - if @opt.act[:ao][:set]==:on - @retry_count= -1 - begin - @get_s,@get_p,@get_pl=[],[],[] - re_s=/(\S+?\.-sst)$/ - re_p3=/((?:https?|file):\/\/\S+?(?:\/\S+?\.ss[mt]\.txz|sisupod(?:\.txz)?|\.ssp))/ - re_pl3=/^(\/\S+?\.ss[mt]\.txz)/ - @opt.files.each do |fns| - if fns =~re_s - @get_s << @opt.f_pths[0][:url] + if @opt.act[:webrick][:set]==:on #% --webrick, -W webrick + SiSU::Operations.new(@opt).webrick + end + if @opt.act[:ao][:set]==:on + @retry_count= -1 + begin + @get_s,@get_p,@get_pl=[],[],[] + re_s=/(\S+?\.-sst)$/ + re_p3=/((?:https?|file):\/\/\S+?(?:\/\S+?\.ss[mt]\.txz|sisupod(?:\.txz)?|\.ssp))/ + re_pl3=/^(\/\S+?\.ss[mt]\.txz)/ + @opt.files.each do |fns| + if fns =~re_s + @get_s << @opt.f_pths[0][:url] + end + if fns =~re_p3 + @get_p << re_p3.match(fns)[1] if re_p3 + end + if fns =~re_pl3 + @get_pl << re_pl3.match(fns)[1] if re_p3 + end end - if fns =~re_p3 - @get_p << re_p3.match(fns)[1] if re_p3 + if @get_s.length > 0 #% remote markup file .sst + require_relative 'remote' # remote.rb + SiSU_Remote::Get.new(@opt,@get_s).fns + SiSU::Operations.new.counter end - if fns =~re_pl3 - @get_pl << re_pl3.match(fns)[1] if re_p3 + if @get_p.length > 0 #% remote sisupod + require_relative 'remote' # remote.rb + SiSU_Remote::Get.new(@opt,@get_p).sisupod end + rescue + SiSU_Errors::Rescued.new($!,$@,@opt,@fns).location do + __LINE__.to_s + ':' + __FILE__ + end + @retry_count +=1 + retry unless @retry_count > 1 + ensure end - if @get_s.length > 0 #% remote markup file .sst - require_relative 'remote' # remote.rb - SiSU_Remote::Get.new(@opt,@get_s).fns - SiSU::Operations.new.counter - end - if @get_p.length > 0 #% remote sisupod - require_relative 'remote' # remote.rb - SiSU_Remote::Get.new(@opt,@get_p).sisupod - end - rescue - SiSU_Errors::Rescued.new($!,$@,@opt,@fns).location do - __LINE__.to_s + ':' + __FILE__ + end + end + self + end + def do_each_file_loop_options + @opt.files.each_with_index do |fno,i| + @opt.fno=fno + @opt.fns=fno. + gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst'). + gsub(/\.ssm$/,'.ssm.sst') + @opt.f_pth=@opt.f_pths[i] + if @opt.fns !~/\.-sst$/ + @opt.pth=@opt.f_pths[i][:pth] + @opt.lng=@opt.f_pths[i][:lng] + else + @opt.pth=Dir.pwd + @opt.lng='en' + end + unless @opt.pth.nil? + @@pwd=@opt.pth + Dir.chdir(@opt.pth) #watch + end + @env=SiSU_Env::InfoEnv.new(@opt.fns) + outputs.each_file.abstract_objects? + outputs.each_file.qrcode? + outputs.each_file.hash_digests? + outputs.each_file.text? + outputs.each_file.html? + outputs.each_file.xhtml? + outputs.each_file.xml? + outputs.each_file.pdf? + outputs.each_file.man_or_info? + outputs.each_file.sqlite_discrete? + outputs.each_file.manifest? + end + end + def do_loop_files_on_given_option_pre + begin + if @opt.act[:zap][:set]==:on #% --zap, -Z + OptionLoopFiles.new(@opt).loop_files_on_given_option do + require_relative 'zap' + SiSU_Zap::Source.new(@opt).read # -Z zap.rb end - @retry_count +=1 - retry unless @retry_count > 1 - ensure end + ensure + end + end + def do_loop_files_on_given_option_post + outputs.loop_files.share_source? + outputs.loop_files.run_termsheet? + outputs.loop_files.sql? + outputs.loop_files.manifest? + outputs.loop_files.sitemaps? + outputs.loop_files.urls? + end + def version_info + if @opt.act[:version_info][:set]==:on + SiSU_Env::InfoAbout.new(@opt).sisu_version end end - def actions + def actions_without_files + prepare.remote_site? + prepare.sql? + end + def actions_on_files if @opt.act[:profile][:set]==:on begin require 'profile' @@ -709,134 +821,54 @@ module SiSU error('profile NOT FOUND (LoadError)') end end - action_on_file_ =if @opt.act[:rsync][:set]==:on \ - && @opt.act[:site_init][:set]==:on - :false - elsif @opt.act[:rsync][:set]==:on \ - && @opt.act[:site_init][:set] !=:on - :true - elsif ((@opt.act[:psql][:set]==:on \ - or @opt.act[:sqlite][:set]==:on) \ - and @opt.mod.join(';') =~/--(?:createdb|init(?:ialize)?|create(?:all)?|createtables|recreate|drop(?:all))/) - :false - else - (@opt.act[:ao][:set]==:on \ - || @opt.act[:manpage][:set]==:on \ - || @opt.act[:texinfo][:set]==:on \ - || @opt.act[:txt][:set]==:on \ - || @opt.act[:txt_textile][:set]==:on \ - || @opt.act[:txt_asciidoc][:set]==:on \ - || @opt.act[:txt_markdown][:set]==:on \ - || @opt.act[:txt_rst][:set]==:on \ - || @opt.act[:html][:set]==:on \ - || @opt.act[:html_scroll][:set]==:on \ - || @opt.act[:html_seg][:set]==:on \ - || @opt.act[:concordance][:set]==:on \ - || @opt.act[:xhtml][:set]==:on \ - || @opt.act[:epub][:set]==:on \ - || @opt.act[:odt][:set]==:on \ - || @opt.act[:xml_sax][:set]==:on \ - || @opt.act[:xml_dom][:set]==:on \ - || @opt.act[:xml_scaffold_structure_sisu][:set]==:on \ - || @opt.act[:xml_scaffold_structure_collapse][:set]==:on \ - || @opt.act[:xml_docbook_book][:set]==:on \ - || @opt.act[:xml_fictionbook][:set]==:on \ - || @opt.act[:pdf][:set]==:on \ - || @opt.act[:pdf_p][:set]==:on \ - || @opt.act[:pdf_l][:set]==:on \ - || @opt.act[:psql][:set]==:on \ - || @opt.act[:sqlite][:set]==:on \ - || @opt.act[:sqlite_discrete][:set]==:on \ - || @opt.act[:share_source][:set]==:on \ - || @opt.act[:sisupod][:set]==:on \ - || @opt.act[:qrcode][:set]==:on \ - || @opt.act[:hash_digests][:set]==:on \ - || @opt.act[:manifest][:set]==:on \ - || @opt.act[:scp][:set]==:on \ - || @opt.act[:webrick][:set]==:on \ - || @opt.act[:zap][:set]==:on) \ - ? (:true) - : (:false) - end - if @opt.act[:harvest][:set]==:on - require_relative 'harvest' # harvest.rb - SiSU_Harvest::Source.new(@opt).read # -h -H html.rb - elsif @opt.mod.inspect =~/--convert|--to|--from/ - require_relative 'sst_convert_markup' # sst_convert_markup.rb - elsif action_on_file_ == :false \ - and (@opt.act[:psql][:set]==:on \ - or @opt.act[:sqlite][:set]==:on) - if @opt.act[:psql][:set]==:on - require_relative 'dbi' - SiSU_DBI::SQL.new(@opt).connect - end - if @opt.act[:sqlite][:set]==:on - require_relative 'dbi' - SiSU_DBI::SQL.new(@opt).connect + outputs.each_file.harvest? #check + outputs.init? + do_loop_files_on_given_option_pre + do_each_file_loop_options + #remove_skipped_files_if_any_from_processing_files_array # NEEDS WORK + do_loop_files_on_given_option_post + print_error_message_if_files_skipped + outputs.sql? #check location + if @opt.f_pths.length > 0 + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + @msg,@msgs="\tsisu -W [to start ruby web-server on output directory]\n",nil end - elsif action_on_file_ == :true \ - or ( #% ---> - @opt.cmd =~/^-/ \ - and @opt.cmd =~/([abCcDdeFGgHhIjikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \ - and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ - or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ - ) - do_initialization - if action_on_file_ == :true \ - and @opt.files.length > 0 - do_loops - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - @msg,@msgs="\tsisu -W [to start ruby web-server on output directory]\n",nil - end - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on \ - || @opt.act[:urls_selected][:set]==:on \ - || @opt.act[:urls_all][:set]==:on) - @tell.call.print_brown unless @opt.files.join.empty? - end - if defined? @@env.processing_path.processing \ - and @@env.user \ - and FileTest.directory?(@@env.processing_path.processing) \ - and @@env.processing_path.processing =~/#{@@env.user}$/ #clean temporary processing directory of content as is located in public area - if @@env.processing_path.processing_base_tmp =~/^\/tmp\/\S+/ - FileUtils::cd(@@env.processing_path.processing_base_tmp) do - FileUtils::rm_rf('.') unless @opt.act[:maintenance][:set] ==:on - end + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on \ + || @opt.act[:urls_selected][:set]==:on \ + || @opt.act[:urls_all][:set]==:on) + @tell.call.print_brown unless @opt.files.join.empty? + end + if defined? @@env.processing_path.processing \ + and @@env.user \ + and FileTest.directory?(@@env.processing_path.processing) \ + and @@env.processing_path.processing =~/#{@@env.user}$/ #clean temporary processing directory of content as is located in public area + if @@env.processing_path.processing_base_tmp =~/^\/tmp\/\S+/ + FileUtils::cd(@@env.processing_path.processing_base_tmp) do + FileUtils::rm_rf('.') unless @opt.act[:maintenance][:set] ==:on end end - elsif action_on_file_ == :true \ - and @opt.files.length == 0 - STDERR.puts %{requested action requires valid sisu markup file [filename (.sst .ssm)] or wildcard (that includes a valid filename)} - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).warn(:fuchsia) - end end - elsif @opt.mod.inspect =~/--query/ - require_relative 'sst_identify_markup' # sst_identify_markup.rb - puts SiSU_Markup::MarkupHistory.new(@opt).query - elsif @opt.mod.inspect =~/--identify/ - require_relative 'sst_identify_markup' # sst_identify_markup.rb - SiSU_Markup::MarkupIdentify.new(@opt).markup_version? - elsif @opt.mod.inspect =~/--sitemaps/ #% sitemaps - require_relative 'sitemaps' # sitemaps.rb - SiSU_Sitemaps::Source.new(@opt).read - if @opt.act[:rsync][:set]==:on - require_relative 'remote' # remote.rb - SiSU_Remote::Put.new(@opt).rsync_sitemaps + elsif @opt.f_pths.length == 0 + STDERR.puts %{requested action requires valid sisu markup file [filename (.sst .ssm)] or wildcard (that includes a valid filename)} + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).warn(:fuchsia) end else #% sisu help refer to man pages - SiSU_Env::InfoAbout.new(@opt).sisu_version - SiSU_Env::InfoAbout.new(@opt).sisu_about + prepare.site? + unless done==:ok + #SiSU_Env::InfoAbout.new(@opt).sisu_about + end end @opt.files.each do |fns| if FileTest.file?(fns) @opt.fns=fns unless @opt.fns =~ /(?:\.(?:(?:-|ssm\.)?sst|ssm|ssp|sx[sdn]\.xml|termsheet.rb)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)?|\S+?\.ssp)$/ - if @opt.cmd.inspect=~/-P/ + if @opt.selections.str=~/--pg/ elsif @opt.fns=~/\.kdi$/ \ and @opt.mod.inspect =~/--(?:convert(?:-from)?|from)[=-]kdi/ elsif @opt.fns=~/\.sx[sdn]\.xml$/ \ @@ -847,7 +879,7 @@ module SiSU end end if @opt.fns =~/\.ssm\.sst$/ \ - and @opt.cmd !~/[S_M]/ # rework necessry, revist, the _ flag is a hack, to keep ._sst files + and @opt.selections.str !~/[S_M]/ # rework necessary, revist, the _ flag is a hack, to keep ._sst files @msg,@msgs='temporary file removed',nil @tell.call.warn unless @opt.act[:quiet][:set]==:on File.unlink(@opt.fns) if File.exist?(@opt.fns) #CONSIDER -- cgit v1.2.3