environment_information 1.4.29

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 (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,264 @@
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/misc.rb'
11
+ require 'environment_information/toplevel_methods/hash.rb'
12
+ require 'environment_information/toplevel_methods/write_what_into.rb'
13
+
14
+ # ========================================================================= #
15
+ # === Environment.silent_run
16
+ # ========================================================================= #
17
+ def self.silent_run
18
+ @hash_available_programs = {} # Clear it every time this method is run.
19
+ work_on_these_programs = []
20
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_NON_PROGRAMS)
21
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_PROGRAMS)
22
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_XORG_COMPONENTS)
23
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_SCIENCE_CLUSTER)
24
+ work_on_these_programs.flatten.each {|this_program|
25
+ version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
26
+ if version_of_this_program
27
+ version_of_this_program = version_of_this_program.to_s
28
+ end
29
+ @hash_available_programs[this_program] = version_of_this_program
30
+ }
31
+ consider_storing_these_results_into_a_local_file(false)
32
+ return @hash_available_programs
33
+ end; self.instance_eval { alias build_up_and_return_the_main_hash silent_run } # === EnvironmentInformation.build_up_and_return_the_main_hash
34
+ self.instance_eval { alias initialize_hash silent_run } # === EnvironmentInformation.initialize_hash
35
+ self.instance_eval { alias initialize silent_run } # === EnvironmentInformation.initialize
36
+ self.instance_eval { alias run silent_run } # === EnvironmentInformation.run
37
+
38
+ # ========================================================================= #
39
+ # === EnvironmentInformation.consider_storing_these_results_into_a_local_file
40
+ #
41
+ # This method will always take the dataset stored in the main Hash when
42
+ # saving the yaml file at hand.
43
+ # ========================================================================= #
44
+ def self.consider_storing_these_results_into_a_local_file(
45
+ be_verbose = true
46
+ )
47
+ unless @hash_available_programs.empty?
48
+ what = YAML.dump(@hash_available_programs)
49
+ # ===================================================================== #
50
+ # The file will be stored under the temp_directory.
51
+ # ===================================================================== #
52
+ into = return_path_to_the_all_programs_file
53
+ e "Storing these #{royalblue(@hash_available_programs.size)} "\
54
+ "components into: #{sfile(into)}" if be_verbose
55
+ write_what_into(what, into)
56
+ end
57
+ end; self.instance_eval { alias store_relevant_files consider_storing_these_results_into_a_local_file } # === EnvironmentInformation.store_relevant_files
58
+
59
+ # ========================================================================= #
60
+ # === EnvironmentInformation.show_detailed_information_about_all_available_components
61
+ #
62
+ # This method is mostly for testing purposes only; for real use
63
+ # for the project you should consider making use of
64
+ # Environment.silent_run instead.
65
+ #
66
+ # Do note that this method will always show all available components;
67
+ # if you need more fine-tuned control then you have to use the
68
+ # class EnvironmentInformation instead.
69
+ # ========================================================================= #
70
+ def self.show_detailed_information_about_all_available_components
71
+ @hash_available_programs = {} # Clear it every time this method is run.
72
+ work_on_these_programs = []
73
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_NON_PROGRAMS)
74
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_PROGRAMS)
75
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_XORG_COMPONENTS)
76
+ work_on_these_programs << YAML.load_file(FILE_ARRAY_SCIENCE_CLUSTER)
77
+ work_on_these_programs.flatten!
78
+ work_on_these_programs.uniq!
79
+ e
80
+ work_on_these_programs.each {|this_program|
81
+ version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
82
+ # ===================================================================== #
83
+ # Do a little sanitizing next:
84
+ # ===================================================================== #
85
+ case this_program.to_s
86
+ when 'kde_frameworks'
87
+ this_program = 'KDE Frameworks'.to_sym
88
+ end
89
+ left_side = colourize_and_pad_the_left_side(this_program)
90
+ case version_of_this_program
91
+ when COMMAND_NOT_FOUND,
92
+ ''
93
+ version_of_this_program = nil
94
+ colour_for_the_right_side = :orange
95
+ else
96
+ colour_for_the_right_side = :notify_if_missing
97
+ end
98
+ # ===================================================================== #
99
+ # Next register this program into the main hash.
100
+ # ===================================================================== #
101
+ @hash_available_programs[this_program] = version_of_this_program
102
+ right_side = colourize_and_pad_the_right_side(
103
+ version_of_this_program,
104
+ colour_for_the_right_side
105
+ )
106
+ e " #{left_side} #{right_side}"
107
+ }
108
+ e
109
+ # ======================================================================= #
110
+ # Report missing programs.
111
+ # ======================================================================= #
112
+ _ = missing_components?
113
+ unless _.empty?
114
+ e 'The following components were not found:'
115
+ e
116
+ _.each {|this_component|
117
+ e lightseagreen(" #{this_component}")
118
+ }
119
+ e
120
+ end
121
+ consider_storing_these_results_into_a_local_file
122
+ end; self.instance_eval { alias test show_detailed_information_about_all_available_components } # === EnvironmentInformation.test
123
+
124
+ # ========================================================================= #
125
+ # === EnvironmentInformation.return_version_of_xvid
126
+ # ========================================================================= #
127
+ def self.return_version_of_xvid(
128
+ target_file = '/usr/include/xvid.h'
129
+ )
130
+ if File.exist?('/System/Index/include/'+File.basename(target_file)) and
131
+ !File.exist?(target_file) # Custom fix.
132
+ target_file = '/System/Index/include/'+File.basename(target_file)
133
+ end
134
+ if File.exist? target_file
135
+ dataset = File.readlines(target_file)
136
+ version = dataset.select {|line|
137
+ line.include? ' XVID_MAKE_VERSION(' # #define XVID_VERSION XVID_MAKE_VERSION(1,3,7)
138
+ }
139
+ if version.is_a? Array
140
+ version = version.flatten.first.to_s
141
+ end
142
+ version = version.scan( # See: https://rubular.com/r/4anuroBmb40yzh
143
+ /XVID_MAKE_VERSION\((\d{0,1},\d{0,1},\d{0,1})/
144
+
145
+ )
146
+ if version.is_a? Array
147
+ version = version.flatten.first.to_s
148
+ end
149
+ version.tr!(',','.')
150
+ else
151
+ version = nil
152
+ end
153
+ return version
154
+ end
155
+
156
+ # ========================================================================= #
157
+ # === EnvironmentInformation.return_version_of_busybox
158
+ # ========================================================================= #
159
+ def self.return_version_of_busybox
160
+ result = `busybox #{ERROR_LINE}`
161
+ if result and result.is_a?(String) and result.include?("\n")
162
+ first_line = result.split("\n").first
163
+ if first_line.include? ' v'
164
+ # "BusyBox v1.32.0 (2020-11-08 04:41:56 Etc) multi-call binary.\n"
165
+ use_this_regex = /v(\d{0,1}.\d{0,2}.\d{0,1})/ # See: https://rubular.com/r/MpnFXlalLCXXGI
166
+ result = first_line.scan(use_this_regex).flatten.first.to_s
167
+ return result
168
+ end
169
+ end
170
+ return nil
171
+ end
172
+
173
+ # ========================================================================= #
174
+ # === EnvironmentInformation.return_version_of_boost
175
+ #
176
+ # This method will either return a String (the version of boost),
177
+ # or nil if boost was not found.
178
+ # ========================================================================= #
179
+ def self.return_version_of_boost
180
+ target_file = '/usr/include/boost/version.hpp'
181
+ if File.exist?('/System/Index/include/boost/version.hpp') and
182
+ !File.exist?(target_file) # Custom fix.
183
+ target_file = '/System/Index/include/boost/version.hpp'
184
+ end
185
+ if File.exist? target_file
186
+ dataset = File.readlines(target_file)
187
+ version = dataset.select {|line|
188
+ line.include? '#define BOOST_LIB_VERSION'
189
+ }.first.sub(/#define BOOST_LIB_VERSION/,'').
190
+ strip.delete('"').tr('_','.')
191
+ if version.count('.') < 2
192
+ version << '.0'
193
+ end
194
+ else
195
+ version = nil
196
+ end
197
+ return version
198
+ end
199
+
200
+ # ========================================================================= #
201
+ # === EnvironmentInformation.return_version_of_mpc
202
+ #
203
+ # This method will read the version-string from a .h header file.
204
+ # ========================================================================= #
205
+ def self.return_version_of_mpc
206
+ target_file = '/usr/include/mpc.h'
207
+ if File.exist? target_file
208
+ dataset = File.read(target_file)
209
+ use_this_regex = /MPC_VERSION_STRING "([0-9\.]+)"$/
210
+ dataset = dataset.scan(use_this_regex).flatten
211
+ version = dataset.first
212
+ return version
213
+ else
214
+ return THE_PROGRAM_WAS_NOT_FOUND
215
+ end
216
+ end
217
+
218
+ # ========================================================================= #
219
+ # === EnvironmentInformation.return_array_of_outdated_programs
220
+ #
221
+ # This method will return all programs that are outdated - this
222
+ # also includes missing programs, so the method name is a slight
223
+ # misnomer.
224
+ #
225
+ # Usage example:
226
+ #
227
+ # EnvironmentInformation.initialize
228
+ # array = EnvironmentInformation.return_array_of_outdated_programs
229
+ #
230
+ # ========================================================================= #
231
+ def self.return_array_of_outdated_programs(
232
+ hash = ::EnvironmentInformation.hash?
233
+ )
234
+ forbidden = ::EnvironmentInformation.load_file_array_tracked_non_programs
235
+ # ======================================================================= #
236
+ # Now find all entries that are either nil, or have a too low program
237
+ # version.
238
+ # ======================================================================= #
239
+ array = hash.select {|key, value|
240
+ if value and forbidden.include?(key) # ← we exclude entries here such as "rubygems_installation_dir".
241
+ false
242
+ else
243
+ if value.nil? or value.include?('not found') or
244
+ !(value =~ /\d+/) # ← check for at the least one number, such as "1".
245
+ true
246
+ else
247
+ false
248
+ end
249
+ end
250
+ }.keys
251
+ # ======================================================================= #
252
+ # Next, check these against the local program version:
253
+ # local_program_version = key
254
+ # ======================================================================= #
255
+ return array
256
+ end
257
+
258
+ end
259
+
260
+ if __FILE__ == $PROGRAM_NAME
261
+ puts EnvironmentInformation.return_version_of_mpc
262
+ puts EnvironmentInformation.return_version_of_boost
263
+ EnvironmentInformation.test
264
+ 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
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/remote_url_of_this_program.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ # ========================================================================= #
10
+ # === EnvironmentInformation.return_remote_url_of_this_program
11
+ #
12
+ # This method will try to return the remote URL of the given program.
13
+ #
14
+ # Note that this functionality depends on the RBT project, which
15
+ # explains the rescued required statement in the method. While in
16
+ # theory we could create a stand-alone solution, I don't want to
17
+ # duplicate code I already wrote for another project, so users
18
+ # are encouraged to install the rbt gem - it's what I use on my
19
+ # home system as well.
20
+ # ========================================================================= #
21
+ def self.return_remote_url_of_this_program(i = ARGV)
22
+ if i.is_a? Array
23
+ i = i.first
24
+ end
25
+ begin
26
+ require 'rbt/utility_scripts/url.rb'
27
+ i = RBT.return_url1_of_this_program(i)
28
+ rescue LoadError; end
29
+ i
30
+ end
31
+
32
+ # ========================================================================= #
33
+ # === EnvironmentInformation.show_remote_url_of_this_program
34
+ #
35
+ # This method will try to show the remote URL of the given program.
36
+ # ========================================================================= #
37
+ def self.show_remote_url_of_this_program(i = ARGV)
38
+ puts return_remote_url_of_this_program(i)
39
+ end
40
+
41
+ end
42
+
43
+ if __FILE__ == $PROGRAM_NAME
44
+ EnvironmentInformation.show_remote_url_of_this_program(ARGV)
45
+ end # rb remote_url_of_this_program.rb glib
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/replay_from_the_stored_file.rb'
6
+ # EnvironmentInformation.replay_from_the_stored_file
7
+ # EnvironmentInformation.colourize_and_pad_the_left_side
8
+ # =========================================================================== #
9
+ module EnvironmentInformation
10
+
11
+ require 'yaml'
12
+ require 'environment_information/constants/temp_directory.rb'
13
+ require 'environment_information/colours/colours.rb'
14
+
15
+ # ========================================================================= #
16
+ # === EnvironmentInformation.return_path_to_the_all_programs_file
17
+ # ========================================================================= #
18
+ def self.return_path_to_the_all_programs_file
19
+ "#{temp_directory?}all_programs.yml"
20
+ end
21
+
22
+ # ========================================================================= #
23
+ # === EnvironmentInformation.replay_from_the_stored_file
24
+ #
25
+ # To invoke this method from the commandline, try:
26
+ #
27
+ # envi --replay
28
+ #
29
+ # ========================================================================= #
30
+ def self.replay_from_the_stored_file(
31
+ _ = return_path_to_the_all_programs_file
32
+ )
33
+ if File.exist? _
34
+ e "Loading from the file #{_}."
35
+ @hash_available_programs = YAML.load_file(_)
36
+ @hash_available_programs.each_pair {|key, value|
37
+ e colourize_and_pad_the_left_side("#{key}:")+
38
+ colourize_and_pad_the_right_side(
39
+ value.to_s, :notify_if_missing
40
+ )
41
+ }
42
+ else
43
+ e "No file exists at #{_}."
44
+ end
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === EnvironmentInformation.colourize_and_pad_the_right_side
49
+ # ========================================================================= #
50
+ def self.colourize_and_pad_the_right_side(
51
+ i,
52
+ colour_for_the_right_side = ::EnvironmentInformation.colour_for_the_right_side
53
+ )
54
+ case colour_for_the_right_side
55
+ # ======================================================================= #
56
+ # === :notify_if_missing
57
+ # ======================================================================= #
58
+ when :notify_if_missing
59
+ colour_for_the_right_side = ::EnvironmentInformation.colour_for_the_right_side
60
+ if i.to_s.empty?
61
+ i = '[Not found]'
62
+ colour_for_the_right_side = :orange
63
+ end
64
+ end
65
+ if use_colours?
66
+ Colours.send(colour_for_the_right_side, i)
67
+ else
68
+ i
69
+ end
70
+ end; self.instance_eval { alias prepare_right_side colourize_and_pad_the_right_side } # === EnvironmentInformation.prepare_right_side
71
+
72
+ # ========================================================================= #
73
+ # === EnvironmentInformation.colourize_and_pad_the_left_side
74
+ # ========================================================================= #
75
+ def self.colourize_and_pad_the_left_side(i)
76
+ left_side = i.to_s.ljust(32) # Pad to the left-hand side.
77
+ if use_colours?
78
+ " #{Colours.send(::EnvironmentInformation.colour_for_the_left_side, left_side)}"
79
+ else
80
+ " #{left_side}"
81
+ end
82
+ end; self.instance_eval { alias prepare_left_side colourize_and_pad_the_left_side } # === EnvironmentInformation.prepare_left_side
83
+
84
+ end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/return_pkgconfig_based_programs.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ require 'environment_information/constants/file_constants.rb'
10
+
11
+ # ========================================================================= #
12
+ # === EnvironmentInformation.return_pkgconfig_based_programs
13
+ # ========================================================================= #
14
+ def self.return_pkgconfig_based_programs
15
+ dataset = YAML.load_file(file_query_to_use_for_the_individual_components)
16
+ dataset.select {|key, value|
17
+ # ===================================================================== #
18
+ # The next query will select both :pkgconfig and :"pkg-config".
19
+ # ===================================================================== #
20
+ value.to_s.start_with? 'pkg'
21
+ }.keys
22
+ end
23
+
24
+ end
25
+
26
+ if __FILE__ == $PROGRAM_NAME
27
+ pp EnvironmentInformation.return_pkgconfig_based_programs
28
+ end
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/return_remote_gtk2_version.rb'
6
+ # EnvironmentInformation.return_remote_gtk2_version
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'environment_information/toplevel_methods/internet_is_available.rb'
11
+
12
+ # ========================================================================= #
13
+ # === EnvironmentInformation.return_remote_gtk2_version
14
+ #
15
+ # This method can be used to obtain the latest gtk2-version, from a
16
+ # remote URL.
17
+ #
18
+ # The reason why this was necessary is because the RBT project may not
19
+ # always keep the latest gtk2 version, since gtk3 (and so forth) is more
20
+ # recent. Since we may still have to find out which gtk2 version is the
21
+ # most recent, we need a method to do so - which is precisely what this
22
+ # method here is doing.
23
+ # ========================================================================= #
24
+ def self.return_remote_gtk2_version
25
+ # ======================================================================= #
26
+ # We will use a hardcoded URL pointing towards gtk2:
27
+ # ======================================================================= #
28
+ remote_url = 'https://ftp.gnome.org/pub/GNOME/sources/gtk+/2.24/?C=M;O=D'
29
+ require 'open-uri'
30
+ newest_version = ''
31
+ # ======================================================================= #
32
+ # We will next try to obtain the remote dataset, but this would
33
+ # fail if we have no www-connection, so we must rescue this step.
34
+ # ======================================================================= #
35
+ if internet_is_available?
36
+ begin
37
+ dataset = URI.open(remote_url).read
38
+ use_this_regex =
39
+ /<a href="gtk\+\-(\d.\d\d.\d\d).tar.xz"><img src=/
40
+ scanned = dataset.scan(use_this_regex).flatten
41
+ newest_version = scanned.first
42
+ rescue SocketError => error
43
+ puts "It seems as if we have no working internet "\
44
+ "connection (#{sfancy(error.class)})"
45
+ end
46
+ end
47
+ return newest_version.strip # ← And return it here.
48
+ end
49
+
50
+ end
51
+
52
+ if __FILE__ == $PROGRAM_NAME
53
+ puts EnvironmentInformation.return_remote_gtk2_version
54
+ end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/toplevel_methods/return_simple_version_based_programs.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ require 'environment_information/constants/file_constants.rb'
10
+
11
+ # ========================================================================= #
12
+ # === EnvironmentInformation.return_simple_version_based_programs
13
+ # ========================================================================= #
14
+ def self.return_simple_version_based_programs
15
+ dataset = YAML.load_file(file_query_to_use_for_the_individual_components)
16
+ dataset.select {|key, value|
17
+ # ===================================================================== #
18
+ # The next query will select only for :version entries.
19
+ # ===================================================================== #
20
+ value == :version
21
+ }.keys
22
+ end
23
+
24
+ end
25
+
26
+ if __FILE__ == $PROGRAM_NAME
27
+ pp EnvironmentInformation.return_simple_version_based_programs
28
+ end