kanrisuru 0.8.1 → 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: fb2d3362a0cb76eee232056937ae6d81c0d40c24d0a1bbafed6f78cbbfeda880
4
- data.tar.gz: 3f8ddb4ed3d24ad2741f619bd3f12553ddd26181f42301dbe8c165ade253c006
3
+ metadata.gz: e165b21ec0ad68281ccbb6dd27277d5fe77833d9c27382f8c5233dc93c128ba8
4
+ data.tar.gz: 2ab686965334402864a17586c1e45724d3163a4ed84833f4b904dc0834e1bb68
5
5
  SHA512:
6
- metadata.gz: c6e633ff0d3008cd8bd3ba003bf5c2bf0a5892e9e44c1eb0aeefe2435c4a5f7703ae088cede78a80ac01aa8aef11e6733f1a9926dac646f3d51f943e3a4be1e9
7
- data.tar.gz: a163204d160ab1dff741f18f02a013b5a7cb3a274fc2fa7dd3c00ca9115809fbf64794ec4a075bfb4609019d81ab63fdf90385424a05aeaff2cfb959c2b2916d
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
 
@@ -26,22 +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 | "awk '{print $1, $2}'"
34
+ command.append_flag('-s', summarize)
35
35
 
36
- execute(command)
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
- 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
44
- size = convert ? Kanrisuru::Util::Bits.convert_bytes(values[0], :byte, convert) : values[0]
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'],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.5'
5
5
  end
@@ -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.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 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.1
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-19 00:00:00.000000000 Z
11
+ date: 2021-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec