colours 0.5.48
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of colours might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/LICENCE.md +22 -0
- data/README.md +867 -0
- data/bin/colours +7 -0
- data/bin/html_colour_to_hex_value +7 -0
- data/bin/html_colourize +7 -0
- data/bin/print_rainbow_line +7 -0
- data/bin/rainbow_colours +7 -0
- data/colours.gemspec +75 -0
- data/doc/COLOUR_CODES_CHART.md +28 -0
- data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +29 -0
- data/doc/README.gen +850 -0
- data/lib/colours.rb +5 -0
- data/lib/colours/256_colours/support_for_256_colours.rb +180 -0
- data/lib/colours/autoalias_e.rb +10 -0
- data/lib/colours/autogenerated/README.md +2 -0
- data/lib/colours/autogenerated/support_for_256_colours.rb +2235 -0
- data/lib/colours/autogenerated/support_for_html_colours.rb +1778 -0
- data/lib/colours/autogenerated/toplevel_basic_colour_methods.rb +6366 -0
- data/lib/colours/autoinclude.rb +14 -0
- data/lib/colours/base/base.rb +23 -0
- data/lib/colours/basic_colours/README.md +4 -0
- data/lib/colours/basic_colours/basic_colours.rb +279 -0
- data/lib/colours/colour_methods/README.md +11 -0
- data/lib/colours/colour_methods/default_colour.rb +66 -0
- data/lib/colours/colour_methods/sargument.rb +70 -0
- data/lib/colours/colour_methods/scomments.rb +105 -0
- data/lib/colours/colour_methods/sdir.rb +66 -0
- data/lib/colours/colour_methods/sfancy.rb +84 -0
- data/lib/colours/colour_methods/sfile.rb +71 -0
- data/lib/colours/colour_methods/simportant.rb +92 -0
- data/lib/colours/colour_methods/snormal.rb +66 -0
- data/lib/colours/colour_methods/ssymlink.rb +102 -0
- data/lib/colours/colour_methods/swarn.rb +76 -0
- data/lib/colours/colour_table/README.md +3 -0
- data/lib/colours/colour_table/colour_table.rb +275 -0
- data/lib/colours/colours_e_autoinclude.rb +9 -0
- data/lib/colours/commandline/README.md +2 -0
- data/lib/colours/commandline/commandline.rb +44 -0
- data/lib/colours/commandline/menu.rb +111 -0
- data/lib/colours/constants/colour_constants.rb +299 -0
- data/lib/colours/constants/file_constants.rb +72 -0
- data/lib/colours/constants/hash_simple_colours.rb +146 -0
- data/lib/colours/constants/misc.rb +59 -0
- data/lib/colours/constants/newline.rb +14 -0
- data/lib/colours/constants/registered_colour_methods.rb +53 -0
- data/lib/colours/e.rb +5 -0
- data/lib/colours/e/README.md +13 -0
- data/lib/colours/e/autoinclude.rb +11 -0
- data/lib/colours/e/e.rb +35 -0
- data/lib/colours/eparse/eparse.rb +77 -0
- data/lib/colours/everything/autoinclude.rb +11 -0
- data/lib/colours/html_colours/README.md +1 -0
- data/lib/colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb +22 -0
- data/lib/colours/html_colours/hash_html_colours.rb +63 -0
- data/lib/colours/html_colours/html_colourize.rb +48 -0
- data/lib/colours/html_colours/is_this_html_colour_included.rb +64 -0
- data/lib/colours/html_colours/misc.rb +186 -0
- data/lib/colours/html_colours/show_html_colours.rb +85 -0
- data/lib/colours/kde_colour_palette/kde_colour_palette.rb +128 -0
- data/lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb +219 -0
- data/lib/colours/module.rb +11 -0
- data/lib/colours/project/project_base_directory.rb +22 -0
- data/lib/colours/rainbow_colours/README.md +2 -0
- data/lib/colours/rainbow_colours/check_for_trollop_being_available_or_exit.rb +26 -0
- data/lib/colours/rainbow_colours/constants.rb +30 -0
- data/lib/colours/rainbow_colours/do_parse_via_rainbow_colours.rb +164 -0
- data/lib/colours/rainbow_colours/paint_detected_mode.rb +20 -0
- data/lib/colours/rainbow_colours/print_rainbow_line.rb +68 -0
- data/lib/colours/rainbow_colours/println_ani.rb +32 -0
- data/lib/colours/rainbow_colours/println_plain.rb +36 -0
- data/lib/colours/rainbow_colours/rainbow.rb +38 -0
- data/lib/colours/rainbow_colours/report_errors.rb +32 -0
- data/lib/colours/rainbow_colours/returnln_plain.rb +63 -0
- data/lib/colours/rainbow_colours/set_mode.rb +24 -0
- data/lib/colours/requires/require_all_colour_methods.rb +5 -0
- data/lib/colours/requires/require_commandline.rb +7 -0
- data/lib/colours/requires/require_eparse.rb +11 -0
- data/lib/colours/requires/require_rgb.rb +5 -0
- data/lib/colours/requires/require_sdir.rb +5 -0
- data/lib/colours/requires/require_sfile.rb +5 -0
- data/lib/colours/requires/require_the_256_colours_module.rb +16 -0
- data/lib/colours/requires/require_the_basic_colours.rb +7 -0
- data/lib/colours/requires/require_the_colour_methods.rb +34 -0
- data/lib/colours/requires/require_the_colour_table.rb +7 -0
- data/lib/colours/requires/require_the_colours_project.rb +52 -0
- data/lib/colours/requires/require_the_constants.rb +11 -0
- data/lib/colours/requires/require_the_html_colours.rb +11 -0
- data/lib/colours/requires/require_the_kde_colour_palette.rb +7 -0
- data/lib/colours/requires/require_the_toplevel_methods.rb +42 -0
- data/lib/colours/revert/revert.rb +106 -0
- data/lib/colours/rgb/rgb.rb +547 -0
- data/lib/colours/testing/README.md +2 -0
- data/lib/colours/testing/testing.rb +157 -0
- data/lib/colours/toplevel_methods/bold.rb +35 -0
- data/lib/colours/toplevel_methods/bold_and_italic.rb +36 -0
- data/lib/colours/toplevel_methods/cat.rb +39 -0
- data/lib/colours/toplevel_methods/clear_screen.rb +18 -0
- data/lib/colours/toplevel_methods/cliner.rb +19 -0
- data/lib/colours/toplevel_methods/col.rb +56 -0
- data/lib/colours/toplevel_methods/e.rb +63 -0
- data/lib/colours/toplevel_methods/esystem.rb +19 -0
- data/lib/colours/toplevel_methods/fancy_parse.rb +79 -0
- data/lib/colours/toplevel_methods/html_colourize.rb +64 -0
- data/lib/colours/toplevel_methods/is_on_roebe.rb +16 -0
- data/lib/colours/toplevel_methods/italic.rb +104 -0
- data/lib/colours/toplevel_methods/make_colour.rb +29 -0
- data/lib/colours/toplevel_methods/methods_related_to_html_colours.rb +325 -0
- data/lib/colours/toplevel_methods/misc.rb +95 -0
- data/lib/colours/toplevel_methods/open_this_file.rb +26 -0
- data/lib/colours/toplevel_methods/prefer_this_colour_schemata.rb +80 -0
- data/lib/colours/toplevel_methods/random_html_colour.rb +44 -0
- data/lib/colours/toplevel_methods/random_value.rb +37 -0
- data/lib/colours/toplevel_methods/remove_escape_sequence.rb +107 -0
- data/lib/colours/toplevel_methods/set_last_colour_used.rb +32 -0
- data/lib/colours/toplevel_methods/show_basic_colour_palette.rb +36 -0
- data/lib/colours/toplevel_methods/underline.rb +114 -0
- data/lib/colours/toplevel_methods/use_colours.rb +290 -0
- data/lib/colours/utility_scripts/README.md +2 -0
- data/lib/colours/utility_scripts/autogenerate.rb +291 -0
- data/lib/colours/version/version.rb +25 -0
- data/lib/colours/yaml/256_colours.yml +277 -0
- data/lib/colours/yaml/basic_colours.yml +23 -0
- data/lib/colours/yaml/html_colours.yml +835 -0
- data/lib/colours/yaml/kde_colour_palette.yml +183 -0
- data/lib/colours/yaml/prefer_this_colour_schemata.yml +15 -0
- data/lib/colours/yaml/use_these_values_for_the_colour_methods.yml +13 -0
- data/test/test.html +18 -0
- data/test/testing_256_colours_support.rb +29 -0
- data/test/testing_col.rb +10 -0
- data/test/testing_colours.rb +95 -0
- data/test/testing_colours_e.rb +13 -0
- data/test/testing_eparse.rb +13 -0
- data/test/testing_kde_colour_palette.rb +30 -0
- data/test/testing_konsole_submodule.rb +226 -0
- data/test/testing_map_symbol_to_corresponding_colour.rb +14 -0
- data/test/testing_rgb_to_hex.rb +32 -0
- data/test/testing_the_basic_colours_of_the_colours_project.rb +58 -0
- data/test/testing_the_colour_methods.rb +36 -0
- data/test/testing_the_constants_of_the_colours_project.rb +9 -0
- data/test/testing_the_html_colours_of_the_colours_project.rb +37 -0
- data/test/testing_whether_colours_will_be_used.rb +7 -0
- metadata +224 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/constants/file_constants.rb'
|
6
|
+
# Colours.file_html_colours_to_rgb?
|
7
|
+
# =========================================================================== #
|
8
|
+
require 'colours/project/project_base_directory.rb'
|
9
|
+
|
10
|
+
module Colours
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# === Colours::FILE_HTML_COLOURS
|
14
|
+
# ========================================================================= #
|
15
|
+
FILE_HTML_COLOURS =
|
16
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/html_colours.yml"
|
17
|
+
|
18
|
+
# ========================================================================= #
|
19
|
+
# === Colours::FILE_KDE_COLOUR_PALETTE
|
20
|
+
# ========================================================================= #
|
21
|
+
FILE_KDE_COLOUR_PALETTE =
|
22
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/kde_colour_palette.yml"
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === Colours::FILE_256_COLOURS
|
26
|
+
# ========================================================================= #
|
27
|
+
FILE_256_COLOURS =
|
28
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/256_colours.yml"
|
29
|
+
|
30
|
+
# ========================================================================= #
|
31
|
+
# === Colours::FILE_BASIC_COLOURS
|
32
|
+
# ========================================================================= #
|
33
|
+
FILE_BASIC_COLOURS =
|
34
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/basic_colours.yml"
|
35
|
+
|
36
|
+
# ========================================================================= #
|
37
|
+
# === Colours::FILE_USE_THESE_VALUES_FOR_THE_COLOUR_METHODS
|
38
|
+
# ========================================================================= #
|
39
|
+
FILE_USE_THESE_VALUES_FOR_THE_COLOUR_METHODS =
|
40
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/use_these_values_for_the_colour_methods.yml"
|
41
|
+
|
42
|
+
# ========================================================================= #
|
43
|
+
# === Colours::FILE_PREFER_THIS_COLOUR_SCHEMATA
|
44
|
+
# ========================================================================= #
|
45
|
+
FILE_PREFER_THIS_COLOUR_SCHEMATA =
|
46
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/prefer_this_colour_schemata.yml"
|
47
|
+
|
48
|
+
# ========================================================================= #
|
49
|
+
# === Colours.file_html_colours_to_rgb?
|
50
|
+
#
|
51
|
+
# Easier toplevel-getter method to determine where the file for
|
52
|
+
# the html-colours-to-rgb conversion resides.
|
53
|
+
# ========================================================================= #
|
54
|
+
def self.file_html_colours_to_rgb?
|
55
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/html_colours.yml"
|
56
|
+
end
|
57
|
+
|
58
|
+
# ========================================================================= #
|
59
|
+
# === Colours.available_file_constants
|
60
|
+
# ========================================================================= #
|
61
|
+
def self.available_file_constants
|
62
|
+
[
|
63
|
+
FILE_HTML_COLOURS,
|
64
|
+
FILE_KDE_COLOUR_PALETTE
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
if __FILE__ == $PROGRAM_NAME
|
71
|
+
pp Colours.available_file_constants
|
72
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal = true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/constants/hash_simple_colours.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === Colours::HASH_SIMPLE_COLOURS
|
11
|
+
#
|
12
|
+
# This hash will only store one name for the corresponding colour code.
|
13
|
+
# ========================================================================= #
|
14
|
+
HASH_SIMPLE_COLOURS = {
|
15
|
+
black: '0;30',
|
16
|
+
red: '0;31',
|
17
|
+
green: '0;32',
|
18
|
+
yellow: '0;33',
|
19
|
+
blue: '0;34',
|
20
|
+
magenta: '0;35',
|
21
|
+
cyan: '0;36',
|
22
|
+
light_gray: '0;37',
|
23
|
+
# ======================================================================= #
|
24
|
+
# Next, the secondary-colours:
|
25
|
+
# ======================================================================= #
|
26
|
+
dark_gray: '1;30',
|
27
|
+
light_red: '1;31',
|
28
|
+
light_green: '1;32',
|
29
|
+
brown: '1;33',
|
30
|
+
light_blue: '1;34',
|
31
|
+
light_magenta: '1;35',
|
32
|
+
light_cyan: '1;36',
|
33
|
+
white: '1;37'
|
34
|
+
}
|
35
|
+
|
36
|
+
# ========================================================================= #
|
37
|
+
# === Colours::MAIN_COLOURS
|
38
|
+
#
|
39
|
+
# The main colours come next.
|
40
|
+
#
|
41
|
+
# Eight main colours are currently defined, according to:
|
42
|
+
#
|
43
|
+
# http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
44
|
+
#
|
45
|
+
# The range is:
|
46
|
+
#
|
47
|
+
# Intensity: 0 1 2 3 4 5 6 7
|
48
|
+
# Normal: Black Red Green Yellow Blue Magenta Cyan White
|
49
|
+
#
|
50
|
+
# Yellow, in my opinion, looks more like brown.
|
51
|
+
# ========================================================================= #
|
52
|
+
MAIN_COLOURS = %i(
|
53
|
+
black red green yellow blue magenta teal white
|
54
|
+
) # ^^^ An Array of Symbols.
|
55
|
+
|
56
|
+
# ========================================================================= #
|
57
|
+
# === Colours.available_main_colours?
|
58
|
+
#
|
59
|
+
# Feedback which main colours are available.
|
60
|
+
# ========================================================================= #
|
61
|
+
def self.available_main_colours?
|
62
|
+
MAIN_COLOURS
|
63
|
+
end; self.instance_eval { alias available_basic_colours? available_main_colours? } # === Colours.available_basic_colours?
|
64
|
+
|
65
|
+
# ========================================================================= #
|
66
|
+
# === main_colours
|
67
|
+
#
|
68
|
+
# This will return an Array with the symbols such as
|
69
|
+
# :black, :red etc..
|
70
|
+
# ========================================================================= #
|
71
|
+
def main_colours
|
72
|
+
::Colours.available_main_colours?
|
73
|
+
end
|
74
|
+
|
75
|
+
# ========================================================================= #
|
76
|
+
# === Colours::SECONDARY_COLOURS
|
77
|
+
#
|
78
|
+
# The secondary Colours.
|
79
|
+
#
|
80
|
+
# Colours which are not part of the MAIN_COLOURS Array.
|
81
|
+
#
|
82
|
+
# The secondary colours are:
|
83
|
+
#
|
84
|
+
# Bright Black
|
85
|
+
# Bright Red
|
86
|
+
# Bright Green
|
87
|
+
# Bright Yellow
|
88
|
+
# Bright Blue
|
89
|
+
# Bright Magenta
|
90
|
+
# Bright Cyan
|
91
|
+
# Bright White
|
92
|
+
#
|
93
|
+
# ========================================================================= #
|
94
|
+
SECONDARY_COLOURS = [
|
95
|
+
:bright_black,
|
96
|
+
:bright_red,
|
97
|
+
:bright_green,
|
98
|
+
:bright_yellow,
|
99
|
+
:bright_blue,
|
100
|
+
:bright_magenta,
|
101
|
+
:bright_cyan,
|
102
|
+
:bright_white
|
103
|
+
]
|
104
|
+
|
105
|
+
# ========================================================================= #
|
106
|
+
# === ALL_COLOURS
|
107
|
+
#
|
108
|
+
# Simply combine the two Arrays, MAIN_COLOURS and SECONDARY_COLOURS,
|
109
|
+
# into one aggregate Array.
|
110
|
+
# ========================================================================= #
|
111
|
+
ALL_COLOURS = MAIN_COLOURS +
|
112
|
+
SECONDARY_COLOURS
|
113
|
+
|
114
|
+
# ========================================================================= #
|
115
|
+
# === Colours.really_all_colours
|
116
|
+
#
|
117
|
+
# This method will return an Array that may look like this:
|
118
|
+
#
|
119
|
+
# [:black, :red, :green, :yellow, :blue, :magenta, :teal,
|
120
|
+
# :white, :bright_black, :bright_red, :bright_green,
|
121
|
+
# :bright_yellow, :bright_blue, :bright_magenta,
|
122
|
+
# :bright_cyan, :bright_white]
|
123
|
+
#
|
124
|
+
# ========================================================================= #
|
125
|
+
def self.really_all_colours
|
126
|
+
ALL_COLOURS # This is the conjoint Array.
|
127
|
+
end; self.instance_eval { alias all_available_colours really_all_colours } # === Colours.all_available_colours
|
128
|
+
|
129
|
+
# ========================================================================= #
|
130
|
+
# === Colours.is_a_valid_colour?
|
131
|
+
#
|
132
|
+
# This method allows you to check if a given input-string is a
|
133
|
+
# valid colour.
|
134
|
+
#
|
135
|
+
# A "valid" colour is one that the colours project supports.
|
136
|
+
#
|
137
|
+
# For example, the string "lightblue" is a valid colour.
|
138
|
+
#
|
139
|
+
# Usage example:
|
140
|
+
# Colours.is_a_valid_colour? 'lightblue'
|
141
|
+
# ========================================================================= #
|
142
|
+
def self.is_a_valid_colour?(i)
|
143
|
+
ALL_COLOURS.include? i.to_sym
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal = true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/constants/misc.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === HOME_DIRECTORY_OF_USER_X
|
11
|
+
# ========================================================================= #
|
12
|
+
HOME_DIRECTORY_OF_USER_X = '/home/x/'
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === Colours::DEFAULT_TEXT
|
16
|
+
# ========================================================================= #
|
17
|
+
DEFAULT_TEXT = 'Hello World!'
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === Colours::IS_A_TEST
|
21
|
+
# ========================================================================= #
|
22
|
+
IS_A_TEST = ' This is just a simple colour test.'
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === Colours::TEST_FILE
|
26
|
+
# ========================================================================= #
|
27
|
+
TEST_FILE =
|
28
|
+
"#{HOME_DIRECTORY_OF_USER_X}DATA/PROGRAMMING_LANGUAGES/RUBY/src/colours/test/testing_konsole_submodule.rb"
|
29
|
+
|
30
|
+
# ========================================================================= #
|
31
|
+
# === LEFT
|
32
|
+
#
|
33
|
+
# Leading on the left side, for RGB value setting. This is the beginning
|
34
|
+
# of a special instruction. Note that "\e[38" should be equal to "\x1b",
|
35
|
+
# but IRB reports that this is not the case so.
|
36
|
+
#
|
37
|
+
# Examples on the www show usage such as this:
|
38
|
+
#
|
39
|
+
# printf "\x1b[${bg};2;${red};${green};${blue}m\n"
|
40
|
+
# printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
|
41
|
+
#
|
42
|
+
# ========================================================================= #
|
43
|
+
LEFT = "\e[38;2;".dup
|
44
|
+
|
45
|
+
# ========================================================================= #
|
46
|
+
# === Colours.left?
|
47
|
+
# ========================================================================= #
|
48
|
+
def self.left?
|
49
|
+
LEFT
|
50
|
+
end
|
51
|
+
|
52
|
+
# ========================================================================= #
|
53
|
+
# === left?
|
54
|
+
# ========================================================================= #
|
55
|
+
def left?
|
56
|
+
Colours.left?
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/constants/newline.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === N
|
11
|
+
# ========================================================================= #
|
12
|
+
N = "\n"
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/constants/registered_colour_methods.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === Colours::REGISTERED_COLOUR_METHODS
|
11
|
+
#
|
12
|
+
# These methods constitute the registered colour methods.
|
13
|
+
#
|
14
|
+
# These have a corresponding method, such as snormal() or sdir() or
|
15
|
+
# sfile().
|
16
|
+
#
|
17
|
+
# snormal() stands for the "normal" colour, aka the "default
|
18
|
+
# colour".
|
19
|
+
# ========================================================================= #
|
20
|
+
REGISTERED_COLOUR_METHODS = %i(
|
21
|
+
snormal
|
22
|
+
sargument
|
23
|
+
scomments
|
24
|
+
ssymlink
|
25
|
+
sdir
|
26
|
+
sfile
|
27
|
+
sfancy
|
28
|
+
simportant
|
29
|
+
swarn
|
30
|
+
)
|
31
|
+
|
32
|
+
# ========================================================================= #
|
33
|
+
# === REGISTERED_COLOUR_METHODS_ALIASES
|
34
|
+
#
|
35
|
+
# This Array should hold all aliases to the main colour-methods,
|
36
|
+
# such as simportant() or sargument().
|
37
|
+
# ========================================================================= #
|
38
|
+
REGISTERED_COLOUR_METHODS_ALIASES = %i(
|
39
|
+
argument
|
40
|
+
ssym
|
41
|
+
simp
|
42
|
+
sarg
|
43
|
+
normal
|
44
|
+
comments
|
45
|
+
symlink
|
46
|
+
dir
|
47
|
+
file
|
48
|
+
fancy
|
49
|
+
important
|
50
|
+
warn
|
51
|
+
)
|
52
|
+
|
53
|
+
end
|
data/lib/colours/e.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
The directory here exists for the submodule called E.
|
2
|
+
|
3
|
+
The reason for this strange name is that I used to do
|
4
|
+
this a lot in ruby:
|
5
|
+
|
6
|
+
alias e puts
|
7
|
+
|
8
|
+
So in other words, I would be using "e" rather than
|
9
|
+
puts, in order to do output.
|
10
|
+
|
11
|
+
I also used to have this in another project called AliasE,
|
12
|
+
but eventually I decided that I should put this right
|
13
|
+
into the Colours project.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# This .rb file will just autoinclude Colours::E into the main namespace.
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'colours/e/autoinclude.rb'
|
8
|
+
# =========================================================================== #
|
9
|
+
require 'colours/e/e.rb'
|
10
|
+
|
11
|
+
include Colours::E
|
data/lib/colours/e/e.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === Colours::E
|
6
|
+
#
|
7
|
+
# require 'colours/e/e.rb'
|
8
|
+
# include ::Colours::E
|
9
|
+
# =========================================================================== #
|
10
|
+
module Colours
|
11
|
+
|
12
|
+
module E # === Colours::E
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === Colours::E.e
|
16
|
+
# ========================================================================= #
|
17
|
+
def self.e(i = '')
|
18
|
+
if i.is_a? Array
|
19
|
+
i = i.join(' ')
|
20
|
+
end
|
21
|
+
puts i
|
22
|
+
end; self.instance_eval { alias [] e } # === Colours::E[]
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === e
|
26
|
+
# ========================================================================= #
|
27
|
+
def e(i = '')
|
28
|
+
::Colours::E.e(i)
|
29
|
+
end
|
30
|
+
|
31
|
+
end; end
|
32
|
+
|
33
|
+
if __FILE__ == $PROGRAM_NAME
|
34
|
+
Colours::E.e(ARGV)
|
35
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/eparse/eparse.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'colours/toplevel_methods/e.rb'
|
8
|
+
require 'colours/constants/colour_constants.rb'
|
9
|
+
|
10
|
+
module Colours
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# === Colours.eparse
|
14
|
+
#
|
15
|
+
# This method primarily exists because we can easily split a string
|
16
|
+
# if it has a '#' token. The part that comes after the '#' token is
|
17
|
+
# assumed to be a comment or an explanation.
|
18
|
+
# ========================================================================= #
|
19
|
+
def self.eparse(i = '')
|
20
|
+
Colours.e(rparse(i))
|
21
|
+
end
|
22
|
+
|
23
|
+
# ========================================================================= #
|
24
|
+
# === Colours.rparse
|
25
|
+
#
|
26
|
+
# This method will return a string; the method eparse will output that
|
27
|
+
# (colourized) String.
|
28
|
+
# ========================================================================= #
|
29
|
+
def self.rparse(i = '')
|
30
|
+
_ = i.to_s # We require a String.
|
31
|
+
split_at = ':' # <- Split at this character.
|
32
|
+
# ======================================================================== #
|
33
|
+
# If the input does not include a ':' but it does include a '#', then
|
34
|
+
# we will use that character instead.
|
35
|
+
#
|
36
|
+
# However had, as of Jun 2017, I have disabled that check. Now '#' will
|
37
|
+
# always overrule. My reasoning now is that '#' is more important than
|
38
|
+
# ':', if it is part of the input-string.
|
39
|
+
# ======================================================================== #
|
40
|
+
split_at = '#' if _.include? '#'
|
41
|
+
first_colour = COLOUR_GREEN
|
42
|
+
second_colour = COLOUR_TEAL
|
43
|
+
if i.include? split_at
|
44
|
+
splitted = _.split(split_at)
|
45
|
+
_ = first_colour+
|
46
|
+
splitted.first+
|
47
|
+
split_at+
|
48
|
+
second_colour+
|
49
|
+
splitted[1..-1].join(split_at).dup
|
50
|
+
_ << REVERT
|
51
|
+
elsif i.include? ' '
|
52
|
+
split_at = ' '
|
53
|
+
splitted = _.split(/ /)
|
54
|
+
index = splitted.find_index {|e| ! e.empty? }
|
55
|
+
_ = first_colour+splitted[0..index].join(' ')+split_at+
|
56
|
+
second_colour+splitted[index+1..-1].join(' ').dup
|
57
|
+
_ << REVERT
|
58
|
+
end
|
59
|
+
return _
|
60
|
+
end
|
61
|
+
|
62
|
+
# ========================================================================== #
|
63
|
+
# === eparse (eparse tag)
|
64
|
+
#
|
65
|
+
# Input could be like this:
|
66
|
+
# eparse 'Foo: bla'
|
67
|
+
# eparse 'Foo: '+bla
|
68
|
+
# ========================================================================== #
|
69
|
+
def eparse(i = '')
|
70
|
+
Colours.eparse(i)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
if __FILE__ == $PROGRAM_NAME
|
76
|
+
Colours.eparse('Hello there # how do you do, this is a test')
|
77
|
+
end
|