environment_information 1.4.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of environment_information might be problematic. Click here for more details.

Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1287 -0
  3. data/bin/envi +7 -0
  4. data/bin/fast_envi +7 -0
  5. data/doc/README.gen +1044 -0
  6. data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +48 -0
  7. data/environment_information.gemspec +135 -0
  8. data/lib/environment_information/base/base.rb +166 -0
  9. data/lib/environment_information/class/class.rb +2829 -0
  10. data/lib/environment_information/colours/colours.rb +224 -0
  11. data/lib/environment_information/colours/sfancy.rb +19 -0
  12. data/lib/environment_information/colours/simp.rb +19 -0
  13. data/lib/environment_information/constants/array_tracked_components.rb +210 -0
  14. data/lib/environment_information/constants/constants.rb +17 -0
  15. data/lib/environment_information/constants/encoding.rb +21 -0
  16. data/lib/environment_information/constants/error_line.rb +17 -0
  17. data/lib/environment_information/constants/file_constants.rb +102 -0
  18. data/lib/environment_information/constants/misc.rb +86 -0
  19. data/lib/environment_information/constants/namespace.rb +14 -0
  20. data/lib/environment_information/constants/newline.rb +16 -0
  21. data/lib/environment_information/constants/regex.rb +30 -0
  22. data/lib/environment_information/constants/temp_directory.rb +52 -0
  23. data/lib/environment_information/gui/gtk2/environment_information.rb +35 -0
  24. data/lib/environment_information/gui/gtk3/environment_information.rb +34 -0
  25. data/lib/environment_information/gui/libui/environment_information.rb +74 -0
  26. data/lib/environment_information/gui/shared_code/environment_information_module.rb +409 -0
  27. data/lib/environment_information/misc_components/README.md +3 -0
  28. data/lib/environment_information/misc_components/cflags.rb +36 -0
  29. data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
  30. data/lib/environment_information/misc_components/operating_system.rb +54 -0
  31. data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
  32. data/lib/environment_information/misc_components/ram.rb +30 -0
  33. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
  34. data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
  35. data/lib/environment_information/project/project.rb +27 -0
  36. data/lib/environment_information/queries/README.md +2 -0
  37. data/lib/environment_information/queries/complex_version.rb +273 -0
  38. data/lib/environment_information/queries/pkg_config.rb +125 -0
  39. data/lib/environment_information/queries/simple_version.rb +217 -0
  40. data/lib/environment_information/requires/require_asciitable.rb +15 -0
  41. data/lib/environment_information/requires/require_the_constants.rb +7 -0
  42. data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
  43. data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
  44. data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
  45. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +152 -0
  46. data/lib/environment_information/toplevel_methods/cd.rb +16 -0
  47. data/lib/environment_information/toplevel_methods/e.rb +43 -0
  48. data/lib/environment_information/toplevel_methods/hash.rb +60 -0
  49. data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
  50. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
  51. data/lib/environment_information/toplevel_methods/menu.rb +90 -0
  52. data/lib/environment_information/toplevel_methods/misc.rb +322 -0
  53. data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
  54. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
  55. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
  56. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
  57. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
  58. data/lib/environment_information/toplevel_methods/return_alias_to.rb +30 -0
  59. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
  60. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
  61. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
  62. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +182 -0
  63. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
  64. data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
  65. data/lib/environment_information/version/version.rb +25 -0
  66. data/lib/environment_information/www/sinatra_interface.rb +213 -0
  67. data/lib/environment_information/www/webobject_interface.cgi +29 -0
  68. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +15 -0
  69. data/lib/environment_information/yaml/array_lfs_core_programs.yml +37 -0
  70. data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
  71. data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
  72. data/lib/environment_information/yaml/array_tracked_programs.yml +215 -0
  73. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +37 -0
  74. data/lib/environment_information/yaml/colours.yml +3 -0
  75. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +264 -0
  76. data/lib/environment_information.rb +5 -0
  77. data/test/testing_environment_information.rb +26 -0
  78. data/test/testing_missing_components.rb +9 -0
  79. data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
  80. metadata +177 -0
