environment_information 1.4.29

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

Potentially problematic release.


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

Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1061 -0
  3. data/bin/envi +7 -0
  4. data/bin/fast_envi +7 -0
  5. data/doc/README.gen +893 -0
  6. data/doc/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +54 -0
  7. data/environment_information.gemspec +130 -0
  8. data/lib/environment_information/base/base.rb +113 -0
  9. data/lib/environment_information/class/add.rb +186 -0
  10. data/lib/environment_information/class/colours.rb +283 -0
  11. data/lib/environment_information/class/constants.rb +35 -0
  12. data/lib/environment_information/class/environment_information.rb +51 -0
  13. data/lib/environment_information/class/help.rb +86 -0
  14. data/lib/environment_information/class/html.rb +78 -0
  15. data/lib/environment_information/class/initialize.rb +178 -0
  16. data/lib/environment_information/class/menu.rb +436 -0
  17. data/lib/environment_information/class/misc.rb +821 -0
  18. data/lib/environment_information/class/opn.rb +33 -0
  19. data/lib/environment_information/class/register_sigint.rb +20 -0
  20. data/lib/environment_information/class/reset.rb +213 -0
  21. data/lib/environment_information/class/ruby.rb +79 -0
  22. data/lib/environment_information/class/run.rb +61 -0
  23. data/lib/environment_information/class/show_display_and_report.rb +310 -0
  24. data/lib/environment_information/colours/colours.rb +150 -0
  25. data/lib/environment_information/colours/sfancy.rb +19 -0
  26. data/lib/environment_information/colours/simp.rb +19 -0
  27. data/lib/environment_information/constants/array_tracked_components.rb +207 -0
  28. data/lib/environment_information/constants/constants.rb +17 -0
  29. data/lib/environment_information/constants/encoding.rb +21 -0
  30. data/lib/environment_information/constants/error_line.rb +17 -0
  31. data/lib/environment_information/constants/file_constants.rb +102 -0
  32. data/lib/environment_information/constants/misc.rb +86 -0
  33. data/lib/environment_information/constants/namespace.rb +14 -0
  34. data/lib/environment_information/constants/newline.rb +16 -0
  35. data/lib/environment_information/constants/regex.rb +30 -0
  36. data/lib/environment_information/constants/temp_directory.rb +52 -0
  37. data/lib/environment_information/gui/gtk/bindings.rb +300 -0
  38. data/lib/environment_information/misc_components/README.md +3 -0
  39. data/lib/environment_information/misc_components/cflags.rb +36 -0
  40. data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
  41. data/lib/environment_information/misc_components/operating_system.rb +54 -0
  42. data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
  43. data/lib/environment_information/misc_components/ram.rb +30 -0
  44. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
  45. data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
  46. data/lib/environment_information/project/project.rb +27 -0
  47. data/lib/environment_information/queries/README.md +2 -0
  48. data/lib/environment_information/queries/complex_version.rb +263 -0
  49. data/lib/environment_information/queries/pkg_config.rb +125 -0
  50. data/lib/environment_information/queries/simple_version.rb +211 -0
  51. data/lib/environment_information/requires/require_asciitable.rb +15 -0
  52. data/lib/environment_information/requires/require_the_constants.rb +7 -0
  53. data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
  54. data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
  55. data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
  56. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +152 -0
  57. data/lib/environment_information/toplevel_methods/cd.rb +16 -0
  58. data/lib/environment_information/toplevel_methods/e.rb +30 -0
  59. data/lib/environment_information/toplevel_methods/hash.rb +60 -0
  60. data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
  61. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
  62. data/lib/environment_information/toplevel_methods/menu.rb +90 -0
  63. data/lib/environment_information/toplevel_methods/misc.rb +264 -0
  64. data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
  65. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
  66. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
  67. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
  68. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
  69. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
  70. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
  71. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
  72. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +186 -0
  73. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
  74. data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
  75. data/lib/environment_information/version/version.rb +25 -0
  76. data/lib/environment_information/www/sinatra_interface.rb +213 -0
  77. data/lib/environment_information/www/webobject_interface.cgi +29 -0
  78. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +14 -0
  79. data/lib/environment_information/yaml/array_lfs_core_programs.yml +35 -0
  80. data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
  81. data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
  82. data/lib/environment_information/yaml/array_tracked_programs.yml +165 -0
  83. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +34 -0
  84. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +215 -0
  85. data/lib/environment_information.rb +5 -0
  86. data/test/testing_environment_information.rb +26 -0
  87. data/test/testing_missing_components.rb +9 -0
  88. data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
  89. metadata +195 -0
