hardware_information 1.0.71

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 hardware_information might be problematic. Click here for more details.

Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +65 -0
  3. data/bin/hardware_information +12 -0
  4. data/doc/README.gen +25 -0
  5. data/hardware_information.gemspec +44 -0
  6. data/lib/hardware_information/class/colours.rb +82 -0
  7. data/lib/hardware_information/class/constants.rb +145 -0
  8. data/lib/hardware_information/class/hardware_information.rb +32 -0
  9. data/lib/hardware_information/class/initialize.rb +24 -0
  10. data/lib/hardware_information/class/make_line.rb +55 -0
  11. data/lib/hardware_information/class/menu.rb +52 -0
  12. data/lib/hardware_information/class/misc.rb +275 -0
  13. data/lib/hardware_information/class/obtain.rb +255 -0
  14. data/lib/hardware_information/class/reset.rb +54 -0
  15. data/lib/hardware_information/class/run.rb +48 -0
  16. data/lib/hardware_information/css/project.css +3 -0
  17. data/lib/hardware_information/gui/gtk2/purchased_hardware/purchased_hardware.rb +34 -0
  18. data/lib/hardware_information/gui/gtk2/show_input_devices/show_input_devices.rb +34 -0
  19. data/lib/hardware_information/gui/gtk3/mounted_harddiscs/mounted_harddiscs.rb +103 -0
  20. data/lib/hardware_information/gui/gtk3/purchased_hardware/purchased_hardware.rb +34 -0
  21. data/lib/hardware_information/gui/gtk3/show_input_devices/show_input_devices.rb +34 -0
  22. data/lib/hardware_information/gui/libui/mounted_harddiscs/mounted_harddiscs.rb +88 -0
  23. data/lib/hardware_information/gui/shared_code/mounted_harddiscs/mounted_harddiscs_module.rb +107 -0
  24. data/lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb +291 -0
  25. data/lib/hardware_information/gui/shared_code/show_input_devices/show_input_devices_module.rb +187 -0
  26. data/lib/hardware_information/misc/purchased_hardware/README.md +7 -0
  27. data/lib/hardware_information/misc/purchased_hardware/purchased_hardware.rb +169 -0
  28. data/lib/hardware_information/monitor/README.md +6 -0
  29. data/lib/hardware_information/monitor/monitor.rb +36 -0
  30. data/lib/hardware_information/project/project.rb +29 -0
  31. data/lib/hardware_information/version/version.rb +19 -0
  32. data/lib/hardware_information/www/embeddable_interface.rb +52 -0
  33. data/lib/hardware_information/www/my_hardware.cgi +7 -0
  34. data/lib/hardware_information/www/my_hardware.rb +462 -0
  35. data/lib/hardware_information/www/my_hardware_for_sinatra.rb +65 -0
  36. data/lib/hardware_information/yaml/colours_for_the_hardware_information_project.yml +30 -0
  37. data/lib/hardware_information/yaml/usb_errors/usb_errors.yml +2 -0
  38. data/lib/hardware_information.rb +7 -0
  39. metadata +95 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c1d2ab2b6f90e714e2399478e380e88c43b08faf773bf45d2c391e1851d44d51
