From 9f10ff9b7667f7e62cf17943dc6dae5a260776bd Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 5 Feb 2014 18:31:28 -0500 Subject: v5 v6: utils, code markers & messages, notes/warning/errors, fix --- lib/sisu/v5/ao_images.rb | 12 ++++++------ lib/sisu/v5/utils.rb | 46 +++++++++++++++++++++++++++++++++++----------- lib/sisu/v6/ao_images.rb | 12 ++++++------ lib/sisu/v6/utils.rb | 46 +++++++++++++++++++++++++++++++++++----------- 4 files changed, 82 insertions(+), 34 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_images.rb b/lib/sisu/v5/ao_images.rb index d01c98b8..b72f66a3 100644 --- a/lib/sisu/v5/ao_images.rb +++ b/lib/sisu/v5/ao_images.rb @@ -62,12 +62,12 @@ =end module SiSU_AO_Images class Images - #begin - # require 'RMagick' - # include Magick - #rescue LoadError - # SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('RMagic NOT FOUND (LoadError)') - #end + begin + require 'RMagick' + include Magick + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('RMagic NOT FOUND') + end def initialize(md,data) @md,@data=md,data end diff --git a/lib/sisu/v5/utils.rb b/lib/sisu/v5/utils.rb index 1c04d886..4894df9d 100644 --- a/lib/sisu/v5/utils.rb +++ b/lib/sisu/v5/utils.rb @@ -95,23 +95,29 @@ module SiSU_Utils end def var(v,x) h={ c: nil, m: '' } - if v.class == Hash + if v.is_a?(Hash) h[:c] = (defined? v[:c]) ? v[:c] : '' h[:m] = (defined? v[:m]) ? v[:m] : '' - else - if v.class == Symbol + elsif (v.is_a?(Symbol) \ + and x.is_a?(String)) + if v.is_a?(Symbol) h[:c]=v - elsif v.class == String + elsif v.is_a?(String) h[:m]=v end - if x.class == Symbol - h[:c]=x - elsif x.class == String + if x.is_a?(String) h[:m]=x end - h[:c] = (defined? h[:c]) ? h[:c] : '' - h[:m] = (defined? h[:m]) ? h[:m] : '' + elsif (v.is_a?(Symbol) \ + or v.is_a?(String)) + if v.is_a?(Symbol) + h[:c]=v + elsif v.is_a?(String) + h[:m]=v + end end + h[:c] = (defined? h[:c]) ? h[:c] : '' + h[:m] = (defined? h[:m]) ? h[:m] : '' h[:c]=ansi(h[:c]) h[:m]=message(h[:m]) h @@ -128,10 +134,28 @@ module SiSU_Utils puts set(v,x) end def warn(v=nil,x=nil) - STDERR.puts set(v,'*WARN* ' + x) + if (v.is_a?(Symbol) \ + and x.is_a?(String)) + x= '*WARN* ' + x + elsif v.is_a?(String) + v='*WARN* ' + v + x=nil + else + v,x='*WARN*',nil + end + STDERR.puts set(v,x) end def error(v=nil,x=nil) - STDERR.puts set(v,'*ERROR* ' + x) + if (v.is_a?(Symbol) \ + and x.is_a?(String)) + x= '*ERROR* ' + x + elsif v.is_a?(String) + v='*ERROR* ' + v + x=nil + else + v,x='*ERROR*',nil + end + STDERR.puts set(v,x) end end class Path diff --git a/lib/sisu/v6/ao_images.rb b/lib/sisu/v6/ao_images.rb index 0279994d..05bc8e63 100644 --- a/lib/sisu/v6/ao_images.rb +++ b/lib/sisu/v6/ao_images.rb @@ -62,12 +62,12 @@ =end module SiSU_AO_Images class Images - #begin - # require 'RMagick' - # include Magick - #rescue LoadError - # SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('RMagic NOT FOUND (LoadError)') - #end + begin + require 'RMagick' + include Magick + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('RMagic NOT FOUND') + end def initialize(md,data) @md,@data=md,data end diff --git a/lib/sisu/v6/utils.rb b/lib/sisu/v6/utils.rb index 60925f22..8f9e17b8 100644 --- a/lib/sisu/v6/utils.rb +++ b/lib/sisu/v6/utils.rb @@ -95,23 +95,29 @@ module SiSU_Utils end def var(v,x) h={ c: nil, m: '' } - if v.class == Hash + if v.is_a?(Hash) h[:c] = (defined? v[:c]) ? v[:c] : '' h[:m] = (defined? v[:m]) ? v[:m] : '' - else - if v.class == Symbol + elsif (v.is_a?(Symbol) \ + and x.is_a?(String)) + if v.is_a?(Symbol) h[:c]=v - elsif v.class == String + elsif v.is_a?(String) h[:m]=v end - if x.class == Symbol - h[:c]=x - elsif x.class == String + if x.is_a?(String) h[:m]=x end - h[:c] = (defined? h[:c]) ? h[:c] : '' - h[:m] = (defined? h[:m]) ? h[:m] : '' + elsif (v.is_a?(Symbol) \ + or v.is_a?(String)) + if v.is_a?(Symbol) + h[:c]=v + elsif v.is_a?(String) + h[:m]=v + end end + h[:c] = (defined? h[:c]) ? h[:c] : '' + h[:m] = (defined? h[:m]) ? h[:m] : '' h[:c]=ansi(h[:c]) h[:m]=message(h[:m]) h @@ -128,10 +134,28 @@ module SiSU_Utils puts set(v,x) end def warn(v=nil,x=nil) - STDERR.puts set(v,'*WARN* ' + x) + if (v.is_a?(Symbol) \ + and x.is_a?(String)) + x= '*WARN* ' + x + elsif v.is_a?(String) + v='*WARN* ' + v + x=nil + else + v,x='*WARN*',nil + end + STDERR.puts set(v,x) end def error(v=nil,x=nil) - STDERR.puts set(v,'*ERROR* ' + x) + if (v.is_a?(Symbol) \ + and x.is_a?(String)) + x= '*ERROR* ' + x + elsif v.is_a?(String) + v='*ERROR* ' + v + x=nil + else + v,x='*ERROR*',nil + end + STDERR.puts set(v,x) end end class Path -- cgit v1.2.3