kanrisuru 0.8.4 → 0.8.5
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/CHANGELOG.md +3 -0
- data/lib/kanrisuru/core/disk.rb +11 -8
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/disk_spec.rb +12 -6
- 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: 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,6 @@
|
|
|
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
|
+
|
|
1
4
|
## Kanrisuru 0.8.4 (August 20, 2021) ##
|
|
2
5
|
* Convert `fsize` field to an `integer` for du disk module command.
|
|
3
6
|
|
data/lib/kanrisuru/core/disk.rb
CHANGED
|
@@ -26,23 +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.append_flag('-s', summarize)
|
|
35
|
+
|
|
36
|
+
command << path if Kanrisuru::Util.present?(path)
|
|
37
|
+
|
|
34
38
|
command | "awk '{print \\$1, \\$2}'"
|
|
35
39
|
|
|
36
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 =
|
|
45
|
+
lines.map do |line|
|
|
46
|
+
values = line.split
|
|
44
47
|
size = values[0].to_i
|
|
45
|
-
size = convert ? Kanrisuru::Util::Bits.convert_bytes(size, :byte, convert) : size
|
|
48
|
+
size = convert ? Kanrisuru::Util::Bits.convert_bytes(size, :byte, convert) : size
|
|
46
49
|
|
|
47
50
|
DiskUsage.new(size, values[1])
|
|
48
51
|
end
|
data/lib/kanrisuru/version.rb
CHANGED
|
@@ -59,17 +59,23 @@ 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 disk usage
|
|
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
|
|
69
75
|
host.su('root')
|
|
70
|
-
result = host.du(path: '/etc')
|
|
76
|
+
result = host.du(path: '/etc', summarize: true)
|
|
71
77
|
expect(result).to be_success
|
|
72
|
-
expect(result[0].path).to eq(
|
|
78
|
+
expect(result[0].path).to eq('/etc')
|
|
73
79
|
end
|
|
74
80
|
|
|
75
81
|
it 'gets disk free for system' do
|