colours 0.5.52
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 +889 -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 +76 -0
- data/doc/COLOUR_CODES_CHART.md +28 -0
- data/doc/HOW_TO_PICK_YOUR_OWN_COLOURS.md +29 -0
- data/doc/README.gen +862 -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 +129 -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 +108 -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 +225 -0
@@ -0,0 +1,157 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# Add the test() method to the Colours module here.
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'colours/testing/testing.rb'
|
8
|
+
# =========================================================================== #
|
9
|
+
require 'colours/toplevel_methods/e.rb'
|
10
|
+
require 'colours/toplevel_methods/show_basic_colour_palette.rb'
|
11
|
+
require 'colours/toplevel_methods/make_colour.rb'
|
12
|
+
|
13
|
+
module Colours
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === Colours.test
|
17
|
+
#
|
18
|
+
# This class-method can be used to test the Colours module.
|
19
|
+
#
|
20
|
+
# It will be called from the test.rb file, in order to test all components
|
21
|
+
# of the Colours module.
|
22
|
+
#
|
23
|
+
# To invoke it, do:
|
24
|
+
#
|
25
|
+
# Colours.test
|
26
|
+
#
|
27
|
+
# ========================================================================= #
|
28
|
+
def self.test
|
29
|
+
require 'colours/basic_colours/basic_colours.rb'
|
30
|
+
require 'colours/colour_table/colour_table.rb'
|
31
|
+
cliner
|
32
|
+
show_basic_colour_palette
|
33
|
+
cliner
|
34
|
+
e red('Hello ')+cyan('World!')
|
35
|
+
e 'Hi '+Colours.red+'there.'+rev
|
36
|
+
e 'Hi '+Colours.cyan+'there.'+rev
|
37
|
+
e 'Hi '+Colours::BasicColours.bold_white+'there.'+rev
|
38
|
+
e 'Hi '+Colours.pink+'there.'+rev
|
39
|
+
e 'Hi '+Colours.brown+'there.'+rev
|
40
|
+
cliner
|
41
|
+
e CYAN+'Hi there.'
|
42
|
+
e BWHITE+'Hi there.'+BBLUE+' Yo there.'+rev
|
43
|
+
e sfancy('yo')+simp(' there')
|
44
|
+
disable_colours(true)
|
45
|
+
e sfancy('yo')+simp(' there')
|
46
|
+
enable_colours(true)
|
47
|
+
e sfancy('yo')+simp(' there')
|
48
|
+
e rgb_to_hex('155255255')
|
49
|
+
e col '/Depot/Audio'
|
50
|
+
e col '/Depot/Audio/Westbam_Sunshine.mp3'
|
51
|
+
e rev+'This is '+simp('elegant => simportant()')+'.'
|
52
|
+
e rev+'This is '+sfancy('elegant => sfancy()')+'.'
|
53
|
+
e rev+'This is '+sdir('elegant => sdir()')+'.'
|
54
|
+
e rev+'This is '+sfile('elegant => sfancy()')+'.'
|
55
|
+
e rev+'This is '+swarn('elegant => swarn()')+'.'
|
56
|
+
e rev+'This is '+ssym('elegant => ssym()')+'.'
|
57
|
+
ecomment 'An this # could be a comment.'
|
58
|
+
e
|
59
|
+
e 'Changing colour codes now. We should see different colours '+
|
60
|
+
'when compared to the above.'
|
61
|
+
e
|
62
|
+
Colours.update_the_colour_codes_with
|
63
|
+
e rev+'This is '+simportant('elegant => simportant()')+'.'
|
64
|
+
e rev+'This is '+sfancy('elegant => sfancy()')+'.'
|
65
|
+
e rev+'This is '+sdir('elegant => sdir()')+'.'
|
66
|
+
e rev+'This is '+sfile('elegant => sfancy()')+'.'
|
67
|
+
e rev+'This is '+swarn('elegant => swarn()')+'.'
|
68
|
+
e rev+'This is '+ssym('elegant => ssym()')+'.'
|
69
|
+
e 'Do we use colours? '+use_colours?.to_s
|
70
|
+
e cyan+' ==> Hi there.'
|
71
|
+
e red+' ==> Hi there.'
|
72
|
+
e green+' ==> Hi there.'
|
73
|
+
e brown+' ==> Hi there.'
|
74
|
+
e blue+' ==> Hi there.'
|
75
|
+
e teal+' ==> Hi there.'
|
76
|
+
e white+' ==> Hi there.'
|
77
|
+
e grey+' ==> Hi there.'
|
78
|
+
e lightblue+' ==> Hi there.'+red()+' yo'
|
79
|
+
e RED+'This is red galore.'
|
80
|
+
e 'right?'+Colours.rev
|
81
|
+
e BLUE+'This is blue now.'
|
82
|
+
e 'right?'+rev
|
83
|
+
e 'Hi there - this should be white.'
|
84
|
+
# html_colours?
|
85
|
+
p main_colours
|
86
|
+
main_colours.each {|entry|
|
87
|
+
send(entry, 'test')
|
88
|
+
}
|
89
|
+
e 'yo this should '+pink('be pink.')
|
90
|
+
puts CFANCY+' Hi there.'
|
91
|
+
puts CIMPORTANT+' Hi there.'
|
92
|
+
# Next, we will disable the colours.
|
93
|
+
disable_colours(true)
|
94
|
+
# The following ones have a newline.
|
95
|
+
e rev+'This is '+simportant('elegant => simportant().',true)
|
96
|
+
e rev+'This is '+sfancy('elegant => sfancy().',true)
|
97
|
+
e rev+'This is '+sdir('elegant => sdir().',true)
|
98
|
+
e rev+'This is '+sfile('elegant => sfancy().',true)
|
99
|
+
Colours.enable_colours(true)
|
100
|
+
e rev+'This is '+simportant('elegant => simportant()')+'.'
|
101
|
+
e rev+'This is '+sfancy('elegant => sfancy()')+'.'
|
102
|
+
e rev+'This is '+sdir('elegant => sdir()')+'.'
|
103
|
+
e rev+'This is '+sfile('elegant => sfancy()')+'.'; e
|
104
|
+
e 'Next, trying to underline:'
|
105
|
+
underline 'Hi there'
|
106
|
+
e 'Next trying eparse:'
|
107
|
+
eparse 'Joe: Hey Tim, how do you do?'
|
108
|
+
eparse 'Tim: Really fine. How about you?'
|
109
|
+
eparse ' Joe: ok man let us proceed'
|
110
|
+
eparse ' [name of character here] # show when this character last logged in'
|
111
|
+
e
|
112
|
+
e 'Next some tests with col():'
|
113
|
+
e
|
114
|
+
e ' '+col('/Depot/Audio/AVAILABLE_SONGS').to_s
|
115
|
+
e ' '+col('/Depot/Audio').to_s
|
116
|
+
e
|
117
|
+
cliner
|
118
|
+
e 'Now testing Colours.red("foobar"):'
|
119
|
+
e red('foobar')
|
120
|
+
e 'Next, we test Colours.enable() and Colours.disable()'
|
121
|
+
disable
|
122
|
+
e 'Colours.disable()'
|
123
|
+
e rev+'This is '+simportant('elegant => simportant()')+'.'
|
124
|
+
e 'Colours.enable()'
|
125
|
+
enable
|
126
|
+
e rev+'This is '+simportant('elegant => simportant()')+'.'
|
127
|
+
e rev+'The colour for symlinks is: '+simportant('Colours.colour_for_symlinks')
|
128
|
+
pp colour_for_symlinks
|
129
|
+
e rev+'A classical Hello World! example, and the colour-code for it.'
|
130
|
+
efancy 'Hello World!'
|
131
|
+
pp sfancy('Hello World!')
|
132
|
+
e 'Next removing some escape sequences:'
|
133
|
+
e
|
134
|
+
e remove_escape_sequences(" \e[1;31mhello world\e[0;0m # <-- "+
|
135
|
+
"This here is not coloured and it also does not have "+
|
136
|
+
"escape-sequences either.")
|
137
|
+
e
|
138
|
+
e 'Next testing whether Colours.yellow() works:'
|
139
|
+
e
|
140
|
+
e " hello #{Colours.yellow('world!')}#{rev}"
|
141
|
+
e
|
142
|
+
e 'Next testing Colours.eparse():'
|
143
|
+
e
|
144
|
+
eparse ' hello # world!'
|
145
|
+
e
|
146
|
+
e 'Next testing Colours.ecomment():'
|
147
|
+
e
|
148
|
+
ecomment ' hello # world!'
|
149
|
+
e
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
if __FILE__ == $PROGRAM_NAME
|
155
|
+
include Colours
|
156
|
+
Colours.test
|
157
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/bold.rb'
|
6
|
+
# Colours.bold
|
7
|
+
# =========================================================================== #
|
8
|
+
require 'colours/revert/revert.rb'
|
9
|
+
|
10
|
+
module Colours
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# === Colours.bold
|
14
|
+
#
|
15
|
+
# Usage example:
|
16
|
+
#
|
17
|
+
# puts ' ok | '+Colours.bold('Hello world!')+' | ok'
|
18
|
+
#
|
19
|
+
# ========================================================================= #
|
20
|
+
def self.bold(
|
21
|
+
show_this_text = 'This must be bold.'
|
22
|
+
)
|
23
|
+
"\x1b[1m#{show_this_text}#{REVERT}"
|
24
|
+
end; self.instance_eval { alias return_bold bold } # === Colours.return_bold
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
if __FILE__ == $PROGRAM_NAME
|
29
|
+
if ARGV.empty?
|
30
|
+
puts Colours.bold('Hello world!')
|
31
|
+
puts 'Hello world!'
|
32
|
+
else
|
33
|
+
puts Colours.bold(ARGV.join(' ').strip)
|
34
|
+
end
|
35
|
+
end # colours_bold hello there how do you do
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/bold_and_italic.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'colours/revert/revert.rb'
|
8
|
+
require 'colours/toplevel_methods/bold.rb'
|
9
|
+
require 'colours/toplevel_methods/italic.rb'
|
10
|
+
|
11
|
+
module Colours
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === Colours.bold_and_italic
|
15
|
+
#
|
16
|
+
# Usage example:
|
17
|
+
# puts Colours.bold_and_italic 'Hello world!'
|
18
|
+
# ========================================================================= #
|
19
|
+
def self.bold_and_italic(
|
20
|
+
i = 'This must be bold.'
|
21
|
+
)
|
22
|
+
if i.is_a? Array
|
23
|
+
i = i.join(' ')
|
24
|
+
end
|
25
|
+
italic(bold(i))
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
if __FILE__ == $PROGRAM_NAME
|
31
|
+
if ARGV.empty?
|
32
|
+
puts Colours.bold_and_italic('Hello world!')+' All is fine.'
|
33
|
+
else
|
34
|
+
puts Colours.bold_and_italic(ARGV)
|
35
|
+
end
|
36
|
+
end # bold_and_italic yo there yoda
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/cat.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'colours/rainbow_colours/print_rainbow_line.rb'
|
8
|
+
|
9
|
+
module Colours
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === Colours.cat
|
13
|
+
#
|
14
|
+
# The first argument may be ARGF. It ought to respond to .each anyway.
|
15
|
+
#
|
16
|
+
# Note that .cat) will delegate towards print_line().
|
17
|
+
# ========================================================================= #
|
18
|
+
def self.cat(
|
19
|
+
file_descriptor, hash_options = {}
|
20
|
+
)
|
21
|
+
print "\e[?25l" if hash_options[:animate] # Print this if we animate (enabling psychedelics).
|
22
|
+
# ======================================================================= #
|
23
|
+
# Iterate over the file_descriptor passed.
|
24
|
+
# ======================================================================= #
|
25
|
+
file_descriptor.each { |line|
|
26
|
+
hash_options[:os] += 1 # Increase the output-count.
|
27
|
+
# ===================================================================== #
|
28
|
+
# Next, colourize the line. This depends on the method called
|
29
|
+
# print_rainbow_line().
|
30
|
+
# ===================================================================== #
|
31
|
+
RainbowColours.print_rainbow_line(
|
32
|
+
line, hash_options
|
33
|
+
) # Delegate towards print_line.
|
34
|
+
}
|
35
|
+
ensure
|
36
|
+
print "\e[?25h" if hash_options[:animate]
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/clear_screen.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === Colours.clear_screen
|
11
|
+
#
|
12
|
+
# Simply perform 'clear' here.
|
13
|
+
# ========================================================================= #
|
14
|
+
def self.clear_screen
|
15
|
+
system 'clear'
|
16
|
+
end; self.instance_eval { alias clear clear_screen } # === Colours.clear_screen
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/cliner.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module Colours
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === Colours.cliner
|
11
|
+
# ========================================================================= #
|
12
|
+
def self.cliner(i = 78)
|
13
|
+
if block_given?
|
14
|
+
yield
|
15
|
+
end
|
16
|
+
puts '=' * i
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/col.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'colours/colour_methods/sfile.rb'
|
8
|
+
require 'colours/colour_methods/sdir.rb'
|
9
|
+
require 'colours/colour_methods/ssymlink.rb'
|
10
|
+
|
11
|
+
module Colours
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === Colours.col (col tag)
|
15
|
+
#
|
16
|
+
# Careful - this method may collide with other methods named col().
|
17
|
+
#
|
18
|
+
# Usage examples:
|
19
|
+
#
|
20
|
+
# Colours.col '/Depot/j/geojgirjh'
|
21
|
+
# Colours.col '/Users/x/AUDIO/'
|
22
|
+
# Colours.col '/Users/x/AUDIO/Westbam_Sunshine.mp3'
|
23
|
+
#
|
24
|
+
# ========================================================================= #
|
25
|
+
def self.col(
|
26
|
+
i,
|
27
|
+
optional_arg_not_in_use_right_now = ''
|
28
|
+
)
|
29
|
+
if File.exist? i
|
30
|
+
ftype = File.ftype(i)
|
31
|
+
# e 'The ftype is: '+ftype # <- This could be used for debugging.
|
32
|
+
case ftype
|
33
|
+
# ===================================================================== #
|
34
|
+
# === file
|
35
|
+
# ===================================================================== #
|
36
|
+
when 'file'
|
37
|
+
return sfile(i)
|
38
|
+
# ===================================================================== #
|
39
|
+
# === directory
|
40
|
+
# ===================================================================== #
|
41
|
+
when 'directory'
|
42
|
+
return sdir(i)
|
43
|
+
# ===================================================================== #
|
44
|
+
# === link
|
45
|
+
# ===================================================================== #
|
46
|
+
when 'link'
|
47
|
+
return ssymlink(i)
|
48
|
+
else
|
49
|
+
e "module Colours: We do not know the filetype `#{ftype}`"
|
50
|
+
end
|
51
|
+
else # Else return the input a bit changed.
|
52
|
+
return sfile(i) # We modify it because that is better.
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/e.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'colours/constants/newline.rb'
|
8
|
+
require 'colours/revert/revert.rb'
|
9
|
+
|
10
|
+
module Colours
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# === ef
|
14
|
+
# ========================================================================= #
|
15
|
+
def ef(i)
|
16
|
+
e(i, false) # The variant without newlines.
|
17
|
+
end
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === Colours.e
|
21
|
+
#
|
22
|
+
# This is essentially just a fancified wrapper over puts.
|
23
|
+
#
|
24
|
+
# Usage examples:
|
25
|
+
# Colours.e 'hello world'
|
26
|
+
# Colours.e "hi \n there\n is everything fine? \n\n"
|
27
|
+
# ========================================================================= #
|
28
|
+
def self.e(
|
29
|
+
i = N,
|
30
|
+
append_newline = true
|
31
|
+
)
|
32
|
+
i = i.join(' ') if i.is_a? Array
|
33
|
+
_ = "#{rev}#{i.to_s.dup}".dup # Work with a copy here.
|
34
|
+
_.chomp! # So that we won't have more than one newline initially.
|
35
|
+
_ << N if append_newline # This should be the last modification before calling print.
|
36
|
+
print _ # And print the result finally.
|
37
|
+
end
|
38
|
+
|
39
|
+
# ========================================================================= #
|
40
|
+
# === e (e tag)
|
41
|
+
#
|
42
|
+
# This is just a wrapper towards the above method called Colours.e()
|
43
|
+
#
|
44
|
+
# If the second argument `make_newline` is true then we will append a
|
45
|
+
# newline. This is the default behaviour.
|
46
|
+
#
|
47
|
+
# This method just delegates to the module method Colours.e()
|
48
|
+
# ========================================================================= #
|
49
|
+
def e(
|
50
|
+
i = N, append_newline = true
|
51
|
+
) # This is the main point of Colours.
|
52
|
+
::Colours.e(i, append_newline) # Point towards the class method of e().
|
53
|
+
end; alias ci e # === ci
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
if __FILE__ == $PROGRAM_NAME
|
58
|
+
if ARGV.empty?
|
59
|
+
Colours.e('Hello World!')
|
60
|
+
else
|
61
|
+
Colours.e(ARGV)
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'colours/toplevel_methods/esystem.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'colours/toplevel_methods/e.rb'
|
8
|
+
|
9
|
+
module Colours
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === esystem
|
13
|
+
# ========================================================================= #
|
14
|
+
def self.esystem(i)
|
15
|
+
e i
|
16
|
+
system i
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|