diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-10-01 15:43:19 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-10-01 15:43:19 -0400 |
commit | 6b2c44794b8aeeca96a9b3114b87b3c1df69fd9d (patch) | |
tree | 20ffa7c21eda17b340e473733088fa80986cc0d6 /lib/sisu/v3/sysenv.rb | |
parent | v3: cosmetic code, if true ; x, remove semicolons replace with "then" (diff) |
v3: cosmetic code, .is_a?(X) replaces .class==X (& some defined? & nil? tests)
Diffstat (limited to 'lib/sisu/v3/sysenv.rb')
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index a9df7b2a..1c813fd8 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -467,8 +467,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] @@ -988,7 +988,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? @@ -1191,25 +1191,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 @@ -1388,7 +1388,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 @@ -2075,8 +2075,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 @@ -2085,8 +2084,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 @@ -2100,8 +2098,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] @@ -2166,8 +2163,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 @@ -2176,8 +2172,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 @@ -2192,8 +2187,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 @@ -2207,8 +2201,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 @@ -2217,8 +2210,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 @@ -2333,7 +2325,7 @@ WOK 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}" @@ -2349,7 +2341,7 @@ WOK 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}" @@ -2365,7 +2357,7 @@ WOK 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:\/\// @@ -2374,7 +2366,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 @@ -2743,48 +2735,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 @@ -2982,7 +2968,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]={} @@ -2999,7 +2985,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]={} @@ -3877,7 +3863,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 @@ -5641,7 +5627,7 @@ WOK class InfoSkin def initialize(md=nil,skin=nil) @md=md - @d_sk=if skin.class==String + @d_sk=if skin.is_a?(String) skin elsif defined? md.doc_skin \ and md.doc_skin |