File: colour.rb

package info (click to toggle)
whatweb 0.6.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 23,948 kB
  • sloc: ruby: 43,493; sh: 213; makefile: 41
file content (79 lines) | stat: -rw-r--r-- 1,639 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright 2009 to 2025 Andrew Horton and Brendan Coles
#
# This file is part of WhatWeb.
#
# WhatWeb 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 2 of the License, or
# at your option) any later version.
#
# WhatWeb 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 WhatWeb.  If not, see <http://www.gnu.org/licenses/>.

def colorize(text, color_code)
  "#{color_code}#{text}\e[0m"
end

def red(text)
  colorize(text, "\e[1m\e[31m")
end

def dark_red(text)
  colorize(text, "\e[31m")
end

def green(text)
  colorize(text, "\e[1m\e[32m")
end

def dark_green(text)
  colorize(text, "\e[32m")
end

def yellow(text)
  colorize(text, "\e[1m\e[33m")
end

def dark_yellow(text)
  colorize(text, "\e[33m")
end

def blue(text)
  colorize(text, "\e[1m\e[34m")
end

def dark_blue(text)
  colorize(text, "\e[34m")
end

def magenta(text)
  colorize(text, "\e[1m\e[35m")
end

def dark_magenta(text)
  colorize(text, "\e[35m")
end

def cyan(text)
  colorize(text, "\e[1m\e[36m")
end

def dark_cyan(text)
  colorize(text, "\e[36m")
end

def white(text)
  # quick patch for issue #345 so it's readable with a white terminal background
  # not white, but bold
  colorize(text, "\e[1m")
end

def grey(text)
  # not grey, but reset
  colorize(text, "\e[0m\e[22m")
end