smp_tool-cli 0.2.0 → 0.2.2

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: c83c658d44b09650948b0d0b94e34250ac9a41b374651ed34ed64675678f122b
4
- data.tar.gz: a4052f1740f90749c0dd998850eef0c7d0e6bfd7c54fbb79d2f2dfad03ff9a05
3
+ metadata.gz: adad055504c98f44f46fe53874716c77d1a568b71e38900a21a06840468cff02
4
+ data.tar.gz: e1ea094b6e8fb72e20c7d2319179917d15db6b1107fdb77a59a2270f11eda2aa
5
5
  SHA512:
6
- metadata.gz: 780ab66ca40a0abebd11a47e6f1415429593776d4545c723b1ee94b72928a7e04f82d6a024d70835d12fc96bd7bca6c0824842b6b0f2eec54a5bbd8504d86790
7
- data.tar.gz: 5abbc23d7cbae441f7760a1d030fcc05ebd783c7d4c70bf7af037b0938f4e9a9471654f2357d91298ea890e2783f803c84b6b386a7eb9033e4e0798a5a1d8409
6
+ metadata.gz: badab3dbd9301537f6125e403985e1a416d7ce6b878238ae9c9c8436ba4bf5443359024cdd1ca7b8668a40f3044f670218dd7bb78ccfe8e1df23a0eb0ed16c2b
7
+ data.tar.gz: 2f893c57d253516e3ba72ba75e2042ba94d5c4faa1ff4e91eedd9f01a065755cef99a09b0309d7e8da897f980dc83fad9e918dccf055c806501482ee62a631ee
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.2.2] - 2024-03-18
2
+
3
+ * bug fix: directory creation
4
+
5
+ ## [0.2.1] - 2024-03-18
6
+
7
+ * bug fix: file read/write on MS Windows
8
+
1
9
  ## [0.2.0] - 2024-03-17
2
10
 
3
11
  * `--raw` option for the extract command
@@ -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
- b_str = _volume_to_binary(volume)
21
- @logger.debug "Converted to binary string"
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
- b_str
25
+ bin_obj
26
26
  )
27
27
 
28
28
  @logger.es_info "Changes saved to the file: '#{path}'"
@@ -44,11 +44,11 @@ module SMPTool
44
44
  #
45
45
  # @param [String] path
46
46
  #
47
- # @param [String] data
48
- # Binary string with the file's content.
47
+ # @param [Object] bin_obj
49
48
  #
50
- def _write_bin_file(path, data)
51
- Dry::Files.new.write(path, data)
49
+ def _write_bin_file(path, bin_obj)
50
+ Dry::Files.new.mkdir_p(path)
51
+ File.open(path, "wb") { |file| bin_obj.write(file) }
52
52
  end
53
53
  end
54
54
  end
@@ -17,9 +17,11 @@ module SMPTool
17
17
  def _output(f_arr)
18
18
  dry_files = Dry::Files.new
19
19
 
20
+ dry_files.mkdir(@options[:dir])
21
+
20
22
  f_arr.each do |f|
21
23
  path = dry_files.join(@options[:dir], _filter_filename(f.filename))
22
- _write_file(path, f)
24
+ _save_file(path, f)
23
25
  @logger.info "File '#{path}' created"
24
26
  end
25
27
 
@@ -34,7 +36,7 @@ module SMPTool
34
36
  base + ext
35
37
  end
36
38
 
37
- def _write_file(path, _file_obj); end
39
+ def _save_file(path, _file_obj); end
38
40
  end
39
41
  end
40
42
  end
@@ -6,9 +6,12 @@ module SMPTool
6
6
  class ExtracterRawBase < ExtracterBase
7
7
  private
8
8
 
9
- def _write_file(path, file_obj)
10
- dry_files = Dry::Files.new
11
- dry_files.write(path, file_obj.data)
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 _write_file(path, file_obj)
10
- dry_files = Dry::Files.new
11
- dry_files.write(path, file_obj.data.join("\n"))
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
- b_str = _read_bin_file(path)
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
- vol
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
- b_str
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SMPTool
4
4
  module CLI
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.2"
6
6
  end
7
7
  end
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.0
4
+ version: 0.2.2
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-17 00:00:00.000000000 Z
11
+ date: 2024-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli