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 --- data/doc/sisu/CHANGELOG_v5 | 2 ++ data/doc/sisu/CHANGELOG_v6 | 2 ++ 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 +++++++++++++++++++++++++++++++++++----------- 6 files changed, 86 insertions(+), 34 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 7d080634..cf224b05 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -40,6 +40,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.3.2.orig.tar.xz * ao, html book index linking, follow --strict option +* utils, code markers & messages, notes/warning/errors, fix + %% 5.3.1.orig.tar.xz (2014-02-05:05/3) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.3.1 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.3.1-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index fe534781..d2ce1f19 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -30,6 +30,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.2.orig.tar.xz * ao, html book index linking, follow --strict option +* utils, code markers & messages, notes/warning/errors, fix + %% 6.0.1.orig.tar.xz (2014-02-05:05/3) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.1 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.1-1 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