@@ -0,0 +1,263 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::Queries::ComplexVersion
6
+ #
7
+ # This class will try to do a query based on more complex means.
8
+ # =========================================================================== #
9
+ # require 'environment_information/queries/simple_version.rb'
10
+ # EnvironmentInformation::Queries::ComplexVersion.new
11
+ # =========================================================================== #
12
+ require 'environment_information/base/base.rb'
13
+
14
+ module EnvironmentInformation
15
+
16
+ module Queries
17
+
18
+ class ComplexVersion < ::EnvironmentInformation::Base # === EnvironmentInformation::Queries::ComplexVersion
19
+
20
+ # ========================================================================= #
21
+ # === initialize
22
+ #
23
+ # The first argument is mandatory.
24
+ # ========================================================================= #
25
+ def initialize(
26
+ for_this_program = nil,
27
+ run_already = true
28
+ )
29
+ reset
30
+ set_program_name(
31
+ for_this_program
32
+ )
33
+ # ======================================================================= #
34
+ # === Handle blocks given next
35
+ # ======================================================================= #
36
+ if block_given?
37
+ yielded = yield
38
+ if yielded.is_a? Hash
39
+ if yielded.has_key? :prefix_to_use
40
+ @prefix_to_use << yielded.delete(:prefix_to_use)
41
+ end
42
+ end
43
+ end
44
+ run if run_already
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === reset
49
+ # ========================================================================= #
50
+ def reset
51
+ # ======================================================================= #
52
+ # === @program_name
53
+ # ======================================================================= #
54
+ @program_name = ''.dup
55
+ # ======================================================================= #
56
+ # === @program_version
57
+ # ======================================================================= #
58
+ @program_version = nil
59
+ # ======================================================================= #
60
+ # === @prefix_to_use
61
+ # ======================================================================= #
62
+ @prefix_to_use = ''.dup
63
+ end
64
+
65
+ # ========================================================================= #
66
+ # === set_program_name
67
+ # ========================================================================= #
68
+ def set_program_name(i)
69
+ @program_name = i.to_sym if i
70
+ end
71
+
72
+ # ========================================================================= #
73
+ # === program_name?
74
+ # ========================================================================= #
75
+ def program_name?
76
+ @program_name
77
+ end
78
+
79
+ # ========================================================================= #
80
+ # === program_version?
81
+ # ========================================================================= #
82
+ def program_version?
83
+ @program_version
84
+ end; alias version? program_version? # === version?
85
+
86
+ # ========================================================================= #
87
+ # === return_version_of
88
+ # ========================================================================= #
89
+ def return_version_of(this_program = @program_name)
90
+ _ = ::EnvironmentInformation.query_to_use_for_the_individual_components?
91
+ if _.nil?
92
+ _ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components
93
+ end
94
+ if _.has_key?(this_program)
95
+ cmd_to_run = _[this_program]
96
+ case cmd_to_run
97
+ # ===================================================================== #
98
+ # === :custom_busybox
99
+ # ===================================================================== #
100
+ when :custom_busybox
101
+ @program_version = ::EnvironmentInformation.return_version_of_busybox
102
+ # ===================================================================== #
103
+ # === :custom_xvid
104
+ # ===================================================================== #
105
+ when :custom_xvid
106
+ @program_version = ::EnvironmentInformation.return_version_of_xvid
107
+ # ===================================================================== #
108
+ # === :custom_boost
109
+ # ===================================================================== #
110
+ when :custom_boost
111
+ @program_version = ::EnvironmentInformation.return_version_of_boost
112
+ # ===================================================================== #
113
+ # === :custom_mpc
114
+ # ===================================================================== #
115
+ when :custom_mpc
116
+ @program_version = ::EnvironmentInformation.return_version_of_mpc
117
+ else
118
+ result = `#{@prefix_to_use}#{cmd_to_run} #{ERROR_LINE}`.to_s.strip.dup
119
+ if result.include? ' #' # Handle "uname -a" aka Linux darkstar.example.net 5.4.50 #1 SMP
120
+ result = result.split(' #').first.strip
121
+ end
122
+ @program_version = result
123
+ end
124
+ return nil if @program_version.nil?
125
+ if @program_version.include? '# HMMER ' # <- Specifically for "hammer".
126
+ @program_version = @program_version.scan(
127
+ /# HMMER (\d{0,2}\.\d{0,2}\.\d{0,2})/
128
+ ).flatten.first.to_s
129
+ end
130
+ if @program_version.include? 'extracts blocks from damag' # bzip2recover
131
+ @program_version = @program_version.scan(
132
+ /bzip2recover (\d{0,2}\.\d{0,2}\.\d{0,2}): extracts blocks from damaged .bz2 files/
133
+ ).flatten.first.to_s.dup
134
+ end
135
+ # ===================================================================== #
136
+ # === Handle Imagemagick: 'Version: ImageMagick 7.0.10-28'
137
+ # ===================================================================== #
138
+ if @program_version.include? 'Version: ImageMagick '
139
+ @program_version = @program_version.scan(
140
+ /Version: ImageMagick (\d{0,2}\.\d{0,2}\.\d{0,2}-\d{0,2})/
141
+ ).flatten.first.to_s.tr('-','.')
142
+ end
143
+ # ===================================================================== #
144
+ # === Handle 'KDE Frameworks: 5.73.0'
145
+ # ===================================================================== #
146
+ if @program_version.include? 'KDE Frameworks: '
147
+ @program_version = @program_version.scan(
148
+ /KDE Frameworks: (\d{0,2}\.\d{0,2}\.\d{0,2})/
149
+ ).flatten.first.to_s
150
+ end
151
+ # ===================================================================== #
152
+ # === Handle 'ncurses 6.2.20200212' aka ncurses
153
+ # ===================================================================== #
154
+ if @program_version.include? 'ncurses '
155
+ @program_version = @program_version.scan(
156
+ /ncurses (\d{1,1}\.\d{1,1})/
157
+ ).flatten.first.to_s
158
+ end
159
+ # ===================================================================== #
160
+ # === Handle ruby 'ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]'
161
+ # ===================================================================== #
162
+ if @program_version.include? 'ruby '
163
+ @program_version = @program_version.scan(
164
+ /^ruby (\d{1,1}\.\d{1,1}\.\d{1,1})/
165
+ ).flatten.first.to_s
166
+ end
167
+ # ===================================================================== #
168
+ # === Handle patchelf '0.12.20200827.8d3a16e'
169
+ # ===================================================================== #
170
+ if @program_version.include? 'patchelf '
171
+ @program_version = @program_version.scan(
172
+ /^patchelf (\d{1,1}\.\d{1,2})/
173
+ ).flatten.first.to_s
174
+ end
175
+ # ===================================================================== #
176
+ # We have to be careful with the next, as a few programs report the
177
+ # version on the second line, not on the first.
178
+ # ===================================================================== #
179
+ if @program_version.include? N
180
+ @program_version = @program_version.split(N).first.strip
181
+ end
182
+ # ===================================================================== #
183
+ # Next handle cases such as the following two examples:
184
+ #
185
+ # "ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers"
186
+ # "openjdk version \"14.0.2\" 2020-07-14"
187
+ #
188
+ # ===================================================================== #
189
+ if @program_version.include? ' version '
190
+ @program_version = @program_version.scan(
191
+ / version "?(\d{0,2}\.\d{1,2}\.?\d{0,2})"?/
192
+ ).flatten.first.to_s.strip
193
+ end
194
+ # ===================================================================== #
195
+ # Handle cases such as: "nginx/1.18.0"
196
+ # ===================================================================== #
197
+ if @program_version.include? '/'
198
+ @program_version = @program_version.split('/').last.strip
199
+ end
200
+ if @program_version.include?('(') and # Specifically for XTERM.
201
+ @program_version.include?(')')
202
+ @program_version = @program_version.split('(').last.to_s.delete(')') # 7.7.0(359)
203
+ end
204
+ if @program_version.include? '-'
205
+ # Specifically to fix relion: "3.1.0-commit-GITDIR"
206
+ @program_version = @program_version.split('-').first.to_s.strip
207
+ end
208
+ if @program_version.include? COMMAND_NOT_FOUND
209
+ @program_version = nil
210
+ elsif @program_version.include? ' '
211
+ # =================================================================== #
212
+ # Assume input such as: "GNU ld (GNU Binutils) 2.35"
213
+ # =================================================================== #
214
+ @program_version = @program_version.split(' ').last
215
+ end
216
+ end
217
+ return @program_version
218
+ end
219
+
220
+ # ========================================================================= #
221
+ # === run
222
+ # ========================================================================= #
223
+ def run
224
+ return_version_of
225
+ end
226
+
227
+ end; end; end
228
+
229
+ if __FILE__ == $PROGRAM_NAME
230
+ array = %i(
231
+ mpc
232
+ gtk2
233
+ linux
234
+ binutils
235
+ boost
236
+ coreutils
237
+ diffutils
238
+ ffmpeg
239
+ findutils
240
+ java
241
+ imagemagick
242
+ kde_frameworks
243
+ llvm
244
+ ncurses
245
+ nginx
246
+ qt
247
+ rubygems
248
+ sharutils
249
+ sysstat
250
+ swig
251
+ texinfo
252
+ tmux
253
+ xfsprogs
254
+ xterm
255
+ hmmer
256
+ viennarna
257
+ xstdcmap
258
+ )
259
+ array.each {|entry|
260
+ _ = EnvironmentInformation::Queries::ComplexVersion.new(entry)
261
+ _.report_left_right
262
+ }
263
+ end # complexversion
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::Queries::PkgConfig
6
+ #
7
+ # This class will try to do a pkg-config query, based on a .yml file.
8
+ #
9
+ # As input it needs the name of the program at hand; and that program
10
+ # has to be registered in the .yml file. The query will then use
11
+ # "pkg-config", which in turn queries the local .pc file for the
12
+ # version.
13
+ # =========================================================================== #
14
+ # require 'environment_information/queries/pkg_config.rb'
15
+ # EnvironmentInformation::Queries::PkgConfig.new
16
+ # =========================================================================== #
17
+ require 'environment_information/base/base.rb'
18
+
19
+ module EnvironmentInformation
20
+
21
+ module Queries
22
+
23
+ class PkgConfig < ::EnvironmentInformation::Base # === EnvironmentInformation::Queries::PkgConfig
24
+
25
+ # ========================================================================= #
26
+ # === initialize
27
+ #
28
+ # The first argument is mandatory.
29
+ # ========================================================================= #
30
+ def initialize(
31
+ for_this_program = nil,
32
+ run_already = true
33
+ )
34
+ reset
35
+ set_program_name(for_this_program)
36
+ run if run_already
37
+ end
38
+
39
+ # ========================================================================= #
40
+ # === reset
41
+ # ========================================================================= #
42
+ def reset
43
+ # ======================================================================= #
44
+ # === @program_name
45
+ # ======================================================================= #
46
+ @program_name = ''.dup
47
+ # ======================================================================= #
48
+ # === @program_version
49
+ # ======================================================================= #
50
+ @program_version = nil
51
+ end
52
+
53
+ # ========================================================================= #
54
+ # === set_program_name
55
+ # ========================================================================= #
56
+ def set_program_name(i)
57
+ @program_name = i.to_sym if i
58
+ end
59
+
60
+ # ========================================================================= #
61
+ # === program_name?
62
+ # ========================================================================= #
63
+ def program_name?
64
+ @program_name
65
+ end
66
+
67
+ # ========================================================================= #
68
+ # === program_version?
69
+ # ========================================================================= #
70
+ def program_version?
71
+ @program_version
72
+ end; alias version? program_version? # === version?
73
+
74
+ # ========================================================================= #
75
+ # === run
76
+ # ========================================================================= #
77
+ def run
78
+ return_version_of
79
+ end
80
+
81
+ # ========================================================================= #
82
+ # === return_version_of
83
+ # ========================================================================= #
84
+ def return_version_of(this_program = @program_name)
85
+ _ = ::EnvironmentInformation.query_to_use_for_the_individual_components?
86
+ if _.nil?
87
+ _ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components
88
+ end
89
+ if _.has_key?(this_program)
90
+ result = _[this_program]
91
+ case result
92
+ when :pkgconfig
93
+ @program_version = `pkg-config --modversion #{this_program} #{ERROR_LINE}`.dup
94
+ else
95
+ @program_version = `#{result} #{ERROR_LINE}`.dup
96
+ end
97
+ if @program_version.include? NOT_FOUND_IN_PKG_CONFIG_SEARCH_PATH
98
+ @program_version = nil
99
+ end
100
+ else # We will try to run it anyway.
101
+ @program_version = `pkg-config --modversion #{this_program} #{ERROR_LINE}`.dup
102
+ end
103
+ @program_version.strip! if @program_version
104
+ return @program_version
105
+ end
106
+
107
+ end; end
108
+
109
+ # =========================================================================== #
110
+ # === EnvironmentInformation.query_pkgconfig_version_for
111
+ #
112
+ # This is a simpler toplevel-query, for .pc files in general.
113
+ # =========================================================================== #
114
+ def self.query_pkgconfig_version_for(i = :gtk2)
115
+ ::EnvironmentInformation::Queries::PkgConfig.new(i).version?
116
+ end
117
+
118
+ end
119
+
120
+ if __FILE__ == $PROGRAM_NAME
121
+ _ = EnvironmentInformation::Queries::PkgConfig.new(:webkit2gtk)
122
+ puts _.program_name?.to_s+': '+_.program_version?.to_s
123
+ _ = EnvironmentInformation::Queries::PkgConfig.new(:gjs)
124
+ puts _.program_name?.to_s+': '+_.program_version?.to_s
125
+ end
@@ -0,0 +1,211 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::Queries::SimpleVersion
6
+ #
7
+ # This class will try to do a query based on the main binary at hand.
8
+ #
9
+ # It is only a wrapper over "--version" and nothing else.
10
+ # =========================================================================== #
11
+ # require 'environment_information/queries/simple_version.rb'
12
+ # EnvironmentInformation::Queries::SimpleVersion.new
13
+ # =========================================================================== #
14
+ require 'environment_information/base/base.rb'
15
+
16
+ module EnvironmentInformation
17
+
18
+ module Queries
19
+
20
+ class SimpleVersion < ::EnvironmentInformation::Base # === EnvironmentInformation::Queries::SimpleVersion
21
+
22
+ # ========================================================================= #
23
+ # === initialize
24
+ #
25
+ # The first argument is mandatory.
26
+ # ========================================================================= #
27
+ def initialize(
28
+ for_this_program = nil,
29
+ run_already = true
30
+ )
31
+ reset
32
+ set_program_name(
33
+ for_this_program
34
+ )
35
+ # ======================================================================= #
36
+ # === Handle blocks given next
37
+ # ======================================================================= #
38
+ if block_given?
39
+ yielded = yield
40
+ if yielded.is_a? Hash
41
+ if yielded.has_key? :prefix_to_use
42
+ @prefix_to_use << yielded.delete(:prefix_to_use)
43
+ end
44
+ end
45
+ end
46
+ run if run_already
47
+ end
48
+
49
+ # ========================================================================= #
50
+ # === reset
51
+ # ========================================================================= #
52
+ def reset
53
+ # ======================================================================= #
54
+ # === @program_name
55
+ # ======================================================================= #
56
+ @program_name = ''.dup
57
+ # ======================================================================= #
58
+ # === @program_version
59
+ # ======================================================================= #
60
+ @program_version = nil
61
+ # ======================================================================= #
62
+ # === @prefix_to_use
63
+ # ======================================================================= #
64
+ @prefix_to_use = ''.dup
65
+ end
66
+
67
+ # ========================================================================= #
68
+ # === set_program_name
69
+ # ========================================================================= #
70
+ def set_program_name(i)
71
+ @program_name = i.to_sym if i
72
+ end
73
+
74
+ # ========================================================================= #
75
+ # === program_name?
76
+ # ========================================================================= #
77
+ def program_name?
78
+ @program_name
79
+ end
80
+
81
+ # ========================================================================= #
82
+ # === program_version?
83
+ # ========================================================================= #
84
+ def program_version?
85
+ @program_version
86
+ end; alias version? program_version? # === version?
87
+
88
+ # ========================================================================= #
89
+ # === run
90
+ # ========================================================================= #
91
+ def run
92
+ return_version_of
93
+ end
94
+
95
+ # ========================================================================= #
96
+ # === return_version_of
97
+ # ========================================================================= #
98
+ def return_version_of(this_program = @program_name)
99
+ _ = ::EnvironmentInformation.query_to_use_for_the_individual_components?
100
+ if _.nil?
101
+ _ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components
102
+ end
103
+ if _.has_key?(this_program)
104
+ result = _[this_program]
105
+ case result
106
+ when :version
107
+ @program_version = `#{@prefix_to_use}#{this_program} --version #{ERROR_LINE}`.strip
108
+ end
109
+ end
110
+ if @program_version
111
+ if @program_version.include? N
112
+ @program_version = @program_version.split(N).first
113
+ end
114
+ if @program_version.include? '--'
115
+ @program_version.gsub!(/--/,'') # For strace specifically.
116
+ end
117
+ # if @program_version.include? 'GNOME Document Viewer'
118
+ # @program_version.sub!(/GNOME Document Viewer/,'') # For evince specifically.
119
+ # end
120
+ if @program_version.include? 'GNU'
121
+ @program_version.gsub!(/GNU/,'')
122
+ end
123
+ if @program_version.include? ' built on linux-gnu.'
124
+ @program_version.gsub!(/ built on linux-gnu\./, '') # Fixing wget specifically.
125
+ end
126
+ if @program_version.include?('[') and @program_version.include?(']')
127
+ @program_version.gsub!(/\[.+\]/, '')
128
+ end
129
+ @program_version.strip!
130
+ if @program_version.start_with? "#{this_program} "
131
+ # For example: "ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]"
132
+ @program_version.sub!(/#{this_program} /, '')
133
+ elsif @program_version.start_with? "#{this_program.capitalize} "
134
+ # For example: "Wget 1.20.3 built on linux-gnu."
135
+ @program_version.sub!(/#{this_program.capitalize} /, '')
136
+ elsif @program_version.start_with? "#{this_program.upcase} "
137
+ # For example: "NASM version 2.15.04 compiled on Aug 27 2020"
138
+ @program_version.sub!(/#{this_program.upcase} /, '')
139
+ elsif @program_version.downcase.start_with? "#{this_program.downcase} "
140
+ # For example: "IceWM", has a unusual start.
141
+ @program_version.sub!(/#{this_program} /i, '')
142
+ elsif @program_version.start_with? 'Awk'
143
+ @program_version.sub!(/Awk /i, '') # Ad-hox fix here.
144
+ end
145
+ if @program_version.include? '- Vi IMproved '
146
+ @program_version.sub!(/- Vi IMproved /, '') # Fixing vim specifically.
147
+ end
148
+ if @program_version.include? '(v'
149
+ # This is specifically for perl:
150
+ # "This is perl 5, version 32, subversion 0 (v5.32.0) built for x86_64-linux-thread-multi"
151
+ @program_version = @program_version.scan(
152
+ /\(v(\d{0,2}\.?\d{0,2}\.\d{0,2})\)/
153
+ ).flatten.first.to_s.dup
154
+ end
155
+ # ===================================================================== #
156
+ # The next check for "Version" should come after we eliminated
157
+ # the leading program name.
158
+ # ===================================================================== #
159
+ if @program_version.include? 'Version '
160
+ @program_version = @program_version.scan(
161
+ /Version (\d{0,2}\.?\d{0,2}\.\d{0,2})/
162
+ ).flatten.first.to_s.dup
163
+ elsif @program_version.include? 'version '
164
+ # This here should work for most programs, save for perl.
165
+ @program_version = @program_version.scan(
166
+ /version (\d{0,2}\.?\d{0,2}\.\d{0,2})/
167
+ ).flatten.first.to_s.dup
168
+ end
169
+ if @program_version.include? 'patchlevel '
170
+ # Gnuplot has this specifically: "5.4 patchlevel 0"
171
+ @program_version = @program_version.split('patchlevel ').first.strip
172
+ end
173
+ # ===================================================================== #
174
+ # Next we kill everything inside (). This may sometimes be
175
+ # problematic, which is why this check comes quite late.
176
+ # ===================================================================== #
177
+ if @program_version.include?('(') and @program_version.include?(')')
178
+ @program_version.gsub!(/\(.+\)/, '')
179
+ end
180
+ # ===================================================================== #
181
+ # Handle: "IceWM 1.8.0, Copyright 1997-2003 Marko Macek, 2001 Mathias Hasselmann."
182
+ # ===================================================================== #
183
+ if @program_version.include?(',')
184
+ @program_version = @program_version.split(',').first
185
+ end
186
+ # ===================================================================== #
187
+ # Next, if a '-' is included, we split it and use the last part.
188
+ # This handles cases such as "valgrind-3.16.0".
189
+ # ===================================================================== #
190
+ if @program_version.include?('-')
191
+ @program_version = @program_version.split('-').last
192
+ end
193
+ # ===================================================================== #
194
+ # Last but not least, for "node" specifically.
195
+ # ===================================================================== #
196
+ if @program_version.start_with? 'v'
197
+ @program_version[0,1] = ''
198
+ end
199
+ if @program_version.include? COMMAND_NOT_FOUND
200
+ @program_version = nil
201
+ end
202
+ end
203
+ return @program_version
204
+ end
205
+
206
+ end; end; end
207
+
208
+ if __FILE__ == $PROGRAM_NAME
209
+ _ = EnvironmentInformation::Queries::SimpleVersion.new(:lftp)
210
+ _.report_left_right
211
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/requires/require_asciitable.rb'
6
+ # =========================================================================== #
7
+ begin
8
+ class EnvironmentInformation::EnvironmentInformation; end # Define a prototype here.
9
+ require 'ascii_paradise/requires/require_asciitable_namespace.rb'
10
+ EnvironmentInformation::ASCIITABLE_IS_AVAILABLE = true
11
+ rescue LoadError
12
+ # puts 'asciitable is not available, consider installing it.'
13
+ # puts 'We will, however, continue, as it is not a mandatory package.'
14
+ EnvironmentInformation::ASCIITABLE_IS_AVAILABLE = false
15
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/requires/require_the_constants.rb'
6
+ # =========================================================================== #
7
+ require 'environment_information/constants/constants.rb'
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/requires/require_the_environment_information_project.rb'
6
+ # =========================================================================== #
7
+ require 'environment_information/requires/require_the_constants.rb'
8
+ require 'environment_information/colours/sfancy.rb'
9
+ require 'environment_information/colours/simp.rb'
10
+ require 'environment_information/version/version.rb'
11
+ # =========================================================================== #
12
+ # Next, require the individual components:
13
+ # =========================================================================== #
14
+ require 'environment_information/requires/require_the_individual_misc_components.rb'
15
+ # =========================================================================== #
16
+ # Next, require the toplevel-methods of environment_information/:
17
+ # =========================================================================== #
18
+ require 'environment_information/requires/require_the_toplevel_methods.rb'
19
+ # =========================================================================== #
20
+ # And then we will require the main class of the environment information
21
+ # project:
22
+ # =========================================================================== #
23
+ require 'environment_information/class/environment_information.rb'
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/requires/require_the_individual_misc_components.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ require 'environment_information/constants/array_tracked_components.rb'
10
+
11
+ # ========================================================================= #
12
+ # === EnvironmentInformation.require_all_individual_misc_components
13
+ #
14
+ # This method can be used to load all the individual misc-components
15
+ # that are part of the EnvironmentInformation project.
16
+ # ========================================================================= #
17
+ def self.require_all_individual_misc_components
18
+
19
+ # ======================================================================= #
20
+ # Batch-require the components in the misc_components/ directory next:
21
+ # ======================================================================= #
22
+ tracked_non_programs?.each {|this_component|
23
+ require "environment_information/misc_components/#{this_component}.rb"
24
+ }
25
+
26
+ end
27
+
28
+ require_all_individual_misc_components
29
+
30
+ end