From af7543c058995af80e25f2f71be3a12699e26564 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 13 Sep 2011 19:15:22 -0400 Subject: v3: options, (hub), action (opt.act) modified to increase use possibilities --- data/doc/sisu/CHANGELOG_v3 | 8 +- lib/sisu/v3/hub.rb | 92 ++++++------ lib/sisu/v3/options.rb | 347 +++++++++++++++++++++------------------------ 3 files changed, 211 insertions(+), 236 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 0c9e01b6..a215c831 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -21,7 +21,13 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.18.orig.tar.xz sisu_3.0.18-1.dsc sisu_3.0.18-1.debian.tar.gz - * options, match fix for --glob / --find + * options + * match fix for --glob / --find + * action (opt.act) modified to increase use possibilities + (currently affects hub) + + * hub + * opt.act modifications * correct sisupod references and path to .txz (replace .zip) diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 029c2861..5319bfdc 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -104,7 +104,6 @@ module SiSU @opt.files.each_with_index do |fns,i| env=SiSU_Env::Info_env.new(fns) if fns =~ /sisupod(?:\.txz)?|\S+?(?:\.ss[mt]\.txz|\.ssp)$/ -# env=SiSU_Env::Info_env.new(fns) require_relative 'remote' # remote.rb #check pod_name=if fns =~ /http:\/\/\S+?(?:\.ss[mt]\.txz|\.ssp)$/ SiSU_Remote::Remote_download.new(fns).pod.name @@ -305,28 +304,29 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @opt.cmd =~/E/ # re-assign character require 'profile' end - if @opt.act[:harvest] - require_relative 'harvest' # harvest.rb - SiSU_Harvest::Source.new(@opt).read # -h -H html.rb + if @opt.act[:harvest][:bool] + 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 + require_relative 'sst_convert_markup' # sst_convert_markup.rb elsif @opt.cmd =~/([AabCcDdeFfGgHhIiJjkLMmNnOoPpQqRrSsTtUuVvwWXxYyZ_0-9])/ \ and @opt.cmd =~/^-/ \ and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX flag=SiSU_Env::Info_processing_flag.new - if @opt.cmd =~/[vVM]/ #% version information + if @opt.cmd =~/[vVM]/ #% version information if @opt.cmd =~/V/ \ - and @opt.files.empty? #% environment + and @opt.files.empty? #% environment SiSU_Help::Help.new('env',@opt).environment else SiSU_Help::Help.new('env',@opt).sisu_version end end - if @opt.act[:license] #% license information + if @opt.act[:license][:bool] #% license information SiSU_Help::Help.new('license',@opt).help_request end - if @opt.act[:dal] or @opt.act[:maintenance] #% --maintenance, -m for -C + if @opt.act[:dal][:bool] \ + or @opt.act[:maintenance][:bool] #% --maintenance, -m for -C path={} path[:css]=@@env.path.output + '/_sisu/css' path[:xml]=@@env.path.output + '/_sisu/xml' @@ -344,7 +344,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end end end - if @opt.act[:site_init] #% --init-site, -C initialize/configure + if @opt.act[:site_init][:bool] #% --init-site, -C initialize/configure op('conf','configure site') if @opt.cmd =~/R/ if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ @@ -360,19 +360,19 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end end end - if @opt.act[:sample_search_form] #% --sample-search-form, -F cgi sample search form + if @opt.act[:sample_search_form][:bool] #% --sample-search-form, -F cgi sample search form Operations.new(@opt).cgi end - if @opt.act[:webrick] #% --webrick, -W webrick + if @opt.act[:webrick][:bool] #% --webrick, -W webrick Operations.new(@opt).webrick end - if @opt.cmd =~/Z/ #% -Z wipe previous output clean + if @opt.cmd =~/Z/ #% -Z wipe previous output clean op('zap','Zap, deletions') end - if @opt.act[:share_source] + if @opt.act[:share_source][:bool] op('share_src','SiSU markup source') end - if @opt.act[:dal] + if @opt.act[:dal][:bool] @retry_count= -1 begin path_image='./_sisu/processing/external_document/image' @@ -397,8 +397,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ SiSU_Remote::Get.new(@opt,@get_s).fns Operations.new.counter end - if @get_p.length > 0 #% remote sisupod - require_relative 'remote' # remote.rb + if @get_p.length > 0 #% remote sisupod + require_relative 'remote' # remote.rb SiSU_Remote::Get.new(@opt,@get_p).sisupod end rescue @@ -409,60 +409,60 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end @opt.files=@opt.files.collect {|x| x=x.gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst') } end - if @opt.act[:dal] #%--dal, -m + if @opt.act[:dal][:bool] #%--dal, -m op('dal','dal') end @opt.files=@opt.files.collect {|x| x=x.gsub(/\.ssm$/,'.ssm.sst') } - if @opt.act[:sisupod] #% --sisupod, -S make sisupod + if @opt.act[:sisupod][:bool] #% --sisupod, -S make sisupod op('sisupod_make','sisupod (txz)') if @opt.fns=~/\.kdi._sst/ - op('share_src_kdissert','kdissert (kdi)') #% -S share kdissert source + op('share_src_kdissert','kdissert (kdi)') #% -S share kdissert source end end - if @opt.act[:qrcode] #% --qrcode, -Q + if @opt.act[:qrcode][:bool] #% --qrcode, -Q op('qrcode','QRcode') end - if @opt.act[:hash_digests] #% --hash-digests, -N digest tree + if @opt.act[:hash_digests][:bool] #% --hash-digests, -N digest tree op('digests','digests') end - if @opt.act[:html] #% --html, -h + if @opt.act[:html][:bool] #% --html, -h op('html','html') end - if @opt.act[:txt] #% --txt, -t -a + if @opt.act[:txt][:bool] #% --txt, -t -a #-A -f -e -E plaintext -a creates ms-dos type; -A creates unix type, plaintext file op('plaintext','plaintext') end - if @opt.act[:epub] #% --epub, -e + if @opt.act[:epub][:bool] #% --epub, -e op('epub','ePub') end - if @opt.act[:odt] #% --odt, -o opendocument + if @opt.act[:odt][:bool] #% --odt, -o opendocument op('odf','OpenDocument') end - if @opt.act[:xml_sax] #% --xml-sax, -x xml sax type + if @opt.act[:xml_sax][:bool] #% --xml-sax, -x xml sax type op('xml','xml sax') end - if @opt.act[:xml_dom] #% --xml-dom, -x xml dom type + if @opt.act[:xml_dom][:bool] #% --xml-dom, -x xml dom type op('xml_dom','xml dom') end - #if @opt.act[:fictionbook] #% --fictionbook, -f fictionbook xml + #if @opt.act[:fictionbook] #% --fictionbook, -f fictionbook xml # op('xml_fictionbook','xml fictionbook') #end - if @opt.act[:xhtml] #% --xhtml, -b xhtml + if @opt.act[:xhtml][:bool] #% --xhtml, -b xhtml op('xhtml','xhtml sax') end - if @opt.act[:concordance] #% --concordance, -w + if @opt.act[:concordance][:bool] #% --concordance, -w op('concordance','Concordance') end - if @opt.cmd =~/O/ #% -O open archive initiative, metadata harvesting + if @opt.cmd =~/O/ #% -O open archive initiative, metadata harvesting op('xml_md_oai_pmh_dc','OAI PMH') end - if @opt.act[:po4a] #% --po4a, -P + if @opt.act[:po4a][:bool] #% --po4a, -P op('po4a','po4a') end - if @opt.act[:git] #% --git, -g sisu git + if @opt.act[:git][:bool] #% --git, -g sisu git op('git','SiSU Git') end - if @opt.cmd =~/T/ #% -T termsheet/standard form + if @opt.cmd =~/T/ #% -T termsheet/standard form SiSU_Help::Help.new('termsheet').help_request @opt.files.each do |fns| if FileTest.file?(fns) @@ -476,38 +476,38 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end Operations.new.counter end - if @opt.cmd =~/k/ #% -T temporary tests + if @opt.cmd =~/k/ #% -T temporary tests op('xml_scaffold','XML scaffold') end - if @opt.act[:pdf] #% --pdf, -p latex/ texpdf + if @opt.act[:pdf][:bool] #% --pdf, -p latex/ texpdf op('texpdf','LaTeX pdf') end - if @opt.act[:manpage] #% --manpage, -i + if @opt.act[:manpage][:bool] #% --manpage, -i op('manpage','manpage') end - if @opt.act[:texinfo] #% --texinfo, -I + if @opt.act[:texinfo][:bool] #% --texinfo, -I op('texinfo','TeX Info') end - if @opt.act[:psql] #% --pg, -D DB postgresql + if @opt.act[:psql][:bool] #% --pg, -D DB postgresql op('dbi','postgresql') end - if @opt.act[:sqlite] #% --sqlite, -d DB sqlite + if @opt.act[:sqlite][:bool] #% --sqlite, -d DB sqlite op('dbi','sqlite') end - if @opt.act[:dal] #% --dal, -m embedded content + if @opt.act[:dal][:bool] #% --dal, -m embedded content op('embedded','Embedded Content') end - if @opt.act[:manifest] #% --manifest, -y + if @opt.act[:manifest][:bool] #% --manifest, -y op('manifest','Manifest') end - if @opt.act[:sitemap] #% --sitemap, -Y + if @opt.act[:sitemap][:bool] #% --sitemap, -Y op('sitemaps','Sitemap') end if @opt.mod.inspect !~/--harvest/ - if @opt.act[:scp] #% -r copy to remote server + if @opt.act[:scp][:bool] #% -r copy to remote server op('remote','scp') end - if @opt.act[:rsync] #% -R copy to remote server + if @opt.act[:rsync][:bool] #% -R copy to remote server op('remote','rsync') end else diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index dbfe5d79..66866dc3 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -375,204 +375,173 @@ module SiSU_commandline def opt_act #note mod line commands have already been converted to command characters, cmd cmd,mod=@cmd,@mod act={} - act[:license]=if cmd =~/L/ \ - or mod.inspect =~/"--license/ - true - else false - end - act[:site_init]=if cmd =~/C/ \ - or mod.inspect =~/"--init-site/ - true - else false - end - act[:verbose]=if cmd =~/v/ \ - or mod.inspect =~/"--verbose"/ - true - else false - end - act[:quiet]=if cmd =~/q/ \ - or mod.inspect =~/"--quiet"/ - true - else false - end + act[:license]=(cmd =~/L/ \ + || mod.inspect =~/"--license/) \ + ? { bool: true } + : { bool: false } + act[:site_init]=(cmd =~/C/ \ + || mod.inspect =~/"--init-site/) \ + ? { bool: true } + : { bool: false } + act[:rc]=if mod.inspect =~/"--rc=/ + x=Dir.pwd + '/' + mod.join.gsub(/--rc=/,'') + { bool: true, inst: x } + else + { bool: false, inst: '' } + end + act[:verbose]=(cmd =~/v/ \ + || mod.inspect =~/"--verbose"/) \ + ? { bool: true } + : { bool: false } + act[:quiet]=(cmd =~/q/ \ + || mod.inspect =~/"--quiet"/) \ + ? { bool: true } + : { bool: false } act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ - true + { bool: true } elsif mod.inspect =~/"--color-off"/ - true - else true #fix default color + { bool: false } + else { bool: true } #fix default color end # act[:color_toggle]=if cmd =~/c/ \ # or mod.inspect =~/"--color-toggle"/ # true # else false # end - act[:maintenance]=if cmd =~/M/ \ - or mod.inspect =~/"--maintenance|--keep-processing-files"/ - true - else false - end + act[:maintenance]=(cmd =~/M/ \ + || mod.inspect =~/"--maintenance|--keep-processing-files"/) \ + ? { bool: true } + : { bool: false } act[:ocn]=if mod.inspect =~/"--no-ocn"/ - false - else true - end - act[:dal]=if cmd =~/m/ \ - or mod.inspect =~/"--dal"/ - true - else false - end - act[:html]=if cmd =~/h/ \ - or mod.inspect =~/"--html"/ - true - else false - end - act[:concordance]=if cmd =~/w/ \ - or mod.inspect =~/"--concordance"/ - true - else false - end - act[:pdf]=if cmd =~/p/ \ - or mod.inspect =~/"--pdf"/ - true - else false - end - act[:epub]=if cmd =~/e/ \ - or mod.inspect =~/"--epub"/ - true - else false - end - act[:odt]=if cmd =~/o/ \ - or mod.inspect =~/"--odf"/ - true - else false - end - act[:xml_sax]=if cmd =~/x/ \ - or mod.inspect =~/"--xml-sax"/ - true - else false - end - act[:xml_dom]=if cmd =~/X/ \ - or mod.inspect =~/"--xml-dom"/ - true - else false - end - act[:xhtml]=if cmd =~/b/ \ - or mod.inspect =~/"--xhtml"/ - true - else false - end - act[:txt]=if cmd =~/[at]/ \ - or mod.inspect =~/"--txt"/ - true - else false - end - act[:manpage]=if cmd =~/i/ \ - or mod.inspect =~/"--manpage"/ - true - else false - end - act[:texinfo]=if cmd =~/I/ \ - or mod.inspect =~/"--texinfo"/ - true - else false - end - act[:fictionbook]=if cmd =~/f/ \ - or mod.inspect =~/"--fictionbook"/ - true - else false - end - act[:psql]=if cmd =~/D/ \ - or mod.inspect =~/"--pg"|"--pgsql"/ - true - else false - end - act[:sqlite]=if cmd =~/d/ \ - or mod.inspect =~/"--sqlite"/ - true - else false - end - act[:harvest]=if mod.inspect =~/"--harvest"/ - true - else false - end - act[:po4a]=if cmd =~/P/ \ - or mod.inspect =~/"--po4a"|"--pot?"/ - true - else false - end - act[:git]=if cmd =~/g/ \ - or mod.inspect =~/"--git"/ - true - else false - end - act[:hash_digests]=if cmd =~/N/ \ - or mod.inspect =~/"--hash-digests"/ - true - else false - end - act[:sample_search_form]=if cmd =~/F/ \ - or mod.inspect =~/"--sample-search-form"/ - true - else false - end - act[:webrick]=if cmd =~/W/ \ - or mod.inspect =~/"--webrick"/ - true - else false - end - act[:share_source]=if cmd =~/s/ \ - or mod.inspect =~/"--source"/ - true - else false - end - act[:sisupod]=if cmd =~/S/ \ - or mod.inspect =~/"--sisupod"/ - true - else false - end - act[:scp]=if cmd =~/r/ \ - or mod.inspect =~/"--scp"/ - true - else false - end - act[:rsync]=if cmd =~/R/ \ - or mod.inspect =~/"--rsync"/ - true - else false - end - act[:delete_output]=if cmd =~/z/ \ - or mod.inspect =~/"--delete"|"--zap"/ - true - else false - end - act[:urls_all]=if cmd =~/U/ \ - or mod.inspect =~/"--urls-all"/ - true - else false - end - act[:urls_seleted]=if cmd =~/u/ \ - or mod.inspect =~/"--urls"/ - true - else false - end - act[:sitemap]=if cmd =~/Y/ \ - or mod.inspect =~/"--sitemap"/ - true - else false - end - act[:qrcode]=if cmd =~/Q/ \ - or mod.inspect =~/"--qrcode"/ - true - else false - end - act[:manifest]=if cmd =~/y/ \ - or mod.inspect =~/"--manifest"/ - true - else false - end - act[:help]=if mod.inspect =~/"--help/ - true - else false - end + { bool: false } + else { bool: true } + end + act[:dal]=(cmd =~/m/ \ + || mod.inspect =~/"--dal"/) \ + ? { bool: true } + : { bool: false } + act[:html]=(cmd =~/h/ \ + || mod.inspect =~/"--html"/) \ + ? { bool: true } + : { bool: false } + act[:concordance]=(cmd =~/w/ \ + || mod.inspect =~/"--concordance"/) \ + ? { bool: true } + : { bool: false } + act[:pdf]=(cmd =~/p/ \ + || mod.inspect =~/"--pdf"/) \ + ? { bool: true } + : { bool: false } + act[:epub]=(cmd =~/e/ \ + || mod.inspect =~/"--epub"/) \ + ? { bool: true } + : { bool: false } + act[:odt]=(cmd =~/o/ \ + || mod.inspect =~/"--odf"/) \ + ? { bool: true } + : { bool: false } + act[:xml_sax]=(cmd =~/x/ \ + || mod.inspect =~/"--xml-sax"/) \ + ? { bool: true } + : { bool: false } + act[:xml_dom]=(cmd =~/X/ \ + || mod.inspect =~/"--xml-dom"/) \ + ? { bool: true } + : { bool: false } + act[:xhtml]=(cmd =~/b/ \ + || mod.inspect =~/"--xhtml"/) \ + ? { bool: true } + : { bool: false } + act[:txt]=(cmd =~/[at]/ \ + || mod.inspect =~/"--txt"/) \ + ? { bool: true } + : { bool: false } + act[:manpage]=(cmd =~/i/ \ + || mod.inspect =~/"--manpage"/) \ + ? { bool: true } + : { bool: false } + act[:texinfo]=(cmd =~/I/ \ + || mod.inspect =~/"--texinfo"/) \ + ? { bool: true } + : { bool: false } + act[:fictionbook]=(cmd =~/f/ \ + || mod.inspect =~/"--fictionbook"/) \ + ? { bool: true } + : { bool: false } + act[:psql]=(cmd =~/D/ \ + || mod.inspect =~/"--pg"|"--pgsql"/) \ + ? { bool: true } + : { bool: false } + act[:sqlite]=(cmd =~/d/ \ + || mod.inspect =~/"--sqlite"/) \ + ? { bool: true } + : { bool: false } + act[:harvest]=(mod.inspect =~/"--harvest"/) \ + ? { bool: true } + : { bool: false } + act[:po4a]=(cmd =~/P/ \ + || mod.inspect =~/"--po4a"|"--pot?"/) \ + ? { bool: true } + : { bool: false } + act[:git]=(cmd =~/g/ \ + || mod.inspect =~/"--git"/) \ + ? { bool: true } + : { bool: false } + act[:hash_digests]=(cmd =~/N/ \ + || mod.inspect =~/"--hash-digests"/) \ + ? { bool: true } + : { bool: false } + act[:sample_search_form]=(cmd =~/F/ \ + || mod.inspect =~/"--sample-search-form"/) \ + ? { bool: true } + : { bool: false } + act[:webrick]=(cmd =~/W/ \ + || mod.inspect =~/"--webrick"/) \ + ? { bool: true } + : { bool: false } + act[:share_source]=(cmd =~/s/ \ + || mod.inspect =~/"--source"/) \ + ? { bool: true } + : { bool: false } + act[:sisupod]=(cmd =~/S/ \ + || mod.inspect =~/"--sisupod"/) \ + ? { bool: true } + : { bool: false } + act[:scp]=(cmd =~/r/ \ + || mod.inspect =~/"--scp"/) \ + ? { bool: true } + : { bool: false } + act[:rsync]=(cmd =~/R/ \ + || mod.inspect =~/"--rsync"/) \ + ? { bool: true } + : { bool: false } + act[:delete_output]=(cmd =~/z/ \ + || mod.inspect =~/"--delete"|"--zap"/) \ + ? { bool: true } + : { bool: false } + act[:urls_all]=(cmd =~/U/ \ + || mod.inspect =~/"--urls-all"/) \ + ? { bool: true } + : { bool: false } + act[:urls_seleted]=(cmd =~/u/ \ + || mod.inspect =~/"--urls"/) \ + ? { bool: true } + : { bool: false } + act[:sitemap]=(cmd =~/Y/ \ + || mod.inspect =~/"--sitemap"/) \ + ? { bool: true } + : { bool: false } + act[:qrcode]=(cmd =~/Q/ \ + || mod.inspect =~/"--qrcode"/) \ + ? { bool: true } + : { bool: false } + act[:manifest]=(cmd =~/y/ \ + || mod.inspect =~/"--manifest"/) \ + ? { bool: true } + : { bool: false } + act[:help]=(mod.inspect =~/"--help/) \ + ? { bool: true } + : { bool: false } @act=act end def cmd -- cgit v1.2.3