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,65 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/hash.rb'
6
+ # EnvironmentInformation.hash?
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'environment_information/toplevel_methods/register_this_component_is_missing.rb'
11
+
12
+ # ========================================================================= #
13
+ # === @hash_available_programs
14
+ #
15
+ # This hash stores the available programs.
16
+ #
17
+ # We need to use a Hash, rather than an Array, because we may save
18
+ # the result into a file, such as a yaml file. It is then more
19
+ # convenient to have the names of the program appear on the left
20
+ # side directoy, and the version on the right side.
21
+ #
22
+ # This Hash will hold the program name on the left side, and the
23
+ # program version on the right side. A nil value on the right
24
+ # side indicates that this program is NOT installed - which
25
+ # makes this the default value.
26
+ # ========================================================================= #
27
+ @hash_available_programs = {}
28
+
29
+ # ========================================================================= #
30
+ # === EnvironmentInformation.hash?
31
+ #
32
+ # This method will return the Hash of all available programs.
33
+ # ========================================================================= #
34
+ def self.hash?
35
+ @hash_available_programs
36
+ end; self.instance_eval { alias hash hash? } # === EnvironmentInformation.hash
37
+ self.instance_eval { alias dataset? hash? } # === EnvironmentInformation.dataset?
38
+
39
+ # ========================================================================= #
40
+ # === EnvironmentInformation.add_to_hash
41
+ # ========================================================================= #
42
+ def self.add_to_hash(a, b)
43
+ b.strip! if b.is_a? String
44
+ if b.nil?
45
+ ::EnvironmentInformation.register_this_component_is_missing(a)
46
+ end
47
+ @hash_available_programs[a] = b
48
+ end
49
+
50
+ # ========================================================================= #
51
+ # === EnvironmentInformation.clear_hash
52
+ #
53
+ # This method can be used to clear the main (toplevel) Hash.
54
+ # ========================================================================= #
55
+ def self.clear_hash
56
+ @hash_available_programs.clear
57
+ end; self.instance_eval { alias clear_toplevel_hash clear_hash } # === EnvironmentInformation.clear_toplevel_hash
58
+ self.instance_eval { alias clear_main_hash clear_hash } # === EnvironmentInformation.clear_main_hash
59
+
60
+ end
61
+
62
+
63
+ if __FILE__ == $PROGRAM_NAME
64
+ EnvironmentInformation.clear_hash
65
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/internet_is_available.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ # ========================================================================= #
10
+ # === EnvironmentInformation.internet_is_available?
11
+ # ========================================================================= #
12
+ def self.internet_is_available?
13
+ require 'resolv'
14
+ dns_resolver = Resolv::DNS.new
15
+ begin
16
+ # ===================================================================== #
17
+ # The first domain name ever. Will probably not be removed.
18
+ # ===================================================================== #
19
+ dns_resolver.getaddress('symbolics.com')
20
+ return true
21
+ rescue Resolv::ResolvError => _error
22
+ return false
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ if __FILE__ == $PROGRAM_NAME
29
+ puts EnvironmentInformation.internet_is_available?
30
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/is_on_roebe.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ # ========================================================================= #
10
+ # === EnvironmentInformation.is_on_roebe?
11
+ # ========================================================================= #
12
+ def self.is_on_roebe?
13
+ ENV['IS_ROEBE'].to_i == 1
14
+ end
15
+
16
+ end
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/menu.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ require 'environment_information/toplevel_methods/e.rb'
10
+ require 'environment_information/version/version.rb'
11
+ require 'environment_information/colours/colours.rb'
12
+ require 'environment_information/colours/simp.rb'
13
+ require 'environment_information/constants/regex.rb'
14
+
15
+ # ========================================================================= #
16
+ # === EnvironmentInformation.menu
17
+ # ========================================================================= #
18
+ def self.menu(
19
+ i = ARGV
20
+ )
21
+ if i.is_a? Array
22
+ i.each {|entry| menu(entry) }
23
+ else
24
+ case i # case tag
25
+ # ===================================================================== #
26
+ # === envi --replay
27
+ #
28
+ # The replay-functionality can be used to display information
29
+ # quickly, by reading the dataset from a local file.
30
+ # ===================================================================== #
31
+ when /^-?-?replay$/i
32
+ require 'environment_information/toplevel_methods/replay_from_the_stored_file.rb'
33
+ replay_from_the_stored_file
34
+ # ===================================================================== #
35
+ # === envi --version?
36
+ # ===================================================================== #
37
+ when *ARRAY_VERSION
38
+ report_version
39
+ # ===================================================================== #
40
+ # === envi --compare
41
+ # ===================================================================== #
42
+ when *ARRAY_COMPARE_PROGRAM_VERSIONS
43
+ require 'environment_information/toplevel_methods/show_all_available_components.rb'
44
+ ::EnvironmentInformation.show_all_available_components(
45
+ ['--compare-program-versions']
46
+ )
47
+ # ===================================================================== #
48
+ # === envi --gui
49
+ # ===================================================================== #
50
+ when /^-?-?gui$/i,
51
+ /^-?-?gtk$/i,
52
+ /^-?-?start(-|_)?gtk$/i
53
+ start_gtk_component
54
+ else
55
+ require 'environment_information/toplevel_methods/misc.rb'
56
+ EnvironmentInformation.test
57
+ end
58
+ end
59
+ end
60
+
61
+ # ========================================================================= #
62
+ # === EnvironmentInformation.report_version
63
+ # ========================================================================= #
64
+ def self.report_version
65
+ e "#{rev}The version of the EnvironmentInformation project "\
66
+ "in use is: #{simp(VERSION)}#{rev}"
67
+ end
68
+
69
+ # ========================================================================= #
70
+ # === EnvironmentInformation.start_gtk_component
71
+ #
72
+ # We have to rescue the code so to notify the user what exactly
73
+ # may have failed.
74
+ # ========================================================================= #
75
+ def self.start_gtk_component
76
+ begin
77
+ this_file = 'environment_information/gui/gtk3/environment_information.rb'
78
+ require this_file
79
+ rescue LoadError => error
80
+ e "An error happened - file #{sfile(this_file)} could not be found."
81
+ pp error
82
+ end
83
+ ::EnvironmentInformation.run_gtk
84
+ end
85
+
86
+ end
87
+
88
+ if __FILE__ == $PROGRAM_NAME
89
+ EnvironmentInformation.menu(ARGV)
90
+ end # rb menu.rb --version
@@ -0,0 +1,324 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/misc.rb'
6
+ # EnvironmentInformation.return_version_of_mpc
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'environment_information/constants/file_constants.rb'
11
+ require 'environment_information/constants/misc.rb'
12
+
13
+ # ========================================================================= #
14
+ # === Environment.verbose_truth
15
+ # ========================================================================= #
16
+ def self.verbose_truth(i)
17
+ case i
18
+ when /true/
19
+ 'Yes.'
20
+ when /false/
21
+ 'No.'
22
+ end
23
+ end
24
+
25
+ # ========================================================================= #
26
+ # === Environment.silent_run
27
+ # ========================================================================= #
28
+ def self.silent_run(
29
+ array_load_these_files = [
30
+ FILE_ARRAY_TRACKED_NON_PROGRAMS,
31
+ FILE_ARRAY_TRACKED_PROGRAMS,
32
+ FILE_ARRAY_TRACKED_XORG_COMPONENTS,
33
+ FILE_ARRAY_SCIENCE_CLUSTER
34
+ ]
35
+ )
36
+ @hash_available_programs = {} # Clear it every time this method is run.
37
+ work_on_these_programs = []
38
+ array_load_these_files.each {|this_entry|
39
+ work_on_these_programs << YAML.load_file(this_entry)
40
+ }
41
+ work_on_these_programs.flatten.each {|this_program|
42
+ version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
43
+ if version_of_this_program
44
+ version_of_this_program = version_of_this_program.to_s
45
+ end
46
+ @hash_available_programs[this_program] = version_of_this_program
47
+ }
48
+ consider_storing_these_results_into_a_local_file(false)
49
+ return @hash_available_programs
50
+ end; self.instance_eval { alias build_up_and_return_the_main_hash silent_run } # === EnvironmentInformation.build_up_and_return_the_main_hash
51
+ self.instance_eval { alias initialize_hash silent_run } # === EnvironmentInformation.initialize_hash
52
+ self.instance_eval { alias initialize silent_run } # === EnvironmentInformation.initialize
53
+ self.instance_eval { alias run silent_run } # === EnvironmentInformation.run
54
+
55
+ # ========================================================================= #
56
+ # === EnvironmentInformation.consider_storing_these_results_into_a_local_file
57
+ #
58
+ # This method will always take the dataset stored in the main Hash when
59
+ # saving the yaml file at hand.
60
+ # ========================================================================= #
61
+ def self.consider_storing_these_results_into_a_local_file(
62
+ be_verbose = true
63
+ )
64
+ unless @hash_available_programs.empty?
65
+ what = YAML.dump(@hash_available_programs)
66
+ # ===================================================================== #
67
+ # The file will be stored under the temp_directory.
68
+ # ===================================================================== #
69
+ into = ::EnvironmentInformation.return_path_to_the_all_programs_file
70
+ e "#{rev}Storing these #{royalblue(@hash_available_programs.size)} "\
71
+ "#{rev}components into: #{sfile(into)}" if be_verbose
72
+ write_what_into(what, into)
73
+ end
74
+ end; self.instance_eval { alias store_relevant_files consider_storing_these_results_into_a_local_file } # === EnvironmentInformation.store_relevant_files
75
+
76
+ # ========================================================================= #
77
+ # === EnvironmentInformation.show_detailed_information_about_all_available_components
78
+ #
79
+ # This method is mostly for testing purposes only; for real use
80
+ # for the project you should consider making use of
81
+ # Environment.silent_run instead.
82
+ #
83
+ # Do note that this method will always show all available components;
84
+ # if you need more fine-tuned control then you have to use the
85
+ # class EnvironmentInformation instead.
86
+ # ========================================================================= #
87
+ def self.show_detailed_information_about_all_available_components
88
+ @hash_available_programs = {} # Clear it every time this method is run.
89
+ work_on_these_programs = []
90
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_NON_PROGRAMS)
91
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_PROGRAMS)
92
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_XORG_COMPONENTS)
93
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_SCIENCE_CLUSTER)
94
+ work_on_these_programs.flatten!
95
+ work_on_these_programs.uniq!
96
+ e
97
+ work_on_these_programs.each {|this_program|
98
+ version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
99
+ # ===================================================================== #
100
+ # Do a little sanitizing next:
101
+ # ===================================================================== #
102
+ case this_program.to_s
103
+ when 'kde_frameworks'
104
+ this_program = 'KDE Frameworks'.to_sym
105
+ end
106
+ left_side = colourize_and_pad_the_left_side(this_program)
107
+ case version_of_this_program
108
+ when COMMAND_NOT_FOUND,
109
+ ''
110
+ version_of_this_program = nil
111
+ colour_for_the_right_side = :orange
112
+ else
113
+ colour_for_the_right_side = :notify_if_missing
114
+ end
115
+ # ===================================================================== #
116
+ # Next register this program into the main hash.
117
+ # ===================================================================== #
118
+ @hash_available_programs[this_program] = version_of_this_program
119
+ right_side = colourize_and_pad_the_right_side(
120
+ version_of_this_program,
121
+ colour_for_the_right_side
122
+ )
123
+ e " #{left_side} #{right_side}"
124
+ }
125
+ e
126
+ # ======================================================================= #
127
+ # Report missing programs.
128
+ # ======================================================================= #
129
+ _ = missing_components?
130
+ unless _.empty?
131
+ e 'The following components were not found:'
132
+ e
133
+ _.each {|this_component|
134
+ e lightseagreen(" #{this_component}")
135
+ }
136
+ e
137
+ end
138
+ consider_storing_these_results_into_a_local_file
139
+ end; self.instance_eval { alias test show_detailed_information_about_all_available_components } # === EnvironmentInformation.test
140
+
141
+ # ========================================================================= #
142
+ # === EnvironmentInformation.return_version_of_xrandr
143
+ # ========================================================================= #
144
+ def self.return_version_of_xrandr
145
+ _ = `xrandr --version #{ERROR_LINE}` # Need to use ERROR_LINE to avoid the code breaking down here.
146
+ if _
147
+ version = _.strip.split("\n")
148
+ if version.is_a?(Array)
149
+ version = version.first.split(' ').last.strip # Assume: "xrandr program version 1.5.1"
150
+ return version
151
+ end
152
+ end
153
+ return nil
154
+ end
155
+
156
+ # ========================================================================= #
157
+ # === EnvironmentInformation.return_version_of_xvid
158
+ # ========================================================================= #
159
+ def self.return_version_of_xvid(
160
+ target_file = '/usr/include/xvid.h'
161
+ )
162
+ if File.exist?('/System/Index/include/'+File.basename(target_file)) and
163
+ !File.exist?(target_file) # Custom fix.
164
+ target_file = '/System/Index/include/'+File.basename(target_file)
165
+ end
166
+ if File.exist? target_file
167
+ dataset = File.readlines(target_file)
168
+ version = dataset.select {|line|
169
+ line.include? ' XVID_MAKE_VERSION(' # #define XVID_VERSION XVID_MAKE_VERSION(1,3,7)
170
+ }
171
+ if version.is_a? Array
172
+ version = version.flatten.first.to_s
173
+ end
174
+ version = version.scan( # See: https://rubular.com/r/4anuroBmb40yzh
175
+ /XVID_MAKE_VERSION\((\d{0,1},\d{0,1},\d{0,1})/
176
+
177
+ )
178
+ if version.is_a? Array
179
+ version = version.flatten.first.to_s
180
+ end
181
+ version.tr!(',','.')
182
+ else
183
+ version = nil
184
+ end
185
+ return version
186
+ end
187
+
188
+ # ========================================================================= #
189
+ # === EnvironmentInformation.return_version_of_busybox
190
+ # ========================================================================= #
191
+ def self.return_version_of_busybox
192
+ result = `busybox #{ERROR_LINE}`
193
+ if result and result.is_a?(String) and result.include?("\n")
194
+ first_line = result.split("\n").first
195
+ if first_line.include? ' v'
196
+ # "BusyBox v1.32.0 (2020-11-08 04:41:56 Etc) multi-call binary.\n"
197
+ use_this_regex = /v(\d{0,1}.\d{0,2}.\d{0,1})/ # See: https://rubular.com/r/MpnFXlalLCXXGI
198
+ result = first_line.scan(use_this_regex).flatten.first.to_s
199
+ return result
200
+ end
201
+ end
202
+ return nil
203
+ end
204
+
205
+ # ========================================================================= #
206
+ # === EnvironmentInformation.return_version_of_boost
207
+ #
208
+ # This method will either return a String (the version of boost),
209
+ # or nil if boost was not found.
210
+ # ========================================================================= #
211
+ def self.return_version_of_boost
212
+ target_file = '/usr/include/boost/version.hpp'
213
+ if File.exist?('/System/Index/include/boost/version.hpp') and
214
+ !File.exist?(target_file) # Custom fix.
215
+ target_file = '/System/Index/include/boost/version.hpp'
216
+ end
217
+ if File.exist? target_file
218
+ dataset = File.readlines(target_file)
219
+ version = dataset.select {|line|
220
+ line.include? '#define BOOST_LIB_VERSION'
221
+ }.first.sub(/#define BOOST_LIB_VERSION/,'').
222
+ strip.delete('"').tr('_','.')
223
+ if version.count('.') < 2
224
+ version << '.0'
225
+ end
226
+ else
227
+ version = nil
228
+ end
229
+ return version
230
+ end
231
+
232
+ # ========================================================================= #
233
+ # === EnvironmentInformation.return_version_of_mpc
234
+ #
235
+ # This method will read the version-string from a .h header file.
236
+ # ========================================================================= #
237
+ def self.return_version_of_mpc
238
+ target_file = '/usr/include/mpc.h'
239
+ if File.exist? target_file
240
+ dataset = File.read(target_file)
241
+ use_this_regex = /MPC_VERSION_STRING "([0-9\.]+)"$/
242
+ dataset = dataset.scan(use_this_regex).flatten
243
+ version = dataset.first
244
+ return version
245
+ else
246
+ return THE_PROGRAM_WAS_NOT_FOUND
247
+ end
248
+ end
249
+
250
+ # ========================================================================= #
251
+ # === EnvironmentInformation.return_array_of_outdated_programs
252
+ #
253
+ # This method will return all programs that are outdated - this
254
+ # also includes missing programs, so the method name is a slight
255
+ # misnomer.
256
+ #
257
+ # Usage example:
258
+ #
259
+ # EnvironmentInformation.initialize
260
+ # array = EnvironmentInformation.return_array_of_outdated_programs
261
+ #
262
+ # ========================================================================= #
263
+ def self.return_array_of_outdated_programs(
264
+ hash = ::EnvironmentInformation.hash?
265
+ )
266
+ forbidden = ::EnvironmentInformation.load_file_array_tracked_non_programs
267
+ # ======================================================================= #
268
+ # Now find all entries that are either nil, or have a too low program
269
+ # version.
270
+ # ======================================================================= #
271
+ array = hash.select {|key, value|
272
+ if value and forbidden.include?(key) # ← we exclude entries here such as "rubygems_installation_dir".
273
+ false
274
+ else
275
+ if value.nil? or value.include?('not found') or
276
+ !(value =~ /\d+/) # ← check for at the least one number, such as "1".
277
+ true
278
+ else
279
+ false
280
+ end
281
+ end
282
+ }.keys
283
+ # ======================================================================= #
284
+ # Next, check these against the local program version:
285
+ # local_program_version = key
286
+ # ======================================================================= #
287
+ return array
288
+ end
289
+
290
+ # ========================================================================= #
291
+ # === EnvironmentInformation.return_the_most_important_info
292
+ #
293
+ # This method will just return a String that can be used right away
294
+ # in, for example, a sinatra application.
295
+ # ========================================================================= #
296
+ def self.return_the_most_important_info
297
+ 'Operating system: '+
298
+ ::EnvironmentInformation.operating_system+'<br>'+
299
+ 'Operating system bit type: '+
300
+ ::EnvironmentInformation.operating_system_bit_type+'<br>'+
301
+ 'CPU model: '+
302
+ ::EnvironmentInformation.cpu_model+'<br>'
303
+ end
304
+
305
+ # ========================================================================= #
306
+ # === EnvironmentInformation.return_everything
307
+ # ========================================================================= #
308
+ def self.return_everything
309
+ require 'environment_information/class/class.rb'
310
+ _ = ::EnvironmentInformation::EnvironmentInformation.new(:do_not_run_yet)
311
+ _.disable_colours
312
+ _.be_quiet
313
+ _.menu('--really-everything')
314
+ _.run
315
+ return _.string
316
+ end
317
+
318
+ end
319
+
320
+ if __FILE__ == $PROGRAM_NAME
321
+ puts EnvironmentInformation.return_version_of_mpc
322
+ puts EnvironmentInformation.return_version_of_boost
323
+ EnvironmentInformation.test
324
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/n_subcommands.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ require 'environment_information/constants/array_tracked_components.rb'
10
+
11
+ # ========================================================================= #
12
+ # === EnvironmentInformation.n_subcommands?
13
+ #
14
+ # Return how many subcommands are available/registered. These are
15
+ # the tracked programs; and the xorg-components.
16
+ #
17
+ # The non-programs will not be gathered by this method, on purpose; they
18
+ # are not standalone programs after all.
19
+ #
20
+ # As of August 2020, 167 programs were tracked by this gem.
21
+ # ========================================================================= #
22
+ def self.n_subcommands?
23
+ ARRAY_TRACKED_PROGRAMS.size+
24
+ ARRAY_XORG_COMPONENTS.size
25
+ end
26
+
27
+ end
28
+
29
+ if __FILE__ == $PROGRAM_NAME
30
+ pp EnvironmentInformation.n_subcommands?
31
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/prefix_to_use.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ # ========================================================================= #
10
+ # === @prefix_to_use
11
+ #
12
+ # This variable can be used to designate another base directory to
13
+ # be used, such as at /home/Programs/. This allows us to scan
14
+ # through an AppDir and output the programs found there.
15
+ #
16
+ # By default it must be an empty String, as many other files check
17
+ # on the content of this variable - so only change it if you really
18
+ # need to use another prefix to use.
19
+ #
20
+ # The functionality was specifically added to support versioned
21
+ # AppDirs on a given computer system.
22
+ # ========================================================================= #
23
+ @prefix_to_use = ''.dup
24
+
25
+ # ========================================================================= #
26
+ # === EnvironmentInformation.set_prefix_to_use
27
+ # ========================================================================= #
28
+ def self.set_prefix_to_use(i)
29
+ @prefix_to_use = i.to_s.dup
30
+ end; self.instance_eval { alias set_prefix set_prefix_to_use } # === EnvironmentInformation.set_prefix
31
+
32
+ # ========================================================================= #
33
+ # === EnvironmentInformation.prefix?
34
+ # ========================================================================= #
35
+ def self.prefix?
36
+ @prefix_to_use
37
+ end
38
+
39
+ end
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/register_this_component_is_missing.rb'
6
+ # EnvironmentInformation.register_this_component_is_missing
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ # ========================================================================= #
11
+ # === @array_this_component_is_missing
12
+ #
13
+ # This Array keeps track of all components that are missing on the
14
+ # given system.
15
+ # ========================================================================= #
16
+ @array_this_component_is_missing = []
17
+
18
+ # ========================================================================= #
19
+ # === EnvironmentInformation.which_components_are_missing?
20
+ # ========================================================================= #
21
+ def self.which_components_are_missing?
22
+ @array_this_component_is_missing
23
+ end; self.instance_eval { alias missing_components? which_components_are_missing? } # === EnvironmentInformation.missing_components?
24
+
25
+ # ========================================================================= #
26
+ # === EnvironmentInformation.clear_missing_components
27
+ # ========================================================================= #
28
+ def self.clear_missing_components
29
+ @array_this_component_is_missing.clear
30
+ end
31
+
32
+ # ========================================================================= #
33
+ # === EnvironmentInformation.register_this_component_is_missing
34
+ #
35
+ # The ideal input to this method is a Symbol, so that the Array
36
+ # stores only missing components that way.
37
+ # ========================================================================= #
38
+ def self.register_this_component_is_missing(i)
39
+ if i.is_a? Symbol
40
+ copy = i.to_s
41
+ if copy.include?('_')
42
+ i = copy.split('_').last.to_sym
43
+ end
44
+ end
45
+ i = i.to_sym unless i.is_a? Symbol
46
+ # ======================================================================= #
47
+ # Do not register the same missing component twice:
48
+ # ======================================================================= #
49
+ unless @array_this_component_is_missing.include? i
50
+ @array_this_component_is_missing << i
51
+ end
52
+ end
53
+
54
+ # ========================================================================= #
55
+ # === EnvironmentInformation.is_this_component_missing?
56
+ # ========================================================================= #
57
+ def self.is_this_component_missing?(i)
58
+ !@array_this_component_is_missing.include?(i)
59
+ end
60
+
61
+ end