lmsensors 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,77 @@
1
+ # lib/lmsensors/sensors/sensorspawner.rb
2
+
3
+ # Require the abstract sensor
4
+ require_relative "./sensor"
5
+
6
+ # :nodoc: This module will house the concrete implementation
7
+ # :nodoc: of the actual Sensor object types.
8
+ module LmSensors
9
+ ##
10
+ # SensorSpawner is a Sensor, unto itself,
11
+ # but it provides no way to format any output
12
+ # and is purely used to construct a list of
13
+ # single Sensors.
14
+ #
15
+ # This class inherits the SensorsBase class
16
+ # from the C side of the code.
17
+ #
18
+ # The single Sensors will actually provide
19
+ # the information usable by the client.
20
+ class SensorSpawner < LmSensors::AbsSensor
21
+ ##
22
+ # Set the chip's name you want to
23
+ # get -- by default, 'nil', so it
24
+ # will return ALL the chips
25
+ def set_name(name) @chip_name = name end
26
+
27
+ ##
28
+ # Unset the current chip's name, so
29
+ # it returns ALL the chips, again
30
+ def unset_name() @chip_name = nil end
31
+
32
+ ##
33
+ # Enumerate the available chips for the specified
34
+ # name that was set (or all chips, if no name).
35
+ #
36
+ # This will return an array of either ALL
37
+ # the available chips or the selected
38
+ # chip set by 'set_name'.
39
+ def enum(name=@chip_name)
40
+ chips = pro_enum(nil, name)
41
+ if Hash === chips then
42
+ chips.collect do |index, chip|
43
+ item = LmSensors::Sensor.new
44
+ item.locate index
45
+ item.set_fmap(@fmap)
46
+ item
47
+ end
48
+ else
49
+ STDERR.puts chips
50
+ nil
51
+ end
52
+ end # End sensor chip enumerator
53
+
54
+ ##
55
+ # Select a specific chip by its path.
56
+ def locate(path, set=false)
57
+ dir = path_valid?(path)
58
+ # Return early, if the path is invalid
59
+ if !dir then return dir end
60
+
61
+ # Otherwise, continue
62
+ items = []
63
+ if dir then
64
+ data = enum
65
+ if Array === data then
66
+ # Only proceed if the data is good
67
+ items = data.select { |s| s.path == dir }
68
+ else return nil end
69
+ end.flatten
70
+ if items.length == 1 then
71
+ item = items[0]
72
+ if set then set_name(item.name) end
73
+ item
74
+ else nil end
75
+ end # End locate of specific chip
76
+ end # End SensorSpawner class
77
+ end # End LmSensors append
@@ -0,0 +1,8 @@
1
+ # lib/lmsensors/version.rb
2
+
3
+ # :nodoc: Append the version data to the module
4
+ module LmSensors
5
+ ##
6
+ # The current version
7
+ VERSION = "0.1.0"
8
+ end # End appending of version data
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lmsensors
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Edelweiss
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: "Wrapper for the ``lm-sensors`` library, which provides the programs,
14
+ \n``sensors`` and ``sensors-detect``, for Linux systems. This library \nand its
15
+ programs are used to allow the user to access temperature and\nfan data for various
16
+ hardware devices.\n\nThe wrapper is written in the C-Ruby API, so you can use it
17
+ in whatever \nRuby-based monitoring program makes the most sense and only using\nthe
18
+ parts relevant to your use case.\n"
19
+ email:
20
+ executables: []
21
+ extensions:
22
+ - ext/lmsensors_base/extconf.rb
23
+ extra_rdoc_files:
24
+ - README.md
25
+ - CHANGELOG.md
26
+ - LICENSE.txt
27
+ - FMAPPER.md
28
+ files:
29
+ - CHANGELOG.md
30
+ - FMAPPER.md
31
+ - LICENSE.txt
32
+ - README.md
33
+ - ext/lmsensors_base/extconf.rb
34
+ - lib/lmsensors.rb
35
+ - lib/lmsensors/feature.rb
36
+ - lib/lmsensors/features/abs_feature.rb
37
+ - lib/lmsensors/features/alarm.rb
38
+ - lib/lmsensors/features/beep.rb
39
+ - lib/lmsensors/features/current.rb
40
+ - lib/lmsensors/features/fan.rb
41
+ - lib/lmsensors/features/humidity.rb
42
+ - lib/lmsensors/features/power.rb
43
+ - lib/lmsensors/features/temp.rb
44
+ - lib/lmsensors/features/voltage.rb
45
+ - lib/lmsensors/lm_constants.rb
46
+ - lib/lmsensors/lmsensors.rb
47
+ - lib/lmsensors/sensors/abssensor.rb
48
+ - lib/lmsensors/sensors/sensor.rb
49
+ - lib/lmsensors/sensors/sensorspawner.rb
50
+ - lib/lmsensors/version.rb
51
+ - lib/lmsensors_base/lmsensors_base.so
52
+ homepage: https://github.com/KleineEdelweiss/lmsensors_rb
53
+ licenses:
54
+ - LGPL-3.0
55
+ metadata:
56
+ homepage_uri: https://github.com/KleineEdelweiss/lmsensors_rb
57
+ source_code_uri: https://github.com/KleineEdelweiss/lmsensors_rb
58
+ changelog_uri: https://github.com/KleineEdelweiss/lmsensors_rb/blob/master/CHANGELOG.md
59
+ bug_tracker_uri: https://github.com/KleineEdelweiss/lmsensors_rb/issues
60
+ post_install_message:
61
+ rdoc_options:
62
+ - "--title"
63
+ - LmSensors -- Lmsensors wrapper in the C-Ruby API
64
+ - "--main"
65
+ - README.md
66
+ - "--exclude"
67
+ - Makefile
68
+ - "--exclude"
69
+ - Rakefile
70
+ - "--exclude"
71
+ - Gemfile
72
+ - "--exclude"
73
+ - lmsensors.gemspec
74
+ - "--exclude"
75
+ - rdoc.sh
76
+ - "--line-numbers"
77
+ - "--inline-source"
78
+ - "--quiet"
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.7.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubygems_version: 3.2.5
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Lmsensors wrapper in the C-Ruby API
96
+ test_files: []