kanrisuru 0.8.4 → 0.8.8
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 +12 -0
- data/lib/kanrisuru/core/archive.rb +8 -7
- data/lib/kanrisuru/core/disk.rb +19 -14
- data/lib/kanrisuru/core/path.rb +2 -2
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/disk_spec.rb +15 -8
- data/spec/functional/core/path_spec.rb +3 -3
- data/spec/unit/core/disk_spec.rb +2 -1
- data/spec/unit/core/path_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 389f21ebed2d778e05d949ab651e91e7fd959c4249c32d936355fa1f093802db
|
|
4
|
+
data.tar.gz: f83d7f3385b871890a856470a140d6ce2c2efc7ceefdc4f6fe8b9e2f7a454beb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0185c24a3ff1bdbcc386999f63fb8544a18e8bf9c824e94d001be81785e6a10b7fb47cbcef421399e7e6b1bff805385d5dd4b253b8be7ce2b93fa94022d38596'
|
|
7
|
+
data.tar.gz: 74557bd5df7e1d10223a965d6c3e38fa8bed84f77ff4bfb75614abec344fd088299c7b4e92f9fb08b7aad1fa9630ee8c93d208dd40d3a4189ddf157bb048c694
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## Kanrisuru 0.8.8 (August 21, 2021) ##
|
|
2
|
+
* Add shorthand notation for tar command actions, such as `x` for `extract`, `t` for `list`, and `c` for `create`.
|
|
3
|
+
|
|
4
|
+
## Kanrisuru 0.8.7 (August 21, 2021) ##
|
|
5
|
+
* Fix `FileInfo` field for ls command. Was set to `memory_blocks`, but was incorrect, corrected this to `hard_links`.
|
|
6
|
+
|
|
7
|
+
## Kanrisuru 0.8.6 (August 21, 2021) ##
|
|
8
|
+
* Add `minimum_io_size`, `physical_sector_size`, and `logical_sector_size` to the blkid low level disk probe for devices.
|
|
9
|
+
|
|
10
|
+
## Kanrisuru 0.8.5 (August 20, 2021) ##
|
|
11
|
+
* 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.
|
|
12
|
+
|
|
1
13
|
## Kanrisuru 0.8.4 (August 20, 2021) ##
|
|
2
14
|
* Convert `fsize` field to an `integer` for du disk module command.
|
|
3
15
|
|
|
@@ -24,7 +24,7 @@ module Kanrisuru
|
|
|
24
24
|
set_compression(command, compress) if compress
|
|
25
25
|
|
|
26
26
|
case action
|
|
27
|
-
when 'list'
|
|
27
|
+
when 'list', 't'
|
|
28
28
|
command.append_flag('-t')
|
|
29
29
|
command.append_arg('--occurrence', opts[:occurrence])
|
|
30
30
|
command.append_flag('--label', opts[:label])
|
|
@@ -38,9 +38,10 @@ module Kanrisuru
|
|
|
38
38
|
FilePath.new(item)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
-
when 'extract', 'get'
|
|
41
|
+
when 'extract', 'get', 'x'
|
|
42
42
|
command.append_flag('-x')
|
|
43
43
|
command.append_arg('--occurrence', opts[:occurrence])
|
|
44
|
+
|
|
44
45
|
command.append_flag('--no-same-owner', opts[:no_same_owner])
|
|
45
46
|
command.append_flag('--no-same-permissions', opts[:no_same_permissions])
|
|
46
47
|
command.append_flag('--no-selinux', opts[:no_selinux])
|
|
@@ -64,7 +65,7 @@ module Kanrisuru
|
|
|
64
65
|
|
|
65
66
|
execute_shell(command)
|
|
66
67
|
Kanrisuru::Result.new(command)
|
|
67
|
-
when 'create'
|
|
68
|
+
when 'create', 'c'
|
|
68
69
|
command.append_flag('-c')
|
|
69
70
|
command.append_flag('--multi-volume', opts[:multi_volume])
|
|
70
71
|
|
|
@@ -81,7 +82,7 @@ module Kanrisuru
|
|
|
81
82
|
execute_shell(command)
|
|
82
83
|
|
|
83
84
|
Kanrisuru::Result.new(command)
|
|
84
|
-
when 'append'
|
|
85
|
+
when 'append', 'r'
|
|
85
86
|
command.append_flag('-r')
|
|
86
87
|
|
|
87
88
|
if Kanrisuru::Util.present?(paths)
|
|
@@ -91,7 +92,7 @@ module Kanrisuru
|
|
|
91
92
|
|
|
92
93
|
execute_shell(command)
|
|
93
94
|
Kanrisuru::Result.new(command)
|
|
94
|
-
when 'catenate', 'concat'
|
|
95
|
+
when 'catenate', 'concat', 'A'
|
|
95
96
|
command.append_flag('-A')
|
|
96
97
|
|
|
97
98
|
if Kanrisuru::Util.present?(paths)
|
|
@@ -101,7 +102,7 @@ module Kanrisuru
|
|
|
101
102
|
|
|
102
103
|
execute_shell(command)
|
|
103
104
|
Kanrisuru::Result.new(command)
|
|
104
|
-
when 'update'
|
|
105
|
+
when 'update', 'u'
|
|
105
106
|
command.append_flag('-u')
|
|
106
107
|
|
|
107
108
|
if Kanrisuru::Util.present?(paths)
|
|
@@ -111,7 +112,7 @@ module Kanrisuru
|
|
|
111
112
|
|
|
112
113
|
execute_shell(command)
|
|
113
114
|
Kanrisuru::Result.new(command)
|
|
114
|
-
when 'diff', 'compare'
|
|
115
|
+
when 'diff', 'compare', 'd'
|
|
115
116
|
command.append_flag('-d')
|
|
116
117
|
command.append_arg('--occurrence', opts[:occurrence])
|
|
117
118
|
|
data/lib/kanrisuru/core/disk.rb
CHANGED
|
@@ -22,27 +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
|
|
30
|
-
|
|
30
|
+
path = opts[:path]
|
|
31
|
+
summarize = opts[:summarize]
|
|
32
|
+
convert = opts[:convert]
|
|
31
33
|
|
|
32
34
|
command = Kanrisuru::Command.new('du')
|
|
33
|
-
command.
|
|
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
|
-
|
|
40
|
-
rows = string.split("\n")
|
|
42
|
+
lines = cmd.to_a
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
values =
|
|
44
|
+
lines.map do |line|
|
|
45
|
+
values = line.split
|
|
44
46
|
size = values[0].to_i
|
|
45
|
-
size = convert ? Kanrisuru::Util::Bits.convert_bytes(size, :byte, convert) : size
|
|
47
|
+
size = convert ? Kanrisuru::Util::Bits.convert_bytes(size, :byte, convert) : size
|
|
46
48
|
|
|
47
49
|
DiskUsage.new(size, values[1])
|
|
48
50
|
end
|
|
@@ -98,7 +100,7 @@ module Kanrisuru
|
|
|
98
100
|
command.append_arg('-U', opts[:uuid])
|
|
99
101
|
elsif Kanrisuru::Util.present?(device)
|
|
100
102
|
mode = 'device'
|
|
101
|
-
command.append_arg('-
|
|
103
|
+
command.append_arg('-pio', 'export')
|
|
102
104
|
command << device
|
|
103
105
|
else
|
|
104
106
|
mode = 'list'
|
|
@@ -113,10 +115,7 @@ module Kanrisuru
|
|
|
113
115
|
cmd.to_s
|
|
114
116
|
when 'device'
|
|
115
117
|
lines = cmd.to_a
|
|
116
|
-
|
|
117
|
-
## Only gets 1 device
|
|
118
|
-
devices = blkid_devices(lines)
|
|
119
|
-
devices[0]
|
|
118
|
+
blkid_devices(lines)
|
|
120
119
|
else
|
|
121
120
|
lines = cmd.to_a
|
|
122
121
|
blkid_devices(lines)
|
|
@@ -188,6 +187,12 @@ module Kanrisuru
|
|
|
188
187
|
current_device.usage = value
|
|
189
188
|
elsif line =~ /^VERSION=/
|
|
190
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
|
|
191
196
|
elsif line =~ /^PART_ENTRY_SCHEME=/
|
|
192
197
|
current_device.part_entry_scheme = value
|
|
193
198
|
elsif line =~ /^PART_ENTRY_UUID=/
|
data/lib/kanrisuru/core/path.rb
CHANGED
|
@@ -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, :
|
|
19
|
-
FileInfo = Struct.new(:inode, :mode, :
|
|
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 = {})
|
data/lib/kanrisuru/version.rb
CHANGED
|
@@ -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
|
|
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
|
|
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(
|
|
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.
|
|
32
|
+
expect(file.owner).to eq(1000)
|
|
33
33
|
|
|
34
34
|
case os_name
|
|
35
35
|
when 'opensuse', 'sles'
|
|
36
|
-
expect(file.
|
|
36
|
+
expect(file.group).to eq(100)
|
|
37
37
|
else
|
|
38
|
-
expect(file.
|
|
38
|
+
expect(file.group).to eq(1000)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
data/spec/unit/core/disk_spec.rb
CHANGED
|
@@ -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
|
data/spec/unit/core/path_spec.rb
CHANGED
|
@@ -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, :
|
|
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, :
|
|
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.
|
|
4
|
+
version: 0.8.8
|
|
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-
|
|
11
|
+
date: 2021-08-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|