diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-12-12 14:58:58 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-12-12 14:58:58 -0500 |
commit | 1beb5aa3c376dbef89bc33024216650529ef7262 (patch) | |
tree | 1682500089c14fd49bcf52a3a001e291fadd5f75 /lib/sisu/v3/sysenv.rb | |
parent | debian/changelog (3.3.2-1) (diff) | |
parent | v3: 3.3.3 version & changelog, dates touched (diff) |
Merge tag 'sisu_3.3.3' into debian/sid
Diffstat (limited to 'lib/sisu/v3/sysenv.rb')
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 255 |
1 files changed, 112 insertions, 143 deletions
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 23326b40..c4b364ad 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -87,7 +87,7 @@ module SiSU_Env @t.month end def year_static - '2012' + YEAR end end class InfoSystem @@ -224,10 +224,6 @@ module SiSU_Env "#{@@home}/.sisu", "#{@@sisu_etc}/#{SiSU_version_dir}", ] - @@yamlrc_path=@@rc_path - #@@yamlrc_path=(stub_pwd !~/^sisupod$/) \ - #? (["#{@@pwd}/_sisu/#{SiSU_version_dir}","#{@@pwd}/_sisu","#{@@home}/.sisu/#{SiSU_version_dir}","#{@@home}/.sisu","#{@@sisu_etc}/#{SiSU_version_dir}"]) - #: ["#{@@home}/.sisu/#{SiSU_version_dir}","#{@@home}/.sisu","#{@@sisu_etc}/#{SiSU_version_dir}"] #security policy: prevent reading of sisurc.yml in sisupod @@ad_path=(stub_pwd !~/^sisupod$/) \ ? ([ "#{@@pwd}/.sisu/skin/yml", @@ -236,10 +232,10 @@ module SiSU_Env "#{@@sisu_etc}/skin/yml", ]) : ["#{@@home}/.sisu",@@sisu_etc] - attr_accessor :user,:home,:hostname,:pwd,:host,:arch,:rbver,:dir_arch,:dir_sitearch,:dir_bin,:locale,:webserv_path,:webserv_host_cgi,:webserv_port_cgi,:default_dir,:rc_path,:yamlrc_path,:ad_path + attr_accessor :user,:home,:hostname,:pwd,:host,:arch,:rbver,:dir_arch,:dir_sitearch,:dir_bin,:locale,:webserv_path,:webserv_host_cgi,:webserv_port_cgi,:default_dir,:rc_path,:ad_path def initialize - @user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@yamlrc_path,@ad_path=\ - @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@yamlrc_path,@@ad_path + @user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@ad_path=\ + @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@ad_path #note rbver is duplicated in InfoVersion end end @@ -297,7 +293,7 @@ module SiSU_Env def sisu_yaml def rc unless @@rc - @yamlrc_path.each do |v| + @rc_path.each do |v| if @@noyaml \ or FileTest.exist?("#{v}/noyaml") STDERR.puts "WARNING - YAML loading switched off, to enable delete the file:\n\t#{v}/noyaml\n\n" unless @@noyaml @@ -467,8 +463,8 @@ module SiSU_Env filename=(@fns =~/\.ssm\.sst$/) \ ? @fns.gsub(/\.ssm\.sst$/,'.ssm') : @fns - unless (filename.nil? \ - or filename.empty?) + if filename.is_a?(String) \ + and not filename.empty? if output_dir_structure.by_language_code? m=/((.+?)(?:\~\w{2,3})?)\.(sst|ssm)$/ @fn[:b],@fn[:m],@fn[:t]=filename[m,1],filename[m,2],filename[m,3] @@ -781,7 +777,7 @@ module SiSU_Env @texpdf end def latex2pdf(md,papersize='a4') #convert from latex to pdf - tell=if @cmd =~/[MV]/ + tell=if @cmd =~/[MV]/ '' elsif @cmd =~/[v]/ %q{2>&1 | grep -v ' WARNING '} @@ -790,18 +786,16 @@ module SiSU_Env mode='batchmode' #mode='nonstopmode' program_ref="\n\t\tSee http://www.tug.org/applications/pdftex/\n\t\tOn Debian this is is included in tetex-extra" texpdf=tex2pdf_engine - if @pdfetex_flag; + if @pdfetex_flag texpdf_cmd=case texpdf when /xetex/ - @input =~/landscape\.tex$/ \ - ? %{#{texpdf} -interaction=#{mode} -fmt=xelatex -papersize="#{papersize} -l" #{@input} #{tell}\n} - : %{#{texpdf} -interaction=#{mode} -fmt=xelatex -papersize="#{papersize}" #{@input} #{tell}\n} + %{#{texpdf} -interaction=#{mode} -fmt=xelatex -papersize="#{papersize}" #{@input} #{tell}\n} when /xelatex/ - @input =~/landscape\.tex$/ \ - ? %{#{texpdf} -interaction=#{mode} -papersize="#{papersize} -l" #{@input} #{tell}\n} - : %{#{texpdf} -interaction=#{mode} -papersize="#{papersize}" #{@input} #{tell}\n} - when /pdftex/; "#{texpdf} -interaction=#{mode} -fmt=pdflatex #{@input} #{tell}\n" - when /pdflatex/; "#{texpdf} -interaction=#{mode} #{@input} #{tell}\n" + %{#{texpdf} -interaction=#{mode} -papersize="#{papersize}" #{@input} #{tell}\n} + when /pdftex/ + "#{texpdf} -interaction=#{mode} -fmt=pdflatex #{@input} #{tell}\n" + when /pdflatex/ + "#{texpdf} -interaction=#{mode} #{@input} #{tell}\n" end system(texpdf_cmd) else STDERR.puts "\t*WARN* none of the following programs are installed: #{program[0]}, #{program[1]}, #{program[2]} is installed. #{program_ref}" @@ -979,7 +973,7 @@ module SiSU_Env include FileUtils attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:stub_src,:webserv_host_cgi,:webserv_port_cgi,:processing,:processing_git,:etc,:yamlrc_dir @@image_flag,@@local_image=true,true #warning on @@image_flag - @@fb=@@man_path=nil,nil + @@fb,@@man_path=nil,nil def initialize(fns='',md=nil) super() #you may not want to re-execute this static info so frequently! @fns,@md=fns,md @@ -990,7 +984,7 @@ module SiSU_Env elsif defined? @env.fnb \ and @env.fnb @env.fnb - elsif not @fns.nil? \ + elsif @fns.is_a?(String) \ and not @fns.empty? m=/(.+)?\.(?:(?:-|ssm\.)?sst|ssm)$/m @fns[m,1] if not @fns.empty? @@ -1193,25 +1187,25 @@ module SiSU_Env end def html_minitoc? flag=if defined? @rc['html']['minitoc'] \ - and not @rc['html']['minitoc'].nil? + and @rc['html']['minitoc'].is_a?(String) @rc['html']['minitoc'] else false end end def manifest_minitoc? - flag=if (defined? @rc['manifest']['minitoc'] \ - and not @rc['manifest']['minitoc'].nil?) + flag=if defined? @rc['manifest']['minitoc'] \ + and @rc['manifest']['minitoc'].is_a?(String) @rc['manifest']['minitoc'] else false end end def build def omit_list - @off_list ||=if (defined? @rc['omit_list'] \ - and not @rc['omit_list'].nil?) + @off_list ||=if defined? @rc['omit_list'] \ + and @rc['omit_list'].is_a?(String) @rc['omit_list'] - elsif (defined? @rc['omit']['list'] \ - and not @rc['omit']['list'].nil?) + elsif defined? @rc['omit']['list'] \ + and @rc['omit']['list'].is_a?(String) @rc['omit']['list'] else nil @@ -1390,7 +1384,7 @@ module SiSU_Env true elsif defined? @vz.widget_promo \ and not @vz.widget_promo.nil? \ - and @vz.widget_promo.class==Array \ + and @vz.widget_promo.is_a?(Array) \ and @vz.widget_promo.length > 0 @flag[:sk]=true true @@ -1745,18 +1739,15 @@ WOK self end def read_source_file(fns) - fns_array=if RUBY_VERSION < '1.9' - x=unless fns =~/\.ssm.sst$/ - IO.readlines(fns,'') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'') - end - else #ruby version >= '1.9' - x=unless fns =~/\.ssm.sst$/ - IO.readlines(fns,'r:utf-8') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8') - end + fns_array=unless fns =~/\.ssm.sst$/ + IO.readlines(fns, mode: 'r:utf-8', cr_newline: true) + else + IO.readlines("#{processing_path.composite_file}/#{fns}", mode: 'r:utf-8', cr_newline: true) end end + def source_file_processing_array(fns) + sf=read_source_file(fns).join.split(/\s*\n\s*\n/m) + end def path #dir def home @sys.home @@ -2077,8 +2068,7 @@ WOK end def dal pth=if defined? @rc['processing']['dal'] \ - and not @rc['processing']['dal'].nil? \ - and not @rc['processing']['dal'].empty? + and @rc['processing']['dal'].is_a?(String) "#{processing}/#{@rc['processing']['dal']}" else "#{processing}/#{defaults[:processing_dal]}" end @@ -2087,8 +2077,7 @@ WOK end def tune pth=if defined? @rc['processing']['tune'] \ - and not @rc['processing']['tune'].nil? \ - and not @rc['processing']['tune'].empty? + and @rc['processing']['tune'].is_a?(String) "#{processing}/#{@rc['processing']['tune']}" else "#{processing}/#{defaults[:processing_tune]}" end @@ -2102,8 +2091,7 @@ WOK end def git pth=if defined? @rc['git']['dir'] \ - and not @rc['git']['dir'].nil? \ - and not @rc['git']['dir'].empty? + and @rc['git']['dir'].is_a?(String) x=(@rc['git']['dir'] =~/^(?:~|home)$/) \ ? home + '/' + Gt[:git] : @rc['git']['dir'] + '/' + Gt[:git] @@ -2168,8 +2156,7 @@ WOK end def tex pth=if defined? @rc['processing']['latex'] \ - and not @rc['processing']['latex'].nil? \ - and not @rc['processing']['latex'].empty? + and @rc['processing']['latex'].is_a?(String) "#{processing}/#{@rc['processing']['latex']}" else "#{processing}/#{defaults[:processing_latex]}" end @@ -2178,8 +2165,7 @@ WOK end def texi pth=if defined? @rc['processing']['texinfo'] \ - and not @rc['processing']['texinfo'].nil? \ - and not @rc['processing']['texinfo'].empty? + and @rc['processing']['texinfo'].is_a?(String) "#{processing}/#{@rc['processing']['texinfo']}" else "#{processing}/#{defaults[:processing_texinfo]}" end @@ -2194,8 +2180,7 @@ WOK end def lout pth=if defined? @rc['processing']['lout'] \ - and not @rc['processing']['lout'].nil? \ - and not @rc['processing']['lout'].empty? + and @rc['processing']['lout'].is_a?(String) "#{processing}/#{@rc['processing']['lout']}" else "#{processing}/#{defaults[:processing_lout]}" end @@ -2209,8 +2194,7 @@ WOK end def sqlite pth=if defined? @rc['processing']['sqlite'] \ - and not @rc['processing']['sqlite'].nil? \ - and not @rc['processing']['sqlite'].empty? + and @rc['processing']['sqlite'].is_a?(String) "#{processing}/#{@rc['processing']['sqlite']}" else "#{processing}/#{defaults[:processing_sqlite]}" end @@ -2219,8 +2203,7 @@ WOK end def postgresql pth=if defined? @rc['processing']['postgresql'] \ - and not @rc['processing']['postgresql'].nil? \ - and not @rc['processing']['postgresql'].empty? + and @rc['processing']['postgresql'].is_a?(String) "#{processing}/#{@rc['processing']['postgresql']}" else "#{processing}/#{defaults[:processing_postgresql]}" end @@ -2292,82 +2275,41 @@ WOK else defaults[:webserv_host_cgi] end end - def webrick_port - if @md \ - and @md.opt.cmd.inspect=~/-F/ \ - and @md.opt.mod.inspect=~/port=(\d+)/ - $1 - else - if defined? @rc['webserv_cgi']['port'] - if @rc['webserv_cgi']['port'].nil? \ - and (defined? @md.opt.mod \ - and not @md.opt.mod.nil? \ - and @md.opt.mod.inspect=~/webrick/) - defaults[:webserv_port_cgi] - elsif not @rc['webserv_cgi']['port'].nil? - @rc['webserv_cgi']['port'] - else defaults[:webserv_port_cgi] - end - else defaults[:webserv_port_cgi] - end - end - end - def webserv_port_cgi - if @md \ - and defined? @md.opt \ - and @md.opt.cmd.inspect=~/-F/ \ - and @md.opt.mod.inspect=~/port=(\d+)/ - $1 - else - if defined? @rc['webserv_cgi']['port'] - if @rc['webserv_cgi']['port'].nil? \ - and (defined? @md.opt.mod \ - and not @md.opt.mod.nil? \ - and @md.opt.mod.inspect=~/webrick/) - defaults[:webserv_port_cgi] - elsif not @rc['webserv_cgi']['port'].nil? - @rc['webserv_cgi']['port'] - else nil - end - else nil - end - end - end def webserv_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing - if webserv_port_cgi - "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}/#{@stub_pwd}" + if port.webserv_port_cgi + "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}/#{@stub_pwd}" else "#{http}#{@rc['webserv_cgi']['host']}/#{@stub_pwd}" end else http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://') - if webserv_port_cgi - "#{http}#{webserv_host_base}:#{webserv_port_cgi}/#{@stub_pwd}" + if port.webserv_port_cgi + "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}/#{@stub_pwd}" else "#{http}#{webserv_host_base}/#{@stub_pwd}" end end end def webserv_base_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') - if webserv_port_cgi - "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}" + if port.webserv_port_cgi + "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}" else "#{http}#{@rc['webserv_cgi']['host']}" end else http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://') - if webserv_port_cgi - "#{http}#{webserv_host_base}:#{webserv_port_cgi}" + if port.webserv_port_cgi + "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}" else "#{http}#{webserv_host_base}" end end end def webrick #must have a port #REMOVE if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=if @rc['webserv_cgi']['host'] =~/http:\/\// 'http://' elsif @rc['webserv_cgi']['host'] =~/https:\/\// @@ -2376,7 +2318,7 @@ WOK end "#{http}#{@rc['webserv_cgi']['host']}" elsif webserv_host_base \ - and not webserv_host_base.nil? + and webserv_host_base.is_a?(String) "#{http}#{webserv_host_base}" else "#{http}localhost" end end @@ -2391,8 +2333,8 @@ WOK elsif defined? @rc['webserv']['webrick_url'] \ and @rc['webserv']['webrick_url']==false "file://#{path.webserv}" - elsif webserv_port_cgi =~/\S+/ - "#{url.hostname}:#{webserv_port_cgi}" + elsif port.webserv_port_cgi =~/\S+/ + "#{url.hostname}:#{port.webserv_port_cgi}" else url.hostname end @@ -2485,6 +2427,50 @@ WOK end self end + def port + def webrick_port + if @md \ + and @md.opt.cmd.inspect=~/-F/ \ + and @md.opt.mod.inspect=~/port=(\d+)/ + $1 + else + if defined? @rc['webserv_cgi']['port'] + if @rc['webserv_cgi']['port'].nil? \ + and (defined? @md.opt.mod \ + and not @md.opt.mod.nil? \ + and @md.opt.mod.inspect=~/webrick/) + defaults[:webserv_port_cgi] + elsif not @rc['webserv_cgi']['port'].nil? + @rc['webserv_cgi']['port'] + else defaults[:webserv_port_cgi] + end + else defaults[:webserv_port_cgi] + end + end + end + def webserv_port_cgi + if @md \ + and defined? @md.opt \ + and @md.opt.cmd.inspect=~/-F/ \ + and @md.opt.mod.inspect=~/port=(\d+)/ + $1 + else + if defined? @rc['webserv_cgi']['port'] + if @rc['webserv_cgi']['port'].nil? \ + and (defined? @md.opt.mod \ + and not @md.opt.mod.nil? \ + and @md.opt.mod.inspect=~/webrick/) + defaults[:webserv_port_cgi] + elsif not @rc['webserv_cgi']['port'].nil? + @rc['webserv_cgi']['port'] + else nil + end + else nil + end + end + end + self + end def digest def type if defined? @rc['default']['digest'] \ @@ -2745,48 +2731,42 @@ WOK end def cf_0 #processing flag shortcuts if defined? @rc['flag']['default'] \ - and not (@rc['flag']['default'].nil? \ - or @rc['flag']['default'].empty?) + and @rc['flag']['default'].is_a?(String) @rc['flag']['default'] else '-NQhewpotbxXdyYv' end end def cf_1 #processing flag shortcuts if defined? @rc['flag']['i'] \ - and not (@rc['flag']['i'].nil? \ - or @rc['flag']['i'].empty?) + and @rc['flag']['i'].is_a?(String) @rc['flag']['i'] else '-Qhewpoty' end end def cf_2 #processing flag shortcuts if defined? @rc['flag']['ii'] \ - and not (@rc['flag']['ii'].nil? \ - or @rc['flag']['ii'].empty?) + and @rc['flag']['ii'].is_a?(String) @rc['flag']['ii'] else '-NQhewpotbxXdy' end end def cf_3 #processing flag shortcuts if defined? @rc['flag']['iii'] \ - and not (@rc['flag']['iii'].nil? \ - or @rc['flag']['iii'].empty?) + and @rc['flag']['iii'].is_a?(String) @rc['flag']['iii'] else '-NQhewpotbxXdyY' end end def cf_4 #processing flag shortcuts if defined? @rc['flag']['iv'] \ - and not (@rc['flag']['iv'].nil? \ - or @rc['flag']['iv'].empty?) + and @rc['flag']['iv'].is_a?(String) @rc['flag']['iv'] else '-NQhewpotbxXdDyY --update' end end def cf_5 #processing flag shortcuts if defined? @rc['flag']['v'] \ - and not (@rc['flag']['v'].nil? \ - or @rc['flag']['v'].empty?) + and @rc['flag']['v'].is_a?(String) @rc['flag']['v'] else '-NQhewpotbxXdDyYv --update' end @@ -2984,7 +2964,7 @@ WOK def remote_host #see InfoRemote remote_host_base_general r=[] r=if (defined? @rc['remote'] \ - and @rc['remote'].class==Array) + and @rc['remote'].is_a?(Array)) r_array=@rc['remote'] r_array.each_with_index do |renv,i| r[i]={} @@ -3001,7 +2981,7 @@ WOK end r elsif (defined? @rc['remote'] \ - and @rc['remote'].class==Hash \ + and @rc['remote'].is_a?(Hash) \ and defined? @rc['remote']['user'] \ and defined? @rc['remote']['host']) r[0]={} @@ -3467,8 +3447,8 @@ WOK def dal_idx_sst_rel_html_seg "#{@env.processing_path.dal}/#{@fns}.idx_sst.rbm" end - def dal_idx_sst_rel - "#{@env.processing_path.dal}/#{@fns}.idx_tex.rbm" + def dal_idx_sst_rel #used by tex & odf + "#{@env.processing_path.dal}/#{@fns}.idx_raw.rbm" end def dal_idx_html "#{@env.processing_path.dal}/#{@fns}.idx_html.rbm" @@ -3879,7 +3859,7 @@ WOK def port #PGPORT ((defined? @rc['db']['postgresql']['port']) \ && ( @rc['db']['postgresql']['port'] =~/\d+/ \ - || @rc['db']['postgresql']['port'].class==Fixnum)) \ + || @rc['db']['postgresql']['port'].is_a?(Fixnum))) \ ? @rc['db']['postgresql']['port'] : (@defaults[:postgresql_port]) end @@ -5630,7 +5610,7 @@ WOK @env=SiSU_Env::InfoEnv.new end def webrick - @env.url.webrick_port + @env.port.webrick_port end end class InfoProgram < InfoEnv #revisit @@ -5643,7 +5623,8 @@ WOK class InfoSkin def initialize(md=nil,skin=nil) @md=md - @d_sk=if skin.class==String ; skin + @d_sk=if skin.is_a?(String) + skin elsif defined? md.doc_skin \ and md.doc_skin md.doc_skin @@ -6032,15 +6013,3 @@ module SiSU_Errors end __END__ https? intro check 2007-09-22 - -fns_array=unless fns =~/\.ssm.sst$/ - if RUBY_VERSION < '1.9' - IO.readlines(fns,'') - else IO.readlines(fns,'r:utf-8') - end -else - if RUBY_VERSION < '1.9' - IO.readlines("#{processing_path.composite_file}/#{fns}",'') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8') - end -end |