Class: Mrdbg

Inherits:
Object
  • Object
show all
Defined in:
lib/mrdbg.rb

Instance Method Summary collapse

Constructor Details

#initializeMrdbg

Returns a new instance of Mrdbg.



9
10
11
# File 'lib/mrdbg.rb', line 9

def initialize
	@loglevel = 3
end

Instance Method Details

#b(bind) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/mrdbg.rb', line 49

def b bind
        color_s = "\033[1m\033[31m"
        color_f = "\033[0m\033[22m"
        line= (caller.first.split ":")[1]
	vars = (eval('local_variables',bind) | eval('instance_variables',bind)).map{|v| "#{v.to_s}= #{eval(v.to_s,bind)}"}.join ";"
        puts "#{color_s}#{Time.new.strftime("%H:%M:%S")} line:#{line} -- #{vars}#{color_f}"
	begin
		print "\033[31m"
		begin
			s = Readline.readline("dbg> ",true).strip
			if s == "" then break end
			eval ("puts ' = ' + (#{s}).to_s"),bind
		rescue => e
			puts " > Error ocurred: \033[1m#{e.backtrace[0]}: #{e.message}\033[22m"
		end while true
	ensure
		print "\033[0m"
	end
end

#d(s) ⇒ Object



29
30
31
32
33
34
# File 'lib/mrdbg.rb', line 29

def d(s)
	color_s = "\033[1m\033[33m"
	color_f = "\033[0m\033[22m"
	line= (caller.first.split ":")[1]
	puts "#{color_s}#{Time.new.strftime("%H:%M:%S")} line:#{line} -- #{s.to_s}#{color_f}"
end

#e(n, s) ⇒ Object



43
44
45
46
47
48
# File 'lib/mrdbg.rb', line 43

def e(n,s)
	color_s = "\033[1m\033[31m"
	color_f = "\033[0m\033[22m"
	space = " " *n
	puts "#{color_s}#{Time.new.strftime("%H:%M:%S")} #{space} #{s.to_s}#{color_f}"
end

#l(n, s) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/mrdbg.rb', line 35

def l(n,s)
   	if n <= @loglevel then
		color_s = "\033[1m\033[34m"
		color_f = "\033[0m\033[22m"
		space = " " * n
		puts "#{color_s}#{Time.new.strftime("%H:%M:%S")} #{space} #{s.to_s}#{color_f}"
   	end
end

#set_blue(s) ⇒ Object



17
18
19
# File 'lib/mrdbg.rb', line 17

def set_blue s
        return "#{BLUE}#{s}#{COLOREND}"
end

#set_bold(s) ⇒ Object



25
26
27
# File 'lib/mrdbg.rb', line 25

def set_bold s
        return "#{BOLD}#{s}#{BOLDEND}"
end

#set_loglevel(l) ⇒ Object



5
6
7
# File 'lib/mrdbg.rb', line 5

def set_loglevel l
	@loglevel = l
end

#set_red(s) ⇒ Object



13
14
15
# File 'lib/mrdbg.rb', line 13

def set_red s
	return "#{RED}#{s}#{COLOREND}"
end

#set_yellow(s) ⇒ Object



21
22
23
# File 'lib/mrdbg.rb', line 21

def set_yellow s
        return "#{YELLOW}#{s}#{COLOREND}"
end

#x(bind) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/mrdbg.rb', line 68

def x bind
        color_s = "\033[1m\033[33m"
        color_f = "\033[0m\033[22m"
        puts "#{color_s}Execuation mode: #{color_f}"
        begin
                print "\033[33m"
                begin
                  s = Readline.readline("exe> ",true).strip
                  if s == "" then break end
                  eval ("puts ' = ' + (#{s}).to_s"),bind
                rescue => e
                  puts " > Error ocurred: \033[1m#{e.backtrace[0]}: #{e.message}\033[22m"
                end while true
        ensure
                print "\033[0m"
        end
end