aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v4
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2012-12-28 12:18:24 -0500
committerRalph Amissah <ralph@amissah.com>2012-12-28 12:18:24 -0500
commit6998914adc0bacd41398ab0ed3d2f0bf5af74358 (patch)
treeeb33a62ac5d18b8269b3a82a056a4360ba18f30c /lib/sisu/v4
parentv4 (v3): 4.0.1 (3.3.4) new branch & version & changelog "opened" (diff)
v4 v3: debug (internal code use), color markers for line number & file name
* colored location markers to show when line passed within running code
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r--lib/sisu/v4/constants.rb27
-rw-r--r--lib/sisu/v4/debug.rb109
-rw-r--r--lib/sisu/v4/hub.rb1
3 files changed, 137 insertions, 0 deletions
diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb
index af5c13a4..02bbc286 100644
--- a/lib/sisu/v4/constants.rb
+++ b/lib/sisu/v4/constants.rb
@@ -243,6 +243,27 @@ S_CONF={
header_make: 'sisu_document_make',
rc_yml: 'sisurc.yml',
}
+ANSI_C={
+ red: "\033[#{31}m",
+ green: "\033[#{32}m",
+ yellow: "\033[#{33}m",
+ blue: "\033[#{34}m",
+ fuchsia: "\033[#{35}m",
+ cyan: "\033[#{36}m",
+ inv_red: "\033[#{41}m",
+ inv_green: "\033[#{42}m",
+ inv_yellow: "\033[#{43}m",
+ inv_blue: "\033[#{44}m",
+ inv_fuchsia: "\033[#{45}m",
+ inv_cyan: "\033[#{46}m",
+ b_red: "\033[#{91}m",
+ b_green: "\033[#{92}m",
+ b_yellow: "\033[#{93}m",
+ b_blue: "\033[#{94}m",
+ b_fuchsia: "\033[#{95}m",
+ b_cyan: "\033[#{96}m",
+ off: "\033[m"
+}
DISABLE={
epub: {
internal_navigation: true,
@@ -254,6 +275,12 @@ DEVELOPER={
maintenance: :false,
}
__END__
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:red).set
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:green)
+puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__
+puts "#{ANSI_C[:red]} #{__LINE__.to_s} #{ANSI_C[:off]} #{__FILE__}"
+puts ANSI_C[:fuchsia] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:fuchsia]}\\1#{ANSI_C[:off]}")
+puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:red]}\\1#{ANSI_C[:off]}")
consider:
〔comment〕
〔links?????〕
diff --git a/lib/sisu/v4/debug.rb b/lib/sisu/v4/debug.rb
new file mode 100644
index 00000000..6be60576
--- /dev/null
+++ b/lib/sisu/v4/debug.rb
@@ -0,0 +1,109 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012 Ralph Amissah, All Rights Reserved.
+
+ * License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+ * Download:
+ <http://www.sisudoc.org/sisu/en/SiSU/download.html>
+
+ * Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+ ** Description: system environment, debug related
+
+=end
+module SiSU_Debug
+ class Mark
+ def initialize(line,file,color=:red)
+ @line,@file,@color=line.to_s,file,color
+ end
+ def ansi(color=nil)
+ @color=color ? color : @color
+ c={}
+ c[:on]=case @color
+ when :red; ANSI_C[:red]
+ when :green; ANSI_C[:green]
+ when :yellow; ANSI_C[:yellow]
+ when :blue; ANSI_C[:blue]
+ when :fuchsia; ANSI_C[:fuchsia]
+ when :cyan; ANSI_C[:cyan]
+ when :inv_red; ANSI_C[:inv_red]
+ when :inv_green; ANSI_C[:inv_green]
+ when :inv_yellow; ANSI_C[:inv_yellow]
+ when :inv_blue; ANSI_C[:inv_blue]
+ when :inv_fuchsia; ANSI_C[:inv_fuchsia]
+ when :inv_cyan; ANSI_C[:inv_cyan]
+ when :b_red; ANSI_C[:b_red]
+ when :b_green; ANSI_C[:b_green]
+ when :b_yellow; ANSI_C[:b_yellow]
+ when :b_blue; ANSI_C[:b_blue]
+ when :b_fuchsia; ANSI_C[:b_fuchsia]
+ when :b_cyan; ANSI_C[:b_cyan]
+ else ANSI_C[:red]
+ end
+ c[:off]= ANSI_C[:off]
+ #ansi_color + @line.to_s + ansi_color_off + ' ' + @file.gsub(/([^\/]+$)/,"#{ansi_color}\\1#{ansi_color_off}")
+ c
+ end
+ def set(color=nil)
+ c=ansi(color)
+ file,path=File.basename(@file),File.dirname(@file)
+ c[:on] + @line + c[:off] + ' ' + path + '/' "#{c[:on]}#{file}#{c[:off]}"
+ end
+ def set_(color=nil)
+ c=ansi(color)
+ c[:on] + @line + c[:off] + ' ' +
+ @file.gsub(/([^\/]+$)/,"#{c[:on]}\\1#{c[:off]}")
+ end
+ end
+end
+__END__
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:red)
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:green)
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:inv_red)
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:red).set
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:green).set
+puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:inv_red).set
diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb
index 02762d4a..da5b785e 100644
--- a/lib/sisu/v4/hub.rb
+++ b/lib/sisu/v4/hub.rb
@@ -68,6 +68,7 @@ module SiSU
include SiSU_Viz
require_relative 'help' # help.rb
include SiSU_Help
+ require_relative 'debug' # debug.rb
require 'uri'
class HubMaster
def initialize(argv)