environment_information 1.4.124 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +91 -15
  3. data/doc/README.gen +42 -14
  4. data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +16 -12
  5. data/lib/environment_information/base/base.rb +483 -99
  6. data/lib/environment_information/colours/colours.rb +92 -66
  7. data/lib/environment_information/commandline/commandline.rb +137 -0
  8. data/lib/environment_information/constants/constants.rb +372 -11
  9. data/lib/environment_information/project/project.rb +1 -1
  10. data/lib/environment_information/query/constants.rb +46 -0
  11. data/lib/environment_information/query/help.rb +88 -0
  12. data/lib/environment_information/query/menu.rb +487 -0
  13. data/lib/environment_information/query/misc.rb +2006 -0
  14. data/lib/environment_information/query/query.rb +245 -0
  15. data/lib/environment_information/query/reset.rb +202 -0
  16. data/lib/environment_information/query/run.rb +70 -0
  17. data/lib/environment_information/requires/require_the_environment_information_project.rb +2 -7
  18. data/lib/environment_information/requires/require_the_toplevel_methods.rb +1 -3
  19. data/lib/environment_information/toplevel_methods/toplevel_methods.rb +2258 -0
  20. data/lib/environment_information/version/version.rb +2 -2
  21. data/lib/environment_information/www/sinatra_interface.rb +20 -17
  22. data/lib/environment_information/www/webobject_interface.cgi +6 -7
  23. data/lib/environment_information/yaml/colours.yml +3 -3
  24. data/lib/environment_information/yaml/query_to_use_for_all_components.yml +284 -0
  25. data/lib/environment_information/yaml/{array_tracked_programs.yml → track_these_components.yml} +77 -11
  26. metadata +18 -60
  27. data/lib/environment_information/class/class.rb +0 -2580
  28. data/lib/environment_information/class/colours.rb +0 -282
  29. data/lib/environment_information/colours/sfancy.rb +0 -19
  30. data/lib/environment_information/colours/simp.rb +0 -19
  31. data/lib/environment_information/constants/array_tracked_components.rb +0 -210
  32. data/lib/environment_information/constants/encoding.rb +0 -21
  33. data/lib/environment_information/constants/error_line.rb +0 -17
  34. data/lib/environment_information/constants/file_constants.rb +0 -102
  35. data/lib/environment_information/constants/misc.rb +0 -86
  36. data/lib/environment_information/constants/namespace.rb +0 -14
  37. data/lib/environment_information/constants/newline.rb +0 -16
  38. data/lib/environment_information/constants/regex.rb +0 -30
  39. data/lib/environment_information/constants/temp_directory.rb +0 -52
  40. data/lib/environment_information/misc_components/README.md +0 -3
  41. data/lib/environment_information/misc_components/cflags.rb +0 -36
  42. data/lib/environment_information/misc_components/cpuinfo.rb +0 -64
  43. data/lib/environment_information/misc_components/operating_system.rb +0 -54
  44. data/lib/environment_information/misc_components/operating_system_bit_type.rb +0 -42
  45. data/lib/environment_information/misc_components/ram.rb +0 -30
  46. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +0 -54
  47. data/lib/environment_information/misc_components/screen_resolution.rb +0 -50
  48. data/lib/environment_information/queries/README.md +0 -2
  49. data/lib/environment_information/queries/complex_version.rb +0 -273
  50. data/lib/environment_information/queries/pkg_config.rb +0 -125
  51. data/lib/environment_information/queries/simple_version.rb +0 -272
  52. data/lib/environment_information/requires/require_the_individual_misc_components.rb +0 -30
  53. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +0 -153
  54. data/lib/environment_information/toplevel_methods/cd.rb +0 -16
  55. data/lib/environment_information/toplevel_methods/e.rb +0 -43
  56. data/lib/environment_information/toplevel_methods/hash.rb +0 -65
  57. data/lib/environment_information/toplevel_methods/internet_is_available.rb +0 -30
  58. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +0 -16
  59. data/lib/environment_information/toplevel_methods/menu.rb +0 -90
  60. data/lib/environment_information/toplevel_methods/misc.rb +0 -324
  61. data/lib/environment_information/toplevel_methods/n_subcommands.rb +0 -31
  62. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +0 -39
  63. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +0 -61
  64. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +0 -45
  65. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +0 -84
  66. data/lib/environment_information/toplevel_methods/return_alias_to.rb +0 -30
  67. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +0 -28
  68. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +0 -54
  69. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +0 -28
  70. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +0 -182
  71. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +0 -192
  72. data/lib/environment_information/toplevel_methods/write_what_into.rb +0 -24
  73. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +0 -15
  74. data/lib/environment_information/yaml/array_lfs_core_programs.yml +0 -37
  75. data/lib/environment_information/yaml/array_science_cluster.yml +0 -12
  76. data/lib/environment_information/yaml/array_tracked_non_programs.yml +0 -13
  77. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +0 -37
  78. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +0 -284