4
+ data.tar.gz: 5722c7a24b466396d4516a7e27bc9333f5679ac64856306b3469ff4cc51c1379
5
+ SHA512:
6
+ metadata.gz: e4b7ee8f884a7f0a61a9c2434494d2db493bf404cb63c86b7d9bc827665901a3e64f17132d287fd0c5556000aa01c6960a6125f9d1985adb0b31b3476a628516
7
+ data.tar.gz: 661f01f937f830c54fad8a29d6b10e6528c5aa6be3d70495f13f73897b2b1d6ee51a2d0aa428cc9202f9ea268336c9a85d827c0d45d4a85637c2c6392525741f
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ ## Requiring the project
2
+
3
+ You can require this gem via:
4
+
5
+ require 'hardware_information'
6
+
7
+ ## HardwareInformation.report
8
+
9
+ This toplevel API will report what hardware has been found
10
+ on the given computer system.
11
+
12
+ ## Colour support
13
+
14
+ By default class HardwareInformation will try to show colours,
15
+ if used from the commandline.
16
+
17
+ If this is unwanted, you can pass any of the following flags
18
+ to disable colour support:
19
+
20
+ --disable-colours
21
+ --disable-colors
22
+ --no-colours
23
+ --no-colors
24
+
25
+
26
+ ## Contact information and mandatory 2FA coming up in 2022
27
+
28
+ If your creative mind has ideas and specific suggestions to make this gem
29
+ more useful in general, feel free to drop me an email at any time, via:
30
+
31
+ shevy@inbox.lt
32
+
33
+ Before that email I used an email account at Google gmail, but in **2021** I
34
+ decided to slowly abandon gmail for various reasons. In order to limit this
35
+ explanation here, allow me to just briefly state that I do not feel as if I
36
+ want to promote any Google service anymore, for various reasons.
37
+
38
+ Do keep in mind that responding to emails may take some time, depending on
39
+ the amount of work I may have at that moment.
40
+
41
+ In 2022 rubygems.org decided to make 2FA mandatory for every gem owner:
42
+ see https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
43
+
44
+ As I can not use 2FA, for reasons I will skip explaining here (see
45
+ various github issue discussions in the past), this effectively means that
46
+ Betty Li and others who run the show at rubygems.org will perma-ban me
47
+ from using rubygems as a developer.
48
+
49
+ As I disagree with that decision completely, this will mean that all my
50
+ gems will be removed from rubygems.org prior to that sunset date, e. g.
51
+ before they permanently lock me out from the code that I used
52
+ to maintain. It is pointless to want to discuss this with them anymore -
53
+ they have made up their minds and decided that you can only use
54
+ the code if 2FA is in place, even though the code itself works just
55
+ fine. If you don't use 2FA you are effectively locked out from your
56
+ own code; I consider this a malicious attack. See also how they limited
57
+ discussions to people with mandatory 2FA on the ruby-bugtracker, thus
58
+ banning everyone permanently without 2FA:
59
+
60
+ https://bugs.ruby-lang.org/issues/18800
61
+
62
+ Guess it may indeed be time to finally abandon ruby - not because
63
+ ruby is a bad language, but there are people now in charge who
64
+ really should not be part of ruby in the first place.
65
+
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'hardware_information'
6
+
7
+ _ = HardwareInformation.new(:do_not_run_yet)
8
+ unless ARGV.empty?
9
+ _.menu(ARGV)
10
+ end
11
+ _.run
12
+ _.report_result
data/doc/README.gen ADDED
@@ -0,0 +1,25 @@
1
+ ## Requiring the project
2
+
3
+ You can require this gem via:
4
+
5
+ require 'hardware_information'
6
+
7
+ ## HardwareInformation.report
8
+
9
+ This toplevel API will report what hardware has been found
10
+ on the given computer system.
11
+
12
+ ## Colour support
13
+
14
+ By default class HardwareInformation will try to show colours,
15
+ if used from the commandline.
16
+
17
+ If this is unwanted, you can pass any of the following flags
18
+ to disable colour support:
19
+
20
+ --disable-colours
21
+ --disable-colors
22
+ --no-colours
23
+ --no-colors
24
+
25
+ ADD_CONTACT_INFORMATION
@@ -0,0 +1,44 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project HardwareInformation.
3
+ # =========================================================================== #
4
+ require 'hardware_information/version/version.rb'
5
+ require 'roebe'
6
+
7
+ Gem::Specification.new { |s|
8
+
9
+ s.name = 'hardware_information'
10
+ s.version = HardwareInformation::VERSION
11
+ s.date = Time.now.strftime('%Y-%m-%d')
12
+
13
+ s.summary = <<-EOF
14
+
15
+ This small class will output Information about your hardware,
16
+ i.e. the Processor type and so on. It is supposed to be
17
+ a really small gem.
18
+
19
+ EOF
20
+
21
+ s.description = <<-EOF
22
+
23
+ This small class will output Information about your hardware,
24
+ i.e. the Processor type and so on. It is supposed to be
25
+ a really small gem.
26
+
27
+ EOF
28
+
29
+ s.authors = ['Robert A. Heiler']
30
+ s.email = Roebe.email?
31
+ s.files = Dir['**/*']
32
+ s.homepage = 'https://rubygems.org/gems/environment_information'
33
+ s.license = 'GPL-2.0'
34
+
35
+ s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
36
+ s.required_rubygems_version = '>= '+Gem::VERSION
37
+ s.rubygems_version = '>= '+Gem::VERSION
38
+
39
+ # ============================================================== #
40
+ # Dependencies
41
+ # ============================================================== #
42
+ s.add_dependency 'colours'
43
+
44
+ }
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ class HardwareInformation
6
+
7
+ begin
8
+ require 'colours'
9
+ include Colours
10
+ rescue LoadError; end
11
+
12
+ # ========================================================================= #
13
+ # === green?
14
+ # ========================================================================= #
15
+ def green?
16
+ Colours::GREEN
17
+ end
18
+
19
+ # ========================================================================= #
20
+ # === bold_teal?
21
+ # ========================================================================= #
22
+ def bold_teal?
23
+ Colours::BOLD_TEAL
24
+ end
25
+
26
+ # ========================================================================= #
27
+ # === use_colours?
28
+ # ========================================================================= #
29
+ def use_colours?
30
+ @use_colours
31
+ end
32
+
33
+ # ========================================================================= #
34
+ # === enable_colours
35
+ # ========================================================================= #
36
+ def enable_colours
37
+ @use_colours = true
38
+ end
39
+
40
+ # ========================================================================= #
41
+ # === disable_colours
42
+ # ========================================================================= #
43
+ def disable_colours
44
+ @use_colours = false
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === thistle
49
+ # ========================================================================= #
50
+ def thistle(i)
51
+ return Colours.thistle(i) if use_colours?
52
+ i
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === royalblue
57
+ # ========================================================================= #
58
+ def royalblue(i)
59
+ return Colours.royalblue(i) if use_colours?
60
+ i
61
+ end
62
+
63
+ # ========================================================================= #
64
+ # === steelblue
65
+ # ========================================================================= #
66
+ def steelblue(i)
67
+ return Colours.steelblue(i) if use_colours?
68
+ i
69
+ end
70
+
71
+ # ========================================================================= #
72
+ # === rev
73
+ # ========================================================================= #
74
+ def rev
75
+ if use_colours?
76
+ Colours.rev
77
+ else
78
+ ''
79
+ end
80
+ end
81
+
82
+ end
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'hardware_information/class/constants.rb'
6
+ # =========================================================================== #
7
+ require 'hardware_information/project/project.rb'
8
+
9
+ class HardwareInformation
10
+
11
+ # ========================================================================= #
12
+ # === N
13
+ # ========================================================================= #
14
+ N = "\n"
15
+
16
+ # ========================================================================= #
17
+ # === ERROR_LINE
18
+ # ========================================================================= #
19
+ ERROR_LINE = '2>&1'
20
+
21
+ # ========================================================================= #
22
+ # === LEFT_PADDING
23
+ #
24
+ # How many characters to pad on the left side. Used for the
25
+ # header_content() method.
26
+ # ========================================================================= #
27
+ LEFT_PADDING = 26
28
+
29
+ # ========================================================================= #
30
+ # === MAIN_DEFAULT_RJUST
31
+ # ========================================================================= #
32
+ MAIN_DEFAULT_RJUST = 48
33
+
34
+ # ========================================================================= #
35
+ # === CPUINFO_LOCATION
36
+ #
37
+ # This constants stores where cpuinfo is kept. Will work only on
38
+ # Linux, I think.
39
+ # ========================================================================= #
40
+ CPUINFO_LOCATION = '/proc/cpuinfo'
41
+
42
+ # ========================================================================= #
43
+ # === PROC_MEMINFO
44
+ # ========================================================================= #
45
+ PROC_MEMINFO = '/proc/meminfo'
46
+
47
+ # ========================================================================= #
48
+ # === FILE_COLOURS_FOR_THE_HARDWARE_PROJECT
49
+ # ========================================================================= #
50
+ FILE_COLOURS_FOR_THE_HARDWARE_PROJECT =
51
+ "#{PROJECT_YAML_DIRECTORY}colours_for_the_hardware_information_project.yml"
52
+
53
+ # ========================================================================= #
54
+ # === HardwareInformation.kb_to_mb(i)
55
+ # ========================================================================= #
56
+ def self.kb_to_mb(i)
57
+ (
58
+ i.gsub(/ kB/,'').to_i / 1024
59
+ ).to_s+ ' MB'
60
+ end
61
+
62
+ # ========================================================================= #
63
+ # === HardwareInformation.is_on_windows?
64
+ # ========================================================================= #
65
+ def self.is_on_windows?
66
+ if RUBY_PLATFORM.include?('win') or # if on windows.
67
+ RUBY_PLATFORM.include?('mingw')
68
+ return true
69
+ end
70
+ return false
71
+ end
72
+
73
+ # ========================================================================= #
74
+ # === LSCPU
75
+ #
76
+ # The `lscpu` command may fail, which is why it has to be put into
77
+ # a begin/rescue clause.
78
+ # ========================================================================= #
79
+ if is_on_windows?
80
+ LSCPU = nil
81
+ else
82
+ begin
83
+ LSCPU = `lscpu`.split("\n")
84
+ rescue Errno::ENOENT
85
+ puts 'No binary called lscpu could be found.'
86
+ end
87
+ end
88
+
89
+ # ========================================================================= #
90
+ # === CPUINFO
91
+ #
92
+ # We must first check whether the target location actually does happen
93
+ # to exist.
94
+ # ========================================================================= #
95
+ _ = CPUINFO_LOCATION
96
+ if File.exist? _
97
+ CPUINFO = File.read(_)
98
+ else
99
+ CPUINFO = nil
100
+ end
101
+
102
+ # ========================================================================= #
103
+ # === SPLITTED_CPUINFO
104
+ # ========================================================================= #
105
+ if CPUINFO
106
+ SPLITTED_CPUINFO = CPUINFO.split(N)
107
+ begin
108
+ LSPCI = `lspci`
109
+ rescue # Must rescue here because lspci might not be available.
110
+ LSPCI = nil
111
+ end
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === DATASET_FROM_PROC_MEMINFO
116
+ # ========================================================================= #
117
+ if File.exist? PROC_MEMINFO
118
+ DATASET_FROM_PROC_MEMINFO = File.readlines(PROC_MEMINFO)
119
+ _ = DATASET_FROM_PROC_MEMINFO.select {|entry|
120
+ entry.include? 'MemTotal'
121
+ }.first.strip.split(':').last.strip
122
+ # ======================================================================= #
123
+ # We discard all but the gigs for RAM.
124
+ # ======================================================================= #
125
+ _ = (_.gsub(/ kB/,'').to_i / 1024).to_s+ ' MB'
126
+ else
127
+ DATASET_FROM_PROC_MEMINFO = nil
128
+ end
129
+
130
+ # ========================================================================= #
131
+ # === RAM_AVAILABLE
132
+ # ========================================================================= #
133
+ RAM_AVAILABLE = _
134
+
135
+ if DATASET_FROM_PROC_MEMINFO
136
+ _ = DATASET_FROM_PROC_MEMINFO.select {|entry|
137
+ entry.include? 'MemFree'
138
+ }.first.strip.split(':').last.strip #.gsub(/ kB/,'').to_i / 1024).to_s+ ' MB'
139
+ # ======================================================================= #
140
+ # === RAM_AVAILABLE_FREE
141
+ # ======================================================================= #
142
+ RAM_AVAILABLE_FREE = kb_to_mb(_)
143
+ end
144
+
145
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === HardwareInformation
6
+ #
7
+ # This class will show some information about the local computer system,
8
+ # e. g. hardware information, via colours.
9
+ # =========================================================================== #
10
+ # require 'hardware_information'
11
+ # =========================================================================== #
12
+ require 'hardware_information/version/version.rb'
13
+ require 'hardware_information/class/colours.rb'
14
+ require 'hardware_information/class/constants.rb'
15
+ require 'hardware_information/class/initialize.rb'
16
+ require 'hardware_information/class/make_line.rb'
17
+ require 'hardware_information/class/menu.rb'
18
+ require 'hardware_information/class/misc.rb'
19
+ require 'hardware_information/class/obtain.rb'
20
+ require 'hardware_information/class/reset.rb'
21
+ require 'hardware_information/class/run.rb'
22
+
23
+ class HardwareInformation # === HardwareInformation
24
+
25
+ end
26
+
27
+ if __FILE__ == $PROGRAM_NAME
28
+ _ = HardwareInformation.new(false)
29
+ # _.disable_colours
30
+ _.run
31
+ _.report_result
32
+ end # hardi
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ class HardwareInformation
6
+
7
+ # ========================================================================= #
8
+ # === initialize
9
+ # ========================================================================= #
10
+ def initialize(
11
+ run_already = true
12
+ )
13
+ reset
14
+ case run_already
15
+ when :do_not_run_yet
16
+ run_already = false
17
+ end
18
+ set_run_already(
19
+ run_already
20
+ )
21
+ run if run_already
22
+ end
23
+
24
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ class HardwareInformation
6
+
7
+ # ========================================================================= #
8
+ # === make_line
9
+ #
10
+ # The first argument to this method should be the title that will
11
+ # be displayed.
12
+ #
13
+ # The second argument should show the content towards that argument.
14
+ # ========================================================================= #
15
+ def make_line(
16
+ title, content
17
+ )
18
+ title = title.dup if title.frozen?
19
+ use_this_colour_for_change = bold_teal?
20
+ use_this_colour_to_revert = @default_colour # First a copy.
21
+ title << ': ' if @use_colon_as_delimiter
22
+ title = default_ljust(title)
23
+ content = default_rjust(content)
24
+ # ======================================================================= #
25
+ # === Handle blocks next
26
+ #
27
+ # The passed block can modify the variable called content. This
28
+ # will happen after the various padding-operations above.
29
+ # ======================================================================= #
30
+ if block_given?
31
+ yielded = yield
32
+ case yielded
33
+ when nil
34
+ # Pas through.
35
+ else # Else, use colours.
36
+ if use_colours?
37
+ content = Colours.send(yielded, content)
38
+ end
39
+ end
40
+ end
41
+ string = ''.dup
42
+ string << use_this_colour_for_change if use_colours?
43
+ string << title
44
+ string << use_this_colour_to_revert if use_colours?
45
+ string = string.ljust(40)
46
+ if content.is_a? Array
47
+ _ string
48
+ content.each {|line| _ " #{line}" }
49
+ else
50
+ string << content
51
+ _ string
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'hardware_information/class/menu.rb'
6
+ # =========================================================================== #
7
+ class HardwareInformation # === HardwareInformation
8
+
9
+ # ========================================================================= #
10
+ # === start_the_sinatra_interface
11
+ #
12
+ # To invoke this method, do:
13
+ #
14
+ # hardi --sinatra
15
+ #
16
+ # ========================================================================= #
17
+ def start_the_sinatra_interface
18
+ require 'hardware_information/www/my_hardware_for_sinatra.rb'
19
+ HardwareInformation::SinatraMyHardware.start_sinatra_interface
20
+ end
21
+
22
+ # ========================================================================= #
23
+ # === menu (menu tag)
24
+ #
25
+ # Commandline-arguments, e. g. ARGV, will be passed into this menu
26
+ # interface.
27
+ # ========================================================================= #
28
+ def menu(
29
+ i = nil
30
+ )
31
+ if i
32
+ if i.is_a? Array
33
+ i.each {|entry| menu(entry) }
34
+ else
35
+ case i # case tag
36
+ # =================================================================== #
37
+ # === hardi --sinatra
38
+ # =================================================================== #
39
+ when /^-?-?sinatra$/
40
+ start_the_sinatra_interface
41
+ # =================================================================== #
42
+ # === hardi --disable-colours
43
+ # =================================================================== #
44
+ when /^-?-?disable(-|_)?colou?rs$/,
45
+ /^-?-?no(-|_)?colou?rs$/
46
+ disable_colours
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ end