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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c83c658d44b09650948b0d0b94e34250ac9a41b374651ed34ed64675678f122b
4
- data.tar.gz: a4052f1740f90749c0dd998850eef0c7d0e6bfd7c54fbb79d2f2dfad03ff9a05
3
+ metadata.gz: 3149aa9dc1f632c851d3eb26f0a7789a793915fade6999067efa2869b2190e38
4
+ data.tar.gz: 71b57cabecc20c1a3ef3f45f69a44a908349ee3a91783d54f911a42c3c10f58a
5
5
  SHA512:
6
- metadata.gz: 780ab66ca40a0abebd11a47e6f1415429593776d4545c723b1ee94b72928a7e04f82d6a024d70835d12fc96bd7bca6c0824842b6b0f2eec54a5bbd8504d86790
7
- data.tar.gz: 5abbc23d7cbae441f7760a1d030fcc05ebd783c7d4c70bf7af037b0938f4e9a9471654f2357d91298ea890e2783f803c84b6b386a7eb9033e4e0798a5a1d8409
6
+ metadata.gz: e558d4ce08db06194481a202b21e42b9e350a346f4c0819dfa493d25e1b06dbf3ed3ce83934c6aff390210d81465c8a3e3f37bde6ede2079cd1fa87f859d3efe
7
+ data.tar.gz: 60fca9c7337d7934b8b8f9270d8e9db3cdd57b2fe04eb48f133b91a2564cfb75cbe935a16597c17ffe9c5f13fca47dc0f933002ed5cafbf2f340807162832099
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.1] - 2024-03-18
2
+
3
+ * bug fix: file read/write on MS Windows
4
+
1
5
  ## [0.2.0] - 2024-03-17
2
6
 
3
7
  * `--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,10 @@ 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
+ 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
- _write_file(path, f)
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 _write_file(path, _file_obj); end
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 _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.1"
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.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-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