linux_stat 2.5.3 → 2.7.0

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.
@@ -1,62 +1,58 @@
1
1
  #include <sys/utsname.h>
2
2
  #include "ruby.h"
3
3
 
4
- #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
5
- #pragma GCC optimize ("O3")
6
- #pragma GCC diagnostic warning "-Wall"
7
- #elif defined(__clang__)
8
- #pragma clang optimize on
9
- #pragma clang diagnostic warning "-Wall"
10
- #elif defined(__INTEL_COMPILER)
11
- #pragma intel optimization_level 3
12
- #endif
13
-
14
- static struct utsname buf ;
15
-
16
- static char *sysname = "", *nodename = "" ;
17
- static char *release = "", *version = "", *machine = "" ;
18
-
19
- void init_buf() {
20
- char status = uname(&buf) ;
21
-
22
- if (status > -1) {
23
- sysname = buf.sysname ;
24
- nodename = buf.nodename ;
25
- release = buf.release ;
26
- version = buf.version ;
27
- machine = buf.machine ;
28
- }
29
- }
4
+ // Function to return the sysname, or nil if uname fails
5
+ static VALUE getSysname(VALUE obj) {
6
+ struct utsname buf;
7
+ if (uname(&buf) == -1)
8
+ return Qnil;
30
9
 
31
- static VALUE getSysname(volatile VALUE obj) {
32
- return rb_str_new_cstr(sysname) ;
10
+ return rb_str_new_cstr(buf.sysname);
33
11
  }
34
12
 
35
- static VALUE getNodename(volatile VALUE obj) {
36
- return rb_str_new_cstr(nodename) ;
37
- }
13
+ // Function to return the nodename, or nil if uname fails
14
+ static VALUE getNodename(VALUE obj) {
15
+ struct utsname buf;
16
+ if (uname(&buf) == -1)
17
+ return Qnil;
38
18
 
39
- static VALUE getRelease(volatile VALUE obj) {
40
- return rb_str_new_cstr(release) ;
19
+ return rb_str_new_cstr(buf.nodename);
41
20
  }
42
21
 
43
- static VALUE getVersion(volatile VALUE obj) {
44
- return rb_str_new_cstr(version) ;
22
+ // Function to return the release, or nil if uname fails
23
+ static VALUE getRelease(VALUE obj) {
24
+ struct utsname buf;
25
+ if (uname(&buf) == -1)
26
+ return Qnil;
27
+
28
+ return rb_str_new_cstr(buf.release);
45
29
  }
46
30
 
47
- static VALUE getMachine(volatile VALUE obj) {
48
- return rb_str_new_cstr(machine) ;
31
+ // Function to return the version, or nil if uname fails
32
+ static VALUE getVersion(VALUE obj) {
33
+ struct utsname buf;
34
+ if (uname(&buf) == -1)
35
+ return Qnil;
36
+
37
+ return rb_str_new_cstr(buf.version);
49
38
  }
50
39
 
51
- void Init_utsname() {
52
- init_buf() ;
40
+ // Function to return the machine type, or nil if uname fails
41
+ static VALUE getMachine(VALUE obj) {
42
+ struct utsname buf;
43
+ if (uname(&buf) == -1)
44
+ return Qnil;
53
45
 
54
- VALUE _linux_stat = rb_define_module("LinuxStat") ;
55
- VALUE _uname = rb_define_module_under(_linux_stat, "Uname") ;
46
+ return rb_str_new_cstr(buf.machine);
47
+ }
56
48
 
57
- rb_define_module_function(_uname, "sysname", getSysname, 0) ;
58
- rb_define_module_function(_uname, "nodename", getNodename, 0) ;
59
- rb_define_module_function(_uname, "release", getRelease, 0) ;
60
- rb_define_module_function(_uname, "version", getVersion, 0) ;
61
- rb_define_module_function(_uname, "machine", getMachine, 0) ;
49
+ void Init_utsname() {
50
+ VALUE _linux_stat = rb_define_module("LinuxStat");
51
+ VALUE _uname = rb_define_module_under(_linux_stat, "Uname");
52
+
53
+ rb_define_module_function(_uname, "sysname", getSysname, 0);
54
+ rb_define_module_function(_uname, "nodename", getNodename, 0);
55
+ rb_define_module_function(_uname, "release", getRelease, 0);
56
+ rb_define_module_function(_uname, "version", getVersion, 0);
57
+ rb_define_module_function(_uname, "machine", getMachine, 0);
62
58
  }
@@ -0,0 +1,101 @@
1
+ module LinuxStat
2
+ # Walks through directory and lists files, directories, symbolic links with their sizes.
3
+ # Can also count children (files + directories), files, and directories
4
+
5
+ module FTW
6
+ class << self
7
+ ##
8
+ # Show info about all directories and files in a given path and under its subdirectories.
9
+ # It accepts two arguments:
10
+ # * path: Path is the expanded path that you want to walk through.
11
+ # * flags: Flags will give you the ability to tune the output as you desire.
12
+ # Each flag value can be obtained through LinuxStat::NFTW.constants().
13
+ # Or you can use LinuxStat::NFTW::FLAGS for readable flags in hash format.
14
+ # You can do Or-ing to add multiple flags. More info here:
15
+ # https://man7.org/linux/man-pages/man3/ftw.3.html
16
+ # If no flags or nil were given as the second argument,
17
+ # it will use LS::NFTW::FTW_DEPTH | LS::NFTW::FTW_CONTINUE by default.
18
+ #
19
+ # The return value contains a Hash.
20
+ # The hash contains two keys: `error` and a `value`.
21
+ # * error: If there were any exceptions, the key will be set to true, otherwise false.
22
+ # Having an error means not all values are listed in the `value` array.
23
+ # * value: Is an array, it can or cannot be empty regardless of errors.
24
+ # The `value` key contains an array of Hashes. Each hash contains the following information about a file:
25
+ # 1. type_flag: Type of the file.
26
+ # 2. level: Depth of the file.
27
+ # 3. st_size: Size of the file in bytes.
28
+ # 4. path: Full path of the file.
29
+ # 5. basename: basename of the file.
30
+ #
31
+ # Usage Example:
32
+ # LinuxStat::FTW.stat_all(File.expand_path('~/.rvm/lib/'), LS::NFTW::FTW_DEPTH | LS::NFTW::FTW_CONTINUE)
33
+ # => {:value=>[{:type_flag=>:FTW_F, :level=>1, :st_size=>278, :path=>"/home/user/.rvm/lib/rvm.rb", :basename=>"rvm.rb"}, {:type_flag=>:FTW_F, :level=>2, :st_size=>286, :path=>"/home/user/.rvm/lib/rvm/capistrano.rb", :basename=>"capistrano.rb"}, {:type_flag=>:FTW_DP, :level=>1, :st_size=>27, :path=>"/home/user/.rvm/lib/rvm", :basename=>"rvm"}, {:type_flag=>:FTW_DP, :level=>0, :st_size=>31, :path=>"/home/user/.rvm/lib", :basename=>"lib"}], :error=>false}
34
+ #
35
+ # Internally calls LinuxStat::NFTW.stat(path, flag).
36
+ def stat_all(path = __dir__, flags = nil)
37
+ LS::NFTW.stat(
38
+ path,
39
+ flags ? flags : LS::NFTW::FTW_DEPTH | LS::NFTW::FTW_CONTINUE
40
+ )
41
+ end
42
+
43
+ ##
44
+ # Show info about all files in a given path and under its subdirectories.
45
+ # It accepts one argument:
46
+ # * path: Path is the expanded path that you want to walk through.
47
+ #
48
+ # The return value contains a Hash.
49
+ # The hash contains two keys: `error` and a `value`.
50
+ # * error: If there were any exceptions, the key will be set to true, otherwise false.
51
+ # Having an error means not all values are listed in the `value` array.
52
+ # * value: Is an array, it can or cannot be empty regardless of errors.
53
+ # The `value` key contains an array of Hashes. Each hash contains the following information about a file:
54
+ # 1. type_flag: Type of the file.
55
+ # 2. level: Depth of the file.
56
+ # 3. st_size: Size of the file in bytes.
57
+ # 4. path: Full path of the file.
58
+ # 5. dirname: directory of the file.
59
+ # 6. basename: basename of the file.
60
+ #
61
+ # Usage Example:
62
+ # LinuxStat::FTW.stat_files(File.expand_path('~/.rvm/lib/'))
63
+ # => {:value=>[{:type_flag=>:FTW_F, :level=>1, :st_size=>278, :path=>"/home/user/.rvm/lib/rvm.rb", :dirname=>"/home/user/.rvm/lib", :basename=>"rvm.rb"}, {:type_flag=>:FTW_F, :level=>2, :st_size=>286, :path=>"/home/user/.rvm/lib/rvm/capistrano.rb", :dirname=>"/home/user/.rvm/lib/rvm", :basename=>"capistrano.rb"}], :error=>false}
64
+ #
65
+ # Internally calls LinuxStat::NFTW.stat_files(path).
66
+ def stat_files(path = __dir__)
67
+ LS::NFTW.stat_files(path)
68
+ end
69
+
70
+ ##
71
+ # Count only files in a given path and under its subdirectories.
72
+ # It accepts one argument:
73
+ # * path: Path is the expanded path that you want to walk through.
74
+ #
75
+ # The return value is an Integer.
76
+ # Usage Example:
77
+ # LinuxStat::FTW.count_files(File.expand_path '~/.rvm/lib')
78
+ # => 2
79
+ #
80
+ # Internally calls LinuxStat::NFTW.count_files(path).
81
+ def count_files(path = __dir__)
82
+ LS::NFTW.count_files(path)
83
+ end
84
+
85
+ ##
86
+ # Count only directories in a given path and under its subdirectories.
87
+ # It accepts one argument:
88
+ # * path: Path is the expanded path that you want to walk through.
89
+ #
90
+ # The return value is an Integer.
91
+ # Usage Example:
92
+ # LinuxStat::FTW.count_directories(File.expand_path '~/.rvm/lib')
93
+ # => 1
94
+ #
95
+ # Internally calls LinuxStat::NFTW.count_directories(path).
96
+ def count_directories(path = __dir__)
97
+ LS::NFTW.count_directories(path)
98
+ end
99
+ end
100
+ end
101
+ end
@@ -47,7 +47,7 @@ module LinuxStat
47
47
 
48
48
  data = IO.readlines(DEV).drop(2)
49
49
  index = find_index_of_bytes[0]
50
- data.reject! { |x| x.strip.start_with?('lo:') }
50
+ data.reject! { |x| x.strip.start_with?('lo:'.freeze) }
51
51
  data.map { |x| x.split[index].to_i }.reduce(:+)
52
52
  end
53
53
 
@@ -60,7 +60,7 @@ module LinuxStat
60
60
 
61
61
  data = IO.readlines(DEV).drop(2)
62
62
  index = find_index_of_bytes[-1]
63
- data.reject! { |x| x.strip.start_with?('lo:') }
63
+ data.reject! { |x| x.strip.start_with?('lo:'.freeze) }
64
64
  data.map { |x| x.split[index].to_i }.reduce(:+)
65
65
  end
66
66
 
@@ -8,26 +8,24 @@ module LinuxStat
8
8
 
9
9
  module PrettifyBytes
10
10
  # Kilo = Kilobyte (1000 - 1), and so on...
11
- # 8.times { |x| puts 1000.**(x.next).to_s << '.00' }
12
- KILO = 1000.00
13
- MEGA = 1000000.00
14
- GIGA = 1000000000.00
15
- TERA = 1000000000000.00
16
- PETA = 1000000000000000.00
17
- EXA = 1000000000000000000.00
18
- ZETTA = 1000000000000000000000.00
19
- YOTTA = 1000000000000000000000000.00
11
+ KILO = 1e3
12
+ MEGA = 1e6
13
+ GIGA = 1e9
14
+ TERA = 1e12
15
+ PETA = 1e15
16
+ EXA = 1e18
17
+ ZETTA = 1e21
18
+ YOTTA = 1e24
20
19
 
21
20
  # Binary suffixes
22
- # 8.times { |x| puts 1024.**(x.next).to_s << '.00' }
23
- KIBI = 1024.00
24
- MEBI = 1048576.00
25
- GIBI = 1073741824.00
26
- TEBI = 1099511627776.00
27
- PEBI = 1125899906842624.00
28
- EXBI = 1152921504606846976.00
29
- ZEBI = 1180591620717411303424.00
30
- YOBI = 1208925819614629174706176.00
21
+ KIBI = 1024.0
22
+ MEBI = KIBI ** 2
23
+ GIBI = KIBI ** 3
24
+ TEBI = KIBI ** 4
25
+ PEBI = KIBI ** 5
26
+ EXBI = KIBI ** 6
27
+ ZEBI = KIBI ** 7
28
+ YOBI = KIBI ** 8
31
29
 
32
30
  class << self
33
31
  ##
@@ -50,28 +48,36 @@ module LinuxStat
50
48
  "#{"%.#{precision}f" % n} byte#{?s.freeze if n != 1}"
51
49
  elsif n < MEGA
52
50
  n /= KILO
53
- "#{"%.#{precision}f" % n} kilobyte#{?s.freeze if n != 1}"
51
+ n = n.round(precision)
52
+ %(#{"%.#{precision}f" % n} kilobyte#{?s.freeze if n. != 1})
54
53
  elsif n < GIGA
55
54
  n /= MEGA
56
- "#{"%.#{precision}f" % n} megabyte#{?s.freeze if n != 1}"
55
+ n = n.round(precision)
56
+ %(#{"%.#{precision}f" % n} megabyte#{?s.freeze if n != 1})
57
57
  elsif n < TERA
58
58
  n /= GIGA
59
- "#{"%.#{precision}f" % n} gigabyte#{?s.freeze if n != 1}"
59
+ n = n.round(precision)
60
+ %(#{"%.#{precision}f" % n} gigabyte#{?s.freeze if n != 1})
60
61
  elsif n < PETA
61
62
  n /= TERA
62
- "#{"%.#{precision}f" % n} terabyte#{?s.freeze if n != 1}"
63
+ n = n.round(precision)
64
+ %(#{"%.#{precision}f" % n} terabyte#{?s.freeze if n != 1})
63
65
  elsif n < EXA
64
66
  n /= PETA
65
- "#{"%.#{precision}f" % n} petabyte#{?s.freeze if n != 1}"
67
+ n = n.round(precision)
68
+ %(#{"%.#{precision}f" % n} petabyte#{?s.freeze if n != 1})
66
69
  elsif n < ZETTA
67
70
  n /= EXA
68
- "#{"%.#{precision}f" % n} exabyte#{?s.freeze if n != 1}"
71
+ n = n.round(precision)
72
+ %(#{"%.#{precision}f" % n} exabyte#{?s.freeze if n != 1})
69
73
  elsif n < YOTTA
70
74
  n /= ZETTA
71
- "#{"%.#{precision}f" % n} zettabyte#{?s.freeze if n != 1}"
75
+ n = n.round(precision)
76
+ %(#{"%.#{precision}f" % n} zettabyte#{?s.freeze if n != 1})
72
77
  else
73
78
  n /= YOTTA
74
- "#{"%.#{precision}f" % n} yottabyte#{?s.freeze if n != 1}"
79
+ n = n.round(precision)
80
+ %(#{"%.#{precision}f" % n} yottabyte#{?s.freeze if n != 1})
75
81
  end
76
82
  end
77
83
 
@@ -91,31 +97,39 @@ module LinuxStat
91
97
  # => "1.0 gibibyte"
92
98
  def convert_binary(n, precision: 2)
93
99
  if n < KIBI
94
- "#{"%.#{precision}f" % n} byte#{?s.freeze if n != 1}"
100
+ %Q(#{"%.#{precision}f" % n} byte#{?s.freeze if n != 1})
95
101
  elsif n < MEBI
96
102
  n /= KIBI
97
- "#{"%.#{precision}f" % n} kibibyte#{?s.freeze if n != 1}"
103
+ n = n.round(precision)
104
+ %Q(#{"%.#{precision}f" % n} kibibyte#{?s.freeze if n != 1})
98
105
  elsif n < GIBI
99
106
  n /= MEBI
100
- "#{"%.#{precision}f" % n} mebibyte#{?s.freeze if n != 1}"
107
+ n = n.round(precision)
108
+ %Q(#{"%.#{precision}f" % n} mebibyte#{?s.freeze if n != 1})
101
109
  elsif n < TEBI
102
110
  n /= GIBI
103
- "#{"%.#{precision}f" % n} gibibyte#{?s.freeze if n != 1}"
111
+ n = n.round(precision)
112
+ %Q(#{"%.#{precision}f" % n} gibibyte#{?s.freeze if n != 1})
104
113
  elsif n < PEBI
105
114
  n /= TEBI
106
- "#{"%.#{precision}f" % n} tebibyte#{?s.freeze if n != 1}"
115
+ n = n.round(precision)
116
+ %Q(#{"%.#{precision}f" % n} tebibyte#{?s.freeze if n != 1})
107
117
  elsif n < EXBI
108
118
  n /= PEBI
109
- "#{"%.#{precision}f" % n} pebibyte#{?s.freeze if n != 1}"
119
+ n = n.round(precision)
120
+ %Q(#{"%.#{precision}f" % n} pebibyte#{?s.freeze if n != 1})
110
121
  elsif n < ZEBI
111
122
  n /= EXBI
112
- "#{"%.#{precision}f" % n} exbiyte#{?s.freeze if n != 1}"
123
+ n = n.round(precision)
124
+ %Q(#{"%.#{precision}f" % n} exbiyte#{?s.freeze if n != 1})
113
125
  elsif n < YOBI
114
126
  n /= ZEBI
115
- "#{"%.#{precision}f" % n} zebibyte#{?s.freeze if n != 1}"
127
+ n = n.round(precision)
128
+ %Q(#{"%.#{precision}f" % n} zebibyte#{?s.freeze if n != 1})
116
129
  else
117
130
  n /= YOBI
118
- "#{"%.#{precision}f" % n} yobibyte#{?s.freeze if n != 1}"
131
+ n = n.round(precision)
132
+ %Q(#{"%.#{precision}f" % n} yobibyte#{?s.freeze if n != 1})
119
133
  end
120
134
  end
121
135
 
@@ -137,29 +151,21 @@ module LinuxStat
137
151
  if n < KILO
138
152
  "#{"%.#{precision}f" % n} B"
139
153
  elsif n < MEGA
140
- n /= KILO
141
- "#{"%.#{precision}f" % n} kB"
154
+ %(#{"%.#{precision}f" % n.fdiv(KILO)} kB)
142
155
  elsif n < GIGA
143
- n /= MEGA
144
- "#{"%.#{precision}f" % n} MB"
156
+ %(#{"%.#{precision}f" % n.fdiv(MEGA)} MB)
145
157
  elsif n < TERA
146
- n /= GIGA
147
- "#{"%.#{precision}f" % n} GB"
158
+ %(#{"%.#{precision}f" % n.fdiv(GIGA)} GB)
148
159
  elsif n < PETA
149
- n /= TERA
150
- "#{"%.#{precision}f" % n} TB"
160
+ %(#{"%.#{precision}f" % n.fdiv(TERA)} TB)
151
161
  elsif n < EXA
152
- n /= PETA
153
- "#{"%.#{precision}f" % n} PB"
162
+ %(#{"%.#{precision}f" % n.fdiv(PETA)} PB)
154
163
  elsif n < ZETTA
155
- n /= EXA
156
- "#{"%.#{precision}f" % n} EB"
164
+ %(#{"%.#{precision}f" % n.fdiv(EXA)} EB)
157
165
  elsif n < YOTTA
158
- n /= ZETTA
159
- "#{"%.#{precision}f" % n} ZB"
166
+ %(#{"%.#{precision}f" % n.fdiv(ZETTA)} ZB)
160
167
  else
161
- n /= YOTTA
162
- "#{"%.#{precision}f" % n} YB"
168
+ %(#{"%.#{precision}f" % n.fdiv(YOTTA)} YB)
163
169
  end
164
170
  end
165
171
 
@@ -181,31 +187,23 @@ module LinuxStat
181
187
  # => "1.0 GiB"
182
188
  def convert_short_binary(n, precision: 2)
183
189
  if n < KIBI
184
- "#{"%.#{precision}f" % n} B"
190
+ %(#{"%.#{precision}f" % n} B)
185
191
  elsif n < MEBI
186
- n /= KIBI
187
- "#{"%.#{precision}f" % n} KiB"
192
+ %(#{"%.#{precision}f" % n.fdiv(KIBI)} KiB)
188
193
  elsif n < GIBI
189
- n /= MEBI
190
- "#{"%.#{precision}f" % n} MiB"
194
+ %(#{"%.#{precision}f" % n.fdiv(MEBI)} MiB)
191
195
  elsif n < TEBI
192
- n /= GIBI
193
- "#{"%.#{precision}f" % n} GiB"
196
+ %(#{"%.#{precision}f" % n.fdiv(GIBI)} GiB)
194
197
  elsif n < PEBI
195
- n /= TEBI
196
- "#{"%.#{precision}f" % n} TiB"
198
+ %(#{"%.#{precision}f" % n.fdiv(TEBI)} TiB)
197
199
  elsif n < EXBI
198
- n /= PEBI
199
- "#{"%.#{precision}f" % n} PiB"
200
+ %(#{"%.#{precision}f" % n.fdiv(PEBI)} PiB)
200
201
  elsif n < ZEBI
201
- n /= EXBI
202
- "#{"%.#{precision}f" % n} EiB"
202
+ %(#{"%.#{precision}f" % n.fdiv(EXBI)} EiB)
203
203
  elsif n < YOBI
204
- n /= ZEBI
205
- "#{"%.#{precision}f" % n} ZiB"
204
+ %(#{"%.#{precision}f" % n.fdiv(ZEBI)} ZiB)
206
205
  else
207
- n /= YOBI
208
- "#{"%.#{precision}f" % n} YiB"
206
+ %(#{"%.#{precision}f" % n.fdiv(YOBI)} YiB)
209
207
  end
210
208
  end
211
209
  end
@@ -28,10 +28,11 @@ module LinuxStat
28
28
  #
29
29
  # If the info isn't available it will return an empty Hash.
30
30
  def total_io(pid = $$)
31
- return {} unless File.readable?("/proc/#{pid}/io".freeze)
31
+ io_file = "/proc/#{pid}/io"
32
+ return {} unless File.readable?(io_file)
32
33
  out = {}
33
34
 
34
- IO.readlines("/proc/#{pid}/io".freeze).each { |x|
35
+ IO.readlines(io_file).each { |x|
35
36
  x.strip!
36
37
 
37
38
  if x[/^(read|write)_bytes:\s*\d*$/]
@@ -59,7 +60,7 @@ module LinuxStat
59
60
  #
60
61
  # If the info isn't available it will return an empty frozen String.
61
62
  def cmdline(pid = $$)
62
- file = "/proc/#{pid}/cmdline".freeze
63
+ file = "/proc/#{pid}/cmdline"
63
64
  return ''.freeze unless File.readable?(file)
64
65
 
65
66
  _cmdline = IO.read(file)
@@ -110,7 +111,7 @@ module LinuxStat
110
111
  #
111
112
  # If the info isn't available it will return an empty frozen String.
112
113
  def process_name(pid = $$)
113
- file = "/proc/#{pid}/stat".freeze
114
+ file = "/proc/#{pid}/stat"
114
115
  return command_name unless File.readable?(file)
115
116
 
116
117
  name = IO.read(file).split(/(\(.*\))/) &.[](1) &.[](1..-2)
@@ -424,7 +425,7 @@ module LinuxStat
424
425
  #
425
426
  # If the info isn't available it returns an empty Array.
426
427
  def uid(pid = $$)
427
- file = "/proc/#{pid}/status".freeze
428
+ file = "/proc/#{pid}/status"
428
429
  return nil unless File.readable?(file)
429
430
 
430
431
  data = IO.foreach(file.freeze).find { |x|
@@ -448,7 +449,7 @@ module LinuxStat
448
449
  #
449
450
  # If the info isn't available or the argument passed doesn't exist as a process ID, it will return an empty Hash.
450
451
  def gid(pid = $$)
451
- file = "/proc/#{pid}/status".freeze
452
+ file = "/proc/#{pid}/status"
452
453
  return nil unless File.readable?(file)
453
454
 
454
455
  data = IO.foreach(file.freeze).find { |x|
@@ -469,7 +470,7 @@ module LinuxStat
469
470
  # Returns the owner of the process
470
471
  # But if the status is not available, it will return an empty frozen String.
471
472
  def owner(pid = $$)
472
- file = "/proc/#{pid}/status".freeze
473
+ file = "/proc/#{pid}/status"
473
474
  return ''.freeze unless File.readable?(file)
474
475
 
475
476
  gid = IO.foreach(file.freeze).find { |x|
@@ -1,3 +1,3 @@
1
1
  module LinuxStat
2
- VERSION = "2.5.3"
2
+ VERSION = "2.7.0".freeze
3
3
  end
data/lib/linux_stat.rb CHANGED
@@ -60,5 +60,9 @@ require "linux_stat/kernel"
60
60
  require 'linux_stat/user'
61
61
  require "linux_stat/process_info"
62
62
 
63
+ # LinuxStat::NFTW dependent modules
64
+ require "linux_stat/nftw"
65
+ require "linux_stat/ftw"
66
+
63
67
  # A short alias to LinuxStat
64
68
  LS = LinuxStat
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linux_stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourav Goswami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-08 00:00:00.000000000 Z
11
+ date: 2024-10-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Linux only, efficient linux system utilization reporting and system monitoring
14
14
  gem
@@ -19,6 +19,7 @@ executables:
19
19
  extensions:
20
20
  - ext/fs_stat/extconf.rb
21
21
  - ext/misc/integer/extconf.rb
22
+ - ext/nftw/extconf.rb
22
23
  - ext/nproc/extconf.rb
23
24
  - ext/procfs/extconf.rb
24
25
  - ext/sysconf/extconf.rb
@@ -38,6 +39,8 @@ files:
38
39
  - ext/fs_stat/sector_size.h
39
40
  - ext/misc/integer/extconf.rb
40
41
  - ext/misc/integer/integer?.c
42
+ - ext/nftw/extconf.rb
43
+ - ext/nftw/nftw.c
41
44
  - ext/nproc/extconf.rb
42
45
  - ext/nproc/nproc.c
43
46
  - ext/procfs/extconf.rb
@@ -57,6 +60,7 @@ files:
57
60
  - lib/linux_stat/bios.rb
58
61
  - lib/linux_stat/cpu.rb
59
62
  - lib/linux_stat/filesystem.rb
63
+ - lib/linux_stat/ftw.rb
60
64
  - lib/linux_stat/kernel.rb
61
65
  - lib/linux_stat/memory.rb
62
66
  - lib/linux_stat/mounts.rb
@@ -90,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
94
  - !ruby/object:Gem::Version
91
95
  version: '0'
92
96
  requirements: []
93
- rubygems_version: 3.3.8
97
+ rubygems_version: 3.5.21
94
98
  signing_key:
95
99
  specification_version: 4
96
100
  summary: Efficient linux system reporting gem