diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-03-12 18:43:27 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-03-12 18:43:38 -0400 |
commit | 4cdfa555d7e07d032bff270a962415b96c3b8741 (patch) | |
tree | ab721b803da022f84d2683f7c7ee58303c123d1b /lib | |
parent | v3dv: texinfo, fix (break holding back 3.2 merge) (diff) |
v3dv: sysenv, param, options, output control hooks code modified
* for config file, document headers, & command line
* requiring downstream code changes (in commit that follows)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v3dv/options.rb | 303 | ||||
-rw-r--r-- | lib/sisu/v3dv/param.rb | 82 | ||||
-rw-r--r-- | lib/sisu/v3dv/sysenv.rb | 503 |
3 files changed, 597 insertions, 291 deletions
diff --git a/lib/sisu/v3dv/options.rb b/lib/sisu/v3dv/options.rb index b2b7ff15..44eb1020 100644 --- a/lib/sisu/v3dv/options.rb +++ b/lib/sisu/v3dv/options.rb @@ -435,47 +435,47 @@ module SiSU_Commandline act={} act[:license]=(cmd =~/L/ \ || mod.inspect =~/"--license/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:site_init]=(cmd =~/C/ \ || mod.inspect =~/"--init-site/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:rc]=if mod.inspect =~/"--rc=/ x=Dir.pwd + '/' + mod.join.gsub(/--rc=/,'') - { bool: true, inst: x } + { bool: true, set: :on, inst: x } else - { bool: false, inst: '' } + { bool: false, set: :na, inst: '' } end act[:dump]=if mod.inspect =~/"--dump=/ base_pth=mod.join(';').gsub(/^.*--dump=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, inst: base_pth } + { bool: true, set: :on, inst: base_pth } elsif mod.inspect =~/"--dump/ - { bool: true, inst: @base_path } + { bool: true, set: :on, inst: @base_path } else - { bool: false, inst: nil } + { bool: false, set: :na, inst: nil } end act[:redirect]=if mod.inspect =~/"--redirect=/ base_pth=mod.join(';').gsub(/^.*--redirect=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, inst: base_pth } + { bool: true, set: :on, inst: base_pth } elsif mod.inspect =~/"--redirect/ - { bool: true, inst: @base_path } + { bool: true, set: :on, inst: @base_path } else - { bool: false, inst: nil } + { bool: false, set: :na, inst: nil } end act[:verbose]=(cmd =~/v/ \ || mod.inspect =~/"--verbose"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:quiet]=(cmd =~/q/ \ || mod.inspect =~/"--quiet"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ - { bool: true } + { bool: true, set: :on } elsif mod.inspect =~/"--color-off"/ - { bool: false } - else { bool: true } #fix default color + { bool: false, set: :off } + else { bool: true, set: :na } #fix default color end # act[:color_toggle]=if cmd =~/c/ \ # or mod.inspect =~/"--color-toggle"/ @@ -484,202 +484,253 @@ module SiSU_Commandline # end act[:maintenance]=(cmd =~/M/ \ || mod.inspect =~/"--maintenance|--keep-processing-files"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:switch]=if mod.inspect =~/"--switch-off=/ off_list=mod.join(';').gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1') off_list=off_list.scan(/[^,;\s]+/) - { bool: false, off: off_list} - else { bool: true, off: [] } + { bool: false, set: :off, off: off_list} + else { bool: true, set: :na, off: [] } end - act[:ocn]=if mod.inspect =~/"--no-ocn"/ \ + act[:ocn]= + if mod.inspect =~/"--inc-ocn"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-ocn"/ \ || act[:switch][:off].inspect =~/"ocn"/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:toc]=if mod.inspect =~/"--no-toc"/ \ + act[:toc]=if mod.inspect =~/"--inc-toc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-toc"/ \ || act[:switch][:off].inspect =~/"toc"/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:manifest]=if mod.inspect =~/"--no-manifest"/ \ + act[:minitoc]=if mod.inspect =~/"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"minitoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:manifest]=if mod.inspect =~/"--inc-manifest"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ || act[:switch][:off].inspect =~/"manifest"/ - #|| mod.inspect =~/"--(?:redirect|dump)/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:manifest_links]=if mod.inspect =~/"--no-manifest-links"/ \ - || act[:switch][:off].inspect =~/"manifest_links"/ \ + act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \ + || act[:switch][:off].inspect =~/"links_to_manifest"|"manifest_links"/ \ || mod.inspect =~/"--(?:redirect|dump)/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:manifest_minitoc]=if mod.inspect =~/"--no-manifest-minitoc"/ \ + act[:manifest_minitoc]=if mod.inspect =~/"--inc-manifest-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest-minitoc"|"--(?:exc|no)-minitoc"/ \ || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/ #|| mod.inspect =~/"--(?:redirect|dump)/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:metadata]=if mod.inspect =~/"--no-metadata"/ \ + act[:metadata]=if mod.inspect =~/"--inc-metadata"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-metadata"/ \ || act[:switch][:off].inspect =~/"metadata"/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:html_minitoc]=if mod.inspect =~/"--no-html-minitoc"/ \ + act[:html_minitoc]=if mod.inspect =~/"--inc-html-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-minitoc"|"--(?:exc|no)-minitoc"/ \ || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:html_navigation]=if mod.inspect =~/"--no-html-navigation"/ \ + act[:html_navigation]=if mod.inspect =~/"--inc-html-navigation"|"--inc-navigation"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation"|"--(?:exc|no)-navigation"/ \ || act[:switch][:off].inspect =~/"html_navigation"|"nav"/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:html_navigation_bar]=if mod.inspect =~/"--no-html-navigation-bar"/ \ + act[:html_navigation_bar]=if mod.inspect =~/"--inc-html-navigation-bar"|"--inc-navigation-bar"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation-bar"|"--(?:exc|no)-navigation-bar"/ \ || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/ - { bool: false } - else { bool: true } + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:segsubtoc]=if mod.inspect =~/"--inc-segsubtoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-segsubtoc"/ \ + || act[:switch][:off].inspect =~/"segsubtoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:search_form]=if mod.inspect =~/"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_search_form]=if mod.inspect =~/"--inc-html-search-form"|"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-search-form"|"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"html_search_form"|"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:html_search_form]=if mod.inspect =~/"--no-html-search-form"/ \ - || act[:switch][:off].inspect =~/"html_search_form"|"search"/ - { bool: false } - else { bool: true } + act[:html_right_pane]=if mod.inspect =~/"--inc-html-right-pane"|"--inc-right-pane"|"--inc-html-right-column"|"--inc-right-column"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-right-pane"|"--(?:exc|no)-right-pane"|"--(?:exc|no)-html-right-column"|"--(?:exc|no)-right-column"/ \ + || act[:switch][:off].inspect =~/"html_right_pane"|"html_right_column"|"promo"/ + { bool: false, set: :off } + else { bool: true, set: :na } end - act[:html_right_column]=if mod.inspect =~/"--no-html-right-column"/ \ - || act[:switch][:off].inspect =~/"html_right_column"|"promo"/ - { bool: false } - else { bool: true } + act[:html_top_band]=if mod.inspect =~/"--inc-html-top-band"|"--inc-top-band"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-top-band"|"--(?:exc|no)-top-band"/ \ + || act[:switch][:off].inspect =~/"html-top-band"|"top-band"/ + { bool: false, set: :off } + else { bool: true, set: :na } end act[:dal]=(cmd =~/m/ \ || mod.inspect =~/"--dal"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:html]=(cmd =~/h/ \ || mod.inspect =~/"--html"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:concordance]=(cmd =~/w/ \ || mod.inspect =~/"--concordance"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:images]=(cmd =~/j/ \ || mod.inspect =~/"--images"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:pdf]=(cmd =~/p/ \ || mod.inspect =~/"--pdf"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:epub]=(cmd =~/e/ \ || mod.inspect =~/"--epub"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:odt]=(cmd =~/o/ \ || mod.inspect =~/"--odf"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:xml_sax]=(cmd =~/x/ \ || mod.inspect =~/"--xml-sax"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:xml_dom]=(cmd =~/X/ \ || mod.inspect =~/"--xml-dom"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:xhtml]=(cmd =~/b/ \ || mod.inspect =~/"--xhtml"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:txt]=(cmd =~/[at]/ \ || mod.inspect =~/"--txt"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:manpage]=(cmd =~/i/ \ || mod.inspect =~/"--manpage"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:texinfo]=(cmd =~/I/ \ || mod.inspect =~/"--texinfo"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:fictionbook]=(cmd =~/f/ \ || mod.inspect =~/"--fictionbook"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:psql]=(cmd =~/D/ \ || mod.inspect =~/"--pg"|"--pgsql"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sqlite]=(cmd =~/d/ \ || mod.inspect =~/"--sqlite"/) \ - ? { bool: true } - : { bool: false } + && (mod.inspect =~/"--createdb"|"--create"|"--recreate"|"--dropall"|"--recreate"|"--import"|"--update"|"--remove"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:harvest]=(mod.inspect =~/"--harvest"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:po4a]=(cmd =~/P/ \ || mod.inspect =~/"--po4a"|"--pot?"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:git]=(cmd =~/g/ \ || mod.inspect =~/"--git"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:hash_digests]=(cmd =~/N/ \ || mod.inspect =~/"--hash-digests"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sample_search_form]=(cmd =~/F/ \ || mod.inspect =~/"--sample-search-form"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:webrick]=(cmd =~/W/ \ || mod.inspect =~/"--webrick"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:share_source]=(cmd =~/s/ \ || mod.inspect =~/"--source"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sisupod]=(cmd =~/S/ \ || mod.inspect =~/"--sisupod"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:scp]=(cmd =~/r/ \ || mod.inspect =~/"--scp"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:rsync]=(cmd =~/R/ \ || mod.inspect =~/"--rsync"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:delete_output]=(cmd =~/z/ \ || mod.inspect =~/"--delete"|"--zap"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:urls_all]=(cmd =~/U/ \ || mod.inspect =~/"--urls-all"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:urls_seleted]=(cmd =~/u/ \ || mod.inspect =~/"--urls"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sitemap]=(cmd =~/Y/ \ || mod.inspect =~/"--sitemap"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:qrcode]=(cmd =~/Q/ \ || mod.inspect =~/"--qrcode"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:manifest]=(cmd =~/y/ \ || mod.inspect =~/"--manifest"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:help]=(mod.inspect =~/"--help/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } @act=act end def cmd diff --git a/lib/sisu/v3dv/param.rb b/lib/sisu/v3dv/param.rb index 8d3379b7..5563f780 100644 --- a/lib/sisu/v3dv/param.rb +++ b/lib/sisu/v3dv/param.rb @@ -811,8 +811,88 @@ module SiSU_Param else nil end end - def omit_list + def omit m=@h['omit'] + @m=m ? (m.split(/,\s+/)) : nil + def list + @m + end + self + end + def ocn? + (omit.list.inspect =~/"ocn"/) \ + ? :off + : :na + end + def toc? + (omit.list.inspect =~/"toc"/) \ + ? :off + : :na + end + def manifest? + (omit.list.inspect =~/"manifest"/) \ + ? :off + : :na + end + def links_to_manifest? + (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ + ? :off + : :na + end + def metadata? + (omit.list.inspect =~/"metadata"/) \ + ? :off + : :na + end + def minitoc? + (omit.list.inspect =~/"minitoc"/) \ + ? :off + : :na + end + def html_minitoc? + (omit.list.inspect =~/"html_minitoc"/) \ + ? :off + : :na + end + def html_top_band? + (omit.list.inspect =~/"html_top_band"/) \ + ? :off + : :na + end + def html_navigation? + (omit.list.inspect =~/"html_navigation"/) \ + ? :off + : :na + end + def html_navigation_bar? + (omit.list.inspect =~/"html_navigation_bar"/) \ + ? :off + : :na + end + def segsubtoc? + (omit.list.inspect =~/"segsubtoc"/) \ + ? :off + : :na + end + def search_form? + (omit.list.inspect =~/"search_form"/) \ + ? :off + : :na + end + def html_search_form? + (omit.list.inspect =~/"html_search_form"/) \ + ? :off + : :na + end + def html_right_pane? + (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ + ? :off + : :na + end + def manifest_minitoc? + (omit.list.inspect =~/"manifest_minitoc"/) \ + ? :off + : :na end def texpdf_font def main diff --git a/lib/sisu/v3dv/sysenv.rb b/lib/sisu/v3dv/sysenv.rb index fcfc234b..95ebf6d9 100644 --- a/lib/sisu/v3dv/sysenv.rb +++ b/lib/sisu/v3dv/sysenv.rb @@ -435,27 +435,27 @@ module SiSU_Env end def dump? ((by?) ==:dump) \ - ? true \ + ? true : false end def redirect? ((by?) ==:redirect) \ - ? true \ + ? true : false end def by_language_code? ((by?) ==:language) \ - ? true \ + ? true : false end def by_filetype? ((by?) ==:filetype) \ - ? true \ + ? true : false end def by_filename? ((by?) ==:filename) \ - ? true \ + ? true : false end def multilingual? @@ -804,9 +804,10 @@ module SiSU_Env end def makeinfo #texinfo program='makeinfo' + options='' #'--force' #'' program_ref="\n\t\tsee http://www.gnu.org/software/texinfo/" (program_found?(program)) \ - ? system("#{program} #{@input}\n") + ? system("#{program} #{options} #{@input}\n") : (puts "\tWARN: #{program} is not installed #{program_ref}") end def scp @@ -1193,13 +1194,6 @@ module SiSU_Env end end def manifest_minitoc? - flag=if defined? @rc['manifest']['minitoc'] \ - and not @rc['manifest']['minitoc'].nil? - @rc['manifest']['minitoc'] - else false - end - end - def manifest_minitoc? flag=if (defined? @rc['manifest']['minitoc'] \ and not @rc['manifest']['minitoc'].nil?) @rc['manifest']['minitoc'] @@ -1222,7 +1216,7 @@ module SiSU_Env listed=if omit_list x=(omit_list.scan(/\b#{test}\b/)).join test==x \ - ? true \ + ? true : false else false @@ -1230,48 +1224,67 @@ module SiSU_Env listed end def ocn? - flag=if (defined? @rc['omit']['ocn'] \ + if (defined? @rc['omit']['ocn'] \ and not @rc['omit']['ocn'].nil?) \ or listed?('ocn') - false + :off else - true + :na end end def toc? - flag=if (defined? @rc['omit']['toc'] \ + if (defined? @rc['omit']['toc'] \ and not @rc['omit']['toc'].nil?) \ or listed?('toc') - false + :off else - true + :na |