@@ -0,0 +1,2829 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::EnvironmentInformation
6
+ #
7
+ # The primary purpose of this class is to provide information about
8
+ # the computer environment ruby is running on. Obviously ruby must
9
+ # be available in order for this class (this program) to work.
10
+ #
11
+ # By default, class EnvironmentInformation will run in
12
+ # "commandline mode", that is, it will output information
13
+ # onto the console/terminal.
14
+ #
15
+ # The dataset is of course also available internally, though, so you
16
+ # can query this information and display it e. g. in a traditional
17
+ # GUI or WWW setting, like for a webpage.
18
+ # =========================================================================== #
19
+ # A complete usage example for the main class follows next:
20
+ #
21
+ # require 'environment_information'
22
+ #
23
+ # _ = EnvironmentInformation::EnvironmentInformation.new(:do_not_run_yet)
24
+ # _.disable_colours
25
+ # _.be_silent
26
+ # _.run
27
+ # _.string
28
+ #
29
+ # Another usage example:
30
+ #
31
+ # EnvironmentInformation.new('--kdeversions?')
32
+ #
33
+ # =========================================================================== #
34
+ # require 'environment_information/class/class.rb'
35
+ # =========================================================================== #
36
+ require 'environment_information/base/base.rb'
37
+
38
+ module EnvironmentInformation
39
+
40
+ class EnvironmentInformation < ::EnvironmentInformation::Base # === EnvironmentInformation::EnvironmentInformation
41
+
42
+ # ========================================================================= #
43
+ # === EnvironmentInformation::EnvironmentInformation::TRY_TO_USE_HTML_COLOURS
44
+ #
45
+ # If true then we will try to use the konsole-colours, when possible.
46
+ #
47
+ # These are part of the colours gem, so this adds a dependency on the
48
+ # colours gem.
49
+ # ========================================================================= #
50
+ TRY_TO_USE_HTML_COLOURS = true
51
+
52
+ require 'environment_information/constants/namespace.rb'
53
+ require 'environment_information/constants/array_tracked_components.rb'
54
+ require 'environment_information/constants/misc.rb'
55
+ require 'environment_information/colours/colours.rb'
56
+ require 'environment_information/queries/complex_version.rb'
57
+ require 'environment_information/queries/pkg_config.rb'
58
+ require 'environment_information/queries/simple_version.rb'
59
+ require 'environment_information/toplevel_methods/hash.rb'
60
+ require 'environment_information/toplevel_methods/misc.rb'
61
+ require 'environment_information/toplevel_methods/return_pkgconfig_based_programs.rb'
62
+ require 'environment_information/toplevel_methods/return_simple_version_based_programs'
63
+ require 'environment_information/toplevel_methods/write_what_into.rb'
64
+ require 'environment_information/version/version.rb'
65
+
66
+ begin
67
+ require 'opn'
68
+ rescue LoadError; end
69
+
70
+ # ========================================================================= #
71
+ # === initialize
72
+ # ========================================================================= #
73
+ def initialize(
74
+ commandline_arguments = nil,
75
+ run_already = true
76
+ )
77
+ register_sigint
78
+ reset
79
+ # ======================================================================= #
80
+ # Next, we handle special run-mode variants.
81
+ # ======================================================================= #
82
+ case run_already
83
+ when :do_show_everything
84
+ do_show_everything
85
+ run_already = true
86
+ end
87
+ # ======================================================================= #
88
+ # And set @run_already, so that menu() can overrule it lateron.
89
+ # ======================================================================= #
90
+ @run_already = run_already
91
+ set_commandline_arguments(
92
+ commandline_arguments
93
+ )
94
+ # ======================================================================= #
95
+ # === Handle blocks
96
+ #
97
+ # Next blocks will be handled. This must come after the reset() method.
98
+ # ======================================================================= #
99
+ if block_given?
100
+ yielded = yield
101
+ case yielded # case tag
102
+ # ===================================================================== #
103
+ # === :do_not_use_rbt
104
+ # ===================================================================== #
105
+ when :do_not_use_rbt
106
+ @may_we_try_to_use_rbt = false
107
+ # ===================================================================== #
108
+ # === :disable_colours
109
+ # ===================================================================== #
110
+ when :disable_colours
111
+ disable_colours
112
+ # ===================================================================== #
113
+ # === :disable_colours_and_do_not_store_into_a_local_file
114
+ # ===================================================================== #
115
+ when :disable_colours_and_do_not_store_into_a_local_file
116
+ disable_colours
117
+ do_not_save_anything
118
+ # ===================================================================== #
119
+ # === :do_not_run_yet
120
+ # ===================================================================== #
121
+ when :do_not_run_yet
122
+ @run_already = false
123
+ else
124
+ # =================================================================== #
125
+ # Handle Hashes given in the block.
126
+ # =================================================================== #
127
+ if yielded.is_a? Hash
128
+ # ================================================================= #
129
+ # === :use_n_tokens
130
+ # ================================================================= #
131
+ if yielded.has_key? :use_n_tokens
132
+ set_use_n_tokens(yielded.delete(:use_n_tokens))
133
+ # ================================================================= #
134
+ # === :n_tokens
135
+ # ================================================================= #
136
+ elsif yielded.has_key? :n_tokens
137
+ set_use_n_tokens(yielded.delete(:n_tokens))
138
+ end
139
+ # ================================================================= #
140
+ # === :use_colours
141
+ # ================================================================= #
142
+ if yielded.has_key? :use_colours
143
+ set_use_colours(yielded.delete(:use_colours))
144
+ end
145
+ # ================================================================= #
146
+ # === :be_silent
147
+ # ================================================================= #
148
+ if yielded.has_key? :be_silent
149
+ set_be_silent(yielded.delete(:be_silent))
150
+ end
151
+ # ================================================================= #
152
+ # === :show_ruby_stuff
153
+ # ================================================================= #
154
+ if yielded.has_key? :show_ruby_stuff
155
+ if yielded.delete(:show_ruby_stuff) == false
156
+ dont_show_ruby_stuff
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ # ======================================================================= #
163
+ # First, we will add the default programs on a linux computer. The
164
+ # later invocation to menu() can change this, but we also want to
165
+ # provide "useful defaults" for users to benefit from this gem.
166
+ # ======================================================================= #
167
+ add_the_default_programs_on_a_linux_computer
168
+ # ======================================================================= #
169
+ # Add the ruby components next. This must come before menu().
170
+ # ======================================================================= #
171
+ consider_adding_the_ruby_components
172
+ # ======================================================================= #
173
+ # Invoke menu() to query and honour the commandline arguments.
174
+ # ======================================================================= #
175
+ menu
176
+ run if @run_already
177
+ end
178
+
179
+ # ========================================================================= #
180
+ # === add (add tag)
181
+ #
182
+ # This method can be used to add individual entries to the main array
183
+ # called @array_report_these_programs.
184
+ #
185
+ # The format for add() contains only one component, which appears on
186
+ # the left side, and denotes the name of the program or component
187
+ # that we wish to query, such as "php" or "ruby" and so forth.
188
+ #
189
+ # Some Symbols will be used as a "pointer" towards an Array of
190
+ # registered programs.
191
+ #
192
+ # Note that (1) will be converted into a Symbol if it is a String.
193
+ #
194
+ # If the second entry (2) is nil, then the version will be inferred
195
+ # at "runtime" within the method display(). Otherwise display()
196
+ # will simply use the passed version (which should be a String in
197
+ # that case, then).
198
+ #
199
+ # Before we can add an entry to the main dataset, we have to check
200
+ # whether it is a registered entry altogether. If it is not
201
+ # registered, the user has to be notified about this fact.
202
+ # This notification will ONLY happen if the associated version is nil;
203
+ # if a specific version is supplied then this method will assume
204
+ # that the program should be displayed anyway.
205
+ #
206
+ # An Array can also be supplied to this method, if necessary.
207
+ # ========================================================================= #
208
+ def add(
209
+ i
210
+ )
211
+ if i.is_a?(String) and i.include?(',')
212
+ # ===================================================================== #
213
+ # Strings containing ',' will be split accordingly.
214
+ # ===================================================================== #
215
+ i = i.split(',')
216
+ elsif i.is_a?(String) and i.include?('-')
217
+ # ===================================================================== #
218
+ # Strings containing '-' will lose that '-'.
219
+ # ===================================================================== #
220
+ i = i.dup if i.frozen?
221
+ i.delete!('-')
222
+ end
223
+ [i].flatten.compact.each {|entry|
224
+ case entry
225
+ # ===================================================================== #
226
+ # === :everything
227
+ #
228
+ # This entry point is meant for simply adding everything.
229
+ # ===================================================================== #
230
+ when :everything
231
+ entry = return_every_registered_component
232
+ # ===================================================================== #
233
+ # === Rubygems installation directory
234
+ # ===================================================================== #
235
+ when :rubygems_installation_directory,
236
+ /^rubygems( |_)?installation( |_)?directory\??$/i
237
+ entry = 'rubygems_installation_directory'
238
+ # ===================================================================== #
239
+ # === cflags
240
+ # ===================================================================== #
241
+ when :cflags,
242
+ /^cflags$/i
243
+ entry = 'CFLAGS in use'
244
+ # ===================================================================== #
245
+ # === screen_resolution
246
+ # ===================================================================== #
247
+ when :screen_resolution,
248
+ /^screen( |_)?resolution$/i
249
+ entry = 'Screen Resolution'
250
+ # ===================================================================== #
251
+ # === ram
252
+ # ===================================================================== #
253
+ when :ram,
254
+ /^ram$/i
255
+ entry = 'RAM'
256
+ # ===================================================================== #
257
+ # === cpuinfo
258
+ # ===================================================================== #
259
+ when :cpuinfo,
260
+ /^cpuinfo$/i
261
+ entry = 'CPU Model'
262
+ # ===================================================================== #
263
+ # === operating_system_bit_type
264
+ # ===================================================================== #
265
+ when :operating_system_bit_type,
266
+ /^operating(_|-)?system(_|-)?bit(_|-)?type$/i
267
+ entry = 'Operating system bit type'
268
+ # ===================================================================== #
269
+ # === :operating_system
270
+ # ===================================================================== #
271
+ when :operating_system,
272
+ /^operating(_|-)?system$/i,
273
+ /^operating(_|-)?system(_|-)?in(_|-)?use$/i
274
+ entry = 'Operating system'
275
+ # ===================================================================== #
276
+ # === cpflags
277
+ # ===================================================================== #
278
+ when /^cflags$/i,
279
+ /^CFLAGS in use$/i
280
+ entry = 'CFLAGS in use'
281
+ # ===================================================================== #
282
+ # === :pkgconfig_entries
283
+ # ===================================================================== #
284
+ when :pkgconfig_entries
285
+ entry = ::EnvironmentInformation.return_pkgconfig_based_programs
286
+ # ===================================================================== #
287
+ # === :all_xorg_components
288
+ # ===================================================================== #
289
+ when :all_xorg_components
290
+ entry = return_all_xorg_components
291
+ # ===================================================================== #
292
+ # === envi --science
293
+ # ===================================================================== #
294
+ when :science_cluster
295
+ entry = ARRAY_SCIENCE_CLUSTER
296
+ # ===================================================================== #
297
+ # === envi --lfs_core_programs
298
+ # ===================================================================== #
299
+ when :lfs,
300
+ :lfs_core_programs
301
+ entry = ::EnvironmentInformation.lfs_core_programs?
302
+ # ===================================================================== #
303
+ # === :linux_kernel
304
+ # ===================================================================== #
305
+ when :linux_kernel
306
+ i = :linux
307
+ # ===================================================================== #
308
+ # === :RAM
309
+ # ===================================================================== #
310
+ when :RAM
311
+ entry = :ram # Just the "alias" to the real entry.
312
+ end
313
+ unless @array_report_these_programs.include? entry
314
+ @array_report_these_programs << entry
315
+ @array_report_these_programs.flatten!
316
+ end
317
+ }
318
+ end; alias update_version_for add # === add
319
+ alias append add # === append
320
+ alias append_this_to_main_string add # === append_this_to_main_string
321
+ alias show_these_entries add # === show_these_entries
322
+ alias set_additional add # === set_additional
323
+
324
+ # ========================================================================= #
325
+ # === add_the_default_programs_on_a_linux_computer
326
+ # ========================================================================= #
327
+ def add_the_default_programs_on_a_linux_computer
328
+ # ======================================================================= #
329
+ # Add the default programs on a linux computer.
330
+ # ======================================================================= #
331
+ add(
332
+ return_default_programs_on_a_linux_computer
333
+ )
334
+ end; alias add_default_linux_programs add_the_default_programs_on_a_linux_computer # === add_default_linux_programs
335
+
336
+ # ========================================================================= #
337
+ # === add_ruby_and_rubygems
338
+ # ========================================================================= #
339
+ def add_ruby_and_rubygems
340
+ add(:ruby)
341
+ add(:rubygems)
342
+ add(:rubygems_installation_directory)
343
+ end
344
+
345
+ # ========================================================================= #
346
+ # === add_this_to_the_toplevel_hash
347
+ # ========================================================================= #
348
+ def add_this_to_the_toplevel_hash(a, b)
349
+ a = a.to_sym unless a.is_a? Symbol
350
+ ::EnvironmentInformation.hash?[a] = b
351
+ end; alias register_onto_the_main_hash add_this_to_the_toplevel_hash # === register_onto_the_main_hash
352
+
353
+ # ========================================================================= #
354
+ # === colourize_this_in_the_right_side_colour
355
+ # ========================================================================= #
356
+ def colourize_this_in_the_right_side_colour(i)
357
+ if use_colours?
358
+ ::Colours.send(::EnvironmentInformation.colour_for_the_right_side, i)
359
+ else
360
+ i
361
+ end
362
+ end
363
+
364
+ # ========================================================================= #
365
+ # === set_use_colours
366
+ # ========================================================================= #
367
+ def set_use_colours(i = '')
368
+ ::EnvironmentInformation.set_use_colours(true)
369
+ end
370
+
371
+ # ========================================================================= #
372
+ # === use_colours?
373
+ # ========================================================================= #
374
+ def use_colours?
375
+ ::EnvironmentInformation.use_colours?
376
+ end
377
+
378
+ # ========================================================================= #
379
+ # === enable_colours
380
+ # ========================================================================= #
381
+ def enable_colours
382
+ ::EnvironmentInformation.use_colours = true
383
+ end
384
+
385
+ # ========================================================================= #
386
+ # === disable_colours
387
+ #
388
+ # Call this method when you wish to disable the colours. Note that
389
+ # this will disable colours on the toplevel.
390
+ # ========================================================================= #
391
+ def disable_colours
392
+ ::EnvironmentInformation.use_colours = false
393
+ end; alias no_colours disable_colours # === no_colours()
394
+
395
+ # ========================================================================= #
396
+ # === rev
397
+ # ========================================================================= #
398
+ def rev
399
+ if use_colours?
400
+ Colours::GREEN
401
+ else
402
+ ''
403
+ end
404
+ end
405
+
406
+ # ========================================================================= #
407
+ # === true_rev
408
+ # ========================================================================= #
409
+ def true_rev
410
+ if use_colours?
411
+ Colours::REV
412
+ else
413
+ ''
414
+ end
415
+ end
416
+
417
+ # ========================================================================= #
418
+ # === col1
419
+ #
420
+ # The "first" colour to be used.
421
+ # ========================================================================= #
422
+ def col1
423
+ if use_colours?
424
+ Colours::BOLD_BLUE
425
+ else
426
+ ''
427
+ end
428
+ end
429
+
430
+ # ========================================================================= #
431
+ # === cyan
432
+ # ========================================================================= #
433
+ def cyan(i = '')
434
+ if i.empty?
435
+ Colours::CYAN
436
+ end if use_colours?
437
+ end
438
+
439
+ # ========================================================================= #
440
+ # === blue
441
+ # ========================================================================= #
442
+ def blue(i = '')
443
+ if i.empty?
444
+ Colours::BLUE
445
+ end if use_colours?
446
+ end
447
+
448
+ # ========================================================================= #
449
+ # === simp
450
+ # ========================================================================= #
451
+ def simp(i)
452
+ return ::Colours.simp(i) if use_colours?
453
+ return i
454
+ end
455
+
456
+ # ========================================================================= #
457
+ # === sfile
458
+ # ========================================================================= #
459
+ def sfile(i)
460
+ return ::Colours.sfile(i) if use_colours?
461
+ return i
462
+ end
463
+
464
+ # ========================================================================= #
465
+ # === sfancy
466
+ # ========================================================================= #
467
+ def sfancy(i = '')
468
+ return ::Colours.sfancy(i) if use_colours?
469
+ return i
470
+ end
471
+
472
+ # ========================================================================= #
473
+ # === crimson
474
+ # ========================================================================= #
475
+ def crimson(i = '')
476
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
477
+ i = ::Colours.crimson(i)
478
+ end
479
+ return i
480
+ end
481
+
482
+ # ========================================================================= #
483
+ # === darkgreen
484
+ # ========================================================================= #
485
+ def darkgreen(i = '')
486
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
487
+ i = ::Colours.darkgreen(i)
488
+ end
489
+ return i
490
+ end
491
+
492
+ # ========================================================================= #
493
+ # === dimgray
494
+ # ========================================================================= #
495
+ def dimgray(i = '')
496
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
497
+ i = ::Colours.dimgray(i)
498
+ end
499
+ return i
500
+ end
501
+
502
+ # ========================================================================= #
503
+ # === royalblue
504
+ # ========================================================================= #
505
+ def royalblue(i = '')
506
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
507
+ i = ::Colours.royalblue(i)
508
+ end
509
+ return i
510
+ end
511
+
512
+ # ========================================================================= #
513
+ # === slateblue
514
+ # ========================================================================= #
515
+ def slateblue(i = '')
516
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
517
+ i = ::Colours.slateblue(i)
518
+ end
519
+ return i
520
+ end
521
+
522
+ # ========================================================================= #
523
+ # === steelblue
524
+ # ========================================================================= #
525
+ def steelblue(i = '')
526
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
527
+ i = ::Colours.steelblue(i)
528
+ end
529
+ return i
530
+ end
531
+
532
+ # ========================================================================= #
533
+ # === seagreen
534
+ # ========================================================================= #
535
+ def seagreen(i = '')
536
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
537
+ i = ::Colours.seagreen(i)
538
+ end
539
+ return i
540
+ end
541
+
542
+ # ========================================================================= #
543
+ # === olivedrab
544
+ #
545
+ # This one will be used for the right-hand side.
546
+ # ========================================================================= #
547
+ def olivedrab(i = '')
548
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
549
+ i = ::Colours.olivedrab(i)
550
+ end
551
+ return i
552
+ end
553
+
554
+ # ========================================================================= #
555
+ # === olive
556
+ # ========================================================================= #
557
+ def olive(i = '')
558
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
559
+ i = ::Colours.olive(i)
560
+ end
561
+ return i
562
+ end
563
+
564
+ # ========================================================================= #
565
+ # === limegreen
566
+ # ========================================================================= #
567
+ def limegreen(i = '')
568
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
569
+ i = ::Colours.limegreen(i)
570
+ end
571
+ return i
572
+ end
573
+
574
+ # ========================================================================= #
575
+ # === darkolivegreen
576
+ # ========================================================================= #
577
+ def darkolivegreen(i = '')
578
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
579
+ i = ::Colours.darkolivegreen(i)
580
+ end
581
+ return i
582
+ end
583
+
584
+ # ========================================================================= #
585
+ # === lightgreen
586
+ # ========================================================================= #
587
+ def lightgreen(i = '')
588
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
589
+ i = ::Colours.lightgreen(i)
590
+ end
591
+ return i
592
+ end
593
+
594
+ # ========================================================================= #
595
+ # === mediumpurple
596
+ # ========================================================================= #
597
+ def mediumpurple(i = '')
598
+ if use_colours? and TRY_TO_USE_HTML_COLOURS
599
+ i = ::Colours.mediumpurple(i)
600
+ end
601
+ return i
602
+ end
603
+
604
+ # ========================================================================= #
605
+ # === teal
606
+ # ========================================================================= #
607
+ def teal(i = '')
608
+ return ::Colours.teal(i) if use_colours?
609
+ return i
610
+ end
611
+
612
+ # ========================================================================= #
613
+ # === orange
614
+ # ========================================================================= #
615
+ def orange(i = '')
616
+ return ::Colours.orange(i) if use_colours?
617
+ return i
618
+ end
619
+
620
+ # ========================================================================= #
621
+ # === EnvironmentInformation::EnvironmentInformation::THIS_FILE
622
+ #
623
+ # THIS_FILE = __FILE__
624
+ #
625
+ # We hardcode this since it is only relevant on my home system, anyway.
626
+ # ========================================================================= #
627
+ THIS_FILE =
628
+ '/home/x/programming/ruby/src/'\
629
+ 'environment_information/lib/environment_information/class/'\
630
+ 'environment_information.rb'
631
+
632
+ begin
633
+ require 'rbt/utility_scripts/report_mate_desktop_version.rb'
634
+ rescue LoadError; end
635
+
636
+ require 'environment_information/requires/require_asciitable.rb'
637
+
638
+ # ========================================================================= #
639
+ # === do_show_help (help tag)
640
+ #
641
+ # Show the commandline-usage through this method here.
642
+ #
643
+ # To invoke this, try:
644
+ #
645
+ # envi --help
646
+ #
647
+ # ========================================================================= #
648
+ def do_show_help
649
+ e
650
+ lpad = "#{col1} "
651
+ e "#{rev}The following options are available for "\
652
+ "#{simp('class EnvironmentInformation:')}#{rev}#{N}#{N}"
653
+ if ASCIITABLE_IS_AVAILABLE
654
+ e col1+' asciitable '+rev+'# Print in Ascii Table format'
655
+ end
656
+ e lpad+'html '+rev+'# Save the environment information '\
657
+ 'into a .html file'
658
+ e lpad+'gui '+rev+'# Start the GTK gui bindings; some '\
659
+ 'aliases are possible such as --GUI'
660
+ e lpad+'nocolours '+rev+'# Disable colours '\
661
+ '(--disable-colours also works)'
662
+ e lpad+'noruby '+rev+'# dont show ruby-related environment '\
663
+ 'information'
664
+ e lpad+'help '+rev+'# show some help'
665
+ e lpad+'xorg '+rev+'# show some xorg-specific '\
666
+ 'components (also --xorg-components)'
667
+ e lpad+'OS '+rev+'# show the OS then exit'
668
+ e lpad+'full '+rev+'# show full information, including '\
669
+ 'GTK, Glib, Atk and Pango Version'
670
+ e ' # ^^^ This is probably the most useful usage.'
671
+ e lpad+'openssl '+rev+'# display openssl option'
672
+ e lpad+'REALLY_ALL '+rev+'# also compare the program_versions '\
673
+ '(--really-everything is an alias to this)'
674
+ e lpad+'save '+rev+'# display the result, then '\
675
+ 'save it into a file'
676
+ e lpad+'sinatra '+rev+'# start the sinatra-interface '\
677
+ 'of the environment_information project'
678
+ e lpad+'version '+rev+'# show the version of '\
679
+ 'EnvironmentInformation in use'
680
+ e lpad+'--show-remote-url '+rev+'# show the remote URLs '\
681
+ 'of a program (requires the RBT project)'
682
+ e lpad+'padding=value '+rev+'# set to another padding value'
683
+ e lpad+'--one-liner '+rev+'# show everything compacted, without a newline'
684
+ e lpad+'--nentries? '+rev+'# feedback how many entries are tracked in total'
685
+ e rev+N+'The above commands should be commandline arguments, '\
686
+ 'such as: "'+teal('envi full')+rev+'".'
687
+ e
688
+ e "#{rev}Do note that you can prefix the above commands via "\
689
+ "a leading --, of course."
690
+ e
691
+ # ======================================================================= #
692
+ # Show a simple usage example next:
693
+ # ======================================================================= #
694
+ e 'Usage example:'
695
+ e
696
+ e steelblue(
697
+ ' envi --version'
698
+ )
699
+ e
700
+ e rev+'If you wish to show only some programs, you could '\
701
+ 'use the following:'
702
+ e
703
+ e steelblue(
704
+ ' envi --use-these-programs=bash,binutils,bison,yacc,bzip2,coreutils,diff,find,gawk,gcc'
705
+ )
706
+ e steelblue(
707
+ ' envi --use-these-programs=:lfs'
708
+ )
709
+ e true_rev # Reset via Colours.rev here.
710
+ do_exit_the_program
711
+ end; alias show_help do_show_help # === show_help
712
+
713
+ require 'environment_information/toplevel_methods/write_what_into.rb'
714
+ require 'environment_information/constants/temp_directory.rb'
715
+
716
+ # ========================================================================= #
717
+ # === do_generate_a_html_file (html tag)
718
+ #
719
+ # The action-method that will generate the html file. This depends
720
+ # on the gem html_tags, with module HtmlTags though.
721
+ #
722
+ # To invoke this method, do:
723
+ #
724
+ # envi --generate-html-file
725
+ #
726
+ # ========================================================================= #
727
+ def do_generate_a_html_file(
728
+ styling_instructions = :none
729
+ )
730
+ # ======================================================================= #
731
+ # === Ensure that the html_tags project is available
732
+ # ======================================================================= #
733
+ unless Object.const_defined? :HtmlTags
734
+ begin
735
+ require 'html_tags'
736
+ rescue LoadError
737
+ e 'html_tags is not available. Considering installing it via:'
738
+ e
739
+ e ' gem install html_tags'
740
+ e
741
+ end
742
+ end
743
+ # ======================================================================= #
744
+ # === Define where to store the .html file in question
745
+ # ======================================================================= #
746
+ this_html_file = "#{::EnvironmentInformation.temp_directory?}environment_information.html"
747
+ # ======================================================================= #
748
+ # Obtain the main dataset next.
749
+ # ======================================================================= #
750
+ what = dataset_as_string
751
+ case styling_instructions
752
+ when :bold
753
+ what = HtmlTags.b(what)
754
+ end
755
+ what = HtmlTags.html(
756
+ HtmlTags.title('Information about the local environment')+
757
+ HtmlTags.body(
758
+ HtmlTags.h1(
759
+ 'Your environment',
760
+ css_style: 'margin-top: 0.5em; margin-bottom: 0.5em; padding: 2px;'
761
+ )+
762
+ HtmlTags.pre(
763
+ what,
764
+ css_style: 'font-weight: bold; font-size: 2em; padding-left: 1.0em; margin-top:2px;'
765
+ )
766
+ )
767
+ )
768
+ ::EnvironmentInformation.write_what_into(what, this_html_file)
769
+ # ======================================================================= #
770
+ # Notify the user what has been done.
771
+ # ======================================================================= #
772
+ if File.exist? this_html_file
773
+ opnn; e "Generated a HTML file at `#{sfile(this_html_file)}`."
774
+ end
775
+ end
776
+
777
+ # ========================================================================= #
778
+ # === THE_PROGRAM_IS_NOT_INSTALLED_OR_COULD_NOT_BE_FOUND
779
+ # ========================================================================= #
780
+ THE_PROGRAM_IS_NOT_INSTALLED_OR_COULD_NOT_BE_FOUND =
781
+ '[The program is not installed or could not be found.]'.dup
782
+
783
+ # ========================================================================= #
784
+ # === report_the_installed_KDE_software_suite
785
+ # ========================================================================= #
786
+ def report_the_installed_KDE_software_suite
787
+ begin
788
+ require 'rbt/toplevel_methods/misc.rb'
789
+ require 'rbt/toplevel_methods/try_to_return_a_special_compile_component.rb'
790
+ require 'rbt/toplevel_methods/swift_return_version_of_this_program.rb'
791
+ array = RBT.return_kde_apps
792
+ append_this = ''.dup
793
+ if array and !array.empty?
794
+ e 'Now working through all registered KDE applications, trying to'
795
+ e 'show their version on the commandline:'
796
+ e
797
+ array.each {|this_program|
798
+ append_this.clear
799
+ # ================================================================= #
800
+ # The next line of code was added in August 2022 because ksmoothdock
801
+ # is misbehaving. At a later time we may have to review this;
802
+ # ideally we should not need any such ad-hoc exceptions ever.
803
+ # ================================================================= #
804
+ next if this_program == 'ksmoothdock'
805
+ print gold(
806
+ (' '+this_program+':').ljust(40)
807
+ )
808
+ cmd_to_use = "#{this_program} --version 2>&1"
809
+ version = `#{cmd_to_use}`
810
+ if version.include? "command not found\n"
811
+ version = THE_PROGRAM_IS_NOT_INSTALLED_OR_COULD_NOT_BE_FOUND
812
+ else
813
+ if version
814
+ # Remove the name of the program here e. g. "kcachegrind 21.12.1"
815
+ version.sub!(/#{this_program}/,'')
816
+ most_recent_version = ::RBT.swift_return_version_of_this_program(this_program.strip.downcase)
817
+ if RBT.is_this_version_higher_than_that_version?(
818
+ most_recent_version.to_s,
819
+ version.to_s,
820
+ :do_not_report_any_errors
821
+ )
822
+ append_this << orange(
823
+ "\n ^^^ This program could "\
824
+ "be updated to version "+
825
+ most_recent_version.to_s
826
+ )
827
+ end
828
+ end
829
+ end
830
+ version.strip!
831
+ if version.include? 'The program is not installed'
832
+ e lightblue(version)+append_this
833
+ else
834
+ e steelblue(version)+append_this
835
+ end
836
+ }
837
+ e
838
+ else
839
+ e 'The array appears to be empty.'
840
+ end
841
+ exit
842
+ rescue LoadError; end
843
+ end
844
+
845
+ # ========================================================================= #
846
+ # === is_a_registered_component?
847
+ # ========================================================================= #
848
+ def is_a_registered_component?(i)
849
+ ::EnvironmentInformation.is_this_component_included?(i)
850
+ end; alias is_an_allowed_entry? is_a_registered_component? # === is_an_allowed_entry?
851
+
852
+ # ========================================================================= #
853
+ # === tracked_programs?
854
+ # ========================================================================= #
855
+ def tracked_programs?
856
+ ARRAY_TRACKED_PROGRAMS
857
+ end
858
+
859
+ # ========================================================================= #
860
+ # === return_default_programs_on_linux
861
+ #
862
+ # This method should return the "main" programs on a linux computer,
863
+ # the most important entries.
864
+ # ========================================================================= #
865
+ def return_default_programs_on_linux
866
+ ARRAY_DEFAULT_PROGRAMS_ON_LINUX
867
+ end; alias return_default_programs_on_a_linux_computer return_default_programs_on_linux # === return_default_programs_on_a_linux_computer
868
+ alias return_default_programs return_default_programs_on_linux # === return_default_programs
869
+
870
+ # ========================================================================= #
871
+ # === do_show_almost_everything_excluding_the_default_linux_programs
872
+ #
873
+ # This is similar to do_show_everything() but it will not show
874
+ # the default linux programs.
875
+ # ========================================================================= #
876
+ def do_show_almost_everything_excluding_the_default_linux_programs
877
+ these_programs = return_every_registered_component
878
+ default_programs = return_default_programs
879
+ # ======================================================================= #
880
+ # Next subtract those that are part in the default_programs.
881
+ # ======================================================================= #
882
+ these_programs.reject! {|entry|
883
+ default_programs.include? entry
884
+ }
885
+ add(these_programs)
886
+ end
887
+
888
+ # ========================================================================= #
889
+ # === do_show_everything (everything tag, full tag)
890
+ #
891
+ # This method can be used when the user wishes to enable seeing
892
+ # full information about his local environment (on the computer).
893
+ #
894
+ # This will always display EVERY registered component.
895
+ #
896
+ # Commandline invocation:
897
+ #
898
+ # envi --everything
899
+ #
900
+ # ========================================================================= #
901
+ def do_show_everything
902
+ add(:everything) # Simply add everything.
903
+ end; alias do_show_full_information do_show_everything # === do_show_full_information
904
+ alias show_full_information do_show_everything # === show_full_information
905
+
906
+ # ========================================================================= #
907
+ # === consider_storing_the_components_that_were_displayed
908
+ # ========================================================================= #
909
+ def consider_storing_the_components_that_were_displayed
910
+ if store_the_results_into_local_files?
911
+ ::EnvironmentInformation.consider_storing_these_results_into_a_local_file
912
+ end
913
+ end; alias consider_storing_which_components_were_displayed consider_storing_the_components_that_were_displayed # === consider_storing_which_components_were_displayed
914
+
915
+ # ========================================================================= #
916
+ # === store_the_results_into_local_files?
917
+ # ========================================================================= #
918
+ def store_the_results_into_local_files?
919
+ @internal_hash[:store_the_results_into_local_files]
920
+ end
921
+
922
+ # ========================================================================= #
923
+ # === do_show_only_the_operating_system
924
+ #
925
+ # To invoke this method, try:
926
+ #
927
+ # envi --os?
928
+ #
929
+ # ========================================================================= #
930
+ def do_show_only_the_operating_system
931
+ clear_old_dataset
932
+ add(:operating_system)
933
+ end
934
+
935
+ # ========================================================================= #
936
+ # === can_we_query_the_mate_desktop?
937
+ # ========================================================================= #
938
+ def can_we_query_the_mate_desktop?
939
+ is_rbt_available? and RBT.const_defined?(:ReportMateDesktopVersion)
940
+ end
941
+
942
+ # ========================================================================= #
943
+ # === show_n_registered_entries
944
+ #
945
+ # Invoke this via:
946
+ #
947
+ # envi --n_entries
948
+ #
949
+ # ========================================================================= #
950
+ def show_n_registered_entries
951
+ e "#{true_rev}The EnvironmentInformation project contains "\
952
+ "#{sfancy(::EnvironmentInformation.tracked_programs?.size)} "\
953
+ "#{true_rev}registered entries."
954
+ end
955
+
956
+ # ========================================================================= #
957
+ # === assign_components_for_the_short_format
958
+ #
959
+ # We will only display 6 components when we use the short variant.
960
+ # ========================================================================= #
961
+ def assign_components_for_the_short_format
962
+ clear_old_dataset
963
+ dont_show_ruby_stuff
964
+ add(%i(
965
+ operating_system
966
+ operating_system_bit_type
967
+ cpuinfo
968
+ cflags
969
+ RAM
970
+ screen_resolution
971
+ ))
972
+ end
973
+
974
+ # ========================================================================= #
975
+ # === may_we_try_to_use_rbt?
976
+ # ========================================================================= #
977
+ def may_we_try_to_use_rbt?
978
+ @may_we_try_to_use_rbt
979
+ end
980
+
981
+ # ========================================================================= #
982
+ # === write_what_into
983
+ # ========================================================================= #
984
+ def write_what_into(what, into)
985
+ ::EnvironmentInformation.write_what_into(what, into)
986
+ end
987
+
988
+ # ========================================================================= #
989
+ # === work_on_the_programs_directory_only
990
+ #
991
+ # This works on the /home/Programs/ directory directly.
992
+ #
993
+ # Invocation example:
994
+ #
995
+ # envi --work-on-programs-directory-only
996
+ #
997
+ # ========================================================================= #
998
+ def work_on_the_programs_directory_only(
999
+ use_this_as_programs_directory = '/home/Programs/'
1000
+ )
1001
+ # ======================================================================= #
1002
+ # 1) First, we have to determine which programs are available.
1003
+ # ======================================================================= #
1004
+ e "#{rev}Determining which programs are available at the prefix "\
1005
+ "#{steelblue(use_this_as_programs_directory)}:"
1006
+ array_these_programs_are_available = []
1007
+ tracked_programs?.each {|entry|
1008
+ target = "#{use_this_as_programs_directory}#{entry.capitalize}"
1009
+ if File.directory?(target)
1010
+ # =================================================================== #
1011
+ # In this case we know that this target exists.
1012
+ # =================================================================== #
1013
+ array_these_programs_are_available << entry
1014
+ end
1015
+ }
1016
+ # ======================================================================= #
1017
+ # 2) Checking these programs next.
1018
+ # ======================================================================= #
1019
+ clear_main_dataset
1020
+ add(array_these_programs_are_available)
1021
+ ::EnvironmentInformation.set_prefix_to_use(use_this_as_programs_directory)
1022
+ end
1023
+
1024
+ # ========================================================================= #
1025
+ # === set_main_array
1026
+ # ========================================================================= #
1027
+ def set_main_array(i)
1028
+ @array_report_these_programs = i
1029
+ end; alias set_display_these_components set_main_array # === set_display_these_components
1030
+ alias set_use_this_as_main_input set_main_array # === set_use_this_as_main_input
1031
+ alias set_report_these_programs set_main_array # === set_report_these_programs
1032
+ alias show_only_the_components_from_this_dataset set_main_array # === show_only_the_components_from_this_dataset
1033
+
1034
+ # ========================================================================= #
1035
+ # === set_runmode_gui
1036
+ # ========================================================================= #
1037
+ def set_runmode_gui
1038
+ @runmode = :gui
1039
+ end
1040
+
1041
+ # ========================================================================= #
1042
+ # === set_runmode_html
1043
+ # ========================================================================= #
1044
+ def set_runmode_html
1045
+ @runmode = :html
1046
+ end
1047
+
1048
+ # ========================================================================= #
1049
+ # === do_exit_the_program
1050
+ # ========================================================================= #
1051
+ def do_exit_the_program
1052
+ @do_exit_the_program = true
1053
+ end
1054
+
1055
+ # ========================================================================= #
1056
+ # === gui?
1057
+ # ========================================================================= #
1058
+ def gui?
1059
+ @runmode == :gui
1060
+ end
1061
+
1062
+ # ========================================================================= #
1063
+ # === commandline?
1064
+ #
1065
+ # Whether we run in the "commandline mode" or whether we run in the
1066
+ # GUI or WWW/HTML mode.
1067
+ # ========================================================================= #
1068
+ def commandline?
1069
+ @runmode == :commandline
1070
+ end
1071
+
1072
+ # ========================================================================= #
1073
+ # === be_silent
1074
+ # ========================================================================= #
1075
+ def be_silent
1076
+ @be_silent = true
1077
+ end; alias be_quiet be_silent # === be_quiet
1078
+
1079
+ # ========================================================================= #
1080
+ # === set_be_silent
1081
+ # ========================================================================= #
1082
+ def set_be_silent(i = true)
1083
+ @be_silent = i
1084
+ end
1085
+
1086
+ # ========================================================================= #
1087
+ # === be_silent?
1088
+ # ========================================================================= #
1089
+ def be_silent?
1090
+ @be_silent
1091
+ end
1092
+
1093
+ # ========================================================================= #
1094
+ # === start_the_sinatra_interface
1095
+ # ========================================================================= #
1096
+ def start_the_sinatra_interface
1097
+ require 'environment_information/www/sinatra_interface.rb'
1098
+ ::EnvironmentInformation.start_sinatra_interface
1099
+ end
1100
+
1101
+ # ========================================================================= #
1102
+ # === do_not_display_the_result
1103
+ # ========================================================================= #
1104
+ def do_not_display_the_result
1105
+ @display_result = false
1106
+ end
1107
+
1108
+ # ========================================================================= #
1109
+ # === do_rename_kde_konsole
1110
+ #
1111
+ # This will attempt to rename the KDE Konsole tab, but only if we are
1112
+ # on roebe.
1113
+ # ========================================================================= #
1114
+ def do_rename_kde_konsole(
1115
+ use_this_title = 'Environment Information'
1116
+ )
1117
+ begin
1118
+ require 'roebe/requires/require_kde_konsole.rb'
1119
+ rescue LoadError; end
1120
+ if try_to_rename_the_kde_konsole_tab? and
1121
+ is_on_roebe? and
1122
+ Object.const_defined?(:Roebe) and
1123
+ Roebe.const_defined?(:KdeKonsole)
1124
+ Roebe.rename_konsole(use_this_title)
1125
+ end
1126
+ end
1127
+
1128
+ # ========================================================================= #
1129
+ # === use_ascii_table
1130
+ #
1131
+ # We will display in ascii-table format here.
1132
+ # ========================================================================= #
1133
+ def use_ascii_table
1134
+ disable_colours # Can't use colours right now. Perhaps at a later time.
1135
+ extend Terminal::Table::TableHelper
1136
+ @table = table ['Name', 'Version']
1137
+ @table.style = {
1138
+ padding_left: 2,
1139
+ width: 110 # Set the width here.
1140
+ }
1141
+ @use_ascii_table = true
1142
+ end
1143
+
1144
+ # ========================================================================= #
1145
+ # === show_everything?
1146
+ # ========================================================================= #
1147
+ def show_everything?
1148
+ @show_everything
1149
+ end
1150
+
1151
+ # ========================================================================= #
1152
+ # === try_to_rename_the_kde_konsole_tab?
1153
+ # ========================================================================= #
1154
+ def try_to_rename_the_kde_konsole_tab?
1155
+ @internal_hash[:try_to_rename_the_kde_konsole_tab]
1156
+ end
1157
+
1158
+ # ========================================================================= #
1159
+ # === do_not_run_already
1160
+ # ========================================================================= #
1161
+ def do_not_run_already
1162
+ @run_already = false
1163
+ end; alias do_not_run do_not_run_already # === do_not_run
1164
+
1165
+ # ========================================================================= #
1166
+ # === open_this_file_in_editor
1167
+ # ========================================================================= #
1168
+ def open_this_file_in_editor
1169
+ _ = "bluefish #{THIS_FILE}"
1170
+ e _; system _; exit
1171
+ end
1172
+
1173
+ # ========================================================================= #
1174
+ # === xorg_components?
1175
+ # ========================================================================= #
1176
+ def xorg_components?
1177
+ ::EnvironmentInformation.xorg_components?
1178
+ end; alias return_all_xorg_components xorg_components? # === return_all_xorg_components
1179
+
1180
+ # ========================================================================= #
1181
+ # === do_show_only_the_xorg_components
1182
+ #
1183
+ # This method will essentially clear the old dataset before adding
1184
+ # all xorg-components to the display-part of this class.
1185
+ #
1186
+ # The components that are appended here, are defined in the file
1187
+ # constants/array_tracked_components.rb - so if you wish to add
1188
+ # new xorg-related entries, you should modify the entries in that
1189
+ # .rb file.
1190
+ # ========================================================================= #
1191
+ def do_show_only_the_xorg_components
1192
+ clear_old_dataset
1193
+ do_not_show_the_ruby_components
1194
+ add(:all_xorg_components)
1195
+ end
1196
+
1197
+ # ========================================================================= #
1198
+ # === clear_old_dataset
1199
+ # ========================================================================= #
1200
+ def clear_old_dataset
1201
+ @array_report_these_programs.clear
1202
+ end
1203
+
1204
+ # ========================================================================= #
1205
+ # === shall_we_really_store_which_programs_are_not_up_to_date?
1206
+ #
1207
+ # This method will also honour whether the user is on a roebe-like
1208
+ # system or whether the user is not.
1209
+ # ========================================================================= #
1210
+ def shall_we_really_store_which_programs_are_not_up_to_date?
1211
+ is_on_roebe? and !@array_these_programs_not_up_to_date.empty?
1212
+ end
1213
+
1214
+ # ========================================================================= #
1215
+ # === result_as_array
1216
+ #
1217
+ # The lines that we will have inside of this method, may look like this:
1218
+ #
1219
+ # " operating_system: GNU/Linux\n"
1220
+ #
1221
+ # ========================================================================= #
1222
+ def result_as_array
1223
+ _ = dataset_as_string
1224
+ splitted = _.split("\n")
1225
+ splitted.map! {|inner_line|
1226
+ inner_line.split(': ').map {|entry| entry.strip }
1227
+ }
1228
+ return splitted
1229
+ end; alias result result_as_array # === result
1230
+
1231
+ # ========================================================================= #
1232
+ # === clear_the_main_dataset
1233
+ # ========================================================================= #
1234
+ def clear_the_main_dataset
1235
+ clear_old_dataset
1236
+ do_not_display_the_ruby_components
1237
+ end; alias clear_main_dataset clear_the_main_dataset # === clear_main_dataset
1238
+ alias empty_main_dataset clear_the_main_dataset # === empty_main_dataset
1239
+ alias empty_main_array clear_the_main_dataset # === empty_main_array
1240
+
1241
+ # ========================================================================= #
1242
+ # === clear_toplevel_hash
1243
+ # ========================================================================= #
1244
+ def clear_toplevel_hash
1245
+ ::EnvironmentInformation.clear_hash
1246
+ end
1247
+
1248
+ # ========================================================================= #
1249
+ # === dataset_as_string
1250
+ #
1251
+ # This method must return the dataset in String format. That String
1252
+ # must already be properly "formatted".
1253
+ # ========================================================================= #
1254
+ def dataset_as_string
1255
+ _ = ''.dup # Put the information onto that String here.
1256
+ main_dataset?.each {|entry|
1257
+ if entry.is_a? Array
1258
+ entry = entry.first # The second entry is ignored in that event.
1259
+ end
1260
+ # ===================================================================== #
1261
+ # Before we can use .send() we have to check whether EnvironmentInformation
1262
+ # actually responds to that method. If not then we will simply skip
1263
+ # this snippet for now; but this may have to be changed at some
1264
+ # point in the future, to more elegantly handle failure. (Sep 2019).
1265
+ # ===================================================================== #
1266
+ use_this_method = "return_version_of_#{entry}".to_sym
1267
+ if ::EnvironmentInformation.respond_to? use_this_method
1268
+ program_version = ::EnvironmentInformation.send(
1269
+ use_this_method
1270
+ )
1271
+ entry = " #{entry}:"
1272
+ _ << "#{entry} #{program_version}#{N}"
1273
+ end
1274
+ }
1275
+ return _ # And return the generated String.
1276
+ end; alias string? dataset_as_string # === string?
1277
+ alias string dataset_as_string # === string
1278
+ alias main_string? dataset_as_string # === main_string?
1279
+ alias stringified dataset_as_string # === stringified
1280
+
1281
+ # ========================================================================= #
1282
+ # === return_version_of_awk?
1283
+ # ========================================================================= #
1284
+ def return_version_of_awk?
1285
+ ::EnvironmentInformation.send(__method__)
1286
+ end; alias return_version_of_awk return_version_of_awk? # == return_version_of_awk
1287
+
1288
+ # ========================================================================= #
1289
+ # === return_version_of_binutils?
1290
+ # ========================================================================= #
1291
+ def return_version_of_binutils?
1292
+ ::EnvironmentInformation.send(__method__)
1293
+ end; alias return_version_of_binutils return_version_of_binutils? # == return_version_of_binutils
1294
+
1295
+ # ========================================================================= #
1296
+ # === return_version_of_coreutils?
1297
+ # ========================================================================= #
1298
+ def return_version_of_coreutils?
1299
+ ::EnvironmentInformation.send(__method__)
1300
+ end; alias return_version_of_coreutils return_version_of_coreutils? # == return_version_of_coreutils
1301
+
1302
+ # ========================================================================= #
1303
+ # === return_version_of_diffutils?
1304
+ # ========================================================================= #
1305
+ def return_version_of_diffutils?
1306
+ ::EnvironmentInformation.send(__method__)
1307
+ end; alias return_version_of_diffutils return_version_of_diffutils? # == return_version_of_diffutils
1308
+
1309
+ # ========================================================================= #
1310
+ # === return_version_of_gcc?
1311
+ # ========================================================================= #
1312
+ def return_version_of_gcc?
1313
+ ::EnvironmentInformation.send(__method__)
1314
+ end; alias return_version_of_gcc return_version_of_gcc? # == return_version_of_gcc
1315
+
1316
+ # ========================================================================= #
1317
+ # === return_version_of_linux_kernel?
1318
+ # ========================================================================= #
1319
+ def return_version_of_linux_kernel?
1320
+ ::EnvironmentInformation.send(__method__)
1321
+ end; alias return_version_of_linux_kernel return_version_of_linux_kernel? # == return_version_of_linux_kernel
1322
+
1323
+ # ========================================================================= #
1324
+ # === is_this_program_included?
1325
+ # ========================================================================= #
1326
+ def is_this_program_included?(i)
1327
+ ::EnvironmentInformation.is_this_program_included?(i)
1328
+ end
1329
+
1330
+ # ========================================================================= #
1331
+ # === return_version_of_glibc?
1332
+ # ========================================================================= #
1333
+ def return_version_of_glibc?
1334
+ ::EnvironmentInformation.send(__method__)
1335
+ end; alias return_version_of_glibc return_version_of_glibc? # == return_version_of_glibc
1336
+
1337
+ # ========================================================================= #
1338
+ # === return_version_of_intltool?
1339
+ # ========================================================================= #
1340
+ def return_version_of_intltool?
1341
+ ::EnvironmentInformation.send(__method__)
1342
+ end; alias return_version_of_intltool return_version_of_intltool? # == return_version_of_intltool
1343
+
1344
+ # ========================================================================= #
1345
+ # === return_version_of_grep?
1346
+ # ========================================================================= #
1347
+ def return_version_of_grep?
1348
+ ::EnvironmentInformation.send(__method__)
1349
+ end; alias return_version_of_grep return_version_of_grep? # == return_version_of_grep
1350
+
1351
+ # ========================================================================= #
1352
+ # === return_version_of_gnupg?
1353
+ # ========================================================================= #
1354
+ def return_version_of_gnupg?
1355
+ ::EnvironmentInformation.send(__method__)
1356
+ end; alias return_version_of_gnupg return_version_of_gnupg? # == return_version_of_gnupg
1357
+
1358
+ # ========================================================================= #
1359
+ # === return_version_of_bison?
1360
+ # ========================================================================= #
1361
+ def return_version_of_bison?
1362
+ ::EnvironmentInformation.send(__method__)
1363
+ end; alias return_version_of_bison return_version_of_bison? # == return_version_of_bison
1364
+
1365
+ # ========================================================================= #
1366
+ # === return_version_of_flex?
1367
+ # ========================================================================= #
1368
+ def return_version_of_flex?
1369
+ ::EnvironmentInformation.send(__method__)
1370
+ end; alias return_version_of_flex return_version_of_flex? # == return_version_of_flex
1371
+
1372
+ # ========================================================================= #
1373
+ # === operating_system?
1374
+ #
1375
+ # To quickly test this method, try:
1376
+ #
1377
+ # EnvironmentInformation::EnvironmentInformation.new { :do_not_run_yet }.operating_system?
1378
+ #
1379
+ # ========================================================================= #
1380
+ def operating_system?
1381
+ ::EnvironmentInformation.send(__method__)
1382
+ end; alias return_version_of_operating_system operating_system? # === return_version_of_operating_system
1383
+
1384
+ # ========================================================================= #
1385
+ # === load_dataset_from_this_file
1386
+ #
1387
+ # This method can be used to read which programs will be displayed
1388
+ # from a local file, rather than rely on the pre-set default.
1389
+ # ========================================================================= #
1390
+ def load_dataset_from_this_file(i)
1391
+ if File.exist? i
1392
+ File.readlines(i).map {|entry|
1393
+ entry.delete('-').strip # ← Clean up the input a little bit.
1394
+ }
1395
+ else
1396
+ opnn; e "No file exists at `#{sfile(i)}`."
1397
+ end
1398
+ end; alias try_to_load_dataset_from_this_file load_dataset_from_this_file # === try_to_load_dataset_from_this_file
1399
+ alias try_to_read_content_from_this_file load_dataset_from_this_file # === try_to_read_content_from_this_file
1400
+
1401
+ # ========================================================================= #
1402
+ # === consider_storing_which_programs_are_not_up_to_date
1403
+ # ========================================================================= #
1404
+ def consider_storing_which_programs_are_not_up_to_date
1405
+ if shall_we_really_store_which_programs_are_not_up_to_date?
1406
+ into = FILE_THESE_PROGRAMS_CAN_BE_UPGRADED
1407
+ what = YAML.dump(@array_these_programs_not_up_to_date)
1408
+ if File.directory?('/home/Temp/rbt/')
1409
+ into = "/home/Temp/rbt/#{File.basename(into)}"
1410
+ else
1411
+ into = "#{log_dir?}#{File.basename(into)}"
1412
+ end
1413
+ opnn; e 'We will also store which programs are not up to date.'
1414
+ opnn; e "These will be stored into the file at `#{sfile(into)}`."
1415
+ ::EnvironmentInformation.write_what_into(what, into)
1416
+ end
1417
+ end
1418
+
1419
+ require 'environment_information/misc_components/operating_system_bit_type.rb'
1420
+ # ========================================================================= #
1421
+ # === bit_type?
1422
+ # ========================================================================= #
1423
+ def bit_type?
1424
+ ::EnvironmentInformation.operating_system_bit_type
1425
+ end
1426
+
1427
+ # ========================================================================= #
1428
+ # === register_unavailable_program
1429
+ #
1430
+ # Programs that were not be found can be registered through this method.
1431
+ # ========================================================================= #
1432
+ def register_unavailable_program(i)
1433
+ i = i.to_sym # Let's store only Symbols.
1434
+ @array_unavailable_programs << i
1435
+ end; alias register_not_found register_unavailable_program # === register_not_found
1436
+
1437
+ require 'environment_information/misc_components/cpuinfo.rb'
1438
+ # ========================================================================= #
1439
+ # === cpu_model?
1440
+ # ========================================================================= #
1441
+ def cpu_model?
1442
+ ::EnvironmentInformation.cpuinfo?
1443
+ end
1444
+
1445
+ require 'environment_information/misc_components/ram.rb'
1446
+ # ========================================================================= #
1447
+ # === ram?
1448
+ # ========================================================================= #
1449
+ def ram?
1450
+ ::EnvironmentInformation.ram?
1451
+ end
1452
+
1453
+ require 'environment_information/misc_components/screen_resolution.rb'
1454
+ # ========================================================================= #
1455
+ # === screen_resolution?
1456
+ # ========================================================================= #
1457
+ def screen_resolution?
1458
+ ::EnvironmentInformation.screen_resolution?
1459
+ end
1460
+
1461
+ require 'environment_information/misc_components/cflags.rb'
1462
+ # ========================================================================= #
1463
+ # === cflags_in_use?
1464
+ # ========================================================================= #
1465
+ def cflags_in_use?
1466
+ ::EnvironmentInformation.cflags_in_use?
1467
+ end
1468
+
1469
+ # ========================================================================= #
1470
+ # === return_every_registered_component
1471
+ # ========================================================================= #
1472
+ def return_every_registered_component
1473
+ array = ::EnvironmentInformation.tracked_programs?+
1474
+ ::EnvironmentInformation.tracked_non_programs?+
1475
+ ::EnvironmentInformation.science_cluster?+
1476
+ ::EnvironmentInformation.xorg_components?
1477
+ array = array.flatten.uniq
1478
+ # ======================================================================= #
1479
+ # === The mate-desktop
1480
+ #
1481
+ # Since as of 31.03.2019 we will also try to show the mate-desktop
1482
+ # components if the RBT project is available/installed.
1483
+ # ======================================================================= #
1484
+ if can_we_query_the_mate_desktop?
1485
+ # ===================================================================== #
1486
+ # Keep in mind that this Array is nested, so the name is
1487
+ # included as well as the version.
1488
+ # ===================================================================== #
1489
+ _ = RBT.return_mate_desktop_version_array
1490
+ _.each {|a,b|
1491
+ # array << [a, b]
1492
+ array << a
1493
+ register_onto_the_main_hash(a, b)
1494
+ }
1495
+ end
1496
+ return array # Return our findings.
1497
+ end
1498
+
1499
+ # ========================================================================= #
1500
+ # === clear_hash_and_missing_components
1501
+ # ========================================================================= #
1502
+ def clear_hash_and_missing_components
1503
+ clear_toplevel_hash
1504
+ clear_missing_components
1505
+ end
1506
+
1507
+ # ========================================================================= #
1508
+ # === clear_missing_components
1509
+ # ========================================================================= #
1510
+ def clear_missing_components
1511
+ ::EnvironmentInformation.clear_missing_components
1512
+ end
1513
+
1514
+ # ========================================================================= #
1515
+ # === return_remote_gtk2_version
1516
+ #
1517
+ # Be wary when using this method, as it may slow down the whole
1518
+ # application, due to making remote web-based queries.
1519
+ # ========================================================================= #
1520
+ def return_remote_gtk2_version
1521
+ ::EnvironmentInformation.return_remote_gtk2_version
1522
+ end
1523
+
1524
+ # ========================================================================= #
1525
+ # === do_compare_the_program_version
1526
+ #
1527
+ # This method can be used if the user wishes to also compare the
1528
+ # program version of the installed programs. This functionality
1529
+ # depends on the rbt gem, and the RBT namespace.
1530
+ # ========================================================================= #
1531
+ def do_compare_the_program_version(
1532
+ be_verbose = true
1533
+ )
1534
+ if be_verbose
1535
+ @array_show_this_to_the_user <<
1536
+ 'The program versions will also be compared.'
1537
+ end
1538
+ @internal_hash[:compare_program_versions] = true
1539
+ end
1540
+
1541
+ # ========================================================================= #
1542
+ # === compare_program_versions?
1543
+ # ========================================================================= #
1544
+ def compare_program_versions?
1545
+ @internal_hash[:compare_program_versions]
1546
+ end; alias compare_program_version? compare_program_versions? # === compare_program_version?
1547
+
1548
+ # ========================================================================= #
1549
+ # === is_rbt_available_and_may_we_try_to_use_rbt?
1550
+ # ========================================================================= #
1551
+ def is_rbt_available_and_may_we_try_to_use_rbt?
1552
+ is_rbt_available? and may_we_try_to_use_rbt?
1553
+ end
1554
+
1555
+ # ========================================================================= #
1556
+ # === report_the_remote_urls?
1557
+ # ========================================================================= #
1558
+ def report_the_remote_urls?
1559
+ @internal_hash[:report_the_remote_urls]
1560
+ end
1561
+
1562
+ # ========================================================================= #
1563
+ # === return_version_of_busyboxy?
1564
+ # ========================================================================= #
1565
+ def return_version_of_busyboxy?
1566
+ ::EnvironmentInformation.send(__method__)
1567
+ end; alias return_version_of_busyboxy return_version_of_busyboxy? # == return_version_of_busyboxy
1568
+
1569
+ # ========================================================================= #
1570
+ # === return_version_of_boost?
1571
+ # ========================================================================= #
1572
+ def return_version_of_boost?
1573
+ ::EnvironmentInformation.send(__method__)
1574
+ end; alias return_version_of_boost return_version_of_boost? # == return_version_of_boost
1575
+
1576
+ # ========================================================================= #
1577
+ # === return_version_of_xvid?
1578
+ # ========================================================================= #
1579
+ def return_version_of_xvid?
1580
+ ::EnvironmentInformation.send(__method__)
1581
+ end; alias return_version_of_xvid return_version_of_xvid? # == return_version_of_xvid
1582
+
1583
+ # ========================================================================= #
1584
+ # === start_gtk_component
1585
+ #
1586
+ # To invoke this method from the commandline, do:
1587
+ #
1588
+ # envi --start-gtk
1589
+ #
1590
+ # ========================================================================= #
1591
+ def start_gtk_component
1592
+ require 'environment_information/gui/gtk3/environment_information.rb'
1593
+ ::EnvironmentInformation.run_gtk
1594
+ @do_exit_the_program = true
1595
+ end
1596
+
1597
+ # ========================================================================= #
1598
+ # === do_sort_alphabetically (sort tag)
1599
+ #
1600
+ # Some entries are Symbols, which is why we have to call .to_s in the
1601
+ # method here.
1602
+ # ========================================================================= #
1603
+ def do_sort_alphabetically(
1604
+ display_these_components = display_which_components?
1605
+ )
1606
+ _ = display_these_components.sort_by {|name, version| name.to_s }
1607
+ set_main_array(_)
1608
+ end
1609
+
1610
+ # ========================================================================= #
1611
+ # === do_not_save_anything
1612
+ # ========================================================================= #
1613
+ def do_not_save_anything
1614
+ @shall_the_results_be_saved = false
1615
+ # ======================================================================= #
1616
+ # We will also avoid saving the results into a local yaml file.
1617
+ # ======================================================================= #
1618
+ @internal_hash[:store_the_results_into_local_files] = false
1619
+ end; alias do_not_store_anything do_not_save_anything # === do_not_store_anything
1620
+
1621
+ # ========================================================================= #
1622
+ # === do_display_in_a_short_format
1623
+ #
1624
+ # The short-format means that we will use only a compact set of
1625
+ # programs to display. For example, "make" and "bash" will not be
1626
+ # displayed, neither "binutils" or "ruby".
1627
+ # ========================================================================= #
1628
+ def do_display_in_a_short_format
1629
+ @display_everything_in_short_format = true
1630
+ end
1631
+
1632
+ # ========================================================================= #
1633
+ # === sort_alphabetically?
1634
+ # ========================================================================= #
1635
+ def sort_alphabetically?
1636
+ @internal_hash[:sort_alphabetically]
1637
+ end
1638
+
1639
+ # ========================================================================= #
1640
+ # === enable_sort_alphabetically
1641
+ # ========================================================================= #
1642
+ def enable_sort_alphabetically
1643
+ @internal_hash[:sort_alphabetically] = true
1644
+ end
1645
+
1646
+ # ========================================================================= #
1647
+ # === opnn
1648
+ # ========================================================================= #
1649
+ def opnn
1650
+ if TRY_TO_MAKE_USE_OF_THE_OPN_GEM_IF_IT_IS_AVAILABLE and
1651
+ Object.const_defined?(:Opn)
1652
+ Opn.opn({
1653
+ namespace: NAMESPACE,
1654
+ use_colours: use_colours?
1655
+ })
1656
+ end
1657
+ end; alias opn opnn # === opn
1658
+
1659
+ # ========================================================================= #
1660
+ # === register_sigint
1661
+ # ========================================================================= #
1662
+ def register_sigint
1663
+ Signal.trap('SIGINT') { e; exit }
1664
+ end
1665
+
1666
+ # ========================================================================= #
1667
+ # === reset (reset tag)
1668
+ # ========================================================================= #
1669
+ def reset
1670
+ # ======================================================================= #
1671
+ # === @pkg_config_query
1672
+ # ======================================================================= #
1673
+ @pkg_config_query = ::EnvironmentInformation::Queries::PkgConfig.new
1674
+ # ======================================================================= #
1675
+ # === @simple_version_query
1676
+ # ======================================================================= #
1677
+ @simple_version_query = ::EnvironmentInformation::Queries::SimpleVersion.new
1678
+ # ======================================================================= #
1679
+ # === @complex_version_query
1680
+ # ======================================================================= #
1681
+ @complex_version_query = ::EnvironmentInformation::Queries::ComplexVersion.new
1682
+ # ======================================================================= #
1683
+ # === @array_report_these_programs
1684
+ #
1685
+ # This Array denotes which programs are to be reported.
1686
+ #
1687
+ # By default it is empty.
1688
+ # ======================================================================= #
1689
+ @array_report_these_programs = []
1690
+ # ======================================================================= #
1691
+ # === @array_unavailable_programs
1692
+ #
1693
+ # Programs which could not be found can be registered into the following
1694
+ # Array.
1695
+ # ======================================================================= #
1696
+ @array_unavailable_programs = []
1697
+ # ======================================================================= #
1698
+ # === @runmode
1699
+ #
1700
+ # The @runmode variable can be :commandline or :gui or :www.
1701
+ # ======================================================================= #
1702
+ @runmode = :commandline
1703
+ # ======================================================================= #
1704
+ # === @show_everything
1705
+ #
1706
+ # If the following instance variable is set to true then this class
1707
+ # will try to show every registered (and thus, available) component.
1708
+ #
1709
+ # By default this is not wanted, so it is disabled. The user has to
1710
+ # specifically enable this option via the commandline, if so
1711
+ # desired, and thus overrule this default value.
1712
+ # ======================================================================= #
1713
+ @show_everything = false
1714
+ # ======================================================================= #
1715
+ # === @display_result
1716
+ #
1717
+ # If the following instance variable is true, which is the case by
1718
+ # default, then this class will report to the user on the commandline.
1719
+ #
1720
+ # If it is set to false then nothing will be displayed; this is
1721
+ # useful when you only want to obtain the dataset, without
1722
+ # showing anything to the user.
1723
+ # ======================================================================= #
1724
+ @display_result = true
1725
+ # ======================================================================= #
1726
+ # === @be_silent
1727
+ #
1728
+ # By default, this class is not silent, meaning that it will display
1729
+ # information to the user.
1730
+ # ======================================================================= #
1731
+ @be_silent = false
1732
+ # ======================================================================= #
1733
+ # === @may_we_try_to_use_rbt
1734
+ #
1735
+ # Whether we may query RBT for additional help or not. By default
1736
+ # we will try to make use of RBT.
1737
+ # ======================================================================= #
1738
+ @may_we_try_to_use_rbt = true
1739
+ # ======================================================================= #
1740
+ # === @array_show_this_to_the_user
1741
+ #
1742
+ # The following Array can be used to show messages to the user.
1743
+ # ======================================================================= #
1744
+ @array_show_this_to_the_user = []
1745
+ # ======================================================================= #
1746
+ # === @array_display_these_components
1747
+ #
1748
+ # This Array will display the components on the commandline.
1749
+ #
1750
+ # Take note that the order is important: the entries that appear first
1751
+ # will be displayed earlier. In other words: first entries will be
1752
+ # shown first as well.
1753
+ # ======================================================================= #
1754
+ @array_display_these_components = []
1755
+ # ======================================================================= #
1756
+ # === @show_ruby_version_and_gem_version
1757
+ #
1758
+ # This instance variable determines whether class EnvironmentInformation
1759
+ # will display the ruby version and the gem version.
1760
+ #
1761
+ # By default we will do so, but there may be situations where this
1762
+ # may be unwanted, or not a good idea, such as in a minimal system
1763
+ # where no ruby is running, or if the user only wants to display
1764
+ # very little information.
1765
+ # ======================================================================= #
1766
+ @show_ruby_version_and_gem_version = true
1767
+ # ======================================================================= #
1768
+ # === @display_everything_in_short_format
1769
+ #
1770
+ # This variable determines whether we will use a compact-display or
1771
+ # whether there will be one-entry-per-program instead.
1772
+ # ======================================================================= #
1773
+ @display_everything_in_short_format = false
1774
+ # ======================================================================= #
1775
+ # === @run_already
1776
+ #
1777
+ # This variable will be true by default.
1778
+ # ======================================================================= #
1779
+ @run_already = true
1780
+ # ======================================================================= #
1781
+ # === @show_help
1782
+ #
1783
+ # If this variable is set to true, then we will only show help, then
1784
+ # exit the program.
1785
+ # ======================================================================= #
1786
+ @show_help = false
1787
+ # ======================================================================= #
1788
+ # === @do_exit_the_program
1789
+ #
1790
+ # The following variable can determine when we exit from this class.
1791
+ # By default we will not exist early.
1792
+ # ======================================================================= #
1793
+ @do_exit_the_program = false
1794
+ # ======================================================================= #
1795
+ # === @array_these_programs_not_up_to_date
1796
+ #
1797
+ # This Array can be used to save into a local file which programs
1798
+ # are not up to date.
1799
+ # ======================================================================= #
1800
+ if is_on_roebe?
1801
+ @array_these_programs_not_up_to_date = []
1802
+ end
1803
+ # ======================================================================= #
1804
+ # === @internal_hash
1805
+ # ======================================================================= #
1806
+ @internal_hash = {}
1807
+ # ======================================================================= #
1808
+ # === :report_the_remote_urls
1809
+ #
1810
+ # If this instance variable is set to true then the remote URLs will
1811
+ # be shown as well, on the commandline.
1812
+ # ======================================================================= #
1813
+ @internal_hash[:report_the_remote_urls] = false
1814
+ # ======================================================================= #
1815
+ # === :try_to_rename_the_kde_konsole_tab
1816
+ #
1817
+ # The following instance variable will determine as to whether we will
1818
+ # try to make use of the KDE Konsole and rename the tab of the konsole
1819
+ # there.
1820
+ #
1821
+ # Since as of October 2018 we will not use the KDE konsole by default
1822
+ # anymore. This may change at a later moment in time, though.
1823
+ # ======================================================================= #
1824
+ @internal_hash[:try_to_rename_the_kde_konsole_tab] = false
1825
+ # ======================================================================= #
1826
+ # === :generate_a_html_file
1827
+ #
1828
+ # If the next instance variable is set to true then a html file will
1829
+ # be generated. By default this will not happen, though.
1830
+ # ======================================================================= #
1831
+ @internal_hash[:generate_a_html_file] = false
1832
+ # ======================================================================= #
1833
+ # === :store_the_results_into_local_files
1834
+ #
1835
+ # If the following variable is set to true then the project will
1836
+ # generate local files too, e. g. yaml files and what not.
1837
+ # ======================================================================= #
1838
+ @internal_hash[:store_the_results_into_local_files] = true
1839
+ # ======================================================================= #
1840
+ # === :use_ascii_table
1841
+ #
1842
+ # Whether to use an ASCII table or whether we will not:
1843
+ # ======================================================================= #
1844
+ @internal_hash[:use_ascii_table] = false
1845
+ # ======================================================================= #
1846
+ # === :table
1847
+ # ======================================================================= #
1848
+ @internal_hash[:table] = nil # The ascii table.
1849
+ # ======================================================================= #
1850
+ # === :compare_program_versions
1851
+ #
1852
+ # This instance variable can be used to also compare the program
1853
+ # versions, if the RBT project is available.
1854
+ #
1855
+ # By default this will not be done, though.
1856
+ # ======================================================================= #
1857
+ @internal_hash[:compare_program_versions] = false
1858
+ # ======================================================================= #
1859
+ # === :use_one_line_to_show_the_result
1860
+ # ======================================================================= #
1861
+ @internal_hash[:use_one_line_to_show_the_result] = false
1862
+ # ======================================================================= #
1863
+ # === :sort_alphabetically
1864
+ #
1865
+ # Whether to sort the main Hash alphabetically or not.
1866
+ # ======================================================================= #
1867
+ @internal_hash[:sort_alphabetically] = false
1868
+ end
1869
+
1870
+ # ========================================================================= #
1871
+ # === dont_show_ruby_stuff
1872
+ #
1873
+ # Disable showing ruby + gem information.
1874
+ # ========================================================================= #
1875
+ def dont_show_ruby_stuff # Dont show ruby stuff.
1876
+ @show_ruby_version_and_gem_version = false
1877
+ end; alias show_no_ruby dont_show_ruby_stuff # === show_no_ruby
1878
+
1879
+ # ========================================================================= #
1880
+ # === return_all_ruby_components
1881
+ #
1882
+ # Combine three calls into one here - all related to ruby.
1883
+ # ========================================================================= #
1884
+ def return_all_ruby_components
1885
+ %i(
1886
+ ruby
1887
+ rubygems
1888
+ rubygems_installation_directory
1889
+ )
1890
+ end
1891
+
1892
+ # ========================================================================= #
1893
+ # === consider_adding_the_ruby_components
1894
+ #
1895
+ # This method can be used to consider adding the ruby-components,
1896
+ # which means "ruby" itself, rubygems "gem", and the rubygems
1897
+ # installation directory.
1898
+ # ========================================================================= #
1899
+ def consider_adding_the_ruby_components
1900
+ if @show_ruby_version_and_gem_version
1901
+ add(
1902
+ return_all_ruby_components # Combine three calls into one here - all related to ruby.
1903
+ )
1904
+ end
1905
+ end
1906
+
1907
+ # ========================================================================= #
1908
+ # === do_not_show_the_ruby_components
1909
+ # ========================================================================= #
1910
+ def do_not_show_the_ruby_components
1911
+ @show_ruby_version_and_gem_version = false
1912
+ end; alias do_not_display_the_ruby_components do_not_show_the_ruby_components # === do_not_display_the_ruby_components
1913
+
1914
+ # ========================================================================= #
1915
+ # === return_version_of_rubygems?
1916
+ # ========================================================================= #
1917
+ def return_version_of_rubygems?
1918
+ ::EnvironmentInformation.send(__method__)
1919
+ end; alias return_version_of_rubygems return_version_of_rubygems? # == return_version_of_rubygems
1920
+
1921
+ # ========================================================================= #
1922
+ # === return_version_of_ruby?
1923
+ # ========================================================================= #
1924
+ def return_version_of_ruby?
1925
+ ::EnvironmentInformation.send(__method__)
1926
+ end; alias return_version_of_ruby return_version_of_ruby? # == return_version_of_ruby
1927
+
1928
+ require 'environment_information/misc_components/rubygems_installation_directory.rb'
1929
+ # ========================================================================= #
1930
+ # === rubygems_installation_directory?
1931
+ # ========================================================================= #
1932
+ def rubygems_installation_directory?
1933
+ ::EnvironmentInformation.rubygems_installation_directory?
1934
+ end
1935
+
1936
+ # ========================================================================= #
1937
+ # === run (run tag)
1938
+ # ========================================================================= #
1939
+ def run
1940
+ # ======================================================================= #
1941
+ # Try to rename the KDE konsole first. This will happen on
1942
+ # roebe-systems only.
1943
+ # ======================================================================= #
1944
+ do_rename_kde_konsole
1945
+ # ======================================================================= #
1946
+ # ^^^ This check happens here again because menu() is allowed to
1947
+ # toggle this variable.
1948
+ # ======================================================================= #
1949
+ if @display_everything_in_short_format
1950
+ assign_components_for_the_short_format # Handle the short format here.
1951
+ end
1952
+ do_sort_alphabetically if sort_alphabetically? # ← Must come before the report-step.
1953
+ unless @do_exit_the_program
1954
+ # ===================================================================== #
1955
+ # === Report step
1956
+ #
1957
+ # We may only display the components if @display_result is true.
1958
+ # ===================================================================== #
1959
+ if @display_result
1960
+ register_the_available_components_and_show_them_at_once
1961
+ end
1962
+ end
1963
+ # ======================================================================= #
1964
+ # === Consider generating a .html file
1965
+ #
1966
+ # The user may want to generate a .html file, so the following
1967
+ # functionality allows the user to do so. This check should
1968
+ # ideally come before other local files are generated.
1969
+ # ======================================================================= #
1970
+ do_generate_a_html_file if @internal_hash[:generate_a_html_file]
1971
+ if commandline? and store_the_results_into_local_files?
1972
+ # ===================================================================== #
1973
+ # Only store local files if the variable
1974
+ # @store_the_results_into_local_files is true.
1975
+ # ===================================================================== #
1976
+ consider_storing_the_components_that_were_displayed
1977
+ consider_storing_which_programs_are_not_up_to_date
1978
+ end
1979
+ end; alias feedback_everything run # === feedback_everything
1980
+ alias do_feedback_everything run # === do_feedback_everything
1981
+ alias output run # === output
1982
+ alias feedback run # === feedback
1983
+
1984
+
1985
+ require 'environment_information/toplevel_methods/is_on_roebe.rb'
1986
+ require 'environment_information/toplevel_methods/return_alias_to.rb'
1987
+ begin
1988
+ require 'rbt/requires/swift_version.rb'
1989
+ rescue LoadError
1990
+ if ::EnvironmentInformation.is_on_roebe?
1991
+ puts 'The file rbt/toplevel_methods/swift_return_version_of_this_program.rb is not available.'
1992
+ end
1993
+ end
1994
+
1995
+ begin
1996
+ require 'rbt/toplevel_methods/url.rb'
1997
+ rescue LoadError
1998
+ if ::EnvironmentInformation.is_on_roebe?
1999
+ puts 'The file rbt/toplevel_methods/url.rb is not available.'
2000
+ end
2001
+ end
2002
+
2003
+ # ========================================================================= #
2004
+ # === show_help?
2005
+ # ========================================================================= #
2006
+ def show_help?
2007
+ @show_help
2008
+ end
2009
+
2010
+ # ========================================================================= #
2011
+ # === compare_via_gem_version
2012
+ # ========================================================================= #
2013
+ def compare_via_gem_version(i)
2014
+ begin
2015
+ Gem::Version.new(i)
2016
+ rescue ArgumentError => error
2017
+ e Colours.tomato(error)
2018
+ e 'We will continue nonetheless ('+i+')'
2019
+ return nil
2020
+ end
2021
+ end
2022
+
2023
+ require 'environment_information/toplevel_methods/e.rb'
2024
+ # ========================================================================= #
2025
+ # === e (e tag)
2026
+ #
2027
+ # The e() method is the general output-method for this class.
2028
+ # ========================================================================= #
2029
+ def e(i = '')
2030
+ unless @be_silent
2031
+ if use_one_line_to_show_the_result? # This will just use "print".
2032
+ ::EnvironmentInformation.ee(i)
2033
+ else
2034
+ ::EnvironmentInformation.e(
2035
+ i, display_everything_in_short_format: @display_everything_in_short_format
2036
+ )
2037
+ end
2038
+ end
2039
+ end
2040
+
2041
+ # ========================================================================= #
2042
+ # === do_report_the_remote_urls
2043
+ #
2044
+ # Enable the reporting of the remote URLs, if available.
2045
+ # ========================================================================= #
2046
+ def do_report_the_remote_urls
2047
+ @internal_hash[:report_the_remote_urls] = true
2048
+ end
2049
+
2050
+ # ========================================================================= #
2051
+ # === show_the_registered_components
2052
+ # ========================================================================= #
2053
+ def show_the_registered_components(
2054
+ i = tracked_programs?
2055
+ )
2056
+ e
2057
+ e 'The following programs will be tracked:'
2058
+ e
2059
+ use_one_line_to_show_the_result = use_one_line_to_show_the_result?
2060
+ i.each_with_index {|this_program, index| index += 1
2061
+ if use_one_line_to_show_the_result
2062
+ padded_index = index.to_s+') '
2063
+ else
2064
+ padded_index = ' '+(index.to_s+') ').rjust(5)
2065
+ end
2066
+ colourized_and_padded_index = seagreen(padded_index)
2067
+ e colourized_and_padded_index+
2068
+ steelblue(this_program)
2069
+ }
2070
+ e
2071
+ end
2072
+
2073
+ # ========================================================================= #
2074
+ # === report_version
2075
+ # ========================================================================= #
2076
+ def report_version
2077
+ require 'environment_information/toplevel_methods/menu.rb'
2078
+ ::EnvironmentInformation.report_version
2079
+ @do_exit_the_program = true
2080
+ end
2081
+
2082
+ # ========================================================================= #
2083
+ # === display_these_components?
2084
+ #
2085
+ # Note that @display_these_components is a Hash.
2086
+ # ========================================================================= #
2087
+ def display_these_components?
2088
+ @array_report_these_programs
2089
+ end; alias components? display_these_components? # === components?
2090
+ alias main_dataset? display_these_components? # === main_dataset?
2091
+ alias main_entry? display_these_components? # === main_entry?
2092
+ alias dataset? display_these_components? # === dataset?
2093
+ alias result display_these_components? # === result
2094
+ alias result? display_these_components? # === result?
2095
+ alias display_which_components? display_these_components? # === display_which_components?
2096
+ alias array_obtain_these_programs? display_these_components? # === array_obtain_these_programs?
2097
+ alias array_with_entries? display_these_components? # === array_with_entries?
2098
+ alias main_array? display_these_components? # === main_array?
2099
+ alias programs? display_these_components? # === programs?
2100
+ alias show_these_components? display_these_components? # === show_these_components?
2101
+
2102
+ # ========================================================================= #
2103
+ # === main_hash?
2104
+ # ========================================================================= #
2105
+ def main_hash?
2106
+ ::EnvironmentInformation.hash?
2107
+ end
2108
+
2109
+ # ========================================================================= #
2110
+ # === register_the_available_components_and_show_them_at_once (report tag)
2111
+ #
2112
+ # This method can be used to register information about the various
2113
+ # components. It will also instantly display the component at
2114
+ # hand, to avoid "lagging" behaviour on the commandline.
2115
+ # ========================================================================= #
2116
+ def register_the_available_components_and_show_them_at_once(
2117
+ report_these_programs = @array_report_these_programs
2118
+ )
2119
+ if report_these_programs.empty?
2120
+ opn; e 'There are no components that can be displayed.' # And this ends here.
2121
+ else
2122
+ # ===================================================================== #
2123
+ # Always clear the main Array before proceeding here.
2124
+ # ===================================================================== #
2125
+ clear_missing_components
2126
+ toplevel_hash = ::EnvironmentInformation.hash?
2127
+ hash_use_this_for_the_query = ::EnvironmentInformation.all_the_queries
2128
+ # ===================================================================== #
2129
+ # Iterate over the registered programs next.
2130
+ # ===================================================================== #
2131
+ report_these_programs.each {|this_program|
2132
+ # =================================================================== #
2133
+ # First, determine the left_side and the right_side.
2134
+ # =================================================================== #
2135
+ left_side = this_program.to_s.dup
2136
+ right_side = nil
2137
+ case this_program
2138
+ # =================================================================== #
2139
+ # === RAM
2140
+ # =================================================================== #
2141
+ when :ram,
2142
+ /^RAM$/i
2143
+ right_side = ram?.to_s.dup
2144
+ right_side = right_side.dup if right_side.frozen?
2145
+ # ================================================================= #
2146
+ # Append 'MB RAM' in orange colour next, with some padding.
2147
+ # This is just a small visual "enhancement" that I quite like.
2148
+ # ================================================================= #
2149
+ right_side << orange(' MB RAM')
2150
+ # =================================================================== #
2151
+ # === Rubygems installation directory
2152
+ # =================================================================== #
2153
+ when :rubygems_installation_directory,
2154
+ /^rubygems( |_)?installation( |_)?directory\??$/i
2155
+ right_side = rubygems_installation_directory?
2156
+ # =================================================================== #
2157
+ # === cflags
2158
+ # =================================================================== #
2159
+ when :cflags,
2160
+ /^cflags$/i,
2161
+ /^cflags(_|-| )?in(_|-| )?use$/i
2162
+ right_side = cflags_in_use?
2163
+ # =================================================================== #
2164
+ # === Screen resolution
2165
+ #
2166
+ # This is a bit "special" in the sense that we will colourize
2167
+ # the middle 'x', if found, and if colours are used.
2168
+ # =================================================================== #
2169
+ when :screen_resolution,
2170
+ /^screen( |_)?resolution$/i
2171
+ right_side = screen_resolution?
2172
+ if right_side.include?('x') and use_colours?
2173
+ splitted = right_side.split('x')
2174
+ right_side = colourize_this_in_the_right_side_colour(splitted.first)+
2175
+ royalblue('x')+
2176
+ colourize_this_in_the_right_side_colour(splitted.last)
2177
+ end
2178
+ # =================================================================== #
2179
+ # === CPU Model
2180
+ # =================================================================== #
2181
+ when /^cpuinfo$/i,
2182
+ /^CPU(_|-| )?Model/
2183
+ right_side = cpu_model?
2184
+ # =================================================================== #
2185
+ # === Operating system bit type
2186
+ # =================================================================== #
2187
+ when /^operating(_|-| )?system(_|-| )?bit(_|-| )?type$/i
2188
+ right_side = bit_type?
2189
+ # =================================================================== #
2190
+ # === Operating system
2191
+ # =================================================================== #
2192
+ when /^Operating(_|-| )?system$/i,
2193
+ :operating_system
2194
+ right_side = ::EnvironmentInformation.operating_system
2195
+ end
2196
+ # =================================================================== #
2197
+ # Find the corresponding entry next while including aliases:
2198
+ # =================================================================== #
2199
+ this_program = this_program.to_sym # These are stored as symbol.
2200
+ this_program = ::EnvironmentInformation.return_alias_to(this_program)
2201
+ _ = hash_use_this_for_the_query[this_program]
2202
+ if hash_use_this_for_the_query.has_key? this_program
2203
+ if _.to_s.start_with? 'pkg'
2204
+ # =============================================================== #
2205
+ # === :pkgconfig
2206
+ #
2207
+ # This is by far the simplest solution.
2208
+ # =============================================================== #
2209
+ right_side = @pkg_config_query.return_version_of(this_program)
2210
+ add_this_to_the_toplevel_hash(left_side, right_side)
2211
+ # ================================================================= #
2212
+ # === :version
2213
+ #
2214
+ # Here we will handle simple versions, e. g. "lftp --version"
2215
+ # entries, and similar.
2216
+ # ================================================================= #
2217
+ elsif _ == :version
2218
+ right_side = @simple_version_query.return_version_of(this_program)
2219
+ add_this_to_the_toplevel_hash(left_side, right_side)
2220
+ else
2221
+ # =============================================================== #
2222
+ # Else we will pass through class ComplexVersion:
2223
+ # =============================================================== #
2224
+ right_side = @complex_version_query.return_version_of(this_program)
2225
+ add_this_to_the_toplevel_hash(left_side, right_side)
2226
+ end
2227
+ # =================================================================== #
2228
+ # The next clause has been written specifically to allow querying
2229
+ # the mate-desktop components.
2230
+ # =================================================================== #
2231
+ elsif toplevel_hash.has_key?(this_program) and
2232
+ toplevel_hash[this_program] # ← This is thus non-nil.
2233
+ right_side = toplevel_hash[this_program]
2234
+ end
2235
+ if right_side.nil?
2236
+ register_unavailable_program(this_program)
2237
+ end
2238
+ # =================================================================== #
2239
+ # === @internal_hash[:report_the_remote_urls]
2240
+ #
2241
+ # Next, honour @internal_hash[:report_the_remote_urls] if it is
2242
+ # set to true.
2243
+ # =================================================================== #
2244
+ if report_the_remote_urls? and
2245
+ is_rbt_available? and
2246
+ RBT.respond_to?(:remote_url_for?)
2247
+ version = ''.dup
2248
+ _ = this_program.to_s.delete('-').downcase.strip.to_sym
2249
+ if RBT.does_include?(_)
2250
+ remote_url = RBT.remote_url_for?(_, :return_as_string)
2251
+ if is_a_registered_component? _
2252
+ if version.frozen?
2253
+ version = version.dup
2254
+ end
2255
+ version << lightgreen(remote_url)
2256
+ if right_side # We can only continue if the program is available.
2257
+ # In theory we could show the URL anyway, but for the time
2258
+ # being, at the least, we will not show the URL.
2259
+ right_side = right_side.dup if right_side.frozen?
2260
+ right_side << " #{olive('→')} #{version}"
2261
+ end
2262
+ end
2263
+ end
2264
+ end
2265
+ # =================================================================== #
2266
+ # The next method is defined in base.rb.
2267
+ # =================================================================== #
2268
+ report_left_right(
2269
+ left_side,
2270
+ right_side,
2271
+ :default_colour,
2272
+ :default_colour,
2273
+ :default_colour,
2274
+ !use_one_line_to_show_the_result?
2275
+ )
2276
+ # =================================================================== #
2277
+ # Next compare the program versions with the local versions.
2278
+ # =================================================================== #
2279
+ if compare_program_versions? and
2280
+ is_rbt_available_and_may_we_try_to_use_rbt? and
2281
+ RBT.respond_to?(:swift_return_version_of_this_program) and
2282
+ RBT.does_include?(left_side.to_s.strip)
2283
+ # ================================================================= #
2284
+ # Example:
2285
+ #
2286
+ # RBT.swift_return_version_of_this_program(:gettext)
2287
+ #
2288
+ # ================================================================= #
2289
+ registered_local_version = RBT.swift_return_version_of_this_program(
2290
+ left_side.to_s.strip.to_sym
2291
+ ).to_s
2292
+ # ================================================================= #
2293
+ # We ignore gtk2 when it comes to the version-check.
2294
+ # ================================================================= #
2295
+ next if this_program == :gtk2
2296
+ # ================================================================= #
2297
+ # Next use Gem::Version to compare them, but not if the version
2298
+ # is nil.
2299
+ # ================================================================= #
2300
+ unless right_side.nil?
2301
+ # =============================================================== #
2302
+ # The .delete('v') is specifically for libuv or node.
2303
+ # =============================================================== #
2304
+ registered_local_version = registered_local_version.to_s.
2305
+ delete('v').
2306
+ tr('_','.')
2307
+ a = compare_via_gem_version(registered_local_version)
2308
+ b = compare_via_gem_version(right_side)
2309
+ if a and b and (a > b)
2310
+ result = ''.dup
2311
+ if use_one_line_to_show_the_result?
2312
+ result << mediumaquamarine(' ← ')
2313
+ else # else this is the default.
2314
+ result << lightblue(' ^^^^ ')
2315
+ end
2316
+ result << slateblue('This program could be '\
2317
+ 'upgraded, to the version ')+
2318
+ steelblue(registered_local_version)
2319
+ e result
2320
+ end if registered_local_version =~ /\d+/
2321
+ end
2322
+ end
2323
+ }
2324
+ end
2325
+ end; alias display register_the_available_components_and_show_them_at_once # === display
2326
+ alias report_result register_the_available_components_and_show_them_at_once # === report_result
2327
+ alias display_the_components register_the_available_components_and_show_them_at_once # === display_the_components
2328
+ alias display_the_dataset register_the_available_components_and_show_them_at_once # === display_the_dataset
2329
+ alias work_through_the_programs register_the_available_components_and_show_them_at_once # === work_through_the_programs
2330
+ alias build_up_the_main_string register_the_available_components_and_show_them_at_once # === build_up_the_main_string
2331
+ alias display_the_main_components register_the_available_components_and_show_them_at_once # === build_up_the_main_string
2332
+ alias report register_the_available_components_and_show_them_at_once # === report
2333
+
2334
+ # ========================================================================= #
2335
+ # === menu (menu tag)
2336
+ #
2337
+ # This method constitutes the "menu" interface for class
2338
+ # EnvironmentInformation. It usually deals with the
2339
+ # commandline-given arguments stored in ARGV.
2340
+ # ========================================================================= #
2341
+ def menu(
2342
+ i = @commandline_arguments
2343
+ )
2344
+ if i.is_a? Array
2345
+ i.each {|entry| menu(entry) }
2346
+ else
2347
+ case i # case tag
2348
+ # ===================================================================== #
2349
+ # === envi --really-all
2350
+ #
2351
+ # This entry point is for really showing everything.
2352
+ # ===================================================================== #
2353
+ when /^-?-?REALLY(_|-)?ALL$/i,
2354
+ /^-?-?compare(_|-)?program(_|-)?version$/i,
2355
+ /^-?-?compare(_|-)?to(_|-)?program(_|-)?versions$/i,
2356
+ /^-?-?do(_|-)?compare(_|-)?program(_|-)?version$/i,
2357
+ /^-?-?really(_|-)?everything$/i # === envi --really-everything
2358
+ clear_old_dataset
2359
+ add_default_linux_programs
2360
+ add_ruby_and_rubygems
2361
+ do_show_almost_everything_excluding_the_default_linux_programs
2362
+ do_compare_the_program_version
2363
+ # ===================================================================== #
2364
+ # === envi --one-liner
2365
+ #
2366
+ # A more complex usage example may be this:
2367
+ #
2368
+ # envi --rall --oneliner
2369
+ #
2370
+ # ===================================================================== #
2371
+ when /^-?-?one(-|_)?liner$/i # === envi --oneliner
2372
+ @internal_hash[:use_one_line_to_show_the_result] = true # This is different to the short-format.
2373
+ # ===================================================================== #
2374
+ # === envi --short
2375
+ # ===================================================================== #
2376
+ when /^-?-?short$/i,
2377
+ /^-?-?display(-|_)?short(-|_)?format$/i,
2378
+ /^-?-?do(-|_)?display(-|_)?in(-|_)?a(-|_)?short(-|_)?format$/i
2379
+ do_display_in_a_short_format
2380
+ # ===================================================================== #
2381
+ # === envi --sort-alphabetically
2382
+ #
2383
+ # This entry point can also be combined, such as in:
2384
+ #
2385
+ # envi --show-everything --sort-alphabetically
2386
+ #
2387
+ # ===================================================================== #
2388
+ when /^-?-?sort(-|_)?alphabetically$/i,
2389
+ /^-?-?sort$/i,
2390
+ /^-?-?alphabetically$/i,
2391
+ /^-?-?alphabet$/i
2392
+ enable_sort_alphabetically
2393
+ # ===================================================================== #
2394
+ # === envi --use-colours?
2395
+ # ===================================================================== #
2396
+ when /^-?-?use(-|_)?colou?rs\??$/i
2397
+ e 'Will colours be used? '+
2398
+ ::EnvironmentInformation.verbose_truth(
2399
+ ::EnvironmentInformation.use_colours?.to_s
2400
+ )
2401
+ do_not_run
2402
+ @do_exit_the_program = true
2403
+ # ===================================================================== #
2404
+ # === :do_show_everything
2405
+ #
2406
+ # An alternative way to make use of this entry point is via:
2407
+ #
2408
+ # envi --do-show-everything
2409
+ # envi --show-everything
2410
+ # envi --all
2411
+ #
2412
+ # ===================================================================== #
2413
+ when :do_show_everything,
2414
+ :show_really_everything,
2415
+ /^-?-?do(_|-)?show(_|-)?everything$/i,
2416
+ /^-?-?show(-|_)?everything$/i,
2417
+ /^-?-?show(-|_)?full(-|_)?information$/i,
2418
+ /^-?-?everything$/i,
2419
+ /^-?-?rall$/i,
2420
+ /^-?-?ALL$/i
2421
+ do_show_everything
2422
+ @run_already = true
2423
+ # ===================================================================== #
2424
+ # === envi --kdeversions?
2425
+ #
2426
+ # Note that this variant depends on another gem, called "rbt", and
2427
+ # the associated RBT namespace.
2428
+ # ===================================================================== #
2429
+ when /^-?-?kde(_|-)?versions\??$/i,
2430
+ /^-?-?kde\??$/i
2431
+ report_the_installed_KDE_software_suite
2432
+ # ===================================================================== #
2433
+ # === envi --registered-components?
2434
+ # ===================================================================== #
2435
+ when /^-?-?registered(_|-)?components\??$/i,
2436
+ /^-?-?available\??$/i
2437
+ do_not_run_already
2438
+ show_the_registered_components
2439
+ @do_exit_the_program = true
2440
+ # ===================================================================== #
2441
+ # === envi --additional=php
2442
+ #
2443
+ # This entry point allows us to show additional programs.
2444
+ #
2445
+ # Another usage example:
2446
+ #
2447
+ # envi --additional=php,python,perl
2448
+ #
2449
+ # ===================================================================== #
2450
+ when /^-?-?additional=(.+)$/i,
2451
+ /^-?-?add=(.+)$/i
2452
+ _ = $1.to_s.dup
2453
+ add(_)
2454
+ # ===================================================================== #
2455
+ # === envi --n_entries?
2456
+ # ===================================================================== #
2457
+ when /^-?-?n(_|-)?entries\??$/i,
2458
+ /^-?-?n(_|-)?programs\??$/i # envi --nprograms?
2459
+ show_n_registered_entries # === envi --n_entries
2460
+ @do_exit_the_program = true
2461
+ # ===================================================================== #
2462
+ # === envi --use-these-programs=bash,binutils,bison,yacc,bzip2,coreutils,diff,find,gawk,gcc,grep,gzip,linux,make,m4,patch,perl,python,sed,tar,makeinfo,xz
2463
+ # === envi --use-these-programs=:lfs
2464
+ #
2465
+ # This entry point can be used to display a certain subset of
2466
+ # programs, at the user's discretion.
2467
+ # ===================================================================== #
2468
+ when /^-?-?use(-|_)?these(-|_)?programs=(.+)$/i # === $3
2469
+ # =================================================================== #
2470
+ # First clear (aka reset) the main dataset.
2471
+ # =================================================================== #
2472
+ clear_old_dataset
2473
+ match = $3.to_s.dup
2474
+ add(match)
2475
+ # ===================================================================== #
2476
+ # === envi --show-remote-url
2477
+ #
2478
+ # This entry point will also show the remote URL to the
2479
+ # program at hand.
2480
+ # ===================================================================== #
2481
+ when /^-?-?show(_|-)?remote(_|-)?url$/i
2482
+ do_report_the_remote_urls
2483
+ # ===================================================================== #
2484
+ # === envi --help
2485
+ #
2486
+ # This entry point will always show help-related information.
2487
+ # ===================================================================== #
2488
+ when /^-?-?help$/i
2489
+ do_show_help
2490
+ # ===================================================================== #
2491
+ # === envi --no-save
2492
+ #
2493
+ # Skip saving into a local file through this entry point.
2494
+ #
2495
+ # Invocation example:
2496
+ #
2497
+ # envi --lfs --no-save
2498
+ #
2499
+ # ===================================================================== #
2500
+ when /^-?-?no(_|-)?save$/i
2501
+ do_not_save_anything
2502
+ # ===================================================================== #
2503
+ # === envi --os?
2504
+ # ===================================================================== #
2505
+ when /^-?-?OS\??$/i,
2506
+ /^-?-?show(-|_)?only(-|_)?the(-|_)?operating(-|_)?system$/i
2507
+ do_show_only_the_operating_system
2508
+ show_no_ruby
2509
+ # ===================================================================== #
2510
+ # === envi --help
2511
+ # ===================================================================== #
2512
+ when /help/i
2513
+ @show_help = true
2514
+ # ===================================================================== #
2515
+ # === envi --clear
2516
+ #
2517
+ # This entry point will simply clear the old dataset.
2518
+ #
2519
+ # This can be used to only display a few components, such as:
2520
+ #
2521
+ # envi --clear --python --ruby --perl
2522
+ #
2523
+ # ===================================================================== #
2524
+ when /^-?-?clear$/i,
2525
+ /^-?-?clear(_|-)?old(_|-)?dataset$/i
2526
+ clear_old_dataset
2527
+ # ===================================================================== #
2528
+ # === envi --sinatra
2529
+ # ===================================================================== #
2530
+ when /^-?-?sinatra$/i,
2531
+ /^-?-?www$/i
2532
+ start_the_sinatra_interface
2533
+ # ===================================================================== #
2534
+ # === envi --open
2535
+ # ===================================================================== #
2536
+ when /^-?-?open$/i,
2537
+ /^-?-?edit$/i
2538
+ open_this_file_in_editor
2539
+ # ===================================================================== #
2540
+ # === envi --lfs
2541
+ # ===================================================================== #
2542
+ when /^-?-?lfs$/i,
2543
+ /^-?-?lfs(_|-)?core(_|-)?programs$/i
2544
+ clear_old_dataset
2545
+ add(:lfs_core_programs)
2546
+ # ===================================================================== #
2547
+ # === envi openssl
2548
+ # ===================================================================== #
2549
+ when /^-?-?openssl$/,
2550
+ 'ssl'
2551
+ add(:openssl)
2552
+ # ===================================================================== #
2553
+ # === envi --science
2554
+ # ===================================================================== #
2555
+ when /^-?-?science$/
2556
+ clear_old_dataset
2557
+ add(:science_cluster)
2558
+ # ===================================================================== #
2559
+ # === envi --nocolours
2560
+ #
2561
+ # This entry point can be used to disable usage of colours.
2562
+ # ===================================================================== #
2563
+ when /^-?-?nocolours/,'2',
2564
+ /^-?-?no(-|_)?colou?rs$/i,
2565
+ /^-?-?nocol$/i,
2566
+ /^-?-?disable(-|_)?colou?rs$/i, # === envi --really-all --disable-colours
2567
+ :disable_colours
2568
+ disable_colours
2569
+ # ===================================================================== #
2570
+ # === envi --version
2571
+ # ===================================================================== #
2572
+ when *ARRAY_VERSION
2573
+ report_version
2574
+ # ===================================================================== #
2575
+ # === envi --gui
2576
+ # ===================================================================== #
2577
+ when /^-?-?gui$/i,
2578
+ /^-?-?gtk$/i,
2579
+ /^-?-?start(-|_)?gtk$/i
2580
+ start_gtk_component
2581
+ # ===================================================================== #
2582
+ # === envi --replay
2583
+ # ===================================================================== #
2584
+ when /^-?-?replay$/i
2585
+ require 'environment_information/toplevel_methods/replay_from_the_stored_file.rb'
2586
+ ::EnvironmentInformation.replay_from_the_stored_file
2587
+ # ===================================================================== #
2588
+ # === envi --be_silent_no_colours
2589
+ #
2590
+ # Not sure why the following entry point exists, but I will retain it
2591
+ # for the time being.
2592
+ # ===================================================================== #
2593
+ when /^-?-?be(_|-)?silent(_|-)?no(_|-)?colours$/
2594
+ disable_colours
2595
+ do_not_display_the_result
2596
+ do_show_everything
2597
+ # ===================================================================== #
2598
+ # This entry point is mostly for internal use, e. g. to pass
2599
+ # in Symbols to menu().
2600
+ # ===================================================================== #
2601
+ when :be_silent_no_colours_everything,
2602
+ :be_silent_and_no_colours,
2603
+ :be_silent_no_colours,
2604
+ :full_be_silent
2605
+ disable_colours
2606
+ do_show_everything
2607
+ do_not_display_the_result
2608
+ # ===================================================================== #
2609
+ # === envi --be_silent
2610
+ # ===================================================================== #
2611
+ when /^-?-?be(_|-)?silent$/i # === envi --be-silent
2612
+ do_not_display_the_result
2613
+ do_show_everything
2614
+ # ===================================================================== #
2615
+ # === envi --work-on-programs-directory-only
2616
+ # ===================================================================== #
2617
+ when /^-?-?work(-|_)?on(-|_)?programs(-|_)?directory(-|_)?only$/i,
2618
+ /^-?-?work(-|_)?on(-|_)?the(-|_)?programs(-|_)?directory(-|_)?only$/i
2619
+ work_on_the_programs_directory_only
2620
+ # ===================================================================== #
2621
+ # === envi --do-save
2622
+ # ===================================================================== #
2623
+ when /^save$/i,
2624
+ /^-?-?do(_|-)?save$/i
2625
+ @store_the_results_into_local_files = true
2626
+ # ===================================================================== #
2627
+ # === envi --asciitable
2628
+ # ===================================================================== #
2629
+ when /^-?-?asciitable$/i,
2630
+ 'table','1'
2631
+ use_ascii_table if ASCIITABLE_IS_AVAILABLE
2632
+ # ===================================================================== #
2633
+ # === envi --read-from-this-file=/Depot/j/display_these_programs.md
2634
+ # === envi --file=/Depot/j/display_these_programs.md
2635
+ # === envi --input-from=/Depot/j/display_these_programs.md
2636
+ # ===================================================================== #
2637
+ when /^-?-?read(-|_)?from(-|_)?this(-|_)?file=(.+)$/i, # <- And this has $4
2638
+ /^-?-?file=(.+)$/i, # <- This has only $1
2639
+ /^-?-?input(-|_)?from=(.+)$/i # <- This has $2
2640
+ _ = $1.to_s.dup
2641
+ _ = $2.to_s.dup if $2
2642
+ _ = $4.to_s.dup if $4
2643
+ clear_old_dataset
2644
+ set_use_this_as_main_input(
2645
+ load_dataset_from_this_file(_)
2646
+ )
2647
+ # ===================================================================== #
2648
+ # === envi --no-yaml-file
2649
+ # ===================================================================== #
2650
+ when /^-?-?no(-|_)?yaml(-|_)?file$/i,
2651
+ /^-?-?no(-|_)?local(-|_)?file$/i
2652
+ @store_the_results_into_local_files = false
2653
+ # ===================================================================== #
2654
+ # === envi noruby
2655
+ # ===================================================================== #
2656
+ when /^-?-?noruby$/i,
2657
+ 'show_no_ruby',
2658
+ 'classic',
2659
+ 'naked',
2660
+ '3',
2661
+ 'minimal'
2662
+ show_no_ruby
2663
+ # ===================================================================== #
2664
+ # === envi --show-all
2665
+ # ===================================================================== #
2666
+ when /^-?-?show(-|_)?all$/i,
2667
+ /^-?-?all$/i,
2668
+ /^-?-?full$/i,
2669
+ /^-?-?everything$/i, # === envi --everything
2670
+ /^-?-?information$/i,
2671
+ 'f',
2672
+ '4'
2673
+ do_show_everything # <- Just to be sure.
2674
+ # ===================================================================== #
2675
+ # === :be_silent
2676
+ # ===================================================================== #
2677
+ when /^-?-?be(_|-)?silent$/i,
2678
+ :be_silent # We will be silent, but we will still show everything.
2679
+ do_not_display_the_result
2680
+ do_show_everything
2681
+ # ===================================================================== #
2682
+ # === envi --compare_programs
2683
+ #
2684
+ # This entry point allows us to compare the program versions with
2685
+ # the one registered in RBT.
2686
+ # ===================================================================== #
2687
+ when *ARRAY_COMPARE_PROGRAM_VERSIONS
2688
+ do_compare_the_program_version
2689
+ # ===================================================================== #
2690
+ # === envi --generate-html-file
2691
+ #
2692
+ # This entry point can be used to generate a local .html file.
2693
+ # ===================================================================== #
2694
+ when /^-?-?generate(-|_)?html(-|_)?file$/i,
2695
+ /^-?-?html$/i # envi --HTML
2696
+ @internal_hash[:generate_a_html_file] = true
2697
+ set_runmode_html # Set it here again, just in case.
2698
+ do_show_everything
2699
+ # ===================================================================== #
2700
+ # === envi --show-components?
2701
+ # ===================================================================== #
2702
+ when /^-?-?show(-|_)?components\??$/i
2703
+ e "#{true_rev}The following components will be shown on a default run:"
2704
+ e
2705
+ show_these_components?.each {|this_component|
2706
+ if this_component.is_a? Array
2707
+ this_component = this_component.first
2708
+ end
2709
+ e " - #{steelblue(this_component)}#{true_rev}"
2710
+ }
2711
+ e
2712
+ exit
2713
+ # ===================================================================== #
2714
+ # === :do_not_run_yet
2715
+ #
2716
+ # Invocation example:
2717
+ #
2718
+ # envi --do-not-run-yet
2719
+ #
2720
+ # ===================================================================== #
2721
+ when /^-?-?-do(-|_)?not(-|_)?run(-|_)?yet$/i, # === envi --do-not-run-yet
2722
+ :do_not_run_yet,
2723
+ :dont_run_yet,
2724
+ :default # This is the default variant.
2725
+ @run_already = false
2726
+ # ===================================================================== #
2727
+ # === envi --pkgconfig
2728
+ #
2729
+ # Show all pkgconfig entries - but only these.
2730
+ # ===================================================================== #
2731
+ when /^-?-?pkg(-|_)?config$/i
2732
+ clear_old_dataset
2733
+ add(:pkgconfig_entries)
2734
+ # ===================================================================== #
2735
+ # === envi --xorg-components
2736
+ #
2737
+ # This entry point is for when the user only wants to show the
2738
+ # xorg-components on the local computer system.
2739
+ # ===================================================================== #
2740
+ when /^-?-?xorg(_|-)?components$/i,
2741
+ /^-?-?xorg$/i,
2742
+ /^-?-?show(_|-)?xorg(_|-)?components$/i
2743
+ do_show_only_the_xorg_components
2744
+ else # else tag
2745
+ # =================================================================== #
2746
+ # It is better to report that the given commandline-input as
2747
+ # not found, so this will be reported. Before we can do so, we
2748
+ # will first check whether the user wanted to pass some
2749
+ # existing/registered component nonetheless.
2750
+ #
2751
+ # This clause can be checked via something like this:
2752
+ #
2753
+ # envi --bash
2754
+ # envi --brotli
2755
+ #
2756
+ # =================================================================== #
2757
+ if is_a_registered_component?(i.delete('-'))
2758
+ # ================================================================= #
2759
+ # The next line has been added in August 2022. Not sure if we
2760
+ # retain it or not - either way the future will show.
2761
+ # ================================================================= #
2762
+ @array_report_these_programs.clear # Clear the old result first.
2763
+ do_not_store_anything
2764
+ add(
2765
+ i.delete('-')
2766
+ )
2767
+ else
2768
+ # ================================================================= #
2769
+ # Only enter the report-section if we do NOT want to exit early.
2770
+ # ================================================================= #
2771
+ do_show_help if show_help?
2772
+ # Or:
2773
+ # e 'Unhandled command input (in file environment_information/class/menu.rb): '
2774
+ # e
2775
+ # e " #{sfancy(i)}"
2776
+ # e
2777
+ end
2778
+ end
2779
+ end
2780
+ end
2781
+
2782
+ # ========================================================================= #
2783
+ # === use_one_line_to_show_the_result?
2784
+ # ========================================================================= #
2785
+ def use_one_line_to_show_the_result?
2786
+ @internal_hash[:use_one_line_to_show_the_result]
2787
+ end
2788
+
2789
+ # ========================================================================= #
2790
+ # === EnvironmentInformation::EnvironmentInformation[]
2791
+ # ========================================================================= #
2792
+ def self.[](i = ARGV, &block)
2793
+ new(i, &block)
2794
+ end
2795
+
2796
+ end
2797
+
2798
+ # =========================================================================== #
2799
+ # === EnvironmentInformation.run
2800
+ # =========================================================================== #
2801
+ def self.run(i = ARGV)
2802
+ ::EnvironmentInformation::EnvironmentInformation.new(i)
2803
+ end
2804
+
2805
+ # =========================================================================== #
2806
+ # === EnvironmentInformation.run_the_main_class
2807
+ # =========================================================================== #
2808
+ def self.run_the_main_class(i = ARGV, &block)
2809
+ ::EnvironmentInformation::EnvironmentInformation.new(i, &block)
2810
+ end; self.instance_eval { alias result run_the_main_class } # === EnvironmentInformation.result
2811
+ self.instance_eval { alias show run_the_main_class } # === EnvironmentInformation.show
2812
+ self.instance_eval { alias new run_the_main_class } # === EnvironmentInformation.new
2813
+ self.instance_eval { alias [] run_the_main_class } # === EnvironmentInformation[]
2814
+
2815
+ # =========================================================================== #
2816
+ # === EnvironmentInformation.environment_information?
2817
+ #
2818
+ # This method will return a very long string containing all
2819
+ # information about the locally installed/available programs.
2820
+ # =========================================================================== #
2821
+ def self.environment_information?
2822
+ ::EnvironmentInformation::EnvironmentInformation.new(:full_be_silent).stringified
2823
+ end
2824
+
2825
+ end
2826
+
2827
+ if __FILE__ == $PROGRAM_NAME
2828
+ EnvironmentInformation::EnvironmentInformation.new(ARGV)
2829
+ end # environment_information.rb