kanrisuru 0.8.2 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce41108c8201af2a48ac2453f8dc3fb993869e9264a8754d603a11d09ffe1cb5
4
- data.tar.gz: 542d34622a949d0eb5ddddc1d7403f13e9e37dfb39cb88b589c7655a2a34a3e4
3
+ metadata.gz: 3cf097324010e600d653651749e4269d4befe7e2b6ccc1b17cc2b31ee53d1991
4
+ data.tar.gz: febb4bc33e7a1a1810c00d1deddd5c39a30ae961f74204245277984274b2d2b7
5
5
  SHA512:
6
- metadata.gz: 7aea2688091ff8449f21eb11cd2fdcb51d71563538fd9c9e38a484770adb8745663a3132314b0001d9e6206dbd57533fe2626af1c59e2ada6d0ea394e2fdd113
7
- data.tar.gz: 054a8612edecb94b79bd6b7488096ae12d4fee790d17cf295d4a04f397282ae2c9f5e4a977a37145bd4fc37bf0896a2a9bbd43098762ff65496de29804aa6a0b
6
+ metadata.gz: bccf90abb47b07d52bcf2e791830e38380e009ef19fad30f896d979325f6133c5531676b3d3e79555c9090624f15794ec8884d9c889e57c1a150258107b39e3a
7
+ data.tar.gz: d5f17fc9c9a6f80257d5bf54ee1d2e28aa48d9de0859b7abda2f8ed695b1003aff98c3f2ee75b3dc5317eb7b9d8c947b205133b9b92f0d8af727f9d827ed4b45
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
+ ## Kanrisuru 0.8.6 (August 21, 2021) ##
2
+ * Add `minimum_io_size`, `physical_sector_size`, and `logical_sector_size` to the blkid low level disk probe for devices.
3
+
4
+ ## Kanrisuru 0.8.5 (August 20, 2021) ##
5
+ * 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.
6
+
7
+ ## Kanrisuru 0.8.4 (August 20, 2021) ##
8
+ * Convert `fsize` field to an `integer` for du disk module command.
9
+
10
+ ## Kanrisuru 0.8.3 (August 20, 2021) ##
11
+ * Fix bug with disk usage, `du` command by escaping the awk variables in the command.
12
+ * Update `du` command to execute with shell user.
13
+
1
14
  ## Kanrisuru 0.8.2 (August 19, 2021) ##
2
- * Convert `major` and `minor` device field values to an `integer` in lsblk system module.
15
+ * Convert `major` and `minor` device field values to an `integer` in lsblk disk module.
3
16
 
4
17
  ## Kanrisuru 0.8.1 (August 19, 2021) ##
5
18
  * Fix `nodeps` flag value for `lsblk` command in disk module.
@@ -22,26 +22,29 @@ module Kanrisuru
22
22
  BlkidDevice = Struct.new(
23
23
  :name, :label, :uuid, :type, :uuid_sub, :label_fatboot, :version, :usage,
24
24
  :part_uuid, :part_entry_scheme, :part_entry_uuid, :part_entry_type,
25
- :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk
25
+ :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk,
26
+ :minimum_io_size, :physical_sector_size, :logical_sector_size,
26
27
  )
27
28
 
28
29
  def du(opts = {})
29
- path = opts[:path]
30
- convert = opts[:convert]
30
+ path = opts[:path]
31
+ summarize = opts[:summarize]
32
+ convert = opts[:convert]
31
33
 
32
34
  command = Kanrisuru::Command.new('du')
33
- command.append_arg('-s', path)
34
- command | "awk '{print $1, $2}'"
35
+ command.append_flag('-s', summarize)
36
+ command << path if Kanrisuru::Util.present?(path)
37
+ command | "awk '{print \\$1, \\$2}'"
35
38
 
36
- execute(command)
39
+ execute_shell(command)
37
40
 
38
41
  Kanrisuru::Result.new(command) do |cmd|
39
- string = cmd.to_s
40
- rows = string.split("\n")
42
+ lines = cmd.to_a
41
43
 
42
- rows.map do |row|
43
- values = row.split
44
- size = convert ? Kanrisuru::Util::Bits.convert_bytes(values[0], :byte, convert) : values[0]
44
+ lines.map do |line|
45
+ values = line.split
46
+ size = values[0].to_i
47
+ size = convert ? Kanrisuru::Util::Bits.convert_bytes(size, :byte, convert) : size
45
48
 
