Class: LogPlugin

Inherits:
Rubko::Plugin show all
Defined in:
lib/rubko/plugins/log.rb

Constant Summary collapse

Colors =
{
	black: 0,
	red: 1,
	green: 2,
	yellow: 3,
	blue: 4,
	magenta: 5,
	cyan: 6,
	white: 7,
	default: 9,
}

Instance Attribute Summary

Attributes included from Rubko::Base

#parent

Instance Method Summary collapse

Methods inherited from Rubko::Plugin

#config

Methods included from Rubko::Base

#camelize, #finalize, #httpGet, #initialize, #jsonParse, #loadController, #loadFile, #loadModel, #loadPlugin, #loadView, #uncamelize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *params) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/rubko/plugins/log.rb', line 41

def method_missing(name, *params)
	unless @mapper && @mapper.key?(name)
		return super
	end

	clr = name.hash/2%7 + 1
	puts "#{color clr, 1}#{name.to_s.upcase}:#{reset} #{params * ', '}"
end

Instance Method Details

#bg(color = 0) ⇒ Object



33
34
35
# File 'lib/rubko/plugins/log.rb', line 33

def bg(color = 0)
	mark color+40
end

#color(color = 0, bold = 0) ⇒ Object



29
30
31
# File 'lib/rubko/plugins/log.rb', line 29

def color(color = 0, bold = 0)
	mark bold, color+30
end

#initObject



3
4
5
6
7
8
9
10
# File 'lib/rubko/plugins/log.rb', line 3

def init
	@mapper = {
		sql: [:term, :file],
		time: [:term],
		debug: [:term],
	}
	config
end

#mark(*what) ⇒ Object



24
25
26
27
# File 'lib/rubko/plugins/log.rb', line 24

def mark(*what)
	insert = what.map(&:to_s).join ';'
	"\033[#{insert}m"
end

#resetObject



37
38
39
# File 'lib/rubko/plugins/log.rb', line 37

def reset
	mark 0
end