kanrisuru 0.8.3 → 0.8.7

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: 7986958e7a5a32bb79f6f8cd225b73e996f68329e9adb95c324ad898efaa8bdc
4
- data.tar.gz: '02279420cd5ff6017234d4058847173f3be44810267e57c59cb2b09be8f9dadc'
3
+ metadata.gz: 401e4f3fbff30e96891e65a0cb9d1916d022f1128c3667de554776c775ea0b19
4
+ data.tar.gz: 7e560e7e8c6e217fab2bf8b5afbe9c57224e488bac510cc58305d990880b0a7e
5
5
  SHA512:
6
- metadata.gz: 7fedbd06614d36213c5d7df56c22e1f88ecb5b41732704a02b41eff1272559db3f8dc22eaa1112188cd5b0204f4c81f40e1d7f66689c41ca2d34ef0c125fbd9e
7
- data.tar.gz: a451f3c5c4cb26ff0bf733371175c99f148ccd9531bcf0366b08d063b4ac495b1fdd3aafe47ff40b4a2cbd9df94b2de3c7dff8e0afa1f9717b3e54271a4ef75b
6
+ metadata.gz: 715a07d652de292cdc587b49b4a5b43b373e5eac5c225439c5fb15a464a860a8cdee43a13c5a2e2439c13f21d2afb0d8000deaf3146148febb7b2b0fb9114c21
7
+ data.tar.gz: f1ff0104249a8524d3d8d6c8bf7730af8ad0a55e84ef5a1c9ec75926c8f922c11aa7e46e9086dda36c2a0e6373008649e279182a1cc0aa8e74187bbab3f52e57
data/CHANGELOG.md CHANGED
@@ -1,9 +1,21 @@
1
+ ## Kanrisuru 0.8.7 (August 21, 2021) ##
2
+ * Fix `FileInfo` field for ls command. Was set to `memory_blocks`, but was incorrect, corrected this to `hard_links`.
3
+
4
+ ## Kanrisuru 0.8.6 (August 21, 2021) ##
5
+ * Add `minimum_io_size`, `physical_sector_size`, and `logical_sector_size` to the blkid low level disk probe for devices.
6
+
7
+ ## Kanrisuru 0.8.5 (August 20, 2021) ##
8
+ * 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.
9
+
10
+ ## Kanrisuru 0.8.4 (August 20, 2021) ##
11
+ * Convert `fsize` field to an `integer` for du disk module command.
12
+
1
13
  ## Kanrisuru 0.8.3 (August 20, 2021) ##
2
14
  * Fix bug with disk usage, `du` command by escaping the awk variables in the command.
3
- * Update `du` command to execute with shell user.
15
+ * Update `du` command to execute with shell user.
4
16
 
5
17
  ## Kanrisuru 0.8.2 (August 19, 2021) ##
6
- * Convert `major` and `minor` device field values to an `integer` in lsblk system module.
18
+ * Convert `major` and `minor` device field values to an `integer` in lsblk disk module.
7
19
 
8
20
  ## Kanrisuru 0.8.1 (August 19, 2021) ##
9
21
  * 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)
35
+ command.append_flag('-s', summarize)
36
+ command << path if Kanrisuru::Util.present?(path)
34
37
  command | "awk '{print \\$1, \\$2}'"
35
38
 
36
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=/
@@ -15,8 +15,8 @@ module Kanrisuru
15
15
  os_define :linux, :which
16
16
 
17
17
  FilePath = Struct.new(:path)
18
- FileInfoId = Struct.new(:inode, :mode, :memory_blocks, :uid, :gid, :fsize, :date, :path, :type)
19
- FileInfo = Struct.new(:inode, :mode, :memory_blocks, :owner, :group, :fsize, :date, :path, :type)
18
+ FileInfoId = Struct.new(:inode, :mode, :hard_links, :uid, :gid, :fsize, :date, :path, :type)
19
+ FileInfo = Struct.new(:inode, :mode, :hard_links, :owner, :group, :fsize, :date, :path, :type)
20
20
  UserName = Struct.new(:user)
21
21
 
22
22
  def ls(opts = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.8.3'
4
+ VERSION = '0.8.7'
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,17 +60,23 @@ 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
 
68
- it 'gets disk usage root' do
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
69
76
  host.su('root')
70
- result = host.du(path: '/etc')
77
+ result = host.du(path: '/etc', summarize: true)
71
78
  expect(result).to be_success
72
- expect(result[0].path).to eq("/etc")
79
+ expect(result[0].path).to eq('/etc')
73
80
  end
74
81
 
75
82
  it 'gets disk free for system' do
@@ -29,13 +29,13 @@ RSpec.describe Kanrisuru::Core::Path do
29
29
  expect(result.data).to be_instance_of(Array)
30
30
 
31
31
  file = result.find { |f| f.path == '.bashrc' }
32
- expect(file.uid).to eq(1000)
32
+ expect(file.owner).to eq(1000)
33
33
 
34
34
  case os_name
35
35
  when 'opensuse', 'sles'
36
- expect(file.gid).to eq(100)
36
+ expect(file.group).to eq(100)
37
37
  else
38
- expect(file.gid).to eq(1000)
38
+ expect(file.group).to eq(1000)
39
39
  end
40
40
  end
41
41
 
@@ -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
@@ -6,10 +6,10 @@ RSpec.describe Kanrisuru::Core::Path do
6
6
  it 'responds to path fields' do
7
7
  expect(Kanrisuru::Core::Path::FilePath.new).to respond_to(:path)
8
8
  expect(Kanrisuru::Core::Path::FileInfoId.new).to respond_to(
9
- :inode, :mode, :memory_blocks, :uid, :gid, :fsize, :date, :path, :type
9
+ :inode, :mode, :hard_links, :uid, :gid, :fsize, :date, :path, :type
10
10
  )
11
11
  expect(Kanrisuru::Core::Path::FileInfo.new).to respond_to(
12
- :inode, :mode, :memory_blocks, :owner, :group, :fsize, :date, :path, :type
12
+ :inode, :mode, :hard_links, :owner, :group, :fsize, :date, :path, :type
13
13
  )
14
14
  expect(Kanrisuru::Core::Path::UserName.new).to respond_to(:user)
15
15
  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.3
4
+ version: 0.8.7
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-20 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