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.

Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1287 -0
  3. data/bin/envi +7 -0
  4. data/bin/fast_envi +7 -0
  5. data/doc/README.gen +1044 -0
  6. data/doc/todo/TODO_FOR_THE_ENVIRONMENT_INFORMATION_PROJECT.md +48 -0
  7. data/environment_information.gemspec +135 -0
  8. data/lib/environment_information/base/base.rb +166 -0
  9. data/lib/environment_information/class/class.rb +2829 -0
  10. data/lib/environment_information/colours/colours.rb +224 -0
  11. data/lib/environment_information/colours/sfancy.rb +19 -0
  12. data/lib/environment_information/colours/simp.rb +19 -0
  13. data/lib/environment_information/constants/array_tracked_components.rb +210 -0
  14. data/lib/environment_information/constants/constants.rb +17 -0
  15. data/lib/environment_information/constants/encoding.rb +21 -0
  16. data/lib/environment_information/constants/error_line.rb +17 -0
  17. data/lib/environment_information/constants/file_constants.rb +102 -0
  18. data/lib/environment_information/constants/misc.rb +86 -0
  19. data/lib/environment_information/constants/namespace.rb +14 -0
  20. data/lib/environment_information/constants/newline.rb +16 -0
  21. data/lib/environment_information/constants/regex.rb +30 -0
  22. data/lib/environment_information/constants/temp_directory.rb +52 -0
  23. data/lib/environment_information/gui/gtk2/environment_information.rb +35 -0
  24. data/lib/environment_information/gui/gtk3/environment_information.rb +34 -0
  25. data/lib/environment_information/gui/libui/environment_information.rb +74 -0
  26. data/lib/environment_information/gui/shared_code/environment_information_module.rb +409 -0
  27. data/lib/environment_information/misc_components/README.md +3 -0
  28. data/lib/environment_information/misc_components/cflags.rb +36 -0
  29. data/lib/environment_information/misc_components/cpuinfo.rb +64 -0
  30. data/lib/environment_information/misc_components/operating_system.rb +54 -0
  31. data/lib/environment_information/misc_components/operating_system_bit_type.rb +42 -0
  32. data/lib/environment_information/misc_components/ram.rb +30 -0
  33. data/lib/environment_information/misc_components/rubygems_installation_directory.rb +54 -0
  34. data/lib/environment_information/misc_components/screen_resolution.rb +50 -0
  35. data/lib/environment_information/project/project.rb +27 -0
  36. data/lib/environment_information/queries/README.md +2 -0
  37. data/lib/environment_information/queries/complex_version.rb +273 -0
  38. data/lib/environment_information/queries/pkg_config.rb +125 -0
  39. data/lib/environment_information/queries/simple_version.rb +217 -0
  40. data/lib/environment_information/requires/require_asciitable.rb +15 -0
  41. data/lib/environment_information/requires/require_the_constants.rb +7 -0
  42. data/lib/environment_information/requires/require_the_environment_information_project.rb +23 -0
  43. data/lib/environment_information/requires/require_the_individual_misc_components.rb +30 -0
  44. data/lib/environment_information/requires/require_the_toplevel_methods.rb +22 -0
  45. data/lib/environment_information/toplevel_methods/autogenerate_all_relevant_methods.rb +152 -0
  46. data/lib/environment_information/toplevel_methods/cd.rb +16 -0
  47. data/lib/environment_information/toplevel_methods/e.rb +43 -0
  48. data/lib/environment_information/toplevel_methods/hash.rb +60 -0
  49. data/lib/environment_information/toplevel_methods/internet_is_available.rb +30 -0
  50. data/lib/environment_information/toplevel_methods/is_on_roebe.rb +16 -0
  51. data/lib/environment_information/toplevel_methods/menu.rb +90 -0
  52. data/lib/environment_information/toplevel_methods/misc.rb +322 -0
  53. data/lib/environment_information/toplevel_methods/n_subcommands.rb +31 -0
  54. data/lib/environment_information/toplevel_methods/prefix_to_use.rb +39 -0
  55. data/lib/environment_information/toplevel_methods/register_this_component_is_missing.rb +61 -0
  56. data/lib/environment_information/toplevel_methods/remote_url_of_this_program.rb +45 -0
  57. data/lib/environment_information/toplevel_methods/replay_from_the_stored_file.rb +84 -0
  58. data/lib/environment_information/toplevel_methods/return_alias_to.rb +30 -0
  59. data/lib/environment_information/toplevel_methods/return_pkgconfig_based_programs.rb +28 -0
  60. data/lib/environment_information/toplevel_methods/return_remote_gtk2_version.rb +54 -0
  61. data/lib/environment_information/toplevel_methods/return_simple_version_based_programs.rb +28 -0
  62. data/lib/environment_information/toplevel_methods/return_version_of_this_program.rb +182 -0
  63. data/lib/environment_information/toplevel_methods/show_all_available_components.rb +192 -0
  64. data/lib/environment_information/toplevel_methods/write_what_into.rb +24 -0
  65. data/lib/environment_information/version/version.rb +25 -0
  66. data/lib/environment_information/www/sinatra_interface.rb +213 -0
  67. data/lib/environment_information/www/webobject_interface.cgi +29 -0
  68. data/lib/environment_information/yaml/array_default_programs_on_linux.yml +15 -0
  69. data/lib/environment_information/yaml/array_lfs_core_programs.yml +37 -0
  70. data/lib/environment_information/yaml/array_science_cluster.yml +12 -0
  71. data/lib/environment_information/yaml/array_tracked_non_programs.yml +13 -0
  72. data/lib/environment_information/yaml/array_tracked_programs.yml +215 -0
  73. data/lib/environment_information/yaml/array_tracked_xorg_components.yml +37 -0
  74. data/lib/environment_information/yaml/colours.yml +3 -0
  75. data/lib/environment_information/yaml/query_to_use_for_the_individual_components.yml +264 -0
  76. data/lib/environment_information.rb +5 -0
  77. data/test/testing_environment_information.rb +26 -0
  78. data/test/testing_missing_components.rb +9 -0
  79. data/test/testing_prefix_for_the_environment_information_project.rb +20 -0
  80. metadata +177 -0