46
49
  DiskUsage.new(size, values[1])
47
50
  end
@@ -97,7 +100,7 @@ module Kanrisuru
97
100
  command.append_arg('-U', opts[:uuid])
98
101
  elsif Kanrisuru::Util.present?(device)
99
102
  mode = 'device'
100
- command.append_arg('-po', 'export')
103
+ command.append_arg('-pio', 'export')
101
104
  command << device
102
105
  else
103
106
  mode = 'list'
@@ -112,10 +115,7 @@ module Kanrisuru
112
115
  cmd.to_s
113
116
  when 'device'
114
117
  lines = cmd.to_a
115
-
116
- ## Only gets 1 device
117
- devices = blkid_devices(lines)
118
- devices[0]
118
+ blkid_devices(lines)
119
119
  else
120
120
  lines = cmd.to_a
121
121
  blkid_devices(lines)
@@ -187,6 +187,12 @@ module Kanrisuru
187
187
  current_device.usage = value
188
188
  elsif line =~ /^VERSION=/
189
189
  current_device.version = value.to_f
190
+ elsif line =~ /^MINIMUM_IO_SIZE=/
191
+ current_device.minimum_io_size = value.to_i
192
+ elsif line =~ /^PHYSICAL_SECTOR_SIZE=/
193
+ current_device.physical_sector_size = value.to_i
194
+ elsif line =~ /^LOGICAL_SECTOR_SIZE=/
195
+ current_device.logical_sector_size = value.to_i
190
196
  elsif line =~ /^PART_ENTRY_SCHEME=/
191
197
  current_device.part_entry_scheme = value
192
198
  elsif line =~ /^PART_ENTRY_UUID=/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.8.2'
4
+ VERSION = '0.8.6'
5
5
  end
@@ -37,10 +37,11 @@ RSpec.describe Kanrisuru::Core::Disk do
37
37
  # puts device.name
38
38
  # puts result.inspect
39
39
  expect(result.success?).to eq(true)
40
- expect(result.data).to respond_to(
40
+ expect(result.data[0]).to respond_to(
41
41
  :name, :label, :uuid, :type, :uuid_sub, :label_fatboot, :version, :usage,
42
42
  :part_uuid, :part_entry_scheme, :part_entry_uuid, :part_entry_type,
43
- :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk
43
+ :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk,
44
+ :minimum_io_size, :physical_sector_size, :logical_sector_size,
44
45
  )
45
46
  end
46
47
 
@@ -59,12 +60,25 @@ RSpec.describe Kanrisuru::Core::Disk do
59
60
  )
60
61
  end
61
62
 
62
- it 'gets disk usage' do
63
- result = host.du(path: "#{host_json['home']}/.bashrc")
64
- expect(result.success?).to eq(true)
63
+ it 'gets summarize disk usage' do
64
+ result = host.du(path: "#{host_json['home']}/.bashrc", summarize: true)
65
+ expect(result).to be_success
65
66
  expect(result[0].path).to eq("#{host_json['home']}/.bashrc")
66
67
  end
67
68
 
69
+ it 'gets all disk usage' do
70
+ result = host.du(path: host_json['home'])
71
+ expect(result).to be_success
72
+ expect(result.data.length).to be >= 2
73
+ end
74
+
75
+ it 'gets summarized disk usage root user' do
76
+ host.su('root')
77
+ result = host.du(path: '/etc', summarize: true)
78
+ expect(result).to be_success
79
+ expect(result[0].path).to eq('/etc')
80
+ end
81
+
68
82
  it 'gets disk free for system' do
69
83
  expect(host.df.data).to be_instance_of(Array)
70
84
  expect(host.df(inodes: true).data).to be_instance_of(Array)
@@ -15,7 +15,8 @@ RSpec.describe Kanrisuru::Core::Disk do
15
15
  expect(Kanrisuru::Core::Disk::BlkidDevice.new).to respond_to(
16
16
  :name, :label, :uuid, :type, :uuid_sub, :label_fatboot, :version, :usage,
17
17
  :part_uuid, :part_entry_scheme, :part_entry_uuid, :part_entry_type,
18
- :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk
18
+ :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk,
19
+ :minimum_io_size, :physical_sector_size, :logical_sector_size
19
20
  )
20
21
  end
21
22
  end
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.2
4
+ version: 0.8.6
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-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec