environment_information 1.4.89
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of environment_information might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +1276 -0
- data/bin/envi +7 -0
- data/bin/fast_envi +7 -0
- data/doc/README.gen +1044 -0
- data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +48 -0
- data/environment_information.gemspec +135 -0
- data/lib/environment_information/base/base.rb +159 -0
- data/lib/environment_information/class/add.rb +187 -0
- data/lib/environment_information/class/colours.rb +283 -0
- data/lib/environment_information/class/constants.rb +35 -0
- data/lib/environment_information/class/environment_information.rb +51 -0
- data/lib/environment_information/class/help.rb +90 -0
- data/lib/environment_information/class/html.rb +78 -0
- data/lib/environment_information/class/initialize.rb +177 -0
- data/lib/environment_information/class/menu.rb +465 -0
- data/lib/environment_information/class/misc.rb +897 -0
- data/lib/environment_information/class/opn.rb +33 -0
- data/lib/environment_information/class/register_sigint.rb +20 -0
- data/lib/environment_information/class/reset.rb +217 -0
- data/lib/environment_information/class/ruby.rb +79 -0
- data/lib/environment_information/class/run.rb +61 -0
- data/lib/environment_information/class/show_display_and_report.rb +355 -0
- data/lib/environment_information/colours/colours.rb +211 -0
- data/lib/environment_information/colours/sfancy.rb +19 -0
- data/lib/environment_information/colours/simp.rb +19 -0
- data/lib/environment_information/constants/array_tracked_components.rb +210 -0
- data/lib/environment_information/constants/constants.rb +17 -0
- data/lib/environment_information/constants/encoding.rb +21 -0
- data/lib/environment_information/constants/error_line.rb +17 -0
- data/lib/environment_information/constants/file_constants.rb +102 -0
- data/lib/environment_information/constants/misc.rb +86 -0
- data/lib/environment_information/constants/namespace.rb +14 -0
- data/lib/environment_information/constants/newline.rb +16 -0
- data/lib/environment_information/constants/regex.rb +30 -0
- data/lib/environment_information/constants/temp_directory.rb +52 -0
- data/lib/environment_information/gui/gtk2/environment_information.rb +35 -0
- data/lib/environment_information/gui/gtk3/environment_information.rb +34 -0
- data/lib/environment_information/gui/libui/environment_information.rb +74 -0
- data/lib/environment_information/gui/shared_code/environment_information_module.rb +409 -0
- data/lib/environment_information/misc_components/README.md +3 -0
- data/lib/environment_information/misc_components/cflags.rb +36 -0
- data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
- data/lib/environment_information/misc_components/operating_system.rb +54 -0
- data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
- data/lib/environment_information/misc_components/ram.rb +30 -0
- data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
- data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
- data/lib/environment_information/project/project.rb +27 -0
- data/lib/environment_information/queries/README.md +2 -0
- data/lib/environment_information/queries/complex_version.rb +272 -0
- data/lib/environment_information/queries/pkg_config.rb +125 -0
- data/lib/environment_information/queries/simple_version.rb +217 -0
- data/lib/environment_information/requires/require_asciitable.rb +15 -0
- data/lib/environment_information/requires/require_the_constants.rb +7 -0
- data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
- data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
- data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
- data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +152 -0
- data/lib/environment_information/toplevel_methods/cd.rb +16 -0
- data/lib/environment_information/toplevel_methods/e.rb +43 -0
- data/lib/environment_information/toplevel_methods/hash.rb +60 -0
- data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
- data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
- data/lib/environment_information/toplevel_methods/menu.rb +90 -0
- data/lib/environment_information/toplevel_methods/misc.rb +309 -0
- data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
- data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
- data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
- data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
- data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
- data/lib/environment_information/toplevel_methods/return_alias_to.rb +30 -0
- data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
- data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
- data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
- data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +182 -0
- data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
- data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
- data/lib/environment_information/version/version.rb +25 -0
- data/lib/environment_information/www/sinatra_interface.rb +213 -0
- data/lib/environment_information/www/webobject_interface.cgi +29 -0
- data/lib/environment_information/yaml/array_default_programs_on_linux.yml +15 -0
- data/lib/environment_information/yaml/array_lfs_core_programs.yml +37 -0
- data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
- data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
- data/lib/environment_information/yaml/array_tracked_programs.yml +207 -0
- data/lib/environment_information/yaml/array_tracked_xorg_components.yml +37 -0
- data/lib/environment_information/yaml/colours.yml +3 -0
- data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +256 -0
- data/lib/environment_information.rb +5 -0
- data/test/testing_environment_information.rb +26 -0
- data/test/testing_missing_components.rb +9 -0
- data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
- metadata +191 -0
@@ -0,0 +1,355 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'environment_information/class/show_display_and_report.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'environment_information/base/base.rb'
|
8
|
+
|
9
|
+
module EnvironmentInformation
|
10
|
+
|
11
|
+
class EnvironmentInformation < ::EnvironmentInformation::Base # === EnvironmentInformation::EnvironmentInformation
|
12
|
+
|
13
|
+
require 'environment_information/toplevel_methods/is_on_roebe.rb'
|
14
|
+
require 'environment_information/toplevel_methods/return_alias_to.rb'
|
15
|
+
begin
|
16
|
+
require 'rbt/requires/swift_version.rb'
|
17
|
+
rescue LoadError
|
18
|
+
if ::EnvironmentInformation.is_on_roebe?
|
19
|
+
puts 'The file rbt/toplevel_methods/swift_return_version_of_this_program.rb is not available.'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'rbt/toplevel_methods/url.rb'
|
25
|
+
rescue LoadError
|
26
|
+
if ::EnvironmentInformation.is_on_roebe?
|
27
|
+
puts 'The file rbt/toplevel_methods/url.rb is not available.'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# ========================================================================= #
|
32
|
+
# === show_help?
|
33
|
+
# ========================================================================= #
|
34
|
+
def show_help?
|
35
|
+
@show_help
|
36
|
+
end
|
37
|
+
|
38
|
+
# ========================================================================= #
|
39
|
+
# === compare_via_gem_version
|
40
|
+
# ========================================================================= #
|
41
|
+
def compare_via_gem_version(i)
|
42
|
+
begin
|
43
|
+
Gem::Version.new(i)
|
44
|
+
rescue ArgumentError => error
|
45
|
+
e Colours.tomato(error)
|
46
|
+
e 'We will continue nonetheless ('+i+')'
|
47
|
+
return nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
require 'environment_information/toplevel_methods/e.rb'
|
52
|
+
# ========================================================================= #
|
53
|
+
# === e (e tag)
|
54
|
+
#
|
55
|
+
# The e() method is the general output-method for this class.
|
56
|
+
# ========================================================================= #
|
57
|
+
def e(i = '')
|
58
|
+
unless @be_silent
|
59
|
+
if use_one_line_to_show_the_result? # This will just use "print".
|
60
|
+
::EnvironmentInformation.ee(i)
|
61
|
+
else
|
62
|
+
::EnvironmentInformation.e(
|
63
|
+
i, display_everything_in_short_format: @display_everything_in_short_format
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# ========================================================================= #
|
70
|
+
# === do_report_the_remote_urls
|
71
|
+
#
|
72
|
+
# Enable the reporting of the remote URLs, if available.
|
73
|
+
# ========================================================================= #
|
74
|
+
def do_report_the_remote_urls
|
75
|
+
@internal_hash[:report_the_remote_urls] = true
|
76
|
+
end
|
77
|
+
|
78
|
+
# ========================================================================= #
|
79
|
+
# === show_the_registered_components
|
80
|
+
# ========================================================================= #
|
81
|
+
def show_the_registered_components(
|
82
|
+
i = tracked_programs?
|
83
|
+
)
|
84
|
+
e
|
85
|
+
e 'The following programs will be tracked:'
|
86
|
+
e
|
87
|
+
use_one_line_to_show_the_result = use_one_line_to_show_the_result?
|
88
|
+
i.each_with_index {|this_program, index| index += 1
|
89
|
+
if use_one_line_to_show_the_result
|
90
|
+
padded_index = index.to_s+') '
|
91
|
+
else
|
92
|
+
padded_index = ' '+(index.to_s+') ').rjust(5)
|
93
|
+
end
|
94
|
+
colourized_and_padded_index = seagreen(padded_index)
|
95
|
+
e colourized_and_padded_index+
|
96
|
+
steelblue(this_program)
|
97
|
+
}
|
98
|
+
e
|
99
|
+
end
|
100
|
+
|
101
|
+
# ========================================================================= #
|
102
|
+
# === report_version
|
103
|
+
# ========================================================================= #
|
104
|
+
def report_version
|
105
|
+
require 'environment_information/toplevel_methods/menu.rb'
|
106
|
+
::EnvironmentInformation.report_version
|
107
|
+
@do_exit_the_program = true
|
108
|
+
end
|
109
|
+
|
110
|
+
# ========================================================================= #
|
111
|
+
# === display_these_components?
|
112
|
+
#
|
113
|
+
# Note that @display_these_components is a Hash.
|
114
|
+
# ========================================================================= #
|
115
|
+
def display_these_components?
|
116
|
+
@array_report_these_programs
|
117
|
+
end; alias components? display_these_components? # === components?
|
118
|
+
alias main_dataset? display_these_components? # === main_dataset?
|
119
|
+
alias main_entry? display_these_components? # === main_entry?
|
120
|
+
alias dataset? display_these_components? # === dataset?
|
121
|
+
alias result display_these_components? # === result
|
122
|
+
alias result? display_these_components? # === result?
|
123
|
+
alias display_which_components? display_these_components? # === display_which_components?
|
124
|
+
alias array_obtain_these_programs? display_these_components? # === array_obtain_these_programs?
|
125
|
+
alias array_with_entries? display_these_components? # === array_with_entries?
|
126
|
+
alias main_array? display_these_components? # === main_array?
|
127
|
+
alias programs? display_these_components? # === programs?
|
128
|
+
alias show_these_components? display_these_components? # === show_these_components?
|
129
|
+
|
130
|
+
# ========================================================================= #
|
131
|
+
# === main_hash?
|
132
|
+
# ========================================================================= #
|
133
|
+
def main_hash?
|
134
|
+
::EnvironmentInformation.hash?
|
135
|
+
end
|
136
|
+
|
137
|
+
# ========================================================================= #
|
138
|
+
# === register_the_available_components_and_show_them_at_once (report tag)
|
139
|
+
#
|
140
|
+
# This method can be used to register information about the various
|
141
|
+
# components. It will also instantly display the component at
|
142
|
+
# hand, to avoid "lagging" behaviour on the commandline.
|
143
|
+
# ========================================================================= #
|
144
|
+
def register_the_available_components_and_show_them_at_once(
|
145
|
+
report_these_programs = @array_report_these_programs
|
146
|
+
)
|
147
|
+
if report_these_programs.empty?
|
148
|
+
opn; e 'There are no components that can be displayed.' # And this ends here.
|
149
|
+
else
|
150
|
+
# ===================================================================== #
|
151
|
+
# Always clear the main Array before proceeding here.
|
152
|
+
# ===================================================================== #
|
153
|
+
clear_missing_components
|
154
|
+
toplevel_hash = ::EnvironmentInformation.hash?
|
155
|
+
hash_use_this_for_the_query = ::EnvironmentInformation.all_the_queries
|
156
|
+
# ===================================================================== #
|
157
|
+
# Iterate over the registered programs next.
|
158
|
+
# ===================================================================== #
|
159
|
+
report_these_programs.each {|this_program|
|
160
|
+
# =================================================================== #
|
161
|
+
# First, determine the left_side and the right_side.
|
162
|
+
# =================================================================== #
|
163
|
+
left_side = this_program.to_s.dup
|
164
|
+
right_side = nil
|
165
|
+
case this_program
|
166
|
+
# =================================================================== #
|
167
|
+
# === RAM
|
168
|
+
# =================================================================== #
|
169
|
+
when :ram,
|
170
|
+
/^RAM$/i
|
171
|
+
right_side = ram?.to_s.dup
|
172
|
+
right_side = right_side.dup if right_side.frozen?
|
173
|
+
# ================================================================= #
|
174
|
+
# Append 'MB RAM' in orange colour next, with some padding.
|
175
|
+
# This is just a small visual "enhancement" that I quite like.
|
176
|
+
# ================================================================= #
|
177
|
+
right_side << orange(' MB RAM')
|
178
|
+
# =================================================================== #
|
179
|
+
# === Rubygems installation directory
|
180
|
+
# =================================================================== #
|
181
|
+
when :rubygems_installation_directory,
|
182
|
+
/^rubygems( |_)?installation( |_)?directory\??$/i
|
183
|
+
right_side = rubygems_installation_directory?
|
184
|
+
# =================================================================== #
|
185
|
+
# === cflags
|
186
|
+
# =================================================================== #
|
187
|
+
when :cflags,
|
188
|
+
/^cflags$/i,
|
189
|
+
/^cflags(_|-| )?in(_|-| )?use$/i
|
190
|
+
right_side = cflags_in_use?
|
191
|
+
# =================================================================== #
|
192
|
+
# === Screen resolution
|
193
|
+
#
|
194
|
+
# This is a bit "special" in the sense that we will colourize
|
195
|
+
# the middle 'x', if found, and if colours are used.
|
196
|
+
# =================================================================== #
|
197
|
+
when :screen_resolution,
|
198
|
+
/^screen( |_)?resolution$/i
|
199
|
+
right_side = screen_resolution?
|
200
|
+
if right_side.include?('x') and use_colours?
|
201
|
+
splitted = right_side.split('x')
|
202
|
+
right_side = colourize_this_in_the_right_side_colour(splitted.first)+
|
203
|
+
royalblue('x')+
|
204
|
+
colourize_this_in_the_right_side_colour(splitted.last)
|
205
|
+
end
|
206
|
+
# =================================================================== #
|
207
|
+
# === CPU Model
|
208
|
+
# =================================================================== #
|
209
|
+
when /^cpuinfo$/i,
|
210
|
+
/^CPU(_|-| )?Model/
|
211
|
+
right_side = cpu_model?
|
212
|
+
# =================================================================== #
|
213
|
+
# === Operating system bit type
|
214
|
+
# =================================================================== #
|
215
|
+
when /^operating(_|-| )?system(_|-| )?bit(_|-| )?type$/i
|
216
|
+
right_side = bit_type?
|
217
|
+
# =================================================================== #
|
218
|
+
# === Operating system
|
219
|
+
# =================================================================== #
|
220
|
+
when /^Operating(_|-| )?system$/i,
|
221
|
+
:operating_system
|
222
|
+
right_side = ::EnvironmentInformation.operating_system
|
223
|
+
end
|
224
|
+
# =================================================================== #
|
225
|
+
# Find the corresponding entry next while including aliases:
|
226
|
+
# =================================================================== #
|
227
|
+
this_program = this_program.to_sym # These are stored as symbol.
|
228
|
+
this_program = ::EnvironmentInformation.return_alias_to(this_program)
|
229
|
+
_ = hash_use_this_for_the_query[this_program]
|
230
|
+
if hash_use_this_for_the_query.has_key? this_program
|
231
|
+
if _.to_s.start_with? 'pkg'
|
232
|
+
# =============================================================== #
|
233
|
+
# === :pkgconfig
|
234
|
+
#
|
235
|
+
# This is by far the simplest solution.
|
236
|
+
# =============================================================== #
|
237
|
+
right_side = @pkg_config_query.return_version_of(this_program)
|
238
|
+
add_this_to_the_toplevel_hash(left_side, right_side)
|
239
|
+
# ================================================================= #
|
240
|
+
# === :version
|
241
|
+
#
|
242
|
+
# Here we will handle simple versions, e. g. "lftp --version"
|
243
|
+
# entries, and similar.
|
244
|
+
# ================================================================= #
|
245
|
+
elsif _ == :version
|
246
|
+
right_side = @simple_version_query.return_version_of(this_program)
|
247
|
+
add_this_to_the_toplevel_hash(left_side, right_side)
|
248
|
+
else
|
249
|
+
# =============================================================== #
|
250
|
+
# Else we will pass through class ComplexVersion:
|
251
|
+
# =============================================================== #
|
252
|
+
right_side = @complex_version_query.return_version_of(this_program)
|
253
|
+
add_this_to_the_toplevel_hash(left_side, right_side)
|
254
|
+
end
|
255
|
+
# =================================================================== #
|
256
|
+
# The next clause has been written specifically to allow querying
|
257
|
+
# the mate-desktop components.
|
258
|
+
# =================================================================== #
|
259
|
+
elsif toplevel_hash.has_key?(this_program) and
|
260
|
+
toplevel_hash[this_program] # ← This is thus non-nil.
|
261
|
+
right_side = toplevel_hash[this_program]
|
262
|
+
end
|
263
|
+
if right_side.nil?
|
264
|
+
register_unavailable_program(this_program)
|
265
|
+
end
|
266
|
+
# =================================================================== #
|
267
|
+
# === @internal_hash[:report_the_remote_urls]
|
268
|
+
#
|
269
|
+
# Next, honour @internal_hash[:report_the_remote_urls] if it is
|
270
|
+
# set to true.
|
271
|
+
# =================================================================== #
|
272
|
+
if report_the_remote_urls? and
|
273
|
+
is_rbt_available? and
|
274
|
+
RBT.respond_to?(:remote_url_for?)
|
275
|
+
version = ''.dup
|
276
|
+
_ = this_program.to_s.delete('-').downcase.strip.to_sym
|
277
|
+
if RBT.does_include?(_)
|
278
|
+
remote_url = RBT.remote_url_for?(_, :return_as_string)
|
279
|
+
if is_a_registered_component? _
|
280
|
+
if version.frozen?
|
281
|
+
version = version.dup
|
282
|
+
end
|
283
|
+
version << lightgreen(remote_url)
|
284
|
+
if right_side # We can only continue if the program is available.
|
285
|
+
# In theory we could show the URL anyway, but for the time
|
286
|
+
# being, at the least, we will not show the URL.
|
287
|
+
right_side = right_side.dup if right_side.frozen?
|
288
|
+
right_side << " #{olive('→')} #{version}"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
# =================================================================== #
|
294
|
+
# The next method is defined in base.rb.
|
295
|
+
# =================================================================== #
|
296
|
+
report_left_right(
|
297
|
+
left_side,
|
298
|
+
right_side,
|
299
|
+
:default_colour,
|
300
|
+
:default_colour,
|
301
|
+
:default_colour,
|
302
|
+
!use_one_line_to_show_the_result?
|
303
|
+
)
|
304
|
+
# =================================================================== #
|
305
|
+
# Next compare the program versions with the local versions.
|
306
|
+
# =================================================================== #
|
307
|
+
if compare_program_versions? and
|
308
|
+
is_rbt_available_and_may_we_try_to_use_rbt? and
|
309
|
+
RBT.respond_to?(:swift_return_version_of_this_program) and
|
310
|
+
RBT.does_include?(left_side.to_s.strip)
|
311
|
+
# ================================================================= #
|
312
|
+
# Example:
|
313
|
+
#
|
314
|
+
# RBT.swift_return_version_of_this_program(:gettext)
|
315
|
+
#
|
316
|
+
# ================================================================= #
|
317
|
+
registered_local_version = RBT.swift_return_version_of_this_program(
|
318
|
+
left_side.to_s.strip.to_sym
|
319
|
+
).to_s
|
320
|
+
# ================================================================= #
|
321
|
+
# We ignore gtk2 when it comes to the version-check.
|
322
|
+
# ================================================================= #
|
323
|
+
next if this_program == :gtk2
|
324
|
+
# ================================================================= #
|
325
|
+
# Next use Gem::Version to compare them, but not if the version
|
326
|
+
# is nil.
|
327
|
+
# ================================================================= #
|
328
|
+
unless right_side.nil?
|
329
|
+
# =============================================================== #
|
330
|
+
# The .delete('v') is specifically for libuv or node.
|
331
|
+
# =============================================================== #
|
332
|
+
registered_local_version = registered_local_version.to_s.
|
333
|
+
delete('v').
|
334
|
+
tr('_','.')
|
335
|
+
a = compare_via_gem_version(registered_local_version)
|
336
|
+
b = compare_via_gem_version(right_side)
|
337
|
+
if a and b and (a > b)
|
338
|
+
e slateblue(' ^^^^^ This program could be '\
|
339
|
+
'upgraded, to the version ')+
|
340
|
+
steelblue(registered_local_version)
|
341
|
+
end if registered_local_version =~ /\d+/
|
342
|
+
end
|
343
|
+
end
|
344
|
+
}
|
345
|
+
end
|
346
|
+
end; alias display register_the_available_components_and_show_them_at_once # === display
|
347
|
+
alias report_result register_the_available_components_and_show_them_at_once # === report_result
|
348
|
+
alias display_the_components register_the_available_components_and_show_them_at_once # === display_the_components
|
349
|
+
alias display_the_dataset register_the_available_components_and_show_them_at_once # === display_the_dataset
|
350
|
+
alias work_through_the_programs register_the_available_components_and_show_them_at_once # === work_through_the_programs
|
351
|
+
alias build_up_the_main_string register_the_available_components_and_show_them_at_once # === build_up_the_main_string
|
352
|
+
alias display_the_main_components register_the_available_components_and_show_them_at_once # === build_up_the_main_string
|
353
|
+
alias report register_the_available_components_and_show_them_at_once # === report
|
354
|
+
|
355
|
+
end; end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'environment_information/colours/colours.rb'
|
6
|
+
# EnvironmentInformation.colour_for_the_left_side
|
7
|
+
# =========================================================================== #
|
8
|
+
module EnvironmentInformation
|
9
|
+
|
10
|
+
require 'environment_information/project/project.rb'
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# First the code here will determine which colours are to be used. If
|
14
|
+
# a .yml file can be found as part of this project then it will override
|
15
|
+
# the default values given here; otherwise the default values will be
|
16
|
+
# used, consequently.
|
17
|
+
# ========================================================================= #
|
18
|
+
|
19
|
+
yaml_file = EnvironmentInformation.project_base_directory?+'yaml/colours.yml'
|
20
|
+
if File.exist? yaml_file
|
21
|
+
dataset = YAML.load_file(yaml_file) # These should be a Symbol.
|
22
|
+
@colour_for_the_left_side = dataset['left_side'].to_sym
|
23
|
+
@colour_for_the_right_side = dataset['right_side'].to_sym
|
24
|
+
@colour_for_program_not_found = dataset['program_not_found'].to_sym
|
25
|
+
else # else use default values here
|
26
|
+
# ========================================================================= #
|
27
|
+
# === @colour_for_the_left_side
|
28
|
+
# ========================================================================= #
|
29
|
+
@colour_for_the_left_side = :forestgreen
|
30
|
+
|
31
|
+
# ========================================================================= #
|
32
|
+
# === @colour_for_the_right_side
|
33
|
+
# ========================================================================= #
|
34
|
+
@colour_for_the_right_side = :steelblue
|
35
|
+
|
36
|
+
# ========================================================================= #
|
37
|
+
# === @colour_for_program_not_found
|
38
|
+
# ========================================================================= #
|
39
|
+
@colour_for_program_not_found = :lightslategrey
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
require 'colours'
|
44
|
+
# ======================================================================= #
|
45
|
+
# === @use_colours
|
46
|
+
#
|
47
|
+
# By default this project will try to make use of colours. This has
|
48
|
+
# be protected by a rescue clause, as not every user may have the
|
49
|
+
# gem called "colours" installed.
|
50
|
+
# ======================================================================= #
|
51
|
+
@use_colours = true
|
52
|
+
rescue LoadError
|
53
|
+
# ======================================================================= #
|
54
|
+
# If the colours-gem is not available then we will not use colours.
|
55
|
+
# The user could still overrule this at a later time, though.
|
56
|
+
# ======================================================================= #
|
57
|
+
@use_colours = false
|
58
|
+
end
|
59
|
+
|
60
|
+
# ========================================================================= #
|
61
|
+
# === EnvironmentInformation.colour_for_the_left_side (left tag)
|
62
|
+
#
|
63
|
+
# This method will return the colour
|
64
|
+
#
|
65
|
+
# This could also be :limegreen rather than :forestgreen or vice versa.
|
66
|
+
# ========================================================================= #
|
67
|
+
def self.colour_for_the_left_side
|
68
|
+
@colour_for_the_left_side
|
69
|
+
end
|
70
|
+
|
71
|
+
# ========================================================================= #
|
72
|
+
# === EnvironmentInformation.colour_for_the_right_side (right tag)
|
73
|
+
# ========================================================================= #
|
74
|
+
def self.colour_for_the_right_side
|
75
|
+
@colour_for_the_right_side
|
76
|
+
end
|
77
|
+
|
78
|
+
# ========================================================================= #
|
79
|
+
# === EnvironmentInformation.colour_for_program_not_found
|
80
|
+
# ========================================================================= #
|
81
|
+
def self.colour_for_program_not_found
|
82
|
+
@colour_for_program_not_found
|
83
|
+
end
|
84
|
+
|
85
|
+
# ========================================================================= #
|
86
|
+
# === EnvironmentInformation.rev
|
87
|
+
# ========================================================================= #
|
88
|
+
def self.rev
|
89
|
+
return ::Colours.rev if @use_colours
|
90
|
+
'' # Else return an empty String.
|
91
|
+
end
|
92
|
+
|
93
|
+
# ========================================================================= #
|
94
|
+
# === EnvironmentInformation.use_colours?
|
95
|
+
# ========================================================================= #
|
96
|
+
def self.use_colours?
|
97
|
+
@use_colours
|
98
|
+
end
|
99
|
+
|
100
|
+
# ========================================================================= #
|
101
|
+
# === EnvironmentInformation.set_use_colours
|
102
|
+
#
|
103
|
+
# Determine whether the EnvironmentInformation project will use
|
104
|
+
# colours or whether it will not.
|
105
|
+
# ========================================================================= #
|
106
|
+
def self.set_use_colours(i = true)
|
107
|
+
@use_colours = i
|
108
|
+
end; self.instance_eval { alias use_colours= set_use_colours } # === EnvironmentInformation.use_colours=
|
109
|
+
|
110
|
+
# ========================================================================= #
|
111
|
+
# === EnvironmentInformation.do_use_colours
|
112
|
+
# ========================================================================= #
|
113
|
+
def self.do_use_colours
|
114
|
+
@use_colours = i
|
115
|
+
end
|
116
|
+
|
117
|
+
# ========================================================================= #
|
118
|
+
# === EnvironmentInformation.mediumpurple
|
119
|
+
# ========================================================================= #
|
120
|
+
def self.mediumpurple(i = '')
|
121
|
+
if @use_colours
|
122
|
+
return ::Colours.mediumpurple(i)
|
123
|
+
end
|
124
|
+
return i
|
125
|
+
end
|
126
|
+
|
127
|
+
# ========================================================================= #
|
128
|
+
# === EnvironmentInformation.lightslategrey
|
129
|
+
# ========================================================================= #
|
130
|
+
def self.lightslategrey(i = '')
|
131
|
+
if @use_colours
|
132
|
+
return ::Colours.lightslategrey(i)
|
133
|
+
end
|
134
|
+
return i
|
135
|
+
end
|
136
|
+
|
137
|
+
# ========================================================================= #
|
138
|
+
# === EnvironmentInformation.tomato
|
139
|
+
# ========================================================================= #
|
140
|
+
def self.tomato(
|
141
|
+
i = '', use_colours = @use_colours
|
142
|
+
)
|
143
|
+
return ::Colours.tomato(i) if use_colours
|
144
|
+
return i
|
145
|
+
end
|
146
|
+
|
147
|
+
# ========================================================================= #
|
148
|
+
# === EnvironmentInformation.pink
|
149
|
+
# ========================================================================= #
|
150
|
+
def self.pink(
|
151
|
+
i = '', use_colours = @use_colours
|
152
|
+
)
|
153
|
+
return ::Colours.pink(i) if use_colours
|
154
|
+
return i
|
155
|
+
end
|
156
|
+
|
157
|
+
# ========================================================================= #
|
158
|
+
# === EnvironmentInformation.forestgreen
|
159
|
+
# ========================================================================= #
|
160
|
+
def self.forestgreen(
|
161
|
+
i = '', use_colours = @use_colours
|
162
|
+
)
|
163
|
+
return ::Colours.forestgreen(i) if use_colours
|
164
|
+
return i
|
165
|
+
end
|
166
|
+
|
167
|
+
# ========================================================================= #
|
168
|
+
# === EnvironmentInformation.lightseagreen
|
169
|
+
# ========================================================================= #
|
170
|
+
def self.lightseagreen(i = '', use_colours = @use_colours)
|
171
|
+
if use_colours
|
172
|
+
return ::Colours.lightseagreen(i)
|
173
|
+
end
|
174
|
+
return i
|
175
|
+
end
|
176
|
+
|
177
|
+
# ========================================================================= #
|
178
|
+
# === EnvironmentInformation.steelblue
|
179
|
+
# ========================================================================= #
|
180
|
+
def self.steelblue(i = '')
|
181
|
+
if @use_colours
|
182
|
+
return ::Colours.steelblue(i)
|
183
|
+
end
|
184
|
+
return i
|
185
|
+
end
|
186
|
+
|
187
|
+
# ========================================================================= #
|
188
|
+
# === EnvironmentInformation.royalblue
|
189
|
+
# ========================================================================= #
|
190
|
+
def self.royalblue(
|
191
|
+
i = '',
|
192
|
+
use_colours = @use_colours
|
193
|
+
)
|
194
|
+
if use_colours
|
195
|
+
return ::Colours.royalblue(i)
|
196
|
+
end
|
197
|
+
return i
|
198
|
+
end
|
199
|
+
|
200
|
+
# ========================================================================= #
|
201
|
+
# === EnvironmentInformation.sfile
|
202
|
+
# ========================================================================= #
|
203
|
+
def self.sfile(i = '')
|
204
|
+
if @use_colours
|
205
|
+
::Colours.sfile(i)
|
206
|
+
else
|
207
|
+
i
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'environment_information/colours/sfancy.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module EnvironmentInformation
|
8
|
+
|
9
|
+
require 'environment_information/colours/colours.rb'
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === EnvironmentInformation
|
13
|
+
# ========================================================================= #
|
14
|
+
def self.sfancy(i = '')
|
15
|
+
return ::Colours.sfancy(i) if Object.const_defined? :Colours
|
16
|
+
i
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'environment_information/colours/simp.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module EnvironmentInformation
|
8
|
+
|
9
|
+
require 'environment_information/colours/colours.rb'
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === EnvironmentInformation
|
13
|
+
# ========================================================================= #
|
14
|
+
def self.simp(i = '')
|
15
|
+
return ::Colours.simp(i) if Object.const_defined? :Colours
|
16
|
+
i
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|