@@ -0,0 +1,409 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === EnvironmentInformation::GUI::Gtk::EnvironmentInformationModule
6
+ # =========================================================================== #
7
+ # require 'environment_information/gui/shared_code/environment_information_module.rb'
8
+ # include ::EnvironmentInformation::EnvironmentInformation::GUI::Gtk::BindingModule
9
+ # =========================================================================== #
10
+ module EnvironmentInformation
11
+
12
+ class EnvironmentInformation < ::EnvironmentInformation::Base
13
+
14
+ module GUI
15
+
16
+ module Gtk
17
+
18
+ module EnvironmentInformationModule
19
+
20
+ require 'gtk_paradise/requires/require_the_base_module.rb'
21
+ include ::Gtk::BaseModule
22
+
23
+ begin
24
+ require 'colours'
25
+ include Colours::E
26
+ rescue LoadError; end
27
+
28
+ # ========================================================================= #
29
+ # === N
30
+ # ========================================================================= #
31
+ N = "\n"
32
+
33
+ # ========================================================================= #
34
+ # === TITLE
35
+ # ========================================================================= #
36
+ TITLE = 'Environment Information'
37
+
38
+ # ========================================================================= #
39
+ # === WIDTH
40
+ # ========================================================================= #
41
+ WIDTH = '98%'
42
+
43
+ # ========================================================================= #
44
+ # === HEIGHT
45
+ # ========================================================================= #
46
+ HEIGHT = '80%'
47
+
48
+ # ========================================================================= #
49
+ # === initialize
50
+ # ========================================================================= #
51
+ def initialize(
52
+ optional_file = nil,
53
+ run_already = true
54
+ )
55
+ super(:vertical)
56
+ reset
57
+ run if run_already
58
+ end
59
+
60
+ # ========================================================================= #
61
+ # === reset
62
+ # ========================================================================= #
63
+ def reset
64
+ reset_the_internal_variables
65
+ # ======================================================================= #
66
+ # === @configuration
67
+ # ======================================================================= #
68
+ @configuration = [true, __dir__, NAMESPACE]
69
+ # ======================================================================= #
70
+ # === @title
71
+ # ======================================================================= #
72
+ set_title(TITLE)
73
+ # ======================================================================= #
74
+ # === @width
75
+ # ======================================================================= #
76
+ set_width(WIDTH)
77
+ set_height(HEIGHT)
78
+ # ======================================================================= #
79
+ # === @data
80
+ # ======================================================================= #
81
+ assign_the_environment_information_dataset_to_the_data_variable
82
+ # ======================================================================= #
83
+ # === @display_information_on_the_commandline
84
+ #
85
+ # If the next variable is set to true then information will be
86
+ # displayed on the commandline.
87
+ # ======================================================================= #
88
+ @display_information_on_the_commandline = true
89
+ # ======================================================================= #
90
+ # === @list_store
91
+ # ======================================================================= #
92
+ @list_store = ::Gtk::ListStore.new(String, String)
93
+ increase_font_size
94
+ use_gtk_paradise_css_file
95
+ infer_the_size_automatically
96
+ end
97
+
98
+ # ========================================================================= #
99
+ # === connect_skeleton
100
+ # ========================================================================= #
101
+ def connect_skeleton
102
+ end
103
+
104
+ # ========================================================================= #
105
+ # === border_size?
106
+ # ========================================================================= #
107
+ def border_size?
108
+ 0
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === create_skeleton
113
+ # ========================================================================= #
114
+ def create_skeleton
115
+ create_toolbar
116
+ create_gtk_tree_view
117
+ @renderer = gtk_cell_renderer_text
118
+ end
119
+
120
+ # ========================================================================= #
121
+ # === create_toolbar
122
+ #
123
+ # This will create the toolbar on top of the widget.
124
+ # ========================================================================= #
125
+ def create_toolbar
126
+ @toolbar = gtk_toolbar
127
+ @toolbar.append_space if ::Gtk.use_gtk2?
128
+ # ======================================================================= #
129
+ # (1) Add the refresh-button next.
130
+ # ======================================================================= #
131
+ button_refresh = gtk_button(:refresh)
132
+ button_refresh.no_relief
133
+ button_refresh.on_clicked {
134
+ do_update_the_main_content_of_the_widget
135
+ }
136
+ button_refresh.hint = '<b>Click</b> on this button in order to '\
137
+ 'refresh the information shown below.'
138
+ @toolbar << button_refresh
139
+ # ======================================================================= #
140
+ # (2) Add a pin-emoji next, to assign to the xorg-buffer upon clicking
141
+ # on it.
142
+ # ======================================================================= #
143
+ pin_emoji = emoji(:pin)
144
+ event_box_for_the_pin_emoji = event_box(pin_emoji)
145
+ event_box_for_the_pin_emoji.on_clicked {
146
+ do_assign_the_current_selection_to_the_xorg_buffer
147
+ }
148
+ pin_emoji.hint = '<b>Click</b> on this button to assign the '\
149
+ 'current selection to the xorg-buffer.'
150
+ @toolbar << event_box_for_the_pin_emoji
151
+ # ======================================================================= #
152
+ # (2) This belongs to the pin-emoji actually; the functionality should
153
+ # be regarded as a "cohesive unit".
154
+ # ======================================================================= #
155
+ @button_assign_to_the_xorg_buffer = button_xorg_buffer(label: 'Xorg')
156
+ @button_assign_to_the_xorg_buffer.no_relief
157
+ @button_assign_to_the_xorg_buffer.on_clicked {
158
+ do_assign_the_current_selection_to_the_xorg_buffer
159
+ }
160
+ @toolbar << @button_assign_to_the_xorg_buffer
161
+ end
162
+
163
+ # ========================================================================= #
164
+ # === currently_selected
165
+ #
166
+ # Will show both key and version.
167
+ # ========================================================================= #
168
+ def currently_selected
169
+ _ = ''.dup
170
+ if @tree_view and @tree_view.selection
171
+ @tree_view.selection.selected_each {|list_store, tree_path, tree_iter|
172
+ if tree_iter[0]
173
+ name_of_the_program = tree_iter[0].strip
174
+ else
175
+ name_of_the_program = 'unknown'
176
+ end
177
+ version_of_the_program = tree_iter[1]
178
+ _ << "#{name_of_the_program} #{version_of_the_program}"
179
+ }
180
+ end
181
+ return _
182
+ end; alias return_the_current_selection_of_the_treeview_widget currently_selected # === return_the_current_selection_of_the_treeview_widget
183
+
184
+ # ========================================================================= #
185
+ # === do_assign_the_current_selection_to_the_xorg_buffer
186
+ # ========================================================================= #
187
+ def do_assign_the_current_selection_to_the_xorg_buffer(
188
+ i = return_the_current_selection_of_the_treeview_widget
189
+ )
190
+ @button_assign_to_the_xorg_buffer.attach(i)
191
+ end
192
+
193
+ # ========================================================================= #
194
+ # === assign_the_environment_information_dataset_to_the_data_variable
195
+ # ========================================================================= #
196
+ def assign_the_environment_information_dataset_to_the_data_variable
197
+ @data = ::EnvironmentInformation.initialize_hash
198
+ end
199
+
200
+ # ========================================================================= #
201
+ # === do_update_the_main_content_of_the_widget
202
+ # ========================================================================= #
203
+ def do_update_the_main_content_of_the_widget
204
+ assign_the_environment_information_dataset_to_the_data_variable
205
+ @list_store.clear
206
+ @data.each {|line|
207
+ name, version = *line # Decompose line.
208
+ iter = @list_store.append
209
+ if version.nil? or version.to_s.empty?
210
+ version = '[Not installed.]'
211
+ end
212
+ iter.set_value(0, name)
213
+ iter.set_value(1, version)
214
+ }
215
+ end
216
+
217
+ # ========================================================================= #
218
+ # === add_status_icon
219
+ # ========================================================================= #
220
+ def add_status_icon
221
+ _ = gtk_status_icon(:dialog_info)
222
+ # ======================================================================= #
223
+ # Add a menu and a quit-button too.
224
+ # ======================================================================= #
225
+ menu = gtk_menu
226
+ quit = gtk_image_menu_item(::Gtk::Stock::QUIT)
227
+ quit.on_activate { ::Gtk.main_quit }
228
+ menu.append(quit)
229
+ menu.show_all
230
+ _.signal_connect(:popup_menu) { |icon, button, time|
231
+ menu.popup(nil, nil, button, time)
232
+ }
233
+ end
234
+
235
+ # ========================================================================= #
236
+ # === padding?
237
+ # ========================================================================= #
238
+ def padding?
239
+ 2
240
+ end
241
+
242
+ # ========================================================================= #
243
+ # === EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.width
244
+ # ========================================================================= #
245
+ def self.width
246
+ WIDTH
247
+ end
248
+
249
+ # ========================================================================= #
250
+ # === EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.height
251
+ # ========================================================================= #
252
+ def self.height
253
+ HEIGHT
254
+ end
255
+
256
+ # ========================================================================= #
257
+ # === favicon?
258
+ # ========================================================================= #
259
+ def favicon?
260
+ :tabble
261
+ end
262
+
263
+ # ========================================================================= #
264
+ # === create_gtk_tree_view
265
+ #
266
+ # The TreeView widget is the main widget which allows the user to
267
+ # display environment-related information about installed
268
+ # programs.
269
+ # ========================================================================= #
270
+ def create_gtk_tree_view
271
+ @tree_view = ::Gtk::TreeView.new(@list_store) # rf ruby gtk_TreeView
272
+ @tree_view.do_select_multiple # Allow multiple selections.
273
+ @tree_view.use_clickable_headers
274
+ # ======================================================================= #
275
+ # === ruby-gtk2
276
+ # ======================================================================= #
277
+ if ::Gtk.use_gtk2?
278
+ @tree_view.enable_model_drag_source(
279
+ Gdk::Window::BUTTON1_MASK,
280
+ [ ['GTK_TREE_MODEL_ROW', 0, 0] ],
281
+ Gdk::DragContext::ACTION_COPY|Gdk::DragContext::ACTION_MOVE
282
+ )
283
+ @tree_view.enable_model_drag_dest([
284
+ ['GTK_TREE_MODEL_ROW', 0, 0] ],
285
+ Gdk::DragContext::ACTION_COPY|Gdk::DragContext::ACTION_MOVE
286
+ )
287
+ else
288
+ # ======================================================================= #
289
+ # ruby-gtk3
290
+ # ======================================================================= #
291
+ @tree_view.enable_model_drag_source(
292
+ :button1_mask,
293
+ [ ['GTK_TREE_MODEL_ROW', 0, 0] ],
294
+ Gdk::DragAction::COPY|Gdk::DragAction::MOVE
295
+ )
296
+ @tree_view.enable_model_drag_dest([
297
+ ['GTK_TREE_MODEL_ROW', 0, 0] ],
298
+ Gdk::DragAction::COPY|Gdk::DragAction::MOVE
299
+ )
300
+ end
301
+ @tree_view.signal_connect(:row_activated) {
302
+ # puts "hello"
303
+ }
304
+ # ========================================================================= #
305
+ # Respond to mouse-button press events. This is currently not in use
306
+ # really.
307
+ # ========================================================================= #
308
+ @tree_view.on_button_press_event { |widget, event|
309
+ if mouse_button_double_click?(event)
310
+ # e 'MouseButton: double click event.'
311
+ # ^^^ Currently we do not handle this event.
312
+ elsif left_mouse_button_clicked?(event)
313
+ # e 'MouseButton: left-click event (once).'
314
+ elsif right_mouse_button_clicked?(event)
315
+ # e 'MouseButton: right-click event (once).'
316
+ end
317
+ }
318
+ @tree_view.selection.set_mode(::Gtk::SelectionMode::MULTIPLE)
319
+ @tree_view.selection.signal_connect(:changed) {|entry|
320
+ entry.each {|model, path, inner_array|
321
+ if @display_information_on_the_commandline
322
+ if inner_array[0]
323
+ name_of_the_program = inner_array[0].strip
324
+ else
325
+ name_of_the_program = '(unknown'
326
+ end
327
+ version_of_the_program = inner_array[1]
328
+ result = Colours.steelblue(
329
+ name_of_the_program.ljust(25)
330
+ ).dup
331
+ if ::EnvironmentInformation.is_this_a_registered_program?(name_of_the_program)
332
+ result << 'Version: '
333
+ end
334
+ result << Colours.lightgreen(version_of_the_program.to_s)
335
+ e result
336
+ end
337
+ }
338
+ }
339
+ @tree_view.resizable_headers
340
+ end
341
+
342
+ # ========================================================================= #
343
+ # === run
344
+ # ========================================================================= #
345
+ def run
346
+ create_skeleton
347
+ # ======================================================================= #
348
+ # Append the information contained in our @data variable to the
349
+ # ListStore object next. This will yield an Array.
350
+ # ======================================================================= #
351
+ do_update_the_main_content_of_the_widget
352
+ @tree_view.append('Name', @renderer, text: 0)
353
+ @tree_view.append('Version', @renderer, text: 1)
354
+ @tree_view.the_headers_are_clickable
355
+ @tree_view.is_sortable
356
+ @tree_view.on_key_press_event { |w, event|
357
+ case Gdk::Keyval.to_name(event.keyval)
358
+ when 'Return','KP_Enter'
359
+ e currently_selected
360
+ end
361
+ }
362
+ vbox = gtk_vbox
363
+ vbox.add(@toolbar)
364
+ @scrolled_window = gtk_scrolled_window(@tree_view)
365
+ @scrolled_window.set_size_request(600, 600)
366
+ vbox.maximal(@scrolled_window, 2)
367
+ maximal(vbox)
368
+ add_status_icon
369
+ show_all
370
+ end
371
+
372
+ # ========================================================================= #
373
+ # === EnvironmentInformation::GUI::Gtk::EnvironmentInformationModule.run
374
+ # ========================================================================= #
375
+ def self.run
376
+ require 'gtk_paradise/run'
377
+ r = ::Gtk.run
378
+ r << ::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.new
379
+ r.enable_quick_exit
380
+ r.top_left_then_run
381
+ end
382
+
383
+ end; end; end; end
384
+
385
+ # ========================================================================= #
386
+ # === EnvironmentInformation.gtk_bindings
387
+ # ========================================================================= #
388
+ def self.gtk_bindings
389
+ ::EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.new
390
+ end
391
+
392
+ # ========================================================================= #
393
+ # === EnvironmentInformation.run_gtk
394
+ #
395
+ # Use this method if you wish to run the gtk-component of the
396
+ # EnvironmentInformation project.
397
+ # ========================================================================= #
398
+ def self.run_gtk
399
+ require 'gtk_paradise/run'
400
+ _ = ::EnvironmentInformation.gtk_bindings
401
+ r = ::Gtk.run
402
+ r << _ # ← Add the widget here.
403
+ r.add_shortcut(1, 'focus(:left)', :alt)
404
+ r.modify_background(:normal, :white)
405
+ r.automatic_title
406
+ r.top_left_then_run
407
+ end
408
+
409
+ end
@@ -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
@@ -0,0 +1,42 @@
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_bit_type_information (bit tag, bit type tag)
14
+ #
15
+ # This method will return the bit type in use, as a String,
16
+ # such as "x86_64" or "x86_64 (64 bit)" specifically. The
17
+ # reason why this method appends ' (64 bit)' is mostly so
18
+ # that the user can quickly see whether a computer is on
19
+ # 32 bit or on 64 bit.
20
+ # ========================================================================= #
21
+ def self.operating_system_bit_type_information
22
+ cmd = 'uname -m'
23
+ result = `#{cmd}`.chomp
24
+ result = result.split(' ')[-1] if result.include?(' ')
25
+ result = result.dup if result.frozen?
26
+ case result
27
+ when 'x86_64'
28
+ result << ' (64 bit)'
29
+ end
30
+ result
31
+ end; self.instance_eval { alias add_bit_type_information operating_system_bit_type_information } # === EnvironmentInformation.add_bit_type_information
32
+ self.instance_eval { alias add_operating_system_bit_type operating_system_bit_type_information } # === EnvironmentInformation.add_operating_system_bit_type
33
+ self.instance_eval { alias bit_type? operating_system_bit_type_information } # === EnvironmentInformation.bit_type?
34
+ self.instance_eval { alias return_version_of_operating_system_bit_type operating_system_bit_type_information } # === EnvironmentInformation.return_version_of_operating_system_bit_type
35
+ self.instance_eval { alias operating_system_bit_type? operating_system_bit_type_information } # === EnvironmentInformation.operating_system_bit_type?
36
+ self.instance_eval { alias operating_system_bit_type operating_system_bit_type_information } # === EnvironmentInformation.operating_system_bit_type
37
+
38
+ end
39
+
40
+ if __FILE__ == $PROGRAM_NAME
41
+ puts EnvironmentInformation.operating_system_bit_type_information
42
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'environment_information/misc_components/ram.rb'
6
+ # ::EnvironmentInformation.ram?
7
+ # =========================================================================== #
8
+ module EnvironmentInformation
9
+
10
+ # ========================================================================= #
11
+ # === EnvironmentInformation.ram? (ram tag)
12
+ #
13
+ # This method will determine how much RAM the given computer host has.
14
+ #
15
+ # The result will be given in n MB.
16
+ # ========================================================================= #
17
+ def self.ram?
18
+ result_in_n_mb = `free -m 2>&1`.split("\n")[1]
19
+ if result_in_n_mb and result_in_n_mb.include?(' ')
20
+ result_in_n_mb = result_in_n_mb.split(' ')[1]
21
+ end
22
+ result_in_n_mb
23
+ end; self.instance_eval { alias return_version_of_ram ram? } # === EnvironmentInformation.return_version_of_ram
24
+ self.instance_eval { alias ram ram? } # === EnvironmentInformation.ram
25
+
26
+ end
27
+
28
+ if __FILE__ == $PROGRAM_NAME
29
+ puts EnvironmentInformation.ram?
30
+ end