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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7548306bf7e81fd29f475dfef82c4b8f0973448f22f3cb8882518ace8e70389
4
- data.tar.gz: c069633d4408c38333cd3dacfade92678f0309a1b53e435238d6f0814598ec73
3
+ metadata.gz: e165b21ec0ad68281ccbb6dd27277d5fe77833d9c27382f8c5233dc93c128ba8
4
+ data.tar.gz: 2ab686965334402864a17586c1e45724d3163a4ed84833f4b904dc0834e1bb68
5
5
  SHA512:
6
- metadata.gz: fbd31bc19b021a3d904b8a9c3d167921a47c709ca05b0590fa1dab5d0032181d454b7da0572760cfebe36286456e3a10547bb14bd6fb60c71413de533daa48a8
7
- data.tar.gz: '0710940fec60fab2802a9810d6b5a6bb48f575c8ef8661c2447fbe8dc445ac68a3fb174ed1dd6413689439303983ee229e2ebb08cc1b1c0e68007db3346c2219'
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
 
@@ -26,23 +26,26 @@ module Kanrisuru
26
26
  )
27
27
 
28
28
  def du(opts = {})
29
- path = opts[:path]
30
- convert = opts[:convert]
29
+ path = opts[:path]
30
+ summarize = opts[:summarize]
31
+ convert = opts[:convert]
31
32
 
32
33
  command = Kanrisuru::Command.new('du')
33
- command.append_arg('-s', path)
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
- string = cmd.to_s
40
- rows = string.split("\n")
43
+ lines = cmd.to_a
41
44
 
42
- rows.map do |row|
43
- values = row.split
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.8.4'
4
+ VERSION = '0.8.5'
5
5
  end
@@ -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.success?).to eq(true)
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 root' do
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("/etc")
78
+ expect(result[0].path).to eq('/etc')
73
79
  end
74
80
 
75
81
  it 'gets disk free for system' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanrisuru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mammina