smp_tool-cli 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/smp_tool/cli/executor/base.rb +0 -47
- data/lib/smp_tool/cli/executor/bin_write_mixin.rb +6 -7
- data/lib/smp_tool/cli/executor/extracter_base.rb +2 -2
- data/lib/smp_tool/cli/executor/extracter_raw_base.rb +6 -3
- data/lib/smp_tool/cli/executor/extracter_txt_base.rb +6 -3
- data/lib/smp_tool/cli/executor/vol_read_operator.rb +3 -28
- data/lib/smp_tool/cli/version.rb +1 -1
- 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: 3149aa9dc1f632c851d3eb26f0a7789a793915fade6999067efa2869b2190e38
|
4
|
+
data.tar.gz: 71b57cabecc20c1a3ef3f45f69a44a908349ee3a91783d54f911a42c3c10f58a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e558d4ce08db06194481a202b21e42b9e350a346f4c0819dfa493d25e1b06dbf3ed3ce83934c6aff390210d81465c8a3e3f37bde6ede2079cd1fa87f859d3efe
|
7
|
+
data.tar.gz: 60fca9c7337d7934b8b8f9270d8e9db3cdd57b2fe04eb48f133b91a2564cfb75cbe935a16597c17ffe9c5f13fca47dc0f933002ed5cafbf2f340807162832099
|
data/CHANGELOG.md
CHANGED
@@ -12,53 +12,6 @@ module SMPTool
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call; end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
#
|
19
|
-
# Save volume to a binary file.
|
20
|
-
#
|
21
|
-
# @param [String] path
|
22
|
-
# Path to the destination file.
|
23
|
-
#
|
24
|
-
# @param [SMPTool::VirtualVolume::Volume] volume
|
25
|
-
#
|
26
|
-
# @param [Hash{ Symbol => Object }] **_options
|
27
|
-
#
|
28
|
-
def _save_volume(path:, volume:, **_options)
|
29
|
-
b_str = _volume_to_binary(volume)
|
30
|
-
@logger.debug "Converted to binary string."
|
31
|
-
|
32
|
-
_write_bin_file(
|
33
|
-
path,
|
34
|
-
b_str
|
35
|
-
)
|
36
|
-
|
37
|
-
@logger.info "Changes saved to the file: '#{path}'"
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Convert virtual volume to binary string.
|
42
|
-
#
|
43
|
-
# @param [SMPTool::VirtualVolume::Volume] volume
|
44
|
-
#
|
45
|
-
# @return [String]
|
46
|
-
#
|
47
|
-
def _volume_to_binary(volume)
|
48
|
-
volume.to_binary_s
|
49
|
-
end
|
50
|
-
|
51
|
-
#
|
52
|
-
# Write data to a binary file.
|
53
|
-
#
|
54
|
-
# @param [String] path
|
55
|
-
#
|
56
|
-
# @param [String] data
|
57
|
-
# Binary string with the file's content.
|
58
|
-
#
|
59
|
-
def _write_bin_file(path, data)
|
60
|
-
Dry::Files.new.write(path, data)
|
61
|
-
end
|
62
15
|
end
|
63
16
|
end
|
64
17
|
end
|
@@ -17,12 +17,12 @@ module SMPTool
|
|
17
17
|
# @param [Hash{ Symbol => Object }] **_options
|
18
18
|
#
|
19
19
|
def _save_volume(path:, volume:, **_options)
|
20
|
-
|
21
|
-
@logger.debug "Converted to
|
20
|
+
bin_obj = volume.to_volume_io
|
21
|
+
@logger.debug "Converted to VolumeIO of #{bin_obj.num_bytes} bytes"
|
22
22
|
|
23
23
|
_write_bin_file(
|
24
24
|
path,
|
25
|
-
|
25
|
+
bin_obj
|
26
26
|
)
|
27
27
|
|
28
28
|
@logger.es_info "Changes saved to the file: '#{path}'"
|
@@ -44,11 +44,10 @@ module SMPTool
|
|
44
44
|
#
|
45
45
|
# @param [String] path
|
46
46
|
#
|
47
|
-
# @param [
|
48
|
-
# Binary string with the file's content.
|
47
|
+
# @param [Object] bin_obj
|
49
48
|
#
|
50
|
-
def _write_bin_file(path,
|
51
|
-
|
49
|
+
def _write_bin_file(path, bin_obj)
|
50
|
+
File.open(path, "wb") { |file| bin_obj.write(file) }
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
@@ -19,7 +19,7 @@ module SMPTool
|
|
19
19
|
|
20
20
|
f_arr.each do |f|
|
21
21
|
path = dry_files.join(@options[:dir], _filter_filename(f.filename))
|
22
|
-
|
22
|
+
_save_file(path, f)
|
23
23
|
@logger.info "File '#{path}' created"
|
24
24
|
end
|
25
25
|
|
@@ -34,7 +34,7 @@ module SMPTool
|
|
34
34
|
base + ext
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def _save_file(path, _file_obj); end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -6,9 +6,12 @@ module SMPTool
|
|
6
6
|
class ExtracterRawBase < ExtracterBase
|
7
7
|
private
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
9
|
+
def _save_file(path, file_obj)
|
10
|
+
_write_data(path, file_obj.data)
|
11
|
+
end
|
12
|
+
|
13
|
+
def _write_data(path, data)
|
14
|
+
File.binwrite(path, data)
|
12
15
|
end
|
13
16
|
|
14
17
|
def _filter_filename(filename)
|
@@ -6,9 +6,12 @@ module SMPTool
|
|
6
6
|
class ExtracterTxtBase < ExtracterBase
|
7
7
|
private
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
9
|
+
def _save_file(path, file_obj)
|
10
|
+
_write_data(path, file_obj.data.join("\n"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def _write_data(path, data)
|
14
|
+
File.binwrite(path, data)
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -30,39 +30,14 @@ module SMPTool
|
|
30
30
|
# @return [SMPTool::VirtualVolume::Volume]
|
31
31
|
#
|
32
32
|
def _load_volume(path:, **_options)
|
33
|
-
|
34
|
-
@logger.info "Read data from the file: '#{path}'"
|
35
|
-
|
36
|
-
vol = _parse_volume(b_str)
|
37
|
-
@logger.debug "Volume parsed"
|
33
|
+
io = File.binread(path)
|
38
34
|
|
39
|
-
|
40
|
-
end
|
35
|
+
@logger.info "Read data from the file: '#{path}'"
|
41
36
|
|
42
|
-
#
|
43
|
-
# Parse binary string to create a volume obj.
|
44
|
-
#
|
45
|
-
# @param [String] b_str
|
46
|
-
#
|
47
|
-
# @return [SMPTool::VirtualVolume::Volume]
|
48
|
-
#
|
49
|
-
def _parse_volume(b_str)
|
50
37
|
SMPTool::VirtualVolume::Volume.read_io(
|
51
|
-
|
38
|
+
io
|
52
39
|
)
|
53
40
|
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# Read a binary file.
|
57
|
-
#
|
58
|
-
# @param [String] path
|
59
|
-
#
|
60
|
-
# @return [String]
|
61
|
-
# Binary string with the file's content.
|
62
|
-
#
|
63
|
-
def _read_bin_file(path)
|
64
|
-
Dry::Files.new.read(path)
|
65
|
-
end
|
66
41
|
end
|
67
42
|
end
|
68
43
|
end
|
data/lib/smp_tool/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smp_tool-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 8bit-m8
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|