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