linux_stat 1.0.2 → 1.0.3
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.
- checksums.yaml +4 -4
- data/lib/linux_stat/net.rb +6 -2
- data/lib/linux_stat/os.rb +9 -5
- data/lib/linux_stat/usb.rb +5 -3
- data/lib/linux_stat/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01f83a838dcd8dcb7e9a0777a68fbad83284103ddc12e8c1ef9a1358df7c4965
|
4
|
+
data.tar.gz: ba699f7a8bcb56469f44ab36e3a48888421dd23295287b56896f4c931c99a6e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7350b44b72c7385eb552d029668577c4cda06f1130104437e0baaf853cd119c8eb27aac99e7070a7191110faef4f3ba85773bcadf646485f94856b7ff859564e
|
7
|
+
data.tar.gz: 5ae2a2344cdff502a559e4feefd028feb0194fbfe63197f0969a78c87328077dc033acedf78f99844c338082937b3d72270f44666528fec45ee06ca129265431
|
data/lib/linux_stat/net.rb
CHANGED
@@ -17,7 +17,9 @@ module LinuxStat
|
|
17
17
|
# Returns the total bytes received and transmitted as Hash.
|
18
18
|
#
|
19
19
|
# For example:
|
20
|
-
#
|
20
|
+
# LinuxStat::Net.usage
|
21
|
+
#
|
22
|
+
# => {:received=>56602867, :transmitted=>6940922}
|
21
23
|
#
|
22
24
|
# But if the status isn't available it will return an empty Hash.
|
23
25
|
def total_bytes
|
@@ -68,7 +70,9 @@ module LinuxStat
|
|
68
70
|
# The return type is a Hash, containg the current internet usage (received, transmit) in B/s.
|
69
71
|
#
|
70
72
|
# For example:
|
71
|
-
#
|
73
|
+
# LinuxStat::Net.usage
|
74
|
+
#
|
75
|
+
# => {:received=>436060.0, :transmitted=>50350.0}
|
72
76
|
#
|
73
77
|
# If the system transmits 100 kb in the interval,
|
74
78
|
#
|
data/lib/linux_stat/os.rb
CHANGED
@@ -3,7 +3,9 @@ module LinuxStat
|
|
3
3
|
class << self
|
4
4
|
##
|
5
5
|
# Reads /etc/os-release and returns a Hash. For example:
|
6
|
-
#
|
6
|
+
# LinuxStat::OS.os_release
|
7
|
+
#
|
8
|
+
# => {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling", :ANSI_COLOR=>"38;2;23;147;209", :HOME_URL=>"https://www.archlinux.org/", :DOCUMENTATION_URL=>"https://wiki.archlinux.org/", :SUPPORT_URL=>"https://bbs.archlinux.org/", :BUG_REPORT_URL=>"https://bugs.archlinux.org/", :LOGO=>"archlinux"}
|
7
9
|
#
|
8
10
|
# If the info isn't available, it will return an empty Hash.
|
9
11
|
#
|
@@ -13,13 +15,14 @@ module LinuxStat
|
|
13
15
|
# Because changing the /etc/lsb-release
|
14
16
|
# isn't expected in runtime.
|
15
17
|
def os_release
|
16
|
-
# cached (memoized) ; as changing the value in runtime is unexpected
|
17
18
|
@@os_release ||= File.readable?('/etc/os-release') ? release('/etc/os-release') : {}
|
18
19
|
end
|
19
20
|
|
20
21
|
##
|
21
22
|
# Reads /etc/lsb-release and returns a Hash. For example:
|
22
|
-
#
|
23
|
+
# LinuxStat::OS.lsb_release
|
24
|
+
#
|
25
|
+
# => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
|
23
26
|
#
|
24
27
|
# If the info isn't available, it will return an empty Hash.
|
25
28
|
#
|
@@ -28,7 +31,6 @@ module LinuxStat
|
|
28
31
|
# The information is also cached, and once loaded, won't change in runtime.
|
29
32
|
# Because changing the /etc/lsb-release isn't expected in runtime.
|
30
33
|
def lsb_release
|
31
|
-
# cached (memoized) ; as changing the value in runtime is unexpected
|
32
34
|
@@lsb_release ||= File.readable?('/etc/lsb-release') ? release('/etc/lsb-release') : {}
|
33
35
|
end
|
34
36
|
|
@@ -104,7 +106,9 @@ module LinuxStat
|
|
104
106
|
|
105
107
|
##
|
106
108
|
# Reads /proc/uptime and returns the system uptime:
|
107
|
-
#
|
109
|
+
# LinuxStat::OS.uptime
|
110
|
+
#
|
111
|
+
# => {:hour=>10, :minute=>34, :second=>12.59}
|
108
112
|
#
|
109
113
|
# If the stat isn't available, an empty hash is returned.
|
110
114
|
def uptime
|
data/lib/linux_stat/usb.rb
CHANGED
@@ -158,9 +158,11 @@ module LinuxStat
|
|
158
158
|
x = file_data[i]
|
159
159
|
|
160
160
|
_lstripped = x.lstrip
|
161
|
-
next if _lstripped == ?#.freeze || _lstripped.empty?
|
161
|
+
next if _lstripped[0] == ?#.freeze || _lstripped.empty?
|
162
|
+
|
163
|
+
if x[0] == ?\t.freeze
|
164
|
+
next unless vendor_id
|
162
165
|
|
163
|
-
if x.start_with?(?\t.freeze)
|
164
166
|
data = x.tap(&:strip!)
|
165
167
|
device_id = data[/\A.*?\s/].to_s.strip
|
166
168
|
device = data[device_id.length..-1].to_s.strip
|
@@ -173,7 +175,7 @@ module LinuxStat
|
|
173
175
|
end
|
174
176
|
end
|
175
177
|
|
176
|
-
ret
|
178
|
+
ret
|
177
179
|
else
|
178
180
|
{}
|
179
181
|
end
|
data/lib/linux_stat/version.rb
CHANGED