environment_information 1.4.124

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.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1322 -0
  3. data/bin/envi +7 -0
  4. data/bin/fast_envi +7 -0
  5. data/doc/README.gen +1058 -0
  6. data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +55 -0
  7. data/environment_information.gemspec +135 -0
  8. data/lib/environment_information/base/base.rb +166 -0
  9. data/lib/environment_information/class/class.rb +2580 -0
  10. data/lib/environment_information/class/colours.rb +282 -0
  11. data/lib/environment_information/colours/colours.rb +224 -0
  12. data/lib/environment_information/colours/sfancy.rb +19 -0
  13. data/lib/environment_information/colours/simp.rb +19 -0
  14. data/lib/environment_information/constants/array_tracked_components.rb +210 -0
  15. data/lib/environment_information/constants/constants.rb +17 -0
  16. data/lib/environment_information/constants/encoding.rb +21 -0
  17. data/lib/environment_information/constants/error_line.rb +17 -0
  18. data/lib/environment_information/constants/file_constants.rb +102 -0
  19. data/lib/environment_information/constants/misc.rb +86 -0
  20. data/lib/environment_information/constants/namespace.rb +14 -0
  21. data/lib/environment_information/constants/newline.rb +16 -0
  22. data/lib/environment_information/constants/regex.rb +30 -0
  23. data/lib/environment_information/constants/temp_directory.rb +52 -0
  24. data/lib/environment_information/gui/jruby/environment_information.rb +77 -0
  25. data/lib/environment_information/gui/shared_code/environment_information/environment_information_module.rb +99 -0
  26. data/lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb +419 -0
  27. data/lib/environment_information/misc_components/README.md +3 -0
  28. data/lib/environment_information/misc_components/cflags.rb +36 -0
  29. data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
  30. data/lib/environment_information/misc_components/operating_system.rb +54 -0
  31. data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
  32. data/lib/environment_information/misc_components/ram.rb +30 -0
  33. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
  34. data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
  35. data/lib/environment_information/project/project.rb +27 -0
  36. data/lib/environment_information/queries/README.md +2 -0
  37. data/lib/environment_information/queries/complex_version.rb +273 -0
  38. data/lib/environment_information/queries/pkg_config.rb +125 -0
  39. data/lib/environment_information/queries/simple_version.rb +272 -0
  40. data/lib/environment_information/requires/require_asciitable.rb +15 -0
  41. data/lib/environment_information/requires/require_the_constants.rb +7 -0
  42. data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
  43. data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
  44. data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
  45. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +153 -0
  46. data/lib/environment_information/toplevel_methods/cd.rb +16 -0
  47. data/lib/environment_information/toplevel_methods/e.rb +43 -0
  48. data/lib/environment_information/toplevel_methods/hash.rb +65 -0
  49. data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
  50. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
  51. data/lib/environment_information/toplevel_methods/menu.rb +90 -0
  52. data/lib/environment_information/toplevel_methods/misc.rb +324 -0
  53. data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
  54. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
  55. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
  56. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
  57. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
  58. data/lib/environment_information/toplevel_methods/return_alias_to.rb +30 -0
  59. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
  60. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
  61. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
  62. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +182 -0
  63. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
  64. data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
  65. data/lib/environment_information/version/version.rb +25 -0
  66. data/lib/environment_information/www/sinatra_interface.rb +213 -0
  67. data/lib/environment_information/www/webobject_interface.cgi +29 -0
  68. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +15 -0
  69. data/lib/environment_information/yaml/array_lfs_core_programs.yml +37 -0
  70. data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
  71. data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
  72. data/lib/environment_information/yaml/array_tracked_programs.yml +235 -0
  73. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +37 -0
  74. data/lib/environment_information/yaml/colours.yml +3 -0
  75. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +284 -0
  76. data/lib/environment_information.rb +5 -0
  77. data/test/testing_environment_information.rb +26 -0
  78. data/test/testing_missing_components.rb +9 -0
  79. data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
  80. metadata +177 -0
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformationModule
6
+ # =========================================================================== #
7
+ # require 'environment_information/gui/shared_code/environment_information/environment_information_module.rb'
8
+ # include ::EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformationModule
9
+ # =========================================================================== #
10
+ module EnvironmentInformation
11
+
12
+ module GUI
13
+
14
+ module UniversalWidgets
15
+
16
+ module EnvironmentInformationModule # === EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformationModule
17
+
18
+ require 'environment_information/toplevel_methods/misc.rb'
19
+
20
+ # ========================================================================= #
21
+ # === N
22
+ # ========================================================================= #
23
+ N = "\n"
24
+
25
+ # ========================================================================= #
26
+ # === TITLE
27
+ # ========================================================================= #
28
+ TITLE = 'Environment Information'
29
+
30
+ # ========================================================================= #
31
+ # === USE_THIS_FONT
32
+ # ========================================================================= #
33
+ USE_THIS_FONT = 'Mono 20'
34
+
35
+ # ========================================================================= #
36
+ # === LARGER_FONT
37
+ # ========================================================================= #
38
+ LARGER_FONT = :hack_25
39
+
40
+ # ========================================================================= #
41
+ # === SMALLER_FONT
42
+ # ========================================================================= #
43
+ SMALLER_FONT = :hack_20
44
+
45
+ # ========================================================================= #
46
+ # === FONT_SIZE
47
+ # ========================================================================= #
48
+ FONT_SIZE = '19'
49
+
50
+ # ========================================================================= #
51
+ # === reset_the_variables
52
+ # ========================================================================= #
53
+ def reset_the_variables
54
+ # ======================================================================= #
55
+ # === @display_information_on_the_commandline
56
+ #
57
+ # If the next variable is set to true then information will be
58
+ # displayed on the commandline.
59
+ # ======================================================================= #
60
+ @display_information_on_the_commandline = true
61
+ assign_the_environment_information_dataset_to_the_data_variable
62
+ end
63
+
64
+ # ========================================================================= #
65
+ # === assign_the_environment_information_dataset_to_the_data_variable
66
+ # ========================================================================= #
67
+ def assign_the_environment_information_dataset_to_the_data_variable
68
+ @data = ::EnvironmentInformation.initialize_hash
69
+ end
70
+
71
+ # ========================================================================= #
72
+ # === smaller_font?
73
+ # ========================================================================= #
74
+ def smaller_font?
75
+ SMALLER_FONT
76
+ end
77
+
78
+ # ========================================================================= #
79
+ # === favicon?
80
+ # ========================================================================= #
81
+ def favicon?
82
+ :tabble
83
+ end
84
+
85
+ # ========================================================================= #
86
+ # === border_size?
87
+ # ========================================================================= #
88
+ def border_size?
89
+ 10
90
+ end
91
+
92
+ # ========================================================================= #
93
+ # === padding?
94
+ # ========================================================================= #
95
+ def padding?
96
+ 2
97
+ end
98
+
99
+ end; end; end; end
@@ -0,0 +1,419 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation
6
+ #
7
+ # Usage example:
8
+ #
9
+ # EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation.new(ARGV)
10
+ #
11
+ # =========================================================================== #
12
+ # require 'ascii_paradise/gui/universal_widgets/environment_information/environment_information.rb'
13
+ # =========================================================================== #
14
+ require 'environment_information/base/base.rb'
15
+
16
+ module EnvironmentInformation
17
+
18
+ module GUI
19
+
20
+ module UniversalWidgets
21
+
22
+ class EnvironmentInformation < ::EnvironmentInformation::Base # === EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation
23
+
24
+ require 'universal_widgets/base_module/base_module.rb'
25
+ include ::UniversalWidgets::BaseModule
26
+
27
+ require 'environment_information/toplevel_methods/return_version_of_this_program.rb'
28
+
29
+ # ========================================================================= #
30
+ # === WIDTH
31
+ # ========================================================================= #
32
+ WIDTH = '60% or minimum 1280px'
33
+
34
+ # ========================================================================= #
35
+ # === HEIGHT
36
+ # ========================================================================= #
37
+ HEIGHT = '30% or minimum 880px'
38
+
39
+ # ========================================================================= #
40
+ # === initialize
41
+ # ========================================================================= #
42
+ def initialize(
43
+ commandline_arguments = nil,
44
+ run_already = true
45
+ )
46
+ super(:vertical) if use_gtk3?
47
+ determine_the_GUI_to_be_used(commandline_arguments) # This must come first, even before reset().
48
+ reset
49
+ set_commandline_arguments(
50
+ commandline_arguments
51
+ )
52
+ on_delete_event_quit_the_application
53
+ run if run_already
54
+ end
55
+
56
+ # ========================================================================= #
57
+ # === reset (reset tag)
58
+ # ========================================================================= #
59
+ def reset
60
+ super() if respond_to?(:super)
61
+ reset_the_shared_module # This can come early.
62
+ reset_the_base_module
63
+ reset_the_internal_variables
64
+ infer_the_namespace
65
+ # ======================================================================= #
66
+ # === @configuration
67
+ # ======================================================================= #
68
+ @configuration = [true, __dir__, namespace?]
69
+ # ======================================================================= #
70
+ # === Set the title, width, height and the font in use.
71
+ # ======================================================================= #
72
+ title_width_height_font(TITLE, WIDTH, HEIGHT, "Mono #{FONT_SIZE}")
73
+ if use_gtk3?
74
+ handle_CSS_rules
75
+ end
76
+ infer_the_size_automatically
77
+ reset_the_variables
78
+ # ======================================================================= #
79
+ # === @list_store
80
+ # ======================================================================= #
81
+ @list_store = ::Gtk::ListStore.new(String, String)
82
+ end
83
+
84
+ # ========================================================================= #
85
+ # === create_the_toolbar
86
+ #
87
+ # This will create the toolbar on top of the widget.
88
+ # ========================================================================= #
89
+ def create_the_toolbar
90
+ @toolbar = create_toolbar
91
+ # ======================================================================= #
92
+ # (1) Add the refresh-button next.
93
+ # ======================================================================= #
94
+ button_refresh = create_button(:refresh)
95
+ button_refresh.no_relief
96
+ button_refresh.on_clicked {
97
+ do_update_the_main_content_of_the_widget
98
+ }
99
+ button_refresh.hint = '<b>Click</b> on this button in order to '\
100
+ 'refresh the information shown below.'
101
+ @toolbar << button_refresh
102
+ # ======================================================================= #
103
+ # (2) Add a pin-emoji next, to assign to the xorg-buffer upon clicking
104
+ # on it.
105
+ # ======================================================================= #
106
+ pin_emoji = emoji(:pin)
107
+ event_box_for_the_pin_emoji = event_box(pin_emoji)
108
+ event_box_for_the_pin_emoji.on_clicked {
109
+ do_assign_the_current_selection_to_the_xorg_buffer
110
+ }
111
+ pin_emoji.hint = '<b>Click</b> on this button to assign the '\
112
+ 'current selection to the xorg-buffer.'
113
+ @toolbar << event_box_for_the_pin_emoji
114
+ # ======================================================================= #
115
+ # (2) This belongs to the pin-emoji actually; the functionality should
116
+ # be regarded as a "cohesive unit".
117
+ # ======================================================================= #
118
+ @button_assign_to_the_xorg_buffer = button_xorg_buffer(label: 'Xorg')
119
+ @button_assign_to_the_xorg_buffer.no_relief
120
+ @button_assign_to_the_xorg_buffer.on_clicked {
121
+ do_assign_the_current_selection_to_the_xorg_buffer
122
+ }
123
+ @toolbar << @button_assign_to_the_xorg_buffer
124
+ end
125
+
126
+ # ========================================================================= #
127
+ # === currently_selected
128
+ #
129
+ # Will show both key and version.
130
+ # ========================================================================= #
131
+ def currently_selected
132
+ _ = ''.dup
133
+ if @tree_view and @tree_view.selection
134
+ @tree_view.selection.selected_each {|list_store, tree_path, tree_iter|
135
+ if tree_iter[0]
136
+ name_of_the_program = tree_iter[0].strip
137
+ else
138
+ name_of_the_program = 'unknown'
139
+ end
140
+ version_of_the_program = tree_iter[1]
141
+ _ << "#{name_of_the_program} #{version_of_the_program}"
142
+ }
143
+ end
144
+ return _
145
+ end; alias return_the_current_selection_of_the_treeview_widget currently_selected # === return_the_current_selection_of_the_treeview_widget
146
+
147
+ # ========================================================================= #
148
+ # === do_assign_the_current_selection_to_the_xorg_buffer
149
+ # ========================================================================= #
150
+ def do_assign_the_current_selection_to_the_xorg_buffer(
151
+ i = return_the_current_selection_of_the_treeview_widget
152
+ )
153
+ @button_assign_to_the_xorg_buffer.attach(i)
154
+ end
155
+
156
+ # ========================================================================= #
157
+ # === do_update_the_main_content_of_the_widget
158
+ # ========================================================================= #
159
+ def do_update_the_main_content_of_the_widget
160
+ assign_the_environment_information_dataset_to_the_data_variable
161
+ @list_store.clear
162
+ @data.each {|line|
163
+ name, version = *line # Decompose line.
164
+ iter = @list_store.append
165
+ if version.nil? or version.to_s.empty?
166
+ version = '[Not installed.]'
167
+ end
168
+ iter.set_value(0, name)
169
+ iter.set_value(1, version)
170
+ }
171
+ end
172
+
173
+ # ========================================================================= #
174
+ # === add_status_icon
175
+ # ========================================================================= #
176
+ def add_status_icon
177
+ if use_gtk3?
178
+ _ = create_status_icon(:dialog_info)
179
+ # ======================================================================= #
180
+ # Add a menu and a quit-button too.
181
+ # ======================================================================= #
182
+ menu = create_menu
183
+ quit = create_image_menu_item(:quit)
184
+ quit.on_activate { ::Gtk.main_quit }
185
+ menu.append(quit)
186
+ menu.show_all
187
+ _.signal_connect(:popup_menu) { |icon, button, time|
188
+ menu.popup(nil, nil, button, time)
189
+ }
190
+ return _
191
+ end
192
+ end
193
+
194
+ # ========================================================================= #
195
+ # === create_the_tree_view
196
+ #
197
+ # The TreeView widget is the main widget which allows the user to
198
+ # display environment-related information about installed
199
+ # programs.
200
+ # ========================================================================= #
201
+ def create_the_tree_view
202
+ @tree_view = ::Gtk::TreeView.new(@list_store) # rf ruby gtk_TreeView
203
+ @tree_view.do_select_multiple # Allow multiple selections.
204
+ @tree_view.use_clickable_headers
205
+ # ======================================================================= #
206
+ # ruby-gtk3
207
+ # ======================================================================= #
208
+ @tree_view.enable_model_drag_source(
209
+ :button1_mask,
210
+ [ ['GTK_TREE_MODEL_ROW', 0, 0] ],
211
+ Gdk::DragAction::COPY|Gdk::DragAction::MOVE
212
+ )
213
+ @tree_view.enable_model_drag_dest([
214
+ ['GTK_TREE_MODEL_ROW', 0, 0] ],
215
+ Gdk::DragAction::COPY|Gdk::DragAction::MOVE
216
+ )
217
+ @tree_view.signal_connect(:row_activated) {
218
+ # puts "hello"
219
+ }
220
+ # ========================================================================= #
221
+ # Respond to mouse-button press events. This is currently not in use
222
+ # really.
223
+ # ========================================================================= #
224
+ @tree_view.on_button_press_event { |widget, event|
225
+ if mouse_button_double_click?(event)
226
+ # e 'MouseButton: double click event.'
227
+ # ^^^ Currently we do not handle this event.
228
+ elsif left_mouse_button_clicked?(event)
229
+ # e 'MouseButton: left-click event (once).'
230
+ elsif right_mouse_button_clicked?(event)
231
+ # e 'MouseButton: right-click event (once).'
232
+ end
233
+ }
234
+ @tree_view.selection.set_mode(::Gtk::SelectionMode::MULTIPLE)
235
+ @tree_view.selection.signal_connect(:changed) {|entry|
236
+ entry.each {|model, path, inner_array|
237
+ if @display_information_on_the_commandline
238
+ if inner_array[0]
239
+ name_of_the_program = inner_array[0].strip
240
+ else
241
+ name_of_the_program = '(unknown'
242
+ end
243
+ version_of_the_program = inner_array[1]
244
+ result = Colours.steelblue(
245
+ name_of_the_program.ljust(25)
246
+ ).dup
247
+ if ::EnvironmentInformation.is_this_a_registered_program?(name_of_the_program)
248
+ result << 'Version: '
249
+ end
250
+ result << Colours.lightgreen(version_of_the_program.to_s)
251
+ e result
252
+ end
253
+ }
254
+ }
255
+ @tree_view.resizable_headers
256
+ end
257
+
258
+ # ========================================================================= #
259
+ # === handle_CSS_rules (CSS tag)
260
+ # ========================================================================= #
261
+ def handle_CSS_rules
262
+ use_gtk_paradise_project_css_file
263
+ append_project_css_file
264
+ more_CSS_then_apply_it '
265
+
266
+
267
+ '
268
+ end
269
+
270
+ # ========================================================================= #
271
+ # === reset_the_shared_module
272
+ #
273
+ # This method can be used for ruby-gtk3 and ruby-libui, among other
274
+ # toolkits.
275
+ # ========================================================================= #
276
+ def reset_the_shared_module
277
+ end
278
+
279
+ # ========================================================================= #
280
+ # === EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.width
281
+ # ========================================================================= #
282
+ def self.width
283
+ WIDTH
284
+ end
285
+
286
+ # ========================================================================= #
287
+ # === EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.height
288
+ # ========================================================================= #
289
+ def self.height
290
+ HEIGHT
291
+ end
292
+
293
+ # ========================================================================= #
294
+ # === do_all_startup_related_actions
295
+ # ========================================================================= #
296
+ def do_all_startup_related_actions
297
+ end
298
+
299
+ # ========================================================================= #
300
+ # === connect_the_skeleton (connect tag)
301
+ # ========================================================================= #
302
+ def connect_the_skeleton
303
+ abort_on_exception
304
+
305
+ outer_vbox = create_vbox
306
+
307
+ # ======================================================================= #
308
+ # Append the information contained in our @data variable to the
309
+ # ListStore object next. This will yield an Array.
310
+ # ======================================================================= #
311
+ do_update_the_main_content_of_the_widget
312
+ @tree_view.append('Name', @renderer, text: 0)
313
+ @tree_view.append('Version', @renderer, text: 1)
314
+ @tree_view.the_headers_are_clickable
315
+ @tree_view.is_sortable
316
+ @tree_view.on_key_press_event { |w, event|
317
+ case Gdk::Keyval.to_name(event.keyval)
318
+ when 'Return','KP_Enter'
319
+ e currently_selected
320
+ end
321
+ }
322
+ vbox = create_vbox
323
+ vbox.add(@toolbar)
324
+ @scrolled_window = create_scrolled_window(@tree_view)
325
+ @scrolled_window.set_size_request(600, 600)
326
+ vbox.maximal(@scrolled_window, 2)
327
+ outer_vbox.maximal(vbox)
328
+ outer_vbox.minimal(add_status_icon) if use_gtk3?
329
+
330
+ window = create_window_or_runner
331
+ window << outer_vbox
332
+
333
+ properly_prepare_this_window(window,
334
+ {
335
+ title: title?,
336
+ font: font?,
337
+ width: width?,
338
+ height: height?,
339
+ padding: padding?,
340
+ border_size: border_size?
341
+ }
342
+ )
343
+ window.show_all
344
+ window.top_left
345
+ do_all_startup_related_actions
346
+ run_main
347
+ end
348
+
349
+ # ========================================================================= #
350
+ # === create_the_skeleton (create tag, skeleton tag)
351
+ # ========================================================================= #
352
+ def create_the_skeleton
353
+ create_the_toolbar
354
+ create_the_tree_view
355
+ @renderer = create_cell_renderer_text
356
+ end
357
+
358
+ # ========================================================================= #
359
+ # === run (run tag)
360
+ # ========================================================================= #
361
+ def run
362
+ run_super
363
+ end
364
+
365
+ # ========================================================================= #
366
+ # === EnvironmentInformation::GUI::Gtk::EnvironmentInformation.run
367
+ # ========================================================================= #
368
+ def self.run(
369
+ i = ARGV
370
+ )
371
+ require 'gtk_paradise/run'
372
+ _ = ::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.new(i)
373
+ r = ::Gtk.run
374
+ _.set_parent_widget(r) # Must come before we enable the key-combinations.
375
+ r << _
376
+ r.automatic_size_then_automatic_title
377
+ r.enable_quick_exit
378
+ r.set_background :white
379
+ r.top_left_then_run
380
+ end; self.instance_eval { alias start_gui_application run } # === EnvironmentInformation::GUI::Gtk::Widget.start_gui_application
381
+
382
+ # ========================================================================= #
383
+ # === EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation[]
384
+ # ========================================================================= #
385
+ def self.[](i = ARGV)
386
+ new(i)
387
+ end
388
+
389
+ end; end; end
390
+
391
+ # =========================================================================== #
392
+ # === EnvironmentInformation.gtk_bindings
393
+ # =========================================================================== #
394
+ def self.gtk_bindings
395
+ ::EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.new
396
+ end
397
+
398
+ # =========================================================================== #
399
+ # === EnvironmentInformation.run_gtk
400
+ #
401
+ # Use this method if you wish to run the gtk-component of the
402
+ # EnvironmentInformation project.
403
+ # =========================================================================== #
404
+ def self.run_gtk
405
+ require 'gtk_paradise/run'
406
+ _ = ::EnvironmentInformation.gtk_bindings
407
+ r = ::Gtk.run
408
+ r << _ # ← Add the widget here.
409
+ r.add_shortcut(1, 'focus(:left)', :alt)
410
+ r.modify_background(:normal, :white)
411
+ r.automatic_title
412
+ r.top_left_then_run
413
+ end
414
+
415
+ end
416
+
417
+ if __FILE__ == $PROGRAM_NAME
418
+ EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation.new(ARGV)
419
+ end # guishell
@@ -0,0 +1,3 @@
1
+ Ruby files in this directory relate to components that are not really
2
+ programs, such as CFLAGS, or the number of processors, or the amount
3
+ of RAM on a given computer system.
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/misc_components/cflags.rb'
6
+ # EnvironmentInformation.cflags_in_use?
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ # ========================================================================= #
11
+ # === EnvironmentInformation.cflags? (cflags tag)
12
+ #
13
+ # The following is equivalent to the value stored in the variable
14
+ # $CFLAGS, which on unix-like systems may be obtained by issuing
15
+ # the following command:
16
+ #
17
+ # echo $CFLAGS
18
+ #
19
+ # The output may be like this:
20
+ #
21
+ # -O2 -fPIC -fno-strict-overflow -Wno-error
22
+ #
23
+ # ========================================================================= #
24
+ def self.cflags?
25
+ version = ENV['CFLAGS'].to_s.strip
26
+ version = '<none>' if version.empty? # Display special status if it is empty.
27
+ version
28
+ end; self.instance_eval { alias cflags_in_use? cflags? } # === EnvironmentInformation.cflags_in_use?
29
+ self.instance_eval { alias return_version_of_cflags cflags? } # === EnvironmentInformation.return_version_of_cflags
30
+ self.instance_eval { alias cflags cflags? } # === EnvironmentInformation.cflags
31
+
32
+ end
33
+
34
+ if __FILE__ == $PROGRAM_NAME
35
+ puts EnvironmentInformation.cflags?
36
+ end
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/misc_components/cpuinfo.rb'
6
+ # EnvironmentInformation.cpuinfo?
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ require 'environment_information/constants/newline.rb'
11
+ require 'environment_information/constants/error_line.rb'
12
+
13
+ # ========================================================================= #
14
+ # === EnvironmentInformation.cpuinfo? (cpuinfo tag)
15
+ #
16
+ # This method currently relies on /proc/cpuinfo, thus favouring
17
+ # Linux-based systems.
18
+ #
19
+ # The output will be similar to this:
20
+ #
21
+ # AMD A8-7600 Radeon R7, 10 Compute Cores 4C+6G, 4 cores
22
+ #
23
+ # It will become the display part of "CPU Model".
24
+ # ========================================================================= #
25
+ def self.cpuinfo?
26
+ result = '/proc/cpuinfo'
27
+ if File.exist? result
28
+ readlines = File.readlines(result)
29
+ _ = readlines.grep(/model name/).first.chomp
30
+ splitted = _.split(':')
31
+ _ = splitted[1].strip # => "model name\t: AMD Sempron(tm) 145 Processor"
32
+ # ===================================================================== #
33
+ # Next, add the amount of cores. We use "nproc" for this but "lscpu"
34
+ # also contains this information. The following regex could be used
35
+ # for lscpu:
36
+ #
37
+ # Core\(s\) per socket: (.+)
38
+ #
39
+ # Ok, we use lscpu for now.
40
+ # ===================================================================== #
41
+ n_cores = `nproc --all`.strip
42
+ case n_cores.to_s
43
+ when '1'
44
+ n_cores << ' core' # Singular.
45
+ else
46
+ n_cores << ' cores' # Plural then.
47
+ end
48
+ _ << ", #{n_cores}" unless n_cores.empty?
49
+ result = _
50
+ else
51
+ result = nil
52
+ end
53
+ result
54
+ end; self.instance_eval { alias append_operating_system_cpuinfo cpuinfo? } # === EnvironmentInformation.append_operating_system_cpuinfo
55
+ self.instance_eval { alias cpu_model cpuinfo? } # === EnvironmentInformation.cpu_model
56
+ self.instance_eval { alias cpu_model? cpuinfo? } # === EnvironmentInformation.cpu_model?
57
+ self.instance_eval { alias return_version_of_cpuinfo cpuinfo? } # === EnvironmentInformation.return_version_of_cpuinfo
58
+ self.instance_eval { alias cpuinfo cpuinfo? } # === EnvironmentInformation.cpuinfo
59
+
60
+ end
61
+
62
+ if __FILE__ == $PROGRAM_NAME
63
+ puts EnvironmentInformation.cpuinfo?
64
+ end
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/misc_components/operating_system.rb'
6
+ # =========================================================================== #
7
+ module EnvironmentInformation
8
+
9
+ require 'environment_information/constants/newline.rb'
10
+ require 'environment_information/constants/error_line.rb'
11
+
12
+ # ========================================================================= #
13
+ # === EnvironmentInformation.operating_system (os tag)
14
+ #
15
+ # This method is also known as "bit type".
16
+ #
17
+ # The return value of this method may be a String such as this one here:
18
+ #
19
+ # "GNU/Linux"
20
+ #
21
+ # This is then further modified a bit to drop the "GNU/" part
22
+ # specifically.
23
+ #
24
+ # ========================================================================= #
25
+ def self.operating_system
26
+ cmd = 'uname -mo'
27
+ result = `#{cmd}`.chomp
28
+ if result.start_with? 'GNU'
29
+ # ===================================================================== #
30
+ # The next part removes 'GNU/' specifically. It is a simpler name
31
+ # than "GNU Linux" and variants, just as "BSD" is simpler than
32
+ # e. g. "FreeBSD". You can reason that it may be "less accurate",
33
+ # but it makes the notification-part of this gem simpler.
34
+ # ===================================================================== #
35
+ result.sub!(/^GNU\//,'') # Experimental as of Sep 2019.
36
+ end
37
+ if result.include? ' '
38
+ result = result.split(' ').last
39
+ end
40
+ result
41
+ end; self.instance_eval { alias operating_system? operating_system } # === EnvironmentInformation.operating_system?
42
+ self.instance_eval { alias operating_system_information? operating_system } # === EnvironmentInformation.operating_system_information
43
+ self.instance_eval { alias add_operating_system_information operating_system } # === EnvironmentInformation.add_operating_system_information
44
+ self.instance_eval { alias append_operating_system_in_use operating_system } # === EnvironmentInformation.append_operating_system_in_use
45
+ self.instance_eval { alias add_os_information operating_system } # === EnvironmentInformation.add_os_information
46
+ self.instance_eval { alias operating_system_in_use? operating_system } # === EnvironmentInformation.operating_system_in_use?
47
+ self.instance_eval { alias return_version_of_operating_system operating_system } # === EnvironmentInformation.return_version_of_operating_system
48
+ self.instance_eval { alias return_version_of_operating_system_in_use operating_system } # === EnvironmentInformation.return_version_of_operating_system_in_use
49
+
50
+ end
51
+
52
+ if __FILE__ == $PROGRAM_NAME
53
+ puts EnvironmentInformation.operating_system
54
+ end # envi_operating_system