environment_information 1.4.124 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +91 -15
- data/doc/README.gen +42 -14
- data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +16 -12
- data/lib/environment_information/base/base.rb +483 -99
- data/lib/environment_information/colours/colours.rb +92 -66
- data/lib/environment_information/commandline/commandline.rb +137 -0
- data/lib/environment_information/constants/constants.rb +372 -11
- data/lib/environment_information/project/project.rb +1 -1
- data/lib/environment_information/query/constants.rb +46 -0
- data/lib/environment_information/query/help.rb +88 -0
- data/lib/environment_information/query/menu.rb +487 -0
- data/lib/environment_information/query/misc.rb +2006 -0
- data/lib/environment_information/query/query.rb +245 -0
- data/lib/environment_information/query/reset.rb +202 -0
- data/lib/environment_information/query/run.rb +70 -0
- data/lib/environment_information/requires/require_the_environment_information_project.rb +2 -7
- data/lib/environment_information/requires/require_the_toplevel_methods.rb +1 -3
- data/lib/environment_information/toplevel_methods/toplevel_methods.rb +2258 -0
- data/lib/environment_information/version/version.rb +2 -2
- data/lib/environment_information/www/sinatra_interface.rb +20 -17
- data/lib/environment_information/www/webobject_interface.cgi +6 -7
- data/lib/environment_information/yaml/colours.yml +3 -3
- data/lib/environment_information/yaml/query_to_use_for_all_components.yml +284 -0
- data/lib/environment_information/yaml/{array_tracked_programs.yml → track_these_components.yml} +77 -11
- metadata +18 -60
- data/lib/environment_information/class/class.rb +0 -2580
- data/lib/environment_information/class/colours.rb +0 -282
- data/lib/environment_information/colours/sfancy.rb +0 -19
- data/lib/environment_information/colours/simp.rb +0 -19
- data/lib/environment_information/constants/array_tracked_components.rb +0 -210
- data/lib/environment_information/constants/encoding.rb +0 -21
- data/lib/environment_information/constants/error_line.rb +0 -17
- data/lib/environment_information/constants/file_constants.rb +0 -102
- data/lib/environment_information/constants/misc.rb +0 -86
- data/lib/environment_information/constants/namespace.rb +0 -14
- data/lib/environment_information/constants/newline.rb +0 -16
- data/lib/environment_information/constants/regex.rb +0 -30
- data/lib/environment_information/constants/temp_directory.rb +0 -52
- data/lib/environment_information/misc_components/README.md +0 -3
- data/lib/environment_information/misc_components/cflags.rb +0 -36
- data/lib/environment_information/misc_components/cpuinfo.rb +0 -64
- data/lib/environment_information/misc_components/operating_system.rb +0 -54
- data/lib/environment_information/misc_components/operating_system_bit_type.rb +0 -42
- data/lib/environment_information/misc_components/ram.rb +0 -30
- data/lib/environment_information/misc_components/rubygems_installation_directory.rb +0 -54
- data/lib/environment_information/misc_components/screen_resolution.rb +0 -50
- data/lib/environment_information/queries/README.md +0 -2
- data/lib/environment_information/queries/complex_version.rb +0 -273
- data/lib/environment_information/queries/pkg_config.rb +0 -125
- data/lib/environment_information/queries/simple_version.rb +0 -272
- data/lib/environment_information/requires/require_the_individual_misc_components.rb +0 -30
- data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +0 -153
- data/lib/environment_information/toplevel_methods/cd.rb +0 -16
- data/lib/environment_information/toplevel_methods/e.rb +0 -43
- data/lib/environment_information/toplevel_methods/hash.rb +0 -65
- data/lib/environment_information/toplevel_methods/internet_is_available.rb +0 -30
- data/lib/environment_information/toplevel_methods/is_on_roebe.rb +0 -16
- data/lib/environment_information/toplevel_methods/menu.rb +0 -90
- data/lib/environment_information/toplevel_methods/misc.rb +0 -324
- data/lib/environment_information/toplevel_methods/n_subcommands.rb +0 -31
- data/lib/environment_information/toplevel_methods/prefix_to_use.rb +0 -39
- data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +0 -61
- data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +0 -45
- data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +0 -84
- data/lib/environment_information/toplevel_methods/return_alias_to.rb +0 -30
- data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +0 -28
- data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +0 -54
- data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +0 -28
- data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +0 -182
- data/lib/environment_information/toplevel_methods/show_all_available_components.rb +0 -192
- data/lib/environment_information/toplevel_methods/write_what_into.rb +0 -24
- data/lib/environment_information/yaml/array_default_programs_on_linux.yml +0 -15
- data/lib/environment_information/yaml/array_lfs_core_programs.yml +0 -37
- data/lib/environment_information/yaml/array_science_cluster.yml +0 -12
- data/lib/environment_information/yaml/array_tracked_non_programs.yml +0 -13
- data/lib/environment_information/yaml/array_tracked_xorg_components.yml +0 -37
- data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +0 -284
@@ -0,0 +1,2006 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# ============================================================================ #
|
5
|
+
# require 'environment_information/query/misc.rb'
|
6
|
+
# ============================================================================ #
|
7
|
+
require 'environment_information/base/base.rb'
|
8
|
+
|
9
|
+
module EnvironmentInformation
|
10
|
+
|
11
|
+
class Query < ::EnvironmentInformation::Base # === EnvironmentInformation::Query
|
12
|
+
|
13
|
+
# ========================================================================== #
|
14
|
+
# === do_show_everything (everything tag, full tag)
|
15
|
+
#
|
16
|
+
# This method can be used when the user wishes to enable seeing
|
17
|
+
# full information about his local environment (on the computer).
|
18
|
+
#
|
19
|
+
# This will always display EVERY registered component.
|
20
|
+
#
|
21
|
+
# Commandline invocation:
|
22
|
+
#
|
23
|
+
# envi --everything
|
24
|
+
#
|
25
|
+
# ========================================================================== #
|
26
|
+
def add_everything
|
27
|
+
add(:everything) # Simply add everything.
|
28
|
+
end; alias do_show_full_information add_everything # === do_show_full_information
|
29
|
+
alias show_full_information add_everything # === show_full_information
|
30
|
+
alias do_show_everything add_everything # === do_show_everything
|
31
|
+
|
32
|
+
# ========================================================================== #
|
33
|
+
# === check_for_nil_values
|
34
|
+
# ========================================================================== #
|
35
|
+
def check_for_nil_values(
|
36
|
+
i,
|
37
|
+
this_program = nil
|
38
|
+
)
|
39
|
+
case i
|
40
|
+
# ======================================================================== #
|
41
|
+
# Register some errors next:
|
42
|
+
# ======================================================================== #
|
43
|
+
when nil,'',
|
44
|
+
/: command not found/,
|
45
|
+
/^options$/,
|
46
|
+
/was not found in the pkg-?config search path./,
|
47
|
+
/was not found in the pkg-?conf/,
|
48
|
+
/error while loading shared libraries/
|
49
|
+
i = NOT_FOUND
|
50
|
+
::EnvironmentInformation.register_this_component_is_missing(this_program)
|
51
|
+
end
|
52
|
+
return i
|
53
|
+
end
|
54
|
+
|
55
|
+
# ========================================================================== #
|
56
|
+
# === display_this_component
|
57
|
+
#
|
58
|
+
# This method may NOT work on Arrays.
|
59
|
+
#
|
60
|
+
# This method is allowed to make modifications to the given input.
|
61
|
+
# ========================================================================== #
|
62
|
+
def display_this_component(
|
63
|
+
name_of_the_component,
|
64
|
+
hash = the_primary_hash?,
|
65
|
+
use_padding = true
|
66
|
+
)
|
67
|
+
version = hash[name_of_the_component.to_sym].strip
|
68
|
+
original_version = version.to_s.dup.strip
|
69
|
+
# ======================================================================== #
|
70
|
+
# This used to be called "report_left_right". The right side
|
71
|
+
# constitutes the program-version, shortened towards just "version".
|
72
|
+
# ======================================================================== #
|
73
|
+
case name_of_the_component
|
74
|
+
# ======================================================================== #
|
75
|
+
# === cpuinfo
|
76
|
+
# ======================================================================== #
|
77
|
+
when :cpuinfo,
|
78
|
+
/^cpuinfo$/i
|
79
|
+
name_of_the_component = 'CPU Model'
|
80
|
+
# ======================================================================== #
|
81
|
+
# === :operating_system
|
82
|
+
# ======================================================================== #
|
83
|
+
when :operating_system,
|
84
|
+
/^operating(_|-)?system$/i,
|
85
|
+
/^operating(_|-)?system(_|-)?in(_|-)?use$/i
|
86
|
+
name_of_the_component = 'Operating system'
|
87
|
+
# ======================================================================== #
|
88
|
+
# === operating_system_bit_type
|
89
|
+
# ======================================================================== #
|
90
|
+
when :operating_system_bit_type,
|
91
|
+
/^operating(_|-)?system(_|-)?bit(_|-)?type$/i
|
92
|
+
name_of_the_component = 'Operating system bit type'
|
93
|
+
# ======================================================================== #
|
94
|
+
# === :ram
|
95
|
+
# ======================================================================== #
|
96
|
+
when :ram, /^ram$/i
|
97
|
+
name_of_the_component = 'RAM'
|
98
|
+
# ======================================================================== #
|
99
|
+
# === :cflags
|
100
|
+
# ======================================================================== #
|
101
|
+
when :cflags,
|
102
|
+
/^cflags$/i
|
103
|
+
name_of_the_component = 'CFLAGS in use'
|
104
|
+
# ======================================================================== #
|
105
|
+
# === screen_resolution
|
106
|
+
#
|
107
|
+
# This is a bit "special" in the sense that this class will colourize
|
108
|
+
# the middle 'x', if found, and if colours are used.
|
109
|
+
# ======================================================================== #
|
110
|
+
when :screen_resolution,
|
111
|
+
/^screen( |_)?resolution$/i
|
112
|
+
name_of_the_component = 'Screen Resolution:'
|
113
|
+
if use_padding
|
114
|
+
name_of_the_component = name_of_the_component.ljust(N_LEFT_PAD)
|
115
|
+
end
|
116
|
+
if version.include?('x') and use_colours?
|
117
|
+
splitted = version.split('x')
|
118
|
+
version = colourize_this_in_the_right_side_colour(splitted.first)+
|
119
|
+
royalblue('x')+
|
120
|
+
colourize_this_in_the_right_side_colour(splitted.last)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
if name_of_the_component.is_a?(String) and name_of_the_component.include?(':')
|
124
|
+
the_left_side = "#{name_of_the_component}"
|
125
|
+
else
|
126
|
+
the_left_side = "#{name_of_the_component}:"
|
127
|
+
end
|
128
|
+
if use_padding
|
129
|
+
the_left_side = the_left_side.ljust(N_LEFT_PAD)
|
130
|
+
end
|
131
|
+
if version.include?(NOT_FOUND)
|
132
|
+
version = lightseagreen(version, use_colours?)
|
133
|
+
else
|
134
|
+
version = right_side(version)
|
135
|
+
end
|
136
|
+
the_right_side = version.dup.strip
|
137
|
+
# ======================================================================== #
|
138
|
+
# === @internal_hash[:report_the_remote_urls]
|
139
|
+
#
|
140
|
+
# Next, honour @internal_hash[:report_the_remote_urls] if it is
|
141
|
+
# set to true.
|
142
|
+
# ======================================================================== #
|
143
|
+
if report_the_remote_urls? and
|
144
|
+
is_rbt_available? and
|
145
|
+
RBT.respond_to?(:remote_url_for?)
|
146
|
+
_ = this_component.to_s.delete('-').downcase.strip.to_sym
|
147
|
+
# ====================================================================== #
|
148
|
+
# Query whether RBT keeps track of that program:
|
149
|
+
# ====================================================================== #
|
150
|
+
if RBT.does_include?(_)
|
151
|
+
# ==================================================================== #
|
152
|
+
# Next we will obtain the remote URL:
|
153
|
+
# ==================================================================== #
|
154
|
+
remote_URL = RBT.remote_url_for?(_, :return_as_string)
|
155
|
+
if is_a_registered_component? _
|
156
|
+
the_right_side = the_right_side.ljust(58, ' ')
|
157
|
+
the_right_side << " #{olive('→')} #{lightgreen(remote_URL)}" # Colourize the URL in olive.
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
# ======================================================================== #
|
162
|
+
# Next compare the program versions with the local versions.
|
163
|
+
# ======================================================================== #
|
164
|
+
if compare_program_versions? and
|
165
|
+
is_rbt_available_and_may_we_try_to_use_rbt? and
|
166
|
+
RBT.respond_to?(:swift_return_version_of_this_program) and
|
167
|
+
RBT.does_include?(name_of_the_component.to_s.strip.delete(':'))
|
168
|
+
# ====================================================================== #
|
169
|
+
# Example:
|
170
|
+
#
|
171
|
+
# RBT.swift_return_version_of_this_program(:gettext)
|
172
|
+
#
|
173
|
+
# ====================================================================== #
|
174
|
+
registered_local_version = RBT.swift_return_version_of_this_program(
|
175
|
+
name_of_the_component.to_s.strip.delete(':').to_sym
|
176
|
+
).to_s
|
177
|
+
# ====================================================================== #
|
178
|
+
# We ignore gtk2 when it comes to the version-check.
|
179
|
+
# ====================================================================== #
|
180
|
+
return if name_of_the_component.to_sym == :gtk2
|
181
|
+
# ====================================================================== #
|
182
|
+
# Next use Gem::Version to compare them, but not if the version
|
183
|
+
# is nil.
|
184
|
+
# ====================================================================== #
|
185
|
+
unless version.nil? or (version.to_s.include?(NOT_FOUND))
|
186
|
+
# ==================================================================== #
|
187
|
+
# The .delete('v') is specifically for libuv or node.
|
188
|
+
# ==================================================================== #
|
189
|
+
registered_local_version = registered_local_version.to_s.dup.
|
190
|
+
delete('v').
|
191
|
+
tr('_','.')
|
192
|
+
a = compare_via_gem_version(registered_local_version)
|
193
|
+
b = compare_via_gem_version(original_version)
|
194
|
+
if a and b and (a > b)
|
195
|
+
result = ''.dup
|
196
|
+
if use_one_line_to_show_the_result?
|
197
|
+
result << mediumaquamarine(' ← ')
|
198
|
+
else # else this is the default.
|
199
|
+
result << lightblue(' ^^^^ ')
|
200
|
+
end
|
201
|
+
result << slateblue('This program could be '\
|
202
|
+
'upgraded, to the version ')+
|
203
|
+
steelblue(registered_local_version)+
|
204
|
+
' (original_version was: '+original_version.to_s+')'
|
205
|
+
e result
|
206
|
+
end if registered_local_version =~ /\d+/
|
207
|
+
end
|
208
|
+
end
|
209
|
+
display_left_side_then_the_right_side(
|
210
|
+
the_left_side,
|
211
|
+
the_right_side
|
212
|
+
)
|
213
|
+
end; alias do_report_this_component display_this_component # === do_report_this_component
|
214
|
+
|
215
|
+
# ========================================================================== #
|
216
|
+
# === display_left_side_then_the_right_side
|
217
|
+
#
|
218
|
+
# This method will simply display what is passed into it. It is NOT
|
219
|
+
# allowed to do ANY modifications to the given input.
|
220
|
+
# ========================================================================== #
|
221
|
+
def display_left_side_then_the_right_side(
|
222
|
+
the_left_side = nil,
|
223
|
+
the_right_side = nil
|
224
|
+
)
|
225
|
+
e "#{left_side(the_left_side)}#{the_right_side}"
|
226
|
+
end
|
227
|
+
|
228
|
+
# ========================================================================== #
|
229
|
+
# === display_these_components (report tag)
|
230
|
+
#
|
231
|
+
# This method operates on an Array at all times.
|
232
|
+
# ========================================================================== #
|
233
|
+
def display_these_components(
|
234
|
+
array = array_work_on_these_components?
|
235
|
+
)
|
236
|
+
unless do_exit_the_program?
|
237
|
+
# ====================================================================== #
|
238
|
+
# === Report step
|
239
|
+
#
|
240
|
+
# We may only display the components if display_result? is true.
|
241
|
+
# ====================================================================== #
|
242
|
+
return unless display_result?
|
243
|
+
array = [array].flatten.compact
|
244
|
+
if array.empty?
|
245
|
+
notify_the_user_that_there_are_no_components_that_can_be_displayed # And this ends here.
|
246
|
+
else
|
247
|
+
array.each {|name_of_the_program|
|
248
|
+
display_this_component(name_of_the_program)
|
249
|
+
}
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end; alias do_work_through_all_the_specified_components display_these_components # === do_work_through_all_the_specified_components
|
253
|
+
alias report display_these_components # === report
|
254
|
+
alias report_result display_these_components # === report_result
|
255
|
+
alias build_up_the_main_string display_these_components # === build_up_the_main_string
|
256
|
+
alias register_the_available_components_and_show_them_at_once display_these_components # === register_the_available_components_and_show_them_at_once
|
257
|
+
alias display_the_components display_these_components # === display_the_components
|
258
|
+
alias display_the_dataset display_these_components # === display_the_dataset
|
259
|
+
alias display_the_main_components display_these_components # === build_up_the_main_string
|
260
|
+
alias report_the_findings_from_this display_these_components # === report_the_findings_from_this
|
261
|
+
|
262
|
+
|
263
|
+
def ___report_the_findings_from_this
|
264
|
+
hash.each_pair {|name, version|
|
265
|
+
do_report_this_component(name, hash, use_padding)
|
266
|
+
case the_left_side.to_s
|
267
|
+
when /^RAM:/
|
268
|
+
# ================================================================== #
|
269
|
+
# Append 'MB RAM' in orange colour next, with some padding.
|
270
|
+
# This is just a small visual "enhancement" that I quite like.
|
271
|
+
# ================================================================== #
|
272
|
+
the_right_side = the_right_side.dup if the_right_side.frozen?
|
273
|
+
# the_right_side = (the_right_side.to_f / 1028.0).round(0).to_s # If we want GB.
|
274
|
+
the_right_side << orange(' MB RAM')
|
275
|
+
end
|
276
|
+
display_left_side_then_the_right_side(the_left_side, the_right_side)
|
277
|
+
}
|
278
|
+
end
|
279
|
+
|
280
|
+
# ========================================================================== #
|
281
|
+
# === return_operating_system_bit_type
|
282
|
+
#
|
283
|
+
# We could also use "lscpu" and check for the substring 'CPU op-mode'.
|
284
|
+
# ========================================================================== #
|
285
|
+
def return_operating_system_bit_type
|
286
|
+
return ::EnvironmentInformation.operating_system_bit_type_information
|
287
|
+
end; alias bit_type? return_operating_system_bit_type # === bit_type?
|
288
|
+
|
289
|
+
# ========================================================================== #
|
290
|
+
# === add (add tag)
|
291
|
+
#
|
292
|
+
# This method can be used to add individual entries to the main Hash
|
293
|
+
# called @internal_hash[:the_primary_hash].
|
294
|
+
#
|
295
|
+
# The format for add() works on both Symbols as well as Arrays as
|
296
|
+
# input. This will be shown on the left side, and denotes the name of
|
297
|
+
# the program or component that we wish to query, such as "php" or
|
298
|
+
# "ruby" and so forth.
|
299
|
+
#
|
300
|
+
# Some Symbols will be used as a "pointer" towards an Array of
|
301
|
+
# registered programs.
|
302
|
+
#
|
303
|
+
# Note that (1) will be converted into a Symbol if it is a String.
|
304
|
+
#
|
305
|
+
# If the second entry (2) is nil, then the version will be inferred
|
306
|
+
# at "runtime" within the method display(). Otherwise display()
|
307
|
+
# will simply use the passed version (which should be a String in
|
308
|
+
# that case, then).
|
309
|
+
#
|
310
|
+
# Before we can add an entry to the main dataset, we have to check
|
311
|
+
# whether it is a registered entry altogether. If it is not
|
312
|
+
# registered, the user has to be notified about this fact.
|
313
|
+
# This notification will ONLY happen if the associated version is nil;
|
314
|
+
# if a specific version is supplied then this method will assume
|
315
|
+
# that the program should be displayed anyway.
|
316
|
+
#
|
317
|
+
# An Array can also be supplied to this method, if necessary.
|
318
|
+
#
|
319
|
+
# On 11.04.2024 the behaviour of this method changed. It will now always
|
320
|
+
# register the correct version in the primary hash.
|
321
|
+
# ========================================================================== #
|
322
|
+
def add(
|
323
|
+
i = nil,
|
324
|
+
primary_hash = primary_hash?
|
325
|
+
)
|
326
|
+
if i
|
327
|
+
case i
|
328
|
+
# ====================================================================== #
|
329
|
+
# === :everything
|
330
|
+
#
|
331
|
+
# This entry point will add every available component.
|
332
|
+
# ====================================================================== #
|
333
|
+
when :everything
|
334
|
+
add(return_all_available_components)
|
335
|
+
# ====================================================================== #
|
336
|
+
# === :pkgconfig_entries
|
337
|
+
# ====================================================================== #
|
338
|
+
when :pkgconfig_entries
|
339
|
+
add(::EnvironmentInformation.return_pkgconfig_based_programs)
|
340
|
+
# ====================================================================== #
|
341
|
+
# === :all_xorg_components
|
342
|
+
# ====================================================================== #
|
343
|
+
when :all_xorg_components
|
344
|
+
add(return_all_xorg_components)
|
345
|
+
# ====================================================================== #
|
346
|
+
# === envi --science
|
347
|
+
# ====================================================================== #
|
348
|
+
when :science_cluster
|
349
|
+
add(science_cluster?)
|
350
|
+
# ====================================================================== #
|
351
|
+
# === envi --lfs_core_programs
|
352
|
+
# ====================================================================== #
|
353
|
+
when :lfs,
|
354
|
+
:lfs_core_programs
|
355
|
+
add(::EnvironmentInformation.lfs_core_programs?)
|
356
|
+
# ====================================================================== #
|
357
|
+
# === :linux_kernel
|
358
|
+
# ====================================================================== #
|
359
|
+
when :linux_kernel
|
360
|
+
add(:linux)
|
361
|
+
else
|
362
|
+
result = nil
|
363
|
+
# ====================================================================== #
|
364
|
+
# === Handle Arrays as input first
|
365
|
+
# ====================================================================== #
|
366
|
+
if i.is_a? Array
|
367
|
+
i.flatten.compact.each {|this_component|
|
368
|
+
add(this_component, primary_hash)
|
369
|
+
}
|
370
|
+
# ====================================================================== #
|
371
|
+
# === Handle Strings containing ',' next
|
372
|
+
# ====================================================================== #
|
373
|
+
elsif i.is_a?(String) and i.include?(',')
|
374
|
+
# ==================================================================== #
|
375
|
+
# Strings containing ',' will be split accordingly.
|
376
|
+
# ==================================================================== #
|
377
|
+
entry = i.split(',')
|
378
|
+
add(entry)
|
379
|
+
else
|
380
|
+
# ==================================================================== #
|
381
|
+
# === Handle Strings containing '-' next
|
382
|
+
# ==================================================================== #
|
383
|
+
if i.is_a?(String) and i.include?('-')
|
384
|
+
i = i.dup if i.frozen?
|
385
|
+
i.delete!('-')
|
386
|
+
end
|
387
|
+
i = i.to_sym unless i.is_a?(Symbol) # i will always be a Symbol past this point.
|
388
|
+
unless primary_hash.has_key?(i)
|
389
|
+
case i
|
390
|
+
# ================================================================== #
|
391
|
+
# === :rubygems_installation_directory
|
392
|
+
# ================================================================== #
|
393
|
+
when :rubygems_installation_directory,
|
394
|
+
/^rubygems( |_)?installation( |_)?directory\??$/i
|
395
|
+
result = return_rubygems_installation_directory
|
396
|
+
# ================================================================== #
|
397
|
+
# === :operating_system_bit_type
|
398
|
+
# ================================================================== #
|
399
|
+
when :operating_system_bit_type,
|
400
|
+
/^operating(_|-| )?system(_|-| )?bit(_|-| )?type$/i
|
401
|
+
result = return_operating_system_bit_type
|
402
|
+
# ================================================================== #
|
403
|
+
# === :operating_system
|
404
|
+
# ================================================================== #
|
405
|
+
when :operating_system,
|
406
|
+
/^Operating(_|-| )?system$/i,
|
407
|
+
/^operating(_|-)?system(_|-)?in(_|-)?use$/i
|
408
|
+
result = return_operating_system
|
409
|
+
# ================================================================== #
|
410
|
+
# === :ram
|
411
|
+
# ================================================================== #
|
412
|
+
when :ram,
|
413
|
+
/^RAM$/i
|
414
|
+
result = ram?
|
415
|
+
# ================================================================== #
|
416
|
+
# === :cflags
|
417
|
+
# ================================================================== #
|
418
|
+
when :cflags,
|
419
|
+
/^cflags$/i,
|
420
|
+
/^cflags(_|-| )?in(_|-| )?use$/i
|
421
|
+
result = cflags_in_use?
|
422
|
+
# ================================================================== #
|
423
|
+
# === :cpuinfo
|
424
|
+
# ================================================================== #
|
425
|
+
when :cpuinfo,
|
426
|
+
/^cpuinfo$/i,
|
427
|
+
/^CPU(_|-| )?Model/
|
428
|
+
result = return_cpuinfo
|
429
|
+
# ================================================================== #
|
430
|
+
# === :screen_resolution
|
431
|
+
# ================================================================== #
|
432
|
+
when :screen_resolution,
|
433
|
+
/^screen( |_)?resolution$/i
|
434
|
+
result = screen_resolution?
|
435
|
+
else
|
436
|
+
i = ::EnvironmentInformation.return_alias_to(i)
|
437
|
+
cmd = QUERY_TO_USE_FOR_ALL_COMPONENTS[i.to_s]
|
438
|
+
case cmd.to_s # case tag
|
439
|
+
# ================================================================ #
|
440
|
+
# === special_entry_for_doubleconversion
|
441
|
+
# ================================================================ #
|
442
|
+
when /special_entry_for_doubleconversion/
|
443
|
+
result = ::EnvironmentInformation.return_version_of_doubleconversion
|
444
|
+
# ================================================================ #
|
445
|
+
# === custom_boost
|
446
|
+
# ================================================================ #
|
447
|
+
when 'custom_boost'
|
448
|
+
result = ::EnvironmentInformation.return_version_of_boost
|
449
|
+
# ================================================================ #
|
450
|
+
# === custom_mpc
|
451
|
+
# ================================================================ #
|
452
|
+
when 'custom_mpc'
|
453
|
+
result = ::EnvironmentInformation.return_version_of_mpc
|
454
|
+
# ================================================================ #
|
455
|
+
# === short_version
|
456
|
+
# ================================================================ #
|
457
|
+
when 'short_version'
|
458
|
+
result = silent_query("#{i} -v")
|
459
|
+
# ================================================================ #
|
460
|
+
# === custom_xvid
|
461
|
+
# ================================================================ #
|
462
|
+
when /custom_xvid/
|
463
|
+
result = return_xvid_version
|
464
|
+
# ================================================================ #
|
465
|
+
# === custom_busybox
|
466
|
+
# ================================================================ #
|
467
|
+
when 'custom_busybox'
|
468
|
+
result = ::EnvironmentInformation.return_version_of_busybox
|
469
|
+
# ================================================================ #
|
470
|
+
# === custom_xrandr
|
471
|
+
# ================================================================ #
|
472
|
+
when /custom_xrandr/
|
473
|
+
result = ::EnvironmentInformation.return_version_of_xrandr
|
474
|
+
# ================================================================ #
|
475
|
+
# === pkgconfig
|
476
|
+
# ================================================================ #
|
477
|
+
when /pkgconfig$/
|
478
|
+
# ============================================================== #
|
479
|
+
# In this case we do a default pkgconfig run, using the name
|
480
|
+
# of the entry at hand.
|
481
|
+
# ============================================================== #
|
482
|
+
intermediate_result = ::EnvironmentInformation.query_pkgconfig_version_for(i)
|
483
|
+
result = intermediate_result.strip
|
484
|
+
# ============================================================== #
|
485
|
+
# And we can "exit" here, aka call the next element.
|
486
|
+
# ============================================================== #
|
487
|
+
# ================================================================ #
|
488
|
+
# === version
|
489
|
+
#
|
490
|
+
# This is, for instance, "ruby --version".
|
491
|
+
# ================================================================ #
|
492
|
+
when /^version$/i
|
493
|
+
intermediate_result = silent_query("#{i} --version")
|
494
|
+
result = sanitize_this_version_string(intermediate_result)
|
495
|
+
else
|
496
|
+
result = sanitize_this_version_string(silent_query(cmd))
|
497
|
+
end
|
498
|
+
# ================================================================ #
|
499
|
+
# Do some post-processing next:
|
500
|
+
# ================================================================ #
|
501
|
+
if result.include?("\n")
|
502
|
+
splitted = result.split("\n")
|
503
|
+
if splitted.first == "\n"
|
504
|
+
result = splitted[1 .. -1].join("\n")
|
505
|
+
end
|
506
|
+
end
|
507
|
+
if result.include? 'no version information available (required by '
|
508
|
+
# ============================================================== #
|
509
|
+
# In this case we have some external problem which will be
|
510
|
+
# ignored by environment_information.
|
511
|
+
# ============================================================== #
|
512
|
+
splitted = result.split("\n")
|
513
|
+
splitted.reject! {|entry| entry.include? 'no version information available (required by ' }
|
514
|
+
result = splitted.join("\n")
|
515
|
+
end
|
516
|
+
result = ::EnvironmentInformation.sanitize_this_program_version(result)
|
517
|
+
if result.include? 'ruby '
|
518
|
+
new_match = result.scan(/ruby (\d{1,2}\.\d{1,2}\.\d{1,2})/).flatten.first
|
519
|
+
result = new_match if new_match
|
520
|
+
end
|
521
|
+
if result.include? 'RELION version: '
|
522
|
+
result = result.split(/RELION version: /).flatten.last
|
523
|
+
end
|
524
|
+
if result.include? 'Make'
|
525
|
+
result.sub!(/Make/,'')
|
526
|
+
end
|
527
|
+
if result.include? "#{entry}-" # The entry includes itself and a '-'.
|
528
|
+
result.sub!(/#{entry.to_s}-/,'')
|
529
|
+
elsif result.include? entry.to_s # The entry includes itself.
|
530
|
+
result.sub!(/#{entry.to_s}/,'')
|
531
|
+
end
|
532
|
+
if result.count("\n") > 0
|
533
|
+
result = result.split("\n").first
|
534
|
+
end
|
535
|
+
if result.include? ', version' # This is specifically for Bash.'
|
536
|
+
# GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
|
537
|
+
new_value = result.scan(
|
538
|
+
/, version (\d{1,2}\.\d{1,2}\.\d{1,2})/ # See: https://rubular.com/r/t3Ma5fpSPyGjqR
|
539
|
+
).flatten.first
|
540
|
+
result = new_value if new_value
|
541
|
+
end
|
542
|
+
if result.include?('(') and result.include?(')')
|
543
|
+
result = result.split(')').last
|
544
|
+
end
|
545
|
+
if result.include?('(') # Such as for 'XTerm(390'
|
546
|
+
result = result.split('(').last
|
547
|
+
end
|
548
|
+
if result.include? 'paper '
|
549
|
+
result.sub!(/paper /,'')
|
550
|
+
end
|
551
|
+
if result.include? 'version '
|
552
|
+
result.sub!(/version/,'')
|
553
|
+
end
|
554
|
+
if result.include? ' - ' # For lighttpd.
|
555
|
+
result = result.split(/ - /).first
|
556
|
+
end
|
557
|
+
if result.include? '--'
|
558
|
+
result.delete!('-')
|
559
|
+
end
|
560
|
+
if result.include? '/' # e. g. "nginx/1.24.0"
|
561
|
+
result = result.split('/').last
|
562
|
+
end
|
563
|
+
result[0,1] = '' if result.start_with?('/')
|
564
|
+
result.rstrip!
|
565
|
+
result = check_for_nil_values(result, i)
|
566
|
+
end
|
567
|
+
if result
|
568
|
+
# if result.include?(' ')
|
569
|
+
# result = result.split(' ').last
|
570
|
+
# end
|
571
|
+
i = i.to_sym
|
572
|
+
# ============================================================== #
|
573
|
+
# Always register it directly here:
|
574
|
+
# ============================================================== #
|
575
|
+
@internal_hash[:the_primary_hash][i] = result
|
576
|
+
if display_the_results_at_once?
|
577
|
+
display_this_component(i)
|
578
|
+
end
|
579
|
+
end
|
580
|
+
end
|
581
|
+
end
|
582
|
+
end
|
583
|
+
end
|
584
|
+
end; alias show_these_entries add # === show_these_entries
|
585
|
+
alias set_additional add # === set_additional
|
586
|
+
alias update_version_for add # === update_version_for
|
587
|
+
alias append add # === append
|
588
|
+
alias append_this_to_main_string add # === append_this_to_main_string
|
589
|
+
|
590
|
+
# ========================================================================== #
|
591
|
+
# === check_this_hash_for_unavailable_programs
|
592
|
+
# ========================================================================== #
|
593
|
+
def check_this_hash_for_unavailable_programs(
|
594
|
+
hash
|
595
|
+
)
|
596
|
+
# ======================================================================== #
|
597
|
+
# Register that this program is not available.
|
598
|
+
# ======================================================================== #
|
599
|
+
register_unavailable_program(
|
600
|
+
hash.select {|key, value|
|
601
|
+
value.include?(NOT_FOUND)
|
602
|
+
}.keys
|
603
|
+
)
|
604
|
+
end
|
605
|
+
|
606
|
+
# ========================================================================== #
|
607
|
+
# === remove_these_components
|
608
|
+
#
|
609
|
+
# This method can be used to remove registered components again.
|
610
|
+
# ========================================================================== #
|
611
|
+
def remove_these_components(
|
612
|
+
i
|
613
|
+
)
|
614
|
+
# ======================================================================== #
|
615
|
+
# === Handle Strings containing ',' first
|
616
|
+
# ======================================================================== #
|
617
|
+
if i.is_a?(String) and i.include?(',')
|
618
|
+
splitted = i.split(',')
|
619
|
+
remove_these_components(splitted)
|
620
|
+
# ======================================================================== #
|
621
|
+
# === Handle Arrays next
|
622
|
+
# ======================================================================== #
|
623
|
+
elsif i.is_a? Array
|
624
|
+
i.flatten.each {|entry|
|
625
|
+
remove_these_components(entry)
|
626
|
+
}
|
627
|
+
else
|
628
|
+
i = i.to_sym
|
629
|
+
primary_hash = primary_hash?
|
630
|
+
if primary_hash.has_key? i
|
631
|
+
primary_hash.delete(i)
|
632
|
+
end
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
# ========================================================================== #
|
637
|
+
# === right_side
|
638
|
+
# ========================================================================== #
|
639
|
+
def right_side(i)
|
640
|
+
if use_colours?
|
641
|
+
return send(::EnvironmentInformation.colour_for_the_right_side, i)
|
642
|
+
else
|
643
|
+
return i
|
644
|
+
end
|
645
|
+
end; alias colourize_this_in_the_right_side_colour right_side # === colourize_this_in_the_right_side_colour
|
646
|
+
|
647
|
+
# ========================================================================== #
|
648
|
+
# === clear_hash_and_missing_components
|
649
|
+
# ========================================================================== #
|
650
|
+
def clear_hash_and_missing_components
|
651
|
+
clear_toplevel_hash
|
652
|
+
clear_missing_components
|
653
|
+
end
|
654
|
+
|
655
|
+
# ========================================================================== #
|
656
|
+
# === show_the_registered_components
|
657
|
+
# ========================================================================== #
|
658
|
+
def show_the_registered_components(
|
659
|
+
i = tracked_programs?
|
660
|
+
)
|
661
|
+
e
|
662
|
+
e "#{rev}The following components are currently tracked:"
|
663
|
+
e
|
664
|
+
use_one_line_to_show_the_result = use_one_line_to_show_the_result?
|
665
|
+
i.each_with_index {|this_program, index| index += 1
|
666
|
+
if use_one_line_to_show_the_result
|
667
|
+
padded_index = index.to_s+') '
|
668
|
+
else
|
669
|
+
padded_index = ' '+(index.to_s+') ').rjust(5)
|
670
|
+
end
|
671
|
+
colourized_and_padded_index = seagreen(padded_index)
|
672
|
+
e colourized_and_padded_index+
|
673
|
+
steelblue(this_program)
|
674
|
+
}
|
675
|
+
e
|
676
|
+
end
|
677
|
+
|
678
|
+
# ========================================================================== #
|
679
|
+
# === consider_storing_which_programs_are_not_up_to_date
|
680
|
+
# ========================================================================== #
|
681
|
+
def consider_storing_which_programs_are_not_up_to_date(
|
682
|
+
temp_dir = temp_dir?,
|
683
|
+
array_programs_that_are_not_up_to_date = array_these_programs_not_up_to_date?
|
684
|
+
)
|
685
|
+
if shall_we_really_store_which_programs_are_not_up_to_date? # This also checks for a roebe-system.
|
686
|
+
into = FILE_THESE_PROGRAMS_CAN_BE_UPGRADED
|
687
|
+
what = YAML.dump(array_programs_that_are_not_up_to_date)
|
688
|
+
if File.directory?(temp_dir)
|
689
|
+
into = "#{temp_dir}#{File.basename(into)}"
|
690
|
+
else
|
691
|
+
into = "#{temp_dir}#{File.basename(into)}"
|
692
|
+
end
|
693
|
+
opne "#{rev}We will also store which programs are not up to date."
|
694
|
+
opne "These will be stored into the file "\
|
695
|
+
"at `#{sfile(into)}#{rev}`."
|
696
|
+
::EnvironmentInformation.write_what_into(what, into)
|
697
|
+
end
|
698
|
+
end
|
699
|
+
|
700
|
+
# ========================================================================== #
|
701
|
+
# === do_not_run_already
|
702
|
+
# ========================================================================== #
|
703
|
+
def do_not_run_already
|
704
|
+
@internal_hash[:run_already] = false
|
705
|
+
end; alias do_not_run do_not_run_already # === do_not_run
|
706
|
+
|
707
|
+
# ========================================================================== #
|
708
|
+
# === run_already?
|
709
|
+
# ========================================================================== #
|
710
|
+
def run_already?
|
711
|
+
@internal_hash[:run_already]
|
712
|
+
end
|
713
|
+
|
714
|
+
# ========================================================================== #
|
715
|
+
# === set_array_work_on_these_components
|
716
|
+
# ========================================================================== #
|
717
|
+
def set_array_work_on_these_components(
|
718
|
+
i
|
719
|
+
)
|
720
|
+
hash = primary_hash?
|
721
|
+
i = [i].flatten
|
722
|
+
i.each {|this_entry|
|
723
|
+
hash[this_entry.to_sym] = nil
|
724
|
+
}
|
725
|
+
end; alias set_main_array set_array_work_on_these_components # === set_main_array
|
726
|
+
alias set_display_these_components set_array_work_on_these_components # === set_display_these_components
|
727
|
+
alias set_use_this_as_main_input set_array_work_on_these_components # === set_use_this_as_main_input
|
728
|
+
alias set_report_these_programs set_array_work_on_these_components # === set_report_these_programs
|
729
|
+
alias show_only_the_components_from_this_dataset set_array_work_on_these_components # === show_only_the_components_from_this_dataset
|
730
|
+
|
731
|
+
# ========================================================================== #
|
732
|
+
# === do_sort_alphabetically (sort tag)
|
733
|
+
#
|
734
|
+
# Some entries are Symbols, which is why we have to call .to_s in the
|
735
|
+
# method here.
|
736
|
+
# ========================================================================== #
|
737
|
+
def do_sort_alphabetically(
|
738
|
+
i = work_on_which_components?
|
739
|
+
)
|
740
|
+
_ = i.sort_by {|name, version| name.to_s }
|
741
|
+
set_main_array(_)
|
742
|
+
end
|
743
|
+
|
744
|
+
# ========================================================================== #
|
745
|
+
# === query_this_version
|
746
|
+
# ========================================================================== #
|
747
|
+
def query_this_version(
|
748
|
+
i,
|
749
|
+
query_hash = return_hash_query_to_use_for_all_components
|
750
|
+
)
|
751
|
+
use_this_query = query_hash[i]
|
752
|
+
# ======================================================================== #
|
753
|
+
# Next, feed it to the main query-code:
|
754
|
+
# ======================================================================== #
|
755
|
+
result = silent_query(use_this_query)
|
756
|
+
if result
|
757
|
+
result.strip
|
758
|
+
else
|
759
|
+
nil
|
760
|
+
end
|
761
|
+
end
|
762
|
+
|
763
|
+
# ========================================================================== #
|
764
|
+
# === main_hash?
|
765
|
+
# ========================================================================== #
|
766
|
+
def main_hash?
|
767
|
+
::EnvironmentInformation.hash?
|
768
|
+
end
|
769
|
+
|
770
|
+
# ========================================================================== #
|
771
|
+
# === generate_a_html_file?
|
772
|
+
# ========================================================================== #
|
773
|
+
def generate_a_html_file?
|
774
|
+
@internal_hash[:generate_a_html_file]
|
775
|
+
end
|
776
|
+
|
777
|
+
# ========================================================================== #
|
778
|
+
# === do_generate_a_html_file (html tag)
|
779
|
+
#
|
780
|
+
# The action-method that will generate the html file. This depends
|
781
|
+
# on the gem html_tags, with module HtmlTags though.
|
782
|
+
#
|
783
|
+
# To invoke this method, do:
|
784
|
+
#
|
785
|
+
# envi --generate-html-file
|
786
|
+
#
|
787
|
+
# ========================================================================== #
|
788
|
+
def do_generate_a_html_file(
|
789
|
+
styling_instructions = :none
|
790
|
+
)
|
791
|
+
# ======================================================================== #
|
792
|
+
# === Ensure that the html_tags project is available
|
793
|
+
# ======================================================================== #
|
794
|
+
unless Object.const_defined? :HtmlTags
|
795
|
+
begin
|
796
|
+
require 'html_tags'
|
797
|
+
rescue LoadError
|
798
|
+
e 'html_tags is not available. Considering installing it via:'
|
799
|
+
e
|
800
|
+
e ' gem install html_tags'
|
801
|
+
e
|
802
|
+
end
|
803
|
+
end
|
804
|
+
# ======================================================================== #
|
805
|
+
# === Define where to store the .html file in question
|
806
|
+
# ======================================================================== #
|
807
|
+
this_html_file = "#{temp_directory?}environment_information.html"
|
808
|
+
# ======================================================================== #
|
809
|
+
# Obtain the main dataset next.
|
810
|
+
# ======================================================================== #
|
811
|
+
what = dataset_as_string
|
812
|
+
case styling_instructions
|
813
|
+
# ======================================================================== #
|
814
|
+
# === :bold
|
815
|
+
# ======================================================================== #
|
816
|
+
when :bold
|
817
|
+
what = HtmlTags.b(what)
|
818
|
+
end
|
819
|
+
what = HtmlTags.html(
|
820
|
+
HtmlTags.title('Information about the local environment')+
|
821
|
+
HtmlTags.body(
|
822
|
+
HtmlTags.h1(
|
823
|
+
'Your environment',
|
824
|
+
css_style: 'margin-top: 0.5em; margin-bottom: 0.5em; '\
|
825
|
+
'padding: 2px;'
|
826
|
+
)+
|
827
|
+
HtmlTags.pre(
|
828
|
+
what,
|
829
|
+
css_style: 'font-weight: bold; font-size: 2em; '\
|
830
|
+
'padding-left: 1.0em; margin-top:2px;'
|
831
|
+
)
|
832
|
+
)
|
833
|
+
)
|
834
|
+
::EnvironmentInformation.write_what_into(what, this_html_file)
|
835
|
+
# ======================================================================== #
|
836
|
+
# Notify the user what has been done.
|
837
|
+
# ======================================================================== #
|
838
|
+
if File.exist? this_html_file
|
839
|
+
opne "#{rev}Generated a HTML file at"
|
840
|
+
opne "`#{sfile(this_html_file)}#{rev}`."
|
841
|
+
end
|
842
|
+
end
|
843
|
+
|
844
|
+
# ========================================================================== #
|
845
|
+
# === do_really_create_a_html_file
|
846
|
+
# ========================================================================== #
|
847
|
+
def do_really_create_a_html_file
|
848
|
+
@internal_hash[:generate_a_html_file] = true
|
849
|
+
end
|
850
|
+
|
851
|
+
# ========================================================================== #
|
852
|
+
# === store_this_hash_into_a_local_file
|
853
|
+
# ========================================================================== #
|
854
|
+
def store_this_hash_into_a_local_file(
|
855
|
+
hash = the_primary_hash?,
|
856
|
+
this_file = ::EnvironmentInformation.return_path_to_all_programs_file
|
857
|
+
)
|
858
|
+
unless hash.empty?
|
859
|
+
e
|
860
|
+
e "#{rev}Storing these results into the local file at"
|
861
|
+
e "`#{sfile(this_file)}#{rev}`."
|
862
|
+
e
|
863
|
+
::EnvironmentInformation.store_this_hash_into_a_local_file(hash, this_file)
|
864
|
+
end
|
865
|
+
end; alias consider_storing_the_components_that_were_displayed store_this_hash_into_a_local_file # === consider_storing_the_components_that_were_displayed
|
866
|
+
alias consider_storing_which_components_were_displayed store_this_hash_into_a_local_file # === consider_storing_which_components_were_displayed
|
867
|
+
|
868
|
+
# ========================================================================== #
|
869
|
+
# === clear_the_main_dataset
|
870
|
+
# ========================================================================== #
|
871
|
+
def clear_the_main_dataset
|
872
|
+
clear_the_old_dataset
|
873
|
+
do_not_display_the_ruby_components
|
874
|
+
end; alias clear_main_dataset clear_the_main_dataset # === clear_main_dataset
|
875
|
+
alias empty_main_dataset clear_the_main_dataset # === empty_main_dataset
|
876
|
+
alias empty_main_array clear_the_main_dataset # === empty_main_array
|
877
|
+
|
878
|
+
# ========================================================================== #
|
879
|
+
# === do_show_only_the_operating_system
|
880
|
+
#
|
881
|
+
# To invoke this method, try:
|
882
|
+
#
|
883
|
+
# envi --os?
|
884
|
+
#
|
885
|
+
# ========================================================================== #
|
886
|
+
def do_show_only_the_operating_system
|
887
|
+
clear_old_dataset
|
888
|
+
add(:operating_system)
|
889
|
+
end
|
890
|
+
|
891
|
+
# ========================================================================== #
|
892
|
+
# === open_this_file_in_editor
|
893
|
+
# ========================================================================== #
|
894
|
+
def open_this_file_in_editor
|
895
|
+
_ = "geany #{THIS_FILE}"
|
896
|
+
e _; system _; exit
|
897
|
+
end
|
898
|
+
|
899
|
+
# ========================================================================== #
|
900
|
+
# === cflags_in_use?
|
901
|
+
# ========================================================================== #
|
902
|
+
def cflags_in_use?
|
903
|
+
::EnvironmentInformation.cflags?
|
904
|
+
end; alias cflags? cflags_in_use? # === cflags?
|
905
|
+
|
906
|
+
# ========================================================================== #
|
907
|
+
# === is_a_registered_component?
|
908
|
+
# ========================================================================== #
|
909
|
+
def is_a_registered_component?(i)
|
910
|
+
::EnvironmentInformation.is_this_component_included?(i)
|
911
|
+
end; alias is_an_allowed_entry? is_a_registered_component? # === is_an_allowed_entry?
|
912
|
+
|
913
|
+
# ========================================================================== #
|
914
|
+
# === return_version_of_awk?
|
915
|
+
# ========================================================================== #
|
916
|
+
def return_version_of_awk?
|
917
|
+
::EnvironmentInformation.send(__method__)
|
918
|
+
end; alias return_version_of_awk return_version_of_awk? # === return_version_of_awk
|
919
|
+
|
920
|
+
# ========================================================================== #
|
921
|
+
# === return_version_of_binutils?
|
922
|
+
# ========================================================================== #
|
923
|
+
def return_version_of_binutils?
|
924
|
+
::EnvironmentInformation.send(__method__)
|
925
|
+
end; alias return_version_of_binutils return_version_of_binutils? # === return_version_of_binutils
|
926
|
+
|
927
|
+
# ========================================================================== #
|
928
|
+
# === return_version_of_coreutils?
|
929
|
+
# ========================================================================== #
|
930
|
+
def return_version_of_coreutils?
|
931
|
+
::EnvironmentInformation.send(__method__)
|
932
|
+
end; alias return_version_of_coreutils return_version_of_coreutils? # === return_version_of_coreutils
|
933
|
+
|
934
|
+
# ========================================================================== #
|
935
|
+
# === return_version_of_diffutils?
|
936
|
+
# ========================================================================== #
|
937
|
+
def return_version_of_diffutils?
|
938
|
+
::EnvironmentInformation.send(__method__)
|
939
|
+
end; alias return_version_of_diffutils return_version_of_diffutils? # === return_version_of_diffutils
|
940
|
+
|
941
|
+
# ========================================================================== #
|
942
|
+
# === return_version_of_gcc?
|
943
|
+
# ========================================================================== #
|
944
|
+
def return_version_of_gcc?
|
945
|
+
::EnvironmentInformation.send(__method__)
|
946
|
+
end; alias return_version_of_gcc return_version_of_gcc? # === return_version_of_gcc
|
947
|
+
|
948
|
+
# ========================================================================== #
|
949
|
+
# === return_version_of_linux_kernel?
|
950
|
+
# ========================================================================== #
|
951
|
+
def return_version_of_linux_kernel?
|
952
|
+
::EnvironmentInformation.send(__method__)
|
953
|
+
end; alias return_version_of_linux_kernel return_version_of_linux_kernel? # === return_version_of_linux_kernel
|
954
|
+
|
955
|
+
# ========================================================================== #
|
956
|
+
# === is_this_program_included?
|
957
|
+
# ========================================================================== #
|
958
|
+
def is_this_program_included?(i)
|
959
|
+
::EnvironmentInformation.is_this_program_included?(i)
|
960
|
+
end
|
961
|
+
|
962
|
+
# ========================================================================== #
|
963
|
+
# === return_version_of_glibc?
|
964
|
+
# ========================================================================== #
|
965
|
+
def return_version_of_glibc?
|
966
|
+
::EnvironmentInformation.send(__method__)
|
967
|
+
end; alias return_version_of_glibc return_version_of_glibc? # == return_version_of_glibc
|
968
|
+
|
969
|
+
# ========================================================================== #
|
970
|
+
# === screen_resolution?
|
971
|
+
# ========================================================================== #
|
972
|
+
def screen_resolution?
|
973
|
+
::EnvironmentInformation.screen_resolution?
|
974
|
+
end
|
975
|
+
|
976
|
+
# ========================================================================== #
|
977
|
+
# === return_hash_query_to_use_for_all_components
|
978
|
+
# ========================================================================== #
|
979
|
+
def return_hash_query_to_use_for_all_components
|
980
|
+
_ = QUERY_TO_USE_FOR_ALL_COMPONENTS
|
981
|
+
_.transform_keys! {|entry| entry.to_sym }
|
982
|
+
return _
|
983
|
+
end
|
984
|
+
|
985
|
+
# ========================================================================== #
|
986
|
+
# === result_as_array
|
987
|
+
#
|
988
|
+
# The lines that we will have inside of this method, may look like this:
|
989
|
+
#
|
990
|
+
# " operating_system: GNU/Linux\n"
|
991
|
+
#
|
992
|
+
# ========================================================================== #
|
993
|
+
def result_as_array
|
994
|
+
_ = dataset_as_string
|
995
|
+
splitted = _.split("\n")
|
996
|
+
splitted.map! {|inner_line|
|
997
|
+
inner_line.split(': ').map {|entry| entry.strip }
|
998
|
+
}
|
999
|
+
return splitted
|
1000
|
+
end; alias result result_as_array # === result
|
1001
|
+
|
1002
|
+
# ========================================================================== #
|
1003
|
+
# === do_not_save_anything
|
1004
|
+
# ========================================================================== #
|
1005
|
+
def do_not_save_anything
|
1006
|
+
do_not_store_anything_into_a_local_file
|
1007
|
+
# ======================================================================== #
|
1008
|
+
# We will also avoid saving the results into a local yaml file.
|
1009
|
+
# ======================================================================== #
|
1010
|
+
do_not_store_anything_into_a_local_file
|
1011
|
+
end; alias do_not_store_anything do_not_save_anything # === do_not_store_anything
|
1012
|
+
|
1013
|
+
# ========================================================================== #
|
1014
|
+
# === disable_colours
|
1015
|
+
#
|
1016
|
+
# Call this method when you wish to disable the colours. Note that
|
1017
|
+
# this will disable colours on the toplevel.
|
1018
|
+
# ========================================================================== #
|
1019
|
+
def disable_colours
|
1020
|
+
super()
|
1021
|
+
::EnvironmentInformation.use_colours = false
|
1022
|
+
end; alias no_colours disable_colours # === no_colours()
|
1023
|
+
|
1024
|
+
# ========================================================================== #
|
1025
|
+
# === enable_colours
|
1026
|
+
# ========================================================================== #
|
1027
|
+
def enable_colours
|
1028
|
+
super()
|
1029
|
+
::EnvironmentInformation.use_colours = true
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
# ========================================================================== #
|
1033
|
+
# === clear_the_main_hash
|
1034
|
+
# ========================================================================== #
|
1035
|
+
def clear_the_main_hash
|
1036
|
+
@internal_hash[:the_primary_hash].clear
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
# ========================================================================== #
|
1040
|
+
# === add_this_to_the_toplevel_hash
|
1041
|
+
# ========================================================================== #
|
1042
|
+
def add_this_to_the_toplevel_hash(a, b)
|
1043
|
+
a = a.to_sym unless a.is_a? Symbol
|
1044
|
+
::EnvironmentInformation.hash?[a] = b
|
1045
|
+
end; alias register_onto_the_main_hash add_this_to_the_toplevel_hash # === register_onto_the_main_hash
|
1046
|
+
|
1047
|
+
# ========================================================================== #
|
1048
|
+
# === return_all_available_components
|
1049
|
+
# ========================================================================== #
|
1050
|
+
def return_all_available_components
|
1051
|
+
_ = dataset_containing_all_tracked_programs?
|
1052
|
+
# ======================================================================== #
|
1053
|
+
# === The mate-desktop
|
1054
|
+
#
|
1055
|
+
# Since as of 31.03.2019 we will also try to show the mate-desktop
|
1056
|
+
# components if the RBT project is available/installed.
|
1057
|
+
# ======================================================================== #
|
1058
|
+
if can_we_query_the_mate_desktop?
|
1059
|
+
# ====================================================================== #
|
1060
|
+
# Keep in mind that this Array is nested, so the name is
|
1061
|
+
# included as well as the version.
|
1062
|
+
# ====================================================================== #
|
1063
|
+
array = RBT.return_mate_desktop_version_array
|
1064
|
+
array.each {|a,b|
|
1065
|
+
# array << [a, b]
|
1066
|
+
_ << a
|
1067
|
+
the_primary_hash?[a.to_sym] = b
|
1068
|
+
}
|
1069
|
+
end
|
1070
|
+
result = _.flatten
|
1071
|
+
return result
|
1072
|
+
end; alias return_every_registered_component return_all_available_components # === return_every_registered_component
|
1073
|
+
|
1074
|
+
# ========================================================================== #
|
1075
|
+
# === clear_missing_components
|
1076
|
+
# ========================================================================== #
|
1077
|
+
def clear_missing_components
|
1078
|
+
::EnvironmentInformation.clear_missing_components
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
# ========================================================================== #
|
1082
|
+
# === shall_we_really_store_which_programs_are_not_up_to_date?
|
1083
|
+
#
|
1084
|
+
# This method will also honour whether the user is on a roebe-like
|
1085
|
+
# system or whether the user is not.
|
1086
|
+
# ========================================================================== #
|
1087
|
+
def shall_we_really_store_which_programs_are_not_up_to_date?
|
1088
|
+
is_on_roebe? and !array_these_programs_not_up_to_date?.empty?
|
1089
|
+
end
|
1090
|
+
|
1091
|
+
# ========================================================================== #
|
1092
|
+
# === array_these_programs_not_up_to_date?
|
1093
|
+
# ========================================================================== #
|
1094
|
+
def array_these_programs_not_up_to_date?
|
1095
|
+
@internal_hash[:array_these_programs_not_up_to_date]
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
# ========================================================================== #
|
1099
|
+
# === store_the_results_into_local_files?
|
1100
|
+
# ========================================================================== #
|
1101
|
+
def store_the_results_into_local_files?
|
1102
|
+
@internal_hash[:store_the_results_into_local_files]
|
1103
|
+
end; alias shall_we_store_the_main_hash_into_a_local_file? store_the_results_into_local_files? # === alias shall_we_store_the_main_hash_into_a_local_file?
|
1104
|
+
alias store_the_results_into_local_files? store_the_results_into_local_files? # === store_the_results_into_local_files?
|
1105
|
+
|
1106
|
+
# ========================================================================== #
|
1107
|
+
# === dataset_as_string
|
1108
|
+
#
|
1109
|
+
# This method must return the dataset in String format. That String
|
1110
|
+
# must already be properly "formatted".
|
1111
|
+
# ========================================================================== #
|
1112
|
+
def dataset_as_string(
|
1113
|
+
main_hash = the_primary_hash?
|
1114
|
+
)
|
1115
|
+
_ = ''.dup # Put the information onto that String here.
|
1116
|
+
main_dataset?.each {|entry|
|
1117
|
+
if entry.is_a? Array
|
1118
|
+
entry = entry.first # The second entry is ignored in that event.
|
1119
|
+
end
|
1120
|
+
# ====================================================================== #
|
1121
|
+
# Before we can use .send() we have to check whether EnvironmentInformation
|
1122
|
+
# actually responds to that method. If not then we will simply skip
|
1123
|
+
# this snippet for now; but this may have to be changed at some
|
1124
|
+
# point in the future, to more elegantly handle failure. (Sep 2019).
|
1125
|
+
# ====================================================================== #
|
1126
|
+
use_this_method = "return_version_of_#{entry}".to_sym
|
1127
|
+
if main_hash.has_key?(entry.to_sym)
|
1128
|
+
_ << " #{entry}: #{main_hash[entry.to_sym]}#{N}"
|
1129
|
+
elsif ::EnvironmentInformation.respond_to? use_this_method
|
1130
|
+
program_version = ::EnvironmentInformation.send(
|
1131
|
+
use_this_method
|
1132
|
+
)
|
1133
|
+
entry = " #{entry}:"
|
1134
|
+
_ << "#{entry} #{program_version}#{N}"
|
1135
|
+
else # Try a self-query here
|
1136
|
+
case entry.to_sym
|
1137
|
+
when 'pkgconfig'
|
1138
|
+
entry = ::EnvironmentInformation.query_pkgconfig_version_for(entry)
|
1139
|
+
end
|
1140
|
+
result = query_this_version(entry.to_sym)
|
1141
|
+
if result and !result.empty?
|
1142
|
+
entry = " #{entry}:"
|
1143
|
+
_ << "#{entry} #{result}#{N}"
|
1144
|
+
end
|
1145
|
+
end
|
1146
|
+
}
|
1147
|
+
return _ # And return the generated String.
|
1148
|
+
end; alias string? dataset_as_string # === string?
|
1149
|
+
alias string dataset_as_string # === string
|
1150
|
+
alias main_string? dataset_as_string # === main_string?
|
1151
|
+
alias stringified dataset_as_string # === stringified
|
1152
|
+
|
1153
|
+
# ========================================================================== #
|
1154
|
+
# === compare_via_gem_version
|
1155
|
+
# ========================================================================== #
|
1156
|
+
def compare_via_gem_version(i)
|
1157
|
+
begin
|
1158
|
+
Gem::Version.new(i)
|
1159
|
+
rescue ArgumentError => error
|
1160
|
+
e Colours.tomato(error)
|
1161
|
+
e "#{rev}We will continue nonetheless (#{i})"
|
1162
|
+
return nil
|
1163
|
+
end
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
# ========================================================================== #
|
1167
|
+
# === return_version_of_busyboxy?
|
1168
|
+
# ========================================================================== #
|
1169
|
+
def return_version_of_busyboxy?
|
1170
|
+
::EnvironmentInformation.send(__method__)
|
1171
|
+
end; alias return_version_of_busyboxy return_version_of_busyboxy? # == return_version_of_busyboxy
|
1172
|
+
|
1173
|
+
# ========================================================================== #
|
1174
|
+
# === return_version_of_boost?
|
1175
|
+
# ========================================================================== #
|
1176
|
+
def return_version_of_boost?
|
1177
|
+
::EnvironmentInformation.send(__method__)
|
1178
|
+
end; alias return_version_of_boost return_version_of_boost? # == return_version_of_boost
|
1179
|
+
|
1180
|
+
# ========================================================================== #
|
1181
|
+
# === return_version_of_xvid?
|
1182
|
+
# ========================================================================== #
|
1183
|
+
def return_version_of_xvid?
|
1184
|
+
::EnvironmentInformation.send(__method__)
|
1185
|
+
end; alias return_version_of_xvid return_version_of_xvid? # == return_version_of_xvid
|
1186
|
+
|
1187
|
+
# ========================================================================== #
|
1188
|
+
# === start_gtk_component
|
1189
|
+
#
|
1190
|
+
# To invoke this method from the commandline, do:
|
1191
|
+
#
|
1192
|
+
# envi --start-gtk
|
1193
|
+
#
|
1194
|
+
# ========================================================================== #
|
1195
|
+
def start_gtk_component
|
1196
|
+
require 'environment_information/gui/gtk3/environment_information.rb'
|
1197
|
+
::EnvironmentInformation.run_gtk
|
1198
|
+
@internal_hash[:do_exit_the_program] = true
|
1199
|
+
end
|
1200
|
+
|
1201
|
+
# ========================================================================== #
|
1202
|
+
# === do_show_almost_everything_excluding_the_default_linux_programs
|
1203
|
+
#
|
1204
|
+
# This is similar to do_show_everything() but it will not show
|
1205
|
+
# the default linux programs.
|
1206
|
+
# ========================================================================== #
|
1207
|
+
def do_show_almost_everything_excluding_the_default_linux_programs
|
1208
|
+
these_programs = return_every_registered_component
|
1209
|
+
default_programs = return_default_programs
|
1210
|
+
# ======================================================================== #
|
1211
|
+
# Next subtract those that are part in the default_programs.
|
1212
|
+
# ======================================================================== #
|
1213
|
+
these_programs.reject! {|entry|
|
1214
|
+
default_programs.include? entry
|
1215
|
+
}
|
1216
|
+
add(these_programs)
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
# ========================================================================== #
|
1220
|
+
# === display_the_results_at_once?
|
1221
|
+
# ========================================================================== #
|
1222
|
+
def display_the_results_at_once?
|
1223
|
+
@internal_hash[:display_the_results_at_once]
|
1224
|
+
end; alias insta_show? display_the_results_at_once? # === insta_show?
|
1225
|
+
|
1226
|
+
# ========================================================================== #
|
1227
|
+
# === can_we_query_the_mate_desktop?
|
1228
|
+
# ========================================================================== #
|
1229
|
+
def can_we_query_the_mate_desktop?
|
1230
|
+
is_rbt_available? and
|
1231
|
+
RBT.const_defined?(:Action) and
|
1232
|
+
RBT::Action.const_defined?(:ReportMateDesktopVersion)
|
1233
|
+
end
|
1234
|
+
|
1235
|
+
# ========================================================================== #
|
1236
|
+
# === report_the_installed_KDE_software_suite (KDE tag)
|
1237
|
+
# ========================================================================== #
|
1238
|
+
def report_the_installed_KDE_software_suite
|
1239
|
+
begin
|
1240
|
+
require 'rbt/toplevel_methods/toplevel_methods.rb'
|
1241
|
+
require 'rbt/toplevel_methods/try_to_return_a_special_compile_component.rb'
|
1242
|
+
require 'rbt/toplevel_methods/swift_return_version_of_this_program.rb'
|
1243
|
+
array = RBT.return_kde_apps
|
1244
|
+
append_this = ''.dup
|
1245
|
+
if array and !array.empty?
|
1246
|
+
e "#{rev}Now working through all registered KDE applications, "\
|
1247
|
+
"trying to"
|
1248
|
+
e 'show their version on the commandline:'
|
1249
|
+
e
|
1250
|
+
array.each {|this_program|
|
1251
|
+
append_this.clear
|
1252
|
+
# ================================================================= #
|
1253
|
+
# The next line of code was added in August 2022 because ksmoothdock
|
1254
|
+
# is misbehaving. At a later time we may have to review this;
|
1255
|
+
# ideally we should not need any such ad-hoc exceptions ever.
|
1256
|
+
# ================================================================= #
|
1257
|
+
next if this_program == 'ksmoothdock'
|
1258
|
+
print gold(
|
1259
|
+
(' '+this_program+':').ljust(40)
|
1260
|
+
)
|
1261
|
+
cmd_to_use = "#{this_program} --version"
|
1262
|
+
version = swift_query(cmd_to_use)
|
1263
|
+
if version.include?(NOT_FOUND) or version.include?('not found')
|
1264
|
+
version = NOT_FOUND
|
1265
|
+
else
|
1266
|
+
if version
|
1267
|
+
# Remove the name of the program here e. g. "kcachegrind 21.12.1"
|
1268
|
+
version.sub!(/#{this_program}/,'')
|
1269
|
+
most_recent_version = ::RBT.swift_return_version_of_this_program(this_program.strip.downcase)
|
1270
|
+
if RBT.is_this_version_higher_than_that_version?(
|
1271
|
+
most_recent_version.to_s,
|
1272
|
+
version.to_s,
|
1273
|
+
:do_not_report_any_errors
|
1274
|
+
)
|
1275
|
+
append_this << orange(
|
1276
|
+
"\n ^^^ This program could "\
|
1277
|
+
"be updated to version "+
|
1278
|
+
most_recent_version.to_s
|
1279
|
+
)
|
1280
|
+
end
|
1281
|
+
end
|
1282
|
+
end
|
1283
|
+
version.strip! unless version.frozen?
|
1284
|
+
if version.include?('The program is not installed') or
|
1285
|
+
version.include?(NOT_FOUND)
|
1286
|
+
e lightblue(version)+append_this
|
1287
|
+
else
|
1288
|
+
e steelblue(version)+append_this
|
1289
|
+
end
|
1290
|
+
}
|
1291
|
+
e
|
1292
|
+
else
|
1293
|
+
e 'The array appears to be empty.'
|
1294
|
+
end
|
1295
|
+
exit
|
1296
|
+
rescue LoadError; end
|
1297
|
+
end
|
1298
|
+
|
1299
|
+
# ========================================================================== #
|
1300
|
+
# === sync_the_primary_hash_onto_the_toplevel_hash
|
1301
|
+
# ========================================================================== #
|
1302
|
+
def sync_the_primary_hash_onto_the_toplevel_hash(
|
1303
|
+
i = the_primary_hash?
|
1304
|
+
)
|
1305
|
+
::EnvironmentInformation.clear_hash
|
1306
|
+
i.each_pair {|key, value|
|
1307
|
+
::EnvironmentInformation.add_to_hash(key, value.to_s.strip)
|
1308
|
+
}
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
# ========================================================================== #
|
1312
|
+
# === do_compare_the_program_version
|
1313
|
+
#
|
1314
|
+
# This method can be used if the user wishes to also compare the
|
1315
|
+
# program version of the installed programs. This functionality
|
1316
|
+
# depends on the rbt gem, and the RBT namespace.
|
1317
|
+
# ========================================================================== #
|
1318
|
+
def do_compare_the_program_version(
|
1319
|
+
be_verbose = false
|
1320
|
+
)
|
1321
|
+
if be_verbose
|
1322
|
+
e "#{rev}The program versions will also be compared."
|
1323
|
+
end
|
1324
|
+
@internal_hash[:compare_program_versions] = true
|
1325
|
+
end
|
1326
|
+
|
1327
|
+
# ========================================================================== #
|
1328
|
+
# === start_the_sinatra_interface
|
1329
|
+
# ========================================================================== #
|
1330
|
+
def start_the_sinatra_interface
|
1331
|
+
require 'environment_information/www/sinatra_interface.rb'
|
1332
|
+
::EnvironmentInformation.start_sinatra_interface
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
# ========================================================================== #
|
1336
|
+
# === clear_toplevel_hash
|
1337
|
+
# ========================================================================== #
|
1338
|
+
def clear_toplevel_hash
|
1339
|
+
::EnvironmentInformation.clear_hash
|
1340
|
+
end
|
1341
|
+
|
1342
|
+
# ========================================================================== #
|
1343
|
+
# === the_primary_hash?
|
1344
|
+
# ========================================================================== #
|
1345
|
+
def the_primary_hash?
|
1346
|
+
@internal_hash[:the_primary_hash]
|
1347
|
+
end; alias primary_hash? the_primary_hash? # === primary_hash?
|
1348
|
+
|
1349
|
+
# ========================================================================== #
|
1350
|
+
# === work_on_these_components?
|
1351
|
+
# ========================================================================== #
|
1352
|
+
def work_on_these_components?
|
1353
|
+
primary_hash?.keys
|
1354
|
+
end; alias components? work_on_these_components? # === components?
|
1355
|
+
alias main_dataset? work_on_these_components? # === main_dataset?
|
1356
|
+
alias main_entry? work_on_these_components? # === main_entry?
|
1357
|
+
alias dataset? work_on_these_components? # === dataset?
|
1358
|
+
alias result work_on_these_components? # === result
|
1359
|
+
alias result? work_on_these_components? # === result?
|
1360
|
+
alias array_obtain_these_programs? work_on_these_components? # === array_obtain_these_programs?
|
1361
|
+
alias array_with_entries? work_on_these_components? # === array_with_entries?
|
1362
|
+
alias main_array? work_on_these_components? # === main_array?
|
1363
|
+
alias programs? work_on_these_components? # === programs?
|
1364
|
+
alias show_these_components? work_on_these_components? # === show_these_components?
|
1365
|
+
alias array_display_these_components work_on_these_components? # === array_display_these_components
|
1366
|
+
alias array_work_on_these_components? work_on_these_components? # === array_work_on_these_components?
|
1367
|
+
alias display_these_components? work_on_these_components? # === display_these_components?
|
1368
|
+
alias display_which_components? work_on_these_components? # === display_which_components?
|
1369
|
+
alias display work_on_these_components? # === display
|
1370
|
+
alias work_on_which_components? work_on_these_components? # === work_on_which_components?
|
1371
|
+
|
1372
|
+
# ========================================================================== #
|
1373
|
+
# === set_runmode_gui
|
1374
|
+
# ========================================================================== #
|
1375
|
+
def set_runmode_gui
|
1376
|
+
@internal_hash[:runmode] = :gui
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
# ========================================================================== #
|
1380
|
+
# === set_runmode_html
|
1381
|
+
# ========================================================================== #
|
1382
|
+
def set_runmode_html
|
1383
|
+
@internal_hash[:runmode] = :html
|
1384
|
+
end
|
1385
|
+
|
1386
|
+
# ========================================================================== #
|
1387
|
+
# === gui?
|
1388
|
+
# ========================================================================== #
|
1389
|
+
def gui?
|
1390
|
+
runmode? == :gui
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
# ========================================================================== #
|
1394
|
+
# === commandline?
|
1395
|
+
#
|
1396
|
+
# Whether we run in the "commandline mode" or whether we run in the
|
1397
|
+
# GUI or WWW/HTML mode.
|
1398
|
+
# ========================================================================== #
|
1399
|
+
def commandline?
|
1400
|
+
runmode? == :commandline
|
1401
|
+
end
|
1402
|
+
|
1403
|
+
# ========================================================================== #
|
1404
|
+
# === runmode?
|
1405
|
+
# ========================================================================== #
|
1406
|
+
def runmode?
|
1407
|
+
@internal_hash[:runmode]
|
1408
|
+
end
|
1409
|
+
|
1410
|
+
# ========================================================================== #
|
1411
|
+
# === work_on_the_programs_directory_only
|
1412
|
+
#
|
1413
|
+
# This works on the /home/Programs/ directory directly.
|
1414
|
+
#
|
1415
|
+
# Invocation example:
|
1416
|
+
#
|
1417
|
+
# envi --work-on-programs-directory-only
|
1418
|
+
#
|
1419
|
+
# ========================================================================== #
|
1420
|
+
def work_on_the_programs_directory_only(
|
1421
|
+
use_this_as_programs_directory = '/home/Programs/'
|
1422
|
+
)
|
1423
|
+
# ======================================================================== #
|
1424
|
+
# 1) First, we have to determine which programs are available.
|
1425
|
+
# ======================================================================== #
|
1426
|
+
e "#{rev}Determining which programs are available at the prefix "\
|
1427
|
+
"#{steelblue(use_this_as_programs_directory)}:"
|
1428
|
+
array_these_programs_are_available = []
|
1429
|
+
tracked_programs?.each {|entry|
|
1430
|
+
target = "#{use_this_as_programs_directory}#{entry.capitalize}"
|
1431
|
+
if File.directory?(target)
|
1432
|
+
# ======================================================================== #
|
1433
|
+
# In this case we know that this target exists.
|
1434
|
+
# ======================================================================== #
|
1435
|
+
array_these_programs_are_available << entry
|
1436
|
+
end
|
1437
|
+
}
|
1438
|
+
# ======================================================================== #
|
1439
|
+
# 2) Checking these programs next.
|
1440
|
+
# ======================================================================== #
|
1441
|
+
clear_main_dataset
|
1442
|
+
add(array_these_programs_are_available)
|
1443
|
+
::EnvironmentInformation.set_prefix_to_use(use_this_as_programs_directory)
|
1444
|
+
end
|
1445
|
+
|
1446
|
+
# ========================================================================== #
|
1447
|
+
# === do_report_the_remote_urls
|
1448
|
+
#
|
1449
|
+
# This method will enable the reporting of the remote URLs, if
|
1450
|
+
# available.
|
1451
|
+
# ========================================================================== #
|
1452
|
+
def do_report_the_remote_urls
|
1453
|
+
@internal_hash[:report_the_remote_urls] = true
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
# ========================================================================== #
|
1457
|
+
# === report_the_remote_urls?
|
1458
|
+
# ========================================================================== #
|
1459
|
+
def report_the_remote_urls?
|
1460
|
+
@internal_hash[:report_the_remote_urls]
|
1461
|
+
end
|
1462
|
+
|
1463
|
+
# ========================================================================== #
|
1464
|
+
# === dont_show_ruby_stuff
|
1465
|
+
#
|
1466
|
+
# Disable showing ruby + gem information.
|
1467
|
+
# ========================================================================== #
|
1468
|
+
def dont_show_ruby_stuff # Dont show ruby stuff.
|
1469
|
+
@internal_hash[:show_ruby_version_and_gem_version] = false
|
1470
|
+
end; alias show_no_ruby dont_show_ruby_stuff # === show_no_ruby
|
1471
|
+
alias do_not_show_the_ruby_components dont_show_ruby_stuff # === do_not_show_the_ruby_components
|
1472
|
+
alias do_not_display_the_ruby_components dont_show_ruby_stuff # === do_not_display_the_ruby_components
|
1473
|
+
|
1474
|
+
# ========================================================================== #
|
1475
|
+
# === return_rubygems_installation_directory
|
1476
|
+
# ========================================================================== #
|
1477
|
+
def return_rubygems_installation_directory
|
1478
|
+
return ::EnvironmentInformation.rubygems_installation_directory
|
1479
|
+
end; alias rubygems_installation_directory? return_rubygems_installation_directory # === rubygems_installation_directory?
|
1480
|
+
|
1481
|
+
# ========================================================================== #
|
1482
|
+
# === return_version_of_rubygems?
|
1483
|
+
#
|
1484
|
+
# This method will return the rubygems-version at hand.
|
1485
|
+
# ========================================================================== #
|
1486
|
+
def return_version_of_rubygems?
|
1487
|
+
::EnvironmentInformation.send(__method__)
|
1488
|
+
end; alias return_version_of_rubygems return_version_of_rubygems? # == return_version_of_rubygems
|
1489
|
+
|
1490
|
+
# ========================================================================== #
|
1491
|
+
# === return_version_of_ruby?
|
1492
|
+
# ========================================================================== #
|
1493
|
+
def return_version_of_ruby?
|
1494
|
+
::EnvironmentInformation.send(__method__)
|
1495
|
+
end; alias return_version_of_ruby return_version_of_ruby? # == return_version_of_ruby
|
1496
|
+
|
1497
|
+
# ========================================================================== #
|
1498
|
+
# === may_we_try_to_use_rbt?
|
1499
|
+
# ========================================================================== #
|
1500
|
+
def may_we_try_to_use_rbt?
|
1501
|
+
@internal_hash[:may_we_try_to_use_rbt]
|
1502
|
+
end
|
1503
|
+
|
1504
|
+
# ========================================================================== #
|
1505
|
+
# === show_n_registered_entries
|
1506
|
+
#
|
1507
|
+
# Invoke this via:
|
1508
|
+
#
|
1509
|
+
# envi --n_entries
|
1510
|
+
#
|
1511
|
+
# ========================================================================== #
|
1512
|
+
def show_n_registered_entries
|
1513
|
+
e "#{true_rev}The EnvironmentInformation project contains "\
|
1514
|
+
"#{sfancy(tracked_programs?.size)} "\
|
1515
|
+
"#{true_rev}registered entries."
|
1516
|
+
end
|
1517
|
+
|
1518
|
+
# ========================================================================== #
|
1519
|
+
# === program_not_found
|
1520
|
+
# ========================================================================== #
|
1521
|
+
def program_not_found(
|
1522
|
+
i,
|
1523
|
+
use_colours = use_colours?
|
1524
|
+
)
|
1525
|
+
if use_colours
|
1526
|
+
return send(::EnvironmentInformation.colour_for_program_not_found, i)
|
1527
|
+
else
|
1528
|
+
return i
|
1529
|
+
end
|
1530
|
+
end
|
1531
|
+
|
1532
|
+
# ========================================================================== #
|
1533
|
+
# === RAM?
|
1534
|
+
# ========================================================================== #
|
1535
|
+
def RAM?
|
1536
|
+
return ::EnvironmentInformation.ram?
|
1537
|
+
end; alias ram? RAM? # === ram?
|
1538
|
+
|
1539
|
+
# ========================================================================== #
|
1540
|
+
# === return_xvid_version
|
1541
|
+
# ========================================================================== #
|
1542
|
+
def return_xvid_version
|
1543
|
+
::EnvironmentInformation.return_version_of_xvid
|
1544
|
+
end
|
1545
|
+
|
1546
|
+
# ========================================================================== #
|
1547
|
+
# === return_remote_gtk2_version
|
1548
|
+
#
|
1549
|
+
# Be wary when using this method, as it may slow down the whole
|
1550
|
+
# application, due to making remote web-based queries.
|
1551
|
+
# ========================================================================== #
|
1552
|
+
def return_remote_gtk2_version
|
1553
|
+
::EnvironmentInformation.return_remote_gtk2_version
|
1554
|
+
end
|
1555
|
+
|
1556
|
+
# ========================================================================== #
|
1557
|
+
# === return_operating_system
|
1558
|
+
# ========================================================================== #
|
1559
|
+
def return_operating_system
|
1560
|
+
return ::EnvironmentInformation.operating_system
|
1561
|
+
end; alias operating_system? return_operating_system # === operating_system?
|
1562
|
+
alias return_version_of_operating_system return_operating_system # === return_version_of_operating_system
|
1563
|
+
|
1564
|
+
# ========================================================================== #
|
1565
|
+
# === return_cpuinfo
|
1566
|
+
#
|
1567
|
+
# This is also known as the "cpu model".
|
1568
|
+
# ========================================================================== #
|
1569
|
+
def return_cpuinfo
|
1570
|
+
return ::EnvironmentInformation.cpuinfo?
|
1571
|
+
end; alias cpu_model? return_cpuinfo # === cpu_model?
|
1572
|
+
|
1573
|
+
# ========================================================================== #
|
1574
|
+
# === left_side
|
1575
|
+
# ========================================================================== #
|
1576
|
+
def left_side(
|
1577
|
+
i,
|
1578
|
+
use_colours = use_colours?
|
1579
|
+
)
|
1580
|
+
if use_colours
|
1581
|
+
return send(::EnvironmentInformation.colour_for_the_left_side, i)
|
1582
|
+
else
|
1583
|
+
return i
|
1584
|
+
end
|
1585
|
+
end
|
1586
|
+
|
1587
|
+
# ========================================================================== #
|
1588
|
+
# === return_version_of_intltool?
|
1589
|
+
# ========================================================================== #
|
1590
|
+
def return_version_of_intltool?
|
1591
|
+
::EnvironmentInformation.send(__method__)
|
1592
|
+
end; alias return_version_of_intltool return_version_of_intltool? # == return_version_of_intltool
|
1593
|
+
|
1594
|
+
# ========================================================================== #
|
1595
|
+
# === return_version_of_grep?
|
1596
|
+
# ========================================================================== #
|
1597
|
+
def return_version_of_grep?
|
1598
|
+
::EnvironmentInformation.send(__method__)
|
1599
|
+
end; alias return_version_of_grep return_version_of_grep? # == return_version_of_grep
|
1600
|
+
|
1601
|
+
# ========================================================================== #
|
1602
|
+
# === return_version_of_gnupg?
|
1603
|
+
# ========================================================================== #
|
1604
|
+
def return_version_of_gnupg?
|
1605
|
+
::EnvironmentInformation.send(__method__)
|
1606
|
+
end; alias return_version_of_gnupg return_version_of_gnupg? # == return_version_of_gnupg
|
1607
|
+
|
1608
|
+
# ========================================================================== #
|
1609
|
+
# === return_version_of_bison?
|
1610
|
+
# ========================================================================== #
|
1611
|
+
def return_version_of_bison?
|
1612
|
+
::EnvironmentInformation.send(__method__)
|
1613
|
+
end; alias return_version_of_bison return_version_of_bison? # == return_version_of_bison
|
1614
|
+
|
1615
|
+
# ========================================================================== #
|
1616
|
+
# === return_version_of_flex?
|
1617
|
+
# ========================================================================== #
|
1618
|
+
def return_version_of_flex?
|
1619
|
+
::EnvironmentInformation.send(__method__)
|
1620
|
+
end; alias return_version_of_flex return_version_of_flex? # == return_version_of_flex
|
1621
|
+
|
1622
|
+
# ========================================================================== #
|
1623
|
+
# === dataset_containing_all_tracked_programs?
|
1624
|
+
# ========================================================================== #
|
1625
|
+
def dataset_containing_all_tracked_programs?
|
1626
|
+
@internal_hash[:dataset_containing_all_tracked_programs]
|
1627
|
+
end
|
1628
|
+
|
1629
|
+
# ========================================================================== #
|
1630
|
+
# === do_exit_the_program?
|
1631
|
+
# ========================================================================== #
|
1632
|
+
def do_exit_the_program?
|
1633
|
+
@internal_hash[:do_exit_the_program]
|
1634
|
+
end
|
1635
|
+
|
1636
|
+
# ========================================================================== #
|
1637
|
+
# === register_unavailable_program
|
1638
|
+
#
|
1639
|
+
# Programs that were not be found can be registered through this method.
|
1640
|
+
# ========================================================================== #
|
1641
|
+
def register_unavailable_program(
|
1642
|
+
i,
|
1643
|
+
array = array_unavailable_programs?
|
1644
|
+
)
|
1645
|
+
if i.is_a? Array
|
1646
|
+
i.flatten.each {|entry|
|
1647
|
+
register_unavailable_program(entry, array)
|
1648
|
+
}
|
1649
|
+
else
|
1650
|
+
i = i.to_sym # Let's store only Symbols.
|
1651
|
+
array << i unless array.include?(i)
|
1652
|
+
end
|
1653
|
+
end; alias register_not_found register_unavailable_program # === register_not_found
|
1654
|
+
|
1655
|
+
# ========================================================================== #
|
1656
|
+
# === do_display_in_a_short_format
|
1657
|
+
#
|
1658
|
+
# The short-format means that we will use only a compact set of
|
1659
|
+
# programs to display. For example, "make" and "bash" will not be
|
1660
|
+
# displayed, neither "binutils" or "ruby".
|
1661
|
+
# ========================================================================== #
|
1662
|
+
def do_display_in_a_short_format
|
1663
|
+
@internal_hash[:display_everything_in_short_format] = true
|
1664
|
+
end
|
1665
|
+
|
1666
|
+
# ========================================================================== #
|
1667
|
+
# === consider_adding_the_ruby_components
|
1668
|
+
#
|
1669
|
+
# This method can be used to consider adding the ruby-components,
|
1670
|
+
# which means "ruby" itself, rubygems "gem", and the rubygems
|
1671
|
+
# installation directory.
|
1672
|
+
# ========================================================================== #
|
1673
|
+
def consider_adding_the_ruby_components
|
1674
|
+
if show_ruby_version_and_gem_version?
|
1675
|
+
add(
|
1676
|
+
return_all_ruby_components # Combine three calls into one here - all related to ruby.
|
1677
|
+
)
|
1678
|
+
end
|
1679
|
+
end
|
1680
|
+
|
1681
|
+
# ========================================================================== #
|
1682
|
+
# === show_ruby_version_and_gem_version?
|
1683
|
+
# ========================================================================== #
|
1684
|
+
def show_ruby_version_and_gem_version?
|
1685
|
+
@internal_hash[:show_ruby_version_and_gem_version]
|
1686
|
+
end
|
1687
|
+
|
1688
|
+
# ========================================================================== #
|
1689
|
+
# === return_all_ruby_components
|
1690
|
+
#
|
1691
|
+
# Combine three calls into one here - all related to ruby.
|
1692
|
+
# ========================================================================== #
|
1693
|
+
def return_all_ruby_components
|
1694
|
+
%i(
|
1695
|
+
ruby
|
1696
|
+
rubygems
|
1697
|
+
rubygems_installation_directory
|
1698
|
+
)
|
1699
|
+
end
|
1700
|
+
|
1701
|
+
# ========================================================================== #
|
1702
|
+
# === array_unavailable_programs?
|
1703
|
+
# ========================================================================== #
|
1704
|
+
def array_unavailable_programs?
|
1705
|
+
@internal_hash[:array_unavailable_programs]
|
1706
|
+
end
|
1707
|
+
|
1708
|
+
# ========================================================================== #
|
1709
|
+
# === enable_sort_alphabetically
|
1710
|
+
# ========================================================================== #
|
1711
|
+
def enable_sort_alphabetically
|
1712
|
+
@internal_hash[:sort_alphabetically] = true
|
1713
|
+
end
|
1714
|
+
|
1715
|
+
# ========================================================================== #
|
1716
|
+
# === opnn
|
1717
|
+
# ========================================================================== #
|
1718
|
+
def opnn
|
1719
|
+
if TRY_TO_MAKE_USE_OF_THE_OPN_GEM_IF_IT_IS_AVAILABLE and
|
1720
|
+
Object.const_defined?(:Opn)
|
1721
|
+
Opn.opn({
|
1722
|
+
namespace: NAMESPACE,
|
1723
|
+
use_colours: use_colours?
|
1724
|
+
})
|
1725
|
+
end
|
1726
|
+
end; alias opn opnn # === opn
|
1727
|
+
|
1728
|
+
# ========================================================================== #
|
1729
|
+
# === add_the_default_programs_on_a_linux_computer
|
1730
|
+
# ========================================================================== #
|
1731
|
+
def add_the_default_programs_on_a_linux_computer
|
1732
|
+
# ======================================================================== #
|
1733
|
+
# Add the default programs on a linux computer.
|
1734
|
+
# ======================================================================== #
|
1735
|
+
add(
|
1736
|
+
return_default_programs_on_a_linux_computer
|
1737
|
+
)
|
1738
|
+
end; alias add_default_linux_programs add_the_default_programs_on_a_linux_computer # === add_default_linux_programs
|
1739
|
+
|
1740
|
+
# ========================================================================== #
|
1741
|
+
# === add_the_commandline_arguments
|
1742
|
+
# ========================================================================== #
|
1743
|
+
def add_the_commandline_arguments(
|
1744
|
+
i = commandline_arguments?
|
1745
|
+
)
|
1746
|
+
i.compact.each {|entry|
|
1747
|
+
add(entry) unless entry.start_with?('--')
|
1748
|
+
}
|
1749
|
+
end
|
1750
|
+
|
1751
|
+
# ========================================================================== #
|
1752
|
+
# === notify_the_user_that_there_are_no_components_that_can_be_displayed
|
1753
|
+
# ========================================================================== #
|
1754
|
+
def notify_the_user_that_there_are_no_components_that_can_be_displayed
|
1755
|
+
opne 'There are no components that can be displayed.'
|
1756
|
+
end
|
1757
|
+
|
1758
|
+
# ========================================================================== #
|
1759
|
+
# === do_exit_the_program
|
1760
|
+
# ========================================================================== #
|
1761
|
+
def do_exit_the_program
|
1762
|
+
@internal_hash[:do_exit_the_program] = true
|
1763
|
+
end
|
1764
|
+
|
1765
|
+
# ========================================================================== #
|
1766
|
+
# === use_one_line_to_show_the_result?
|
1767
|
+
# ========================================================================== #
|
1768
|
+
def use_one_line_to_show_the_result?
|
1769
|
+
@internal_hash[:use_one_line_to_show_the_result]
|
1770
|
+
end
|
1771
|
+
|
1772
|
+
# ========================================================================== #
|
1773
|
+
# === report_version
|
1774
|
+
# ========================================================================== #
|
1775
|
+
def report_version
|
1776
|
+
::EnvironmentInformation.report_version
|
1777
|
+
@internal_hash[:do_exit_the_program] = true
|
1778
|
+
end
|
1779
|
+
|
1780
|
+
# ========================================================================== #
|
1781
|
+
# === e (e tag)
|
1782
|
+
#
|
1783
|
+
# The e() method is the general output-method for this class.
|
1784
|
+
# ========================================================================== #
|
1785
|
+
def e(
|
1786
|
+
i = ''
|
1787
|
+
)
|
1788
|
+
if be_verbose?
|
1789
|
+
if use_one_line_to_show_the_result? # This will just use "print".
|
1790
|
+
::EnvironmentInformation.ee(i)
|
1791
|
+
else
|
1792
|
+
::EnvironmentInformation.e(
|
1793
|
+
i,
|
1794
|
+
display_everything_in_short_format: display_everything_in_short_format?
|
1795
|
+
)
|
1796
|
+
end
|
1797
|
+
end
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
# ========================================================================== #
|
1801
|
+
# === add_ruby_and_rubygems
|
1802
|
+
# ========================================================================== #
|
1803
|
+
def add_ruby_and_rubygems
|
1804
|
+
add(:ruby)
|
1805
|
+
add(:rubygems)
|
1806
|
+
add(:rubygems_installation_directory)
|
1807
|
+
end
|
1808
|
+
|
1809
|
+
# ========================================================================== #
|
1810
|
+
# === show_everything?
|
1811
|
+
# ========================================================================== #
|
1812
|
+
def show_everything?
|
1813
|
+
@internal_hash[:show_everything]
|
1814
|
+
end
|
1815
|
+
|
1816
|
+
# ========================================================================== #
|
1817
|
+
# === try_to_rename_the_kde_konsole_tab?
|
1818
|
+
# ========================================================================== #
|
1819
|
+
def try_to_rename_the_kde_konsole_tab?
|
1820
|
+
@internal_hash[:try_to_rename_the_kde_konsole_tab]
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
# ========================================================================== #
|
1824
|
+
# === is_rbt_available_and_may_we_try_to_use_rbt?
|
1825
|
+
# ========================================================================== #
|
1826
|
+
def is_rbt_available_and_may_we_try_to_use_rbt?
|
1827
|
+
is_rbt_available? and may_we_try_to_use_rbt?
|
1828
|
+
end
|
1829
|
+
|
1830
|
+
# ========================================================================== #
|
1831
|
+
# === compare_program_versions?
|
1832
|
+
# ========================================================================== #
|
1833
|
+
def compare_program_versions?
|
1834
|
+
@internal_hash[:compare_program_versions]
|
1835
|
+
end; alias compare_program_version? compare_program_versions? # === compare_program_version?
|
1836
|
+
|
1837
|
+
# ========================================================================== #
|
1838
|
+
# === do_store_the_results_into_local_files
|
1839
|
+
# ========================================================================== #
|
1840
|
+
def do_store_the_results_into_local_files
|
1841
|
+
@internal_hash[:store_the_results_into_local_files] = true
|
1842
|
+
end
|
1843
|
+
|
1844
|
+
# ========================================================================== #
|
1845
|
+
# === do_not_store_anything_into_a_local_file
|
1846
|
+
# ========================================================================== #
|
1847
|
+
def do_not_store_anything_into_a_local_file
|
1848
|
+
@internal_hash[:shall_we_store_the_main_hash_into_a_local_file] = false
|
1849
|
+
end
|
1850
|
+
|
1851
|
+
# ========================================================================== #
|
1852
|
+
# === set_use_colours
|
1853
|
+
# ========================================================================== #
|
1854
|
+
def set_use_colours(
|
1855
|
+
i = true
|
1856
|
+
)
|
1857
|
+
super()
|
1858
|
+
::EnvironmentInformation.set_use_colours(i)
|
1859
|
+
end
|
1860
|
+
|
1861
|
+
# ========================================================================== #
|
1862
|
+
# === do_rename_kde_konsole
|
1863
|
+
#
|
1864
|
+
# This will attempt to rename the KDE Konsole tab, but only if we are
|
1865
|
+
# on roebe.
|
1866
|
+
# ========================================================================== #
|
1867
|
+
def do_rename_kde_konsole(
|
1868
|
+
use_this_title = 'Environment Information'
|
1869
|
+
)
|
1870
|
+
begin
|
1871
|
+
require 'roebe/requires/require_kde_konsole.rb'
|
1872
|
+
rescue LoadError; end
|
1873
|
+
if try_to_rename_the_kde_konsole_tab? and
|
1874
|
+
is_on_roebe? and
|
1875
|
+
Object.const_defined?(:Roebe) and
|
1876
|
+
Roebe.const_defined?(:KdeKonsole)
|
1877
|
+
Roebe.rename_konsole(use_this_title)
|
1878
|
+
end
|
1879
|
+
end
|
1880
|
+
|
1881
|
+
# ========================================================================== #
|
1882
|
+
# === return_default_programs_on_linux
|
1883
|
+
#
|
1884
|
+
# This method should return the "main" programs on a linux computer,
|
1885
|
+
# the most important entries.
|
1886
|
+
# ========================================================================== #
|
1887
|
+
def return_default_programs_on_linux
|
1888
|
+
ARRAY_DEFAULT_PROGRAMS_ON_LINUX
|
1889
|
+
end; alias return_default_programs_on_a_linux_computer return_default_programs_on_linux # === return_default_programs_on_a_linux_computer
|
1890
|
+
alias return_default_programs return_default_programs_on_linux # === return_default_programs
|
1891
|
+
|
1892
|
+
# ========================================================================== #
|
1893
|
+
# === do_not_display_the_result
|
1894
|
+
# ========================================================================== #
|
1895
|
+
def do_not_display_the_result
|
1896
|
+
@internal_hash[:display_result] = false
|
1897
|
+
end
|
1898
|
+
|
1899
|
+
# ========================================================================== #
|
1900
|
+
# === display_result?
|
1901
|
+
# ========================================================================== #
|
1902
|
+
def display_result?
|
1903
|
+
@internal_hash[:display_result]
|
1904
|
+
end
|
1905
|
+
|
1906
|
+
# ========================================================================== #
|
1907
|
+
# === xorg_components?
|
1908
|
+
# ========================================================================== #
|
1909
|
+
def xorg_components?
|
1910
|
+
::EnvironmentInformation.xorg_components?
|
1911
|
+
end; alias return_all_xorg_components xorg_components? # === return_all_xorg_components
|
1912
|
+
|
1913
|
+
# ========================================================================== #
|
1914
|
+
# === clear_old_dataset
|
1915
|
+
# ========================================================================== #
|
1916
|
+
def clear_old_dataset
|
1917
|
+
work_on_these_components?.clear
|
1918
|
+
end; alias clear_the_old_dataset clear_old_dataset # === clear_the_old_dataset
|
1919
|
+
|
1920
|
+
# ========================================================================== #
|
1921
|
+
# === do_show_only_the_xorg_components
|
1922
|
+
#
|
1923
|
+
# This method will essentially clear the old dataset before adding
|
1924
|
+
# all xorg-components to the display-part of this class.
|
1925
|
+
#
|
1926
|
+
# The components that are appended here, are defined in the file
|
1927
|
+
# constants/array_tracked_components.rb - so if you wish to add
|
1928
|
+
# new xorg-related entries, you should modify the entries in that
|
1929
|
+
# .rb file.
|
1930
|
+
# ========================================================================== #
|
1931
|
+
def do_show_only_the_xorg_components
|
1932
|
+
clear_old_dataset
|
1933
|
+
do_not_show_the_ruby_components
|
1934
|
+
add(:all_xorg_components)
|
1935
|
+
end
|
1936
|
+
|
1937
|
+
# ========================================================================== #
|
1938
|
+
# === display_everything_in_short_format?
|
1939
|
+
# ========================================================================== #
|
1940
|
+
def display_everything_in_short_format?
|
1941
|
+
@internal_hash[:display_everything_in_short_format]
|
1942
|
+
end
|
1943
|
+
|
1944
|
+
# ========================================================================== #
|
1945
|
+
# === use_ascii_table
|
1946
|
+
#
|
1947
|
+
# We will display in ascii-table format here.
|
1948
|
+
# ========================================================================== #
|
1949
|
+
def use_ascii_table
|
1950
|
+
disable_colours # Can't use colours right now. Perhaps at a later time.
|
1951
|
+
extend Terminal::Table::TableHelper
|
1952
|
+
@internal_hash[:table] = table ['Name', 'Version']
|
1953
|
+
@internal_hash[:table].style = {
|
1954
|
+
padding_left: 2,
|
1955
|
+
width: 110 # Set the width here.
|
1956
|
+
}
|
1957
|
+
@internal_hash[:use_ascii_table] = true
|
1958
|
+
end
|
1959
|
+
|
1960
|
+
# ========================================================================== #
|
1961
|
+
# === sort_alphabetically?
|
1962
|
+
# ========================================================================== #
|
1963
|
+
def sort_alphabetically?
|
1964
|
+
@internal_hash[:sort_alphabetically]
|
1965
|
+
end
|
1966
|
+
|
1967
|
+
# ========================================================================== #
|
1968
|
+
# === assign_components_for_the_short_format
|
1969
|
+
#
|
1970
|
+
# We will only display 6 components when we use the short variant.
|
1971
|
+
# ========================================================================== #
|
1972
|
+
def assign_components_for_the_short_format
|
1973
|
+
clear_old_dataset
|
1974
|
+
dont_show_ruby_stuff
|
1975
|
+
add(%i(
|
1976
|
+
operating_system
|
1977
|
+
operating_system_bit_type
|
1978
|
+
cpuinfo
|
1979
|
+
cflags
|
1980
|
+
RAM
|
1981
|
+
screen_resolution
|
1982
|
+
))
|
1983
|
+
end
|
1984
|
+
|
1985
|
+
# ========================================================================== #
|
1986
|
+
# === version?
|
1987
|
+
# ========================================================================== #
|
1988
|
+
def version?(
|
1989
|
+
key = the_primary_hash?.keys.first
|
1990
|
+
)
|
1991
|
+
the_primary_hash?[key]
|
1992
|
+
end
|
1993
|
+
|
1994
|
+
# ========================================================================== #
|
1995
|
+
# === EnvironmentInformation.colourize_and_pad_the_left_side
|
1996
|
+
# ========================================================================== #
|
1997
|
+
def self.colourize_and_pad_the_left_side(i)
|
1998
|
+
left_side = i.to_s.ljust(32) # Pad to the left-hand side.
|
1999
|
+
if use_colours?
|
2000
|
+
" #{Colours.send(::EnvironmentInformation.colour_for_the_left_side, left_side)}"
|
2001
|
+
else
|
2002
|
+
" #{left_side}"
|
2003
|
+
end
|
2004
|
+
end; self.instance_eval { alias prepare_left_side colourize_and_pad_the_left_side } # === EnvironmentInformation.prepare_left_side
|
2005
|
+
|
2006
|
+
end; end
|