kanrisuru 0.8.1 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/kanrisuru/core/disk.rb +18 -14
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/disk_spec.rb +16 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e165b21ec0ad68281ccbb6dd27277d5fe77833d9c27382f8c5233dc93c128ba8
|
4
|
+
data.tar.gz: 2ab686965334402864a17586c1e45724d3163a4ed84833f4b904dc0834e1bb68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88820369f4d9f10dbe9d4200cecc4804aff4ddb29322cd4c7dd399c1739b2f2736ac6e2346666717e5949a3bbac0cbcf12a2e681706f591c93d9da4144b4c035
|
7
|
+
data.tar.gz: 6f1eadc3de432097d35dbf5f42b3fc3a9d9b6eabf3cc697551ea71f9b6547875f36407d821e61ec9bfc257d76f96f4e7dcd2d0ae2c65baab03b32f34f2618411
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## Kanrisuru 0.8.5 (August 20, 2021) ##
|
2
|
+
* Add `summarize` option to `du` command. This will only output a total disk usage size for the entire directory versus disk usage for each file individually.
|
3
|
+
|
4
|
+
## Kanrisuru 0.8.4 (August 20, 2021) ##
|
5
|
+
* Convert `fsize` field to an `integer` for du disk module command.
|
6
|
+
|
7
|
+
## Kanrisuru 0.8.3 (August 20, 2021) ##
|
8
|
+
* Fix bug with disk usage, `du` command by escaping the awk variables in the command.
|
9
|
+
* Update `du` command to execute with shell user.
|
10
|
+
|
11
|
+
## Kanrisuru 0.8.2 (August 19, 2021) ##
|
12
|
+
* Convert `major` and `minor` device field values to an `integer` in lsblk disk module.
|
13
|
+
|
1
14
|
## Kanrisuru 0.8.1 (August 19, 2021) ##
|
2
15
|
* Fix `nodeps` flag value for `lsblk` command in disk module.
|
3
16
|
|
data/lib/kanrisuru/core/disk.rb
CHANGED
@@ -26,22 +26,26 @@ module Kanrisuru
|
|
26
26
|
)
|
27
27
|
|
28
28
|
def du(opts = {})
|
29
|
-
path
|
30
|
-
|
29
|
+
path = opts[:path]
|
30
|
+
summarize = opts[:summarize]
|
31
|
+
convert = opts[:convert]
|
31
32
|
|
32
33
|
command = Kanrisuru::Command.new('du')
|
33
|
-
command.
|
34
|
-
command | "awk '{print $1, $2}'"
|
34
|
+
command.append_flag('-s', summarize)
|
35
35
|
|
36
|
-
|
36
|
+
command << path if Kanrisuru::Util.present?(path)
|
37
|
+
|
38
|
+
command | "awk '{print \\$1, \\$2}'"
|
39
|
+
|
40
|
+
execute_shell(command)
|
37
41
|
|
38
42
|
Kanrisuru::Result.new(command) do |cmd|
|
39
|
-
|
40
|
-
rows = string.split("\n")
|
43
|
+
lines = cmd.to_a
|
41
44
|
|
42
|
-
|
43
|
-
values =
|
44
|
-
size =
|
45
|
+
lines.map do |line|
|
46
|
+
values = line.split
|
47
|
+
size = values[0].to_i
|
48
|
+
size = convert ? Kanrisuru::Util::Bits.convert_bytes(size, :byte, convert) : size
|
45
49
|
|
46
50
|
DiskUsage.new(size, values[1])
|
47
51
|
end
|
@@ -244,8 +248,8 @@ module Kanrisuru
|
|
244
248
|
current_device.fs_type = value
|
245
249
|
when 'MAJ:MIN'
|
246
250
|
maj, min = value.split(':')
|
247
|
-
current_device.maj_dev = maj
|
248
|
-
current_device.min_dev = min
|
251
|
+
current_device.maj_dev = maj ? maj.to_i : nil
|
252
|
+
current_device.min_dev = min ? min.to_i : nil
|
249
253
|
when 'MOUNTPOINT'
|
250
254
|
current_device.mount_point = value
|
251
255
|
when 'SIZE'
|
@@ -281,8 +285,8 @@ module Kanrisuru
|
|
281
285
|
|
282
286
|
LsblkDevice.new(
|
283
287
|
device['name'],
|
284
|
-
maj_min ? maj_min.split(':')[0] : nil,
|
285
|
-
maj_min ? maj_min.split(':')[1] : nil,
|
288
|
+
maj_min ? maj_min.split(':')[0].to_i : nil,
|
289
|
+
maj_min ? maj_min.split(':')[1].to_i : nil,
|
286
290
|
device['rm'],
|
287
291
|
device['ro'],
|
288
292
|
device['owner'],
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -59,12 +59,25 @@ RSpec.describe Kanrisuru::Core::Disk do
|
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
-
it 'gets disk usage' do
|
63
|
-
result = host.du(path: "#{host_json['home']}/.bashrc")
|
64
|
-
expect(result
|
62
|
+
it 'gets summarize disk usage' do
|
63
|
+
result = host.du(path: "#{host_json['home']}/.bashrc", summarize: true)
|
64
|
+
expect(result).to be_success
|
65
65
|
expect(result[0].path).to eq("#{host_json['home']}/.bashrc")
|
66
66
|
end
|
67
67
|
|
68
|
+
it 'gets all disk usage' do
|
69
|
+
result = host.du(path: host_json['home'])
|
70
|
+
expect(result).to be_success
|
71
|
+
expect(result.data.length).to be >= 2
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'gets summarized disk usage root user' do
|
75
|
+
host.su('root')
|
76
|
+
result = host.du(path: '/etc', summarize: true)
|
77
|
+
expect(result).to be_success
|
78
|
+
expect(result[0].path).to eq('/etc')
|
79
|
+
end
|
80
|
+
|
68
81
|
it 'gets disk free for system' do
|
69
82
|
expect(host.df.data).to be_instance_of(Array)
|
70
83
|
expect(host.df(inodes: true).data).to be_instance_of(Array)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|