environment_information 1.4.99

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1287 -0
  3. data/bin/envi +7 -0
  4. data/bin/fast_envi +7 -0
  5. data/doc/README.gen +1044 -0
  6. data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +48 -0
  7. data/environment_information.gemspec +135 -0
  8. data/lib/environment_information/base/base.rb +166 -0
  9. data/lib/environment_information/class/class.rb +2829 -0
  10. data/lib/environment_information/colours/colours.rb +224 -0
  11. data/lib/environment_information/colours/sfancy.rb +19 -0
  12. data/lib/environment_information/colours/simp.rb +19 -0
  13. data/lib/environment_information/constants/array_tracked_components.rb +210 -0
  14. data/lib/environment_information/constants/constants.rb +17 -0
  15. data/lib/environment_information/constants/encoding.rb +21 -0
  16. data/lib/environment_information/constants/error_line.rb +17 -0
  17. data/lib/environment_information/constants/file_constants.rb +102 -0
  18. data/lib/environment_information/constants/misc.rb +86 -0
  19. data/lib/environment_information/constants/namespace.rb +14 -0
  20. data/lib/environment_information/constants/newline.rb +16 -0
  21. data/lib/environment_information/constants/regex.rb +30 -0
  22. data/lib/environment_information/constants/temp_directory.rb +52 -0
  23. data/lib/environment_information/gui/gtk2/environment_information.rb +35 -0
  24. data/lib/environment_information/gui/gtk3/environment_information.rb +34 -0
  25. data/lib/environment_information/gui/libui/environment_information.rb +74 -0
  26. data/lib/environment_information/gui/shared_code/environment_information_module.rb +409 -0
  27. data/lib/environment_information/misc_components/README.md +3 -0
  28. data/lib/environment_information/misc_components/cflags.rb +36 -0
  29. data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
  30. data/lib/environment_information/misc_components/operating_system.rb +54 -0
  31. data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
  32. data/lib/environment_information/misc_components/ram.rb +30 -0
  33. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
  34. data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
  35. data/lib/environment_information/project/project.rb +27 -0
  36. data/lib/environment_information/queries/README.md +2 -0
  37. data/lib/environment_information/queries/complex_version.rb +273 -0
  38. data/lib/environment_information/queries/pkg_config.rb +125 -0
  39. data/lib/environment_information/queries/simple_version.rb +217 -0
  40. data/lib/environment_information/requires/require_asciitable.rb +15 -0
  41. data/lib/environment_information/requires/require_the_constants.rb +7 -0
  42. data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
  43. data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
  44. data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
  45. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +152 -0
  46. data/lib/environment_information/toplevel_methods/cd.rb +16 -0
  47. data/lib/environment_information/toplevel_methods/e.rb +43 -0
  48. data/lib/environment_information/toplevel_methods/hash.rb +60 -0
  49. data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
  50. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
  51. data/lib/environment_information/toplevel_methods/menu.rb +90 -0
  52. data/lib/environment_information/toplevel_methods/misc.rb +322 -0
  53. data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
  54. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
  55. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
  56. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
  57. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
  58. data/lib/environment_information/toplevel_methods/return_alias_to.rb +30 -0
  59. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
  60. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
  61. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
  62. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +182 -0
  63. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
  64. data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
  65. data/lib/environment_information/version/version.rb +25 -0
  66. data/lib/environment_information/www/sinatra_interface.rb +213 -0
  67. data/lib/environment_information/www/webobject_interface.cgi +29 -0
  68. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +15 -0
  69. data/lib/environment_information/yaml/array_lfs_core_programs.yml +37 -0
  70. data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
  71. data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
  72. data/lib/environment_information/yaml/array_tracked_programs.yml +215 -0
  73. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +37 -0
  74. data/lib/environment_information/yaml/colours.yml +3 -0
  75. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +264 -0
  76. data/lib/environment_information.rb +5 -0
  77. data/test/testing_environment_information.rb +26 -0
  78. data/test/testing_missing_components.rb +9 -0
  79. data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
  80. metadata +177 -0
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/misc_components/rubygems_installation_directory.rb'
6
+ # EnvironmentInformation.rubygems_installation_directory?
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'environment_information/constants/newline.rb'
11
+ require 'environment_information/constants/error_line.rb'
12
+ require 'environment_information/toplevel_methods/prefix_to_use.rb'
13
+
14
+ # ========================================================================= #
15
+ # === EnvironmentInformation.rubygems_installation_directory
16
+ #
17
+ # This method will return the path to the rubygems installation
18
+ # directory, if possible (if it exists).
19
+ #
20
+ # As this ought to be a directory, we will ensure that a trailing '/'
21
+ # character exists.
22
+ #
23
+ # This method may return a String such as "/root/.gem/".
24
+ # ========================================================================= #
25
+ def self.rubygems_installation_directory(
26
+ prefix_to_use = @prefix_to_use
27
+ )
28
+ result = `#{prefix_to_use}gem env #{ERROR_LINE}` # We need the 2>&1 to check if gem is available.
29
+ unless result.include? 'not found'
30
+ # ===================================================================== #
31
+ # Apply a regex next.
32
+ # ===================================================================== #
33
+ path_to_the_rubygem_directory = result.to_s.scan(
34
+ /INSTALLATION DIRECTORY: (.+)/ # Obtain the proper match here.
35
+ ).flatten.first.to_s
36
+ if File.directory? path_to_the_rubygem_directory
37
+ path_to_the_rubygem_directory << '/'
38
+ end unless path_to_the_rubygem_directory.end_with? '/'
39
+ result = path_to_the_rubygem_directory
40
+ else
41
+ result = nil
42
+ end
43
+ result
44
+ end; self.instance_eval { alias add_rubygems_installation_directory_information rubygems_installation_directory } # === EnvironmentInformation.add_rubygems_installation_directory_information
45
+ self.instance_eval { alias add_rubygem_directory_information rubygems_installation_directory } # === EnvironmentInformation.add_rubygem_directory_information
46
+ self.instance_eval { alias append_rubygem_installation_directory rubygems_installation_directory } # === EnvironmentInformation.append_rubygem_installation_directory
47
+ self.instance_eval { alias return_version_of_rubygems_installation_directory rubygems_installation_directory } # === EnvironmentInformation.return_version_of_rubygems_installation_directory
48
+ self.instance_eval { alias rubygems_installation_directory? rubygems_installation_directory } # === EnvironmentInformation.rubygems_installation_directory?
49
+
50
+ end
51
+
52
+ if __FILE__ == $PROGRAM_NAME
53
+ puts EnvironmentInformation.rubygems_installation_directory
54
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/misc_components/screen_resolution.rb'
6
+ # EnvironmentInformation.screen_resolution?
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'environment_information/constants/newline.rb'
11
+ require 'environment_information/constants/error_line.rb'
12
+
13
+ # ========================================================================= #
14
+ # === EnvironmentInformation.screen_resolution (screen tag)
15
+ #
16
+ # This method will typically make use of xdpyinfo first, as it also
17
+ # works in a .cgi environment. For non-cgi environments, on linux,
18
+ # we could use xrandr, which is a bit more elegant.
19
+ #
20
+ # On success, the method here will return a String such as "1920x1080".
21
+ # ========================================================================= #
22
+ def self.screen_resolution
23
+ result = '(unknown)' # This is the default return-value, then.
24
+ # ======================================================================= #
25
+ # === Check for linux as host OS first
26
+ # ======================================================================= #
27
+ if RUBY_PLATFORM.downcase.include? 'linux'
28
+ # ================================================================= #
29
+ # We have to be careful as xdpyinfo may not be installed on the
30
+ # given computer system.
31
+ # ================================================================= #
32
+ resolution = `xdpyinfo #{ERROR_LINE}`.scan(/dimensions:.+$/).first # The error here may be: "xdpyinfo: unable to open display"
33
+ if resolution and resolution.include? ':'
34
+ result = resolution.split(':').last.strip.split('pixels').first.strip
35
+ end
36
+ # ======================================================================= #
37
+ # === Else simply assume to be on windows here
38
+ # ======================================================================= #
39
+ else
40
+ result = `wmic desktopmonitor get screenheight,screenwidth #{ERROR_LINE}`
41
+ end
42
+ result
43
+ end; self.instance_eval { alias screen_resolution? screen_resolution } # === EnvironmentInformation.screen_resolution?
44
+ self.instance_eval { alias return_version_of_screen_resolution screen_resolution } # === EnvironmentInformation.return_version_of_screen_resolution
45
+
46
+ end
47
+
48
+ if __FILE__ == $PROGRAM_NAME
49
+ puts EnvironmentInformation.screen_resolution
50
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/project/project.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ # ========================================================================= #
10
+ # === EnvironmentInformation::PROJECT_BASE_DIRECTORY
11
+ #
12
+ # This constant may point to a target such as:
13
+ #
14
+ # /home/Programs/Ruby/2.7.1/lib/ruby/site_ruby/2.7.0/environment_information/
15
+ #
16
+ # ========================================================================= #
17
+ PROJECT_BASE_DIRECTORY =
18
+ File.absolute_path("#{__dir__}/..")+'/'
19
+
20
+ # ========================================================================= #
21
+ # === EnvironmentInformation.project_base_directory?
22
+ # ========================================================================= #
23
+ def self.project_base_directory?
24
+ PROJECT_BASE_DIRECTORY
25
+ end; self.instance_eval { alias project_base_dir? project_base_directory? } # === EnvironmentInformation.project_base_dir?
26
+
27
+ end
@@ -0,0 +1,2 @@
1
+ This directory contains code to specifically handle the different
2
+ query-related ways.
@@ -0,0 +1,273 @@
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(
90
+ this_program = @program_name
91
+ )
92
+ _ = ::EnvironmentInformation.query_to_use_for_the_individual_components?
93
+ if _.nil?
94
+ _ = ::EnvironmentInformation.load_file_query_to_use_for_the_individual_components
95
+ end
96
+ if _.has_key?(this_program)
97
+ cmd_to_run = _[this_program]
98
+ case cmd_to_run
99
+ # ===================================================================== #
100
+ # === :custom_busybox
101
+ # ===================================================================== #
102
+ when :custom_busybox
103
+ @program_version = ::EnvironmentInformation.return_version_of_busybox
104
+ # ===================================================================== #
105
+ # === :custom_xrandr
106
+ # ===================================================================== #
107
+ when :custom_xrandr
108
+ @program_version = ::EnvironmentInformation.return_version_of_xrandr
109
+ # ===================================================================== #
110
+ # === :custom_xvid
111
+ # ===================================================================== #
112
+ when :custom_xvid
113
+ @program_version = ::EnvironmentInformation.return_version_of_xvid
114
+ # ===================================================================== #
115
+ # === :custom_boost
116
+ # ===================================================================== #
117
+ when :custom_boost
118
+ @program_version = ::EnvironmentInformation.return_version_of_boost
119
+ # ===================================================================== #
120
+ # === :custom_mpc
121
+ # ===================================================================== #
122
+ when :custom_mpc
123
+ @program_version = ::EnvironmentInformation.return_version_of_mpc
124
+ else
125
+ result = `#{@prefix_to_use}#{cmd_to_run} #{ERROR_LINE}`.to_s.strip.dup
126
+ if result.include? ' #' # Handle "uname -a" aka Linux darkstar.example.net 5.4.50 #1 SMP
127
+ result = result.split(' #').first.strip
128
+ end
129
+ @program_version = result
130
+ end
131
+ return nil if @program_version.nil?
132
+ if @program_version.include? '# HMMER ' # <- Specifically for "hammer".
133
+ @program_version = @program_version.scan(
134
+ /# HMMER (\d{0,2}\.\d{0,2}\.\d{0,2})/
135
+ ).flatten.first.to_s
136
+ end
137
+ if @program_version.include? 'extracts blocks from damag' # bzip2recover
138
+ @program_version = @program_version.scan(
139
+ /bzip2recover (\d{0,2}\.\d{0,2}\.\d{0,2}): extracts blocks from damaged .bz2 files/
140
+ ).flatten.first.to_s.dup
141
+ end
142
+ # ===================================================================== #
143
+ # === Handle Imagemagick: 'Version: ImageMagick 7.0.10-28'
144
+ # ===================================================================== #
145
+ if @program_version.include? 'Version: ImageMagick '
146
+ @program_version = @program_version.scan(
147
+ /Version: ImageMagick (\d{0,2}\.\d{0,2}\.\d{0,2}-\d{0,2})/
148
+ ).flatten.first.to_s.tr('-','.')
149
+ end
150
+ # ===================================================================== #
151
+ # === Handle 'KDE Frameworks: 5.73.0'
152
+ # ===================================================================== #
153
+ if @program_version.include? 'KDE Frameworks: '
154
+ @program_version = @program_version.scan(
155
+ /KDE Frameworks: (\d{0,2}\.\d{0,2}\.\d{0,2})/
156
+ ).flatten.first.to_s
157
+ end
158
+ # ===================================================================== #
159
+ # === Handle 'ncurses 6.2.20200212' aka ncurses
160
+ # ===================================================================== #
161
+ if @program_version.include? 'ncurses '
162
+ @program_version = @program_version.scan(
163
+ /ncurses (\d{1,1}\.\d{1,1})/
164
+ ).flatten.first.to_s
165
+ end
166
+ # ===================================================================== #
167
+ # === Handle ruby 'ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]'
168
+ # ===================================================================== #
169
+ if @program_version.include? 'ruby '
170
+ @program_version = @program_version.scan(
171
+ /^ruby (\d{1,1}\.\d{1,1}\.\d{1,1})/
172
+ ).flatten.first.to_s
173
+ end
174
+ # ===================================================================== #
175
+ # === Handle patchelf '0.12.20200827.8d3a16e'
176
+ #
177
+ # This can also include output such as "patchelf 0.14.3".
178
+ # ===================================================================== #
179
+ if @program_version.include? 'patchelf '
180
+ @program_version = @program_version.scan(
181
+ /^patchelf (\d{1,1}\.\d{1,2}\.?\d{0,2})/
182
+ ).flatten.first.to_s
183
+ end
184
+ # ===================================================================== #
185
+ # We have to be careful with the next, as a few programs report the
186
+ # version on the second line, not on the first.
187
+ # ===================================================================== #
188
+ if @program_version.include? N
189
+ @program_version = @program_version.split(N).first.strip
190
+ end
191
+ # ===================================================================== #
192
+ # Next handle cases such as the following two examples:
193
+ #
194
+ # "ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers"
195
+ # "openjdk version \"14.0.2\" 2020-07-14"
196
+ # "ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers"
197
+ #
198
+ # ===================================================================== #
199
+ if @program_version.include? ' version '
200
+ @program_version = @program_version.scan(
201
+ / version n?"?(\d{0,2}\.\d{1,2}\.?\d{0,2})"?/ # See: See: https://rubular.com/r/39cIQqXin2oco0
202
+ ).flatten.first.to_s.strip
203
+ end
204
+ # ===================================================================== #
205
+ # Handle cases such as: "nginx/1.18.0"
206
+ # ===================================================================== #
207
+ if @program_version.include? '/'
208
+ @program_version = @program_version.split('/').last.strip
209
+ end
210
+ if @program_version.include?('(') and # Specifically for XTERM.
211
+ @program_version.include?(')')
212
+ @program_version = @program_version.split('(').last.to_s.delete(')') # 7.7.0(359)
213
+ end
214
+ if @program_version.include? '-'
215
+ # Specifically to fix relion: "3.1.0-commit-GITDIR"
216
+ @program_version = @program_version.split('-').first.to_s.strip
217
+ end
218
+ if @program_version.include? COMMAND_NOT_FOUND
219
+ @program_version = nil
220
+ elsif @program_version.include? ' '
221
+ # =================================================================== #
222
+ # Assume input such as: "GNU ld (GNU Binutils) 2.35"
223
+ # =================================================================== #
224
+ @program_version = @program_version.split(' ').last
225
+ end
226
+ end
227
+ return @program_version
228
+ end
229
+
230
+ # ========================================================================= #
231
+ # === run
232
+ # ========================================================================= #
233
+ def run
234
+ return_version_of
235
+ end
236
+
237
+ end; end; end
238
+
239
+ if __FILE__ == $PROGRAM_NAME
240
+ array = %i(
241
+ mpc
242
+ gtk2
243
+ linux
244
+ binutils
245
+ boost
246
+ coreutils
247
+ diffutils
248
+ ffmpeg
249
+ findutils
250
+ java
251
+ imagemagick
252
+ kde_frameworks
253
+ llvm
254
+ ncurses
255
+ nginx
256
+ qt
257
+ rubygems
258
+ sharutils
259
+ sysstat
260
+ swig
261
+ texinfo
262
+ tmux
263
+ xfsprogs
264
+ xterm
265
+ hmmer
266
+ viennarna
267
+ xstdcmap
268
+ )
269
+ array.each {|entry|
270
+ _ = EnvironmentInformation::Queries::ComplexVersion.new(entry)
271
+ _.report_left_right
272
+ }
273
+ 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