environment_information 1.4.124

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