colours 0.8.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/LICENCE.md +22 -0
  3. data/README.md +1152 -0
  4. data/bin/colours +7 -0
  5. data/bin/egreen +7 -0
  6. data/bin/fancy_parse +7 -0
  7. data/bin/html_colour_to_hex_value +7 -0
  8. data/bin/html_colourize +7 -0
  9. data/bin/orange +7 -0
  10. data/bin/print_rainbow_line +7 -0
  11. data/bin/rainbow_colours +7 -0
  12. data/bin/remove_ansii_escape_sequences +7 -0
  13. data/bin/steelblue +7 -0
  14. data/colours.gemspec +74 -0
  15. data/doc/COLOUR_CODES_CHART.md +27 -0
  16. data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +28 -0
  17. data/doc/README.gen +1105 -0
  18. data/doc/todo/todo.md +25 -0
  19. data/lib/colours/256_colours/support_for_256_colours.rb +196 -0
  20. data/lib/colours/autoalias_e.rb +10 -0
  21. data/lib/colours/autogenerated/README.md +2 -0
  22. data/lib/colours/autogenerated/support_for_256_colours.rb +2235 -0
  23. data/lib/colours/autogenerated/support_for_html_colours.rb +1778 -0
  24. data/lib/colours/autogenerated/toplevel_basic_colour_methods.rb +7001 -0
  25. data/lib/colours/autoinclude.rb +14 -0
  26. data/lib/colours/base/base.rb +29 -0
  27. data/lib/colours/basic_colours/README.md +4 -0
  28. data/lib/colours/basic_colours/basic_colours.rb +334 -0
  29. data/lib/colours/class/colours.rb +537 -0
  30. data/lib/colours/colour_methods/README.md +11 -0
  31. data/lib/colours/colour_methods/colour_methods.rb +685 -0
  32. data/lib/colours/colour_table/README.md +2 -0
  33. data/lib/colours/colour_table/colour_table.rb +282 -0
  34. data/lib/colours/colours_e_autoinclude.rb +9 -0
  35. data/lib/colours/commandline/README.md +2 -0
  36. data/lib/colours/commandline/commandline.rb +58 -0
  37. data/lib/colours/commandline/menu.rb +122 -0
  38. data/lib/colours/constants/constants.rb +9 -0
  39. data/lib/colours/constants/escape.rb +22 -0
  40. data/lib/colours/constants/file_constants.rb +73 -0
  41. data/lib/colours/constants/hash_ansi_colours.rb +39 -0
  42. data/lib/colours/constants/hash_simple_colours.rb +148 -0
  43. data/lib/colours/constants/misc.rb +361 -0
  44. data/lib/colours/constants/newline.rb +14 -0
  45. data/lib/colours/constants/registered_colour_methods.rb +53 -0
  46. data/lib/colours/e/README.md +13 -0
  47. data/lib/colours/e/autoinclude.rb +11 -0
  48. data/lib/colours/e/e.rb +35 -0
  49. data/lib/colours/e.rb +5 -0
  50. data/lib/colours/eparse/eparse.rb +114 -0
  51. data/lib/colours/everything/autoinclude.rb +11 -0
  52. data/lib/colours/html_colours/README.md +1 -0
  53. data/lib/colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb +22 -0
  54. data/lib/colours/html_colours/html_colours.rb +424 -0
  55. data/lib/colours/kde_colour_palette/kde_colour_palette.rb +132 -0
  56. data/lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb +224 -0
  57. data/lib/colours/module.rb +11 -0
  58. data/lib/colours/project/project.rb +22 -0
  59. data/lib/colours/rainbow_colours/README.md +2 -0
  60. data/lib/colours/rainbow_colours/check_for_trollop_being_available_or_exit.rb +26 -0
  61. data/lib/colours/rainbow_colours/constants.rb +30 -0
  62. data/lib/colours/rainbow_colours/do_parse_via_rainbow_colours.rb +164 -0
  63. data/lib/colours/rainbow_colours/paint_detected_mode.rb +20 -0
  64. data/lib/colours/rainbow_colours/print_rainbow_line.rb +68 -0
  65. data/lib/colours/rainbow_colours/println_ani.rb +32 -0
  66. data/lib/colours/rainbow_colours/println_plain.rb +36 -0
  67. data/lib/colours/rainbow_colours/rainbow.rb +38 -0
  68. data/lib/colours/rainbow_colours/report_errors.rb +32 -0
  69. data/lib/colours/rainbow_colours/returnln_plain.rb +63 -0
  70. data/lib/colours/rainbow_colours/set_mode.rb +24 -0
  71. data/lib/colours/requires/require_autogenerated_colour_methods.rb +5 -0
  72. data/lib/colours/requires/require_commandline.rb +7 -0
  73. data/lib/colours/requires/require_eparse.rb +11 -0
  74. data/lib/colours/requires/require_rgb.rb +5 -0
  75. data/lib/colours/requires/require_the_256_colours_module.rb +16 -0
  76. data/lib/colours/requires/require_the_basic_colours.rb +7 -0
  77. data/lib/colours/requires/require_the_colour_methods.rb +34 -0
  78. data/lib/colours/requires/require_the_colour_table.rb +7 -0
  79. data/lib/colours/requires/require_the_constants.rb +5 -0
  80. data/lib/colours/requires/require_the_html_colours.rb +11 -0
  81. data/lib/colours/requires/require_the_kde_colour_palette.rb +7 -0
  82. data/lib/colours/requires/require_the_project.rb +53 -0
  83. data/lib/colours/requires/require_the_toplevel_methods.rb +42 -0
  84. data/lib/colours/requires/require_yaml.rb +9 -0
  85. data/lib/colours/rgb/rgb.rb +550 -0
  86. data/lib/colours/testing/README.md +2 -0
  87. data/lib/colours/testing/testing.rb +168 -0
  88. data/lib/colours/toplevel_methods/autogenerate.rb +310 -0
  89. data/lib/colours/toplevel_methods/bold.rb +41 -0
  90. data/lib/colours/toplevel_methods/bold_and_italic.rb +38 -0
  91. data/lib/colours/toplevel_methods/cat.rb +39 -0
  92. data/lib/colours/toplevel_methods/clear_screen.rb +18 -0
  93. data/lib/colours/toplevel_methods/cliner.rb +17 -0
  94. data/lib/colours/toplevel_methods/col.rb +54 -0
  95. data/lib/colours/toplevel_methods/e.rb +69 -0
  96. data/lib/colours/toplevel_methods/esystem.rb +19 -0
  97. data/lib/colours/toplevel_methods/html_colour_to_hex_value.rb +41 -0
  98. data/lib/colours/toplevel_methods/html_colourize.rb +69 -0
  99. data/lib/colours/toplevel_methods/is_on_roebe.rb +16 -0
  100. data/lib/colours/toplevel_methods/italic.rb +110 -0
  101. data/lib/colours/toplevel_methods/make_colour.rb +28 -0
  102. data/lib/colours/toplevel_methods/methods_related_to_html_colours.rb +336 -0
  103. data/lib/colours/toplevel_methods/misc.rb +226 -0
  104. data/lib/colours/toplevel_methods/open_this_file.rb +26 -0
  105. data/lib/colours/toplevel_methods/prefer_this_colour_schemata.rb +88 -0
  106. data/lib/colours/toplevel_methods/random_value.rb +37 -0
  107. data/lib/colours/toplevel_methods/remove_escape_sequence.rb +112 -0
  108. data/lib/colours/toplevel_methods/revert.rb +104 -0
  109. data/lib/colours/toplevel_methods/set_last_colour_used.rb +32 -0
  110. data/lib/colours/toplevel_methods/shell_file_containing_the_html_colours.sh +148 -0
  111. data/lib/colours/toplevel_methods/show_basic_colour_palette.rb +36 -0
  112. data/lib/colours/toplevel_methods/underline.rb +130 -0
  113. data/lib/colours/toplevel_methods/use_colours.rb +290 -0
  114. data/lib/colours/version/version.rb +25 -0
  115. data/lib/colours/yaml/256_colours.yml +279 -0
  116. data/lib/colours/yaml/basic_colours.yml +25 -0
  117. data/lib/colours/yaml/html_colours.yml +837 -0
  118. data/lib/colours/yaml/kde_colour_palette.yml +183 -0
  119. data/lib/colours/yaml/prefer_this_colour_schemata.yml +17 -0
  120. data/lib/colours/yaml/use_these_values_for_the_colour_methods.yml +15 -0
  121. data/lib/colours.rb +1 -0
  122. data/test/test.html +18 -0
  123. data/test/testing_256_colours_support.rb +29 -0
  124. data/test/testing_bold_italic_underline.rb +26 -0
  125. data/test/testing_class_colours.rb +46 -0
  126. data/test/testing_col.rb +10 -0
  127. data/test/testing_colours.rb +96 -0
  128. data/test/testing_colours_e.rb +13 -0
  129. data/test/testing_eparse.rb +13 -0
  130. data/test/testing_italic.rb +28 -0
  131. data/test/testing_kde_colour_palette.rb +30 -0
  132. data/test/testing_konsole_submodule.rb +226 -0
  133. data/test/testing_map_symbol_to_corresponding_colour.rb +14 -0
  134. data/test/testing_replace_number_words_with_the_corresponding_html_colour.rb +39 -0
  135. data/test/testing_rgb_to_hex.rb +32 -0
  136. data/test/testing_the_basic_colours_of_the_colours_project.rb +62 -0
  137. data/test/testing_the_colour_methods.rb +36 -0
  138. data/test/testing_the_constants_of_the_colours_project.rb +9 -0
  139. data/test/testing_the_ecomment_method.rb +11 -0
  140. data/test/testing_the_html_colours_of_the_colours_project.rb +37 -0
  141. data/test/testing_the_regex_for_capturing_the_commandline_coloured_content.rb +112 -0
  142. data/test/testing_whether_colours_will_be_used.rb +7 -0
  143. metadata +225 -0
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'colours/autoinclude'
6
+
7
+ class Bar
8
+ include Colours
9
+ end
10
+
11
+ N = "\n"
12
+ e 'Now testing the gem called '+sfancy('colours')+rev+'.'
13
+ e
14
+ e 'We will also read in this html file lateron:'
15
+ e
16
+ e ' '+sfile(Colours::TEST_FILE)
17
+
18
+ # =========================================================================== #
19
+ # === konsole_colour_tests
20
+ # =========================================================================== #
21
+ def konsole_colour_tests(i = ARGV)
22
+ e 'First, we will display six random colours.'
23
+ e
24
+ e Colours[:random]+' heya1'
25
+ e Colours[:random]+' heya2'
26
+ e Colours[:random]+' heya3'
27
+ e Colours.random(' heya4')
28
+ e Colours.random(' heya5')
29
+ e Colours.random(' heya6')
30
+ pp Colours[:slateblue]
31
+ _ = Colours::Colour.new(ARGV)
32
+ begin
33
+ _.show_in_random_colour 'hmm'+N
34
+ _.show_in_random_colour 'hmm'+N
35
+ _.show_in_random_colour 'hmm'+N
36
+ rescue; end
37
+ # p _.html_colours # Test outputting all HTML colours.
38
+ # p Colours.html_colours
39
+ # p _.rvalue
40
+ _.seed_rgb_values # Get some random values for R,G,B.
41
+ # _.output_this_string :default, 89, 250, 237
42
+ _.output_this
43
+ _.output_this 'Hello World!'+N, :random_colours
44
+ _.output_this "Hello World!\n", :random_colours
45
+ _.output_this :random_colours
46
+ e _.random_colour? 'yeah'
47
+ # _.slateblue
48
+ # _.slateblue 'Hello World!'+N+N+N+N
49
+ # _.slateblue 'yoo!'+N
50
+ # e _.slateblue+'Direct test 1'
51
+ # e _.lightcyan+'Direct test 2'
52
+ # e _.mintcream+'Direct test 3'
53
+ # e _.slateblue('Direct test 4')
54
+ begin
55
+ e '
56
+ This is a longer paragraph. Some '+_.slateblue(:keywords)+' will
57
+ be highlighted in '+_.random_colour('a colour')+'.'+N+N+N+
58
+ ' '+_.random_colour('test')+
59
+ ' '+_.random_colour('test')+
60
+ ' '+_.random_colour('test')+
61
+ ' '+_.random_colour('test')+
62
+ ' '+_.random_colour('test')+
63
+ ' '+_.random_colour('test')+
64
+ ' '+_.random_colour('test')+N+
65
+ ' '+_.random_colour('test')+
66
+ ' '+_.random_colour('test')+
67
+ ' '+_.random_colour('test')+
68
+ ' '+_.random_colour('test')+
69
+ ' '+_.random_colour('test')+
70
+ ' '+_.random_colour('test')+
71
+ ' '+_.random_colour('test')+
72
+ ' '+_.random_colour('test')+
73
+ ' '+_.random_colour('test')+
74
+ ' '+_.random_colour('test')+
75
+ ' '+_.random_colour('test')+N+
76
+ ' '+_.random_colour('test')+
77
+ ' '+_.random_colour('test')+
78
+ ' '+_.random_colour('test')+
79
+ ' '+_.random_colour('test')+
80
+ ' '+_.random_colour('test')+
81
+ ' '+_.random_colour('test')+
82
+ ' '+_.random_colour('test')+
83
+ ' '+_.random_colour('test')+
84
+ ' '+_.random_colour('test')+
85
+ ' '+_.random_colour('test')+
86
+ ' '+_.random_colour('test')+N+
87
+ ' '+_.random_colour('test')+
88
+ ' '+_.random_colour('test')+
89
+ ' '+_.random_colour('test')+
90
+ ' '+_.random_colour('test')+
91
+ ' '+_.random_colour('test')+
92
+ ' '+_.random_colour('test')+
93
+ ' '+_.random_colour('test')+
94
+ ' '+_.random_colour('test')+
95
+ ' '+_.random_colour('test')+
96
+ ' '+_.random_colour('test')+
97
+ ' '+_.random_colour('test')+N+
98
+ ' '+_.random_colour('test')+
99
+ ' '+_.random_colour('test')+
100
+ ' '+_.random_colour('test')+
101
+ ' '+_.random_colour('test')+
102
+ ' '+_.random_colour('test')+
103
+ ' '+_.random_colour('test')+
104
+ ' '+_.random_colour('test')+
105
+ ' '+_.random_colour('test')+
106
+ ' '+_.random_colour('test')+
107
+ ' '+_.random_colour('test')+
108
+ ' '+_.random_colour('test')+N+
109
+ ' '+_.random_colour('test')+
110
+ ' '+_.random_colour('test')+
111
+ ' '+_.random_colour('test')+
112
+ ' '+_.random_colour('test')+
113
+ ' '+_.random_colour('test')+
114
+ ' '+_.random_colour('test')+
115
+ ' '+_.random_colour('test')+
116
+ ' '+_.random_colour('test')+
117
+ ' '+_.random_colour('test')+
118
+ ' '+_.random_colour('test')+
119
+ ' '+_.random_colour('test')
120
+ e
121
+ rescue; end
122
+ e 'Next trying to find out whether slateblue is registered or not:'
123
+ e _.registered_colour? 'slateblue'
124
+ e 'Next trying to read in a file:'
125
+ Colours.cliner {
126
+ _.read_file(TEST_FILE)
127
+ }
128
+ Colours.cliner {
129
+ e 'The registered colours are (Colours.registered_colours? '+
130
+ '- showing only 5):'
131
+ pp Colours.registered_colours?[0..5]
132
+ }
133
+ e
134
+ e 'Next we will show some random colours, just to test whether this'
135
+ e 'functionaly works properly:'
136
+ e
137
+ e ' '+Colours.random_colour?
138
+ e ' '+Colours.random_colour?
139
+ e ' '+Colours.random_colour?
140
+ e ' '+Colours.random_colour?
141
+ e ' '+Colours.random_colour?
142
+ e ' '+Colours.random_colour?
143
+ e
144
+ e "Next testing Colours :green, 'hello world'"
145
+ konsole_colours :green, 'hello world'
146
+ Colours.cliner {
147
+ e Time.now.strftime('%H:%M:%S')
148
+ puts kde_colour(:slateblue, Time.now.strftime('%H:%M:%S') ).to_s
149
+ }
150
+ puts Colours[:slateblue, Time.now.strftime('%H:%M:%S')]
151
+ pp REVERT
152
+ pp rgb
153
+ pp rgb
154
+ pp rgb
155
+ output_in_a_random_colour 'yo there'
156
+ output_in_a_random_colour 'yo there'
157
+ output_in_a_random_colour 'yo there'
158
+ e; Colours.cliner {
159
+ e 'We will display three random colours next:'
160
+ e ' '+Colours.random_colour?
161
+ e ' '+Colours.random_colour?
162
+ e ' '+Colours.random_colour?
163
+ }
164
+ e 'Is darkgreen a registered colour? '+registered_colour?('darkgreen').to_s
165
+ e Colours.rgb('slateblue')+'yo there'+restore?
166
+ e Colours.rgb(:random)+'yo there'+restore?+' (<-- '+
167
+ Colours.colourize(Colours.last_colour_used?)+')'
168
+ Colours.write_this_in_random_colour('yo man how do you do')
169
+ Colours.cliner
170
+ e 'Next testing direct calls such as: Colours.sienna()'
171
+ e Colours.sienna
172
+ e Colours.sienna('yo there')
173
+ e Colours.lightblue('yo there')
174
+ e Colours.cyan('yo there')
175
+ p darkgreen('ok')
176
+ p lightblue('ok')
177
+ slateblue
178
+ e Colours_colour_slateblue 'hello world!'
179
+ e Colours_colour_darkgreen 'hello world!'
180
+ eslateblue 'yo there'
181
+ Colours.slateblue
182
+ Colours.edarkgreen 'This is Colours.edarkgreen'
183
+ Colours.eslateblue 'This is Colours.eslateblue'
184
+ Bar.new.slateblue
185
+ Bar.slateblue
186
+ e Bar.slateblue('oki doki')
187
+ e; Colours.cliner {
188
+ e 'Next testing 4 occurances of slateblue:'
189
+ e Colours['slateblue','(1) Hello World!']
190
+ eColours_colour_slateblue '(2) hello world!' # This is the same as the above.
191
+ e Colours.slateblue '(3) yo'
192
+ eslateblue '(4) hi world'
193
+ }
194
+ e; Colours.cliner {
195
+ e 'We will next test out Colours.rgb with 3 specific values (R,G,B)'
196
+ e Colours.rgb(122,56,141)+' ok'+rev
197
+ e Colours.rgb(125,61,164)+' ok'+rev
198
+ e Colours.rgb(132,76,198)+' ok'+rev
199
+ e Colours.rgb(262,86,213)+' ok'+rev
200
+ }
201
+ e; Colours.cliner {
202
+ e 'Next we will test the method: write_this_in_random_colour'
203
+ write_this_in_random_colour ' hello world'
204
+ write_this_in_random_colour ' hello world'
205
+ write_this_in_random_colour ' hello world'
206
+ }
207
+ Colours_colours :green, 'Hello world!'
208
+ e Colours_colour_peru 'hey there - this here is Colours_colour_peru()'
209
+ e; Colours.cliner {
210
+ e 'Next testing italic:'
211
+ e Colours.italic('This must be italic.')
212
+ e
213
+ e 'Next testing underline:'
214
+ e Colours.underline('This must be underlined.')
215
+ }
216
+ Colours.display_all_colours # Finally, display all colours here.
217
+ end; alias test_Colours_colours Colours_colour_tests # === test_Colours_colours
218
+
219
+ if __FILE__ == $PROGRAM_NAME
220
+ # Testing code comes next:
221
+ if ARGV.empty?
222
+ Colours_colour_tests # Here we run the various colour-tests.
223
+ else
224
+ Colours.menu(ARGV) # Delegate towards Colours.menu() here.
225
+ end
226
+ end # tkon
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'new_colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb'
6
+
7
+ alias e puts
8
+
9
+ e
10
+ NewColours.available_colours?.each {|this_colour|
11
+ translated = NewColours.map_symbol_to_corresponding_colour(this_colour)
12
+ e translated+':'+this_colour.to_s.ljust(8)+' -> '+
13
+ translated.to_s+' ('+translated.inspect+')'
14
+ }; e
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'colours'
6
+ alias e puts
7
+
8
+ use_this_hash = {
9
+ :one => :steelblue,
10
+ :two => :mediumseagreen,
11
+ :three => :mediumpurple,
12
+ :four => :olivedrab,
13
+ :five => :lightgreen,
14
+ :default_colour => :olivedrab
15
+ }
16
+ x = 'Contemporary research in animal cognition has as its roots ... where? In <one>Charles Darwin’s theory of evolution by natural selection</one>.'
17
+
18
+ e x
19
+ y = Colours.replace_number_words_with_the_corresponding_html_colour(x, use_this_hash)
20
+ e y
21
+
22
+ z = '- Is <one>abc</one> <two>an example of</two> <orange>def ghi</orange> or of <orange>jkl mno</orange>? <one>Non-associative learning</one>.'
23
+ scanned = z.scan(
24
+ Colours::REGEX_FOR_HTML_COLOURS
25
+ ).flatten.uniq
26
+ scanned.each {|entry|
27
+ if Colours.is_a_HTML_colour?(entry) # Here we know it is a HTML colour.
28
+ e z+::Colours.rev
29
+ colour_to_use = Colours.replace_number_words_with_the_corresponding_html_colour(entry, use_this_hash)
30
+ regex_to_use = Colours.return_main_regex_to_use_for_obtaining_the_full_content(colour_to_use)
31
+ e z.gsub(
32
+ regex_to_use,
33
+ ::Colours::AllColourMethods.send(colour_to_use.to_sym, "\\1") { :omit_end }+
34
+ ::Colours.rev
35
+ )
36
+ end
37
+ }
38
+ #e z
39
+ # y = Colours.replace_number_words_with_the_corresponding_html_colour(x, use_this_hash)
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ alias e puts
6
+ require 'colours'
7
+
8
+ # Testing code comes next:
9
+ e 'We will now test R,G,B values: 255,200,22'
10
+ p Colours::RGB[255,200,22]
11
+ begin
12
+ p Colours::RGB[355,200,22]
13
+ rescue ArgumentError => error
14
+ p error
15
+ e 'We rescued this error however.'
16
+ end
17
+ _ = Colours::RGB.new '55,66,77'
18
+ e 'We will now test R,G,B values: 55,66,77'
19
+ p _
20
+ e 'Testing add(3) next:'
21
+ _.add 3
22
+ p _
23
+ e _.rgb
24
+ e
25
+ e 'Next, we will test HTML Colours (strings):'
26
+ e 'slateblue: → '+Colours::RGB['slateblue']
27
+ e 'darkblue: → '+Colours::RGB['darkblue']
28
+ e '-------'
29
+ e 'Next, we will apply .lighten, from darkblue as our base colour:'
30
+ e Colours::RGB['darkblue']
31
+ e Colours::RGB.new(Colours::RGB['darkblue']).lighten # => "#232323"
32
+ e '-------'
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ if __FILE__ == $PROGRAM_NAME
6
+ alias e puts
7
+ require 'colours/constants/constants.rb'
8
+ include Colours
9
+ require 'colours/basic_colours/basic_colours.rb'
10
+ include Colours::BasicColours
11
+ module Colours
12
+ include Colours::BasicColours
13
+ end
14
+ e 'Next testing direct support for colour-constants, such as '\
15
+ 'COLOUR_LIGHT_PURPLE or COLOUR_GRAY'
16
+ e COLOUR_LIGHT_PURPLE+'foo bar'+COLOUR_NC
17
+ e COLOUR_GRAY+'foo bar'+COLOUR_NC
18
+ e GREEN+'TEST IN GREEN, THEN THE CLOSING "TAG"'+CLOSING_TAG
19
+ e
20
+ e 'Next, we will directly test for colour-methods such as .gray() or'
21
+ e '.light_gray(), .blue() and so forth:'
22
+ e
23
+ e 'yo '+Colours::BasicColours.gray('there - this is gray') # This one is not visible on a black background.
24
+ e 'yo '+Colours::BasicColours.light_gray('there - this is light gray')
25
+ e 'yo '+Colours::BasicColours.yellow('there - this is yellow')
26
+ e 'yo '+Colours::BasicColours.blue('there - this is blue')
27
+ e 'yo '+Colours::BasicColours.brown('there - this is brown')
28
+ e 'yo '+Colours::BasicColours.red('there - this is red')
29
+ e 'yo '+Colours::BasicColours.white('there - this is white')
30
+ e 'yo '+Colours::BasicColours.purple('there - this is purple')
31
+ e 'yo '+Colours::BasicColours.purple('there - this is green')
32
+ e 'yo '+Colours::BasicColours.light_purple('there - this is light purple')
33
+ e 'yo '+Colours::BasicColours.light_red('there - this is light red')
34
+ e 'yo '+Colours::BasicColours.light_green('there - this is light green')
35
+ e 'yo '+Colours::BasicColours.cyan('there - this is cyan')
36
+ e 'yo '+Colours::BasicColours.light_cyan('there - this is light cyan')
37
+ e 'yo '+Colours::BasicColours.light_blue('there - this is light blue')
38
+ e 'Is this line without colours?'
39
+ e
40
+ e 'Next, we will test whether HASH_SIMPLE_COLOURS contains all keys'
41
+ e 'as methods:'
42
+ keys = HASH_SIMPLE_COLOURS.keys
43
+ e
44
+ keys.each_with_index {|this_method, index| index += 1
45
+ padded_index = ('('+index.to_s+') ').rjust(5)
46
+ e Colours::BasicColours.send(
47
+ this_method,
48
+ padded_index+this_method.to_s+' does exist.'
49
+ )
50
+ }
51
+ e
52
+ e
53
+ e 'Next testing .rev()'
54
+ e
55
+ e Colours.rev
56
+ e
57
+ pp Colours::ARRAY_REGISTERED_ANSI_COLOURS
58
+ e
59
+ e 'Next testing: pp Colours.really_all_colours'
60
+ e
61
+ pp Colours.really_all_colours
62
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ alias e puts
6
+ e
7
+ e 'The code in this file will test the various colour-methods, such as'
8
+ e 'sfancy(), sdir() and so forth.'
9
+ e
10
+ require 'new_colours'
11
+ e
12
+ e NewColours.sfancy( 'Hello world (through sfancy())')+NewColours.sfancy('').inspect
13
+ e NewColours.sdir( 'Hello world (through sdir())')+NewColours.sdir('').inspect
14
+ e NewColours.simportant('Hello world (through simportant())')+NewColours.simportant('').inspect
15
+ e NewColours.swarn( 'Hello world (through swarn())')+NewColours.swarn('').inspect
16
+ e NewColours.snormal( 'Hello world (through snormal())')+NewColours.snormal('').inspect
17
+ e NewColours.sargument( 'Hello world (through sargument())')+NewColours.sargument('').inspect
18
+ e NewColours.sfile( 'Hello world (through sfile())')+NewColours.sfile('').inspect
19
+ e NewColours.ssymlink( 'Hello world (through ssymlink())')+NewColours.ssymlink('').inspect
20
+ e NewColours.scomments( 'Hello world (through scomments())')+NewColours.scomments('').inspect
21
+
22
+ e
23
+ e 'Next we will use Colours.use_new_colour_table and hope'
24
+ e 'that this will change the above colours:'
25
+ e
26
+ NewColours.use_new_colour_table
27
+ e NewColours.sfancy( 'Hello world (through sfancy())')+NewColours.sfancy('').inspect
28
+ e NewColours.sdir( 'Hello world (through sdir())')+NewColours.sdir('').inspect
29
+ e NewColours.simportant('Hello world (through simportant())')+NewColours.simportant('').inspect
30
+ e NewColours.swarn( 'Hello world (through swarn())')+NewColours.swarn('').inspect
31
+ e NewColours.snormal( 'Hello world (through snormal())')+NewColours.snormal('').inspect
32
+ e NewColours.sargument( 'Hello world (through sargument())')+NewColours.sargument('').inspect
33
+ e NewColours.sfile( 'Hello world (through sfile())')+NewColours.sfile('').inspect
34
+ e NewColours.ssymlink( 'Hello world (through ssymlink())')+NewColours.ssymlink('').inspect
35
+ e NewColours.scomments( 'Hello world (through scomments())')+NewColours.scomments('').inspect
36
+ e
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'colours/constants/hash_simple_colours.rb'
6
+ require 'colours/constants/constants.rb'
7
+
8
+ pp Colours::HASH_SIMPLE_COLOURS
9
+ pp Colours::REVERT
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'colours/colour_methods/colour_methods.rb'
6
+
7
+ alias e puts
8
+
9
+ e "The following text should be output in a colourized manner:\n\n"
10
+ Colours.ecomment(' test1 # test2')
11
+ e
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'new_colours/requires/require_the_html_colours.rb'
6
+ require 'new_colours/autogenerated/support_for_html_colours.rb'
7
+
8
+ def cliner; e '='*80; end
9
+
10
+ alias e puts
11
+
12
+ cliner
13
+ e
14
+ pp NewColours::HtmlColours::HASH_HTML_COLOURS
15
+ e
16
+ cliner
17
+ e
18
+ pp NewColours::HtmlColours.return_all_html_colours
19
+ e
20
+ cliner
21
+ e
22
+ pp NewColours::HtmlColours['slateblue']
23
+ e 'slateblue is represented as: '+
24
+ NewColours::HtmlColours['slateblue'].to_s
25
+ e
26
+
27
+ pp NewColours['crimson']
28
+
29
+ e NewColours['crimson']+'Hello world!'
30
+ e
31
+ e 'Next testing for class inclusion.'
32
+ class Foo
33
+ include NewColours::SupportForHTMLColours
34
+ end
35
+
36
+ foo = Foo.new
37
+ e foo.slateblue('yo there')
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This .rb file will also text the extensive test suite that I am using
6
+ # to make sure the colourization parts work.
7
+ # =========================================================================== #
8
+ require 'colours/toplevel_methods/methods_related_to_html_colours.rb'
9
+ require 'colours/html_colours/html_colours.rb'
10
+
11
+ result = <<-EOF
12
+ - Is <one>abc</one> <two>an example of</two> <orange>def ghi</orange> or of <orange>jkl mno</orange>? <one>Non-associative learning</one>.
13
+ <orange>C₅|H₁₀₀|N₂|O</orange>
14
+ <orange>C₆|H₁₄|N₂|O₂</orange>
15
+ <orange>H₂CO₃</orange>
16
+ <orange>α-aminogruppe</orange>
17
+ <orange>Mg²⁺</orange>
18
+ <orange>„Write once, run everywhere.“</orange>.
19
+ <orange>5'→3'</orange>yo
20
+ ist <orange>a @ b</orange> eine valide Anweisung?
21
+ <orange>x^2 + 1 = 0⁺</orange>
22
+ <orange>yo there</orange>
23
+ <orange>Antigen-Antikörper</orange>
24
+ <orange>Antigen-Antikörper</orange>
25
+ For the production of recombinant antibodies, we may use <orange>₂₃₄library display methods</orange>.
26
+ C3-Pflanzen fixieren ... <orange>CO²</orange>
27
+ <orange>4 ≥ 3</orange>
28
+ <orange>item -> { }</orange>
29
+ In <orange>Charles Darwin’s theory of evolution by natural selection</orange>.
30
+ <orange>catch (...) { cout << 42; }</orange>
31
+ <orange>₁₂₃₄₅₆₇₈₉⁰¹²³⁴⁵⁶⁷⁸⁹</orange>
32
+ <orange>[]</orange>
33
+ <orange>| |</orange>
34
+ <orange>last shared_ptr to it is destroyed</orange>
35
+ <orange>Process.uid.zero?</orange>
36
+ <orange>"UGA"Å</orange>
37
+ <orange>2:1 ratio</orange>
38
+ <orange>3-O-β-D-galactose</orange>
39
+ <orange>open(foobar.txt);</orange>
40
+ <orange>open("foobar.txt")</orange>
41
+ <orange>open("foobar.txt");</orange>
42
+ <orange>Huber’s pigeon lab.</orange>
43
+ <orange>Carl von Linné</orange>
44
+ <orange>Tú frog</orange>
45
+ <orange>(3x10²) + (2x10¹) + (7x10⁰)</orange>
46
+ <orange>10∨³⁰</orange>
47
+ <orange>10³⁰</orange>
48
+ <orange>n μm in diameter</orange>
49
+ <orange>10-20 μm in diameter</orange>
50
+ <orange>⁻¹²</orange>
51
+ <orange>+αβÅ</orange>
52
+ <orange>+</orange>
53
+ <orange>Maximale Trennungsgröße</orange>
54
+ <orange>++foo</orange>
55
+ <orange>300.000</orange>
56
+ <orange>50°C</orange>
57
+ <orange>1g/kg Körpergewicht</orange>
58
+ <orange>foobar = { 1, 5, 9, 3, 6, 2 }</orange>
59
+ <orange>a = b;</orange>
60
+ foo? <orange>4-10 per cell</orange>
61
+ - foo <orange>ok</orange>
62
+ <orange>60%</orange>
63
+ <orange>operative Geschäft</orange>
64
+ <orange>C -> U</orange>
65
+ <orange>"ok again"</orange> <green>yere</green>
66
+ <orange>ok</orange>"? ok
67
+ <orange>rint(f.read(5))</orange>
68
+ <orange># => 3</orange>
69
+ <orange>&</orange>
70
+ <orange>int *x;</orange>
71
+ <orange>a single F(ab)2 fragment</orange>
72
+ <orange>¹⁸F.</orange>
73
+ <orange>~70x</orange>
74
+ <orange>!=</orange>
75
+ Üowohl +0 sowie -0. Bei Vergleichen ... <orange>+0 = −0</orange>.
76
+ <orange>3' OH Gruppe</orange>
77
+ <orange>f = open("foobar.txt", "r");</orange>
78
+ Dies ist <orange>xeee, aaa, prognostische, x "precision medicine"</orange>, die zudem ...
79
+ <orange>-C≡N</orange>
80
+ <orange>NOAEL</orange> und <orange>LOEL</orange>
81
+ <orange>'\0'</orange>
82
+ The female <orange>Túngara frog</orange> will select males that show ...
83
+ EOF
84
+
85
+ USE_THIS_COLOUR_FOR_THE_DEFAULT_COLOUR = :grey
86
+
87
+ result = result.split("\n").reject {|entry| entry.strip.empty? }
88
+ result.each {|this_line|
89
+ this_line = this_line.dup if this_line.frozen?
90
+ scanned_results = this_line.scan(
91
+ Colours::REGEX_FOR_HTML_COLOURS
92
+ ).flatten.uniq
93
+ scanned_results.each {|this_colour|
94
+ if Colours.is_this_a_valid_html_colour?(this_colour)
95
+ use_this_regex =
96
+ Colours.return_main_regex_to_use_for_obtaining_the_full_content(this_colour)
97
+ # =================================================================== #
98
+ # We must use .gsub!() because the colour-string may occur more
99
+ # than once. Unfortunately for longer Strings this becomes a bit
100
+ # fragile.
101
+ # =================================================================== #
102
+ part1 = ::Colours::AllColourMethods.send(this_colour.to_sym, "\\1") { :omit_end }
103
+ part2 = ::Colours::AllColourMethods.send(USE_THIS_COLOUR_FOR_THE_DEFAULT_COLOUR) { :omit_end }
104
+ this_line.gsub!(
105
+ use_this_regex,
106
+ part1+
107
+ part2
108
+ ).dup
109
+ end
110
+ }
111
+ puts ::Colours.rev+this_line
112
+ }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'colours/toplevel_methods/use_colours.rb'
6
+
7
+ Colours.report_whether_colours_will_be_used