@@ -1,324 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/toplevel_methods/misc.rb'
6
- # EnvironmentInformation.return_version_of_mpc
7
- # =========================================================================== #
8
- module EnvironmentInformation
9
-
10
- require 'environment_information/constants/file_constants.rb'
11
- require 'environment_information/constants/misc.rb'
12
-
13
- # ========================================================================= #
14
- # === Environment.verbose_truth
15
- # ========================================================================= #
16
- def self.verbose_truth(i)
17
- case i
18
- when /true/
19
- 'Yes.'
20
- when /false/
21
- 'No.'
22
- end
23
- end
24
-
25
- # ========================================================================= #
26
- # === Environment.silent_run
27
- # ========================================================================= #
28
- def self.silent_run(
29
- array_load_these_files = [
30
- FILE_ARRAY_TRACKED_NON_PROGRAMS,
31
- FILE_ARRAY_TRACKED_PROGRAMS,
32
- FILE_ARRAY_TRACKED_XORG_COMPONENTS,
33
- FILE_ARRAY_SCIENCE_CLUSTER
34
- ]
35
- )
36
- @hash_available_programs = {} # Clear it every time this method is run.
37
- work_on_these_programs = []
38
- array_load_these_files.each {|this_entry|
39
- work_on_these_programs << YAML.load_file(this_entry)
40
- }
41
- work_on_these_programs.flatten.each {|this_program|
42
- version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
43
- if version_of_this_program
44
- version_of_this_program = version_of_this_program.to_s
45
- end
46
- @hash_available_programs[this_program] = version_of_this_program
47
- }
48
- consider_storing_these_results_into_a_local_file(false)
49
- return @hash_available_programs
50
- end; self.instance_eval { alias build_up_and_return_the_main_hash silent_run } # === EnvironmentInformation.build_up_and_return_the_main_hash
51
- self.instance_eval { alias initialize_hash silent_run } # === EnvironmentInformation.initialize_hash
52
- self.instance_eval { alias initialize silent_run } # === EnvironmentInformation.initialize
53
- self.instance_eval { alias run silent_run } # === EnvironmentInformation.run
54
-
55
- # ========================================================================= #
56
- # === EnvironmentInformation.consider_storing_these_results_into_a_local_file
57
- #
58
- # This method will always take the dataset stored in the main Hash when
59
- # saving the yaml file at hand.
60
- # ========================================================================= #
61
- def self.consider_storing_these_results_into_a_local_file(
62
- be_verbose = true
63
- )
64
- unless @hash_available_programs.empty?
65
- what = YAML.dump(@hash_available_programs)
66
- # ===================================================================== #
67
- # The file will be stored under the temp_directory.
68
- # ===================================================================== #
69
- into = ::EnvironmentInformation.return_path_to_the_all_programs_file
70
- e "#{rev}Storing these #{royalblue(@hash_available_programs.size)} "\
71
- "#{rev}components into: #{sfile(into)}" if be_verbose
72
- write_what_into(what, into)
73
- end
74
- end; self.instance_eval { alias store_relevant_files consider_storing_these_results_into_a_local_file } # === EnvironmentInformation.store_relevant_files
75
-
76
- # ========================================================================= #
77
- # === EnvironmentInformation.show_detailed_information_about_all_available_components
78
- #
79
- # This method is mostly for testing purposes only; for real use
80
- # for the project you should consider making use of
81
- # Environment.silent_run instead.
82
- #
83
- # Do note that this method will always show all available components;
84
- # if you need more fine-tuned control then you have to use the
85
- # class EnvironmentInformation instead.
86
- # ========================================================================= #
87
- def self.show_detailed_information_about_all_available_components
88
- @hash_available_programs = {} # Clear it every time this method is run.
89
- work_on_these_programs = []
90
- work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_NON_PROGRAMS)
91
- work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_PROGRAMS)
92
- work_on_these_programs << YAML.load_file(FILE_ARRAY_TRACKED_XORG_COMPONENTS)
93
- work_on_these_programs << YAML.load_file(FILE_ARRAY_SCIENCE_CLUSTER)
94
- work_on_these_programs.flatten!
95
- work_on_these_programs.uniq!
96
- e
97
- work_on_these_programs.each {|this_program|
98
- version_of_this_program = ::EnvironmentInformation.return_version_of_this_program(this_program)
99
- # ===================================================================== #
100
- # Do a little sanitizing next:
101
- # ===================================================================== #
102
- case this_program.to_s
103
- when 'kde_frameworks'
104
- this_program = 'KDE Frameworks'.to_sym
105
- end
106
- left_side = colourize_and_pad_the_left_side(this_program)
107
- case version_of_this_program
108
- when COMMAND_NOT_FOUND,
109
- ''
110
- version_of_this_program = nil
111
- colour_for_the_right_side = :orange
112
- else
113
- colour_for_the_right_side = :notify_if_missing
114
- end
115
- # ===================================================================== #
116
- # Next register this program into the main hash.
117
- # ===================================================================== #
118
- @hash_available_programs[this_program] = version_of_this_program
119
- right_side = colourize_and_pad_the_right_side(
120
- version_of_this_program,
121
- colour_for_the_right_side
122
- )
123
- e " #{left_side} #{right_side}"
124
- }
125
- e
126
- # ======================================================================= #
127
- # Report missing programs.
128
- # ======================================================================= #
129
- _ = missing_components?
130
- unless _.empty?
131
- e 'The following components were not found:'
132
- e
133
- _.each {|this_component|
134
- e lightseagreen(" #{this_component}")
135
- }
136
- e
137
- end
138
- consider_storing_these_results_into_a_local_file
139
- end; self.instance_eval { alias test show_detailed_information_about_all_available_components } # === EnvironmentInformation.test
140
-
141
- # ========================================================================= #
142
- # === EnvironmentInformation.return_version_of_xrandr
143
- # ========================================================================= #
144
- def self.return_version_of_xrandr
145
- _ = `xrandr --version #{ERROR_LINE}` # Need to use ERROR_LINE to avoid the code breaking down here.
146
- if _
147
- version = _.strip.split("\n")
148
- if version.is_a?(Array)
149
- version = version.first.split(' ').last.strip # Assume: "xrandr program version 1.5.1"
150
- return version
151
- end
152
- end
153
- return nil
154
- end
155
-
156
- # ========================================================================= #
157
- # === EnvironmentInformation.return_version_of_xvid
158
- # ========================================================================= #
159
- def self.return_version_of_xvid(
160
- target_file = '/usr/include/xvid.h'
161
- )
162
- if File.exist?('/System/Index/include/'+File.basename(target_file)) and
163
- !File.exist?(target_file) # Custom fix.
164
- target_file = '/System/Index/include/'+File.basename(target_file)
165
- end
166
- if File.exist? target_file
167
- dataset = File.readlines(target_file)
168
- version = dataset.select {|line|
169
- line.include? ' XVID_MAKE_VERSION(' # #define XVID_VERSION XVID_MAKE_VERSION(1,3,7)
170
- }
171
- if version.is_a? Array
172
- version = version.flatten.first.to_s
173
- end
174
- version = version.scan( # See: https://rubular.com/r/4anuroBmb40yzh
175
- /XVID_MAKE_VERSION\((\d{0,1},\d{0,1},\d{0,1})/
176
-
177
- )
178
- if version.is_a? Array
179
- version = version.flatten.first.to_s
180
- end
181
- version.tr!(',','.')
182
- else
183
- version = nil
184
- end
185
- return version
186
- end
187
-
188
- # ========================================================================= #
189
- # === EnvironmentInformation.return_version_of_busybox
190
- # ========================================================================= #
191
- def self.return_version_of_busybox
192
- result = `busybox #{ERROR_LINE}`
193
- if result and result.is_a?(String) and result.include?("\n")
194
- first_line = result.split("\n").first
195
- if first_line.include? ' v'
196
- # "BusyBox v1.32.0 (2020-11-08 04:41:56 Etc) multi-call binary.\n"
197
- use_this_regex = /v(\d{0,1}.\d{0,2}.\d{0,1})/ # See: https://rubular.com/r/MpnFXlalLCXXGI
198
- result = first_line.scan(use_this_regex).flatten.first.to_s
199
- return result
200
- end
201
- end
202
- return nil
203
- end
204
-
205
- # ========================================================================= #
206
- # === EnvironmentInformation.return_version_of_boost
207
- #
208
- # This method will either return a String (the version of boost),
209
- # or nil if boost was not found.
210
- # ========================================================================= #
211
- def self.return_version_of_boost
212
- target_file = '/usr/include/boost/version.hpp'
213
- if File.exist?('/System/Index/include/boost/version.hpp') and
214
- !File.exist?(target_file) # Custom fix.
215
- target_file = '/System/Index/include/boost/version.hpp'
216
- end
217
- if File.exist? target_file
218
- dataset = File.readlines(target_file)
219
- version = dataset.select {|line|
220
- line.include? '#define BOOST_LIB_VERSION'
221
- }.first.sub(/#define BOOST_LIB_VERSION/,'').
222
- strip.delete('"').tr('_','.')
223
- if version.count('.') < 2
224
- version << '.0'
225
- end
226
- else
227
- version = nil
228
- end
229
- return version
230
- end
231
-
232
- # ========================================================================= #
233
- # === EnvironmentInformation.return_version_of_mpc
234
- #
235
- # This method will read the version-string from a .h header file.
236
- # ========================================================================= #
237
- def self.return_version_of_mpc
238
- target_file = '/usr/include/mpc.h'
239
- if File.exist? target_file
240
- dataset = File.read(target_file)
241
- use_this_regex = /MPC_VERSION_STRING "([0-9\.]+)"$/
242
- dataset = dataset.scan(use_this_regex).flatten
243
- version = dataset.first
244
- return version
245
- else
246
- return THE_PROGRAM_WAS_NOT_FOUND
247
- end
248
- end
249
-
250
- # ========================================================================= #
251
- # === EnvironmentInformation.return_array_of_outdated_programs
252
- #
253
- # This method will return all programs that are outdated - this
254
- # also includes missing programs, so the method name is a slight
255
- # misnomer.
256
- #
257
- # Usage example:
258
- #
259
- # EnvironmentInformation.initialize
260
- # array = EnvironmentInformation.return_array_of_outdated_programs
261
- #
262
- # ========================================================================= #
263
- def self.return_array_of_outdated_programs(
264
- hash = ::EnvironmentInformation.hash?
265
- )
266
- forbidden = ::EnvironmentInformation.load_file_array_tracked_non_programs
267
- # ======================================================================= #
268
- # Now find all entries that are either nil, or have a too low program
269
- # version.
270
- # ======================================================================= #
271
- array = hash.select {|key, value|
272
- if value and forbidden.include?(key) # ← we exclude entries here such as "rubygems_installation_dir".
273
- false
274
- else
275
- if value.nil? or value.include?('not found') or
276
- !(value =~ /\d+/) # ← check for at the least one number, such as "1".
277
- true
278
- else
279
- false
280
- end
281
- end
282
- }.keys
283
- # ======================================================================= #
284
- # Next, check these against the local program version:
285
- # local_program_version = key
286
- # ======================================================================= #
287
- return array
288
- end
289
-
290
- # ========================================================================= #
291
- # === EnvironmentInformation.return_the_most_important_info
292
- #
293
- # This method will just return a String that can be used right away
294
- # in, for example, a sinatra application.
295
- # ========================================================================= #
296
- def self.return_the_most_important_info
297
- 'Operating system: '+
298
- ::EnvironmentInformation.operating_system+'<br>'+
299
- 'Operating system bit type: '+
300
- ::EnvironmentInformation.operating_system_bit_type+'<br>'+
301
- 'CPU model: '+
302
- ::EnvironmentInformation.cpu_model+'<br>'
303
- end
304
-
305
- # ========================================================================= #
306
- # === EnvironmentInformation.return_everything
307
- # ========================================================================= #
308
- def self.return_everything
309
- require 'environment_information/class/class.rb'
310
- _ = ::EnvironmentInformation::EnvironmentInformation.new(:do_not_run_yet)
311
- _.disable_colours
312
- _.be_quiet
313
- _.menu('--really-everything')
314
- _.run
315
- return _.string
316
- end
317
-
318
- end
319
-
320
- if __FILE__ == $PROGRAM_NAME
321
- puts EnvironmentInformation.return_version_of_mpc
322
- puts EnvironmentInformation.return_version_of_boost
323
- EnvironmentInformation.test
324
- end
@@ -1,31 +0,0 @@
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
@@ -1,39 +0,0 @@
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
@@ -1,61 +0,0 @@
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
@@ -1,45 +0,0 @@
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/cookbooks/url/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
@@ -1,84 +0,0 @@
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
@@ -1,30 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # require 'environment_information/toplevel_methods/return_alias_to.rb'
6
- # EnvironmentInformation.return_alias_to
7
- # =========================================================================== #
8
- module EnvironmentInformation
9
-
10
- # ========================================================================= #
11
- # === EnvironmentInformation.return_alias_to
12
- #
13
- # This method will return some abbreviations to programs.
14
- # ========================================================================= #
15
- def self.return_alias_to(i)
16
- if i.is_a? Array
17
- i = i.first
18
- end
19
- case i.to_sym
20
- when :find
21
- i = :findutils
22
- when :diff
23
- i = :diffutils
24
- when :yacc
25
- i = :bison
26
- end
27
- return i # Always return something.
28
- end
29
-
30
- end
@@ -1,28 +0,0 @@
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